...
|
...
|
@@ -20,6 +20,39 @@ class GoodsdetailsController extends WeChatBaseController{ |
|
|
public function Goods_details(){
|
|
|
|
|
|
$goods_id = $this -> request -> param();
|
|
|
$uid = cmf_get_current_user_id();
|
|
|
//判断跳转过来的链接
|
|
|
if(!empty($goods_id['status']) && !empty($goods_id['id'])){
|
|
|
$share_user = Db::name('my_user') -> where('uid',$uid) -> find();
|
|
|
//判断用户是否存在
|
|
|
if(!empty($share_user)){
|
|
|
//判断用户是不是自由人
|
|
|
if($share_user['status'] == 0){
|
|
|
//如果是自由人 那就绑定关系
|
|
|
$share_data['status'] = 4;
|
|
|
$share_data['pid'] = $goods_id['id'];
|
|
|
$share_data['bind_time'] = time();
|
|
|
$share_data['bind_status'] = 1;
|
|
|
Db::name('my_user') -> where("uid",$uid) -> update($share_data);
|
|
|
}
|
|
|
}else{
|
|
|
//用户不存在的话 如果是老师分享过来的
|
|
|
if($goods_id['status'] == 3 || $goods_id['status'] == 4){
|
|
|
//判断这个用户是否存在
|
|
|
if(empty($share_user)){
|
|
|
$share_data['status'] = 4;
|
|
|
$share_data['uid'] = $uid;
|
|
|
$share_data['create_time'] = time();
|
|
|
$share_data['is_pro'] = 0;
|
|
|
$share_data['pid'] = $goods_id['id'];
|
|
|
$share_data['bind_time'] = time();
|
|
|
$share_data['bind_status'] = 1;
|
|
|
Db::name('my_user') -> insert($share_data);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
$data = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where('a.id',$goods_id['goods_id']) -> find();
|
|
|
$this -> assign('price',$data['price']);
|
|
|
$price = explode('.',$data['price']);
|
...
|
...
|
@@ -67,7 +100,31 @@ class GoodsdetailsController extends WeChatBaseController{ |
|
|
$js = $app->js;
|
|
|
$jssdk=$js->config(array('onMenuShareAppMessage', 'onMenuShareTimeline'), false,false,true);
|
|
|
$this->assign('jssdk',$jssdk);
|
|
|
$url = "http://xkeasy.w.bronet.cn/portal/goodsdetails/goods_details/goods_id/".$goods_id['goods_id'];
|
|
|
//判断用户身份
|
|
|
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
|
|
|
//如果是业务员身份
|
|
|
if($my_user['status'] == 2 || $my_user['status'] == 0 || $my_user['status'] == 1 || $my_user['status'] == 5 || $my_user['status'] == 6){
|
|
|
$url = "http://xkeasy.w.bronet.cn/portal/goodsdetails/goods_details/goods_id/".$goods_id['goods_id'];
|
|
|
}
|
|
|
//如果是老师身份
|
|
|
if($my_user['status'] == 3){
|
|
|
if(empty($goods_id['id'])){
|
|
|
$url = "http://xkeasy.w.bronet.cn/portal/goodsdetails/goods_details/goods_id/".$goods_id['goods_id']."/status/3/id/".$my_user['id'];
|
|
|
}else{
|
|
|
$url = "http://xkeasy.w.bronet.cn/portal/goodsdetails/goods_details/goods_id/".$goods_id['goods_id']."/status/3/id/".$goods_id['id'];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//学生身份
|
|
|
if($my_user['status'] == 4){
|
|
|
$teacher_my_user = Db::name('my_user') -> where('id',$my_user['pid']) -> find();
|
|
|
if(empty($goods_id['id'])){
|
|
|
$url = "http://xkeasy.w.bronet.cn/portal/goodsdetails/goods_details/goods_id/".$goods_id['goods_id']."/status/4/id/".$teacher_my_user['id'];
|
|
|
}else{
|
|
|
$url = "http://xkeasy.w.bronet.cn/portal/goodsdetails/goods_details/goods_id/".$goods_id['goods_id']."/status/4/id/".$goods_id['id'];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
$this -> assign('url',$url);
|
|
|
return $this -> fetch();
|
|
|
}
|
...
|
...
|
@@ -178,10 +235,32 @@ class GoodsdetailsController extends WeChatBaseController{ |
|
|
return $res;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断购买的商品是不是自己上一级业务员卖的商品
|
|
|
*/
|
|
|
public function is_salesmang_goods(){
|
|
|
|
|
|
|
|
|
|
|
|
$uid = cmf_get_current_user_id();
|
|
|
$goods_uid = Db::name('goods') -> where("id",$_POST['goods_id']) -> find();
|
|
|
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
|
|
|
if($my_user['status'] == 3){
|
|
|
$salesman_user = Db::name('my_user') -> where('id',$my_user['pid']) -> find();
|
|
|
}
|
|
|
if($my_user['status'] == 4){
|
|
|
$teacher_user = Db::name('my_user') -> where('id',$my_user['pid']) -> find();
|
|
|
$salesman_user = Db::name('my_user') -> where('id',$teacher_user['pid']) -> find();
|
|
|
}
|
|
|
if(!empty($salesman_user)){
|
|
|
if($goods_uid['uid'] == $salesman_user['uid']){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}else{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
...
|
...
|
@@ -197,6 +276,4 @@ class GoodsdetailsController extends WeChatBaseController{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|