Systemfout.php 111 KB

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