Systemfout.php 121 KB

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