Boss.php 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Boss extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_api', 'api');
  9. $this->load->_model('Model_apismt', 'apismt');
  10. $this->load->_model('Model_shop', 'shop');
  11. $this->load->_model('Model_fullorder', 'fullorder');
  12. $this->load->_model('Model_fullordertt', 'fullordertt');
  13. $this->load->_model('Model_fedex_cby', 'fedex_cby');
  14. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  15. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  16. $this->load->_model('Model_fullorderxw', 'fullorderxw');
  17. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  18. $this->load->_model('Model_customersmt', 'customersmt');
  19. $this->load->_model('Model_logic_order', 'logic_order');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_hl', 'hl');
  22. $this->load->_model('Model_is', 'is');
  23. $this->load->_model('Model_kdniao', 'kdniao');
  24. $this->load->_model('Model_typeclass', 'typeclass');
  25. $this->load->_model('Model_warehouse', 'warehouse');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_dhl', 'dhl');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_dhltest', 'dhltest');
  30. $this->load->_model('Model_customer', 'customer');
  31. $this->load->_model('Model_express', 'express');
  32. $this->load->_model('Model_notice', 'notice');
  33. $this->load->_model('Model_whlabel', 'whlabel');
  34. $this->load->_model('Model_productdescribe', 'productdescribe');
  35. $this->load->_model('Model_ljg', 'ljg');
  36. $this->load->_model('Model_commodityread', 'commodityread');
  37. $this->load->_model('Model_service', 'service');
  38. $this->load->_model('Model_fedex', 'fedex');
  39. $this->load->_model('Model_commodity', 'commodity');
  40. $this->load->_model('Model_fullordersmtorder', 'fullordersmtorder');
  41. $this->load->_model('Model_ali', 'ali');
  42. $this->load->_model('Model_fullordersmthb', 'fullordersmthb');
  43. $this->load->_model('Model_fullordersmtbf', 'fullordersmtbf');
  44. $this->load->_model('Model_taxzhengzhou', 'taxzhengzhou');
  45. $this->load->_model('Model_taxshanghai', 'taxshanghai');
  46. $this->load->_model('Model_excel', 'excel');
  47. $this->load->_model('Model_ups', 'ups');
  48. $this->load->_model('Model_dpd', 'dpd');
  49. $this->load->_model('Model_cne', 'cne');
  50. $this->load->_model('Model_outbound', 'outbound');
  51. $this->load->_model('Model_specialstock', 'specialstock');
  52. $this->load->_model('Model_setting', 'setting');
  53. $this->load->_model('Model_pay', 'pay');
  54. $this->load->_model('Model_shopsku', 'shopsku');
  55. $this->load->_model('Model_classid', 'classid');
  56. $this->load->_model('Model_weight', 'weight');
  57. $this->load->_model('Model_country', 'country');
  58. $this->load->_model("Model_zzquque_u9", "zzquque_u9");
  59. $this->load->_model("Model_customsdeclaration", "customsdeclaration");
  60. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  61. $this->load->_model("Model_check","check");
  62. $this->load->_model("Model_logic_express","logic_express");
  63. $this->load->_model("Model_ck","ck");
  64. }
  65. //定义方法的调用规则 获取URI第二段值
  66. public function _remap($arg, $arg_array)
  67. {
  68. if ($arg == 'out') {
  69. $this->_out($arg_array);
  70. } else if ($arg == 'sku') {
  71. $this->_sku();
  72. } else if ($arg == 'spexcel') {
  73. $this->_spexcel();
  74. } else if ($arg == 'qczd') {
  75. $this->_qczd();
  76. } else if ($arg == 'setting') {
  77. $this->_setting();
  78. } else if ($arg == 'sctime') {
  79. $this->_sctime();
  80. } else if ($arg == 'dpex') {
  81. $this->_dpex();
  82. } else if ($arg == 'dpay') {
  83. $this->_dpay();
  84. } else if ($arg == 'excellkh') {
  85. $this->_excellkh();
  86. } else if ($arg == 'excelshop') {
  87. $this->_excelshop();
  88. } else if ($arg == 'ggdd') {
  89. $this->_ggdd();
  90. } else if ($arg == 'qt') {
  91. $this->_qt();
  92. }else if($arg == 'dycs'){
  93. $this->_dycs();
  94. }else if($arg =='yxdpdck'){
  95. $this->_yxDPDchuku();
  96. }else if($arg == 'spexceljs'){
  97. $this->_spexceljs();
  98. } else {
  99. $this->_index();
  100. }
  101. }
  102. public function _index()
  103. {
  104. if(empty($_SESSION['api'])){
  105. exit('No direct script access allowed');
  106. }
  107. $user = $this->user->get_api($_SESSION['api']);
  108. $this->data['user'] = $user; //登录的用户信息
  109. $vip = 0;
  110. if($user['vip'] == 1){
  111. $vip = 1;
  112. }
  113. $this->data['is_vip'] = $vip;
  114. $setting = $this->setting->get_settings();
  115. $this->data['excelpass'] = $setting['excelpass'];
  116. $this->data['excelusernum'] = $setting['excelusernum'];
  117. $this->data['exceljmnum'] = $setting['exceljmnum'];
  118. $this->data['sctime'] = $setting['sctime'];
  119. $this->_Template('boss', $this->data);
  120. }
  121. public function _qt()
  122. {
  123. $setting = $this->setting->get_settings();
  124. $this->data['excelpass'] = $setting['excelpass'];
  125. $this->data['excelusernum'] = $setting['excelusernum'];
  126. $this->data['exceljmnum'] = $setting['exceljmnum'];
  127. $this->data['sctime'] = $setting['sctime'];
  128. $wh = $this->warehouse->find_all('1=1', 'id,title');
  129. $this->data['wh'] = $wh;
  130. $this->_Template('boss_qt', $this->data);
  131. }
  132. public function _out($arg_array)
  133. {
  134. $post = $this->input->post(NULL, TRUE);
  135. if (isset($post['order'])) {
  136. $time = $this->input->post('time', true);
  137. $time = strtotime($time);
  138. $order = $this->input->post('order', true);
  139. $weight = $this->input->post('weight', true);
  140. if (!isset($weight)) //测试没问题后可以删
  141. {
  142. $weight = '';
  143. }
  144. if (substr($order, 0, 3) == '788' && substr($order, -4, 4) == '0430') //Fedex联邦
  145. {
  146. $order = substr($order, 0, 12);
  147. }
  148. if (strlen($order) == '34') //联邦杭州超长运单截取
  149. {
  150. $order = substr($order, 22, 12);
  151. }
  152. if (!$order) {
  153. echo json_encode(array('msg' => '出库信息不能为空!', 'success' => false));
  154. exit;
  155. }
  156. // $fullorder_name = 'fullorder';$outtype = 1;
  157. // $y = $this->fullorder->get_waybill($order);
  158. // if(!$y)
  159. // {
  160. // $y = $this->fullorder->get_number($order);
  161. // $outtype = 2;
  162. // if(!$y)
  163. // {
  164. // $fullorder_name = 'fullordersmt';$outtype = 1;
  165. // $y = $this->fullordersmt->get_waybill($order);
  166. // if(!$y)
  167. // {
  168. // $y = $this->fullordersmt->get_number($order);
  169. // $outtype = 2;
  170. // if(!$y)
  171. // {
  172. // $fullorder_name = 'fullordertt';$outtype = 1;
  173. // $y = $this->fullordertt->get_waybill($order);
  174. // if(!$y)
  175. // {
  176. // $y = $this->fullordertt->get_number($order);
  177. // $outtype = 2;
  178. // if(!$y)
  179. // {
  180. // $fullorder_name = 'fullorderamz';$outtype = 1;
  181. // $y = $this->fullorderamz->get_waybill($order);
  182. // if(!$y)
  183. // {
  184. // $y = $this->fullorderamz->get_number($order);
  185. // $outtype = 2;
  186. // if(!$y)
  187. // {
  188. // $fullorder_name = 'fullorderxw';$outtype = 1;
  189. // $y = $this->fullorderxw->get_waybill($order);
  190. // if(!$y)
  191. // {
  192. // $y = $this->fullorderxw->get_number($order);
  193. // $outtype = 2;
  194. // if(!$y)
  195. // {
  196. // echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  197. // }
  198. // }
  199. // }
  200. // }
  201. // }
  202. // }
  203. // }
  204. // }
  205. // }
  206. // }
  207. $outtype = 1;
  208. $y = $this->logic_order->getInfo("waybill = '" . $order . "'");
  209. if (empty($y)) {
  210. $outtype = 2;
  211. $y = $this->logic_order->getInfo("number = '" . $order . "'");
  212. }
  213. // 78 dpd英国 和 79dpd欧盟
  214. if(in_array($y['express'],[78,79,84])){
  215. $r = $this->check->checkOverdue($y['name'],$y['number'],$y['address']);
  216. if(!$r){
  217. echo json_encode(array('msg'=>'同一个客户3天内发货超过2包,不可出库!请联系店员做申报信息修改!','success'=>false));exit;
  218. }
  219. }
  220. $fullorder_name = $y['lv_platform'];
  221. if ($y['mergeid'] == '1') {
  222. $y = $this->$fullorder_name->read($y['merge']);
  223. }
  224. $express = $this->express->read($y['express']);
  225. if ($y['state'] == 216 && $fullorder_name == 'fullordersmt') {
  226. $y['librarynot'] = '客户已取消!';
  227. }
  228. 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')) && $y['type'] != 3) //独立站216先关了
  229. {
  230. echo json_encode(array('msg' => '禁止出库!' . $y['librarynot'], 'success' => false));
  231. exit;
  232. }
  233. if ($y['library'] > 1) {
  234. echo json_encode(array('msg' => '此数据 ' . date('Y-m-d H:i:s', $y['librarytime']) . ' 已操作', 'success' => false));
  235. exit;
  236. }
  237. if ($express['out'] != 3) {
  238. if ($express['out'] != $outtype) {
  239. $smlx = ($express['out'] == '1') ? '运单' : '发货单';
  240. echo json_encode(array('msg' => '扫描类型错误!此单需要扫描' . $smlx, 'success' => false));
  241. exit;
  242. }
  243. }
  244. if ($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1') {
  245. $y['waybill'] = trim($y['waybill'], ' ');
  246. // 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'] != 71 && $y['express'] != 73 && $y['express'] != 75 && $y['express'] != 78 && $y['express'] != 79) {
  247. // echo json_encode(array('msg' => '出库物流和系统不匹配,请联系梦体解决' . $y['express'] . '-1', 'success' => false));
  248. // exit;
  249. // } else if (strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42 && $y['express'] != 78 && $y['express'] != 79) {
  250. // echo json_encode(array('msg' => '出库物流和系统不匹配,请联系梦体解决' . $y['express'] . '-2', 'success' => false));
  251. // exit;
  252. // } else if (strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67 && $y['express'] != 72 && $y['express']!= 82) {
  253. // echo json_encode(array('msg' => '出库物流和系统不匹配,请联系梦体解决' . $y['express'] . '-3', 'success' => false));
  254. // exit;
  255. // }
  256. // else if(strlen($y['waybill']) == 16 && $y['express'] != 76 && $y['express'] != 77 && $y['express'] != 80)
  257. // {
  258. // echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-4','success'=>false));exit;
  259. // }
  260. $r = $this->logic_express->ydCheckById($y['waybill'],$y['express']);
  261. if(!$r){
  262. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'],'success'=>false));exit;
  263. }
  264. }
  265. // if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
  266. // {
  267. // $numweight = str_replace('kg','',$weight);
  268. // if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  269. // {
  270. // echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  271. // }
  272. // $yzweight = explode('.',$numweight);
  273. // if($yzweight[0] == '')
  274. // {
  275. // echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  276. // }
  277. // if($numweight > '0.98' && $y['express'] == '3')
  278. // {
  279. // echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
  280. // }
  281. // if($numweight > '2' && $y['express'] == '37')
  282. // {
  283. // echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
  284. // }
  285. // if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
  286. // {
  287. // echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
  288. // }
  289. // }
  290. $numweight = str_replace('kg', '', $weight);
  291. //根据要求 USPS-USA FEDEX-US2 USPS-US2 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
  292. $express_info = $this->express->read($y['express']);
  293. if (empty($express_info)) {
  294. echo json_encode(array('msg' => '该快递信息异常,请联系技术!', 'success' => false));
  295. exit;
  296. }
  297. $weight_limit = $express_info['weight_limit'] * 1;
  298. if ($weight_limit > 0) {
  299. if ($weight == '' || $numweight < '0.1' || !is_numeric($numweight)) {
  300. echo json_encode(array('msg' => '此单需要称重!', 'success' => false));
  301. exit;
  302. }
  303. $yzweight = explode('.', $numweight);
  304. if ($yzweight[0] == '') {
  305. echo json_encode(array('msg' => '重量错误,请重新称重!', 'success' => false));
  306. exit;
  307. }
  308. if ($numweight < (($y['jweight'] * 1) / 1000)) {
  309. echo json_encode(array('msg' => '重量小于净重,请重新称重!', 'success' => false));
  310. exit;
  311. }
  312. //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
  313. if (in_array($y['express'], [3, 24, 42])) {
  314. //规定实际重量不允许超过 净重为1kg
  315. if ($numweight - (($y['jweight'] * 1) / 1000) > 1) {
  316. echo json_encode(array('msg' => '称重重量和净重相差过大,请找成会或梦体处理!', 'success' => false));
  317. exit;
  318. }
  319. }
  320. if ($weight_limit < $numweight) {
  321. echo json_encode(array('msg' => $express['servicename'] . '大于' . $weight_limit . '公斤需要拆包!', 'success' => false));
  322. exit;
  323. }
  324. }
  325. if (((time() - $y['printtime']) > (15 * 24 * 3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6) //杭州店铺除外
  326. {
  327. echo json_encode(array('yd' => 1, 'id' => $y['id'], 'express' => $y['express'], 'name' => $fullorder_name, 'success' => true));
  328. exit;
  329. }
  330. if ((time() - $y['printtime']) > (4 * 24 * 3600) && $y['express'] == '3' && $y['type'] != 6) //杭州店铺除外
  331. {
  332. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  333. echo json_encode(array('msg' => '此运单过期无法出库,请联系成会处理!', 'success' => false));
  334. exit;
  335. }
  336. if ((time() - $y['printtime']) > (7 * 24 * 3600) && $y['express'] == '37' && $y['type'] != 6) //杭州店铺除外
  337. {
  338. echo json_encode(array('yd' => 1, 'id' => $y['id'], 'express' => $y['express'], 'name' => $fullorder_name, 'success' => true));
  339. exit;
  340. }
  341. $this->db->trans_begin();
  342. $warehouse = $this->warehouse->read($y['type']);
  343. if ($warehouse['zd'] == '1') {
  344. if ($warehouse['bdck'] == '') {
  345. echo json_encode(array('msg' => '仓库设置错误!', 'success' => false));
  346. exit;
  347. }
  348. $bdck = $warehouse['bdck'];
  349. $wh = $this->_fout_db($y, $warehouse, $bdck);
  350. if ($wh['fh'] == 2) {
  351. $kcyz = $this->ck->get_kc($y['state'], $warehouse, $y['shop'], $y['number'], $y['whlabel'], $y['fpdata']);
  352. if($kcyz['t'] == '1'){
  353. $tmp_msg = json_decode($kcyz['m'],true);
  354. echo json_encode(array('msg' => $tmp_msg['msg'], 'success' => false));
  355. exit;
  356. }
  357. if ($kcyz['fpdata'] != '' && $kcyz['t'] == '0') {
  358. $x['whlabel'] = $kcyz['whlabel'];
  359. $x['fpdata'] = $kcyz['fpdata'];
  360. $y['whlabel'] = $x['whlabel'];
  361. $this->$fullorder_name->save($x, $y['id']);
  362. }
  363. $wh = $this->_fout_db($y, $warehouse, $bdck);
  364. if ($wh['fh'] == 2) {
  365. echo json_encode(array('msg' => '库存占用量与实际出库量不符!', 'success' => false));
  366. exit;
  367. }
  368. }
  369. foreach ($wh['sj'] as $v) {
  370. $this->$bdck->save(array('state' => 1, 'cktype' => 1, 'orderinfo' => $y['orderinfo'], 'waybill' => $y['waybill'], 'outk' => $time, 'time' => $time), $v['id']);
  371. }
  372. }
  373. if ($fullorder_name == 'fullordersmt') {
  374. $stt = ($y['waybill'] != '') ? 209 : $y['state'];
  375. $this->$fullorder_name->save(array('library' => 2, 'state' => $stt, 'librarytime' => $time, 'weight' => $weight), $y['id']);
  376. } else {
  377. if ($y['type'] == 3) {
  378. $this->$fullorder_name->save(array('print' => 3, 'printtime' => $time, 'printnumber' => 1, 'state' => 216, 'libraryconfirm' => 2, 'library' => 2, 'librarytime' => $time, 'weight' => $weight), $y['id']);
  379. } else {
  380. $this->$fullorder_name->save(array('library' => 2, 'librarytime' => $time, 'weight' => $weight), $y['id']);
  381. }
  382. }
  383. $queue_u9_list = [];
  384. $queue_u9_list[] = [
  385. 'platform' => $fullorder_name,
  386. 'warehouse' => $y['type'],
  387. 'type' => ($y['type'] == 5) ? 11 : 10, //5代表美仓
  388. 'order_no' => $y['number'],
  389. 'status' => 0,
  390. 'create_time' => time(),
  391. 'update_time' => time(),
  392. ];
  393. //将要执行的队列数据添加进去
  394. foreach ($queue_u9_list as $item) {
  395. if ($item['platform'] != 'fullorderxw') {
  396. if ($item['warehouse'] != 5) {
  397. $this->zzquque_u9->insert($item);
  398. }
  399. }
  400. }
  401. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  402. $update_arr = [];
  403. $update_arr['waybill'] = $y['waybill'];
  404. $update_arr['express'] = $y['express'];
  405. $update_arr['printtype'] = $y['printtype'];
  406. $update_arr['ioss'] = $y['ioss'];
  407. $update_arr['review'] = 6;
  408. $update_arr['bx'] = $y['bx'];
  409. $update_arr['qm'] = $y['qm'];
  410. $update_arr['js'] = $y['js'];
  411. //$post['state'] = 216;
  412. $update_arr['print'] = $y['print'];
  413. $update_arr['printtime'] = $y['printtime'];
  414. $update_arr['library'] = 2;
  415. $update_arr['librarytime'] = $time;
  416. $update_arr['libraryconfirm'] = 2;
  417. $update_arr['librarynot'] = '';
  418. foreach ($hb as $v)
  419. {
  420. $update_arr['state'] = $v['state'];
  421. $vshop = $this->shop->read($v['shop']);
  422. $vwarehouse = $this->warehouse->read($v['type']);
  423. $this->$fullorder_name->save($update_arr,$v['id']);
  424. //2025年1月25日发现翔文合并订单发现此问题
  425. // if($warehouse['zd'] == '1'){
  426. // $wh = $this->_fout_db($v,$warehouse,$bdck);
  427. // foreach ($wh['sj'] as $vv)
  428. // {
  429. // $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  430. // }
  431. // }
  432. }
  433. if ($this->db->trans_status() === TRUE) {
  434. $this->db->trans_commit();
  435. echo json_encode(array('msg' => '操作成功!', 'success' => true));
  436. exit;
  437. } else {
  438. $this->db->trans_rollback();
  439. echo json_encode(array('msg' => '出库失败,请重试', 'success' => false));
  440. }
  441. }
  442. }
  443. public function _fout_db($y, $warehouse, $bdck) //对比占单是否正确
  444. {
  445. $wh = $this->$bdck->find_all("zd = '" . $y['number'] . "' and warehouse = '" . $y['type'] . "' and (state = '0' or state = '9')");
  446. $cpsl = 0;
  447. $pp = explode('|', trim($y['whlabel'], '|'));
  448. foreach ($pp as $va) {
  449. $num = explode('-', $va);
  450. if (isset($num[2])) {
  451. if (stripos($num[2], $warehouse['hz']) !== false) {
  452. $cpsl += $num[1];
  453. }
  454. }
  455. }
  456. if (count($wh) == $cpsl) {
  457. return array('fh' => 1, 'sj' => $wh);
  458. } else {
  459. return array('fh' => 2);
  460. }
  461. }
  462. public function _sku() //测试SKU
  463. {
  464. $post = $this->input->post(NULL, TRUE);
  465. if (isset($post['sku'])) {
  466. $sku = $this->input->post('sku', true);
  467. if ($sku == '') {
  468. echo json_encode(array('msg' => 'SKU不能为空!', 'success' => false));
  469. exit;
  470. }
  471. $gethl = $this->hl->get_hl(); //获取即时汇率
  472. $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
  473. $dtc = array();
  474. foreach ($dictionaries as $v) {
  475. if (stripos($v['spare'], '|') !== false) //如果有多个值
  476. {
  477. $v['spare'] = explode('|', $v['spare']);
  478. foreach ($v['spare'] as $k => $vs) {
  479. if (stripos($v['zh'], '|') !== false) {
  480. $vzh = explode('|', $v['zh']);
  481. $dtc[strtolower($vs)] = array('classid' => $v['classid'], 'zh' => $vzh[$k], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $vs);
  482. } else {
  483. $dtc[strtolower($vs)] = array('classid' => $v['classid'], 'zh' => $v['zh'], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $vs);
  484. }
  485. }
  486. } else {
  487. $dtc[strtolower($v['spare'])] = array('classid' => $v['classid'], 'zh' => $v['zh'], 'id' => $v['id'], 'jm' => $v['jm'], 'spare' => $v['spare']);
  488. }
  489. }
  490. $dictionaries2 = $this->typeclass->find_all();
  491. foreach ($dictionaries2 as $v) {
  492. $dtctitle[$v['id']] = $v['title'];
  493. }
  494. /* 匹配结束 */
  495. /* 价格加入 */
  496. $money = array();
  497. $productdescribe = $this->productdescribe->find_all('1=1');
  498. foreach ($productdescribe as $v) {
  499. $money[$v['number']] = array();
  500. }
  501. /* 价格加入 */
  502. /* 匹配ID加入 */
  503. $int = array();
  504. $intdata = $this->typeclass->find_all('classid=14', 'id,spare');
  505. foreach ($intdata as $v) {
  506. $v['spare'] = explode('|', $v['spare']);
  507. $int[$v['id']] = $v['spare'][0];
  508. }
  509. /* 匹配ID加入 */
  510. $zjsku = array();
  511. $shopsku = $this->shopsku->find_all();
  512. foreach ($shopsku as $val) {
  513. $ss = explode(',', trim($val['shop'], ','));
  514. foreach ($ss as $v) {
  515. if (isset($zjsku[$v])) {
  516. $zjsku[$v] .= ',' . trim($val['sku'], ',');
  517. } else {
  518. $zjsku[$v] = trim($val['sku'], ',');
  519. }
  520. }
  521. }
  522. /* 匹配ID结束 */
  523. $q = '';
  524. $quantity = explode(',', trim($sku, ','));
  525. foreach ($quantity as $v) {
  526. $q .= '1;';
  527. }
  528. $is = $this->is->find_all('1=1', '*', 'number asc'); //获取仓库平匹配表
  529. $shop = $this->shop->read(19);
  530. if (isset($zjsku[$shop['id']])) //判断是否找到店铺SKU
  531. {
  532. $sku = rtrim($sku, ',') . ',' . $zjsku[$shop['id']];
  533. }
  534. $r = $this->api->matching(trim($q, ';'), $sku, $dtc, $money, $int, $dtctitle, $shop);
  535. $p = '';
  536. $product = explode(';', trim($r['product'], ';'));
  537. if ($r['title'] != '' && $product) {
  538. foreach ($product as $v) {
  539. $vc = explode('|', $v);
  540. if(isset($vc[1])){
  541. $p .= $vc[1] . '<br>';
  542. }
  543. }
  544. $tmp_str = $r['product'];
  545. $tmp_arr = explode(";",$tmp_str);
  546. $list = [];
  547. foreach($tmp_arr as $k=>$v){
  548. $tmp_str1 = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
  549. $tmp_arr1 = explode('|',trim($tmp_str1,'|'));
  550. if(stripos($tmp_arr1[0],',') !== false){
  551. $ft = explode(',',$tmp_arr1[0]);
  552. $features = explode('-',trim($ft[1],'-'));
  553. $features[] = $ft[0];
  554. }else{
  555. $features = explode('-',trim($tmp_arr1[0],'-'));
  556. }
  557. $sku = implode("-",$features);
  558. if(!empty($sku)){
  559. $list[] = [
  560. 'sku2'=>$sku
  561. ];
  562. }
  563. }
  564. $u9_data = $this->logic_u9tools->getU9bm($list,'sku2');
  565. if(isset($u9_data[0]['jm'])){
  566. $jm = $u9_data[0]['jm'];
  567. }else{
  568. $jm = json_encode($u9_data,JSON_UNESCAPED_UNICODE);
  569. }
  570. $r['title'] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $r['title']);
  571. echo json_encode(array('msg' => '仓库品名:' . $r['title'] . '<br>商品名称:' . $p ."<br>用友料号:".$jm, 'success' => true, 'r' => $r));
  572. exit;
  573. } else {
  574. echo json_encode(array('msg' => 'SKU错误', 'success' => false));
  575. exit;
  576. }
  577. }
  578. }
  579. public function matching($quantity, $issku, $dtc, $money, $int, $dtctitle)
  580. {
  581. $sl = explode(';', $quantity);
  582. $x = 0;
  583. $product = ''; //product 每单多产品链接组合
  584. $purchase = 0;
  585. $cost = 0; //每单所有产品总成本价格;
  586. $whlabel = '|'; //库存产品码
  587. $cscs = array();
  588. $cscs = $issku;
  589. $nr = '';
  590. $cs = array();
  591. $t = array('/\-\-/', '/\+/', '/\#Color/', '/\#Long/', '/-[1-4]-/', '/(\w+)~(\w+)-/');
  592. $h = array('-', '-', '', '', '-', '');
  593. $issku = str_replace(array('(', ')'), array('(', ')'), $issku);
  594. $issku = str_replace(array(' <', '> '), array('<', '>'), $issku);
  595. $issku = strtolower($issku);
  596. $varsku = preg_replace($t, $h, $issku); ////转大写、匹配更改和删除
  597. $varsku = strtolower($varsku); //转小写
  598. $sku = explode(',', $varsku); //多产品分割为多数组
  599. $pd = explode(',', $issku);
  600. $slpx = array();
  601. $tqjcskua = array(); //先检测是否只匹配品名
  602. $tqjcskub = array();
  603. $tqjcqda = array();
  604. $tqjcqdb = array();
  605. $tqjcgit = array(); //礼物类放SKU顺序中间
  606. $tqjcgitpd = array(); //礼物类放SKU顺序中间
  607. foreach ($sku as $k => $value) {
  608. //查找是否有头套和HD开始
  609. $cid = array();
  610. $cf = explode('-', trim($value, '-'));
  611. $cf = array_filter($cf);
  612. foreach ($cf as $v) {
  613. if (isset($dtc[$v]['id']) && isset($dtc[$v]['jm'])) {
  614. $cid[$dtc[$v]['classid']] = array('id' => $dtc[$v]['id'], 'spare' => $v, 'jm' => $dtc[$v]['jm']);
  615. }
  616. }
  617. if (isset($cid['44']) && isset($cid['18'])) {
  618. if (isset($dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['id'])) {
  619. $value = '-' . $value . '-';
  620. $sku[$k] = '-' . $sku[$k] . '-';
  621. $pd[$k] = '-' . $pd[$k] . '-';
  622. $value = str_replace('-' . $cid['18']['spare'] . '-', '-' . $dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['spare'] . '-', $value);
  623. $value = str_replace('-' . $cid['44']['spare'], '-', $value);
  624. $sku[$k] = str_replace('-' . $cid['18']['spare'] . '-', '-' . $dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['spare'] . '-', $sku[$k]);
  625. $sku[$k] = str_replace('-' . $cid['44']['spare'], '-', $sku[$k]);
  626. $pd[$k] = str_replace('-' . $cid['18']['spare'] . '-', '-' . $dtc[strtolower($cid['44']['jm']) . $cid['18']['spare']]['spare'] . '-', $pd[$k]);
  627. $pd[$k] = str_replace('-' . $cid['44']['spare'], '-', $pd[$k]);
  628. $value = strtolower(trim($value, '-'));
  629. $pd[$k] = strtolower(trim($pd[$k], '-'));
  630. $sku[$k] = strtolower(trim($sku[$k], '-'));
  631. } else if (stripos($value, '-transparent') !== false || stripos($value, '-tr') === false) {
  632. $value = str_replace(array('-transparent', '-tr'), '', $value);
  633. $sku[$k] = str_replace(array('-transparent', '-tr'), '', $sku[$k]);
  634. $pd[$k] = str_replace(array('-transparent', '-tr'), '', $pd[$k]);
  635. }
  636. }
  637. //查找是否有头套和HD结束
  638. if (isset($dtc[$value]['classid'])) {
  639. if ($dtc[$value]['classid'] == '999' || $dtc[$value]['classid'] == '9999') {
  640. $tqjcskua[$k] = $value;
  641. $tqjcqda[$k] = $pd[$k];
  642. continue;
  643. }
  644. }
  645. if (stripos($value, 'gift') !== false) {
  646. $tqjcgit[$k] = $value;
  647. $tqjcgitpd[$k] = $pd[$k];
  648. continue;
  649. }
  650. $tqjcskub[$k] = $value;
  651. $tqjcqdb[$k] = $pd[$k];
  652. }
  653. $sku = $tqjcskub + $tqjcgit + $tqjcskua;
  654. $newsl = array();
  655. foreach ($sku as $k => $value) {
  656. if (!isset($sl[$k])) {
  657. $sl[$k] = 1;
  658. }
  659. $newsl[] = $sl[$k];
  660. }
  661. $sl = array_values($newsl);
  662. $pd = $tqjcqdb + $tqjcgitpd + $tqjcqda;
  663. $sku = array_values($sku); //按照现有顺序键值重新由0开始
  664. $pd = array_values($pd);
  665. /**
  666. $tqjcskua = array();//先检测是否只匹配品名
  667. $tqjcskub = array();
  668. foreach ($sku as $k=>$value)
  669. {
  670. if(isset($dtc[$value]['classid']))
  671. {
  672. if($dtc[$value]['classid'] == '999' || $dtc[$value]['classid'] == '9999')
  673. {
  674. $tqjcskua[$k] = $value;
  675. continue;
  676. }
  677. }
  678. $tqjcskub[$k] = $value;
  679. }
  680. $sku = $tqjcskub+$tqjcskua;
  681. $sku = array_values($sku);//按照现有顺序键值重新由0开始
  682. **/
  683. foreach ($sku as $value) {
  684. $bmsku = '';
  685. if (stripos($value, '-<') !== false && stripos($value, '>-') === false) {
  686. $isskufg = explode('-<', $value);
  687. $bmsku = '&lt;' . strtoupper($isskufg[1]);
  688. }
  689. if (stripos($value, '-<') !== false && stripos($value, '>-') !== false) {
  690. $isskufg = explode('-<', $value);
  691. $isskufgh = explode('>-', $isskufg[1]);
  692. $bmsku = '&lt;' . strtoupper($isskufgh[0]) . '&gt;';
  693. }
  694. if (stripos($value, '-<') === false && stripos($value, '>-') !== false) {
  695. $isskufg = explode('>-', $value);
  696. $bmsku = strtoupper($isskufg[0]) . '&gt;';
  697. }
  698. if (stripos($value, '-&lt;') !== false && stripos($value, '&gt;-') === false) {
  699. $isskufg = explode('-&lt;', $value);
  700. $bmsku = '&lt;' . strtoupper($isskufg[1]);
  701. }
  702. if (stripos($value, '-&lt;') !== false && stripos($value, '&gt;-') !== false) {
  703. $isskufg = explode('-&lt;', $value);
  704. $isskufgh = explode('&gt;-', $isskufg[1]);
  705. $bmsku = '&lt;' . strtoupper($isskufgh[0]) . '&gt;';
  706. }
  707. if (stripos($value, '-&lt;') === false && stripos($value, '&gt;-') !== false) {
  708. $isskufg = explode('&gt;-', $value);
  709. $bmsku = strtoupper($isskufg[0]) . '&gt;';
  710. }
  711. $value = trim($value, ' ');
  712. $cpson = array();
  713. $cplf = array();
  714. $thisid = '';
  715. $tha = array();
  716. $thb = array();
  717. $purchasemy = 0;
  718. $costmy = 0;
  719. $salespricemy = 0;
  720. $djay = array(); //每单单个产品公司销售价格
  721. $ptitlea = '';
  722. $ptitleb = ''; //每单产品名称
  723. $cpa = '';
  724. $cpb = '';
  725. $fc = 0;
  726. $number = array('dc' => '', 'c' => '');
  727. $classid = $this->classid->sku();
  728. $pm = $classid; //品名顺序
  729. //等级-真人发类型-化纤发编号-颜色-花型-蕾丝头套种类-化纤头套类型-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-化纤其它属性-头套其它属性-头套属性 100为头套额外附加
  730. $cp = array(16 => 126, 22 => '', 13 => 80, 14 => '', 43 => '', 8 => 57, 15 => ''); //产品默认ID内容
  731. //16->类目、22->真人发类型、13->等级、14->长度、8->颜色、15->曲度(花型)
  732. $cptt = array(16 => 128, 13 => 80, 43 => '', 8 => '57', 15 => '', 18 => '', 6 => 30, 10 => 72, 9 => '', 44 => '', 39 => ''); //头套
  733. $cpcp = array(16 => 130, 13 => 80, 14 => '', 33 => '', 8 => 57, 15 => '', 38 => '', 7 => ''); //卡子发,7=>33重量
  734. $cpgi = array(16 => 131, 34 => ''); //礼物
  735. $cpac = array(16 => 133, 35 => ''); //配件
  736. $cphxtt = array(16 => 1297, 13 => 80, 14 => '', 40 => '', 8 => 57, 15 => '', 41 => '', 42 => '');
  737. $cphxhair = array(16 => 1702, 13 => 80, 14 => '', 47 => '', 46 => '', 8 => 57, 15 => '', 38 => '', 48 => '');
  738. if ((preg_match('/\d\*\df/', $pd[$x]) || preg_match('/\df/', $pd[$x]) || stripos($pd[$x], '+F') !== false || stripos($pd[$x], 'Frontal') !== false) && stripos($pd[$x], 'wig') === false && stripos($pd[$x], 'Bob') === false) {
  739. $u27 = (stripos($pd[$x], 'SilkBaseFrontal') !== false) ? 199 : 197;
  740. $cplf = array(16 => 127, 27 => $u27, 12 => 75, 10 => 72, 26 => 191, 9 => '', 44 => ''); //蕾丝发块
  741. $fc = 1;
  742. } else if ((preg_match('/\d\*\dc/', $pd[$x]) || preg_match('/\dc/', $pd[$x]) || stripos($pd[$x], '+C') !== false || stripos($pd[$x], 'Closure') !== false) && stripos($pd[$x], 'wig') === false && stripos($pd[$x], 'Bob') === false) {
  743. $u27 = (stripos($pd[$x], 'SilkBaseClosure') !== false) ? 196 : 195;
  744. $cplf = array(16 => 127, 27 => $u27, 12 => 75, 10 => 72, 25 => 182, 9 => '', 44 => ''); //蕾丝发块
  745. if (stripos($pd[$x], '2*6') !== false) {
  746. $cplf[12] = 76;
  747. }
  748. $fc = 1;
  749. }
  750. $ceshi = array();
  751. $cpcppd = 0;
  752. $cpcptype = $this->typeclass->find_all("classid = 33");
  753. foreach ($cpcptype as $v) {
  754. $val = explode('|', trim($v['spare'], '|'));
  755. foreach ($val as $vv) {
  756. if (stripos('-' . $pd[$x] . '-', '-' . $vv . '-') !== false) {
  757. $cpcppd++;
  758. }
  759. }
  760. }
  761. if ($fc == 1) {
  762. $cpson = $cplf;
  763. } else if ((stripos($pd[$x], 'wig') !== false || stripos($pd[$x], 'Bob') !== false) && stripos($pd[$x], 'Syn') === false && stripos($pd[$x], 'Gift') === false) //
  764. {
  765. $cpson = $cptt;
  766. } else if ((stripos($pd[$x], 'SyHair') !== false || (stripos($pd[$x], 'SyHair') !== false && stripos($pd[$x], 'Syn') !== false)) && $cpcppd == 0) {
  767. $cpson = $cphxhair;
  768. $cp = $cpson;
  769. } else if (stripos($pd[$x], 'Syn') !== false && $cpcppd == 0) {
  770. $cpson = $cphxtt;
  771. $cp = $cpson;
  772. } else if ($cpcppd > 0) {
  773. $cpson = $cpcp;
  774. $cp = $cpcp;
  775. } else if (stripos($pd[$x], 'Gift') !== false) {
  776. $cpson = $cpgi;
  777. } else if (stripos($pd[$x], 'Accs') !== false) {
  778. $cpson = $cpac;
  779. } else {
  780. $cpson = $cp;
  781. }
  782. //$cpson = $fc==1?$cplf:((stripos($pd[$x],'wig') !== false || stripos($pd[$x],'Bob') !== false)?$cptt:(stripos($pd[$x],'Clip') !== false?$cpcp:array()));//是否是类似发块或头套产品
  783. $cs[$x] = $cpson;
  784. $son = explode('-', $value); //字符串转数组
  785. $snum = 0;
  786. $cpsl = 0;
  787. foreach ($son as $val) {
  788. if (stripos($val, '^') !== false) {
  789. $snum += str_replace('^', '', $val);
  790. }
  791. if (isset($dtc[$val])) //如果能匹配到
  792. {
  793. if (is_numeric($val) || $dtc[$val]['classid'] == '14') //如果是组合产品
  794. {
  795. $cpsl++;
  796. if (!is_numeric($val)) {
  797. $pm['c'] = $dtc[$val]['zh'];
  798. } else {
  799. $pm['c'] = $val . '寸'; //尺寸不匹配,并且准备写入到+号后面
  800. }
  801. $number['c'] = $val;
  802. } else {
  803. if (isset($cp[$dtc[$val]['classid']])) //判断匹配ID属于头部还是尾部
  804. {
  805. $cp[$dtc[$val]['classid']] = $dtc[$val]['id'];
  806. }
  807. if (isset($cpson[$dtc[$val]['classid']])) {
  808. if ($dtc[$val]['id'] != 66) //按要求暂时不匹配中棕颜色
  809. {
  810. $cpson[$dtc[$val]['classid']] = $dtc[$val]['id'];
  811. }
  812. }
  813. /**
  814. if($pm[15] == '卡子发卡子发' || $dtc[$val]['zh'] == '卡子发卡子发')
  815. {
  816. $slpx[] = 1;
  817. $pm[$dtc[$val]['classid']] = $pm[$dtc[$val]['classid']].' '.$dtc[$val]['zh'];
  818. }
  819. else
  820. **/
  821. if ($dtc[$val]['classid'] == '999') {
  822. $pm[$dtc[$val]['classid']] .= $dtc[$val]['zh']; //其它正常匹配
  823. } else {
  824. $pm[$dtc[$val]['classid']] = $dtc[$val]['zh']; //其它正常匹配
  825. }
  826. }
  827. } else if (preg_match('/((\d+)\s+(\d+))/', $val) && stripos($val, 'NO') === false) //如果不能匹配是多尺寸字符串
  828. {
  829. $j = (stripos($pd[$x], '+') !== false) ? ' +' : ''; //判断sku是否是+号类型
  830. if (isset($cpson[16])) {
  831. if ($cpson[16] != 128) {
  832. $cpslnum = explode(' ', trim($val, ' '));
  833. $cpsl += count($cpslnum);
  834. $pm['dc'] = $val . $j; //写入多尺寸字符串
  835. }
  836. } else {
  837. $cpslnum = explode(' ', trim($val, ' '));
  838. $cpsl += count($cpslnum);
  839. $pm['dc'] = $val . $j;
  840. }
  841. $number['dc'] = $val;
  842. }
  843. }
  844. if ($sl[$x] > 1 || $snum > 1) {
  845. $slx = $sl[$x];
  846. if ($snum > 1) {
  847. $slx = ($slx > 1) ? $slx : 1;
  848. $slx *= $snum;
  849. }
  850. $slpx[] = $cpsl;
  851. $nr .= '[' . $bmsku . implode(" ", $pm) . ']*' . $slx . '包' . ';'; //数组转字符串
  852. } else {
  853. if ($cpsl > 0) {
  854. $slpx[] = $cpsl;
  855. }
  856. $slx = 1;
  857. $pdpm = $bmsku . implode("", $pm);
  858. if ($pdpm != '') {
  859. $nr .= $bmsku . implode(" ", $pm) . ';'; //数组转字符串
  860. }
  861. }
  862. //以下是特殊类型的匹配
  863. if (stripos($nr, '带绒布内衬半蕾丝头套') !== false && stripos($nr, '#') !== false) {
  864. $nr = preg_replace('/\#(\d+)/', '内衬颜色$1号色', $nr);
  865. }
  866. $weightsku = array();
  867. $weightdata = $this->weight->find_all();
  868. foreach ($weightdata as $w) {
  869. $weightsku[$w['features']] = $w['weight'];
  870. }
  871. if ($number['dc'] != '') {
  872. if (stripos($pd[$x], '+') !== false) {
  873. foreach ($cp as $v) {
  874. $ptitlea .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
  875. }
  876. } else {
  877. foreach ($cpson as $v) {
  878. $ptitlea .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
  879. }
  880. }
  881. $dc = explode(' ', trim($number['dc'], ' '));
  882. for ($i = 0; $i < count($dc); $i++) {
  883. if (isset($dtc[$dc[$i]]['id'])) {
  884. $thisid = $dtc[$dc[$i]]['id'];
  885. /**
  886. $tha[$dc[$i]] = isset($tha[$dc[$i]])?array('zh'=>$tha[$dc[$i]]['zh'],'id'=>$tha[$dc[$i]]['id'],'count'=>$tha[$dc[$i]]['count']+1):array('zh'=>$dc[$i],'id'=>$thisid,'count'=>1);
  887. **/
  888. //一样的不再合并
  889. $tha[] = array('zh' => $dc[$i], 'id' => $thisid, 'count' => 1);
  890. }
  891. }
  892. foreach ($tha as $v) {
  893. $item = array_merge($cp);
  894. $weight = 0;
  895. if ($cp['16'] == '126') {
  896. $weight = $weightsku['126'];
  897. } else if ($cp['16'] == '127') {
  898. if (isset($item[9])) {
  899. $sku127a = $item[0] . '-' . $v['id'] . '-' . $item[3] . '-' . $item[6] . '-' . $item[9];
  900. $sku127b = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[9];
  901. if (isset($weightsku[$sku127a])) {
  902. $weight = $weightsku[$sku127a];
  903. } else if (isset($weightsku[$sku127b])) {
  904. $weight = $weightsku[$sku127b];
  905. }
  906. }
  907. } else if ($cp['16'] == '128') {
  908. if (isset($item[8])) {
  909. $sku128 = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[8];
  910. if (isset($weightsku[$sku128])) {
  911. $weight = $weightsku[$sku128];
  912. }
  913. }
  914. }
  915. $cpa = $cp;
  916. $cpa[14] = $v['id'];
  917. $cpa[22] = ''; //增加长度ID、去除真人发类型
  918. $whlabel .= implode("", $cpa) . '-' . $slx * $v['count'] . '-0|';
  919. $pdcc = (is_numeric($v['zh'])) ? $v['zh'] . 'inch |' : strtoupper($v['zh']) . '|';
  920. $product .= $v['id'] . ',-' . rtrim(implode("-", $cp), '-') . '-|' . $ptitlea . $pdcc . $slx * $v['count'] . '|0|0|' . $v['zh'] . '|0|0|' . $slx * $v['count'] * $weight . '|0;';
  921. }
  922. }
  923. if ($number['c'] != '') {
  924. $fk = $cp;
  925. foreach ($cpson as $k => $v) {
  926. $fk[$k] = $v; //+号左右ID合并右完整ID
  927. }
  928. foreach ($fk as $v) {
  929. $ptitleb .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
  930. }
  931. $c = explode(' ', trim($number['c'], ' '));
  932. for ($i = 0; $i < count($c); $i++) {
  933. $thisid = $dtc[$c[$i]]['id'];
  934. /**
  935. $thb[$c[$i]] = isset($thb[$c[$i]])?array('zh'=>$thb[$c[$i]]['zh'],'id'=>$thb[$c[$i]]['id'],'count'=>$thb[$c[$i]]['count']+1):array('zh'=>$c[$i],'id'=>$thisid,'count'=>1);
  936. **/
  937. //一样的不再合并
  938. $thb[] = array('zh' => $c[$i], 'id' => $thisid, 'count' => 1);
  939. }
  940. foreach ($thb as $v) {
  941. $item = array_merge($fk);
  942. $weight = 0;
  943. if ($fk['16'] == '126') {
  944. $weight = $weightsku[$item[0]];
  945. } else if ($fk['16'] == '127') {
  946. if (isset($item[9])) {
  947. $sku127a = $item[0] . '-' . $v['id'] . '-' . $item[3] . '-' . $item[6] . '-' . $item[9];
  948. $sku127b = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[9];
  949. if (isset($weightsku[$sku127a])) {
  950. $weight = $weightsku[$sku127a];
  951. } else if (isset($weightsku[$sku127b])) {
  952. $weight = $weightsku[$sku127b];
  953. }
  954. }
  955. } else if ($fk['16'] == '128') {
  956. if (isset($item[8])) {
  957. $sku128 = $item[0] . '-' . $v['id'] . '-' . $item[6] . '-' . $item[8];
  958. if (isset($weightsku[$sku128])) {
  959. $weight = $weightsku[$sku128];
  960. }
  961. }
  962. }
  963. $cpb = $fk;
  964. $cpb[14] = $v['id'];
  965. $cpb[22] = ''; //增加长度ID、去除真人发类型
  966. $whlabel .= implode("", $cpb) . '-' . $slx * $v['count'] . '-0|';
  967. $pdcc = (is_numeric($v['zh'])) ? $v['zh'] . 'inch |' : strtoupper($v['zh']) . '|';
  968. $product .= $v['id'] . ',-' . rtrim(implode("-", $fk), '-') . '-|' . $ptitleb . $pdcc . $slx * $v['count'] . '|0|0|' . $v['zh'] . '|0|0|' . $slx * $v['count'] * $weight . '|0;';
  969. }
  970. }
  971. if (stripos($pd[$x], 'Gift-') !== false) {
  972. $ptitleg = '';
  973. foreach ($cpson as $v) {
  974. $ptitleg .= isset($dtctitle[$v]) ? $dtctitle[$v] . ' ' : '';
  975. }
  976. $whlabel .= implode("", $cpson) . '-' . $slx . '-0|';
  977. $product .= '-' . rtrim(implode("-", $cpson), '-') . '-|' . $ptitleg . '|' . $slx . '|0|0||0|0|0|0;';
  978. }
  979. $x++;
  980. $purchase += $purchasemy;
  981. $cost += $costmy;
  982. }
  983. $product = str_replace('--', '-', $product);
  984. $qbslpx = 0;
  985. $wcslpx = '';
  986. foreach ($slpx as $v) {
  987. $wcslpx .= $qbslpx . '-' . ($qbslpx + $v) . '|';
  988. $qbslpx += $v;
  989. }
  990. $nr = str_replace(array('(', ')'), array('(', ')'), $nr);
  991. if (stripos($whlabel, '|--|') !== false) {
  992. $whlabel = '';
  993. $product = '';
  994. }
  995. return array('title' => preg_replace(array('/(\s+)/', '/分\s/u'), array(' ', '分'), trim($nr, ';')), 'purchase' => $purchase, 'cost' => $cost, 'product' => str_replace(array('---', '--'), array('-', '-'), $product), 'whlabel' => $whlabel, 'wcslpx' => trim($wcslpx, '|'), 'cs' => $cscs);
  996. }
  997. public function _spexcel()
  998. {
  999. $tc = array();
  1000. $typeclass = $this->typeclass->find_all();
  1001. foreach ($typeclass as $v) {
  1002. $tc[$v['id']] = $v;
  1003. }
  1004. if (isset($_SESSION['api'])) {
  1005. $user = $this->user->get_api($_SESSION['api']);
  1006. $usp = $user;
  1007. $fgshop = "";
  1008. $sid = "";
  1009. $excelshop = "";
  1010. $usersp = explode('|', trim($user['shop'], '|'));
  1011. foreach ($usersp as $value) {
  1012. $fgshop .= " shop = " . $value . " or";
  1013. $sid .= " id = " . $value . " or";
  1014. }
  1015. $userexcel = explode('|', trim($user['excelshop'], '|'));
  1016. foreach ($userexcel as $value) {
  1017. $excelshop .= " shop = " . $value . " or";
  1018. }
  1019. if ($excelshop != "") {
  1020. $excelshop = "(" . rtrim($excelshop, 'or') . ")";
  1021. }
  1022. }
  1023. $post = $this->input->post(NULL, TRUE);
  1024. $tcall = $this->typeclass->find_all();
  1025. $typeclass = array();
  1026. foreach ($tcall as $v) {
  1027. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1028. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'jm' => $v['jm']);
  1029. }
  1030. $classid = $this->classid->sku();
  1031. if (isset($_GET['category'])) {
  1032. $timetk = $this->input->get('timetk', true);
  1033. $timetj = $this->input->get('timetj', true);
  1034. $color = $this->input->get('color', true);
  1035. $lowe = $this->input->get('lowe', true);
  1036. $size = $this->input->get('size', true);
  1037. $grade = $this->input->get('grade', true);
  1038. $lacetype = $this->input->get('lacetype', true);
  1039. $category = $this->input->get('category', true);
  1040. $shop = $this->input->get('shop', true);
  1041. $density = $this->input->get('density', true);
  1042. $warehouse = $this->input->get('warehouse', true);
  1043. $time = $this->input->get('time', true);
  1044. $timetk = strtotime($timetk);
  1045. $timetj = strtotime($timetj);
  1046. $where = "";
  1047. if ($warehouse) {
  1048. $where .= " type = " . $warehouse . " and ";
  1049. }
  1050. if ($category) {
  1051. $where .= "fpdata like '%-" . $category . "-%' and ";
  1052. }
  1053. if ($color) {
  1054. $where .= "fpdata like '%-" . $color . "-%' and ";
  1055. }
  1056. if ($size) {
  1057. $where .= "fpdata like '%-" . $size . "-%' and ";
  1058. }
  1059. if ($grade) {
  1060. $where .= "fpdata like '%-" . $grade . "-%' and ";
  1061. }
  1062. if ($shop) {
  1063. $where .= "shop = '$shop' and ";
  1064. } else {
  1065. $where .= $excelshop . " and ";
  1066. }
  1067. if ($lowe) {
  1068. $where .= "fpdata like '%-" . $lowe . "-%' and ";
  1069. }
  1070. if ($density) {
  1071. $where .= "fpdata like '%-" . $density . "-%' and ";
  1072. }
  1073. if ($lacetype) {
  1074. $where .= "fpdata like '%-" . $lacetype . "-%' and ";
  1075. }
  1076. $dataa = $this->fullorder->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
  1077. $datab = $this->fullordersmt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj' and shop != '9'", 'fpdata,number,whlabel,type', 'id desc');
  1078. $datac = $this->fullordertt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
  1079. $data = array_merge($dataa, $datab, $datac);
  1080. $sp = array();
  1081. $cs = array();
  1082. $warehouses = $this->warehouse->find_all('1=1', 'id,title');
  1083. $warehouses = array_column($warehouses, 'title', 'id');
  1084. foreach ($data as $val) {
  1085. $f = explode(';', trim($val['fpdata'], ';'));
  1086. $w = explode('|', trim($val['whlabel'], '|'));
  1087. foreach ($f as $k => $v) {
  1088. if ($category) {
  1089. if (stripos($v, '-' . $category . '-') === false) {
  1090. continue;
  1091. }
  1092. }
  1093. if ($color) {
  1094. if (stripos($v, '-' . $color . '-') === false) {
  1095. continue;
  1096. }
  1097. }
  1098. if ($lowe) {
  1099. if (stripos($v, '-' . $lowe . '-') === false) {
  1100. continue;
  1101. }
  1102. }
  1103. if ($size) {
  1104. if (stripos($v, $size . ',') === false) {
  1105. continue;
  1106. }
  1107. }
  1108. if ($grade) {
  1109. if (stripos($v, '-' . $grade . '-') === false) {
  1110. continue;
  1111. }
  1112. }
  1113. if ($lacetype) {
  1114. if (stripos($v, '-' . $lacetype . '-') === false) {
  1115. continue;
  1116. }
  1117. }
  1118. if ($density) {
  1119. if (stripos($v, '-' . $density . '-') === false) {
  1120. continue;
  1121. }
  1122. }
  1123. $title = explode('|', $v);
  1124. $fg = str_replace(array('-163-', '-164-', '-165-', '-166-', '-0-', '-126-', '-127-', '-128-', '-197-', '-195-'), '-', $title[0]);
  1125. $fg = explode(',', $fg);
  1126. $tmp_c = $this->getCate($title[0]);
  1127. //$fg = explode('-',trim($fg[1].$fg[0],'-'));
  1128. if (isset($fg[1])) {
  1129. $fg = explode('-', trim($fg[1] . $fg[0], '-'));
  1130. } else {
  1131. $fg = [];
  1132. }
  1133. $pm = array();
  1134. //$pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'','dc'=>'','c'=>'',12=>'',25=>'',26=>'',14=>'',27=>'',10=>'',6=>'',9=>'',39=>'',999=>'',9999=>'');//品名顺序
  1135. foreach ($fg as $vv) {
  1136. if (isset($tc[$vv]['zh'])) {
  1137. $zh = explode('|', trim($tc[$vv]['zh'], '|'));
  1138. $pm[$tc[$vv]['classid']] = $zh[0];
  1139. }
  1140. }
  1141. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $v);
  1142. $tsk = explode('|', trim($features, '|'));
  1143. if (stripos($tsk[0], ',') !== false) {
  1144. $ftt = explode(',', $tsk[0]);
  1145. $features = explode('-', trim($ftt[1], '-'));
  1146. $features[] = $ftt[0];
  1147. } else {
  1148. $features = explode('-', trim($tsk[0], '-'));
  1149. }
  1150. $jm = $classid;
  1151. $jm = $classid;
  1152. foreach ($features as $vv) {
  1153. if ($vv != 0) {
  1154. if (!isset($typeclass[$vv])) {
  1155. continue;
  1156. }
  1157. if (isset($jm[$typeclass[$vv]['classid']])) {
  1158. if ($typeclass[$vv]['jm']) {
  1159. $jm[$typeclass[$vv]['classid']] = $typeclass[$vv]['jm'];
  1160. }
  1161. }
  1162. }
  1163. }
  1164. $jm = array_filter($jm); //去除空值
  1165. $jm = implode("-", $jm);
  1166. $zh = implode(" ", $pm);
  1167. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1168. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1169. if (isset($title[1])) {
  1170. if (isset($sp[$title[1]])) {
  1171. $sp[$title[1]]['n'] += $title[2];
  1172. if (isset($sp[$title[1]]['warehouse'][$val['type']])) {
  1173. $sp[$title[1]]['warehouse'][$val['type']] += $title[2];
  1174. } else {
  1175. $sp[$title[1]]['warehouse'][$val['type']] = $title[2];
  1176. }
  1177. //美仓
  1178. if ($val['type'] == 5) {
  1179. $sp[$title[1]]['mc'] += $title[2];
  1180. } elseif ($val['type'] == 13) { //许昌仓
  1181. $sp[$title[1]]['xcc'] += $title[2];
  1182. } elseif ($val['type'] == 16) { //定制仓
  1183. $sp[$title[1]]['dzc'] += $title[2];
  1184. } else {
  1185. $sp[$title[1]]['qtc'] += $title[2];
  1186. }
  1187. } else {
  1188. $wh = explode('-', $w[$k]);
  1189. $wsku = $this->whlabel->find_all("number = '" . $wh[0] . "' and sku != 'Preset'");
  1190. $whs = (isset($wsku[0]['sku'])) ? $wsku[0]['sku'] : '';
  1191. $sp[$title[1]] = array('t' => $title[1], 'z' => $zh, 'c' => $tmp_c, 'w' => $whs, 'j' => $jm, 'n' => isset($title[2]) ? $title[2] : "异常 ", "warehouse" => [
  1192. $val['type'] => isset($title[2])? $title[2]:" 异常",
  1193. ], "warehouse_show" => "", "xcc" => 0, "mc" => 0, "dzc" => 0, "qtc" => 0);
  1194. //美仓
  1195. if ($val['type'] == 5) {
  1196. $sp[$title[1]]['mc'] = isset($title[2])? $title[2]:" 异常";
  1197. } elseif ($val['type'] == 13) { //许昌仓
  1198. $sp[$title[1]]['xcc'] = isset($title[2])? $title[2]:" 异常";
  1199. } elseif ($val['type'] == 16) { //定制仓
  1200. $sp[$title[1]]['dzc'] = isset($title[2])? $title[2]:" 异常";
  1201. } else {
  1202. $sp[$title[1]]['qtc'] = isset($title[2])? $title[2]:" 异常";
  1203. }
  1204. }
  1205. }
  1206. //由于原来的按照品名分组可能会有异常 这里将品名转化为skuid为分组依据
  1207. // $wh = explode('-',$w[$k]);
  1208. // if(isset($wh[0])){
  1209. // if(isset($sp[$wh[0]]))
  1210. // {
  1211. // $sp[$wh[0]]['n'] += $title[2];
  1212. // if(isset($sp[$wh[0]]['warehouse'][$val['type']])){
  1213. // $sp[$wh[0]]['warehouse'][$val['type']] += $title[2];
  1214. // }else{
  1215. // $sp[$wh[0]]['warehouse'][$val['type']] = $title[2];
  1216. // }
  1217. // //美仓
  1218. // if($val['type'] == 5){
  1219. // $sp[$wh[0]]['mc'] += $title[2];
  1220. // }elseif($val['type'] == 13){//许昌仓
  1221. // $sp[$wh[0]]['xcc'] += $title[2];
  1222. // }elseif($val['type'] == 16){//定制仓
  1223. // $sp[$wh[0]]['dzc'] += $title[2];
  1224. // }else{
  1225. // $sp[$wh[0]]['qtc'] += $title[2];
  1226. // }
  1227. // }
  1228. // else
  1229. // {
  1230. // $wh = explode('-',$w[$k]);
  1231. // $wsku = $this->whlabel->find_all("number = '".$wh[0]."' and sku != 'Preset'");
  1232. // $whs = (isset($wsku[0]['sku']))?$wsku[0]['sku']:'';
  1233. // $sp[$wh[0]] = array('t'=>$title[1],'z'=>$zh,'c'=>$tmp_c,'w'=>$whs,'j'=>$jm,'n'=>$title[2],"warehouse"=>[
  1234. // $val['type'] =>$title[2],
  1235. // ],"warehouse_show"=>"","xcc"=>0,"mc"=>0,"dzc"=>0,"qtc"=>0);
  1236. // //美仓
  1237. // if($val['type'] == 5){
  1238. // $sp[$wh[0]]['mc'] = $title[2];
  1239. // }elseif($val['type'] == 13){//许昌仓
  1240. // $sp[$wh[0]]['xcc'] = $title[2];
  1241. // }elseif($val['type'] == 16){//定制仓
  1242. // $sp[$wh[0]]['dzc'] = $title[2];
  1243. // }else{
  1244. // $sp[$wh[0]]['qtc'] = $title[2];
  1245. // }
  1246. // }
  1247. // }
  1248. }
  1249. }
  1250. foreach ($sp as $k => $v) {
  1251. // foreach($sp[$k]['warehouse'] as $kk =>$vv){
  1252. // $warehouse_name = isset($warehouses[$kk])?$warehouses[$kk]:"异常仓库-".$kk;
  1253. // $sp[$k]['warehouse_show'] .=$warehouse_name.":".$vv."<br />";
  1254. // }
  1255. unset($sp[$k]['warehouse']);
  1256. unset($sp[$k]['warehouse_show']);
  1257. }
  1258. $sp = array_values($sp);
  1259. $title = "商品统计" . date('Y-m-d H-i-s', time());
  1260. $titlename = "<table border=1>
  1261. <tr>
  1262. <td>名称</td>
  1263. <td>中文</td>
  1264. <td>类型</td>
  1265. <td>SKU</td>
  1266. <td>用友料号</td>
  1267. <td>数量</td>
  1268. <td>许昌仓发货量</td>
  1269. <td>美仓发货量</td>
  1270. <td>定制仓发货量</td>
  1271. <td>其他仓发货量</td>
  1272. </tr>
  1273. </table>";
  1274. $filename = $title . ".xls";
  1275. $tail = "\n";
  1276. $this->excel->get_fz2($sp, $titlename, $filename, $tail);
  1277. }
  1278. }
  1279. private function _spexceljs()
  1280. {
  1281. $tc = array();
  1282. $typeclass = $this->typeclass->find_all();
  1283. foreach ($typeclass as $v) {
  1284. $tc[$v['id']] = $v;
  1285. }
  1286. if (isset($_SESSION['api'])) {
  1287. $user = $this->user->get_api($_SESSION['api']);
  1288. $usp = $user;
  1289. $fgshop = "";
  1290. $sid = "";
  1291. $excelshop = "";
  1292. $usersp = explode('|', trim($user['shop'], '|'));
  1293. foreach ($usersp as $value) {
  1294. $fgshop .= " shop = " . $value . " or";
  1295. $sid .= " id = " . $value . " or";
  1296. }
  1297. $userexcel = explode('|', trim($user['excelshop'], '|'));
  1298. foreach ($userexcel as $value) {
  1299. $excelshop .= " shop = " . $value . " or";
  1300. }
  1301. if ($excelshop != "") {
  1302. $excelshop = "(" . rtrim($excelshop, 'or') . ")";
  1303. }
  1304. }else{
  1305. exit(json_encode(array('code' => 0, 'msg' => '登录信息异常')));
  1306. }
  1307. $tcall = $this->typeclass->find_all();
  1308. $typeclass = array();
  1309. foreach ($tcall as $v) {
  1310. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1311. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'jm' => $v['jm']);
  1312. }
  1313. $classid = $this->classid->sku();
  1314. if (isset($_GET['category'])) {
  1315. $timetk = $this->input->get('timetk', true);
  1316. $timetj = $this->input->get('timetj', true);
  1317. $color = $this->input->get('color', true);
  1318. $lowe = $this->input->get('lowe', true);
  1319. $size = $this->input->get('size', true);
  1320. $grade = $this->input->get('grade', true);
  1321. $lacetype = $this->input->get('lacetype', true);
  1322. $category = $this->input->get('category', true);
  1323. $shop = $this->input->get('shop', true);
  1324. $density = $this->input->get('density', true);
  1325. $warehouse = $this->input->get('warehouse', true);
  1326. $time = $this->input->get('time', true);
  1327. $timetk = strtotime($timetk);
  1328. $timetj = strtotime($timetj);
  1329. $where = "";
  1330. if ($warehouse) {
  1331. $where .= " type = " . $warehouse . " and ";
  1332. }
  1333. if ($category) {
  1334. $where .= "fpdata like '%-" . $category . "-%' and ";
  1335. }
  1336. if ($color) {
  1337. $where .= "fpdata like '%-" . $color . "-%' and ";
  1338. }
  1339. if ($size) {
  1340. $where .= "fpdata like '%-" . $size . "-%' and ";
  1341. }
  1342. if ($grade) {
  1343. $where .= "fpdata like '%-" . $grade . "-%' and ";
  1344. }
  1345. if ($shop) {
  1346. $where .= "shop = '$shop' and ";
  1347. } else {
  1348. $where .= $excelshop . " and ";
  1349. }
  1350. if ($lowe) {
  1351. $where .= "fpdata like '%-" . $lowe . "-%' and ";
  1352. }
  1353. if ($density) {
  1354. $where .= "fpdata like '%-" . $density . "-%' and ";
  1355. }
  1356. if ($lacetype) {
  1357. $where .= "fpdata like '%-" . $lacetype . "-%' and ";
  1358. }
  1359. $dataa = $this->fullorder->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
  1360. $datab = $this->fullordersmt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj' and shop != '9'", 'fpdata,number,whlabel,type', 'id desc');
  1361. $datac = $this->fullordertt->find_all($where . $time . " > '$timetk' and " . $time . " < '$timetj'", 'fpdata,number,whlabel,type', 'id desc');
  1362. $data = array_merge($dataa, $datab, $datac);
  1363. $sp = array();
  1364. $warehouses = $this->warehouse->find_all('1=1', 'id,title');
  1365. $warehouses = array_column($warehouses, 'title', 'id');
  1366. foreach ($data as $val) {
  1367. $f = explode(';', trim($val['fpdata'], ';'));
  1368. $w = explode('|', trim($val['whlabel'], '|'));
  1369. foreach ($f as $k => $v) {
  1370. if ($category) {
  1371. if (stripos($v, '-' . $category . '-') === false) {
  1372. continue;
  1373. }
  1374. }
  1375. if ($color) {
  1376. if (stripos($v, '-' . $color . '-') === false) {
  1377. continue;
  1378. }
  1379. }
  1380. if ($lowe) {
  1381. if (stripos($v, '-' . $lowe . '-') === false) {
  1382. continue;
  1383. }
  1384. }
  1385. if ($size) {
  1386. if (stripos($v, $size . ',') === false) {
  1387. continue;
  1388. }
  1389. }
  1390. if ($grade) {
  1391. if (stripos($v, '-' . $grade . '-') === false) {
  1392. continue;
  1393. }
  1394. }
  1395. if ($lacetype) {
  1396. if (stripos($v, '-' . $lacetype . '-') === false) {
  1397. continue;
  1398. }
  1399. }
  1400. if ($density) {
  1401. if (stripos($v, '-' . $density . '-') === false) {
  1402. continue;
  1403. }
  1404. }
  1405. $title = explode('|', $v);
  1406. $fg = str_replace(array('-163-', '-164-', '-165-', '-166-', '-0-', '-126-', '-127-', '-128-', '-197-', '-195-'), '-', $title[0]);
  1407. $fg = explode(',', $fg);
  1408. $tmp_c = $this->getCate($title[0]);
  1409. if (isset($fg[1])) {
  1410. $fg = explode('-', trim($fg[1] . $fg[0], '-'));
  1411. } else {
  1412. $fg = [];
  1413. }
  1414. $pm = array();
  1415. foreach ($fg as $vv) {
  1416. if (isset($tc[$vv]['zh'])) {
  1417. $zh = explode('|', trim($tc[$vv]['zh'], '|'));
  1418. $pm[$tc[$vv]['classid']] = $zh[0];
  1419. }
  1420. }
  1421. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $v);
  1422. $tsk = explode('|', trim($features, '|'));
  1423. if (stripos($tsk[0], ',') !== false) {
  1424. $ftt = explode(',', $tsk[0]);
  1425. $features = explode('-', trim($ftt[1], '-'));
  1426. $features[] = $ftt[0];
  1427. } else {
  1428. $features = explode('-', trim($tsk[0], '-'));
  1429. }
  1430. $jm = $classid;
  1431. $jm = $classid;
  1432. foreach ($features as $vv) {
  1433. if ($vv != 0) {
  1434. if (!isset($typeclass[$vv])) {
  1435. continue;
  1436. }
  1437. if (isset($jm[$typeclass[$vv]['classid']])) {
  1438. if ($typeclass[$vv]['jm']) {
  1439. $jm[$typeclass[$vv]['classid']] = $typeclass[$vv]['jm'];
  1440. }
  1441. }
  1442. }
  1443. }
  1444. $jm = array_filter($jm); //去除空值
  1445. $jm = implode("-", $jm);
  1446. $zh = implode(" ", $pm);
  1447. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1448. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1449. if (isset($title[1])) {
  1450. if (isset($sp[$title[1]])) {
  1451. $sp[$title[1]]['n'] += $title[2];
  1452. if (isset($sp[$title[1]]['warehouse'][$val['type']])) {
  1453. $sp[$title[1]]['warehouse'][$val['type']] += $title[2];
  1454. } else {
  1455. $sp[$title[1]]['warehouse'][$val['type']] = $title[2];
  1456. }
  1457. //美仓
  1458. if ($val['type'] == 5) {
  1459. $sp[$title[1]]['mc'] += $title[2];
  1460. } elseif ($val['type'] == 13) { //许昌仓
  1461. $sp[$title[1]]['xcc'] += $title[2];
  1462. } elseif ($val['type'] == 16) { //定制仓
  1463. $sp[$title[1]]['dzc'] += $title[2];
  1464. } else {
  1465. $sp[$title[1]]['qtc'] += $title[2];
  1466. }
  1467. } else {
  1468. $wh = explode('-', $w[$k]);
  1469. $wsku = $this->whlabel->find_all("number = '" . $wh[0] . "' and sku != 'Preset'");
  1470. $whs = (isset($wsku[0]['sku'])) ? $wsku[0]['sku'] : '';
  1471. $sp[$title[1]] = array('t' => $title[1], 'z' => $zh, 'c' => $tmp_c, 'w' => $whs, 'j' => $jm, 'n' => isset($title[2]) ? $title[2] : "异常 ", "warehouse" => [
  1472. $val['type'] => isset($title[2])? $title[2]:" 异常",
  1473. ], "warehouse_show" => "", "xcc" => 0, "mc" => 0, "dzc" => 0, "qtc" => 0);
  1474. //美仓
  1475. if ($val['type'] == 5) {
  1476. $sp[$title[1]]['mc'] = isset($title[2])? $title[2]:" 异常";
  1477. } elseif ($val['type'] == 13) { //许昌仓
  1478. $sp[$title[1]]['xcc'] = isset($title[2])? $title[2]:" 异常";
  1479. } elseif ($val['type'] == 16) { //定制仓
  1480. $sp[$title[1]]['dzc'] = isset($title[2])? $title[2]:" 异常";
  1481. } else {
  1482. $sp[$title[1]]['qtc'] = isset($title[2])? $title[2]:" 异常";
  1483. }
  1484. }
  1485. }
  1486. }
  1487. }
  1488. foreach ($sp as $k => $v) {
  1489. unset($sp[$k]['warehouse']);
  1490. unset($sp[$k]['warehouse_show']);
  1491. }
  1492. $sp = array_values($sp);
  1493. $title = "商品统计" . date('Y-m-d H-i-s', time());
  1494. echo json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $sp,'filename'=>$title));
  1495. die;
  1496. }else{
  1497. exit(json_encode(array('code' => 0, 'msg' => '参数异常')));
  1498. }
  1499. }
  1500. private function _spexceljsbak()
  1501. {
  1502. $tcjm = $tmp_typeclass = $tc = [];
  1503. $typeclass = $this->typeclass->find_all();
  1504. foreach ($typeclass as $v) {
  1505. $tc[$v['id']] = $v;
  1506. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1507. $tmp_typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'jm' => $v['jm']);
  1508. }
  1509. $typeclass = $tmp_typeclass;
  1510. if(isset($_SESSION['api'])){
  1511. $user = $this->user->get_api($_SESSION['api']);
  1512. if(empty($user)){
  1513. exit(json_encode(array('code' => 0, 'msg' => '登录信息异常')));
  1514. }
  1515. if(empty($user['shop'])){
  1516. exit(json_encode(array('code' => 0, 'msg' => '该账号没有所属店铺excel导出权限')));
  1517. }
  1518. $excelshop = explode('|', trim($user['shop'], '|'));
  1519. }else{
  1520. exit(json_encode(array('code' => 0, 'msg' => '请先登录')));
  1521. }
  1522. $classid = $this->classid->sku();
  1523. $post = $this->input->post(NULL, TRUE);
  1524. $timetk = strtotime($post['timetk']);
  1525. $timetj = strtotime($post['timetj']);
  1526. $where = $post['time']." > ".$timetk." and ".$post['time']." < ".$timetj." ";
  1527. if(!empty($post['warehouse'])){
  1528. $where .= " and type = ".$post['warehouse']." ";
  1529. }
  1530. if(!empty($post['shop'])){
  1531. $where .= " and shop = ".$post['shop']." ";
  1532. }else{
  1533. $where .= " and shop in (".implode(',',$excelshop).") ";
  1534. }
  1535. if(!empty($post['category'])){
  1536. $where .=" and fpdata like '%-".$post['category']."-%' ";
  1537. }
  1538. if(!empty($post['color'])){
  1539. $where .=" and fpdata like '%-".$post['color']."-%' ";
  1540. }
  1541. if(!empty($post['size'])){
  1542. $where .=" and fpdata like '%-".$post['size']."-%' ";
  1543. }
  1544. if(!empty($post['grade'])){
  1545. $where .=" and fpdata like '%-".$post['grade']."-%' ";
  1546. }
  1547. if(!empty($post['lowe'])){
  1548. $where .=" and fpdata like '%-".$post['lowe']."-%' ";
  1549. }
  1550. if(!empty($post['density'])){
  1551. $where .=" and fpdata like '%-".$post['density']."-%' ";
  1552. }
  1553. if(!empty($post['lacetype'])){
  1554. $where .=" and fpdata like '%-".$post['lacetype']."-%' ";
  1555. }
  1556. $filed_list = "fpdata,number,whlabel,type";
  1557. $data_dlz = $this->db->from('fullorder')->where($where)->select($filed_list)->order_by('id desc')->get()->result_array();
  1558. $data_smt = $this->db->from('fullordersmt')->where($where." and shop != '9'")->select($filed_list)->order_by('id desc')->get()->result_array();
  1559. $data_tt = $this->db->from('fullordertt')->where($where)->select($filed_list)->order_by('id desc')->get()->result_array();
  1560. $data_amz = $this->db->from('fullorderamz')->where($where)->select($filed_list)->order_by('id desc')->get()->result_array();
  1561. $data = $data_dlz + $data_smt + $data_tt + $data_amz;
  1562. if(empty($data)){
  1563. exit(json_encode(array('code' => 0, 'msg' => '暂无数据')));
  1564. }
  1565. if(count($data) >= 65535){
  1566. exit(json_encode(array('code' => 0, 'msg' => '数据量超过65535条,请缩小查询范围')));
  1567. }
  1568. $warehouses = $this->warehouse->find_all('1=1', 'id,title');
  1569. $warehouses = array_column($warehouses, 'title', 'id');
  1570. $sp = [];
  1571. foreach ($data as $val) {
  1572. $f = explode(';', trim($val['fpdata'], ';'));
  1573. $w = explode('|', trim($val['whlabel'], '|'));
  1574. foreach ($f as $k => $v) {
  1575. if(!empty($post['category'])){
  1576. if(stripos($v,'-'.$post['category'].'-') === false){
  1577. continue;
  1578. }
  1579. }
  1580. if(!empty($post['color'])){
  1581. if(stripos($v,'-'.$post['color'].'-') === false){
  1582. continue;
  1583. }
  1584. }
  1585. if(!empty($post['lowe'])){
  1586. if(stripos($v,'-'.$post['lowe'].'-') === false){
  1587. continue;
  1588. }
  1589. }
  1590. if(!empty($post['size'])){
  1591. if(stripos($v,'-'.$post['size'].',') === false){
  1592. continue;
  1593. }
  1594. }
  1595. if(!empty($post['grade'])){
  1596. if(stripos($v,'-'.$post['grade'].'-') === false){
  1597. continue;
  1598. }
  1599. }
  1600. if(!empty($post['lacetype'])){
  1601. if(stripos($v,'-'.$post['lacetype'].'-') === false){
  1602. continue;
  1603. }
  1604. }
  1605. if(!empty($post['density'])){
  1606. if(stripos($v,'-'.$post['density'].'-') === false){
  1607. continue;
  1608. }
  1609. }
  1610. $title = explode('|', $v);
  1611. $fg = str_replace(array('-163-', '-164-', '-165-', '-166-', '-0-', '-126-', '-127-', '-128-', '-197-', '-195-'), '-', $title[0]);
  1612. $fg = explode(',', $fg);
  1613. $tmp_c = $this->getCate($title[0]);
  1614. if (isset($fg[1])) {
  1615. $fg = explode('-', trim($fg[1] . $fg[0], '-'));
  1616. } else {
  1617. $fg = [];
  1618. }
  1619. $pm = array();
  1620. foreach ($fg as $vv) {
  1621. if (isset($tc[$vv]['zh'])) {
  1622. $zh = explode('|', trim($tc[$vv]['zh'], '|'));
  1623. $pm[$tc[$vv]['classid']] = $zh[0];
  1624. }
  1625. }
  1626. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $v);
  1627. $tsk = explode('|', trim($features, '|'));
  1628. if (stripos($tsk[0], ',') !== false) {
  1629. $ftt = explode(',', $tsk[0]);
  1630. $features = explode('-', trim($ftt[1], '-'));
  1631. $features[] = $ftt[0];
  1632. } else {
  1633. $features = explode('-', trim($tsk[0], '-'));
  1634. }
  1635. $jm = $classid;
  1636. $jm = $classid;
  1637. foreach ($features as $vv) {
  1638. if ($vv != 0) {
  1639. if (!isset($typeclass[$vv])) {
  1640. continue;
  1641. }
  1642. if (isset($jm[$typeclass[$vv]['classid']])) {
  1643. if ($typeclass[$vv]['jm']) {
  1644. $jm[$typeclass[$vv]['classid']] = $typeclass[$vv]['jm'];
  1645. }
  1646. }
  1647. }
  1648. }
  1649. $jm = array_filter($jm); //去除空值
  1650. $jm = implode("-", $jm);
  1651. $zh = implode(" ", $pm);
  1652. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1653. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1654. if (isset($title[1])) {
  1655. if (isset($sp[$title[1]])) {
  1656. $sp[$title[1]]['n'] += $title[2];
  1657. if (isset($sp[$title[1]]['warehouse'][$val['type']])) {
  1658. $sp[$title[1]]['warehouse'][$val['type']] += $title[2];
  1659. } else {
  1660. $sp[$title[1]]['warehouse'][$val['type']] = $title[2];
  1661. }
  1662. //美仓
  1663. if ($val['type'] == 5) {
  1664. $sp[$title[1]]['mc'] += $title[2];
  1665. } elseif ($val['type'] == 13) { //许昌仓
  1666. $sp[$title[1]]['xcc'] += $title[2];
  1667. } elseif ($val['type'] == 16) { //定制仓
  1668. $sp[$title[1]]['dzc'] += $title[2];
  1669. } else {
  1670. $sp[$title[1]]['qtc'] += $title[2];
  1671. }
  1672. } else {
  1673. $wh = explode('-', $w[$k]);
  1674. $wsku = $this->whlabel->find_all("number = '" . $wh[0] . "' and sku != 'Preset'");
  1675. $whs = (isset($wsku[0]['sku'])) ? $wsku[0]['sku'] : '';
  1676. $sp[$title[1]] = array('t' => $title[1], 'z' => $zh, 'c' => $tmp_c, 'w' => $whs, 'j' => $jm, 'n' => isset($title[2]) ? $title[2] : "异常 ", "warehouse" => [
  1677. $val['type'] => isset($title[2])? $title[2]:" 异常",
  1678. ], "warehouse_show" => "", "xcc" => 0, "mc" => 0, "dzc" => 0, "qtc" => 0);
  1679. //美仓
  1680. if ($val['type'] == 5) {
  1681. $sp[$title[1]]['mc'] = isset($title[2])? $title[2]:" 异常";
  1682. } elseif ($val['type'] == 13) { //许昌仓
  1683. $sp[$title[1]]['xcc'] = isset($title[2])? $title[2]:" 异常";
  1684. } elseif ($val['type'] == 16) { //定制仓
  1685. $sp[$title[1]]['dzc'] = isset($title[2])? $title[2]:" 异常";
  1686. } else {
  1687. $sp[$title[1]]['qtc'] = isset($title[2])? $title[2]:" 异常";
  1688. }
  1689. }
  1690. }
  1691. }
  1692. }
  1693. foreach ($sp as $k => $v) {
  1694. unset($sp[$k]['warehouse']);
  1695. unset($sp[$k]['warehouse_show']);
  1696. }
  1697. $sp = array_values($sp);
  1698. $title = "商品统计" . date('Y-m-d H-i-s', time());
  1699. echo json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $sp,'filename'=>$title));
  1700. die;
  1701. }
  1702. public function getCate($str)
  1703. {
  1704. //就是为了匹配类型的导出的一个定义数组
  1705. $lx_list = [
  1706. "126" => "Hair Weaving - 发条",
  1707. "127" => "Closure - 发块前头",
  1708. "128" => "Wigs",
  1709. "130" => "Hair Extension - 接发",
  1710. "131" => "Gift - 礼物",
  1711. "133" => "Accessories - 配件",
  1712. "1297" => "Synthetic Wig - 化纤头套",
  1713. "1702" => "Synthetic Hair - 化纤其它",
  1714. ];
  1715. if (stripos($str, '-126-') !== false) {
  1716. $tmp_c = "Hair Weaving - 发条";
  1717. } elseif (stripos($str, '-127-') !== false) {
  1718. $tmp_c = "Closure - 发块前头";
  1719. } elseif (stripos($str, '-128-') !== false) {
  1720. $tmp_c = "Wigs";
  1721. } elseif (stripos($str, '-130-') !== false) {
  1722. $tmp_c = "Hair Extension - 接发";
  1723. } elseif (stripos($str, '-131-') !== false) {
  1724. $tmp_c = "Gift - 礼物";
  1725. } elseif (stripos($str, '-133-') !== false) {
  1726. $tmp_c = "Accessories - 配件";
  1727. } elseif (stripos($str, '-1297-') !== false) {
  1728. $tmp_c = "Synthetic Wig - 化纤头套";
  1729. } elseif (stripos($str, '-1702-') !== false) {
  1730. $tmp_c = "Synthetic Hair - 化纤其它";
  1731. } else {
  1732. $tmp_c = "其他";
  1733. }
  1734. return $tmp_c;
  1735. }
  1736. public function _setting()
  1737. {
  1738. $post = $this->input->post(NULL, TRUE);
  1739. if (isset($post['excelpass'])) {
  1740. $excelpass = $this->input->post('excelpass', true);
  1741. $exceljmnum = $this->input->post('exceljmnum', true);
  1742. $excelusernum = $this->input->post('excelusernum', true);
  1743. if ($excelpass == '') {
  1744. echo json_encode(array('msg' => '密码不能为空', 'success' => false));
  1745. exit;
  1746. }
  1747. if ($exceljmnum < 1 || $excelusernum < 1) {
  1748. echo json_encode(array('msg' => '数量不可以小于1', 'success' => false));
  1749. exit;
  1750. }
  1751. $this->setting->save(array('svalue' => $excelpass), 'excelpass');
  1752. echo json_encode(array('msg' => 'Excel加密密码修改成功', 'success' => false));
  1753. exit;
  1754. }
  1755. }
  1756. public function _sctime()
  1757. {
  1758. $post = $this->input->post(NULL, TRUE);
  1759. if (isset($post['sctime'])) {
  1760. $sctime = $this->input->post('sctime', true);
  1761. if (!is_numeric($sctime)) {
  1762. echo json_encode(array('msg' => '必须为正整数的数字!', 'success' => false));
  1763. exit;
  1764. }
  1765. $sctime = ($sctime > 0) ? $sctime * 3600 : 0;
  1766. $this->setting->save(array('svalue' => $sctime), 'sctime');
  1767. echo json_encode(array('msg' => '时差修改成功!', 'success' => false));
  1768. exit;
  1769. }
  1770. }
  1771. public function _dpay()
  1772. {
  1773. $post = $this->input->post(NULL, TRUE);
  1774. if (isset($post['pay'])) {
  1775. $pay = $this->input->post('pay', true);
  1776. $timetk = $this->input->post('timetk', true);
  1777. $timetj = $this->input->post('timetj', true);
  1778. $timetk = strtotime($timetk);
  1779. $timetj = strtotime($timetj);
  1780. $where = "shouldmoney > '0' and dtime > '$timetk' and dtime < '$timetj' and pay = '$pay'";
  1781. if (!$pay) {
  1782. echo json_encode(array('msg' => '请选择支付方式!', 'success' => false));
  1783. exit;
  1784. }
  1785. $fullorder = $this->fullorder->find_all($where);
  1786. $this->db->trans_begin();
  1787. $cs = array();
  1788. $p = $this->pay->get_typeclass($pay);
  1789. foreach ($fullorder as $v) {
  1790. $yga = $v['shouldmoney']; //金额
  1791. $ygc = $p['estimaterate']; //预估到账公式
  1792. $ifbudget = eval("return $yga*1.$ygc;");
  1793. if ($ifbudget > 0) {
  1794. $this->fullorder->save(array('budget' => $ifbudget, 'estimaterate' => $ygc), $v['id']);
  1795. }
  1796. }
  1797. if ($this->db->trans_status() === TRUE) {
  1798. $this->db->trans_commit();
  1799. echo json_encode(array('msg' => '操作成功!', 'success' => true));
  1800. exit;
  1801. } else {
  1802. $this->db->trans_rollback();
  1803. echo json_encode(array('msg' => '失败,请重试', 'success' => false));
  1804. }
  1805. }
  1806. }
  1807. public function _dpex()
  1808. {
  1809. $post = $this->input->post(NULL, TRUE);
  1810. if (isset($post['n'])) {
  1811. $number = $this->input->post('n', true);
  1812. $postdata = $this->input->post('postdata', true);
  1813. $postdata = json_decode($postdata, true);
  1814. $d = array();
  1815. foreach ($postdata as $val) {
  1816. $d[] = array(
  1817. 'Money' => 'USD', //货币单位
  1818. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1819. 'Cnname' => $val['zh'], //产品中文名
  1820. 'Enname' => $val['en'] . '*' . $val['num'], //产品英文名
  1821. 'Price' => $val['dj'] * 1, //单价
  1822. 'Weight' => $val['zl'] * 1, //重量
  1823. 'Num' => $val['num'] * 1, //数量
  1824. 'CustomsCode' => $val['hg'] //海关编码
  1825. );
  1826. }
  1827. $fullorder = $this->fullorder->get_number($number);
  1828. if (!$fullorder) {
  1829. $fullorder = $this->fullordersmt->get_number($number);
  1830. }
  1831. if (!$fullorder) {
  1832. echo json_encode(array('msg' => '没有此编号的订单!', 'success' => false));
  1833. exit;
  1834. }
  1835. $fullorder = $this->_text($fullorder);
  1836. $fullorder['number'] = $fullorder['number'] . '-' . date('s', time()); //订单号重复修改新订单好
  1837. $data = $fullorder;
  1838. $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=createOrder";
  1839. $Clientid = 'LYFZP';
  1840. $Token = 'NGkJSDx3bAxojl1YN232';
  1841. $code = array('DPEX' => array('11', 'DPEX', '1'), 'ARAMEX' => array('002', '安迈世', 0), 'FEDEX' => array('FEDEX_1CC', 'FEDEX_1CC', ';lab10_10'), 'UPS' => array('04', 'UPS', 0), 'DHL' => array('06', 'DHL', ';lab10_10'), 'FED-SN-IP' => array('07', 'FED-SN-IP', ';lab10_10'), 'WML-FEDEX-ZZ' => array('05', 'WML-FEDEX-ZZ', ';lab10_10'), 'FED-XS-F' => array('03', 'FED-XS-F', ';lab10_10'), 'CNE' => array('08', '全球优先CNE', 'label10x10;0'), 'TCNE' => array('09', 'E速宝特惠', 'label10x10;0'));
  1842. $printcode = $code[$data['printcode']];
  1843. //创建并预报订单
  1844. $count = array(
  1845. 'Verify' => array(
  1846. 'Clientid' => $Clientid,
  1847. 'Token' => $Token
  1848. ),
  1849. 'OrderType' => '1', //1:快件订单 2:快递制单-非实时返回单号 3:仓储订单 4:快递制单-实时返回单号(等待时间较 长)。此方法选择 4,后续如需调用其他 方法,例如调用删除接口,其他方法 OrderType 请选择 2。
  1850. 'OrderDatas' => array(0 => array(
  1851. 'CustomerNumber' => $data['number'], //订单号
  1852. 'ChannelCode' => $printcode[0], //渠道代码
  1853. 'CountryCode' => $data['lb'], //国家二字码
  1854. 'TotalWeight' => $data['zzl'], //订单重量
  1855. 'TotalValue' => $data['zsbjz'], //申报价值
  1856. 'Number' => $data['zjs'], //件数
  1857. 'Note' => $data['number'], //备注
  1858. /**
  1859. 'Insurance' => array(//是否购买保险
  1860. 'Code' => '',//保险类型
  1861. 'Value' => '',//保险金额
  1862. ),
  1863. **/
  1864. 'FeePayData' => array( //运费支付信息
  1865. 'FeePayType' => 'PP', //支付方式 [ PP:预付,CC:到付, TP:第三方]
  1866. 'FeePayAccountNumber' => '', //支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
  1867. 'FeePayCountryCode' => '', //支付账号对应国家 支付方式为 TP 时必传
  1868. 'FeePayPostCode' => '', //支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
  1869. ),
  1870. 'TaxPayData' => array( //税金/关税支付信息 OrderType 为 [快递制单] 时必传字段
  1871. 'TaxPayType' => 'PP', //支付方式 [ PP:预付,CC:到付, TP:第三方]
  1872. 'TaxPayAccountNumber' => '', //支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
  1873. 'TaxPayCountryCode' => '', //支付账号对应国家 支付方式为 TP 时必传
  1874. 'TaxPayPostCode' => '', //支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
  1875. ),
  1876. 'Recipient' => array( //收件人信息
  1877. 'Name' => $data['name'], //姓名
  1878. 'Addres1' => $data['address'], //地址1
  1879. 'Addres2' => $data['address2'], //地址2
  1880. 'Mobile' => preg_replace('/\D/s', '', $data['phone']), //手机
  1881. 'Province' => $data['province'], //省/州
  1882. 'City' => $data['city'], //城市
  1883. 'Post' => trim($data['zipcode'], ' '), //邮编
  1884. ),
  1885. 'OrderItems' => $d
  1886. ))
  1887. /**,
  1888. 'Volumes' => array(//材积明细 (OrderType 为快递制单必传)
  1889. 'Weight' => '123123',//实重
  1890. 'Number' => '123123',//件数
  1891. 'Length' => '123123',//长
  1892. 'Width' => '123123',//宽
  1893. 'Height' => '123123',//高
  1894. ),
  1895. **/
  1896. );
  1897. $count = json_encode($count, true);
  1898. $ch = curl_init();
  1899. curl_setopt($ch, CURLOPT_URL, $url);
  1900. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1901. curl_setopt($ch, CURLOPT_HEADER, 0);
  1902. curl_setopt($ch, CURLOPT_POST, 1);
  1903. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
  1904. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('json' => $count)));
  1905. $res = curl_exec($ch);
  1906. curl_close($ch);
  1907. $res = json_decode($res, true);
  1908. if (!isset($res['returnDatas'][0]['corpBillid'])) {
  1909. echo json_encode(array('msg' => $res['returnDatas'][0]['message'], 'success' => false));
  1910. exit;
  1911. } else {
  1912. $yd = $this->get_dpex_yd($res['returnDatas'][0]['corpBillid'], $printcode[2]);
  1913. $fp = $this->get_dpex_fp($res['returnDatas'][0]['corpBillid'], $count);
  1914. if ($yd != 'c' && $fp != 'c') {
  1915. echo json_encode(array('msg' => '<p><a href="' . $fp . '" target="_blank">查看发票</a> <a href="' . $yd . '" target="_blank">查看运单</a></p>', 'success' => true));
  1916. exit;
  1917. } else {
  1918. echo json_encode(array('msg' => '获取运单失败,请重试', 'success' => false));
  1919. exit;
  1920. }
  1921. }
  1922. }
  1923. }
  1924. public function _text($fullorder)
  1925. {
  1926. /** 发票地址信息暂时无用
  1927. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1928. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1929. $fullorder['baddress'][1] = $country['ename'];
  1930. **/
  1931. //获取所用相关信息
  1932. $warehouse = $this->warehouse->read($fullorder['type']);
  1933. $country = $this->country->read($fullorder['country']); //订单国家信息
  1934. $fcountry = $this->country->read($warehouse['country']); //仓库国家信息
  1935. $warehouse['country'] = $fcountry['ename']; //仓库国家名
  1936. $warehouse['lb'] = $fcountry['lb']; //仓库国家编码
  1937. $fullorder['warehouse'] = $warehouse; //仓库数据加入订单
  1938. $fullorder['lb'] = $country['lb']; //订单国家编码加入
  1939. $fullorder['country'] = $country['ename']; //订单国家名
  1940. $fullorder['zhou'] = $country['continent']; //所属州
  1941. $express = $this->express->read($fullorder['express']);
  1942. $fullorder['express'] = $express['servicename'];
  1943. $fullorder['account'] = $express['account'];
  1944. $fullorder['printcode'] = $express['printcode'];
  1945. $fullorder['time'] = date('Y-m-d', time());
  1946. $fullorder['times'] = date('Y-m-d H:i', time());
  1947. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1948. // 修复报关编码问题
  1949. $declara_info = $this->customsdeclaration->find("ename like '%" . trim($fullorder['sbpm']) . "%' ", "*");
  1950. $sbbm = "";
  1951. if (empty($declara_info)) {
  1952. $sbbm = "";
  1953. } else {
  1954. $sbbm = $declara_info['bname'];
  1955. }
  1956. $fullorder['sbbm'] = $sbbm;
  1957. $fullorder['address'] = str_replace(array('&'), array('&#38;'), $fullorder['address']);
  1958. $fullorder['address2'] = str_replace(array('&'), array('&#38;'), $fullorder['address2']);
  1959. $fullorder['shipremarks'] = str_replace(array('<', '>', ';', ';'), array('&lt', '&gt', ';<br>', ';<br>'), $fullorder['shipremarks']);
  1960. $shop = $this->shop->read($fullorder['shop']);
  1961. $fullorder['shop'] = $shop['shopname'];
  1962. if (is_numeric($fullorder['pay'])) {
  1963. $pay = $this->typeclass->read($fullorder['pay']);
  1964. if ($pay['classid'] == '4') {
  1965. $fullorder['pay'] = $pay['title'];
  1966. }
  1967. }
  1968. if ($fullorder['printcode'] != "USPS") {
  1969. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1970. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1971. }
  1972. //增加退货单所需信息
  1973. $pt = '';
  1974. $fpdata = explode(';', trim($fullorder['fpdata'], ';'));
  1975. foreach ($fpdata as $v) {
  1976. $p = explode('|', trim($v, '|'));
  1977. $pt .= '<p>' . $p[1] . ' * ' . $p[2] . '</p>';
  1978. }
  1979. $fullorder['pt'] = $pt;
  1980. return $fullorder;
  1981. }
  1982. public function get_dpex_yd($waybill, $PrintPaper)
  1983. {
  1984. $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderLabel";
  1985. $Clientid = 'LYFZP';
  1986. $Token = 'NGkJSDx3bAxojl1YN232';
  1987. $count = array(
  1988. 'Verify' => array(
  1989. 'Clientid' => $Clientid,
  1990. 'Token' => $Token
  1991. ),
  1992. 'CorpBillidDatas' => array(0 => array('CorpBillid' => $waybill)),
  1993. 'OrderType' => "1", //1:快件订单 2:快递制单 3:仓库订单
  1994. 'PrintPaper' => $PrintPaper, //打印纸张 快递制单只固定为:label 和 A4
  1995. 'PrintContent' => "1" //打印内容 1:地址标签 2:报关单 3:配货信息 可自由组合用“,”号隔开 如:1,2,3
  1996. );
  1997. $count = json_encode($count, true);
  1998. $ch = curl_init();
  1999. curl_setopt($ch, CURLOPT_URL, $url);
  2000. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  2001. curl_setopt($ch, CURLOPT_HEADER, 0);
  2002. curl_setopt($ch, CURLOPT_POST, 1);
  2003. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
  2004. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('json' => $count)));
  2005. $res = curl_exec($ch);
  2006. curl_close($ch);
  2007. $res = json_decode($res, true);
  2008. if ($res['statusCode'] == 'success') {
  2009. return $res['url'];
  2010. } else {
  2011. return 'c';
  2012. }
  2013. }
  2014. public function get_dpex_fp($waybill)
  2015. {
  2016. $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderInvoice";
  2017. $Clientid = 'LYFZP';
  2018. $Token = 'NGkJSDx3bAxojl1YN232';
  2019. $count = array(
  2020. 'Verify' => array(
  2021. 'Clientid' => $Clientid,
  2022. 'Token' => $Token
  2023. ),
  2024. 'CorpBillidDatas' => array(0 => array('CorpBillid' => $waybill))
  2025. );
  2026. $count = json_encode($count, true);
  2027. $ch = curl_init();
  2028. curl_setopt($ch, CURLOPT_URL, $url);
  2029. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  2030. curl_setopt($ch, CURLOPT_HEADER, 0);
  2031. curl_setopt($ch, CURLOPT_POST, 1);
  2032. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
  2033. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('json' => $count)));
  2034. $res = curl_exec($ch);
  2035. curl_close($ch);
  2036. $res = json_decode($res, true);
  2037. if ($res['statusCode'] == 'success') {
  2038. return $res['url'];
  2039. } else {
  2040. return 'c';
  2041. }
  2042. }
  2043. public function _excellkh()
  2044. {
  2045. if (isset($_SESSION['api'])) {
  2046. $user = $this->user->get_api($_SESSION['api']);
  2047. $usp = $user;
  2048. $fgshop = "";
  2049. $sid = "";
  2050. $user = explode('|', trim($user['shop'], '|'));
  2051. foreach ($user as $value) {
  2052. if ($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') {
  2053. $fgshop .= " shop = " . $value . " or"; //去掉指定的店铺
  2054. }
  2055. $sid .= " id = " . $value . " or";
  2056. }
  2057. }
  2058. $post = $this->input->post(NULL, TRUE);
  2059. if (isset($_GET['time'])) {
  2060. $s = $this->input->get('shop', true);
  2061. $time = $this->input->get('time', true);
  2062. $timetk = $this->input->get('timetk', true);
  2063. $timetj = $this->input->get('timetj', true);
  2064. $timetk = strtotime($timetk);
  2065. $timetj = strtotime($timetj);
  2066. if ($s) {
  2067. $shop = $this->shop->find_all("id = '$shop'");
  2068. } else {
  2069. $shop = $this->shop->find_all("(type = 269 or type = 2768 ) and (" . rtrim($sid, 'or') . ')');
  2070. }
  2071. $d = array();
  2072. $k = $timetk - 24 * 3600; //少一天为增加选择开始天时间
  2073. $j = $timetj;
  2074. $n = ($j - $k) / (24 * 3600);
  2075. if ($n < 1) {
  2076. $n = 1;
  2077. }
  2078. for ($i = 1; $i < $n; $i++) {
  2079. $t = $j - ($n * 24 * 60 * 60) + ($i * 24 * 60 * 60);
  2080. foreach ($shop as $val) {
  2081. $data = $this->fullorder->find_all("source != 1 and $time > '$t' and $time < '" . ($t + 24 * 3600) . "' and shop = '" . $val['id'] . "'");
  2082. $dd = 0;
  2083. $m = 0;
  2084. foreach ($data as $v) {
  2085. $customer = $this->customer->get_email($v['email'], $v['shop']);
  2086. $customernum = $this->fullorder->find_count("$time < '" . ($t + 24 * 3600) . "' and email = '" . $v['email'] . "' and shop = '" . $v['shop'] . "' and extra_status = 0 ");
  2087. preg_match_all('/[0-9]/u', $v['phone'], $result);
  2088. $numphone = join('', $result[0]);
  2089. //$customerc = $this->customer->find_all("shop = '".$v['shop']."' and address = '".$v['address']."' and numphone = '".$numphone."'",'*','id desc');
  2090. if ($customer) {
  2091. if ($customernum > 1) // || (isset($customerc[0]['num']) && $customerc[0]['num'] > 1) // || $customerc['type'] == 1 && $customerc['num'] > 1
  2092. {
  2093. $dd++;
  2094. $m += $v['shouldmoney'];
  2095. }
  2096. }
  2097. }
  2098. $ddzb = ($dd == 0 || count($data) == 0) ? 0 : sprintf("%01.2f", $dd / count($data) * 100) . '%';
  2099. $ddjezb = ($m == 0 || array_sum(array_column($data, 'shouldmoney')) == 0) ? 0 : sprintf("%01.2f", $m / array_sum(array_column($data, 'shouldmoney')) * 100) . '%';
  2100. $d[] = array(date('Y-m-d', $t), $val['shopname'], count($data), sprintf("%01.2f", array_sum(array_column($data, 'shouldmoney'))), $dd, $m, $ddzb, $ddjezb);
  2101. }
  2102. }
  2103. $title = "老客户数据统计" . date('Y-m-d H-i-s', time());
  2104. $titlename = "<table border=1>
  2105. <tr>
  2106. <td>时间</td>
  2107. <td>店铺</td>
  2108. <td>订单数</td>
  2109. <td>订单金额 </td>
  2110. <td>老客户订单数</td>
  2111. <td>老客户订单金额</td>
  2112. <td>老客户订单数占比</td>
  2113. <td>老客户订单金额占比</td>
  2114. </tr>
  2115. </table>";
  2116. $filename = $title . ".xls";
  2117. $tail = "\n";
  2118. $this->excel->get_fz2($d, $titlename, $filename, $tail);
  2119. }
  2120. }
  2121. public function _excelshop()
  2122. {
  2123. if (isset($_SESSION['api'])) {
  2124. $user = $this->user->get_api($_SESSION['api']);
  2125. $usp = $user;
  2126. $fgshop = "";
  2127. $sid = "";
  2128. $user = explode('|', trim($user['shop'], '|'));
  2129. foreach ($user as $value) {
  2130. if ($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') {
  2131. $fgshop .= " shop = " . $value . " or"; //去掉指定的店铺
  2132. }
  2133. $sid .= " id = " . $value . " or";
  2134. }
  2135. }
  2136. $post = $this->input->post(NULL, TRUE);
  2137. if (isset($_GET['time'])) {
  2138. $s = $this->input->get('shop', true);
  2139. $time = $this->input->get('time', true);
  2140. $timetk = $this->input->get('timetk', true);
  2141. $timetj = $this->input->get('timetj', true);
  2142. $timetk = strtotime($timetk);
  2143. $timetj = strtotime($timetj);
  2144. if ($s) {
  2145. $shop = $this->shop->find_all("id = '$shop'");
  2146. } else {
  2147. $shop = $this->shop->find_all("(type = 269 or type = 2768 ) and (" . rtrim($sid, 'or') . ')');
  2148. }
  2149. $d = array();
  2150. $k = $timetk - 24 * 3600; //少一天为增加选择开始天时间
  2151. $j = $timetj;
  2152. $n = ($j - $k) / (24 * 3600);
  2153. if ($n < 1) {
  2154. $n = 1;
  2155. }
  2156. for ($i = 1; $i < $n; $i++) {
  2157. $t = $j - ($n * 24 * 60 * 60) + ($i * 24 * 60 * 60);
  2158. foreach ($shop as $val) {
  2159. $data = $this->fullorder->find_all("$time > '$t' and $time < '" . ($t + 24 * 3600) . "' and shop = '" . $val['id'] . "'");
  2160. $dd = 0;
  2161. $m = 0;
  2162. $d[] = array(date('Y-m-d', $t), $val['shopname'], count($data), sprintf("%01.2f", array_sum(array_column($data, 'shouldmoney'))));
  2163. }
  2164. }
  2165. $title = "店铺数据统计" . date('Y-m-d H-i-s', time());
  2166. $titlename = "<table border=1>
  2167. <tr>
  2168. <td>时间</td>
  2169. <td>店铺</td>
  2170. <td>订单数</td>
  2171. <td>订单金额 </td>
  2172. </tr>
  2173. </table>";
  2174. $filename = $title . ".xls";
  2175. $tail = "\n";
  2176. $this->excel->get_fz2($d, $titlename, $filename, $tail);
  2177. }
  2178. }
  2179. public function _qczd()
  2180. {
  2181. $post = $this->input->post(NULL, TRUE);
  2182. if (isset($post['number'])) {
  2183. $number = $this->input->post('number', true);
  2184. if (!$number || $number == '' || $number == NULL) {
  2185. echo json_encode(array('msg' => '没有编号信息', 'success' => false));
  2186. exit;
  2187. }
  2188. $a = $this->whlabel->find_all("zd = '$number' and state = '0'");
  2189. foreach ($a as $v) {
  2190. $this->whlabel->save(array('zd' => ''), $v['id']);
  2191. }
  2192. echo json_encode(array('msg' => '清除完成!', 'success' => true));
  2193. exit;
  2194. }
  2195. }
  2196. public function _ggdd()
  2197. {
  2198. $post = $this->input->post(NULL, TRUE);
  2199. if (isset($post['number'])) {
  2200. $number = $this->input->post('number', true);
  2201. $guarantee = $this->input->post('guarantee', true);
  2202. $quantity = $this->input->post('quantity', true);
  2203. $post = array();
  2204. if ($guarantee) {
  2205. $post['guarantee'] = $guarantee;
  2206. }
  2207. if ($quantity) {
  2208. $post['quantity'] = $quantity;
  2209. }
  2210. if (!$number || $number == '' || $number == NULL) {
  2211. echo json_encode(array('msg' => '没有编号信息', 'success' => false));
  2212. exit;
  2213. }
  2214. if (!$post) {
  2215. echo json_encode(array('msg' => '没有修改信息', 'success' => false));
  2216. exit;
  2217. }
  2218. $fullorder_name = 'fullorder';
  2219. $y = $this->fullorder->get_number($number);
  2220. if (!$y) {
  2221. $fullorder_name = 'fullordersmt';
  2222. $y = $this->fullordersmt->get_number($number);
  2223. if (!$y) {
  2224. $fullorder_name = 'fullordertt';
  2225. $y = $this->fullordertt->get_number($number);
  2226. if (!$y) {
  2227. echo json_encode(array('msg' => '无此编号数据', 'success' => false));
  2228. exit;
  2229. }
  2230. }
  2231. }
  2232. $this->$fullorder_name->save($post, $y['id']);
  2233. echo json_encode(array('msg' => '修改完成!', 'success' => true));
  2234. exit;
  2235. }
  2236. }
  2237. public function _dycs(){
  2238. $post = $this->input->post(NULL, TRUE);
  2239. if(empty($post['number'])){
  2240. echo json_encode(array('msg' => '订单编码不能为空', 'success' => false));
  2241. exit;
  2242. }
  2243. if(empty($post['dycs'])){
  2244. echo json_encode(array('msg' => '打印次数不能为空', 'success' => false));
  2245. exit;
  2246. }
  2247. $dycs = $post['dycs']*1;
  2248. if($dycs >= 10){
  2249. echo json_encode(array('msg' => '打印次数超过10次,请联系技术处理', 'success' => false));
  2250. exit;
  2251. }
  2252. $info = $this->logic_order->getInfo("number = '{$post['number']}'","*");
  2253. if(empty($info)){
  2254. echo json_encode(array('msg' => '请核对订单编码是否正确', 'success' => false));
  2255. exit;
  2256. }
  2257. if($info['printnumber']*1 >= $dycs){
  2258. echo json_encode(array('msg' => '打印次数不能小于真实的打印次数', 'success' => false));
  2259. exit;
  2260. }
  2261. $table = $info['lv_platform'];
  2262. $this->$table->save(array('printnumber' => $dycs), $info['id']);
  2263. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2264. exit;
  2265. }
  2266. public function _yxDPDchuku(){
  2267. $params = $this->input->post(NULL, TRUE);
  2268. if(empty($params['order'])){
  2269. $params = $this->input->get(NULL, TRUE);
  2270. }
  2271. if(empty($params['order'])){
  2272. echo json_encode(array('msg' => '请填写运单号', 'success' => false));
  2273. exit;
  2274. }
  2275. $y = $this->logic_order->getInfo("waybill = '".$params['order']."'","*");
  2276. if(empty($y)){
  2277. echo json_encode(array('msg' => '请核对运单号是否正确', 'success' => false));
  2278. exit;
  2279. }
  2280. if(!in_array($y['express'],[78,79,84])){
  2281. echo json_encode(array('msg' => '非DPD快递不支持此操作', 'success' => false));
  2282. exit;
  2283. }
  2284. $this->check->allowOverdue($y['name'],$y['number'],$y['address']);
  2285. echo json_encode(array('msg' => '已成功提交', 'success' => true));
  2286. exit;
  2287. }
  2288. }