Boss.php 87 KB

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