Boss.php 87 KB

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