Systemfout.php 112 KB

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