Boss.php 70 KB

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