Boss.php 71 KB

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