Systemfout.php 113 KB

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