Boss.php 71 KB

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