Commit 9af803c8 by 冷斌

fix bug

parent 330e6275
......@@ -52,18 +52,41 @@ class OtherController extends AdminController
$where['pid']=0;
$where['level']=1;
$list=$area->where($where)->select();
$cid = $pid = 0;
$dredge = $dArea = [];
if (isset($_GET['id'])) {
$dredge=M('dredge')->where('id='.$_GET['id'])->find();
$area=M('area');
$where['id']=$dredge['city'];
$areaSelf=$area->where(['id' => $dredge['city']])->find();
$areaParent = $area->where(['id' => $areaSelf['pid']])->find();
$cid = $areaSelf['id'];
$pid = $areaParent['id'];
$dArea = $area->where(['pid' => $pid])->select();
}
$this->assign('cid', $cid);
$this->assign('pid', $pid);
$this->assign('dredge', $dredge);
$this->assign('meta_title','添加城市');
$this->assign('province',$list);
$this->assign('dArea',$dArea);
$this->display();
}elseif(IS_POST){
$rows=I('post.');
$dredge=M('dredge');
if($dredge->where('city='.$_POST['city'])->find()){$this->error('城市已存在!');die;}//城市已存在就返回
// if($dredge->where('city='.$_POST['city'])->find()){$this->error('城市已存在!');die;}//城市已存在就返回
$dd = $dredge->where('city='.$_POST['city'])->find();
$data['city']=$rows['city'];
$data['city_name']=$rows['city_name'];
$data['meet']=$rows['meet'];
$data['reduce']=$rows['reduce'];
if (!empty($dd)) {
$data['id'] = $dd['id'];
$msg=$dredge->data($data)->save();
} else {
$msg=$dredge->data($data)->add();
}
if($msg){
$this->success('添加成功!');
}else{
......
......@@ -78,7 +78,6 @@ class ApiGoodsController extends Controller
if(I('active')){$where['active']=1;}//畅销推荐
if(I('title')){
$where['yi_goods.title']=array('like','%'.I('title').'%');
if(isset($_GET['uid'])){//如果存在用户id 则保存用户搜索词
$keyWord=M('keyword');
$keyW['s_title']=msubstr(I('title'),0,4,'utf-8',false);//只保存4位
......@@ -93,7 +92,15 @@ class ApiGoodsController extends Controller
}
}
}
}//标题搜索
}
$isVip = $isShop = 0;
if(isset($_GET['uid'])){
$user=M('user');
$user_info=$user->where('id='.$_GET['uid'])->field('is_shop,is_vip')->find();
$isVip = $user_info['is_vip'];
$isShop = $user_info['is_shop'];
}
//标题搜索
$where['yi_goods.status']=1;
//排序搜索
$order='yi_goods.id';
......@@ -104,6 +111,18 @@ class ApiGoodsController extends Controller
//价格排序
if(I('price')){if(I('price')==1){$order='price';}else{$order='price desc';}}
if(I('repertory')){if(I('repertory')==1){$order='r_repe';}else{$order='r_repe desc';}}
// 价格查询
if ($isVip) {
$field = 'yi_goods.id gid,unit,yi_goods.title,vip_price as price, vip_price as suggest_price,goods_model,z_img,sales,sum(r_repe) repertory';
} else {
if ($isShop) {
$field = 'yi_goods.id gid,unit,yi_goods.title,suggest_price as price, suggest_price,goods_model,z_img,sales,sum(r_repe) repertory';
} else {
$field = 'yi_goods.id gid,unit,yi_goods.title,price,price as suggest_price,goods_model,z_img,sales,sum(r_repe) repertory';
}
}
//畅销榜开启缓存 时效1天
if($where['active']){
// if(S('active_list'.'_'.I('cityId'))){
......@@ -112,7 +131,8 @@ class ApiGoodsController extends Controller
$goods=M('goods');
$list=$goods
->where($where)
->field('yi_goods.id gid,unit,yi_goods.title,price,suggest_price,goods_model,z_img,sales,sum(r_repe) repertory')
// ->field('yi_goods.id gid,unit,yi_goods.title,price,suggest_price,goods_model,z_img,sales,sum(r_repe) repertory')
->field($field)
->group('yi_goods.id')
->join('yi_g_price g1 on yi_goods.id=g1.goods_id and g1.city_id='.I('cityId'))
->join('yi_auth_group ag on ag.group_city='.I('cityId'))
......@@ -132,7 +152,8 @@ class ApiGoodsController extends Controller
$goods=M('goods');
$list=$goods
->where($where)
->field('yi_goods.id gid,unit,yi_goods.title,price,suggest_price,goods_model,z_img,sales,sum(r_repe) repertory')
// ->field('yi_goods.id gid,unit,yi_goods.title,price,suggest_price,goods_model,z_img,sales,sum(r_repe) repertory')
->field($field)
->group('yi_goods.id')
->join('yi_g_price g1 on yi_goods.id=g1.goods_id and g1.city_id='.I('cityId'))
->join('yi_auth_group ag on ag.group_city='.I('cityId'))
......@@ -153,12 +174,32 @@ class ApiGoodsController extends Controller
//传入城市id
if(!I('cityId')){echo json(401,'开通城市id=null','error');die;}
$isVip = $isShop = 0;
if(isset($_GET['uid'])){
$user=M('user');
$user_info=$user->where('id='.$_GET['uid'])->field('is_shop,is_vip')->find();
$isVip = $user_info['is_vip'];
$isShop = $user_info['is_shop'];
}
// 价格查询
if ($isVip) {
$field = 'yi_goods.id,z_img,unit,s_img,title,vip_price as price,vip_price as suggest_price,goods_model,sales,details,parameter,favorable,meet,reduce,explain,stan,quota,k_quota,dist_quota';
} else {
if ($isShop) {
$field = 'yi_goods.id,z_img,unit,s_img,title,suggest_price as price,suggest_price,goods_model,sales,details,parameter,favorable,meet,reduce,explain,stan,quota,k_quota,dist_quota';
} else {
$field = 'yi_goods.id,z_img,unit,s_img,title,price,price as suggest_price,goods_model,sales,details,parameter,favorable,meet,reduce,explain,stan,quota,k_quota,dist_quota';
}
}
// if(S('goodsR'.I('id').'_'.I('cityId'))){
// $rows=S('goodsR'.I('id').'_'.I('cityId'));
// }else{
$goods=M('goods');
$rows=$goods->where('yi_goods.id='.I('id'))
->field('yi_goods.id,z_img,unit,s_img,title,price,suggest_price,goods_model,sales,details,parameter,favorable,meet,reduce,explain,stan,quota,k_quota,dist_quota')
// ->field('yi_goods.id,z_img,unit,s_img,title,price,suggest_price,goods_model,sales,details,parameter,favorable,meet,reduce,explain,stan,quota,k_quota,dist_quota')
->field($field)
->join('yi_g_price g1 on yi_goods.id=g1.goods_id and g1.city_id='.I('cityId'))
->find();
$auth=M('authGroup');
......
......@@ -177,13 +177,13 @@ class ApiIndentController extends Controller
if(!isset($_GET['gid'])||empty($_GET['gid'])){echo json2(403,'商品ID=NULL','error');die;}
if(!isset($_GET['uid'])||empty($_GET['uid'])){echo json2(404,'用户id=NULL','error');die;}
$user=M('user');//判断用户是否是认证用户
$userInfo=$user->where('id='.$_GET['uid'])->field('is_shop')->find();
$userInfo=$user->where('id='.$_GET['uid'])->field('is_shop, is_vip')->find();
$goods=M('goods');
if(isset($_GET['sum'])||!empty($_GET['sum'])){//存在商品数量执行快速购买
$list1=$goods->where('yi_goods.id='.$_GET['gid'])
->field('yi_goods.id,title,z_img,goods_model,price,suggest_price,favorable,meet,reduce,quota,k_quota,dist_quota')
->field('yi_goods.id,title,z_img,goods_model,price,suggest_price, vip_price, favorable,meet,reduce,quota,k_quota,dist_quota')
->join('yi_g_price gp on gp.city_id='.$_GET['cityId'].' and goods_id='.$_GET['gid'])
->find();
if($list1){
......@@ -191,11 +191,16 @@ class ApiIndentController extends Controller
if(isset($_GET['stan'])||!empty($_GET['stan'])){
$list1['stan']=$_GET['stan'];
}
if ($userInfo['is_vip'] == 1) {
$list1['z_price']=$list1['vip_price']*$list1['sum'];
$list1['price']=$list1['vip_price'];
} else {
if($userInfo['is_shop']==1){//认证用户
$list1['z_price']=$list1['price']*$list1['sum'];
}else{//普通用户 计算总价
$list1['z_price']=$list1['suggest_price']*$list1['sum'];
$list1['price']=$list1['suggest_price'];
}else{//普通用户 计算总价
$list1['z_price']=$list1['price']*$list1['sum'];
}
}
if($list1['favorable']==0){
$list1['explain']='0';
......@@ -206,6 +211,8 @@ class ApiIndentController extends Controller
$mo=floor($list1['sum']/$list1['meet']);
$list1['explain']=$list1['reduce']*$mo;
}
unset($list1['suggest_price']);//去除推荐价格
unset($list1['meet']);
unset($list1['reduce']);
......@@ -221,18 +228,28 @@ class ApiIndentController extends Controller
->find();*/
$shop_cart=M('shop_cart');
$rows=$shop_cart->where('yi_shop_cart.id='.$gid)
->field('yi_goods.id,title,z_img,goods_model,price,suggest_price,favorable,meet,reduce,sum,yi_shop_cart.stan,quota,k_quota,dist_quota')
->field('yi_goods.id,title,z_img,goods_model,price,suggest_price,vip_price,favorable,meet,reduce,sum,yi_shop_cart.stan,quota,k_quota,dist_quota')
->join('yi_goods on yi_goods.id=yi_shop_cart.gid')
->join('yi_g_price gp on gp.city_id='.$_GET['cityId'].' and goods_id=yi_shop_cart.gid')
->find();
if($rows){
// if($userInfo['is_shop']==1){//认证用户
// $rows['z_price']=$rows['price']*$rows['sum'];
// }else{//普通用户 计算总价
// $rows['z_price']=$rows['suggest_price']*$rows['sum'];
// $rows['price']=$rows['suggest_price'];//普通用户推荐价格成为实际价格
// }
if ($userInfo['is_vip'] == 1) {
$rows['z_price']=$rows['vip_price']*$rows['sum'];
$rows['price']=$rows['vip_price'];
} else {
if($userInfo['is_shop']==1){//认证用户
$rows['z_price']=$rows['price']*$rows['sum'];
}else{//普通用户 计算总价
$rows['z_price']=$rows['suggest_price']*$rows['sum'];
$rows['price']=$rows['suggest_price'];//普通用户推荐价格成为实际价格
$rows['price']=$rows['suggest_price'];
}else{//普通用户 计算总价
$rows['z_price']=$rows['price']*$rows['sum'];
}
}
if($rows['favorable']==0){
$rows['explain']=0;
}elseif($rows['favorable']==2){//满就减
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment