Boss.php 87 KB

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