Boss.php 71 KB

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