Boss.php 71 KB

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