Systemfout.php 112 KB

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