Systemfout.php 114 KB

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