Systemfout.php 114 KB

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