Boss.php 71 KB

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