Whlabelfz.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. /**
  3. * 由于whlabel类下的代码太长了,决定以后非必要代码都放在whlabelfz类中,以便于管理。
  4. */
  5. class Whlabelfz extends Start_Controller
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->load->_model('Model_whlabel', 'whlabel');
  11. $this->load->_model('Model_warehouse', 'warehouse');
  12. $this->load->_model('Model_specialstock', 'specialstock');
  13. $this->load->_model('Model_logic_u9tools','logic_u9tools');
  14. $this->load->_model('Model_classid','classid');
  15. $this->load->_model('Model_typeclass','typeclass');
  16. $this->load->_model('Model_purchase', 'purchase');
  17. $this->load->_model("Model_shop", "shop");
  18. $this->load->_model("Model_whlabellabel","whlabellabel");
  19. $this->load->_model("Model_logic_zhlp",'logic_zhlp');
  20. }
  21. //定义方法的调用规则 获取URI第二段值
  22. public function _remap($arg, $arg_array)
  23. {
  24. if ($arg == 'bqckexcel') //
  25. {
  26. //获取标签出库的按条件导出的excel
  27. $this->_bqck_excel();
  28. }
  29. elseif ($arg == 'bqrkexcel') //
  30. {
  31. //获取标签出库的按条件导出的excel
  32. $this->_bqrk_excel();
  33. }
  34. elseif ($arg == 'whlabel_cprk_excel') //
  35. {
  36. $this->_whlabel_cprk_excel();
  37. }
  38. elseif($arg == 'bqplindex'){
  39. $this->_bqplindex();
  40. }elseif($arg == 'bqplprint'){
  41. $this->_bqplprint();
  42. }elseif($arg == 'bqpladd'){
  43. $this->_bqpladd();
  44. }
  45. else {
  46. $this->_index();
  47. }
  48. }
  49. private function _index(){
  50. die('No direct script access allowed');
  51. }
  52. private function _bqck_excel(){
  53. if (isset($_GET['excel'])) {
  54. //统计时间
  55. $timetk = $this->input->get('timetk', true);
  56. $timetj = $this->input->get('timetj', true);
  57. $timetk = strtotime($timetk);
  58. $timetj = strtotime($timetj);
  59. $category = $this->input->get('category',true); //类目
  60. $size = $this->input->get('size',true);//长度
  61. $grade = $this->input->get('grade',true);//等级
  62. $color = $this->input->get('color',true);//颜色
  63. $lowe = $this->input->get('lowe',true);//曲度
  64. $sku = $this->input->get('sku',true);//sku
  65. $warehouse = $this->input->get('warehouse',true);//仓库
  66. $purchase = $this->input->get('purchase',true);//供应商
  67. $where = "state=1 ";
  68. if ($timetk && $timetj) {
  69. $where .= " and outk > '$timetk' and outk < '$timetj'";
  70. }
  71. if ($sku) {
  72. $where .= " and sku = '$sku'";
  73. }
  74. if ($warehouse) {
  75. $where .= " and warehouse = '$warehouse'";
  76. }
  77. if ($purchase) {
  78. $where .= " and purchase = '$purchase'";
  79. }
  80. if ($category) {
  81. $where .= " and features like '%-$category-%'";
  82. }
  83. if ($size) {
  84. $where .= " and features like '%-$size-%'";
  85. }
  86. if ($grade) {
  87. $where .= " and features like '%-$grade-%'";
  88. }
  89. if ($color) {
  90. $where .= " and features like '%-$color-%'";
  91. }
  92. if ($lowe) {
  93. $where .= " and features like '%-$lowe-%'";
  94. }
  95. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  96. $order_str = "outk desc";
  97. //取得信息列表
  98. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,outk,details', $order_str);
  99. $classid = $this->classid->sku();
  100. $tcall = $this->typeclass->find_all();
  101. $typeclass = array();
  102. foreach ($tcall as $v)
  103. {
  104. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  105. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  106. }
  107. $prc = array();
  108. $purchase = $this->purchase->find_all();
  109. foreach ($purchase as $k => $v) {
  110. $prc[$v['id']] = $v['title'];
  111. }
  112. foreach ($info_list as $key => $value) {
  113. $warehouse = $this->warehouse->read($value['warehouse']);
  114. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  115. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  116. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  117. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  118. if ($value['state'] == 0) {
  119. $info_list[$key]['state'] = "在库";
  120. } else if ($value['state'] == 1) {
  121. $info_list[$key]['state'] = "出库";
  122. } else if ($value['state'] == 2) {
  123. $info_list[$key]['state'] = "退库";
  124. } else if ($value['state'] == 3) {
  125. $info_list[$key]['state'] = "调拨中";
  126. } else if ($value['state'] == 4) {
  127. $info_list[$key]['state'] = "再加工";
  128. } else if ($value['state'] == 5) {
  129. $info_list[$key]['state'] = "维修中";
  130. } else if ($value['state'] == 6) {
  131. $info_list[$key]['state'] = "盘亏";
  132. } else if ($value['state'] == 7) {
  133. $info_list[$key]['state'] = "更换标签";
  134. } else if ($value['state'] == 8) {
  135. $info_list[$key]['state'] = "其它";
  136. } else if ($value['state'] == 9) {
  137. $info_list[$key]['state'] = "预设";
  138. } else if ($value['state'] == 10) {
  139. $info_list[$key]['state'] = "美店零售";
  140. }
  141. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  142. }
  143. //生成excel
  144. $filename = date("Y-m-d")."标签出库导出.xls";
  145. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  146. <head>
  147. <!--[if gte mso 9]><xml>
  148. <x:ExcelWorkbook>
  149. <x:ExcelWorksheets>
  150. <x:ExcelWorksheet>
  151. <x:Name>EXCEL</x:Name>
  152. <x:WorksheetOptions>
  153. <x:Print>
  154. <x:ValidPrinterInfo />
  155. </x:Print>
  156. </x:WorksheetOptions>
  157. </x:ExcelWorksheet>
  158. </x:ExcelWorksheets>
  159. </x:ExcelWorkbook>
  160. </xml>
  161. <![endif]-->
  162. </head><body>";
  163. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  164. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>出库时间</td><td>所在位置</td></tr>";
  165. foreach ($info_list as $key=>$value)
  166. {
  167. $str .= "<tr>";
  168. $str .= "<td>". $value['warehouse']. "</td>";
  169. $str .= "<td>". $value['purchase']. "</td>";
  170. $str .= "<td>". $value['sku']. "</td>";
  171. $str .= "<td>". $value['title']. "</td>";
  172. $str .= "<td>". $value['features']. "</td>";
  173. $str .= "<td>". $value['state']. "</td>";
  174. $str .= "<td>". $value['outk']. "</td>";
  175. $str .= "<td>". $value['details']. "</td>";
  176. $str .= "</tr>";
  177. }
  178. $str .= "</table></body></html>";
  179. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  180. header( "Content-type: application/octet-stream" );
  181. header( "Content-Disposition: attachment; filename=".$filename );
  182. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  183. header( "Pragma: no-cache" );
  184. header( "Expires: 0" );
  185. exit($str);
  186. }else{
  187. }
  188. }
  189. public function _bqrk_excel(){
  190. if (isset($_GET['excel'])) {
  191. $sku = $this->input->get('sku', true);
  192. $bs = $this->input->get('bs', true);
  193. $number = $this->input->get('number', true);
  194. $warehouse = $this->input->get('warehouse', true);
  195. $purchase = $this->input->get('purchase', true);
  196. $orderinfo = $this->input->get('orderinfo', true);
  197. $waybill = $this->input->get('waybill', true);
  198. $category = $this->input->get('category', true);
  199. $size = $this->input->get('size', true);
  200. $grade = $this->input->get('grade', true);
  201. $color = $this->input->get('color', true);
  202. $lowe = $this->input->get('lowe', true);
  203. $state = $this->input->get('state', true);
  204. $label = $this->input->get('label', true);
  205. $timetk = $this->input->get('ktime', true);
  206. $timetj = $this->input->get('jtime', true);
  207. $timetk = strtotime($timetk);
  208. $timetj = strtotime($timetj);
  209. $where = "1=1 ";
  210. if ($timetk && $timetj) {
  211. $where .= " and enter > '$timetk' and enter < '$timetj'";
  212. }
  213. if ($sku) {
  214. $where .= " and sku = '$sku'";
  215. }
  216. if ($bs != '') {
  217. $where .= " and bs = '$bs'";
  218. }
  219. if ($number) {
  220. $where .= " and number = '$number'";
  221. }
  222. if ($warehouse) {
  223. $where .= " and warehouse = '$warehouse'";
  224. }
  225. if ($purchase) {
  226. $where .= " and purchase = '$purchase'";
  227. }
  228. if ($orderinfo) {
  229. $where .= " and orderinfo = '$orderinfo'";
  230. }
  231. if ($waybill) {
  232. $where .= " and waybill = '$waybill'";
  233. }
  234. if ($category) {
  235. $where .= " and features like '%-$category-%'";
  236. }
  237. if ($size) {
  238. $where .= " and features like '%-$size-%'";
  239. }
  240. if ($grade) {
  241. $where .= " and features like '%-$grade-%'";
  242. }
  243. if ($color) {
  244. $where .= " and features like '%-$color-%'";
  245. }
  246. if ($lowe) {
  247. $where .= " and features like '%-$lowe-%'";
  248. }
  249. if ($label) {
  250. $where .= " and label = '$label'";
  251. }
  252. if ($state || $state == 0) {
  253. $where .= " and state = '$state'";
  254. }
  255. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  256. //数据排序
  257. $order_str = "enter desc";
  258. //取得信息列表
  259. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,features,state,enter,details', $order_str);
  260. $prc = array();
  261. $purchase = $this->purchase->find_all();
  262. foreach ($purchase as $k => $v) {
  263. $prc[$v['id']] = $v['title'];
  264. }
  265. $classid = $this->classid->sku();
  266. $tcall = $this->typeclass->find_all();
  267. foreach ($tcall as $v)
  268. {
  269. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  270. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  271. }
  272. foreach ($info_list as $key => $value) {
  273. $warehouse = $this->warehouse->read($value['warehouse']);
  274. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  275. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  276. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  277. $info_list[$key]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  278. if ($value['state'] == 0) {
  279. $info_list[$key]['state'] = "在库";
  280. } else if ($value['state'] == 1) {
  281. $info_list[$key]['state'] = "出库";
  282. } else if ($value['state'] == 2) {
  283. $info_list[$key]['state'] = "退库";
  284. } else if ($value['state'] == 3) {
  285. $info_list[$key]['state'] = "调拨中";
  286. } else if ($value['state'] == 4) {
  287. $info_list[$key]['state'] = "再加工";
  288. } else if ($value['state'] == 5) {
  289. $info_list[$key]['state'] = "维修中";
  290. } else if ($value['state'] == 6) {
  291. $info_list[$key]['state'] = "盘亏";
  292. } else if ($value['state'] == 7) {
  293. $info_list[$key]['state'] = "更换标签";
  294. } else if ($value['state'] == 8) {
  295. $info_list[$key]['state'] = "其它";
  296. } else if ($value['state'] == 9) {
  297. $info_list[$key]['state'] = "预设";
  298. } else if ($value['state'] == 10) {
  299. $info_list[$key]['state'] = "美店零售";
  300. }
  301. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  302. }
  303. //生成excel
  304. $filename = date("Y-m-d")."标签入库导出.xls";
  305. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  306. <head>
  307. <!--[if gte mso 9]><xml>
  308. <x:ExcelWorkbook>
  309. <x:ExcelWorksheets>
  310. <x:ExcelWorksheet>
  311. <x:Name>EXCEL</x:Name>
  312. <x:WorksheetOptions>
  313. <x:Print>
  314. <x:ValidPrinterInfo />
  315. </x:Print>
  316. </x:WorksheetOptions>
  317. </x:ExcelWorksheet>
  318. </x:ExcelWorksheets>
  319. </x:ExcelWorkbook>
  320. </xml>
  321. <![endif]-->
  322. </head><body>";
  323. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  324. $str .= "<tr><td>仓库</td><td>供应商</td><td>SKU</td><td>名称</td><td>料号</td><td>状态</td><td>入库时间</td><td>所在位置</td></tr>";
  325. foreach ($info_list as $key=>$value)
  326. {
  327. $str .= "<tr>";
  328. $str .= "<td>". $value['warehouse']. "</td>";
  329. $str .= "<td>". $value['purchase']. "</td>";
  330. $str .= "<td>". $value['sku']. "</td>";
  331. $str .= "<td>". $value['title']. "</td>";
  332. $str .= "<td>". $value['features']. "</td>";
  333. $str .= "<td>". $value['state']. "</td>";
  334. $str .= "<td>". $value['enter']. "</td>";
  335. $str .= "<td>". $value['details']. "</td>";
  336. $str .= "</tr>";
  337. }
  338. $str .= "</table></body></html>";
  339. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  340. header( "Content-type: application/octet-stream" );
  341. header( "Content-Disposition: attachment; filename=".$filename );
  342. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  343. header( "Pragma: no-cache" );
  344. header( "Expires: 0" );
  345. exit($str);
  346. }
  347. }
  348. public function _whlabel_cprk_excel(){
  349. if (empty($_SESSION['api'])) {
  350. exit('No direct script access allowed');
  351. }
  352. // $user = $this->user->get_api($_SESSION['api']);
  353. // $warehouses = $user['warehouse'];
  354. // if(empty($warehouses)){
  355. // exit('没有仓库权限!!!');
  356. // }
  357. // $warehouses = explode('|',trim($warehouses,'|'));
  358. // $ware_list = [];
  359. // foreach ($warehouses as $v) {
  360. // if(!empty($v)){
  361. // $ware_list[] = $v;
  362. // }
  363. // }
  364. $category = $this->input->get('category', true);
  365. $size = $this->input->get('size', true);
  366. $grade = $this->input->get('grade', true);
  367. $color = $this->input->get('color', true);
  368. $lowe = $this->input->get('lowe', true);
  369. $sku = $this->input->get('sku', true);
  370. $warehouse = $this->input->get('warehouse', true);
  371. $purchase = $this->input->get('purchase', true);
  372. $ktime = $this->input->get('ktime', true);
  373. $jtime = $this->input->get('jtime', true);
  374. $ktime = strtotime($ktime);
  375. $jtime = strtotime($jtime);
  376. $where = " ";
  377. // if ($warehouse) {
  378. // if(in_array($warehouse,$ware_list)){
  379. // $where .= " warehouse = '$warehouse' ";
  380. // }else{
  381. // $where .= " warehouse = 0 ";
  382. // }
  383. // }else{
  384. // $where .= " warehouse in (".implode(',',$ware_list).")";
  385. // }
  386. if($warehouse){
  387. $where .= " warehouse = '$warehouse' ";
  388. }else{
  389. $where .=" 1 = 1 ";
  390. }
  391. if ($category) {
  392. $where .= " and features like '%-$category-%'";
  393. }
  394. if ($size) {
  395. $where .= " and features like '%-$size-%'";
  396. }
  397. if ($grade) {
  398. $where .= " and features like '%-$grade-%'";
  399. }
  400. if ($color) {
  401. $where .= " and features like '%-$color-%'";
  402. }
  403. if ($lowe) {
  404. $where .= " and features like '%-$lowe-%'";
  405. }
  406. if ($purchase) {
  407. $where .= " and purchase = '$purchase'";
  408. }
  409. if ($sku) {
  410. $where .= " and sku like '%$sku%'";
  411. }
  412. if ($ktime && $jtime) {
  413. $where .= " and enter > '$ktime' and enter < '$jtime'";
  414. }
  415. //取得信息列表
  416. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter,features');
  417. if(!empty($info_list)){
  418. $wh = array();
  419. $w = $this->warehouse->find_all('1=1', 'id,title');
  420. foreach ($w as $v) {
  421. $wh[$v['id']] = $v['title'];
  422. }
  423. $classid = $this->classid->sku();
  424. $tcall = $this->typeclass->find_all();
  425. foreach ($tcall as $v)
  426. {
  427. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  428. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  429. }
  430. foreach ($info_list as $k => $v) {
  431. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  432. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  433. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  434. $info_list[$k]['g'] = $g;
  435. if(!empty($v['features'])){
  436. $u9_info = $this->logic_u9tools->getOneU9bm($v['features'],$classid,$typeclass);
  437. $info_list[$k]['features'] = empty($u9_info['jm'])?"?**?":$u9_info['jm'];
  438. }
  439. }
  440. }
  441. //生成excel
  442. $filename = date("Y-m-d")."产品入库导出.xls";
  443. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  444. <head>
  445. <!--[if gte mso 9]><xml>
  446. <x:ExcelWorkbook>
  447. <x:ExcelWorksheets>
  448. <x:ExcelWorksheet>
  449. <x:Name>EXCEL</x:Name>
  450. <x:WorksheetOptions>
  451. <x:Print>
  452. <x:ValidPrinterInfo />
  453. </x:Print>
  454. </x:WorksheetOptions>
  455. </x:ExcelWorksheet>
  456. </x:ExcelWorksheets>
  457. </x:ExcelWorkbook>
  458. </xml>
  459. <![endif]-->
  460. </head><body>";
  461. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  462. $str .= "<tr><td>仓库</td><td>SKU</td><td>产品名称</td><td>入库时间</td><td>数量</td><td>料号</td></tr>";
  463. foreach ($info_list as $key=>$value)
  464. {
  465. $str .= "<tr>";
  466. $str .= "<td>". $value['warehouse']. "</td>";
  467. $str .= "<td>". $value['sku']. "</td>";
  468. $str .= "<td>". $value['title']. "</td>";
  469. $str .= "<td>". $value['enter']. "</td>";
  470. $str .= "<td>". $value['g']. "</td>";
  471. $str .= "<td>". $value['features']. "</td>";
  472. $str .= "</tr>";
  473. }
  474. $str .= "</table></body></html>";
  475. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  476. header( "Content-type: application/octet-stream" );
  477. header( "Content-Disposition: attachment; filename=".$filename );
  478. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  479. header( "Pragma: no-cache" );
  480. header( "Expires: 0" );
  481. exit($str);
  482. }
  483. private function _bqplindex(){
  484. if($this->input->method() == 'post'){
  485. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  486. echo json_encode($rows);exit;
  487. }
  488. $this->_Template('whlabelfz_bqpl', $this->data);
  489. }
  490. private function _getShop($str){
  491. $str = trim($str);
  492. if($str == '无'){
  493. return '';
  494. }else{
  495. $str = strtolower($str);
  496. if($str =='alipearl'){
  497. return 1;
  498. }elseif($str == 'supernova'){
  499. return 2;
  500. }elseif($str == 'asteriahair'){
  501. return 3;
  502. }elseif($str == 'westkiss'){
  503. return 4;
  504. }elseif($str == 'yolissahair'){
  505. return 5;
  506. }elseif($str == 'wiggins'){
  507. return 6;
  508. }
  509. }
  510. }
  511. private function _bqpladd(){
  512. $params = $this->input->post('data',true);
  513. $params = json_decode($params,true);
  514. $list = [];
  515. $error_list= [];
  516. $warehouse_list = $this->warehouse->find_all("1 = 1","id,title");
  517. $warehouse_list = array_column($warehouse_list,'id','title');
  518. $purchase_list = $this->purchase->find_all("1 = 1","id,title");
  519. $purchase_list = array_column($purchase_list,'id','title');
  520. $classid = $this->classid->sku();
  521. foreach($params as $k => $v){
  522. $r = $this->_transferForm($v['0'],$v,$warehouse_list,$purchase_list,$classid,$k);
  523. if($r['code'] != 1){
  524. $error_list[] = [
  525. 'sku'=>$v['0'],
  526. 'msg'=>$r['msg']
  527. ];
  528. }else{
  529. $list[] = [
  530. 'shop'=>'',
  531. ];
  532. }
  533. }
  534. }
  535. /**
  536. * 将数据转化为 批量打印标签需要data格式
  537. */
  538. private function _transferForm($tmsku,$info,$warehouse_list,$purchase_list,$classid,$i){
  539. if (is_numeric($tmsku)) {
  540. $yyh = $this->whlabellabel->get_label($tmsku);
  541. } else {
  542. $yyh = $this->whlabellabel->get_sku($tmsku);
  543. }
  544. if(!empty($yyh)){
  545. return ['code'=>1,'msg'=>"获取标签",'data'=>$yyh];
  546. }
  547. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  548. if($r['code'] == -1 ){
  549. return ['code'=>-1,'msg'=>"未找到对应的料品"];
  550. }
  551. $str = $r['data'];
  552. $arr = explode("-",trim($str,"-"));
  553. $data = $this->logic_zhlp->transferSku($arr);
  554. $res = $this->logic_zhlp->sortByColume($data);
  555. if($res['code'] == -1){
  556. return $res;
  557. }
  558. $insert_arr = [];
  559. $insert_arr['sku_master_id']= $insert_arr['sku_shop_id'] =0;
  560. $insert_arr['status'] = 0;
  561. $insert_arr['shop'] = '';
  562. $purchase = isset($purchase_list[$info['2']])?$purchase_list[$info['2']]:1;
  563. $insert_arr['purchase'] = $purchase;
  564. $warehouse = isset($warehouse_list[$info['3']])?$warehouse_list[$info['3']]:1;
  565. $insert_arr['warehouse'] = $warehouse;
  566. $insert_arr['cpbz'] = '';
  567. $post = $res['data'];
  568. $list = [];
  569. $category = $post['category'];
  570. $list['category'] = $category;
  571. $list['hairtype'] = empty($post['hairtype'])?'':$post['hairtype'];
  572. $list['grade'] = empty($post['grade'])?'':$post['grade'];
  573. $list['size'] = empty($post['size'])?'':$post['size'];
  574. $list['hairnumber'] = empty($post['hairnumber'])?'':$post['hairnumber'];
  575. $list['extension'] = empty($post['extension'])?'':$post['extension'];
  576. if ($category == 1297) {
  577. $list['sywignumber'] = empty($post['sywignumber'])?'':$post['sywignumber'];
  578. }
  579. if ($category == 1702) {
  580. $list['syhairnumber'] = empty($post['syhairnumber'])?'':$post['syhairnumber'];
  581. $list['syother'] = empty($post['syother'])?'':$post['syother'];
  582. }
  583. if ($category == 133) {
  584. $list['fittype'] = empty($post['fittype'])?'':$post['fittype'];
  585. $list['acother'] = empty($post['acother'])?'':$post['acother'];
  586. }
  587. $list['color'] = empty($post['color'])?'':$post['color'];
  588. $list['lowe'] = empty($post['lowe'])?'':$post['lowe'];
  589. if ($category == 127) {
  590. $list['type'] = empty($post['type'])?'':$post['type'];
  591. $list['headroad'] = empty($post['headroad'])?'':$post['headroad'];
  592. $list['density'] =empty($post['density'])?'':$post['density'];
  593. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  594. $list['lacesize'] = empty($post['lacesize'])?'':$post['lacesize'];
  595. }
  596. $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor'];
  597. $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes'];
  598. }
  599. if ($category == 128) {
  600. $list['lacetype'] =empty($post['lacetype'])?'':$post['lacetype'];
  601. $list['haircap'] = empty($post['haircap'])?'':$post['haircap'];
  602. $list['density'] = empty($post['density'])?'':$post['density'];
  603. $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor'];
  604. $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes'];
  605. $list['wigother'] = empty($post['wigother'])?'':$post['wigother'];
  606. $list['wigother1'] = empty($post['wigother1'])?'':$post['wigother1'];
  607. $list['wigother2'] = empty($post['wigother2'])?'':$post['wigother2'];
  608. }
  609. if ($category == 129) {
  610. $list['wide'] = empty($post['wide'])?'':$post['wide'];
  611. }
  612. if ($category == 131) {
  613. $list['gifttype'] = empty($post['gifttype'])?'':$post['gifttype'];
  614. $list['giftother'] = empty($post['giftother'])?'':$post['giftother'];
  615. }
  616. if ($category == 134) {
  617. $list['pieceweight'] = empty($post['pieceweight'])?'':$post['pieceweight'];
  618. }
  619. if ($category == 1297) {
  620. $list['synthetictype'] = empty($post['synthetictype'])?'':$post['synthetictype'];
  621. $list['sywigother'] = empty($post['sywigother'])?'':$post['sywigother'];
  622. }
  623. if ($category == 130 || $category == 133 || $category == 1702) {
  624. $list['items'] = empty($post['items'])?'':$post['items'];
  625. $list['weight'] = empty($post['weight'])?'':$post['weight'];
  626. }
  627. if ($category == 1702) {
  628. $list['syhairther'] = empty($post['syhairther'])?'':$post['syhairther'];
  629. }
  630. $pm = $scsku = $classid;
  631. $number = $features = $title = "";
  632. foreach ($list as $k => $v) {
  633. if ($v != 0) {
  634. $number .= $v;
  635. $features .= $v . '-';
  636. $typeclass = $this->typeclass->read($v);
  637. if (isset($pm[$typeclass['classid']])) {
  638. if (stripos($typeclass['zh'], '|') !== false) {
  639. $exzh = explode('|', $typeclass['zh']);
  640. $pm[$typeclass['classid']] = $exzh[0];
  641. } else {
  642. $pm[$typeclass['classid']] = $typeclass['zh'];
  643. }
  644. }
  645. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  646. if ($k != 'size') {
  647. $title .= $typeclass['title'] . " ";
  648. }
  649. }
  650. }
  651. $typeclass = $this->typeclass->read($list['size']);
  652. $title .= $typeclass['title'];
  653. $time = time();
  654. $insert_arr['title'] = rtrim($title, ' ');
  655. $insert_arr['number'] = $number;
  656. $insert_arr['features'] = rtrim($features, '-');
  657. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  658. $featurespp = explode('-', trim($featurespp, '-'));
  659. if (isset($featurespp[5])) {
  660. $insert_arr['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  661. } else {
  662. $insert_arr['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  663. }
  664. $insert_arr['time'] = $time;
  665. $insert_arr['dynum'] = $info['1'];
  666. $title = $features = "";
  667. $scsku = implode("-", $scsku);
  668. $zh = implode(" ", $pm);
  669. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  670. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  671. $bqsku = $scsku;;
  672. $insert_arr['sku'] = $bqsku;
  673. $label = time() . rand(0, 9).$i;
  674. $insert_arr['label'] = $label;
  675. echo "<pre>";
  676. print_r($post);
  677. print_r($insert_arr);
  678. die;
  679. }
  680. private function _bqplprint(){
  681. }
  682. }