Systemfout.php 114 KB

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