Systemfout.php 108 KB

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