Goodimglibrary.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Goodimglibrary extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_goodimgs','goodimgs');
  7. $this->load->_model('Model_goods','goods');
  8. $this->load->_model('Model_logic_order','logic_order');
  9. $this->load->_model("Model_logic_zhlp","logic_zhlp");
  10. $this->load->_model("Model_classid","classid");
  11. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  12. $this->load->_model("Model_typeclass","typeclass");
  13. $this->load->_model("Model_settingtest","settingtest");
  14. $this->load->_model("Model_apiyyv1","apiyyv1");
  15. }
  16. private $show_url = "https://lyerposs.wepolicy.cn";
  17. public function _remap($arg,$arg_array)
  18. {
  19. if($arg=="detail"){
  20. //$this->_detial($arg_array);
  21. }elseif($arg=="edit"){
  22. $this->_editData($arg_array);
  23. }elseif($arg == "get_info_number"){
  24. $this->_getInfoNumber();
  25. }elseif($arg == 'showsku'){
  26. $this->_showSku($arg_array);
  27. }elseif($arg == 'bcedit'){
  28. $this->_bcedit($arg_array);
  29. }elseif($arg == 'indexnoimg'){
  30. $this->_indexnoimg();
  31. }elseif($arg == 'add'){
  32. $this->_add();
  33. }else{
  34. $this->_index();
  35. }
  36. }
  37. private function _index(){
  38. if($this->input->method() == 'post'){
  39. $page = $this->input->post('page',true);
  40. $perpage = $this->input->post('perpage',true);
  41. $title = $this->input->post('title',true);
  42. $zh= $this->input->post('zh',true);
  43. $sku = $this->input->post('sku',true);
  44. $category = $this->input->post('category',true);
  45. $category = trim($category);
  46. $grade = $this->input->post('grade',true);
  47. $grade = trim($grade);
  48. $color = $this->input->post('color',true);
  49. $color = trim($color);
  50. $lowe = $this->input->post('lowe',true);
  51. $lowe = trim($lowe);
  52. $lacetype = $this->input->post('lacetype',true);
  53. $lacetype = trim($lacetype);
  54. $lacecolor = $this->input->post('lacecolor',true);
  55. $lacecolor = trim($lacecolor);
  56. $size = $this->input->post('size',true);
  57. $size = trim($size);
  58. $density = $this->input->post('density',true);
  59. $density = trim($density);
  60. $haircap = $this->input->post('haircap',true);
  61. $haircap = trim($haircap);
  62. $hairnumber = $this->input->post('hairnumber',true);
  63. $hairnumber = trim($hairnumber);
  64. if(empty($page))
  65. {
  66. $start = 0;
  67. $perpage = 1;
  68. }
  69. else
  70. {
  71. $start = ($page - 1)*$perpage;
  72. }
  73. $this->db->select('g.id, g.features, g.title, g.sku, g.zh, g.jm,g.has_source,g.update_time, gi.id as img_id, gi.source_cont');
  74. $this->db->from('crowd_goods as g');
  75. $this->db->join('crowd_goodimgs as gi', 'g.id = gi.goods_id', 'left');
  76. if($title){
  77. $title = trim($title);
  78. $this->db->like('g.title', $title);
  79. }
  80. if($zh){
  81. $zh = trim($zh);
  82. $this->db->like('g.zh', $zh);
  83. }
  84. if($sku){
  85. $sku = trim($sku);
  86. $this->db->like('g.sku', $sku);
  87. }
  88. if($category){
  89. $category = trim($category);
  90. $this->db->like('g.features', $category);
  91. }
  92. if($grade){
  93. $grade = trim($grade);
  94. $this->db->like('g.features', $grade);
  95. }
  96. if($color){
  97. $color = trim($color);
  98. $this->db->like('g.features', $color);
  99. }
  100. if($lowe){
  101. $lowe = trim($lowe);
  102. $this->db->like('g.features', $lowe);
  103. }
  104. if($lacetype){
  105. $lacetype = trim($lacetype);
  106. $this->db->like('g.features', $lacetype);
  107. }
  108. if($lacecolor){
  109. $lacecolor = trim($lacecolor);
  110. $this->db->like('g.features', $lacecolor);
  111. }
  112. if($size){
  113. $size = trim($size);
  114. $this->db->like('g.features', $size);
  115. }
  116. if($density){
  117. $density = trim($density);
  118. $this->db->like('g.features', $density);
  119. }
  120. if($haircap){
  121. $haircap = trim($haircap);
  122. $this->db->like('g.features', $haircap);
  123. }
  124. if($hairnumber){
  125. $hairnumber = trim($hairnumber);
  126. $this->db->like('g.features', $hairnumber);
  127. }
  128. $this->db->order_by('g.has_source', 'desc');
  129. $this->db->order_by('g.update_time', 'desc');
  130. $this->db->order_by('g.id', 'asc');
  131. // 分页 (limit, offset)
  132. $this->db->limit($perpage, $start);
  133. $query = $this->db->get();
  134. $list = $query->result_array();
  135. $info_list = [];
  136. foreach($list as $k => $v){
  137. $info_list[$k]['id'] = $v['id'];
  138. $info_list[$k]['sku'] = $v['sku'];
  139. $info_list[$k]['title'] = $v['title'];
  140. $info_list[$k]['zh'] = $v['zh'];
  141. $info_list[$k]['update_time'] = empty($v['update_time'])? '' : date('Y-m-d H:i',$v['update_time']);
  142. $info_list[$k]['imgs'] = $this->transimg($v['source_cont']);
  143. }
  144. $this->db->from('crowd_goods');
  145. if($title){
  146. $title = trim($title);
  147. $this->db->like('title', $title);
  148. }
  149. if($zh){
  150. $zh = trim($zh);
  151. $this->db->like('zh', $zh);
  152. }
  153. if($sku){
  154. $sku = trim($sku);
  155. $this->db->like('sku', $sku);
  156. }
  157. if($category){
  158. $category = trim($category);
  159. $this->db->like('features', $category);
  160. }
  161. if($grade){
  162. $grade = trim($grade);
  163. $this->db->like('features', $grade);
  164. }
  165. if($color){
  166. $color = trim($color);
  167. $this->db->like('features', $color);
  168. }
  169. if($lowe){
  170. $lowe = trim($lowe);
  171. $this->db->like('features', $lowe);
  172. }
  173. if($lacetype){
  174. $lacetype = trim($lacetype);
  175. $this->db->like('features', $lacetype);
  176. }
  177. if($lacecolor){
  178. $lacecolor = trim($lacecolor);
  179. $this->db->like('features', $lacecolor);
  180. }
  181. if($size){
  182. $size = trim($size);
  183. $this->db->like('features', $size);
  184. }
  185. if($density){
  186. $density = trim($density);
  187. $this->db->like('features', $density);
  188. }
  189. if($haircap){
  190. $haircap = trim($haircap);
  191. $this->db->like('features', $haircap);
  192. }
  193. if($hairnumber){
  194. $hairnumber = trim($hairnumber);
  195. $this->db->like('features', $hairnumber);
  196. }
  197. $total = $this->db->count_all_results();
  198. $pagenum = ceil($total/$perpage);
  199. $over = $total-($start+$perpage);
  200. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  201. echo json_encode($rows);exit;
  202. }else{
  203. $this->_Template('goodimglibrary',$this->data);
  204. }
  205. }
  206. private function _add(){
  207. if($this->input->method() == 'post'){
  208. $post = $this->input->post(null,true);
  209. if(empty($post['category'])){
  210. echo json_encode(['success' => false,'msg' => '请选择分类']);exit;
  211. }
  212. if($post['category'] != '131' && empty($post['size'])){
  213. echo json_encode(['success' => false,'msg' => '请选择尺寸']);exit;
  214. }
  215. if(isset($post['size'])){
  216. $post['size'] = trim($post['size'],",");
  217. }
  218. $typeclass = $this->logic_u9tools->getTypeClass();
  219. $classid = $this->logic_u9tools->getClass();
  220. $scsku = $classid;
  221. foreach($post as $k=>$v){
  222. if (!empty($v)) {
  223. $type_info = $this->typeclass->read($v);
  224. $scsku[$type_info['classid']] = $type_info['bqsku'];
  225. }
  226. }
  227. $scsku = implode("-", $scsku);
  228. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  229. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  230. $res = $this->logic_zhlp->sortByName($post);
  231. if($res['code'] != 1){
  232. echo json_encode(['success' => false,'msg' => $res['msg']]);exit;
  233. }
  234. if(empty($res)){
  235. echo json_encode(['success' => false,'msg' => '分类异常']);exit;
  236. }
  237. $final_list = $res['data'];
  238. $tmp_arr = array_values($final_list);
  239. $size = array_pop($tmp_arr);
  240. $sku_tmp_arr = [];
  241. foreach($tmp_arr as $k=>$v){
  242. if($k == 1 && (!isset($final_list['hairtype']))){
  243. $sku_tmp_arr[] = $v;
  244. $sku_tmp_arr[] = $size;
  245. }
  246. elseif($k == 2 && (isset($final_list['hairtype']))){
  247. $sku_tmp_arr[] = $v;
  248. $sku_tmp_arr[] = $size;
  249. }else{
  250. $sku_tmp_arr[] = $v;
  251. }
  252. }
  253. $en_title = "";
  254. foreach($post as $k=>$v){
  255. if(in_array($v,[163,164,165,166])){
  256. continue;
  257. }
  258. if(isset($typeclass[$v])){
  259. $en_title.= $typeclass[$v]['title']." ";
  260. }
  261. }
  262. $en_title = trim($en_title);
  263. $sku = "-".implode("-",$sku_tmp_arr)."-";
  264. $org_sku = implode("-",$final_list);
  265. $u9_info = $this->logic_u9tools->getOneU9bmHasGift($org_sku,$classid,$typeclass);
  266. $u9_info['title'] = $en_title;
  267. $u9_info['sku'] = $scsku;
  268. $u9_info['features'] = $sku;
  269. $u9_info['org_sku'] = $org_sku;
  270. $r = $this->goods->find("features = '".$u9_info['features']."'");
  271. if(!empty($r)){
  272. if($r['u9_check'] != 1){
  273. //查询u9是否存在
  274. $u9_jm = $this->_getU9GoodInfoByJm($r['jm']);
  275. if(empty($u9_jm)){
  276. echo json_encode(['success' => false,'msg' => $r['jm'].':未同步到u9系统,请联系管理员同步到u9系统。']);exit;
  277. }else{
  278. $this->goods->save([
  279. 'u9_check'=>1,
  280. 'jm'=>$u9_jm
  281. ],$r['id']);
  282. }
  283. }
  284. echo json_encode(['success' => false,'msg' => '商品已录入']);exit;
  285. }
  286. //u9已经创建 但是erp没创建
  287. $u9_jm = $this->_getU9GoodInfoByJm($u9_info['jm']);
  288. if(!empty($u9_jm)){
  289. $rr = $this->goods->insert([
  290. 'features'=>$u9_info['features'],
  291. 'title'=>$u9_info['title'],
  292. 'sku'=>$u9_info['sku'],
  293. 'zh'=>$u9_info['zh'],
  294. 'jm'=>$u9_jm,
  295. 'u9_check'=>1,
  296. ]);
  297. if($rr){
  298. echo json_encode(['success' => true,'msg' => '商品添加成功']);
  299. exit;
  300. }else{
  301. echo json_encode(['success' => false,'msg' => '商品添加失败']);
  302. exit;
  303. }
  304. }
  305. $info = [
  306. 'jm'=>$u9_info['jm'],
  307. 'zh'=>$u9_info['zh'],
  308. 'bm'=>$u9_info['bm'],
  309. 'ztcode'=>'001',
  310. 'title'=>$u9_info['title'],
  311. 'owner_code'=>120,
  312. ];
  313. //u9没创建 erp也没有创建
  314. $token = $this->settingtest->get_yytoken_120();
  315. $res = $this->apiyyv1->cjLpAndtbLp($info,$token);
  316. if(empty($res[0]['Data'])){
  317. echo $res[0]['ResMsg'];
  318. exit;
  319. }
  320. if(empty($res[0]['Data'][0])){
  321. echo $res[0]['ResMsg'];
  322. exit;
  323. }
  324. if(!empty($res[0]['Data'][0]['ResMsg'])){
  325. echo $res[0]['Data'][0]['ResMsg'];
  326. exit;
  327. }
  328. $token = $this->settingtest->get_yytoken_120();
  329. $res = $this->apiyyv1->tbLpNew($info,$token);
  330. $rr = $this->goods->insert([
  331. 'features'=>$u9_info['features'],
  332. 'title'=>$u9_info['title'],
  333. 'sku'=>$u9_info['sku'],
  334. 'zh'=>$u9_info['zh'],
  335. 'jm'=>$u9_info['jm'],
  336. 'u9_check'=>1,
  337. ]);
  338. if($rr){
  339. echo json_encode(['success' => true,'msg' => '商品添加成功']);
  340. exit;
  341. }else{
  342. echo json_encode(['success' => false,'msg' => '商品添加失败']);
  343. exit;
  344. }
  345. }else{
  346. $this->data['data'] = "";
  347. $this->_Template('goodimglibrary_add',$this->data);
  348. }
  349. }
  350. private function _getU9GoodInfoByJm($jm){
  351. $u9_jm = "";
  352. //查询u9是否存在
  353. $token = $this->settingtest->get_yytoken_120();
  354. $res = $this->apiyyv1->cxLpByJm($jm,$token);
  355. if(!empty($res['Data'])){
  356. if(!empty($res['Data']['0'])){
  357. if(!empty($res['Data']['0']['m_code'])){
  358. $u9_jm = $res['Data']['0']['m_code'];
  359. }
  360. }
  361. }
  362. return $u9_jm;
  363. }
  364. private function _indexnoimg(){
  365. if($this->input->method() == 'post'){
  366. $page = $this->input->post('page',true);
  367. $perpage = $this->input->post('perpage',true);
  368. $title = $this->input->post('title',true);
  369. $zh= $this->input->post('zh',true);
  370. $sku = $this->input->post('sku',true);
  371. $category = $this->input->post('category',true);
  372. $category = trim($category);
  373. $grade = $this->input->post('grade',true);
  374. $grade = trim($grade);
  375. $color = $this->input->post('color',true);
  376. $color = trim($color);
  377. $lowe = $this->input->post('lowe',true);
  378. $lowe = trim($lowe);
  379. $lacetype = $this->input->post('lacetype',true);
  380. $lacetype = trim($lacetype);
  381. $lacecolor = $this->input->post('lacecolor',true);
  382. $lacecolor = trim($lacecolor);
  383. $size = $this->input->post('size',true);
  384. $size = trim($size);
  385. $density = $this->input->post('density',true);
  386. $density = trim($density);
  387. $haircap = $this->input->post('haircap',true);
  388. $haircap = trim($haircap);
  389. $hairnumber = $this->input->post('hairnumber',true);
  390. $hairnumber = trim($hairnumber);
  391. if(empty($page))
  392. {
  393. $start = 0;
  394. $perpage = 1;
  395. }
  396. else
  397. {
  398. $start = ($page - 1)*$perpage;
  399. }
  400. $where = '1 = 1';
  401. if($title){
  402. $title = trim($title);
  403. $where .= ' AND title LIKE "%'.trim($title).'%" ';
  404. }
  405. if($zh){
  406. $zh = trim($zh);
  407. $where .= ' AND zh LIKE "%'.trim($zh).'%" ';
  408. }
  409. if($sku){
  410. $sku = trim($sku);
  411. $where .= ' AND sku LIKE "%'.trim($sku).'%" ';
  412. }
  413. if($category){
  414. $category = trim($category);
  415. $where .= ' AND features LIKE "%'.trim($category).'%" ';
  416. }
  417. if($grade){
  418. $grade = trim($grade);
  419. $where .= ' AND features LIKE "%'.trim($grade).'%" ';
  420. }
  421. if($color){
  422. $color = trim($color);
  423. $where .= ' AND features LIKE "%'.trim($color).'%" ';
  424. }
  425. if($lowe){
  426. $lowe = trim($lowe);
  427. $where .= ' AND features LIKE "%'.trim($lowe).'%" ';
  428. }
  429. if($lacetype){
  430. $lacetype = trim($lacetype);
  431. $where .= ' AND features LIKE "%'.trim($lacetype).'%" ';
  432. }
  433. if($lacecolor){
  434. $lacecolor = trim($lacecolor);
  435. $where .= ' AND features LIKE "%'.trim($lacecolor).'%" ';
  436. }
  437. if($size){
  438. $size = trim($size);
  439. $where .= ' AND features LIKE "%'.trim($size).'%" ';
  440. }
  441. if($density){
  442. $density = trim($density);
  443. $where .= ' AND features LIKE "%'.trim($density).'%" ';
  444. }
  445. if($haircap){
  446. $haircap = trim($haircap);
  447. $where .= ' AND features LIKE "%'.trim($haircap).'%" ';
  448. }
  449. if($hairnumber){
  450. $hairnumber = trim($hairnumber);
  451. $where .= ' AND features LIKE "%'.trim($hairnumber).'%" ';
  452. }
  453. $list = $this->goods->find_all($where,'id,sku,title,zh,jm,update_time','id DESC',$start,$perpage);
  454. $info_list = [];
  455. foreach($list as $k => $v){
  456. $info_list[$k]['id'] = $v['id'];
  457. $info_list[$k]['sku'] = $v['sku']." <i class='fa fa-copy' data-text='".$v['sku']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
  458. $info_list[$k]['title'] = $v['title']." <i class='fa fa-copy' data-text='".$v['title']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
  459. $info_list[$k]['zh'] = $v['zh']." <i class='fa fa-copy' data-text='".$v['zh']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
  460. $info_list[$k]['jm'] = $v['jm']." <i class='fa fa-copy' data-text='".$v['jm']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
  461. }
  462. $total = $this->goods->find_count($where);
  463. $pagenum = ceil($total/$perpage);
  464. $over = $total-($start+$perpage);
  465. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  466. echo json_encode($rows);exit;
  467. }else{
  468. $this->_Template('goodimglibrary_noimg',$this->data);
  469. }
  470. }
  471. private function transimg($source_cont){
  472. $str = ' ';
  473. if(!empty($source_cont)){
  474. $imgs = json_decode($source_cont,true);
  475. foreach($imgs as $k => $v){
  476. $type = $this->_checkVideo($v);
  477. $url = $this->_transingurl($v);
  478. if($type == "video"){
  479. $str.= '<video controls="true" width="100" src="'.$url.'" alt="video image" style="margin-right:3px;"></video>';
  480. }else{
  481. $str .= '<img width="100px" src="'.$url.'" alt="image" style="margin-right:3px;" onclick="showBigImg(this)">';
  482. }
  483. }
  484. }
  485. return $str;
  486. }
  487. private function _editData($arg_array){
  488. if($this->input->method() == 'post'){
  489. $id = $this->input->post('id',true);
  490. $img = $this->input->post('img',true);
  491. if(empty($img)){
  492. $img = [];
  493. }
  494. foreach($img as $k => $v){
  495. $img[$k] = str_replace($this->show_url, '', $v);
  496. }
  497. $info = $this->db->get_where('crowd_goods',array('id'=>$id))->row_array();
  498. $images = $this->goodimgs->find("goods_id = ".$id);
  499. $has_source = empty($img)?0:5;
  500. $update_time = time();
  501. if(empty($images)){
  502. if($this->goodimgs->insert(array('goods_id'=>$id,'features'=>$info['features'],'source_cont'=>json_encode($img,JSON_UNESCAPED_SLASHES)))){
  503. $this->goods->save(array('has_source'=>$has_source,'update_time'=>$update_time),$id);
  504. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  505. }else{
  506. echo json_encode(array('msg'=>'修改失败,请重试1','success'=>false));exit;
  507. }
  508. }else{
  509. if($this->goodimgs->save(array('features'=>$info['features'],'source_cont'=>json_encode($img,JSON_UNESCAPED_SLASHES)),$images['id'])){
  510. $this->goods->save(array('has_source'=>$has_source,'update_time'=>$update_time),$id);
  511. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  512. }else{
  513. echo json_encode(array('msg'=>'修改失败,请重试2','success'=>false));exit;
  514. }
  515. }
  516. }
  517. if($this->input->method() == 'get'){
  518. $id = $arg_array[0];
  519. $goods = $this->db->get_where('crowd_goods',array('id'=>$id))->row_array();
  520. $this->db->where('goods_id',$id);
  521. $images = $this->db->get('crowd_goodimgs')->result_array();
  522. if(empty($images)){
  523. $goods['images'] = [];
  524. }else{
  525. $imgs = json_decode($images[0]['source_cont'],true);
  526. $final_imgs = [];
  527. foreach($imgs as $k => $v){
  528. $final_imgs[$k]['url'] = $this->_transingurl($v);
  529. $final_imgs[$k]['type'] = $this->_checkVideo($v);
  530. }
  531. $goods['images'] = $final_imgs;
  532. }
  533. $this->data['goods'] = $goods;
  534. $this->_Template('goodimglibrary_edit',$this->data);
  535. }
  536. }
  537. private function _bcedit($arg_array){
  538. if($this->input->method() == 'post'){
  539. $id = $this->input->post('id',true);
  540. $img = $this->input->post('img',true);
  541. if(empty($img)){
  542. $img = [];
  543. }
  544. foreach($img as $k => $v){
  545. $img[$k] = str_replace($this->show_url, '', $v);
  546. }
  547. $info = $this->db->get_where('crowd_goods',array('id'=>$id))->row_array();
  548. $images = $this->goodimgs->find("goods_id = ".$id);
  549. $has_source = empty($img)?0:5;
  550. $update_time = time();
  551. if(empty($images)){
  552. if($this->goodimgs->insert(array('goods_id'=>$id,'features'=>$info['features'],'source_cont'=>json_encode($img,JSON_UNESCAPED_SLASHES)))){
  553. $this->goods->save(array('has_source'=>$has_source,'update_time'=>$update_time),$id);
  554. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  555. }else{
  556. echo json_encode(array('msg'=>'修改失败,请重试1','success'=>false));exit;
  557. }
  558. }else{
  559. if($this->goodimgs->save(array('features'=>$info['features'],'source_cont'=>json_encode($img,JSON_UNESCAPED_SLASHES)),$images['id'])){
  560. $this->goods->save(array('has_source'=>$has_source,'update_time'=>$update_time),$id);
  561. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  562. }else{
  563. echo json_encode(array('msg'=>'修改失败,请重试3','success'=>false));exit;
  564. }
  565. }
  566. }
  567. if($this->input->method() == 'get'){
  568. $id = $arg_array[0];
  569. $goods = $this->db->get_where('crowd_goods',array('id'=>$id))->row_array();
  570. $this->db->where('goods_id',$id);
  571. $images = $this->db->get('crowd_goodimgs')->result_array();
  572. if(empty($images)){
  573. $goods['images'] = [];
  574. }else{
  575. $imgs = json_decode($images[0]['source_cont'],true);
  576. $final_imgs = [];
  577. foreach($imgs as $k => $v){
  578. $final_imgs[$k]['url'] = $this->_transingurl($v);
  579. $final_imgs[$k]['type'] = $this->_checkVideo($v);
  580. }
  581. $goods['images'] = $final_imgs;
  582. }
  583. $this->data['goods'] = $goods;
  584. $this->_Template('goodimglibrary_bcedit',$this->data);
  585. }
  586. }
  587. //根据后缀判断是否是视频
  588. private function _checkVideo($str){
  589. $hz_arr = explode(".",$str);
  590. $hz = end($hz_arr);
  591. if(in_array($hz,['mp4','flv','rmvb','avi','wmv','mov','rm','mkv'])){
  592. return "video";
  593. }
  594. return "img";
  595. }
  596. private function _transingurl($url){
  597. $url_arr = explode('/', $url);
  598. $filename = array_pop($url_arr);
  599. $filename = rawurlencode($filename);
  600. $url_arr[] = $filename;
  601. $final_url = implode('/', $url_arr);
  602. $final_url = $this->show_url.$final_url;
  603. return $final_url;
  604. }
  605. public function _getInfoNumber(){
  606. if($this->input->method() == 'post'){
  607. $number = $this->input->post('number',true);
  608. if(empty($number)){
  609. echo json_encode(['msg'=>'请输入订单编码','success'=>false,'data'=>[]]);exit;
  610. }
  611. $info = $this->logic_order->getInfo("number = '$number'");
  612. if(empty($info)){
  613. echo json_encode(['msg'=>'订单信息不存在','success'=>false,'data'=>[]]);exit;
  614. }
  615. $fpdata = $info['fpdata'];
  616. $tmp_list = explode(';', trim($fpdata,';'));
  617. $sku_list = [];
  618. foreach($tmp_list as $k => $v){
  619. $tmp_arr = explode('|', $v);
  620. if(strpos($tmp_arr[0],',') !== false){
  621. $tmp_arr[0] =
  622. $sku_list[] = $this->logic_u9tools->getGoodFeatureAlone($tmp_arr[0]);
  623. }else{
  624. $sku_list[] = "-".trim($tmp_arr[0],"-")."-";
  625. }
  626. }
  627. $final_list = [];
  628. $classid = $this->logic_u9tools->getClass();
  629. $typeclass = $this->logic_u9tools->getTypeClass();
  630. foreach($sku_list as $k => $v){
  631. if(strpos($v,'-131-') !== false){
  632. continue;
  633. }
  634. $r = $this->logic_zhlp->transferSku(explode('-',trim($v,'-')));
  635. $rr = $this->logic_zhlp->sortByColume($r);
  636. $rrr = $this->logic_zhlp->featureTransferColumn($rr['data'],$classid);
  637. $rrrr = $this->logic_u9tools->getOneU9bmHasGift($v,$classid,$typeclass);
  638. $final_list[] = [
  639. 'jm'=>$rrrr['jm'],
  640. 'zh'=>$rrrr['zh'],
  641. 'sku'=>$rrr['sku'],
  642. 'title'=>$rrr['title'],
  643. 'zzh'=>$rrr['zh'],
  644. 'features'=>$v,
  645. ];
  646. }
  647. foreach($final_list as $k => $v){
  648. $info = $this->goods->find("features = '$v[features]'");
  649. if(!empty($info)){
  650. $final_list[$k]['s_id'] = $info['id'];
  651. }else{
  652. $id = $this->goods->insert([
  653. 'features'=>$v['features'],
  654. 'title'=>$v['title'],
  655. 'zh'=>$v['zh'],
  656. 'sku'=>$v['sku'],
  657. 'jm'=>$v['jm'],
  658. ]);
  659. $final_list[$k]['s_id'] = $id;
  660. $final_list[$k]['has_source'] = 0;
  661. }
  662. }
  663. echo json_encode(['msg'=>'订单信息获取成功','success'=>true,'data'=>$final_list]);exit;
  664. }else{
  665. $this->_Template('goodimglibrary_number',$this->data);
  666. }
  667. }
  668. private function _showSku($arg_array){
  669. echo "<pre>";
  670. print_r($arg_array);
  671. die;
  672. }
  673. }