Systemfout.php 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemfout extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullorderamz','fullorderamz');
  14. $this->load->_model('Model_fullordersmt','fullordersmt');
  15. $this->load->_model('Model_outbound','outbound');
  16. $this->load->_model('Model_express','express');
  17. $this->load->_model('Model_shop','shop');
  18. $this->load->_model('Model_typeclass','typeclass');
  19. $this->load->_model('Model_country','country');
  20. $this->load->_model('Model_kdniao','kdniao');
  21. $this->load->_model('Model_notice','notice');
  22. $this->load->_model('Model_dhl','dhl');
  23. $this->load->_model('Model_dhlhz','dhlhz');
  24. $this->load->_model('Model_usps','usps');
  25. $this->load->_model('Model_fedex','fedex');
  26. $this->load->_model('Model_fedex_cby','fedex_cby');
  27. $this->load->_model('Model_ups','ups');
  28. $this->load->_model('Model_ali','ali');
  29. $this->load->_model('Model_dpd','dpd');
  30. $this->load->_model('Model_shop','shop');
  31. $this->load->_model('Model_user','user');
  32. $this->load->_model('Model_whlabel','whlabel');
  33. $this->load->_model('Model_specialstock','specialstock');
  34. $this->load->_model('Model_ck','ck');
  35. $this->load->_model('Model_whlabellabel','whlabellabel');
  36. $this->load->_model('Model_apiyy','apiyy');
  37. $this->load->helper('url');
  38. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  39. $this->load->_model('Model_systemtransfer','systemtransfer');
  40. $this->load->_model('Model_classid','classid');
  41. $this->load->_model('Model_allocation','allocation');
  42. $this->load->_model('Model_fullorderxw','fullorderxw');
  43. $this->load->_model('Model_fullorderpaypal','fullorderpaypal');
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_fedexv1",'fedexv1');
  46. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  47. $this->load->_model("Model_customsdeclaration","customsdeclaration");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg,$arg_array)
  51. {
  52. if($arg == 'fedexhz')
  53. {
  54. $this->_fedexhz();
  55. }
  56. else if($arg == 'fout')
  57. {
  58. $this->_fout($arg_array);
  59. }
  60. else if($arg == 'fouthb')//合并出库的
  61. {
  62. $this->_fouthb($arg_array);
  63. }
  64. else if($arg == 'excel')
  65. {
  66. $this->_excel($arg_array);
  67. }
  68. else if($arg == 'cpexcel')
  69. {
  70. $this->_cpexcel($arg_array);
  71. }
  72. else if($arg == 'orderyz')
  73. {
  74. $this->_orderyz();
  75. }
  76. else if($arg == 'hwyz')
  77. {
  78. $this->_hwyz();
  79. }
  80. else if($arg == 'outnumber')
  81. {
  82. $this->_outnumber();
  83. }
  84. else if($arg == 'hb')
  85. {
  86. $this->_hb();
  87. }
  88. else if($arg == 'indexmc'){
  89. $this->_indexmc();
  90. }
  91. else
  92. {
  93. $this->_index();
  94. }
  95. }
  96. public function _index()
  97. {
  98. $post = $this->input->post(NULL, TRUE);
  99. $xw = '';
  100. if(isset($_SESSION['api']))
  101. {
  102. $user = $this->user->get_api($_SESSION['api']);
  103. $usp = $user;
  104. $fgshop = "";$sid = "";$wid="";$wtype="";
  105. $usersp = explode('|',trim($user['shop'],'|'));
  106. $userwh = explode('|',trim($user['warehouse'],'|'));
  107. foreach ($usersp as $value)
  108. {
  109. $fgshop .= " shop = ".$value." or";
  110. $sid .= " id = ".$value." or";
  111. }
  112. foreach ($userwh as $value)
  113. {
  114. $wid .= " id = ".$value." or";
  115. $wtype .= " type = ".$value." or";
  116. }
  117. if($user['userid'] == 'xw')
  118. {
  119. $xw = 1;
  120. }
  121. }
  122. if(isset($post['page']))
  123. {
  124. $page = $this->input->post('page',true);
  125. $perpage = $this->input->post('perpage',true);
  126. $timetk = $this->input->post('timetk',true);
  127. $timetj = $this->input->post('timetj',true);
  128. $shop = $this->input->post('shop',true);
  129. $source = $this->input->post('source',true);
  130. $orderinfo = $this->input->post('orderinfo',true);
  131. $number = $this->input->post('number',true);
  132. $library = $this->input->post('library',true);
  133. $waybill = $this->input->post('waybill',true);
  134. $express = $this->input->post('express',true);
  135. $type = $this->input->post('type',true);
  136. $lowe = $this->input->post('lowe',true);
  137. $so = $this->input->post('so',true);
  138. $is_jiaji = $this->input->post('is_jiaji',true);
  139. $librarytime = $this->input->post('librarytime',true);
  140. $timetk = strtotime($timetk);
  141. $timetj = strtotime($timetj);
  142. $cxtime = 'id';
  143. $where = "library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")";
  144. if($timetk && $timetj && $library == 1)
  145. {
  146. //$cxtime = 'reviewtime';
  147. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  148. $where .= " and state != 217";
  149. }
  150. else if($timetk && $timetj && $library == 2)
  151. {
  152. $cxtime = 'librarytime';
  153. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  154. }
  155. if($shop)
  156. {
  157. $where .= " and shop = '$shop'";
  158. }
  159. if($number)
  160. {
  161. $where .= " and number = '$number'";
  162. }
  163. if($library)
  164. {
  165. $where .= " and library = '$library'";
  166. }
  167. if($waybill)
  168. {
  169. $where .= " and waybill = '$waybill'";
  170. }
  171. if($express)
  172. {
  173. $where .= " and express = '$express'";
  174. }
  175. if($orderinfo)
  176. {
  177. $where .= " and orderinfo = '$orderinfo'";
  178. }
  179. if($type)
  180. {
  181. $where .= " and type = '$type'";
  182. }
  183. if($lowe)
  184. {
  185. $where .= " and shipremarks like '%$lowe%'";
  186. }
  187. if($so)
  188. {
  189. $where .= " and shipremarks like '%$so%'";
  190. }
  191. if($is_jiaji >-1){
  192. $where .= " and is_jiaji = ".$is_jiaji." ";
  193. }
  194. //数据排序
  195. $order_str = $cxtime." desc";
  196. if(empty($page))
  197. {
  198. $start = 0;
  199. $perpage = 1;
  200. }
  201. else
  202. {
  203. $start = ($page - 1)*$perpage;
  204. }
  205. //取得信息列表
  206. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  207. //格式化数据
  208. foreach ($info_list as $key=>$value)
  209. {
  210. $shop = $this->shop->read($value['shop']);
  211. $info_list[$key]['shop'] = $shop['shopname'];
  212. if($value['waybill'] == '0')
  213. {
  214. $info_list[$key]['waybill'] = "";
  215. }
  216. $express = $this->express->read($value['express']);
  217. $info_list[$key]['express'] = $express['servicename'];
  218. $warehouse = $this->warehouse->read($value['type']);
  219. $info_list[$key]['type'] = $warehouse['title'];
  220. if($value['print'] == 1)
  221. {
  222. $info_list[$key]['print'] = '不可打印';
  223. }
  224. else if($value['print'] == 2)
  225. {
  226. $info_list[$key]['print'] = '未打印';
  227. }
  228. else if($value['print'] == 3)
  229. {
  230. $info_list[$key]['print'] = '已打印';
  231. }
  232. if($value['library'] == 1)
  233. {
  234. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  235. }
  236. else if($value['library'] == 2)
  237. {
  238. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  239. }
  240. else if($value['library'] == 3)
  241. {
  242. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  243. }
  244. if($value['librarytime'] == '0')
  245. {
  246. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  247. }
  248. else
  249. {
  250. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  251. }
  252. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  253. }
  254. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  255. //格式化数据
  256. foreach ($info_listtt as $key=>$value)
  257. {
  258. $shop = $this->shop->read($value['shop']);
  259. $info_listtt[$key]['shop'] = $shop['shopname'];
  260. if($value['waybill'] == '0')
  261. {
  262. $info_listtt[$key]['waybill'] = "";
  263. }
  264. $express = $this->express->read($value['express']);
  265. $info_listtt[$key]['express'] = $express['servicename'];
  266. $warehouse = $this->warehouse->read($value['type']);
  267. $info_listtt[$key]['type'] = $warehouse['title'];
  268. if($value['print'] == 1)
  269. {
  270. $info_listtt[$key]['print'] = '不可打印';
  271. }
  272. else if($value['print'] == 2)
  273. {
  274. $info_listtt[$key]['print'] = '未打印';
  275. }
  276. else if($value['print'] == 3)
  277. {
  278. $info_listtt[$key]['print'] = '已打印';
  279. }
  280. if($value['library'] == 1)
  281. {
  282. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  283. }
  284. else if($value['library'] == 2)
  285. {
  286. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  287. }
  288. else if($value['library'] == 3)
  289. {
  290. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  291. }
  292. if($value['librarytime'] == '0')
  293. {
  294. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  295. }
  296. else
  297. {
  298. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  299. }
  300. }
  301. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  302. //格式化数据
  303. foreach ($info_listamz as $key=>$value)
  304. {
  305. $shop = $this->shop->read($value['shop']);
  306. $info_listamz[$key]['shop'] = $shop['shopname'];
  307. if($value['waybill'] == '0')
  308. {
  309. $info_listamz[$key]['waybill'] = "";
  310. }
  311. $express = $this->express->read($value['express']);
  312. $info_listamz[$key]['express'] = $express['servicename'];
  313. $warehouse = $this->warehouse->read($value['type']);
  314. $info_listamz[$key]['type'] = $warehouse['title'];
  315. if($value['print'] == 1)
  316. {
  317. $info_listamz[$key]['print'] = '不可打印';
  318. }
  319. else if($value['print'] == 2)
  320. {
  321. $info_listamz[$key]['print'] = '未打印';
  322. }
  323. else if($value['print'] == 3)
  324. {
  325. $info_listamz[$key]['print'] = '已打印';
  326. }
  327. if($value['library'] == 1)
  328. {
  329. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  330. }
  331. else if($value['library'] == 2)
  332. {
  333. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  334. }
  335. else if($value['library'] == 3)
  336. {
  337. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  338. }
  339. if($value['librarytime'] == '0')
  340. {
  341. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  342. }
  343. else
  344. {
  345. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  346. }
  347. }
  348. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  349. //格式化数据
  350. foreach ($info_listxw as $key=>$value)
  351. {
  352. $shop = $this->shop->read($value['shop']);
  353. $info_listxw[$key]['shop'] = $shop['shopname'];
  354. if($value['waybill'] == '0')
  355. {
  356. $info_listxw[$key]['waybill'] = "";
  357. }
  358. $express = $this->express->read($value['express']);
  359. $info_listxw[$key]['express'] = $express['servicename'];
  360. $warehouse = $this->warehouse->read($value['type']);
  361. $info_listxw[$key]['type'] = $warehouse['title'];
  362. if($value['print'] == 1)
  363. {
  364. $info_listxw[$key]['print'] = '不可打印';
  365. }
  366. else if($value['print'] == 2)
  367. {
  368. $info_listxw[$key]['print'] = '未打印';
  369. }
  370. else if($value['print'] == 3)
  371. {
  372. $info_listxw[$key]['print'] = '已打印';
  373. }
  374. if($value['library'] == 1)
  375. {
  376. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  377. }
  378. else if($value['library'] == 2)
  379. {
  380. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  381. }
  382. else if($value['library'] == 3)
  383. {
  384. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  385. }
  386. if($value['librarytime'] == '0')
  387. {
  388. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  389. }
  390. else
  391. {
  392. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  393. }
  394. }
  395. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  396. //格式化数据
  397. foreach ($info_listsmt as $key=>$value)
  398. {
  399. $shop = $this->shop->read($value['shop']);
  400. $info_listsmt[$key]['shop'] = $shop['shopname'];
  401. if($value['waybill'] == '0')
  402. {
  403. $info_listsmt[$key]['waybill'] = "";
  404. }
  405. $express = $this->express->read($value['express']);
  406. $info_listsmt[$key]['express'] = $express['servicename'];
  407. $warehouse = $this->warehouse->read($value['type']);
  408. $info_listsmt[$key]['type'] = $warehouse['title'];
  409. if($value['print'] == 1)
  410. {
  411. $info_listsmt[$key]['print'] = '不可打印';
  412. }
  413. else if($value['print'] == 2)
  414. {
  415. $info_listsmt[$key]['print'] = '未打印';
  416. }
  417. else if($value['print'] == 3)
  418. {
  419. $info_listsmt[$key]['print'] = '已打印';
  420. }
  421. if($value['library'] == 1)
  422. {
  423. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  424. }
  425. else if($value['library'] == 2)
  426. {
  427. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  428. }
  429. else if($value['library'] == 3)
  430. {
  431. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  432. }
  433. if($value['librarytime'] == '0')
  434. {
  435. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  436. }
  437. else
  438. {
  439. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  440. }
  441. }
  442. $total = $this->fullorder->find_count($where);
  443. $total += $this->fullordertt->find_count($where);
  444. $total += $this->fullorderamz->find_count($where);
  445. $total += $this->fullorderxw->find_count($where);
  446. $total += $this->fullordersmt->find_count($where);
  447. $pagenum = ceil($total/$perpage);
  448. $over = $total-($start+$perpage);
  449. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
  450. echo json_encode($rows);exit;
  451. }
  452. if(isset($_SESSION['api']))
  453. {
  454. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  455. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  456. $this->data['wlshop'] = $wlshop;
  457. $this->data['warehouse'] = $warehouse;
  458. }
  459. $this->data['xw'] = $xw;
  460. $this->_Template('systemfout',$this->data);
  461. }
  462. public function _indexmc()
  463. {
  464. $post = $this->input->post(NULL, TRUE);
  465. $xw = '';
  466. if(isset($_SESSION['api']))
  467. {
  468. $user = $this->user->get_api($_SESSION['api']);
  469. $usp = $user;
  470. $fgshop = "";$sid = "";$wid="";$wtype="";
  471. $usersp = explode('|',trim($user['shop'],'|'));
  472. $userwh = explode('|',trim($user['warehouse'],'|'));
  473. foreach ($usersp as $value)
  474. {
  475. $fgshop .= " shop = ".$value." or";
  476. $sid .= " id = ".$value." or";
  477. }
  478. foreach ($userwh as $value)
  479. {
  480. $wid .= " id = ".$value." or";
  481. $wtype .= " type = ".$value." or";
  482. }
  483. if($user['userid'] == 'xw')
  484. {
  485. $xw = 1;
  486. }
  487. }
  488. if(isset($_SESSION['api']))
  489. {
  490. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  491. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  492. $this->data['wlshop'] = $wlshop;
  493. $this->data['warehouse'] = $warehouse;
  494. }
  495. $this->data['xw'] = $xw;
  496. $this->_Template('systemfoutmc',$this->data);
  497. }
  498. public function _fout()
  499. {
  500. $post = $this->input->post(NULL, TRUE);
  501. if(isset($post['order']))
  502. {
  503. $time = time();
  504. $order = $this->input->post('order',true);
  505. $weight = $this->input->post('weight',true);
  506. if(!isset($weight))//测试没问题后可以删
  507. {
  508. $weight = '';
  509. }
  510. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  511. {
  512. $order = substr($order,0,12);
  513. }
  514. if(strlen($order) == '34')//联邦杭州超长运单截取
  515. {
  516. $str = substr($order, 0,3);
  517. if($str == "420"){
  518. $order = substr($order,12);
  519. }else{
  520. $order = substr($order,22,12);
  521. }
  522. }
  523. if(!$order)
  524. {
  525. echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
  526. }
  527. if(strlen($order) == 30)
  528. {
  529. $order = substr($order, 8);
  530. }
  531. $fullorder_name = 'fullorder';$outtype = 1;
  532. $y = $this->fullorder->get_waybill($order);
  533. // $this->logic_ding->sendToDing("排查五次数据的原有".$order);
  534. // $this->logic_ding->sendToDing("排查五次数据的订单".json_encode($y));
  535. if(!$y)
  536. {
  537. $y = $this->fullorder->get_number($order);
  538. $outtype = 2;
  539. // $this->logic_ding->sendToDing("排查五次数据的原有".$order);
  540. // $this->logic_ding->sendToDing("排查五次数据的订单".json_encode($y));
  541. if(!$y)
  542. {
  543. $fullorder_name = 'fullordersmt';$outtype = 1;
  544. $y = $this->fullordersmt->get_waybill($order);
  545. if(!$y)
  546. {
  547. $y = $this->fullordersmt->get_number($order);
  548. $outtype = 2;
  549. if(!$y)
  550. {
  551. $fullorder_name = 'fullordertt';$outtype = 1;
  552. $y = $this->fullordertt->get_waybill($order);
  553. if(!$y)
  554. {
  555. $y = $this->fullordertt->get_number($order);
  556. $outtype = 2;
  557. if(!$y)
  558. {
  559. $fullorder_name = 'fullorderamz';$outtype = 1;
  560. $y = $this->fullorderamz->get_waybill($order);
  561. if(!$y)
  562. {
  563. $y = $this->fullorderamz->get_number($order);
  564. $outtype = 2;
  565. if(!$y){
  566. $fullorder_name = 'fullorderxw';$outtype = 1;
  567. $y = $this->fullorderxw->get_waybill($order);
  568. if(!$y)
  569. {
  570. $y = $this->fullorderxw->get_number($order);
  571. $outtype = 2;
  572. if(!$y)
  573. {
  574. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  575. }
  576. }
  577. }
  578. }
  579. }
  580. }
  581. }
  582. }
  583. }
  584. }
  585. if($y['mergeid'] == '1')
  586. {
  587. $y = $this->$fullorder_name->read($y['merge']);
  588. }
  589. //云尚-FedEx普货专线 如果出库时打印的快递面单超过6天,不允许出库
  590. if($y['express'] == 75){
  591. $printtime = $y['printtime'];
  592. $set_time = 24 * 60 * 60 * 6;
  593. $time = time();
  594. if(($time - $set_time) > $printtime){
  595. //允许出库状态
  596. if($y['libraryconfirm'] == 2){
  597. echo json_encode(array('msg'=>"该单超时,请重新打印后再出库。".$y['number'],'success'=>false));exit;
  598. }else{
  599. echo json_encode(array('msg'=>"该单超时且禁止出库,请联系梦体做后续处理!".$y['number'],'success'=>false));exit;
  600. }
  601. }
  602. }
  603. // 66 云途(欧洲) 67 云途(欧洲)-带保险 如果是欧洲云途 需要检擦出库时间是否超过15天
  604. if(in_array($y['express'],[66,67])){
  605. if((time() - $y['printtime']) >= (15*24*3600)){
  606. echo json_encode(array('msg'=>'运单超时!请联系梦体处理!','success'=>false));exit;
  607. }
  608. }
  609. $express = $this->express->read($y['express']);
  610. if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
  611. {
  612. $y['librarynot'] = '客户已取消!';
  613. }
  614. if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
  615. {
  616. echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
  617. }
  618. if($y['library'] > 1)
  619. {
  620. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  621. }
  622. if($express['out'] != 3)
  623. {
  624. if($express['out'] != $outtype)
  625. {
  626. $smlx = ($express['out']=='1')?'运单':'发货单';
  627. echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
  628. }
  629. }
  630. if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
  631. {
  632. $y['waybill'] = trim($y['waybill'],' ');
  633. if(strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50 && $y['express'] != 51 && $y['express'] != 63 && $y['express'] != 70 && $y['express'] != 71 && $y['express'] != 73 && $y['express'] != 74 && $y['express'] != 75 && $y['express'] != 78)
  634. {
  635. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit;
  636. }
  637. else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42 && $y['express'] != 69 && $y['express'] != 78)
  638. {
  639. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit;
  640. }
  641. else if(strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67 && $y['express'] != 72)
  642. {
  643. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit;
  644. }
  645. else if(strlen($y['waybill']) == 16 && $y['express'] != 76 && $y['express'] != 77 )
  646. {
  647. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-4','success'=>false));exit;
  648. }
  649. }
  650. if(stripos($weight,',') !== false){
  651. $tmp_arr = explode(",",$weight);
  652. $weight = end($tmp_arr);
  653. $numweight = (float)$weight;
  654. $weight = $numweight."kg";
  655. }
  656. $numweight = str_replace('kg','',$weight);
  657. // if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
  658. // {
  659. // if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  660. // {
  661. // echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  662. // }
  663. // $yzweight = explode('.',$numweight);
  664. // if($yzweight[0] == '')
  665. // {
  666. // echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  667. // }
  668. // if($numweight < ($y['jweight']/1000))
  669. // {
  670. // echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  671. // }
  672. // if($numweight -($y['jweight']/1000) > 0.9 && $y['number'] != 'QQS-30401-002')
  673. // {
  674. // echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会或梦体处理!','success'=>false));exit;
  675. // }
  676. // if($numweight > '0.98' && $y['express'] == '3')
  677. // {
  678. // echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
  679. // }
  680. // if($numweight > '2' && $y['express'] == '37')
  681. // {
  682. // echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
  683. // }
  684. // if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
  685. // {
  686. // echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
  687. // }
  688. // }
  689. //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
  690. //还有翔文仓库的 不执行
  691. //源代码是
  692. //所有快递必须称重
  693. //所有快递必须称重 翔文除外
  694. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
  695. if(!in_array($y['express'],[2,8,39,43,44,45,47,48,49,55,61,63,64,65,74])){
  696. if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  697. {
  698. echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  699. }
  700. $yzweight = explode('.',$numweight);
  701. if($yzweight[0] == '')
  702. {
  703. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  704. }
  705. if(empty($numweight)){
  706. echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
  707. }
  708. //$this->logic_ding->sendToDing("检测订单---------------------标记需要认证的东西".$y['number']);
  709. }
  710. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']);
  711. $express_info = $this->express->read($y['express']);
  712. if(empty($express_info)){
  713. echo json_encode(array('msg'=>'该快递信息异常,请联系技术!','success'=>false));exit;
  714. }
  715. $weight_limit = $express_info['weight_limit']*1;
  716. if($weight_limit > 0){
  717. $yzweight = explode('.',$numweight);
  718. if($yzweight[0] == '')
  719. {
  720. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  721. }
  722. if($numweight < ($y['jweight']/1000)){
  723. echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  724. }
  725. //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
  726. if(in_array($y['express'],[3,24,42])){
  727. //规定实际重量不允许超过 净重为1kg
  728. if($numweight -($y['jweight']/1000) > 1 )
  729. {
  730. echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false));exit;
  731. }
  732. }
  733. if($weight_limit < $numweight){
  734. echo json_encode(array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false));exit;
  735. }
  736. }
  737. if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
  738. {
  739. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  740. }
  741. if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
  742. {
  743. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  744. echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit;
  745. }
  746. if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
  747. {
  748. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  749. }
  750. $this->db->trans_begin();
  751. $warehouse = $this->warehouse->read($y['type']);
  752. $bdck = $warehouse['bdck'];
  753. if($warehouse['zd'] == '1')
  754. {
  755. if($warehouse['bdck'] == '')
  756. {
  757. echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
  758. }
  759. $wh = $this->_fout_db($y,$warehouse,$bdck);
  760. if($wh['fh'] == 2)
  761. {
  762. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  763. if($kcyz['t'] == '0')
  764. {
  765. if($kcyz['fpdata'] != '')
  766. {
  767. $x['whlabel'] = $kcyz['whlabel'];
  768. $x['fpdata'] = $kcyz['fpdata'];
  769. $y['whlabel'] = $x['whlabel'];
  770. $this->$fullorder_name->save($x,$y['id']);
  771. }
  772. }
  773. $wh = $this->_fout_db($y,$warehouse,$bdck);
  774. if($wh['fh'] == 2)
  775. {
  776. echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
  777. }
  778. }
  779. foreach ($wh['sj'] as $v)
  780. {
  781. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  782. }
  783. }
  784. /**
  785. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
  786. {
  787. $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  788. $cpsl = 0;
  789. $pp = explode('|',trim($y['whlabel'],'|'));
  790. foreach ($pp as $va)
  791. {
  792. $num = explode('-',$va);
  793. $cpsl += $num[1];
  794. }
  795. if(count($whlabel) != $cpsl)
  796. {
  797. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  798. }
  799. foreach ($whlabel as $v)
  800. {
  801. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  802. }
  803. }
  804. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
  805. {
  806. $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
  807. $cpsl = 0;
  808. $pp = explode('|',trim($y['whlabel'],'|'));
  809. foreach ($pp as $va)
  810. {
  811. $num = explode('-',$va);
  812. if(stripos($num[2],'z') !== false)//如果是特殊库存
  813. {
  814. $cpsl += $num[1];
  815. }
  816. }
  817. if(count($wh) != $cpsl)
  818. {
  819. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  820. }
  821. foreach ($wh as $v)
  822. {
  823. if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
  824. {
  825. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  826. }
  827. }
  828. }
  829. **/
  830. /**
  831. if($y['dbapi'] == 99 && $y['scapi'] == 99)
  832. {
  833. $d = $this->apiyy->get_chd($y);
  834. if($d['Data'][0]['m_isSucess'] != 1)
  835. {
  836. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  837. }
  838. }
  839. $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
  840. if(isset($systemtransfer[0]))
  841. {
  842. foreach ($systemtransfer as $v)
  843. {
  844. if($v['dbapi'] != 99)
  845. {
  846. echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
  847. }
  848. }
  849. $y['ts'] = count($systemtransfer);
  850. $d = $this->apiyy->get_chd($y);
  851. if($d['Data'][0]['m_isSucess'] != 1)
  852. {
  853. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  854. }
  855. }
  856. **/
  857. $shop = $this->shop->read($y['shop']);
  858. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  859. {
  860. $type = $this->typeclass->read($shop['type']);
  861. $y['shoptype'] = $type['title'];
  862. $y['weight'] = $weight;
  863. $d = $this->dhl->get_data_9610($y);
  864. if($d != 1)
  865. {
  866. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  867. echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
  868. }
  869. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  870. }
  871. if($fullorder_name == 'fullordersmt')
  872. {
  873. $stt = ($y['waybill']!='')?209:$y['state'];
  874. $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  875. /**
  876. if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  877. {
  878. echo json_encode(array('success'=>true));exit;
  879. }
  880. else
  881. {
  882. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  883. }
  884. **/
  885. }
  886. else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
  887. {
  888. /**
  889. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  890. {
  891. echo json_encode(array('success'=>true));exit;
  892. }
  893. else
  894. {
  895. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  896. }
  897. **/
  898. $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  899. }
  900. else
  901. {
  902. /**
  903. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  904. {
  905. echo json_encode(array('success'=>true));exit;
  906. }
  907. else
  908. {
  909. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  910. }
  911. **/
  912. $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  913. }
  914. /**
  915. if($fullorder_name == 'fullorder')
  916. {
  917. $orderinfo = preg_replace('/^' . preg_quote($y['shop'], '/') . '/', '', $y['orderinfo']);
  918. $post['incrementId'] = $orderinfo;
  919. $post['trackingNumber'] = $y['waybill'];
  920. $ex = $this->express->read($y['express']);
  921. $post['carrier'] = $ex['iscode'];
  922. $url = 'https://www.romandhair.com/applepay/payment/addTrack';
  923. $ch = curl_init();
  924. curl_setopt($ch,CURLOPT_URL,$url);
  925. curl_setopt($ch, CURLOPT_POST, 1);
  926. curl_setopt($ch, CURLOPT_HEADER, 0);
  927. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  928. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  929. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  930. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  931. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  932. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  933. $res = curl_exec($ch);
  934. curl_close($ch);
  935. $res = json_decode($res,true);
  936. if($res['success'] == 0)
  937. {
  938. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'cw'=>$res['msg']));//失败
  939. }
  940. else
  941. {
  942. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'type'=>1));
  943. }
  944. }
  945. **/
  946. //开始录入执行u9队列的数据
  947. $queue_u9_list = [];
  948. $queue_u9_list[] = [
  949. 'platform'=>$fullorder_name,
  950. 'warehouse'=>$y['type'],
  951. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  952. 'order_no'=>$y['number'],
  953. 'status'=>0,
  954. 'create_time'=>time(),
  955. 'update_time'=>time(),
  956. ];
  957. //将要执行的队列数据添加进去
  958. foreach($queue_u9_list as $item){
  959. if($item['platform'] != 'fullorderxw'){
  960. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  961. // $this->zzquque_u9->insert($item);
  962. // }
  963. if( !in_array($item['warehouse'],[5,7,8,9]) ){
  964. $this->zzquque_u9->insert($item);
  965. }
  966. }
  967. }
  968. $this->logic_ding->sendToDing("u9小单队列监听数据".json_encode($queue_u9_list,JSON_UNESCAPED_UNICODE));
  969. if($outtype == 2 && $y['printnumber'] > 1)
  970. {
  971. $p = json_encode($post);
  972. echo json_encode(array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false));exit;
  973. }
  974. $this->$fullorder_name->save($post,$y['id']);
  975. //合并订单自动发货
  976. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  977. $post['waybill'] = $y['waybill'];
  978. $post['express'] = $y['express'];
  979. $post['printtype'] = $y['printtype'];
  980. $post['ioss'] = $y['ioss'];
  981. $post['review'] = 6;
  982. $post['bx'] = $y['bx'];
  983. $post['qm'] = $y['qm'];
  984. $post['js'] = $y['js'];
  985. //$post['state'] = 216;
  986. $post['print'] = $y['print'];
  987. $post['printtime'] = $y['printtime'];
  988. $post['library'] = 2;
  989. $post['librarytime'] = $time;
  990. $post['libraryconfirm'] = 2;
  991. $post['librarynot'] = '';
  992. foreach ($hb as $v)
  993. {
  994. $post['state'] = $v['state'];
  995. $vshop = $this->shop->read($v['shop']);
  996. $vwarehouse = $this->warehouse->read($v['type']);
  997. $this->$fullorder_name->save($post,$v['id']);
  998. //2025年1月25日发现翔文合并订单发现此问题
  999. if($warehouse['zd'] == '1'){
  1000. $wh = $this->_fout_db($v,$warehouse,$bdck);
  1001. foreach ($wh['sj'] as $vv)
  1002. {
  1003. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  1004. }
  1005. }
  1006. }
  1007. if ($this->db->trans_status() === TRUE)
  1008. {
  1009. $this->db->trans_commit();
  1010. echo json_encode(array('success'=>true));
  1011. }
  1012. else
  1013. {
  1014. $this->db->trans_rollback();
  1015. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  1016. }
  1017. }
  1018. }
  1019. //之所以用订单已占的库存,就循环更新 为什么不用全部检索是因为牵扯到可能是工厂有可能直接生产后 带到成品库 不入成品库 可能会直接发走,所以只检索已占库存的订单 然后更新
  1020. public function _outnumber()//对比占单是否正确
  1021. {
  1022. $post = $this->input->post(NULL, TRUE);
  1023. if(isset($post['outnumber']))
  1024. {
  1025. $post = $this->input->post('post',true);
  1026. $fullorder_name = $this->input->post('fullorder_name',true);
  1027. $outnumber = $this->input->post('outnumber',true);
  1028. $post = json_decode($post,true);
  1029. $y = $this->$fullorder_name->read($outnumber);
  1030. if(empty($y)){
  1031. echo json_encode(array('msg'=>'订单异常不能出库','success'=>false));exit;
  1032. }
  1033. $warehouse = $this->warehouse->read($y['type']);
  1034. if(empty($warehouse)){
  1035. echo json_encode(array('msg'=>'仓库异常不能出库','success'=>false));exit;
  1036. }
  1037. if($y['library']== 2){
  1038. echo json_encode(array('msg'=>'订单已出库,请勿重复出库','success'=>false));exit;
  1039. }
  1040. if($y['library']== 3){
  1041. echo json_encode(array('msg'=>'订单已退库,请勿重复出库','success'=>false));exit;
  1042. }
  1043. $bdck = $warehouse['bdck'];
  1044. if(!empty($bdck)){
  1045. // $warehouse = $this->warehouse->read($y['type']);
  1046. $list = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  1047. $this->db->trans_begin();
  1048. foreach ($list as $v)
  1049. {
  1050. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$post['librarytime'],'time'=>$post['librarytime']),$v['id']);
  1051. }
  1052. $this->$fullorder_name->save($post,$y['id']);
  1053. if ($this->db->trans_status() === TRUE)
  1054. {
  1055. $this->db->trans_commit();
  1056. if($fullorder_name != 'fullorderxw'){
  1057. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  1058. // $this->zzquque_u9->insert($item);
  1059. // }
  1060. $y = $this->$fullorder_name->read($outnumber);
  1061. if( !in_array($y['type'],[5,7,8,9]) ){
  1062. $data = [
  1063. 'platform'=>$fullorder_name,
  1064. 'warehouse'=>$y['type'],
  1065. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  1066. 'order_no'=>$y['number'],
  1067. 'status'=>0,
  1068. 'create_time'=>time(),
  1069. 'update_time'=>time(),
  1070. ];
  1071. $this->zzquque_u9->insert($data);
  1072. }
  1073. }
  1074. echo json_encode(array('success'=>true));
  1075. }
  1076. else
  1077. {
  1078. $this->db->trans_rollback();
  1079. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  1080. }
  1081. }else{
  1082. $this->$fullorder_name->save($post,$y['id']);
  1083. if($fullorder_name != 'fullorderxw'){
  1084. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  1085. // $this->zzquque_u9->insert($item);
  1086. // }
  1087. $y = $this->$fullorder_name->read($outnumber);
  1088. if( !in_array($y['type'],[5,7,8,9]) ){
  1089. $data = [
  1090. 'platform'=>$fullorder_name,
  1091. 'warehouse'=>$y['type'],
  1092. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  1093. 'order_no'=>$y['number'],
  1094. 'status'=>0,
  1095. 'create_time'=>time(),
  1096. 'update_time'=>time(),
  1097. ];
  1098. $this->zzquque_u9->insert($data);
  1099. }
  1100. }
  1101. echo json_encode(array('success'=>true));
  1102. }
  1103. }
  1104. }
  1105. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  1106. {
  1107. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  1108. $cpsl = 0;
  1109. $pp = explode('|',trim($y['whlabel'],'|'));
  1110. foreach ($pp as $va)
  1111. {
  1112. $num = explode('-',$va);
  1113. if(isset($num[2]))
  1114. {
  1115. if(stripos($num[2],$warehouse['hz']) !== false)
  1116. {
  1117. $cpsl += $num[1];
  1118. }
  1119. }
  1120. }
  1121. if(count($wh) == $cpsl)
  1122. {
  1123. return array('fh'=>1,'sj'=>$wh);
  1124. }
  1125. else
  1126. {
  1127. return array('fh'=>2);
  1128. }
  1129. }
  1130. public function _fedexhz()
  1131. {
  1132. $post = $this->input->post(NULL, TRUE);
  1133. if(isset($post['id']))
  1134. {
  1135. $id = $this->input->post('id',true);
  1136. $fullorder_name = $this->input->post('name',true);
  1137. $express = $this->input->post('express',true);
  1138. $express = $this->express->read($express);
  1139. $fullorder = $this->$fullorder_name->read($id);
  1140. if($fullorder['type'] == '2')
  1141. {
  1142. $fullorder['type'] = 1;
  1143. }
  1144. $time = time();
  1145. $fullorder = $this->_text($fullorder);//获取所需信息
  1146. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  1147. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  1148. $time = time();
  1149. if($express['printcode'] == "FEDEXGF")
  1150. {
  1151. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  1152. //升级的api
  1153. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  1154. if($barcode['x'] == 1)
  1155. {
  1156. $bctime = date('Ymd',$time);
  1157. $Hwaybill = $barcode['waybill'];
  1158. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1159. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1160. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1161. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1162. if(isset($barcode['label']) && isset($Hwaybill))
  1163. {
  1164. if($fullorder['waybill'] != "")
  1165. {
  1166. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1167. }
  1168. else
  1169. {
  1170. $oldwaybill = $fullorder['oldwaybill'];
  1171. }
  1172. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1173. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1174. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1175. {
  1176. $warehouse = $this->warehouse->read($fullorder['type']);
  1177. $text = array();
  1178. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1179. $text['number'] = $fullorder['number'];
  1180. $text['mode'] = '95';
  1181. $text['pdfnum'] = 1;
  1182. $rows = array('text'=>$text);
  1183. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1184. }
  1185. else
  1186. {
  1187. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  1188. }
  1189. }
  1190. }
  1191. else
  1192. {
  1193. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1194. }
  1195. }
  1196. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  1197. {
  1198. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  1199. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1200. if($barcode['x'] == 1)
  1201. {
  1202. $bctime = date('Ymd',$time);
  1203. $Hwaybill = $barcode['waybill'];
  1204. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1205. if(isset($barcode['label']) && isset($Hwaybill))
  1206. {
  1207. if($fullorder['waybill'] != "")
  1208. {
  1209. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1210. }
  1211. else
  1212. {
  1213. $oldwaybill = $fullorder['oldwaybill'];
  1214. }
  1215. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1216. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1217. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1218. {
  1219. $type = 1;
  1220. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  1221. }
  1222. }
  1223. }
  1224. else
  1225. {
  1226. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1227. }
  1228. }
  1229. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  1230. {
  1231. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  1232. if($barcode['c'] == 1)
  1233. {
  1234. $bctime = date('Ymd',$time);
  1235. $Hwaybill = $barcode['data']['waybill'];
  1236. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  1237. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  1238. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  1239. {
  1240. if($fullorder['waybill'] != "")
  1241. {
  1242. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1243. }
  1244. else
  1245. {
  1246. $oldwaybill = $fullorder['oldwaybill'];
  1247. }
  1248. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1249. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  1250. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1251. {
  1252. $warehouse = $this->warehouse->read($fullorder['type']);
  1253. $text = array();
  1254. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1255. $text['number'] = $fullorder['number'];
  1256. $text['mode'] = '95';
  1257. $text['pdfnum'] = 1;
  1258. $rows = array('text'=>$text);
  1259. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1260. }
  1261. }
  1262. }
  1263. else
  1264. {
  1265. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1266. }
  1267. }
  1268. else
  1269. {
  1270. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  1271. }
  1272. }
  1273. }
  1274. public function _text($fullorder)
  1275. {
  1276. /** 发票地址信息暂时无用
  1277. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1278. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1279. $fullorder['baddress'][1] = $country['ename'];
  1280. **/
  1281. //获取所用相关信息
  1282. $warehouse = $this->warehouse->read($fullorder['type']);
  1283. $country = $this->country->read($fullorder['country']);//订单国家信息
  1284. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1285. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1286. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1287. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1288. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1289. $fullorder['country'] = $country['ename'];//订单国家名
  1290. $fullorder['zhou'] = $country['continent'];//所属州
  1291. $express = $this->express->read($fullorder['express']);
  1292. $fullorder['express'] = $express['servicename'];
  1293. $fullorder['account'] = $express['account'];
  1294. $fullorder['printcode'] = $express['printcode'];
  1295. $fullorder['time'] = date('Y-m-d',time());
  1296. $fullorder['times'] = date('Y-m-d H:i',time());
  1297. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1298. // 修复报关编码问题
  1299. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1300. $sbbm = "";
  1301. if(empty($declara_info)){
  1302. $sbbm = "";
  1303. }else{
  1304. $sbbm = $declara_info['bname'];
  1305. }
  1306. $fullorder['sbbm']= $sbbm;
  1307. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1308. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1309. $shop = $this->shop->read($fullorder['shop']);
  1310. $fullorder['shop'] = $shop['shopname'];
  1311. return $fullorder;
  1312. }
  1313. public function _lowe()
  1314. {
  1315. $post = $this->input->post(NULL, TRUE);
  1316. if(isset($post['lowe']))
  1317. {
  1318. $lowe = $this->typeclass->find_all('classid = 15 and id != 105 and id != 107 and id != 108 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189');
  1319. echo json_encode(array('msg'=>$lowe));exit;
  1320. }
  1321. }
  1322. public function _pdf($pdf,$title,$bctime)
  1323. {
  1324. $pdf_path = './data/pdf/'.$bctime.'/';
  1325. $file_base64 = $pdf;
  1326. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1327. $file_base64 = base64_decode($file_base64);
  1328. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1329. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1330. return $bctime;
  1331. }
  1332. public function _pdfurl($pdf,$title,$bctime)
  1333. {
  1334. $pdf_path = './data/pdf/'.$bctime.'/';
  1335. $pdf = fopen($pdf,"r");
  1336. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1337. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1338. return $bctime;
  1339. }
  1340. public function _excel()
  1341. {
  1342. $xw = '';
  1343. if(isset($_SESSION['api']))
  1344. {
  1345. $user = $this->user->get_api($_SESSION['api']);
  1346. $usp = $user;
  1347. $fgshop = "";$sid = "";$wid="";$wtype="";
  1348. $usersp = explode('|',trim($user['shop'],'|'));
  1349. $userwh = explode('|',trim($user['warehouse'],'|'));
  1350. foreach ($usersp as $value)
  1351. {
  1352. $fgshop .= " shop = ".$value." or";
  1353. $sid .= " id = ".$value." or";
  1354. }
  1355. foreach ($userwh as $value)
  1356. {
  1357. $wid .= " id = ".$value." or";
  1358. $wtype .= " type = ".$value." or";
  1359. }
  1360. if($user['userid'] == 'xw')
  1361. {
  1362. $xw = 1;
  1363. }
  1364. }
  1365. if(isset($_GET['fexcel']))
  1366. {
  1367. $dowid = $this->input->get('a');
  1368. $wid = "";
  1369. if($dowid != "")
  1370. {
  1371. $id_arr = explode(',',rtrim($dowid,','));
  1372. foreach ($id_arr as $v)
  1373. {
  1374. $wid .= " id = '$v' or";
  1375. }
  1376. $wid = " and".rtrim($wid,'or');
  1377. }
  1378. $t = $this->input->get('t',true);
  1379. $timetk = $this->input->get('timetk',true);
  1380. $timetj = $this->input->get('timetj',true);
  1381. $shop = $this->input->get('shop',true);
  1382. $source = $this->input->get('source',true);
  1383. $orderinfo = $this->input->get('orderinfo',true);
  1384. $number = $this->input->get('number',true);
  1385. $library = $this->input->get('library',true);
  1386. $waybill = $this->input->get('waybill',true);
  1387. $express = $this->input->get('express',true);
  1388. $type = $this->input->get('type',true);
  1389. $so = $this->input->get('so',true);
  1390. $timetk = strtotime($timetk);
  1391. $timetj = strtotime($timetj);
  1392. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  1393. if($timetk && $timetj && $library == 1)
  1394. {
  1395. //$cxtime = 'reviewtime';
  1396. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  1397. $where .= " and state != 217";
  1398. }
  1399. else if($timetk && $timetj && $library == 2)
  1400. {
  1401. $cxtime = 'librarytime';
  1402. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1403. }
  1404. /**
  1405. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1406. if($timetk && $timetj && $library == 1)
  1407. {
  1408. //$cxtime = 'reviewtime';
  1409. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1410. }
  1411. else if($timetk && $timetj && $library == 2)
  1412. {
  1413. $cxtime = 'librarytime';
  1414. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1415. }
  1416. **/
  1417. if(isset($_SESSION['api']))
  1418. {
  1419. if($type)
  1420. {
  1421. $where .= " and type = '$type'";
  1422. }
  1423. else
  1424. {
  1425. $uw = '';
  1426. $u = $this->user->get_api($_SESSION['api']);
  1427. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1428. foreach ($u['warehouse'] as $v)
  1429. {
  1430. $uw .= " type = '$v' or";
  1431. }
  1432. $uw = rtrim($uw,'or');
  1433. $uw = " and (".ltrim($uw,' ').")";
  1434. $where .= $uw;
  1435. }
  1436. }
  1437. else
  1438. {
  1439. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1440. }
  1441. if($shop)
  1442. {
  1443. $where .= " and shop = '$shop'";
  1444. }
  1445. if($number)
  1446. {
  1447. $where .= " and number = '$number'";
  1448. }
  1449. if($library)
  1450. {
  1451. $where .= " and library = '$library'";
  1452. }
  1453. if($waybill)
  1454. {
  1455. $where .= " and waybill = '$waybill'";
  1456. }
  1457. if($express)
  1458. {
  1459. $where .= " and express = '$express'";
  1460. }
  1461. if($orderinfo)
  1462. {
  1463. $where .= " and orderinfo = '$orderinfo'";
  1464. }
  1465. if($so)
  1466. {
  1467. $where .= " and shipremarks like '%$so%'";
  1468. }
  1469. //数据排序
  1470. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1471. $order_str = "librarytime desc";
  1472. if(empty($page))
  1473. {
  1474. $start = 0;
  1475. $perpage = 1;
  1476. }
  1477. else
  1478. {
  1479. $start = ($page - 1)*$perpage;
  1480. }
  1481. $typeclass = array();
  1482. $tclass = $this->typeclass->find_all();
  1483. foreach ($tclass as $v)
  1484. {
  1485. $typeclass[$v['id']] = $v;
  1486. }
  1487. //取得信息列表
  1488. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1489. //格式化数据
  1490. foreach ($info_list as $key=>$value)
  1491. {
  1492. $shop = $this->shop->read($value['shop']);
  1493. $info_list[$key]['shop'] = $shop['shopname'];
  1494. if($value['waybill'] == '0')
  1495. {
  1496. $info_list[$key]['waybill'] = "";
  1497. }
  1498. $express = $this->express->read($value['express']);
  1499. $info_list[$key]['express'] = $express['servicename'];
  1500. $warehouse = $this->warehouse->read($value['type']);
  1501. $info_list[$key]['type'] = $warehouse['title'];
  1502. if($value['print'] == 1)
  1503. {
  1504. $info_list[$key]['print'] = '不可打印';
  1505. }
  1506. else if($value['print'] == 2)
  1507. {
  1508. $info_list[$key]['print'] = '未打印';
  1509. }
  1510. else if($value['print'] == 3)
  1511. {
  1512. $info_list[$key]['print'] = '已打印';
  1513. }
  1514. if($value['library'] == 1)
  1515. {
  1516. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1517. }
  1518. else if($value['library'] == 2)
  1519. {
  1520. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1521. }
  1522. else if($value['library'] == 3)
  1523. {
  1524. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1525. }
  1526. if($value['librarytime'] == '0')
  1527. {
  1528. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1529. }
  1530. else
  1531. {
  1532. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1533. }
  1534. $classid = $classid = $this->classid->sku();
  1535. $dbapi = explode(';',trim($value['fpdata'],';'));
  1536. $tmp_jm = "";
  1537. $tmp_zh = "";
  1538. foreach ($dbapi as $va)
  1539. {
  1540. $pm = $classid;
  1541. $jm = $classid;
  1542. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1543. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1544. $ts = explode('|',trim($features,'|'));
  1545. if(stripos($ts[0],',') !== false)
  1546. {
  1547. $ft = explode(',',$ts[0]);
  1548. $features = explode('-',trim($ft[1],'-'));
  1549. $features[] = $ft[0];
  1550. }
  1551. else
  1552. {
  1553. $features = explode('-',trim($ts[0],'-'));
  1554. }
  1555. foreach($features as $k=>$v)
  1556. {
  1557. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1558. {
  1559. if($typeclass[$v]['bm'] != '')
  1560. {
  1561. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1562. }
  1563. }
  1564. if($v != 0 && isset($typeclass[$v]))
  1565. {
  1566. if($typeclass[$v]['classid'] == 13)
  1567. {
  1568. $dj = $typeclass[$v]['title'];
  1569. }
  1570. if($typeclass[$v]['classid'] == 8)
  1571. {
  1572. $ys = $typeclass[$v]['title'];
  1573. }
  1574. if($typeclass[$v]['classid'] == 15)
  1575. {
  1576. $hx = $typeclass[$v]['title'];
  1577. }
  1578. if(isset($pm[$typeclass[$v]['classid']]))
  1579. {
  1580. if($typeclass[$v]['title'] == '9A')
  1581. {
  1582. $pm[$typeclass[$v]['classid']] = '9A';
  1583. }
  1584. else if($typeclass[$v]['title'] == '10A')
  1585. {
  1586. $pm[$typeclass[$v]['classid']] = '10A';
  1587. }
  1588. else
  1589. {
  1590. $clzh = $typeclass[$v]['zh'];
  1591. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1592. {
  1593. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1594. $clzh = $clzh[0];
  1595. }
  1596. $pm[$typeclass[$v]['classid']] = $clzh;
  1597. }
  1598. }
  1599. if(isset($jm[$typeclass[$v]['classid']]))
  1600. {
  1601. if($typeclass[$v]['jm'])
  1602. {
  1603. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1604. }
  1605. }
  1606. }
  1607. }
  1608. $jm = array_filter($jm);//去除空值
  1609. $jm = implode("-",$jm);
  1610. $tmp_jm .= $jm.";";
  1611. $pm = array_filter($pm);//去除空值
  1612. $zh = implode(" ",$pm);
  1613. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1614. $tmp_zh .= $zh.";";
  1615. }
  1616. $info_list[$key]['jm'] = trim($tmp_jm,';');
  1617. $info_list[$key]['zh'] = trim($tmp_zh,';');
  1618. }
  1619. //取得信息列表
  1620. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1621. //格式化数据
  1622. foreach ($info_listsmt as $key=>$value)
  1623. {
  1624. $shop = $this->shop->read($value['shop']);
  1625. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1626. if($value['waybill'] == '0')
  1627. {
  1628. $info_listsmt[$key]['waybill'] = "";
  1629. }
  1630. $express = $this->express->read($value['express']);
  1631. $info_listsmt[$key]['express'] = $express['servicename'];
  1632. $warehouse = $this->warehouse->read($value['type']);
  1633. $info_listsmt[$key]['type'] = $warehouse['title'];
  1634. if($value['print'] == 1)
  1635. {
  1636. $info_listsmt[$key]['print'] = '不可打印';
  1637. }
  1638. else if($value['print'] == 2)
  1639. {
  1640. $info_listsmt[$key]['print'] = '未打印';
  1641. }
  1642. else if($value['print'] == 3)
  1643. {
  1644. $info_listsmt[$key]['print'] = '已打印';
  1645. }
  1646. if($value['library'] == 1)
  1647. {
  1648. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1649. }
  1650. else if($value['library'] == 2)
  1651. {
  1652. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1653. }
  1654. else if($value['library'] == 3)
  1655. {
  1656. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1657. }
  1658. if($value['librarytime'] == '0')
  1659. {
  1660. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1661. }
  1662. else
  1663. {
  1664. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1665. }
  1666. $classid = $classid = $this->classid->sku();
  1667. $dbapi = explode(';',trim($value['fpdata'],';'));
  1668. $tmp_jm = "";
  1669. $tmp_zh = "";
  1670. foreach ($dbapi as $va)
  1671. {
  1672. $pm = $classid;
  1673. $jm = $classid;
  1674. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1675. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1676. $ts = explode('|',trim($features,'|'));
  1677. if(stripos($ts[0],',') !== false)
  1678. {
  1679. $ft = explode(',',$ts[0]);
  1680. $features = explode('-',trim($ft[1],'-'));
  1681. $features[] = $ft[0];
  1682. }
  1683. else
  1684. {
  1685. $features = explode('-',trim($ts[0],'-'));
  1686. }
  1687. foreach($features as $k=>$v)
  1688. {
  1689. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1690. {
  1691. if($typeclass[$v]['bm'] != '')
  1692. {
  1693. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1694. }
  1695. }
  1696. if($v != 0 && isset($typeclass[$v]))
  1697. {
  1698. if($typeclass[$v]['classid'] == 13)
  1699. {
  1700. $dj = $typeclass[$v]['title'];
  1701. }
  1702. if($typeclass[$v]['classid'] == 8)
  1703. {
  1704. $ys = $typeclass[$v]['title'];
  1705. }
  1706. if($typeclass[$v]['classid'] == 15)
  1707. {
  1708. $hx = $typeclass[$v]['title'];
  1709. }
  1710. if(isset($pm[$typeclass[$v]['classid']]))
  1711. {
  1712. if($typeclass[$v]['title'] == '9A')
  1713. {
  1714. $pm[$typeclass[$v]['classid']] = '9A';
  1715. }
  1716. else if($typeclass[$v]['title'] == '10A')
  1717. {
  1718. $pm[$typeclass[$v]['classid']] = '10A';
  1719. }
  1720. else
  1721. {
  1722. $clzh = $typeclass[$v]['zh'];
  1723. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1724. {
  1725. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1726. $clzh = $clzh[0];
  1727. }
  1728. $pm[$typeclass[$v]['classid']] = $clzh;
  1729. }
  1730. }
  1731. if(isset($jm[$typeclass[$v]['classid']]))
  1732. {
  1733. if($typeclass[$v]['jm'])
  1734. {
  1735. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1736. }
  1737. }
  1738. }
  1739. }
  1740. $jm = array_filter($jm);//去除空值
  1741. $jm = implode("-",$jm);
  1742. $pm = array_filter($pm);//去除空值
  1743. $zh = implode(" ",$pm);
  1744. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1745. $tmp_jm .= $jm.";";
  1746. $tmp_zh .= $zh.";";
  1747. }
  1748. $info_listsmt[$key]['jm'] = trim($tmp_jm,';');
  1749. $info_listsmt[$key]['zh'] = trim($tmp_zh,';');
  1750. }
  1751. //取得信息列表
  1752. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1753. //格式化数据
  1754. foreach ($info_listtt as $key=>$value)
  1755. {
  1756. $shop = $this->shop->read($value['shop']);
  1757. $info_listtt[$key]['shop'] = $shop['shopname'];
  1758. if($value['waybill'] == '0')
  1759. {
  1760. $info_listtt[$key]['waybill'] = "";
  1761. }
  1762. $express = $this->express->read($value['express']);
  1763. $info_listtt[$key]['express'] = $express['servicename'];
  1764. $warehouse = $this->warehouse->read($value['type']);
  1765. $info_listtt[$key]['type'] = $warehouse['title'];
  1766. if($value['print'] == 1)
  1767. {
  1768. $info_listtt[$key]['print'] = '不可打印';
  1769. }
  1770. else if($value['print'] == 2)
  1771. {
  1772. $info_listtt[$key]['print'] = '未打印';
  1773. }
  1774. else if($value['print'] == 3)
  1775. {
  1776. $info_listtt[$key]['print'] = '已打印';
  1777. }
  1778. if($value['library'] == 1)
  1779. {
  1780. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1781. }
  1782. else if($value['library'] == 2)
  1783. {
  1784. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1785. }
  1786. else if($value['library'] == 3)
  1787. {
  1788. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1789. }
  1790. if($value['librarytime'] == '0')
  1791. {
  1792. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1793. }
  1794. else
  1795. {
  1796. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1797. }
  1798. $classid = $classid = $this->classid->sku();
  1799. $tmp_jm = "";
  1800. $tmp_zh = "";
  1801. $dbapi = explode(';',trim($value['fpdata'],';'));
  1802. foreach ($dbapi as $va)
  1803. {
  1804. $pm = $classid;
  1805. $jm = $classid;
  1806. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1807. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1808. $ts = explode('|',trim($features,'|'));
  1809. if(stripos($ts[0],',') !== false)
  1810. {
  1811. $ft = explode(',',$ts[0]);
  1812. $features = explode('-',trim($ft[1],'-'));
  1813. $features[] = $ft[0];
  1814. }
  1815. else
  1816. {
  1817. $features = explode('-',trim($ts[0],'-'));
  1818. }
  1819. foreach($features as $k=>$v)
  1820. {
  1821. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1822. {
  1823. if($typeclass[$v]['bm'] != '')
  1824. {
  1825. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1826. }
  1827. }
  1828. if($v != 0 && isset($typeclass[$v]))
  1829. {
  1830. if($typeclass[$v]['classid'] == 13)
  1831. {
  1832. $dj = $typeclass[$v]['title'];
  1833. }
  1834. if($typeclass[$v]['classid'] == 8)
  1835. {
  1836. $ys = $typeclass[$v]['title'];
  1837. }
  1838. if($typeclass[$v]['classid'] == 15)
  1839. {
  1840. $hx = $typeclass[$v]['title'];
  1841. }
  1842. if(isset($pm[$typeclass[$v]['classid']]))
  1843. {
  1844. if($typeclass[$v]['title'] == '9A')
  1845. {
  1846. $pm[$typeclass[$v]['classid']] = '9A';
  1847. }
  1848. else if($typeclass[$v]['title'] == '10A')
  1849. {
  1850. $pm[$typeclass[$v]['classid']] = '10A';
  1851. }
  1852. else
  1853. {
  1854. $clzh = $typeclass[$v]['zh'];
  1855. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1856. {
  1857. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1858. $clzh = $clzh[0];
  1859. }
  1860. $pm[$typeclass[$v]['classid']] = $clzh;
  1861. }
  1862. }
  1863. if(isset($jm[$typeclass[$v]['classid']]))
  1864. {
  1865. if($typeclass[$v]['jm'])
  1866. {
  1867. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1868. }
  1869. }
  1870. }
  1871. }
  1872. $jm = array_filter($jm);//去除空值
  1873. $jm = implode("-",$jm);
  1874. $pm = array_filter($pm);//去除空值
  1875. $zh = implode(" ",$pm);
  1876. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1877. $tmp_jm .= $jm.";";
  1878. $tmp_zh .= $zh.";";
  1879. }
  1880. $info_listtt[$key]['jm'] = trim($tmp_jm,';');
  1881. $info_listtt[$key]['zh'] = trim($tmp_zh,';');
  1882. }
  1883. //取得信息列表
  1884. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1885. //格式化数据
  1886. foreach ($info_listamz as $key=>$value)
  1887. {
  1888. $shop = $this->shop->read($value['shop']);
  1889. $info_listamz[$key]['shop'] = $shop['shopname'];
  1890. if($value['waybill'] == '0')
  1891. {
  1892. $info_listamz[$key]['waybill'] = "";
  1893. }
  1894. $express = $this->express->read($value['express']);
  1895. $info_listamz[$key]['express'] = $express['servicename'];
  1896. $warehouse = $this->warehouse->read($value['type']);
  1897. $info_listamz[$key]['type'] = $warehouse['title'];
  1898. if($value['print'] == 1)
  1899. {
  1900. $info_listamz[$key]['print'] = '不可打印';
  1901. }
  1902. else if($value['print'] == 2)
  1903. {
  1904. $info_listamz[$key]['print'] = '未打印';
  1905. }
  1906. else if($value['print'] == 3)
  1907. {
  1908. $info_listamz[$key]['print'] = '已打印';
  1909. }
  1910. if($value['library'] == 1)
  1911. {
  1912. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  1913. }
  1914. else if($value['library'] == 2)
  1915. {
  1916. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  1917. }
  1918. else if($value['library'] == 3)
  1919. {
  1920. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  1921. }
  1922. if($value['librarytime'] == '0')
  1923. {
  1924. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  1925. }
  1926. else
  1927. {
  1928. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1929. }
  1930. $classid = $classid = $this->classid->sku();
  1931. $dbapi = explode(';',trim($value['fpdata'],';'));
  1932. $tmp_jm = "";
  1933. $tmp_zh = "";
  1934. foreach ($dbapi as $va)
  1935. {
  1936. $pm = $classid;
  1937. $jm = $classid;
  1938. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1939. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1940. $ts = explode('|',trim($features,'|'));
  1941. if(stripos($ts[0],',') !== false)
  1942. {
  1943. $ft = explode(',',$ts[0]);
  1944. $features = explode('-',trim($ft[1],'-'));
  1945. $features[] = $ft[0];
  1946. }
  1947. else
  1948. {
  1949. $features = explode('-',trim($ts[0],'-'));
  1950. }
  1951. foreach($features as $k=>$v)
  1952. {
  1953. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1954. {
  1955. if($typeclass[$v]['bm'] != '')
  1956. {
  1957. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1958. }
  1959. }
  1960. if($v != 0 && isset($typeclass[$v]))
  1961. {
  1962. if($typeclass[$v]['classid'] == 13)
  1963. {
  1964. $dj = $typeclass[$v]['title'];
  1965. }
  1966. if($typeclass[$v]['classid'] == 8)
  1967. {
  1968. $ys = $typeclass[$v]['title'];
  1969. }
  1970. if($typeclass[$v]['classid'] == 15)
  1971. {
  1972. $hx = $typeclass[$v]['title'];
  1973. }
  1974. if(isset($pm[$typeclass[$v]['classid']]))
  1975. {
  1976. if($typeclass[$v]['title'] == '9A')
  1977. {
  1978. $pm[$typeclass[$v]['classid']] = '9A';
  1979. }
  1980. else if($typeclass[$v]['title'] == '10A')
  1981. {
  1982. $pm[$typeclass[$v]['classid']] = '10A';
  1983. }
  1984. else
  1985. {
  1986. $clzh = $typeclass[$v]['zh'];
  1987. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1988. {
  1989. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1990. $clzh = $clzh[0];
  1991. }
  1992. $pm[$typeclass[$v]['classid']] = $clzh;
  1993. }
  1994. }
  1995. if(isset($jm[$typeclass[$v]['classid']]))
  1996. {
  1997. if($typeclass[$v]['jm'])
  1998. {
  1999. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2000. }
  2001. }
  2002. }
  2003. }
  2004. $jm = array_filter($jm);//去除空值
  2005. $jm = implode("-",$jm);
  2006. $pm = array_filter($pm);//去除空值
  2007. $zh = implode(" ",$pm);
  2008. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2009. $tmp_jm .= $jm.";";
  2010. $tmp_zh .= $zh.";";
  2011. }
  2012. $info_listamz[$key]['jm'] = trim($tmp_jm,';');
  2013. $info_listamz[$key]['zh'] = trim($tmp_zh,';');
  2014. }
  2015. //取得信息列表
  2016. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  2017. //格式化数据
  2018. foreach ($info_listxw as $key=>$value)
  2019. {
  2020. $shop = $this->shop->read($value['shop']);
  2021. $info_listxw[$key]['shop'] = $shop['shopname'];
  2022. if($value['waybill'] == '0')
  2023. {
  2024. $info_listxw[$key]['waybill'] = "";
  2025. }
  2026. $express = $this->express->read($value['express']);
  2027. $info_listxw[$key]['express'] = $express['servicename'];
  2028. $warehouse = $this->warehouse->read($value['type']);
  2029. $info_listxw[$key]['type'] = $warehouse['title'];
  2030. if($value['print'] == 1)
  2031. {
  2032. $info_listxw[$key]['print'] = '不可打印';
  2033. }
  2034. else if($value['print'] == 2)
  2035. {
  2036. $info_listxw[$key]['print'] = '未打印';
  2037. }
  2038. else if($value['print'] == 3)
  2039. {
  2040. $info_listxw[$key]['print'] = '已打印';
  2041. }
  2042. if($value['library'] == 1)
  2043. {
  2044. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2045. }
  2046. else if($value['library'] == 2)
  2047. {
  2048. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2049. }
  2050. else if($value['library'] == 3)
  2051. {
  2052. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2053. }
  2054. if($value['librarytime'] == '0')
  2055. {
  2056. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  2057. }
  2058. else
  2059. {
  2060. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2061. }
  2062. $classid = $classid = $this->classid->sku();
  2063. $dbapi = explode(';',trim($value['fpdata'],';'));
  2064. foreach ($dbapi as $va)
  2065. {
  2066. $pm = $classid;
  2067. $jm = $classid;
  2068. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2069. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2070. $ts = explode('|',trim($features,'|'));
  2071. if(stripos($ts[0],',') !== false)
  2072. {
  2073. $ft = explode(',',$ts[0]);
  2074. $features = explode('-',trim($ft[1],'-'));
  2075. $features[] = $ft[0];
  2076. }
  2077. else
  2078. {
  2079. $features = explode('-',trim($ts[0],'-'));
  2080. }
  2081. foreach($features as $k=>$v)
  2082. {
  2083. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2084. {
  2085. if($typeclass[$v]['bm'] != '')
  2086. {
  2087. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2088. }
  2089. }
  2090. if($v != 0 && isset($typeclass[$v]))
  2091. {
  2092. if($typeclass[$v]['classid'] == 13)
  2093. {
  2094. $dj = $typeclass[$v]['title'];
  2095. }
  2096. if($typeclass[$v]['classid'] == 8)
  2097. {
  2098. $ys = $typeclass[$v]['title'];
  2099. }
  2100. if($typeclass[$v]['classid'] == 15)
  2101. {
  2102. $hx = $typeclass[$v]['title'];
  2103. }
  2104. if(isset($pm[$typeclass[$v]['classid']]))
  2105. {
  2106. if($typeclass[$v]['title'] == '9A')
  2107. {
  2108. $pm[$typeclass[$v]['classid']] = '9A';
  2109. }
  2110. else if($typeclass[$v]['title'] == '10A')
  2111. {
  2112. $pm[$typeclass[$v]['classid']] = '10A';
  2113. }
  2114. else
  2115. {
  2116. $clzh = $typeclass[$v]['zh'];
  2117. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2118. {
  2119. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2120. $clzh = $clzh[0];
  2121. }
  2122. $pm[$typeclass[$v]['classid']] = $clzh;
  2123. }
  2124. }
  2125. if(isset($jm[$typeclass[$v]['classid']]))
  2126. {
  2127. if($typeclass[$v]['jm'])
  2128. {
  2129. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2130. }
  2131. }
  2132. }
  2133. }
  2134. $jm = array_filter($jm);//去除空值
  2135. $jm = implode("-",$jm);
  2136. $pm = array_filter($pm);//去除空值
  2137. $zh = implode(" ",$pm);
  2138. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2139. }
  2140. $info_listxw[$key]['jm'] = $jm;
  2141. $info_listxw[$key]['zh'] = $zh;
  2142. }
  2143. $title = '订单出库-'.date('Ymd',time());
  2144. $t = str_replace("<td>运单号</td>","<td>运单号</td><td>转单号</td>",$t);
  2145. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  2146. $tail = "\n";
  2147. $filename = $title.".xls";
  2148. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
  2149. }
  2150. }
  2151. public function _cpexcel()
  2152. {
  2153. if(isset($_SESSION['api']))
  2154. {
  2155. $user = $this->user->get_api($_SESSION['api']);
  2156. $usp = $user;
  2157. $fgshop = "";$sid = "";$excelshop="";
  2158. $usersp = explode('|',trim($user['shop'],'|'));
  2159. foreach ($usersp as $value)
  2160. {
  2161. $fgshop .= " shop = ".$value." or";
  2162. $sid .= " id = ".$value." or";
  2163. }
  2164. $userexcel = explode('|',trim($user['excelshop'],'|'));
  2165. foreach ($userexcel as $value)
  2166. {
  2167. $excelshop .= " shop = ".$value." or";
  2168. }
  2169. if($excelshop != "")
  2170. {
  2171. $excelshop = "(".rtrim($excelshop,'or').")";
  2172. }
  2173. }
  2174. if(isset($_GET['excel']))
  2175. {
  2176. $timetk = $this->input->get('timetk',true);
  2177. $timetj = $this->input->get('timetj',true);
  2178. $shop = $this->input->get('shop',true);
  2179. $library = $this->input->get('library',true);
  2180. $type = $this->input->get('type',true);
  2181. $number = $this->input->get('number',true);
  2182. $orderinfo = $this->input->get('orderinfo',true);
  2183. $so = $this->input->get('so',true);
  2184. $number = $this->input->get('number',true);
  2185. $express = $this->input->get('express',true);
  2186. $timetk = strtotime($timetk);
  2187. $timetj = strtotime($timetj);
  2188. $where = "mergeid = 0";
  2189. if($timetk && $timetj && $library == 2)
  2190. {
  2191. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2192. }
  2193. else
  2194. {
  2195. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  2196. }
  2197. if(isset($_SESSION['api']))
  2198. {
  2199. if($type)
  2200. {
  2201. $where .= " and type = '$type'";
  2202. }
  2203. else
  2204. {
  2205. $uw = '';
  2206. $u = $this->user->get_api($_SESSION['api']);
  2207. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  2208. foreach ($u['warehouse'] as $v)
  2209. {
  2210. $uw .= " type = '$v' or";
  2211. }
  2212. $uw = rtrim($uw,'or');
  2213. $uw = " and (".ltrim($uw,' ').")";
  2214. $where .= $uw;
  2215. }
  2216. }
  2217. else
  2218. {
  2219. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  2220. }
  2221. if($shop)
  2222. {
  2223. $where .= " and shop = '$shop'";
  2224. }
  2225. else
  2226. {
  2227. $where .= " and ".$excelshop;
  2228. }
  2229. if($library)
  2230. {
  2231. $where .= " and library = '$library'";
  2232. }
  2233. if($number)
  2234. {
  2235. $where .= " and number = '$number'";
  2236. }
  2237. if($orderinfo)
  2238. {
  2239. $where .= " and orderinfo = '$orderinfo'";
  2240. }
  2241. if($so)
  2242. {
  2243. $where .= " and shipremarks like '%$so%'";
  2244. }
  2245. if($express)
  2246. {
  2247. $where .= " and express = '$express'";
  2248. }
  2249. /* 匹配ID加入 */
  2250. $tc = array();
  2251. $typeclass = $this->typeclass->find_all();
  2252. foreach ($typeclass as $v)
  2253. {
  2254. $tc[$v['id']] = $v['title'];
  2255. }
  2256. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  2257. //取得信息列表
  2258. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  2259. $info_listb = $this->fullorder->find_all($where,'fpdata');
  2260. $info_list = array_merge($info_lista,$info_listb);
  2261. //格式化数据
  2262. $i = 0;$cpexcel = array();
  2263. foreach ($info_list as $key=>$value)
  2264. {
  2265. if(stripos($value['fpdata'],';') !== false)
  2266. {
  2267. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  2268. foreach ($fpdata as $ke=>$va)
  2269. {
  2270. $title = '';
  2271. $fg = explode('|',$va);
  2272. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  2273. $cp = explode('-',rtrim($fg[0],'-'));
  2274. $dj = $tc[$cp[2]];
  2275. if(!isset($cp[3]))
  2276. {
  2277. $ys = json_encode($cp);
  2278. }
  2279. else
  2280. {
  2281. $ys = $tc[$cp[3]];
  2282. }
  2283. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  2284. foreach ($cp as $v)
  2285. {
  2286. $title .= $tc[$v].' ';
  2287. }
  2288. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  2289. }
  2290. }
  2291. $i++;
  2292. }
  2293. $title = "统计信息";
  2294. $titlename = "<table border=1>
  2295. <tr>
  2296. <td>尺寸</td>
  2297. <td>等级</td>
  2298. <td>颜色</td>
  2299. <td>花型</td>
  2300. <td>数量</td>
  2301. </tr>
  2302. </table>";
  2303. $filename = $title.".xls";
  2304. $tail = "\n";
  2305. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  2306. }
  2307. }
  2308. public function _orderyz()
  2309. {
  2310. $post = $this->input->post(NULL, TRUE);
  2311. if(isset($post['yz']))
  2312. {
  2313. $yz = $this->input->post('yz',true);
  2314. $number = $this->input->post('number',true);
  2315. $y = $this->fullorder->get_number($number);
  2316. if(!$y)
  2317. {
  2318. $y = $this->fullordersmt->get_number($number);
  2319. if(!$y)
  2320. {
  2321. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2322. }
  2323. }
  2324. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2325. foreach($whlabel as $k=>$v)
  2326. {
  2327. $w = explode('-',trim($v,'-'));
  2328. $wldata[$w[0]] = $w;
  2329. }
  2330. $whlabellabel = $this->whlabellabel->get_label($yz);
  2331. if(!$whlabellabel)
  2332. {
  2333. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2334. }
  2335. else
  2336. {
  2337. if(isset($wldata[$whlabellabel['number']]))
  2338. {
  2339. if(!isset($wldata[$whlabellabel['number']][2]))
  2340. {
  2341. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2342. }
  2343. else if($wldata[$whlabellabel['number']][2] == 0)
  2344. {
  2345. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2346. }
  2347. }
  2348. else
  2349. {
  2350. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2351. }
  2352. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2353. }
  2354. }
  2355. if(isset($post['number']))
  2356. {
  2357. $number = $this->input->post('number',true);
  2358. $f = 'fullorder';
  2359. $y = $this->fullorder->get_number($number);
  2360. if(!$y)
  2361. {
  2362. $f = 'fullordersmt';
  2363. $y = $this->fullordersmt->get_number($number);
  2364. if(!$y)
  2365. {
  2366. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2367. }
  2368. }
  2369. if($y['librarytime'] > 0)
  2370. {
  2371. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2372. }
  2373. $warehouse = $this->warehouse->read($y['type']);
  2374. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2375. {
  2376. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  2377. }
  2378. $data = explode('|',trim($y['whlabel'],'|'));
  2379. $fpdata = explode(';',trim($y['fpdata'],';'));
  2380. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2381. foreach($fpdata as $val)
  2382. {
  2383. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2384. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2385. $fp = explode('|',$val);
  2386. $fp[0] = str_replace(',','-',$fp[0]);
  2387. $value = explode('-',$fp[0]);
  2388. foreach($value as $v)
  2389. {
  2390. $typeclass = $this->typeclass->read($v);
  2391. $zh = explode('|',trim($typeclass['zh'],'|'));
  2392. $pm[$typeclass['classid']] = $zh[0];
  2393. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2394. }
  2395. $scsku = implode("-",$scsku);
  2396. $zh = implode(" ",$pm);
  2397. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2398. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2399. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2400. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2401. $data[$i] = explode('-',$data[$i]);
  2402. for($j=0;$j<$data[$i][1];$j++)
  2403. {
  2404. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2405. {
  2406. $znum++;//只计算现货
  2407. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2408. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2409. }
  2410. else
  2411. {
  2412. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2413. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2414. }
  2415. $x++;//所有数量
  2416. }
  2417. $i++;
  2418. }
  2419. //ksort($cp);//区别位置模式,暂不使用
  2420. $cp = array_values($cp);
  2421. if($this->$f->save(array('yhs'=>1),$y['id']))
  2422. {
  2423. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2424. }
  2425. else
  2426. {
  2427. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2428. }
  2429. }
  2430. if(isset($post['tid']))
  2431. {
  2432. $typeclass = array();
  2433. $tc = $this->typeclass->find_all();
  2434. foreach($tc as $v)
  2435. {
  2436. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2437. }
  2438. $tid = $this->input->post('tid',true);
  2439. $id = $this->input->post('id',true);
  2440. $number = $this->input->post('n',true);
  2441. $ful = 'fullorder';
  2442. $y = $this->fullorder->get_number($number);
  2443. if(!$y)
  2444. {
  2445. $ful = 'fullordersmt';
  2446. $y = $this->fullordersmt->get_number($number);
  2447. if(!$y)
  2448. {
  2449. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2450. }
  2451. }
  2452. $wtid = $this->whlabellabel->get_label($tid);
  2453. if(!$wtid)
  2454. {
  2455. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2456. }
  2457. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2458. $fpdata = explode(';',trim($y['fpdata'],';'));
  2459. $warehouse = $this->warehouse->read($y['type']);
  2460. $zdkc = $warehouse['bdck'];
  2461. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2462. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2463. if((count($ptc)+count($zsc)) < 1)
  2464. {
  2465. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2466. }
  2467. $this->db->trans_begin();
  2468. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2469. if($zsc)
  2470. {
  2471. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2472. $xrid = $zsc[0]['id'];
  2473. }
  2474. else if($ptc)
  2475. {
  2476. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2477. $xrid = $ptc[0]['id'];
  2478. }
  2479. $xr = $this->$zdkc->read($xrid);
  2480. $features = explode('-',trim($xr['features'],'-'));
  2481. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2482. foreach($features as $kk=>$v)
  2483. {
  2484. if($typeclass[$v]['classid'] == 14)
  2485. {
  2486. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2487. unset($kk);
  2488. }
  2489. }
  2490. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2491. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2492. $wldata = array();
  2493. $fdata = array();
  2494. foreach($whlabel as $k=>$v)
  2495. {
  2496. $w = explode('-',trim($v,'-'));
  2497. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2498. }
  2499. if(!isset($wldata[$id]))
  2500. {
  2501. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2502. }
  2503. if(isset($wldata[$wtid['number']]['sj']))
  2504. {
  2505. $tw = $wldata[$wtid['number']]['sj'];
  2506. if($wtid['number'] != $id)
  2507. {
  2508. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2509. }
  2510. else
  2511. {
  2512. if(isset($tw[2]) && $tw[2] != 0)
  2513. {
  2514. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2515. }
  2516. }
  2517. if($tw[1] > 1)
  2518. {
  2519. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2520. }
  2521. }
  2522. $thfpdata = $y['thfpdata'];
  2523. $w = $wldata[$id]['sj'];
  2524. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2525. $zdkc = $warehouse['bdck'];
  2526. if($w[1] > 1)
  2527. {
  2528. if(isset($w[2]) && $w[2] != 0)
  2529. {
  2530. $hz = explode('~',trim($w[2],'~'));
  2531. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2532. $zd = str_replace($hz[0],'',$w[2]);
  2533. $zd = trim($zd,'~');
  2534. $w[2] = $zd;
  2535. }
  2536. foreach($w as $kk=>$v)
  2537. {
  2538. if($kk == 1)
  2539. {
  2540. $v = $v-1;
  2541. }
  2542. $ww .= $v .'-';
  2543. }
  2544. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2545. foreach($f as $kk=>$v)
  2546. {
  2547. if($kk == 2)
  2548. {
  2549. $v = $v-1;
  2550. $thff .= '1|';
  2551. }
  2552. else
  2553. {
  2554. $thff .= $v .'|';
  2555. }
  2556. $ff .= $v .'|';
  2557. }
  2558. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2559. $thfpdata .= trim($thff,'|');
  2560. }
  2561. else
  2562. {
  2563. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2564. unset($whlabel[$wldata[$id]['wz']]);
  2565. unset($fpdata[$wldata[$id]['wz']]);
  2566. }
  2567. $thfpdata .= '~'.$dataf;
  2568. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2569. $fpdata = implode(";",$fpdata).';'.$dataf;
  2570. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2571. if ($this->db->trans_status() === TRUE)
  2572. {
  2573. $this->db->trans_commit();
  2574. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2575. }
  2576. else
  2577. {
  2578. $this->db->trans_rollback();
  2579. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2580. }
  2581. }
  2582. if(isset($post['yhs']))
  2583. {
  2584. $f = 'fullorder';
  2585. $number = $this->input->post('yhs',true);
  2586. $y = $this->fullorder->get_number($number);
  2587. if(!$y)
  2588. {
  2589. $f = 'fullordersmt';
  2590. $y = $this->fullordersmt->get_number($number);
  2591. }
  2592. if($this->$f->save(array('yhs'=>0),$y['id']))
  2593. {
  2594. echo json_encode(array('success'=>true));exit;
  2595. }
  2596. else
  2597. {
  2598. echo json_encode(array('success'=>false));exit;
  2599. }
  2600. }
  2601. $this->_Template('systemfout_orderyz',$this->data);
  2602. }
  2603. public function _hwyz()
  2604. {
  2605. $post = $this->input->post(NULL, TRUE);
  2606. if(isset($post['yz']))
  2607. {
  2608. $yz = $this->input->post('yz',true);
  2609. $number = $this->input->post('number',true);
  2610. $y = $this->fullorder->get_number($number);
  2611. if(!$y)
  2612. {
  2613. $y = $this->fullordersmt->get_number($number);
  2614. if(!$y)
  2615. {
  2616. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2617. }
  2618. }
  2619. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2620. foreach($whlabel as $k=>$v)
  2621. {
  2622. $w = explode('-',trim($v,'-'));
  2623. $wldata[$w[0]] = $w;
  2624. }
  2625. $whlabellabel = $this->whlabellabel->get_label($yz);
  2626. if(!$whlabellabel)
  2627. {
  2628. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2629. }
  2630. else
  2631. {
  2632. if(isset($wldata[$whlabellabel['number']]))
  2633. {
  2634. if(!isset($wldata[$whlabellabel['number']][2]))
  2635. {
  2636. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2637. }
  2638. else if($wldata[$whlabellabel['number']][2] == 0)
  2639. {
  2640. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2641. }
  2642. }
  2643. else
  2644. {
  2645. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2646. }
  2647. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2648. }
  2649. }
  2650. if(isset($post['number']))
  2651. {
  2652. $number = $this->input->post('number',true);
  2653. $f = 'fullorder';
  2654. $y = $this->fullorder->get_number($number);
  2655. if(!$y)
  2656. {
  2657. $f = 'fullordersmt';
  2658. $y = $this->fullordersmt->get_number($number);
  2659. if(!$y)
  2660. {
  2661. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2662. }
  2663. }
  2664. if($y['librarytime'] > 0)
  2665. {
  2666. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2667. }
  2668. $warehouse = $this->warehouse->read($y['type']);
  2669. $data = explode('|',trim($y['whlabel'],'|'));
  2670. $fpdata = explode(';',trim($y['fpdata'],';'));
  2671. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2672. foreach($fpdata as $val)
  2673. {
  2674. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2675. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2676. $fp = explode('|',$val);
  2677. $fp[0] = str_replace(',','-',$fp[0]);
  2678. $value = explode('-',$fp[0]);
  2679. foreach($value as $v)
  2680. {
  2681. $typeclass = $this->typeclass->read($v);
  2682. $zh = explode('|',trim($typeclass['zh'],'|'));
  2683. $pm[$typeclass['classid']] = $zh[0];
  2684. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2685. }
  2686. $scsku = implode("-",$scsku);
  2687. $zh = implode(" ",$pm);
  2688. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2689. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2690. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2691. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2692. $data[$i] = explode('-',$data[$i]);
  2693. for($j=0;$j<$data[$i][1];$j++)
  2694. {
  2695. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2696. {
  2697. $znum++;//只计算现货
  2698. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2699. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2700. }
  2701. else
  2702. {
  2703. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2704. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2705. }
  2706. $x++;//所有数量
  2707. }
  2708. $i++;
  2709. }
  2710. //ksort($cp);//区别位置模式,暂不使用
  2711. $cp = array_values($cp);
  2712. if($this->$f->save(array('yhs'=>1),$y['id']))
  2713. {
  2714. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2715. {
  2716. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  2717. }
  2718. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2719. }
  2720. else
  2721. {
  2722. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2723. }
  2724. }
  2725. if(isset($post['tid']))
  2726. {
  2727. $typeclass = array();
  2728. $tc = $this->typeclass->find_all();
  2729. foreach($tc as $v)
  2730. {
  2731. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2732. }
  2733. $tid = $this->input->post('tid',true);
  2734. $id = $this->input->post('id',true);
  2735. $number = $this->input->post('n',true);
  2736. $ful = 'fullorder';
  2737. $y = $this->fullorder->get_number($number);
  2738. if(!$y)
  2739. {
  2740. $ful = 'fullordersmt';
  2741. $y = $this->fullordersmt->get_number($number);
  2742. if(!$y)
  2743. {
  2744. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2745. }
  2746. }
  2747. $wtid = $this->whlabellabel->get_label($tid);
  2748. if(!$wtid)
  2749. {
  2750. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2751. }
  2752. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2753. $fpdata = explode(';',trim($y['fpdata'],';'));
  2754. $warehouse = $this->warehouse->read($y['type']);
  2755. $zdkc = $warehouse['bdck'];
  2756. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2757. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2758. if((count($ptc)+count($zsc)) < 1)
  2759. {
  2760. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2761. }
  2762. $this->db->trans_begin();
  2763. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2764. if($zsc)
  2765. {
  2766. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2767. $xrid = $zsc[0]['id'];
  2768. }
  2769. else if($ptc)
  2770. {
  2771. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2772. $xrid = $ptc[0]['id'];
  2773. }
  2774. $xr = $this->$zdkc->read($xrid);
  2775. $features = explode('-',trim($xr['features'],'-'));
  2776. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2777. foreach($features as $kk=>$v)
  2778. {
  2779. if($typeclass[$v]['classid'] == 14)
  2780. {
  2781. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2782. unset($kk);
  2783. }
  2784. }
  2785. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2786. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2787. $wldata = array();
  2788. $fdata = array();
  2789. foreach($whlabel as $k=>$v)
  2790. {
  2791. $w = explode('-',trim($v,'-'));
  2792. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2793. }
  2794. if(!isset($wldata[$id]))
  2795. {
  2796. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2797. }
  2798. if(isset($wldata[$wtid['number']]['sj']))
  2799. {
  2800. $tw = $wldata[$wtid['number']]['sj'];
  2801. if($wtid['number'] != $id)
  2802. {
  2803. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2804. }
  2805. else
  2806. {
  2807. if(isset($tw[2]) && $tw[2] != 0)
  2808. {
  2809. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2810. }
  2811. }
  2812. if($tw[1] > 1)
  2813. {
  2814. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2815. }
  2816. }
  2817. $thfpdata = $y['thfpdata'];
  2818. $w = $wldata[$id]['sj'];
  2819. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2820. $zdkc = $warehouse['bdck'];
  2821. if($w[1] > 1)
  2822. {
  2823. if(isset($w[2]) && $w[2] != 0)
  2824. {
  2825. $hz = explode('~',trim($w[2],'~'));
  2826. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2827. $zd = str_replace($hz[0],'',$w[2]);
  2828. $zd = trim($zd,'~');
  2829. $w[2] = $zd;
  2830. }
  2831. foreach($w as $kk=>$v)
  2832. {
  2833. if($kk == 1)
  2834. {
  2835. $v = $v-1;
  2836. }
  2837. $ww .= $v .'-';
  2838. }
  2839. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2840. foreach($f as $kk=>$v)
  2841. {
  2842. if($kk == 2)
  2843. {
  2844. $v = $v-1;
  2845. $thff .= '1|';
  2846. }
  2847. else
  2848. {
  2849. $thff .= $v .'|';
  2850. }
  2851. $ff .= $v .'|';
  2852. }
  2853. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2854. $thfpdata .= trim($thff,'|');
  2855. }
  2856. else
  2857. {
  2858. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2859. unset($whlabel[$wldata[$id]['wz']]);
  2860. unset($fpdata[$wldata[$id]['wz']]);
  2861. }
  2862. $thfpdata .= '~'.$dataf;
  2863. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2864. $fpdata = implode(";",$fpdata).';'.$dataf;
  2865. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2866. if ($this->db->trans_status() === TRUE)
  2867. {
  2868. $this->db->trans_commit();
  2869. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2870. }
  2871. else
  2872. {
  2873. $this->db->trans_rollback();
  2874. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2875. }
  2876. }
  2877. if(isset($post['yhs']))
  2878. {
  2879. $f = 'fullorder';
  2880. $number = $this->input->post('yhs',true);
  2881. $y = $this->fullorder->get_number($number);
  2882. if(!$y)
  2883. {
  2884. $f = 'fullordersmt';
  2885. $y = $this->fullordersmt->get_number($number);
  2886. }
  2887. if($this->$f->save(array('yhs'=>0),$y['id']))
  2888. {
  2889. echo json_encode(array('success'=>true));exit;
  2890. }
  2891. else
  2892. {
  2893. echo json_encode(array('success'=>false));exit;
  2894. }
  2895. }
  2896. $this->_Template('systemfout_hwyz',$this->data);
  2897. }
  2898. public function _fouthb()
  2899. {
  2900. $post = $this->input->post(NULL, TRUE);
  2901. $xw = '';
  2902. if(isset($_SESSION['api']))
  2903. {
  2904. $user = $this->user->get_api($_SESSION['api']);
  2905. $usp = $user;
  2906. $fgshop = "";$sid = "";$wid="";$wtype="";
  2907. $usersp = explode('|',trim($user['shop'],'|'));
  2908. $userwh = explode('|',trim($user['warehouse'],'|'));
  2909. foreach ($usersp as $value)
  2910. {
  2911. $fgshop .= " shop = ".$value." or";
  2912. $sid .= " id = ".$value." or";
  2913. }
  2914. foreach ($userwh as $value)
  2915. {
  2916. $wid .= " id = ".$value." or";
  2917. $wtype .= " type = ".$value." or";
  2918. }
  2919. if($user['userid'] == 'xw')
  2920. {
  2921. $xw = 1;
  2922. }
  2923. }
  2924. if(isset($post['page']))
  2925. {
  2926. $page = $this->input->post('page',true);
  2927. $perpage = $this->input->post('perpage',true);
  2928. $timetk = $this->input->post('timetk',true);
  2929. $timetj = $this->input->post('timetj',true);
  2930. $shop = $this->input->post('shop',true);
  2931. $type = $this->input->post('type',true);
  2932. $express = $this->input->post('express',true);
  2933. $number = $this->input->post('number',true);
  2934. $waybill = $this->input->post('waybill',true);
  2935. $librarytime = $this->input->post('librarytime',true);
  2936. $timetk = strtotime($timetk);
  2937. $timetj = strtotime($timetj);
  2938. $where = "mergeid = '1'";
  2939. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2940. if($shop)
  2941. {
  2942. $where .= " and shop = '$shop'";
  2943. }
  2944. if($number)
  2945. {
  2946. $where .= " and number like '$number%'";
  2947. }
  2948. if($waybill)
  2949. {
  2950. $where .= " and waybill = '$waybill'";
  2951. }
  2952. if($type)
  2953. {
  2954. $where .= " and type = '$type'";
  2955. }
  2956. if($express)
  2957. {
  2958. $where .= " and express = '$express'";
  2959. }
  2960. //数据排序
  2961. $order_str = "librarytime desc";
  2962. if(empty($page))
  2963. {
  2964. $start = 0;
  2965. $perpage = 1;
  2966. }
  2967. else
  2968. {
  2969. $start = ($page - 1)*$perpage;
  2970. }
  2971. //取得信息列表
  2972. $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2973. //格式化数据
  2974. foreach ($info_list as $key=>$value)
  2975. {
  2976. $shop = $this->shop->read($value['shop']);
  2977. $info_list[$key]['shop'] = $shop['shopname'];
  2978. $express = $this->express->read($value['express']);
  2979. $info_list[$key]['express'] = $express['servicename'];
  2980. $warehouse = $this->warehouse->read($value['type']);
  2981. $info_list[$key]['type'] = $warehouse['title'];
  2982. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2983. }
  2984. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2985. //格式化数据
  2986. foreach ($info_listtt as $key=>$value)
  2987. {
  2988. $shop = $this->shop->read($value['shop']);
  2989. $info_listtt[$key]['shop'] = $shop['shopname'];
  2990. $express = $this->express->read($value['express']);
  2991. $info_listtt[$key]['express'] = $express['servicename'];
  2992. $warehouse = $this->warehouse->read($value['type']);
  2993. $info_listtt[$key]['type'] = $warehouse['title'];
  2994. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2995. }
  2996. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2997. //格式化数据
  2998. foreach ($info_listamz as $key=>$value)
  2999. {
  3000. $shop = $this->shop->read($value['shop']);
  3001. $info_listamz[$key]['shop'] = $shop['shopname'];
  3002. $express = $this->express->read($value['express']);
  3003. $info_listamz[$key]['express'] = $express['servicename'];
  3004. $warehouse = $this->warehouse->read($value['type']);
  3005. $info_listamz[$key]['type'] = $warehouse['title'];
  3006. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3007. }
  3008. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3009. //格式化数据
  3010. foreach ($info_listxw as $key=>$value)
  3011. {
  3012. $shop = $this->shop->read($value['shop']);
  3013. $info_listxw[$key]['shop'] = $shop['shopname'];
  3014. $express = $this->express->read($value['express']);
  3015. $info_listxw[$key]['express'] = $express['servicename'];
  3016. $warehouse = $this->warehouse->read($value['type']);
  3017. $info_listxw[$key]['type'] = $warehouse['title'];
  3018. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3019. }
  3020. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3021. //格式化数据
  3022. foreach ($info_listsmt as $key=>$value)
  3023. {
  3024. $shop = $this->shop->read($value['shop']);
  3025. $info_listsmt[$key]['shop'] = $shop['shopname'];
  3026. $express = $this->express->read($value['express']);
  3027. $info_listsmt[$key]['express'] = $express['servicename'];
  3028. $warehouse = $this->warehouse->read($value['type']);
  3029. $info_listsmt[$key]['type'] = $warehouse['title'];
  3030. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3031. }
  3032. $total = $this->fullorder->find_count($where);
  3033. $total += $this->fullordertt->find_count($where);
  3034. $total += $this->fullorderamz->find_count($where);
  3035. $total += $this->fullorderxw->find_count($where);
  3036. $total += $this->fullordersmt->find_count($where);
  3037. $pagenum = ceil($total/$perpage);
  3038. $over = $total-($start+$perpage);
  3039. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
  3040. echo json_encode($rows);exit;
  3041. }
  3042. if(isset($_SESSION['api']))
  3043. {
  3044. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3045. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3046. $this->data['wlshop'] = $wlshop;
  3047. $this->data['warehouse'] = $warehouse;
  3048. }
  3049. $this->data['xw'] = $xw;
  3050. $this->_Template('systemfout_fouthb',$this->data);
  3051. }
  3052. public function _hb()
  3053. {
  3054. $post = $this->input->post(NULL, TRUE);
  3055. $xw = '';
  3056. if(isset($_SESSION['api']))
  3057. {
  3058. $user = $this->user->get_api($_SESSION['api']);
  3059. $usp = $user;
  3060. $fgshop = "";$sid = "";$wid="";$wtype="";
  3061. $usersp = explode('|',trim($user['shop'],'|'));
  3062. $userwh = explode('|',trim($user['warehouse'],'|'));
  3063. foreach ($usersp as $value)
  3064. {
  3065. $fgshop .= " shop = ".$value." or";
  3066. $sid .= " id = ".$value." or";
  3067. }
  3068. foreach ($userwh as $value)
  3069. {
  3070. $wid .= " id = ".$value." or";
  3071. $wtype .= " type = ".$value." or";
  3072. }
  3073. if($user['userid'] == 'xw')
  3074. {
  3075. $xw = 1;
  3076. }
  3077. }
  3078. if(isset($post['page']))
  3079. {
  3080. $page = $this->input->post('page',true);
  3081. $perpage = $this->input->post('perpage',true);
  3082. $timetk = $this->input->post('timetk',true);
  3083. $timetj = $this->input->post('timetj',true);
  3084. $shop = $this->input->post('shop',true);
  3085. $source = $this->input->post('source',true);
  3086. $orderinfo = $this->input->post('orderinfo',true);
  3087. $number = $this->input->post('number',true);
  3088. $library = $this->input->post('library',true);
  3089. $waybill = $this->input->post('waybill',true);
  3090. $express = $this->input->post('express',true);
  3091. $type = $this->input->post('type',true);
  3092. $lowe = $this->input->post('lowe',true);
  3093. $so = $this->input->post('so',true);
  3094. $librarytime = $this->input->post('librarytime',true);
  3095. $timetk = strtotime($timetk);
  3096. $timetj = strtotime($timetj);
  3097. $cxtime = 'id';
  3098. $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
  3099. if($timetk && $timetj && $library == 1)
  3100. {
  3101. //$cxtime = 'reviewtime';
  3102. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  3103. $where .= " and state != 217";
  3104. }
  3105. else if($timetk && $timetj && $library == 2)
  3106. {
  3107. $cxtime = 'librarytime';
  3108. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  3109. }
  3110. if($shop)
  3111. {
  3112. $where .= " and shop = '$shop'";
  3113. }
  3114. if($number)
  3115. {
  3116. $where .= " and number = '$number'";
  3117. }
  3118. if($library)
  3119. {
  3120. $where .= " and library = '$library'";
  3121. }
  3122. if($waybill)
  3123. {
  3124. $where .= " and waybill = '$waybill'";
  3125. }
  3126. if($express)
  3127. {
  3128. $where .= " and express = '$express'";
  3129. }
  3130. if($orderinfo)
  3131. {
  3132. $where .= " and orderinfo = '$orderinfo'";
  3133. }
  3134. if($type)
  3135. {
  3136. $where .= " and type = '$type'";
  3137. }
  3138. if($lowe)
  3139. {
  3140. $where .= " and shipremarks like '%$lowe%'";
  3141. }
  3142. if($so)
  3143. {
  3144. $where .= " and shipremarks like '%$so%'";
  3145. }
  3146. //数据排序
  3147. $order_str = $cxtime." desc";
  3148. if(empty($page))
  3149. {
  3150. $start = 0;
  3151. $perpage = 1;
  3152. }
  3153. else
  3154. {
  3155. $start = ($page - 1)*$perpage;
  3156. }
  3157. //取得信息列表
  3158. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3159. //格式化数据
  3160. foreach ($info_list as $key=>$value)
  3161. {
  3162. $shop = $this->shop->read($value['shop']);
  3163. $info_list[$key]['shop'] = $shop['shopname'];
  3164. if($value['waybill'] == '0')
  3165. {
  3166. $info_list[$key]['waybill'] = "";
  3167. }
  3168. $express = $this->express->read($value['express']);
  3169. $info_list[$key]['express'] = $express['servicename'];
  3170. $warehouse = $this->warehouse->read($value['type']);
  3171. $info_list[$key]['type'] = $warehouse['title'];
  3172. if($value['print'] == 1)
  3173. {
  3174. $info_list[$key]['print'] = '不可打印';
  3175. }
  3176. else if($value['print'] == 2)
  3177. {
  3178. $info_list[$key]['print'] = '未打印';
  3179. }
  3180. else if($value['print'] == 3)
  3181. {
  3182. $info_list[$key]['print'] = '已打印';
  3183. }
  3184. if($value['library'] == 1)
  3185. {
  3186. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  3187. }
  3188. else if($value['library'] == 2)
  3189. {
  3190. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  3191. }
  3192. else if($value['library'] == 3)
  3193. {
  3194. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  3195. }
  3196. if($value['librarytime'] == '0')
  3197. {
  3198. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3199. }
  3200. else
  3201. {
  3202. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  3203. }
  3204. $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['orderremarks']);
  3205. }
  3206. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3207. //格式化数据
  3208. foreach ($info_listtt as $key=>$value)
  3209. {
  3210. $shop = $this->shop->read($value['shop']);
  3211. $info_listtt[$key]['shop'] = $shop['shopname'];
  3212. if($value['waybill'] == '0')
  3213. {
  3214. $info_listtt[$key]['waybill'] = "";
  3215. }
  3216. $express = $this->express->read($value['express']);
  3217. $info_listtt[$key]['express'] = $express['servicename'];
  3218. $warehouse = $this->warehouse->read($value['type']);
  3219. $info_listtt[$key]['type'] = $warehouse['title'];
  3220. if($value['print'] == 1)
  3221. {
  3222. $info_listtt[$key]['print'] = '不可打印';
  3223. }
  3224. else if($value['print'] == 2)
  3225. {
  3226. $info_listtt[$key]['print'] = '未打印';
  3227. }
  3228. else if($value['print'] == 3)
  3229. {
  3230. $info_listtt[$key]['print'] = '已打印';
  3231. }
  3232. if($value['library'] == 1)
  3233. {
  3234. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  3235. }
  3236. else if($value['library'] == 2)
  3237. {
  3238. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  3239. }
  3240. else if($value['library'] == 3)
  3241. {
  3242. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  3243. }
  3244. if($value['librarytime'] == '0')
  3245. {
  3246. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  3247. }
  3248. else
  3249. {
  3250. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3251. }
  3252. }
  3253. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3254. //格式化数据
  3255. foreach ($info_listamz as $key=>$value)
  3256. {
  3257. $shop = $this->shop->read($value['shop']);
  3258. $info_listamz[$key]['shop'] = $shop['shopname'];
  3259. if($value['waybill'] == '0')
  3260. {
  3261. $info_listamz[$key]['waybill'] = "";
  3262. }
  3263. $express = $this->express->read($value['express']);
  3264. $info_listamz[$key]['express'] = $express['servicename'];
  3265. $warehouse = $this->warehouse->read($value['type']);
  3266. $info_listamz[$key]['type'] = $warehouse['title'];
  3267. if($value['print'] == 1)
  3268. {
  3269. $info_listamz[$key]['print'] = '不可打印';
  3270. }
  3271. else if($value['print'] == 2)
  3272. {
  3273. $info_listamz[$key]['print'] = '未打印';
  3274. }
  3275. else if($value['print'] == 3)
  3276. {
  3277. $info_listamz[$key]['print'] = '已打印';
  3278. }
  3279. if($value['library'] == 1)
  3280. {
  3281. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  3282. }
  3283. else if($value['library'] == 2)
  3284. {
  3285. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  3286. }
  3287. else if($value['library'] == 3)
  3288. {
  3289. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  3290. }
  3291. if($value['librarytime'] == '0')
  3292. {
  3293. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  3294. }
  3295. else
  3296. {
  3297. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3298. }
  3299. }
  3300. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3301. //格式化数据
  3302. foreach ($info_listxw as $key=>$value)
  3303. {
  3304. $shop = $this->shop->read($value['shop']);
  3305. $info_listxw[$key]['shop'] = $shop['shopname'];
  3306. if($value['waybill'] == '0')
  3307. {
  3308. $info_listxw[$key]['waybill'] = "";
  3309. }
  3310. $express = $this->express->read($value['express']);
  3311. $info_listxw[$key]['express'] = $express['servicename'];
  3312. $warehouse = $this->warehouse->read($value['type']);
  3313. $info_listxw[$key]['type'] = $warehouse['title'];
  3314. if($value['print'] == 1)
  3315. {
  3316. $info_listxw[$key]['print'] = '不可打印';
  3317. }
  3318. else if($value['print'] == 2)
  3319. {
  3320. $info_listxw[$key]['print'] = '未打印';
  3321. }
  3322. else if($value['print'] == 3)
  3323. {
  3324. $info_listxw[$key]['print'] = '已打印';
  3325. }
  3326. if($value['library'] == 1)
  3327. {
  3328. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  3329. }
  3330. else if($value['library'] == 2)
  3331. {
  3332. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  3333. }
  3334. else if($value['library'] == 3)
  3335. {
  3336. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  3337. }
  3338. if($value['librarytime'] == '0')
  3339. {
  3340. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  3341. }
  3342. else
  3343. {
  3344. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3345. }
  3346. }
  3347. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  3348. //格式化数据
  3349. foreach ($info_listsmt as $key=>$value)
  3350. {
  3351. $shop = $this->shop->read($value['shop']);
  3352. $info_listsmt[$key]['shop'] = $shop['shopname'];
  3353. if($value['waybill'] == '0')
  3354. {
  3355. $info_listsmt[$key]['waybill'] = "";
  3356. }
  3357. $express = $this->express->read($value['express']);
  3358. $info_listsmt[$key]['express'] = $express['servicename'];
  3359. $warehouse = $this->warehouse->read($value['type']);
  3360. $info_listsmt[$key]['type'] = $warehouse['title'];
  3361. if($value['print'] == 1)
  3362. {
  3363. $info_listsmt[$key]['print'] = '不可打印';
  3364. }
  3365. else if($value['print'] == 2)
  3366. {
  3367. $info_listsmt[$key]['print'] = '未打印';
  3368. }
  3369. else if($value['print'] == 3)
  3370. {
  3371. $info_listsmt[$key]['print'] = '已打印';
  3372. }
  3373. if($value['library'] == 1)
  3374. {
  3375. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  3376. }
  3377. else if($value['library'] == 2)
  3378. {
  3379. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  3380. }
  3381. else if($value['library'] == 3)
  3382. {
  3383. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  3384. }
  3385. if($value['librarytime'] == '0')
  3386. {
  3387. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  3388. }
  3389. else
  3390. {
  3391. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3392. }
  3393. }
  3394. $total = $this->fullorder->find_count($where);
  3395. $total += $this->fullordertt->find_count($where);
  3396. $total += $this->fullorderamz->find_count($where);
  3397. $total += $this->fullorderxw->find_count($where);
  3398. $total += $this->fullordersmt->find_count($where);
  3399. $pagenum = ceil($total/$perpage);
  3400. $over = $total-($start+$perpage);
  3401. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt)));
  3402. echo json_encode($rows);exit;
  3403. }
  3404. if(isset($_SESSION['api']))
  3405. {
  3406. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3407. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3408. $this->data['wlshop'] = $wlshop;
  3409. $this->data['warehouse'] = $warehouse;
  3410. }
  3411. $this->data['xw'] = $xw;
  3412. $this->_Template('systemfout_hb',$this->data);
  3413. }
  3414. }