Boss.php 87 KB

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