Systemfout.php 121 KB

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