Systemfout.php 112 KB

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