Systemfout.php 112 KB

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