Systemfout.php 111 KB

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