<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class goods_uqcms extends control { function __construct() { $this->aid = $_SESSION['admin']['aid']; parent::__construct(); } function index() { $uq0 = $this->db->get_all("select * from ".table('category')); if($uq0){ foreach($uq0 as $uq1=>$uq2){ $uq3[$uq2['cid']] = $uq2['name']; } } $uq4 = isset($_GET['key'])?$_GET['key']:''; $uq5 = isset($_GET['status'])?$_GET['status']:''; $uq6 = ''; if($uq5){ $uq6 = ' status = '.$uq5.' '; }elseif($uq5 == '0'){ $uq6 = ' status = 0 '; } if($uq4){ $uq6 = " title like '%".$uq4."%'"; } if(!empty($uq6)){ $uq6 = ' where '.rtrim($uq6,' and '); } $uq7 = $this->db->get_all("select * from ".table('goods').$uq6." order by id desc ".$this->limit()); if($uq7){ foreach($uq7 as $uq2){ $uq8[] = $uq2['shop_id']; } $uq9 = implode(',',$uq8); $uq10 = $this->db->get_all("select id,name from ".table('shop')." where id in (".$uq9.")"); foreach($uq10 as $uq2){ $uq11[$uq2['id']] = $uq2; } foreach($uq7 as $uq2){ if(isset($uq3[$uq2['cid']])){ $uq2['cats_cn'] = $uq3[$uq2['cid']]; } $uq2['shop_name'] = $uq11[$uq2['shop_id']]['name']; $uq2['addtime'] = _date($uq2['addtime']); $uq12[] = $uq2; } $uq13['list'] = $uq12; $uq13['page'] = $this->page('goods', $uq6); $this->assign('data',$uq13); } $this->display(); } function del() { $uq14 = P('id', '提交错误'); if($uq14){ $this->db->autocommit(); $d1 = $this->db->delete(table('goods'), 'id in('.$uq14.')'); $d2 = $this->db->delete(table('goods_img'), 'gid in ('.$uq14.')'); $d3 = $this->db->delete(table('goods_comment'), 'gid in ('.$uq14.')'); $d3 = $this->db->delete(table('goods_comment_img'), 'gid in ('.$uq14.')'); $d4 = $this->db->delete(table('goods_consult'), 'gid in ('.$uq14.')'); $d5 = $this->db->delete(table('goods_attr_index'), 'gid in ('.$uq14.')'); $d6 = $this->db->delete(table('goods_sku_img'), 'gid in ('.$uq14.')'); $d7 = $this->db->delete(table('goods_sku_index'), 'gid in ('.$uq14.')'); if($d1 && $d2 && $d3 && $d4 && $d5 && $d6 && $d7){ $this->db->commit(); right_json(); }else{ $this->db->rollback(); error_json('删除失败'); } } } function status() { $uq14 = $_GET['id']??error_json('提交错误'); $uq16 = $this->db->get_one("select id,status from ".table('goods')." where id = ".$uq14); if($uq16['id'] && ($uq16['status'] == '1')){ $uq17 = $this->db->update(table('goods'), ['status'=>'0'], 'id = '.$uq14); }elseif($uq16['id'] && ($uq16['status'] == '0')){ $uq17 = $this->db->update(table('goods'), ['status'=>'1'], 'id = '.$uq14); } if($uq17){ right_json(); }else{ error_json('设置失败'); } } public function px_status() { $uq14 = P('id', '提交编号错误'); $uq18 = $_POST['type']; $this->db->query("update ".table('goods')." set $uq18 = ($uq18 + 1)%2 where id = $uq14 limit 1"); $uq16 = $this->db->get_one("select * from ".table('goods')." where id = {$uq14}"); echo $uq16[$uq18]; } public function key_hot() { $uq6 = ''; $uq19 = $this->db->get_all("select * from ".table('keyword')." order by id desc ".$this->limit()); if($uq19){ foreach($uq19 as $uq2){ $uq2['keyword'] = html_in($uq2['keyword']); $uq2['addtime'] = _date($uq2['addtime']); $uq12[] = $uq2; } $uq13['list'] = $uq12; $uq13['page'] = $this->page('keyword', $uq6); $this->assign('data',$uq13); } $this->display(); } function key_hot_edit() { $uq14 = !empty($_GET['id'])?$_GET['id']:false; if($uq14){ $uq16 = $this->db->get_one("select * from ".table('keyword')." where id = ".$uq14); if($uq16['id']){ $this->assign('row', $uq16); } } $this->display('goods/key_hot_edit'); } function key_hot_save() { if($_POST){ $uq20['keyword'] = P('keyword', '关键字不能为空'); $uq20['px'] = P('px', '', '0'); $uq14 = P('id', 0); if($uq14){ $uq17 = $this->db->update(table('keyword'), $uq20, 'id = '.$uq14); }else{ $uq20['addtime'] = time(); $uq17 = $this->db->add(table('keyword'), $uq20); } if($uq17){ right_json(); }else{ error_json('保存失败'); } }else{ error_json('提交错误'); } } public function key_del() { $uq21 = isset($_POST['id'])?$_POST['id']:error_json('没有传递参数'); $uq17 = $this->db->delete(table('keyword'), 'id in('.$uq21.');'); if($uq17){ right_json(); }else{ error_json('删除失败'); } } public function key_hot_status() { $uq14 = isset($_POST['id'])?$_POST['id']:exit('error'); $uq18 = $_POST['type']; $this->db->query("update ".table('keyword')." set $uq18 = ($uq18 + 1)%2 where id = $uq14 limit 1"); $uq16 = $this->db->get_one("select id,keyword,hot from ".table('keyword')." where id = {$uq14}"); echo $uq16[$uq18]; } public function key_px_update() { $uq14 = P('id', '编号错误'); $uq22 = P('px', '排序编号错误'); $uq17 = $this->db->update(table('keyword'), ['px'=>$uq22], 'id = '.$uq14); if($uq17){ right_json(); }else{ error_json('更新错误'); } } } 