Systemfout.php 113 KB

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