Systemfout.php 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178
  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. }
  42. //定义方法的调用规则 获取URI第二段值
  43. public function _remap($arg,$arg_array)
  44. {
  45. if($arg == 'fedexhz')
  46. {
  47. $this->_fedexhz();
  48. }
  49. else if($arg == 'fout')
  50. {
  51. $this->_fout($arg_array);
  52. }
  53. else if($arg == 'excel')
  54. {
  55. $this->_excel($arg_array);
  56. }
  57. else if($arg == 'cpexcel')
  58. {
  59. $this->_cpexcel($arg_array);
  60. }
  61. else if($arg == 'orderyz')
  62. {
  63. $this->_orderyz();
  64. }
  65. else if($arg == 'hwyz')
  66. {
  67. $this->_hwyz();
  68. }
  69. else
  70. {
  71. $this->_index();
  72. }
  73. }
  74. public function _index()
  75. {
  76. $post = $this->input->post(NULL, TRUE);
  77. $xw = '';
  78. if(isset($_SESSION['api']))
  79. {
  80. $user = $this->user->get_api($_SESSION['api']);
  81. $usp = $user;
  82. $fgshop = "";$sid = "";$wid="";$wtype="";
  83. $usersp = explode('|',trim($user['shop'],'|'));
  84. $userwh = explode('|',trim($user['warehouse'],'|'));
  85. foreach ($usersp as $value)
  86. {
  87. $fgshop .= " shop = ".$value." or";
  88. $sid .= " id = ".$value." or";
  89. }
  90. foreach ($userwh as $value)
  91. {
  92. $wid .= " id = ".$value." or";
  93. $wtype .= " type = ".$value." or";
  94. }
  95. if($user['userid'] == 'xw')
  96. {
  97. $xw = 1;
  98. }
  99. }
  100. if(isset($post['page']))
  101. {
  102. $page = $this->input->post('page',true);
  103. $perpage = $this->input->post('perpage',true);
  104. $timetk = $this->input->post('timetk',true);
  105. $timetj = $this->input->post('timetj',true);
  106. $shop = $this->input->post('shop',true);
  107. $source = $this->input->post('source',true);
  108. $orderinfo = $this->input->post('orderinfo',true);
  109. $number = $this->input->post('number',true);
  110. $library = $this->input->post('library',true);
  111. $waybill = $this->input->post('waybill',true);
  112. $express = $this->input->post('express',true);
  113. $type = $this->input->post('type',true);
  114. $lowe = $this->input->post('lowe',true);
  115. $so = $this->input->post('so',true);
  116. $librarytime = $this->input->post('librarytime',true);
  117. $timetk = strtotime($timetk);
  118. $timetj = strtotime($timetj);
  119. $cxtime = 'id';
  120. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  121. if($timetk && $timetj && $library == 1)
  122. {
  123. //$cxtime = 'reviewtime';
  124. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  125. $where .= " and state != 217";
  126. }
  127. else if($timetk && $timetj && $library == 2)
  128. {
  129. $cxtime = 'librarytime';
  130. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  131. }
  132. if($shop)
  133. {
  134. $where .= " and shop = '$shop'";
  135. }
  136. if($number)
  137. {
  138. $where .= " and number = '$number'";
  139. }
  140. if($library)
  141. {
  142. $where .= " and library = '$library'";
  143. }
  144. if($waybill)
  145. {
  146. $where .= " and waybill = '$waybill'";
  147. }
  148. if($express)
  149. {
  150. $where .= " and express = '$express'";
  151. }
  152. if($orderinfo)
  153. {
  154. $where .= " and orderinfo = '$orderinfo'";
  155. }
  156. if($type)
  157. {
  158. $where .= " and type = '$type'";
  159. }
  160. if($lowe)
  161. {
  162. $where .= " and shipremarks like '%$lowe%'";
  163. }
  164. if($so)
  165. {
  166. $where .= " and shipremarks like '%$so%'";
  167. }
  168. //数据排序
  169. $order_str = $cxtime." desc";
  170. if(empty($page))
  171. {
  172. $start = 0;
  173. $perpage = 1;
  174. }
  175. else
  176. {
  177. $start = ($page - 1)*$perpage;
  178. }
  179. //取得信息列表
  180. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  181. //格式化数据
  182. foreach ($info_list as $key=>$value)
  183. {
  184. $shop = $this->shop->read($value['shop']);
  185. $info_list[$key]['shop'] = $shop['shopname'];
  186. if($value['waybill'] == '0')
  187. {
  188. $info_list[$key]['waybill'] = "";
  189. }
  190. $express = $this->express->read($value['express']);
  191. $info_list[$key]['express'] = $express['servicename'];
  192. $warehouse = $this->warehouse->read($value['type']);
  193. $info_list[$key]['type'] = $warehouse['title'];
  194. if($value['print'] == 1)
  195. {
  196. $info_list[$key]['print'] = '不可打印';
  197. }
  198. else if($value['print'] == 2)
  199. {
  200. $info_list[$key]['print'] = '未打印';
  201. }
  202. else if($value['print'] == 3)
  203. {
  204. $info_list[$key]['print'] = '已打印';
  205. }
  206. if($value['library'] == 1)
  207. {
  208. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  209. }
  210. else if($value['library'] == 2)
  211. {
  212. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  213. }
  214. else if($value['library'] == 3)
  215. {
  216. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  217. }
  218. if($value['librarytime'] == '0')
  219. {
  220. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  221. }
  222. else
  223. {
  224. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  225. }
  226. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  227. }
  228. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  229. //格式化数据
  230. foreach ($info_listtt as $key=>$value)
  231. {
  232. $shop = $this->shop->read($value['shop']);
  233. $info_listtt[$key]['shop'] = $shop['shopname'];
  234. if($value['waybill'] == '0')
  235. {
  236. $info_listtt[$key]['waybill'] = "";
  237. }
  238. $express = $this->express->read($value['express']);
  239. $info_listtt[$key]['express'] = $express['servicename'];
  240. $warehouse = $this->warehouse->read($value['type']);
  241. $info_listtt[$key]['type'] = $warehouse['title'];
  242. if($value['print'] == 1)
  243. {
  244. $info_listtt[$key]['print'] = '不可打印';
  245. }
  246. else if($value['print'] == 2)
  247. {
  248. $info_listtt[$key]['print'] = '未打印';
  249. }
  250. else if($value['print'] == 3)
  251. {
  252. $info_listtt[$key]['print'] = '已打印';
  253. }
  254. if($value['library'] == 1)
  255. {
  256. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  257. }
  258. else if($value['library'] == 2)
  259. {
  260. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  261. }
  262. else if($value['library'] == 3)
  263. {
  264. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  265. }
  266. if($value['librarytime'] == '0')
  267. {
  268. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  269. }
  270. else
  271. {
  272. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  273. }
  274. }
  275. $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);
  276. //格式化数据
  277. foreach ($info_listsmt as $key=>$value)
  278. {
  279. $shop = $this->shop->read($value['shop']);
  280. $info_listsmt[$key]['shop'] = $shop['shopname'];
  281. if($value['waybill'] == '0')
  282. {
  283. $info_listsmt[$key]['waybill'] = "";
  284. }
  285. $express = $this->express->read($value['express']);
  286. $info_listsmt[$key]['express'] = $express['servicename'];
  287. $warehouse = $this->warehouse->read($value['type']);
  288. $info_listsmt[$key]['type'] = $warehouse['title'];
  289. if($value['print'] == 1)
  290. {
  291. $info_listsmt[$key]['print'] = '不可打印';
  292. }
  293. else if($value['print'] == 2)
  294. {
  295. $info_listsmt[$key]['print'] = '未打印';
  296. }
  297. else if($value['print'] == 3)
  298. {
  299. $info_listsmt[$key]['print'] = '已打印';
  300. }
  301. if($value['library'] == 1)
  302. {
  303. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  304. }
  305. else if($value['library'] == 2)
  306. {
  307. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  308. }
  309. else if($value['library'] == 3)
  310. {
  311. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  312. }
  313. if($value['librarytime'] == '0')
  314. {
  315. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  316. }
  317. else
  318. {
  319. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  320. }
  321. }
  322. $total = $this->fullorder->find_count($where);
  323. $total += $this->fullordertt->find_count($where);
  324. $total += $this->fullordersmt->find_count($where);
  325. $pagenum = ceil($total/$perpage);
  326. $over = $total-($start+$perpage);
  327. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listsmt)));
  328. echo json_encode($rows);exit;
  329. }
  330. if(isset($_SESSION['api']))
  331. {
  332. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  333. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  334. $this->data['wlshop'] = $wlshop;
  335. $this->data['warehouse'] = $warehouse;
  336. }
  337. $this->data['xw'] = $xw;
  338. $this->_Template('systemfout',$this->data);
  339. }
  340. public function _fout()
  341. {
  342. $post = $this->input->post(NULL, TRUE);
  343. if(isset($post['order']))
  344. {
  345. $time = time();
  346. $order = $this->input->post('order',true);
  347. $weight = $this->input->post('weight',true);
  348. if(!isset($weight))//测试没问题后可以删
  349. {
  350. $weight = '';
  351. }
  352. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  353. {
  354. $order = substr($order,0,12);
  355. }
  356. if(strlen($order) == '34')//联邦杭州超长运单截取
  357. {
  358. $order = substr($order,22,12);
  359. }
  360. if(!$order)
  361. {
  362. echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
  363. }
  364. $fullorder_name = 'fullorder';$outtype = 1;
  365. $y = $this->fullorder->get_waybill($order);
  366. if(!$y)
  367. {
  368. $y = $this->fullorder->get_number($order);
  369. $outtype = 2;
  370. if(!$y)
  371. {
  372. $fullorder_name = 'fullordersmt';$outtype = 1;
  373. $y = $this->fullordersmt->get_waybill($order);
  374. if(!$y)
  375. {
  376. $y = $this->fullordersmt->get_number($order);
  377. $outtype = 2;
  378. if(!$y)
  379. {
  380. $fullorder_name = 'fullordertt';$outtype = 1;
  381. $y = $this->fullordertt->get_waybill($order);
  382. if(!$y)
  383. {
  384. $y = $this->fullordertt->get_number($order);
  385. $outtype = 2;
  386. if(!$y)
  387. {
  388. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. }
  395. if($y['mergeid'] == '1')
  396. {
  397. $y = $this->$fullorder_name->read($y['merge']);
  398. }
  399. $express = $this->express->read($y['express']);
  400. if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
  401. {
  402. $y['librarynot'] = '客户已取消!';
  403. }
  404. 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先关了
  405. {
  406. echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
  407. }
  408. if($y['library'] > 1)
  409. {
  410. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  411. }
  412. if($express['out'] != 3)
  413. {
  414. if($express['out'] != $outtype)
  415. {
  416. $smlx = ($express['out']=='1')?'运单':'发货单';
  417. echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
  418. }
  419. }
  420. if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
  421. {
  422. $y['waybill'] = trim($y['waybill'],' ');
  423. 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)
  424. {
  425. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit;
  426. }
  427. else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42)
  428. {
  429. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit;
  430. }
  431. else if(strlen($y['waybill']) == 18 && $y['express'] != 3)
  432. {
  433. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit;
  434. }
  435. }
  436. $numweight = str_replace('kg','',$weight);
  437. if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
  438. {
  439. if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  440. {
  441. echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  442. }
  443. $yzweight = explode('.',$numweight);
  444. if($yzweight[0] == '')
  445. {
  446. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  447. }
  448. if($numweight < ($y['jweight']/1000))
  449. {
  450. echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  451. }
  452. if($numweight -($y['jweight']/1000) > 0.9 && $y['number'] != 'QQS-30401-002')
  453. {
  454. echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会或梦体处理!','success'=>false));exit;
  455. }
  456. if($numweight > '0.98' && $y['express'] == '3')
  457. {
  458. echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
  459. }
  460. if($numweight > '2' && $y['express'] == '37')
  461. {
  462. echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
  463. }
  464. if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
  465. {
  466. echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
  467. }
  468. }
  469. if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
  470. {
  471. echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  472. }
  473. if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
  474. {
  475. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  476. echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit;
  477. }
  478. if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
  479. {
  480. echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  481. }
  482. $this->db->trans_begin();
  483. $warehouse = $this->warehouse->read($y['type']);
  484. if($warehouse['zd'] == '1')
  485. {
  486. if($warehouse['bdck'] == '')
  487. {
  488. echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
  489. }
  490. $bdck = $warehouse['bdck'];
  491. $wh = $this->_fout_db($y,$warehouse,$bdck);
  492. if($wh['fh'] == 2)
  493. {
  494. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  495. if($kcyz['t'] == '0')
  496. {
  497. if($kcyz['fpdata'] != '')
  498. {
  499. $x['whlabel'] = $kcyz['whlabel'];
  500. $x['fpdata'] = $kcyz['fpdata'];
  501. $y['whlabel'] = $x['whlabel'];
  502. $this->$fullorder_name->save($x,$y['id']);
  503. }
  504. }
  505. $wh = $this->_fout_db($y,$warehouse,$bdck);
  506. if($wh['fh'] == 2)
  507. {
  508. echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
  509. }
  510. }
  511. foreach ($wh['sj'] as $v)
  512. {
  513. $this->$bdck->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  514. }
  515. }
  516. /**
  517. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
  518. {
  519. $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  520. $cpsl = 0;
  521. $pp = explode('|',trim($y['whlabel'],'|'));
  522. foreach ($pp as $va)
  523. {
  524. $num = explode('-',$va);
  525. $cpsl += $num[1];
  526. }
  527. if(count($whlabel) != $cpsl)
  528. {
  529. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  530. }
  531. foreach ($whlabel as $v)
  532. {
  533. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  534. }
  535. }
  536. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
  537. {
  538. $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
  539. $cpsl = 0;
  540. $pp = explode('|',trim($y['whlabel'],'|'));
  541. foreach ($pp as $va)
  542. {
  543. $num = explode('-',$va);
  544. if(stripos($num[2],'z') !== false)//如果是特殊库存
  545. {
  546. $cpsl += $num[1];
  547. }
  548. }
  549. if(count($wh) != $cpsl)
  550. {
  551. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  552. }
  553. foreach ($wh as $v)
  554. {
  555. if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
  556. {
  557. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  558. }
  559. }
  560. }
  561. **/
  562. /**
  563. if($y['dbapi'] == 99 && $y['scapi'] == 99)
  564. {
  565. $d = $this->apiyy->get_chd($y);
  566. if($d['Data'][0]['m_isSucess'] != 1)
  567. {
  568. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  569. }
  570. }
  571. $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
  572. if(isset($systemtransfer[0]))
  573. {
  574. foreach ($systemtransfer as $v)
  575. {
  576. if($v['dbapi'] != 99)
  577. {
  578. echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
  579. }
  580. }
  581. $y['ts'] = count($systemtransfer);
  582. $d = $this->apiyy->get_chd($y);
  583. if($d['Data'][0]['m_isSucess'] != 1)
  584. {
  585. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  586. }
  587. }
  588. **/
  589. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  590. {
  591. $d = $this->dhl->get_data_9610($y);
  592. if($d != 1)
  593. {
  594. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  595. echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
  596. }
  597. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  598. }
  599. if($fullorder_name == 'fullordersmt')
  600. {
  601. $stt = ($y['waybill']!='')?209:$y['state'];
  602. $this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0),$y['id']);
  603. /**
  604. if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  605. {
  606. echo json_encode(array('success'=>true));exit;
  607. }
  608. else
  609. {
  610. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  611. }
  612. **/
  613. }
  614. else if($fullorder_name == 'fullordertt' && $y['source'] == 1)
  615. {
  616. /**
  617. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  618. {
  619. echo json_encode(array('success'=>true));exit;
  620. }
  621. else
  622. {
  623. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  624. }
  625. **/
  626. $this->$fullorder_name->save(array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0),$y['id']);
  627. }
  628. else
  629. {
  630. /**
  631. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  632. {
  633. echo json_encode(array('success'=>true));exit;
  634. }
  635. else
  636. {
  637. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  638. }
  639. **/
  640. $this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0),$y['id']);
  641. }
  642. if ($this->db->trans_status() === TRUE)
  643. {
  644. $this->db->trans_commit();
  645. echo json_encode(array('success'=>true));
  646. }
  647. else
  648. {
  649. $this->db->trans_rollback();
  650. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  651. }
  652. }
  653. }
  654. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  655. {
  656. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  657. $cpsl = 0;
  658. $pp = explode('|',trim($y['whlabel'],'|'));
  659. foreach ($pp as $va)
  660. {
  661. $num = explode('-',$va);
  662. if(isset($num[2]))
  663. {
  664. if(stripos($num[2],$warehouse['hz']) !== false)
  665. {
  666. $cpsl += $num[1];
  667. }
  668. }
  669. }
  670. if(count($wh) == $cpsl)
  671. {
  672. return array('fh'=>1,'sj'=>$wh);
  673. }
  674. else
  675. {
  676. return array('fh'=>2);
  677. }
  678. }
  679. public function _fedexhz()
  680. {
  681. $post = $this->input->post(NULL, TRUE);
  682. if(isset($post['id']))
  683. {
  684. $id = $this->input->post('id',true);
  685. $fullorder_name = $this->input->post('name',true);
  686. $express = $this->input->post('express',true);
  687. $express = $this->express->read($express);
  688. $fullorder = $this->$fullorder_name->read($id);
  689. if($fullorder['type'] == '2')
  690. {
  691. $fullorder['type'] = 1;
  692. }
  693. $time = time();
  694. $fullorder = $this->_text($fullorder);//获取所需信息
  695. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  696. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  697. $time = time();
  698. if($express['printcode'] == "FEDEXGF")
  699. {
  700. $barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  701. if($barcode['x'] == 1)
  702. {
  703. $bctime = date('Ymd',$time);
  704. $Hwaybill = $barcode['waybill'];
  705. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  706. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  707. if(isset($barcode['label']) && isset($Hwaybill))
  708. {
  709. if($fullorder['waybill'] != "")
  710. {
  711. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  712. }
  713. else
  714. {
  715. $oldwaybill = $fullorder['oldwaybill'];
  716. }
  717. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  718. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  719. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  720. {
  721. $warehouse = $this->warehouse->read($fullorder['type']);
  722. $text = array();
  723. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  724. $text['number'] = $fullorder['number'];
  725. $text['mode'] = '95';
  726. $text['pdfnum'] = 1;
  727. $rows = array('text'=>$text);
  728. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  729. }
  730. else
  731. {
  732. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  733. }
  734. }
  735. }
  736. else
  737. {
  738. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  739. }
  740. }
  741. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  742. {
  743. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  744. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  745. if($barcode['x'] == 1)
  746. {
  747. $bctime = date('Ymd',$time);
  748. $Hwaybill = $barcode['waybill'];
  749. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  750. if(isset($barcode['label']) && isset($Hwaybill))
  751. {
  752. if($fullorder['waybill'] != "")
  753. {
  754. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  755. }
  756. else
  757. {
  758. $oldwaybill = $fullorder['oldwaybill'];
  759. }
  760. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  761. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  762. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  763. {
  764. $type = 1;
  765. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  766. }
  767. }
  768. }
  769. else
  770. {
  771. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  772. }
  773. }
  774. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  775. {
  776. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  777. if($barcode['c'] == 1)
  778. {
  779. $bctime = date('Ymd',$time);
  780. $Hwaybill = $barcode['data']['waybill'];
  781. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  782. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  783. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  784. {
  785. if($fullorder['waybill'] != "")
  786. {
  787. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  788. }
  789. else
  790. {
  791. $oldwaybill = $fullorder['oldwaybill'];
  792. }
  793. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  794. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  795. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  796. {
  797. $warehouse = $this->warehouse->read($fullorder['type']);
  798. $text = array();
  799. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  800. $text['number'] = $fullorder['number'];
  801. $text['mode'] = '95';
  802. $text['pdfnum'] = 1;
  803. $rows = array('text'=>$text);
  804. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  805. }
  806. }
  807. }
  808. else
  809. {
  810. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  811. }
  812. }
  813. else
  814. {
  815. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  816. }
  817. }
  818. }
  819. public function _text($fullorder)
  820. {
  821. /** 发票地址信息暂时无用
  822. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  823. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  824. $fullorder['baddress'][1] = $country['ename'];
  825. **/
  826. //获取所用相关信息
  827. $warehouse = $this->warehouse->read($fullorder['type']);
  828. $country = $this->country->read($fullorder['country']);//订单国家信息
  829. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  830. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  831. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  832. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  833. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  834. $fullorder['country'] = $country['ename'];//订单国家名
  835. $fullorder['zhou'] = $country['continent'];//所属州
  836. $express = $this->express->read($fullorder['express']);
  837. $fullorder['express'] = $express['servicename'];
  838. $fullorder['account'] = $express['account'];
  839. $fullorder['printcode'] = $express['printcode'];
  840. $fullorder['time'] = date('Y-m-d',time());
  841. $fullorder['times'] = date('Y-m-d H:i',time());
  842. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  843. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  844. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  845. $shop = $this->shop->read($fullorder['shop']);
  846. $fullorder['shop'] = $shop['shopname'];
  847. return $fullorder;
  848. }
  849. public function _lowe()
  850. {
  851. $post = $this->input->post(NULL, TRUE);
  852. if(isset($post['lowe']))
  853. {
  854. $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');
  855. echo json_encode(array('msg'=>$lowe));exit;
  856. }
  857. }
  858. public function _pdf($pdf,$title,$bctime)
  859. {
  860. $pdf_path = './data/pdf/'.$bctime.'/';
  861. $file_base64 = $pdf;
  862. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  863. $file_base64 = base64_decode($file_base64);
  864. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  865. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  866. return $bctime;
  867. }
  868. public function _pdfurl($pdf,$title,$bctime)
  869. {
  870. $pdf_path = './data/pdf/'.$bctime.'/';
  871. $pdf = fopen($pdf,"r");
  872. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  873. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  874. return $bctime;
  875. }
  876. public function _excel()
  877. {
  878. $xw = '';
  879. if(isset($_SESSION['api']))
  880. {
  881. $user = $this->user->get_api($_SESSION['api']);
  882. $usp = $user;
  883. $fgshop = "";$sid = "";$wid="";$wtype="";
  884. $usersp = explode('|',trim($user['shop'],'|'));
  885. $userwh = explode('|',trim($user['warehouse'],'|'));
  886. foreach ($usersp as $value)
  887. {
  888. $fgshop .= " shop = ".$value." or";
  889. $sid .= " id = ".$value." or";
  890. }
  891. foreach ($userwh as $value)
  892. {
  893. $wid .= " id = ".$value." or";
  894. $wtype .= " type = ".$value." or";
  895. }
  896. if($user['userid'] == 'xw')
  897. {
  898. $xw = 1;
  899. }
  900. }
  901. if(isset($_GET['fexcel']))
  902. {
  903. $dowid = $this->input->get('a');
  904. $wid = "";
  905. if($dowid != "")
  906. {
  907. $id_arr = explode(',',rtrim($dowid,','));
  908. foreach ($id_arr as $v)
  909. {
  910. $wid .= " id = '$v' or";
  911. }
  912. $wid = " and".rtrim($wid,'or');
  913. }
  914. $t = $this->input->get('t',true);
  915. $timetk = $this->input->get('timetk',true);
  916. $timetj = $this->input->get('timetj',true);
  917. $shop = $this->input->get('shop',true);
  918. $source = $this->input->get('source',true);
  919. $orderinfo = $this->input->get('orderinfo',true);
  920. $number = $this->input->get('number',true);
  921. $library = $this->input->get('library',true);
  922. $waybill = $this->input->get('waybill',true);
  923. $express = $this->input->get('express',true);
  924. $type = $this->input->get('type',true);
  925. $so = $this->input->get('so',true);
  926. $timetk = strtotime($timetk);
  927. $timetj = strtotime($timetj);
  928. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  929. if($timetk && $timetj && $library == 1)
  930. {
  931. //$cxtime = 'reviewtime';
  932. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  933. }
  934. else if($timetk && $timetj && $library == 2)
  935. {
  936. $cxtime = 'librarytime';
  937. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  938. }
  939. /**
  940. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  941. if($timetk && $timetj && $library == 1)
  942. {
  943. //$cxtime = 'reviewtime';
  944. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  945. }
  946. else if($timetk && $timetj && $library == 2)
  947. {
  948. $cxtime = 'librarytime';
  949. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  950. }
  951. **/
  952. if(isset($_SESSION['api']))
  953. {
  954. if($type)
  955. {
  956. $where .= " and type = '$type'";
  957. }
  958. else
  959. {
  960. $uw = '';
  961. $u = $this->user->get_api($_SESSION['api']);
  962. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  963. foreach ($u['warehouse'] as $v)
  964. {
  965. $uw .= " type = '$v' or";
  966. }
  967. $uw = rtrim($uw,'or');
  968. $uw = " and (".ltrim($uw,' ').")";
  969. $where .= $uw;
  970. }
  971. }
  972. else
  973. {
  974. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  975. }
  976. if($shop)
  977. {
  978. $where .= " and shop = '$shop'";
  979. }
  980. if($number)
  981. {
  982. $where .= " and number = '$number'";
  983. }
  984. if($library)
  985. {
  986. $where .= " and library = '$library'";
  987. }
  988. if($waybill)
  989. {
  990. $where .= " and waybill = '$waybill'";
  991. }
  992. if($express)
  993. {
  994. $where .= " and express = '$express'";
  995. }
  996. if($orderinfo)
  997. {
  998. $where .= " and orderinfo = '$orderinfo'";
  999. }
  1000. if($so)
  1001. {
  1002. $where .= " and shipremarks like '%$so%'";
  1003. }
  1004. //数据排序
  1005. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1006. $order_str = "librarytime desc";
  1007. if(empty($page))
  1008. {
  1009. $start = 0;
  1010. $perpage = 1;
  1011. }
  1012. else
  1013. {
  1014. $start = ($page - 1)*$perpage;
  1015. }
  1016. $typeclass = array();
  1017. $tclass = $this->typeclass->find_all();
  1018. foreach ($tclass as $v)
  1019. {
  1020. $typeclass[$v['id']] = $v;
  1021. }
  1022. //取得信息列表
  1023. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1024. //格式化数据
  1025. foreach ($info_list as $key=>$value)
  1026. {
  1027. $shop = $this->shop->read($value['shop']);
  1028. $info_list[$key]['shop'] = $shop['shopname'];
  1029. if($value['waybill'] == '0')
  1030. {
  1031. $info_list[$key]['waybill'] = "";
  1032. }
  1033. $express = $this->express->read($value['express']);
  1034. $info_list[$key]['express'] = $express['servicename'];
  1035. $warehouse = $this->warehouse->read($value['type']);
  1036. $info_list[$key]['type'] = $warehouse['title'];
  1037. if($value['print'] == 1)
  1038. {
  1039. $info_list[$key]['print'] = '不可打印';
  1040. }
  1041. else if($value['print'] == 2)
  1042. {
  1043. $info_list[$key]['print'] = '未打印';
  1044. }
  1045. else if($value['print'] == 3)
  1046. {
  1047. $info_list[$key]['print'] = '已打印';
  1048. }
  1049. if($value['library'] == 1)
  1050. {
  1051. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1052. }
  1053. else if($value['library'] == 2)
  1054. {
  1055. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1056. }
  1057. else if($value['library'] == 3)
  1058. {
  1059. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1060. }
  1061. if($value['librarytime'] == '0')
  1062. {
  1063. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1064. }
  1065. else
  1066. {
  1067. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1068. }
  1069. $classid = $classid = $this->classid->sku();
  1070. $dbapi = explode(';',trim($value['fpdata'],';'));
  1071. foreach ($dbapi as $va)
  1072. {
  1073. $pm = $classid;
  1074. $jm = $classid;
  1075. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1076. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1077. $ts = explode('|',trim($features,'|'));
  1078. if(stripos($ts[0],',') !== false)
  1079. {
  1080. $ft = explode(',',$ts[0]);
  1081. $features = explode('-',trim($ft[1],'-'));
  1082. $features[] = $ft[0];
  1083. }
  1084. else
  1085. {
  1086. $features = explode('-',trim($ts[0],'-'));
  1087. }
  1088. foreach($features as $k=>$v)
  1089. {
  1090. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1091. {
  1092. if($typeclass[$v]['bm'] != '')
  1093. {
  1094. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1095. }
  1096. }
  1097. if($v != 0 && isset($typeclass[$v]))
  1098. {
  1099. if($typeclass[$v]['classid'] == 13)
  1100. {
  1101. $dj = $typeclass[$v]['title'];
  1102. }
  1103. if($typeclass[$v]['classid'] == 8)
  1104. {
  1105. $ys = $typeclass[$v]['title'];
  1106. }
  1107. if($typeclass[$v]['classid'] == 15)
  1108. {
  1109. $hx = $typeclass[$v]['title'];
  1110. }
  1111. if(isset($pm[$typeclass[$v]['classid']]))
  1112. {
  1113. if($typeclass[$v]['title'] == '9A')
  1114. {
  1115. $pm[$typeclass[$v]['classid']] = '9A';
  1116. }
  1117. else if($typeclass[$v]['title'] == '10A')
  1118. {
  1119. $pm[$typeclass[$v]['classid']] = '10A';
  1120. }
  1121. else
  1122. {
  1123. $clzh = $typeclass[$v]['zh'];
  1124. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1125. {
  1126. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1127. $clzh = $clzh[0];
  1128. }
  1129. $pm[$typeclass[$v]['classid']] = $clzh;
  1130. }
  1131. }
  1132. if(isset($jm[$typeclass[$v]['classid']]))
  1133. {
  1134. if($typeclass[$v]['jm'])
  1135. {
  1136. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1137. }
  1138. }
  1139. }
  1140. }
  1141. $jm = array_filter($jm);//去除空值
  1142. $jm = implode("-",$jm);
  1143. $pm = array_filter($pm);//去除空值
  1144. $zh = implode(" ",$pm);
  1145. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1146. }
  1147. $info_list[$key]['jm'] = $jm;
  1148. $info_list[$key]['zh'] = $zh;
  1149. }
  1150. //取得信息列表
  1151. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1152. //格式化数据
  1153. foreach ($info_listsmt as $key=>$value)
  1154. {
  1155. $shop = $this->shop->read($value['shop']);
  1156. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1157. if($value['waybill'] == '0')
  1158. {
  1159. $info_listsmt[$key]['waybill'] = "";
  1160. }
  1161. $express = $this->express->read($value['express']);
  1162. $info_listsmt[$key]['express'] = $express['servicename'];
  1163. $warehouse = $this->warehouse->read($value['type']);
  1164. $info_listsmt[$key]['type'] = $warehouse['title'];
  1165. if($value['print'] == 1)
  1166. {
  1167. $info_listsmt[$key]['print'] = '不可打印';
  1168. }
  1169. else if($value['print'] == 2)
  1170. {
  1171. $info_listsmt[$key]['print'] = '未打印';
  1172. }
  1173. else if($value['print'] == 3)
  1174. {
  1175. $info_listsmt[$key]['print'] = '已打印';
  1176. }
  1177. if($value['library'] == 1)
  1178. {
  1179. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1180. }
  1181. else if($value['library'] == 2)
  1182. {
  1183. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1184. }
  1185. else if($value['library'] == 3)
  1186. {
  1187. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1188. }
  1189. if($value['librarytime'] == '0')
  1190. {
  1191. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1192. }
  1193. else
  1194. {
  1195. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1196. }
  1197. $classid = $classid = $this->classid->sku();
  1198. $dbapi = explode(';',trim($value['fpdata'],';'));
  1199. foreach ($dbapi as $va)
  1200. {
  1201. $pm = $classid;
  1202. $jm = $classid;
  1203. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1204. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1205. $ts = explode('|',trim($features,'|'));
  1206. if(stripos($ts[0],',') !== false)
  1207. {
  1208. $ft = explode(',',$ts[0]);
  1209. $features = explode('-',trim($ft[1],'-'));
  1210. $features[] = $ft[0];
  1211. }
  1212. else
  1213. {
  1214. $features = explode('-',trim($ts[0],'-'));
  1215. }
  1216. foreach($features as $k=>$v)
  1217. {
  1218. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1219. {
  1220. if($typeclass[$v]['bm'] != '')
  1221. {
  1222. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1223. }
  1224. }
  1225. if($v != 0 && isset($typeclass[$v]))
  1226. {
  1227. if($typeclass[$v]['classid'] == 13)
  1228. {
  1229. $dj = $typeclass[$v]['title'];
  1230. }
  1231. if($typeclass[$v]['classid'] == 8)
  1232. {
  1233. $ys = $typeclass[$v]['title'];
  1234. }
  1235. if($typeclass[$v]['classid'] == 15)
  1236. {
  1237. $hx = $typeclass[$v]['title'];
  1238. }
  1239. if(isset($pm[$typeclass[$v]['classid']]))
  1240. {
  1241. if($typeclass[$v]['title'] == '9A')
  1242. {
  1243. $pm[$typeclass[$v]['classid']] = '9A';
  1244. }
  1245. else if($typeclass[$v]['title'] == '10A')
  1246. {
  1247. $pm[$typeclass[$v]['classid']] = '10A';
  1248. }
  1249. else
  1250. {
  1251. $clzh = $typeclass[$v]['zh'];
  1252. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1253. {
  1254. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1255. $clzh = $clzh[0];
  1256. }
  1257. $pm[$typeclass[$v]['classid']] = $clzh;
  1258. }
  1259. }
  1260. if(isset($jm[$typeclass[$v]['classid']]))
  1261. {
  1262. if($typeclass[$v]['jm'])
  1263. {
  1264. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1265. }
  1266. }
  1267. }
  1268. }
  1269. $jm = array_filter($jm);//去除空值
  1270. $jm = implode("-",$jm);
  1271. $pm = array_filter($pm);//去除空值
  1272. $zh = implode(" ",$pm);
  1273. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1274. }
  1275. $info_listsmt[$key]['jm'] = $jm;
  1276. $info_listsmt[$key]['zh'] = $zh;
  1277. }
  1278. //取得信息列表
  1279. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1280. //格式化数据
  1281. foreach ($info_listtt as $key=>$value)
  1282. {
  1283. $shop = $this->shop->read($value['shop']);
  1284. $info_listtt[$key]['shop'] = $shop['shopname'];
  1285. if($value['waybill'] == '0')
  1286. {
  1287. $info_listtt[$key]['waybill'] = "";
  1288. }
  1289. $express = $this->express->read($value['express']);
  1290. $info_listtt[$key]['express'] = $express['servicename'];
  1291. $warehouse = $this->warehouse->read($value['type']);
  1292. $info_listtt[$key]['type'] = $warehouse['title'];
  1293. if($value['print'] == 1)
  1294. {
  1295. $info_listtt[$key]['print'] = '不可打印';
  1296. }
  1297. else if($value['print'] == 2)
  1298. {
  1299. $info_listtt[$key]['print'] = '未打印';
  1300. }
  1301. else if($value['print'] == 3)
  1302. {
  1303. $info_listtt[$key]['print'] = '已打印';
  1304. }
  1305. if($value['library'] == 1)
  1306. {
  1307. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1308. }
  1309. else if($value['library'] == 2)
  1310. {
  1311. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1312. }
  1313. else if($value['library'] == 3)
  1314. {
  1315. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1316. }
  1317. if($value['librarytime'] == '0')
  1318. {
  1319. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1320. }
  1321. else
  1322. {
  1323. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1324. }
  1325. $classid = $classid = $this->classid->sku();
  1326. $dbapi = explode(';',trim($value['fpdata'],';'));
  1327. foreach ($dbapi as $va)
  1328. {
  1329. $pm = $classid;
  1330. $jm = $classid;
  1331. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1332. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1333. $ts = explode('|',trim($features,'|'));
  1334. if(stripos($ts[0],',') !== false)
  1335. {
  1336. $ft = explode(',',$ts[0]);
  1337. $features = explode('-',trim($ft[1],'-'));
  1338. $features[] = $ft[0];
  1339. }
  1340. else
  1341. {
  1342. $features = explode('-',trim($ts[0],'-'));
  1343. }
  1344. foreach($features as $k=>$v)
  1345. {
  1346. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1347. {
  1348. if($typeclass[$v]['bm'] != '')
  1349. {
  1350. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1351. }
  1352. }
  1353. if($v != 0 && isset($typeclass[$v]))
  1354. {
  1355. if($typeclass[$v]['classid'] == 13)
  1356. {
  1357. $dj = $typeclass[$v]['title'];
  1358. }
  1359. if($typeclass[$v]['classid'] == 8)
  1360. {
  1361. $ys = $typeclass[$v]['title'];
  1362. }
  1363. if($typeclass[$v]['classid'] == 15)
  1364. {
  1365. $hx = $typeclass[$v]['title'];
  1366. }
  1367. if(isset($pm[$typeclass[$v]['classid']]))
  1368. {
  1369. if($typeclass[$v]['title'] == '9A')
  1370. {
  1371. $pm[$typeclass[$v]['classid']] = '9A';
  1372. }
  1373. else if($typeclass[$v]['title'] == '10A')
  1374. {
  1375. $pm[$typeclass[$v]['classid']] = '10A';
  1376. }
  1377. else
  1378. {
  1379. $clzh = $typeclass[$v]['zh'];
  1380. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1381. {
  1382. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1383. $clzh = $clzh[0];
  1384. }
  1385. $pm[$typeclass[$v]['classid']] = $clzh;
  1386. }
  1387. }
  1388. if(isset($jm[$typeclass[$v]['classid']]))
  1389. {
  1390. if($typeclass[$v]['jm'])
  1391. {
  1392. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1393. }
  1394. }
  1395. }
  1396. }
  1397. $jm = array_filter($jm);//去除空值
  1398. $jm = implode("-",$jm);
  1399. $pm = array_filter($pm);//去除空值
  1400. $zh = implode(" ",$pm);
  1401. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1402. }
  1403. $info_listtt[$key]['jm'] = $jm;
  1404. $info_listtt[$key]['zh'] = $zh;
  1405. }
  1406. $title = '订单出库-'.date('Ymd',time());
  1407. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  1408. $tail = "\n";
  1409. $filename = $title.".xls";
  1410. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listsmt),$titlename,$filename,$tail);
  1411. }
  1412. }
  1413. public function _cpexcel()
  1414. {
  1415. if(isset($_SESSION['api']))
  1416. {
  1417. $user = $this->user->get_api($_SESSION['api']);
  1418. $usp = $user;
  1419. $fgshop = "";$sid = "";$excelshop="";
  1420. $usersp = explode('|',trim($user['shop'],'|'));
  1421. foreach ($usersp as $value)
  1422. {
  1423. $fgshop .= " shop = ".$value." or";
  1424. $sid .= " id = ".$value." or";
  1425. }
  1426. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1427. foreach ($userexcel as $value)
  1428. {
  1429. $excelshop .= " shop = ".$value." or";
  1430. }
  1431. if($excelshop != "")
  1432. {
  1433. $excelshop = "(".rtrim($excelshop,'or').")";
  1434. }
  1435. }
  1436. if(isset($_GET['excel']))
  1437. {
  1438. $timetk = $this->input->get('timetk',true);
  1439. $timetj = $this->input->get('timetj',true);
  1440. $shop = $this->input->get('shop',true);
  1441. $library = $this->input->get('library',true);
  1442. $type = $this->input->get('type',true);
  1443. $number = $this->input->get('number',true);
  1444. $orderinfo = $this->input->get('orderinfo',true);
  1445. $so = $this->input->get('so',true);
  1446. $number = $this->input->get('number',true);
  1447. $express = $this->input->get('express',true);
  1448. $timetk = strtotime($timetk);
  1449. $timetj = strtotime($timetj);
  1450. $where = "mergeid = 0";
  1451. if($timetk && $timetj && $library == 2)
  1452. {
  1453. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1454. }
  1455. else
  1456. {
  1457. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1458. }
  1459. if(isset($_SESSION['api']))
  1460. {
  1461. if($type)
  1462. {
  1463. $where .= " and type = '$type'";
  1464. }
  1465. else
  1466. {
  1467. $uw = '';
  1468. $u = $this->user->get_api($_SESSION['api']);
  1469. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1470. foreach ($u['warehouse'] as $v)
  1471. {
  1472. $uw .= " type = '$v' or";
  1473. }
  1474. $uw = rtrim($uw,'or');
  1475. $uw = " and (".ltrim($uw,' ').")";
  1476. $where .= $uw;
  1477. }
  1478. }
  1479. else
  1480. {
  1481. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1482. }
  1483. if($shop)
  1484. {
  1485. $where .= " and shop = '$shop'";
  1486. }
  1487. else
  1488. {
  1489. $where .= " and ".$excelshop;
  1490. }
  1491. if($library)
  1492. {
  1493. $where .= " and library = '$library'";
  1494. }
  1495. if($number)
  1496. {
  1497. $where .= " and number = '$number'";
  1498. }
  1499. if($orderinfo)
  1500. {
  1501. $where .= " and orderinfo = '$orderinfo'";
  1502. }
  1503. if($so)
  1504. {
  1505. $where .= " and shipremarks like '%$so%'";
  1506. }
  1507. if($express)
  1508. {
  1509. $where .= " and express = '$express'";
  1510. }
  1511. /* 匹配ID加入 */
  1512. $tc = array();
  1513. $typeclass = $this->typeclass->find_all();
  1514. foreach ($typeclass as $v)
  1515. {
  1516. $tc[$v['id']] = $v['title'];
  1517. }
  1518. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  1519. //取得信息列表
  1520. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  1521. $info_listb = $this->fullorder->find_all($where,'fpdata');
  1522. $info_list = array_merge($info_lista,$info_listb);
  1523. //格式化数据
  1524. $i = 0;$cpexcel = array();
  1525. foreach ($info_list as $key=>$value)
  1526. {
  1527. if(stripos($value['fpdata'],';') !== false)
  1528. {
  1529. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  1530. foreach ($fpdata as $ke=>$va)
  1531. {
  1532. $title = '';
  1533. $fg = explode('|',$va);
  1534. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  1535. $cp = explode('-',rtrim($fg[0],'-'));
  1536. $dj = $tc[$cp[2]];
  1537. if(!isset($cp[3]))
  1538. {
  1539. $ys = json_encode($cp);
  1540. }
  1541. else
  1542. {
  1543. $ys = $tc[$cp[3]];
  1544. }
  1545. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  1546. foreach ($cp as $v)
  1547. {
  1548. $title .= $tc[$v].' ';
  1549. }
  1550. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  1551. }
  1552. }
  1553. $i++;
  1554. }
  1555. $title = "统计信息";
  1556. $titlename = "<table border=1>
  1557. <tr>
  1558. <td>尺寸</td>
  1559. <td>等级</td>
  1560. <td>颜色</td>
  1561. <td>花型</td>
  1562. <td>数量</td>
  1563. </tr>
  1564. </table>";
  1565. $filename = $title.".xls";
  1566. $tail = "\n";
  1567. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  1568. }
  1569. }
  1570. public function _orderyz()
  1571. {
  1572. $post = $this->input->post(NULL, TRUE);
  1573. if(isset($post['yz']))
  1574. {
  1575. $yz = $this->input->post('yz',true);
  1576. $number = $this->input->post('number',true);
  1577. $y = $this->fullorder->get_number($number);
  1578. if(!$y)
  1579. {
  1580. $y = $this->fullordersmt->get_number($number);
  1581. if(!$y)
  1582. {
  1583. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1584. }
  1585. }
  1586. $whlabel = explode('|',trim($y['whlabel'],'|'));
  1587. foreach($whlabel as $k=>$v)
  1588. {
  1589. $w = explode('-',trim($v,'-'));
  1590. $wldata[$w[0]] = $w;
  1591. }
  1592. $whlabellabel = $this->whlabellabel->get_label($yz);
  1593. if(!$whlabellabel)
  1594. {
  1595. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  1596. }
  1597. else
  1598. {
  1599. if(isset($wldata[$whlabellabel['number']]))
  1600. {
  1601. if(!isset($wldata[$whlabellabel['number']][2]))
  1602. {
  1603. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1604. }
  1605. else if($wldata[$whlabellabel['number']][2] == 0)
  1606. {
  1607. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1608. }
  1609. }
  1610. else
  1611. {
  1612. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  1613. }
  1614. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  1615. }
  1616. }
  1617. if(isset($post['number']))
  1618. {
  1619. $number = $this->input->post('number',true);
  1620. $f = 'fullorder';
  1621. $y = $this->fullorder->get_number($number);
  1622. if(!$y)
  1623. {
  1624. $f = 'fullordersmt';
  1625. $y = $this->fullordersmt->get_number($number);
  1626. if(!$y)
  1627. {
  1628. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1629. }
  1630. }
  1631. if($y['librarytime'] > 0)
  1632. {
  1633. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  1634. }
  1635. $warehouse = $this->warehouse->read($y['type']);
  1636. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  1637. {
  1638. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  1639. }
  1640. $data = explode('|',trim($y['whlabel'],'|'));
  1641. $fpdata = explode(';',trim($y['fpdata'],';'));
  1642. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  1643. foreach($fpdata as $val)
  1644. {
  1645. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  1646. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  1647. $fp = explode('|',$val);
  1648. $fp[0] = str_replace(',','-',$fp[0]);
  1649. $value = explode('-',$fp[0]);
  1650. foreach($value as $v)
  1651. {
  1652. $typeclass = $this->typeclass->read($v);
  1653. $zh = explode('|',trim($typeclass['zh'],'|'));
  1654. $pm[$typeclass['classid']] = $zh[0];
  1655. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  1656. }
  1657. $scsku = implode("-",$scsku);
  1658. $zh = implode(" ",$pm);
  1659. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1660. $scsku = str_replace('- ','-',trim($scsku,'-'));
  1661. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  1662. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1663. $data[$i] = explode('-',$data[$i]);
  1664. for($j=0;$j<$data[$i][1];$j++)
  1665. {
  1666. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  1667. {
  1668. $znum++;//只计算现货
  1669. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  1670. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  1671. }
  1672. else
  1673. {
  1674. //$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');//区别位置模式,暂不使用
  1675. $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');
  1676. }
  1677. $x++;//所有数量
  1678. }
  1679. $i++;
  1680. }
  1681. //ksort($cp);//区别位置模式,暂不使用
  1682. $cp = array_values($cp);
  1683. if($this->$f->save(array('yhs'=>1),$y['id']))
  1684. {
  1685. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  1686. }
  1687. else
  1688. {
  1689. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  1690. }
  1691. }
  1692. if(isset($post['tid']))
  1693. {
  1694. $typeclass = array();
  1695. $tc = $this->typeclass->find_all();
  1696. foreach($tc as $v)
  1697. {
  1698. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  1699. }
  1700. $tid = $this->input->post('tid',true);
  1701. $id = $this->input->post('id',true);
  1702. $number = $this->input->post('n',true);
  1703. $ful = 'fullorder';
  1704. $y = $this->fullorder->get_number($number);
  1705. if(!$y)
  1706. {
  1707. $ful = 'fullordersmt';
  1708. $y = $this->fullordersmt->get_number($number);
  1709. if(!$y)
  1710. {
  1711. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1712. }
  1713. }
  1714. $wtid = $this->whlabellabel->get_label($tid);
  1715. if(!$wtid)
  1716. {
  1717. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  1718. }
  1719. $whlabel = explode('|',trim($y['whlabel'],'|'));
  1720. $fpdata = explode(';',trim($y['fpdata'],';'));
  1721. $warehouse = $this->warehouse->read($y['type']);
  1722. $zdkc = $warehouse['bdck'];
  1723. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  1724. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  1725. if((count($ptc)+count($zsc)) < 1)
  1726. {
  1727. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  1728. }
  1729. $this->db->trans_begin();
  1730. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  1731. if($zsc)
  1732. {
  1733. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  1734. $xrid = $zsc[0]['id'];
  1735. }
  1736. else if($ptc)
  1737. {
  1738. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  1739. $xrid = $ptc[0]['id'];
  1740. }
  1741. $xr = $this->$zdkc->read($xrid);
  1742. $features = explode('-',trim($xr['features'],'-'));
  1743. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  1744. foreach($features as $kk=>$v)
  1745. {
  1746. if($typeclass[$v]['classid'] == 14)
  1747. {
  1748. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  1749. unset($kk);
  1750. }
  1751. }
  1752. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  1753. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  1754. $wldata = array();
  1755. $fdata = array();
  1756. foreach($whlabel as $k=>$v)
  1757. {
  1758. $w = explode('-',trim($v,'-'));
  1759. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  1760. }
  1761. if(!isset($wldata[$id]))
  1762. {
  1763. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  1764. }
  1765. if(isset($wldata[$wtid['number']]['sj']))
  1766. {
  1767. $tw = $wldata[$wtid['number']]['sj'];
  1768. if($wtid['number'] != $id)
  1769. {
  1770. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  1771. }
  1772. else
  1773. {
  1774. if(isset($tw[2]) && $tw[2] != 0)
  1775. {
  1776. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  1777. }
  1778. }
  1779. if($tw[1] > 1)
  1780. {
  1781. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  1782. }
  1783. }
  1784. $thfpdata = $y['thfpdata'];
  1785. $w = $wldata[$id]['sj'];
  1786. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  1787. $zdkc = $warehouse['bdck'];
  1788. if($w[1] > 1)
  1789. {
  1790. if(isset($w[2]) && $w[2] != 0)
  1791. {
  1792. $hz = explode('~',trim($w[2],'~'));
  1793. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  1794. $zd = str_replace($hz[0],'',$w[2]);
  1795. $zd = trim($zd,'~');
  1796. $w[2] = $zd;
  1797. }
  1798. foreach($w as $kk=>$v)
  1799. {
  1800. if($kk == 1)
  1801. {
  1802. $v = $v-1;
  1803. }
  1804. $ww .= $v .'-';
  1805. }
  1806. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  1807. foreach($f as $kk=>$v)
  1808. {
  1809. if($kk == 2)
  1810. {
  1811. $v = $v-1;
  1812. $thff .= '1|';
  1813. }
  1814. else
  1815. {
  1816. $thff .= $v .'|';
  1817. }
  1818. $ff .= $v .'|';
  1819. }
  1820. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  1821. $thfpdata .= trim($thff,'|');
  1822. }
  1823. else
  1824. {
  1825. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  1826. unset($whlabel[$wldata[$id]['wz']]);
  1827. unset($fpdata[$wldata[$id]['wz']]);
  1828. }
  1829. $thfpdata .= '~'.$dataf;
  1830. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  1831. $fpdata = implode(";",$fpdata).';'.$dataf;
  1832. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  1833. if ($this->db->trans_status() === TRUE)
  1834. {
  1835. $this->db->trans_commit();
  1836. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  1837. }
  1838. else
  1839. {
  1840. $this->db->trans_rollback();
  1841. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  1842. }
  1843. }
  1844. if(isset($post['yhs']))
  1845. {
  1846. $f = 'fullorder';
  1847. $number = $this->input->post('yhs',true);
  1848. $y = $this->fullorder->get_number($number);
  1849. if(!$y)
  1850. {
  1851. $f = 'fullordersmt';
  1852. $y = $this->fullordersmt->get_number($number);
  1853. }
  1854. if($this->$f->save(array('yhs'=>0),$y['id']))
  1855. {
  1856. echo json_encode(array('success'=>true));exit;
  1857. }
  1858. else
  1859. {
  1860. echo json_encode(array('success'=>false));exit;
  1861. }
  1862. }
  1863. $this->_Template('systemfout_orderyz',$this->data);
  1864. }
  1865. public function _hwyz()
  1866. {
  1867. $post = $this->input->post(NULL, TRUE);
  1868. if(isset($post['yz']))
  1869. {
  1870. $yz = $this->input->post('yz',true);
  1871. $number = $this->input->post('number',true);
  1872. $y = $this->fullorder->get_number($number);
  1873. if(!$y)
  1874. {
  1875. $y = $this->fullordersmt->get_number($number);
  1876. if(!$y)
  1877. {
  1878. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1879. }
  1880. }
  1881. $whlabel = explode('|',trim($y['whlabel'],'|'));
  1882. foreach($whlabel as $k=>$v)
  1883. {
  1884. $w = explode('-',trim($v,'-'));
  1885. $wldata[$w[0]] = $w;
  1886. }
  1887. $whlabellabel = $this->whlabellabel->get_label($yz);
  1888. if(!$whlabellabel)
  1889. {
  1890. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  1891. }
  1892. else
  1893. {
  1894. if(isset($wldata[$whlabellabel['number']]))
  1895. {
  1896. if(!isset($wldata[$whlabellabel['number']][2]))
  1897. {
  1898. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1899. }
  1900. else if($wldata[$whlabellabel['number']][2] == 0)
  1901. {
  1902. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1903. }
  1904. }
  1905. else
  1906. {
  1907. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  1908. }
  1909. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  1910. }
  1911. }
  1912. if(isset($post['number']))
  1913. {
  1914. $number = $this->input->post('number',true);
  1915. $f = 'fullorder';
  1916. $y = $this->fullorder->get_number($number);
  1917. if(!$y)
  1918. {
  1919. $f = 'fullordersmt';
  1920. $y = $this->fullordersmt->get_number($number);
  1921. if(!$y)
  1922. {
  1923. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1924. }
  1925. }
  1926. if($y['librarytime'] > 0)
  1927. {
  1928. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  1929. }
  1930. $warehouse = $this->warehouse->read($y['type']);
  1931. $data = explode('|',trim($y['whlabel'],'|'));
  1932. $fpdata = explode(';',trim($y['fpdata'],';'));
  1933. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  1934. foreach($fpdata as $val)
  1935. {
  1936. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  1937. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  1938. $fp = explode('|',$val);
  1939. $fp[0] = str_replace(',','-',$fp[0]);
  1940. $value = explode('-',$fp[0]);
  1941. foreach($value as $v)
  1942. {
  1943. $typeclass = $this->typeclass->read($v);
  1944. $zh = explode('|',trim($typeclass['zh'],'|'));
  1945. $pm[$typeclass['classid']] = $zh[0];
  1946. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  1947. }
  1948. $scsku = implode("-",$scsku);
  1949. $zh = implode(" ",$pm);
  1950. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1951. $scsku = str_replace('- ','-',trim($scsku,'-'));
  1952. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  1953. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1954. $data[$i] = explode('-',$data[$i]);
  1955. for($j=0;$j<$data[$i][1];$j++)
  1956. {
  1957. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  1958. {
  1959. $znum++;//只计算现货
  1960. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  1961. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  1962. }
  1963. else
  1964. {
  1965. //$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');//区别位置模式,暂不使用
  1966. $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');
  1967. }
  1968. $x++;//所有数量
  1969. }
  1970. $i++;
  1971. }
  1972. //ksort($cp);//区别位置模式,暂不使用
  1973. $cp = array_values($cp);
  1974. if($this->$f->save(array('yhs'=>1),$y['id']))
  1975. {
  1976. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  1977. {
  1978. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  1979. }
  1980. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  1981. }
  1982. else
  1983. {
  1984. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  1985. }
  1986. }
  1987. if(isset($post['tid']))
  1988. {
  1989. $typeclass = array();
  1990. $tc = $this->typeclass->find_all();
  1991. foreach($tc as $v)
  1992. {
  1993. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  1994. }
  1995. $tid = $this->input->post('tid',true);
  1996. $id = $this->input->post('id',true);
  1997. $number = $this->input->post('n',true);
  1998. $ful = 'fullorder';
  1999. $y = $this->fullorder->get_number($number);
  2000. if(!$y)
  2001. {
  2002. $ful = 'fullordersmt';
  2003. $y = $this->fullordersmt->get_number($number);
  2004. if(!$y)
  2005. {
  2006. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2007. }
  2008. }
  2009. $wtid = $this->whlabellabel->get_label($tid);
  2010. if(!$wtid)
  2011. {
  2012. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2013. }
  2014. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2015. $fpdata = explode(';',trim($y['fpdata'],';'));
  2016. $warehouse = $this->warehouse->read($y['type']);
  2017. $zdkc = $warehouse['bdck'];
  2018. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2019. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2020. if((count($ptc)+count($zsc)) < 1)
  2021. {
  2022. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2023. }
  2024. $this->db->trans_begin();
  2025. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2026. if($zsc)
  2027. {
  2028. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2029. $xrid = $zsc[0]['id'];
  2030. }
  2031. else if($ptc)
  2032. {
  2033. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2034. $xrid = $ptc[0]['id'];
  2035. }
  2036. $xr = $this->$zdkc->read($xrid);
  2037. $features = explode('-',trim($xr['features'],'-'));
  2038. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2039. foreach($features as $kk=>$v)
  2040. {
  2041. if($typeclass[$v]['classid'] == 14)
  2042. {
  2043. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2044. unset($kk);
  2045. }
  2046. }
  2047. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2048. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2049. $wldata = array();
  2050. $fdata = array();
  2051. foreach($whlabel as $k=>$v)
  2052. {
  2053. $w = explode('-',trim($v,'-'));
  2054. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2055. }
  2056. if(!isset($wldata[$id]))
  2057. {
  2058. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2059. }
  2060. if(isset($wldata[$wtid['number']]['sj']))
  2061. {
  2062. $tw = $wldata[$wtid['number']]['sj'];
  2063. if($wtid['number'] != $id)
  2064. {
  2065. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2066. }
  2067. else
  2068. {
  2069. if(isset($tw[2]) && $tw[2] != 0)
  2070. {
  2071. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2072. }
  2073. }
  2074. if($tw[1] > 1)
  2075. {
  2076. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2077. }
  2078. }
  2079. $thfpdata = $y['thfpdata'];
  2080. $w = $wldata[$id]['sj'];
  2081. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2082. $zdkc = $warehouse['bdck'];
  2083. if($w[1] > 1)
  2084. {
  2085. if(isset($w[2]) && $w[2] != 0)
  2086. {
  2087. $hz = explode('~',trim($w[2],'~'));
  2088. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2089. $zd = str_replace($hz[0],'',$w[2]);
  2090. $zd = trim($zd,'~');
  2091. $w[2] = $zd;
  2092. }
  2093. foreach($w as $kk=>$v)
  2094. {
  2095. if($kk == 1)
  2096. {
  2097. $v = $v-1;
  2098. }
  2099. $ww .= $v .'-';
  2100. }
  2101. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2102. foreach($f as $kk=>$v)
  2103. {
  2104. if($kk == 2)
  2105. {
  2106. $v = $v-1;
  2107. $thff .= '1|';
  2108. }
  2109. else
  2110. {
  2111. $thff .= $v .'|';
  2112. }
  2113. $ff .= $v .'|';
  2114. }
  2115. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2116. $thfpdata .= trim($thff,'|');
  2117. }
  2118. else
  2119. {
  2120. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2121. unset($whlabel[$wldata[$id]['wz']]);
  2122. unset($fpdata[$wldata[$id]['wz']]);
  2123. }
  2124. $thfpdata .= '~'.$dataf;
  2125. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2126. $fpdata = implode(";",$fpdata).';'.$dataf;
  2127. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2128. if ($this->db->trans_status() === TRUE)
  2129. {
  2130. $this->db->trans_commit();
  2131. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2132. }
  2133. else
  2134. {
  2135. $this->db->trans_rollback();
  2136. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2137. }
  2138. }
  2139. if(isset($post['yhs']))
  2140. {
  2141. $f = 'fullorder';
  2142. $number = $this->input->post('yhs',true);
  2143. $y = $this->fullorder->get_number($number);
  2144. if(!$y)
  2145. {
  2146. $f = 'fullordersmt';
  2147. $y = $this->fullordersmt->get_number($number);
  2148. }
  2149. if($this->$f->save(array('yhs'=>0),$y['id']))
  2150. {
  2151. echo json_encode(array('success'=>true));exit;
  2152. }
  2153. else
  2154. {
  2155. echo json_encode(array('success'=>false));exit;
  2156. }
  2157. }
  2158. $this->_Template('systemfout_hwyz',$this->data);
  2159. }
  2160. }