diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index c984b04..35a38ab 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -189,18 +189,43 @@ class User extends BaseModel public function service() { - return $this->hasOne(StoreService::class, 'uid', 'uid') - ->where('mer_id', '<>', 0) - ->where('is_del', 0) - ->where('is_open', 1) + return $this->hasOne(StoreService::class,'uid','uid') + ->where('mer_id','<>',0) + ->where('is_del',0) + ->where('is_open',1) ->field('service_id,uid,nickname,avatar,customer,mer_id,is_verify,is_goods,is_open') ->order('is_verify DESC,customer DESC'); } + // 用户是否存在商户平台 有效店员信息 + public function getServiceAttr($value){ + $info = (new StoreService()) + ->field('service_id,uid,nickname,avatar,customer,StoreService.mer_id,is_verify,is_goods,is_open') + ->hasWhere('merchant',function($query){ + $query->where('is_del', 0) + ->where('mer_state', 1) + ->where('status', 1); + }) + ->where('uid',$this->uid) + ->where('StoreService.mer_id','<>',0) + ->where('StoreService.is_del',0) + ->where('is_open',1) + ->order('StoreService.is_verify DESC,StoreService.customer DESC') + // ->fetchSql() + ->find(); + + return !empty($info) ? $info->toArray() : null; + } + + + public function topService() { return $this->hasOne(StoreService::class, 'uid', 'uid') - ->where('mer_id', 0)->field('service_id,uid,nickname,avatar,customer,mer_id,is_verify,is_goods')->where('is_del', 0) + ->field('service_id,uid,nickname,avatar,customer,mer_id,is_verify,is_goods') + ->where('mer_id', 0) + ->where('is_del', 0) + ->where('is_open',1) ->order('is_verify DESC,customer DESC'); } diff --git a/app/controller/merchant/store/service/StoreService.php b/app/controller/merchant/store/service/StoreService.php index ce05119..651795e 100644 --- a/app/controller/merchant/store/service/StoreService.php +++ b/app/controller/merchant/store/service/StoreService.php @@ -114,6 +114,7 @@ class StoreService extends BaseController 'is_verify', 'is_goods', 'is_user', + 'staff_manage', 'notify', 'avatar', 'phone',