Systemfout.php 112 KB

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