Systemfout.php 101 KB

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