Systemfout.php 112 KB

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