优化:指定用户是否为有效员工判断条件优化,兼容总平台判断
This commit is contained in:
parent
1550d8bf6e
commit
33fb06bd45
|
|
@ -248,25 +248,31 @@ class StoreServiceRepository extends BaseRepository
|
|||
return $key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 判断:指定用户是否为有效员工
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/19 15:56
|
||||
* Time: 2024/01/22 11:35
|
||||
* @param int $uid
|
||||
* @param int $id
|
||||
* @param int $merId
|
||||
* @return bool
|
||||
*/
|
||||
public function isService(int $uid,int $id = 0):bool{
|
||||
public function isService(int $uid,int $id = 0,int $merId = 0):bool{
|
||||
$count = $this->dao->getSearch([])
|
||||
->hasWhere('merchant',function($query){
|
||||
$query->where('is_del', 0);
|
||||
})
|
||||
->where('StoreService.uid',$uid)
|
||||
->where('StoreService.is_del', 0)
|
||||
->when($id > 0,function($query) use ($id){
|
||||
->when((int)$id > 0,function($query) use ($id){
|
||||
$query->where('StoreService.service_id','<>',$id);
|
||||
})->count();
|
||||
})
|
||||
->when((int)$merId > 0,function($query) use ($merId){
|
||||
$query->where('StoreService.mer_id','>',$merId);
|
||||
},function($query){
|
||||
$query->where('StoreService.mer_id', 0);
|
||||
})
|
||||
->count();
|
||||
|
||||
return $count > 0;
|
||||
}
|
||||
|
|
@ -279,7 +285,7 @@ class StoreServiceRepository extends BaseRepository
|
|||
*/
|
||||
public function createInfo($data){
|
||||
// 内容校验
|
||||
if($this->isService($data['uid'])) throw new ValidateException('该用户已绑定商户!');
|
||||
if($this->isService($data['uid'], 0, $data['mer_id'])) throw new ValidateException('该用户已绑定商户!');
|
||||
if($this->dao->fieldExists('account', $data['account'])) throw new ValidateException('账号已存在!');
|
||||
// 数据添加
|
||||
$data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT);
|
||||
|
|
@ -297,7 +303,7 @@ class StoreServiceRepository extends BaseRepository
|
|||
public function updateInfo($id,$data){
|
||||
// 内容校验
|
||||
if (!$this->dao->merExists($data['mer_id'], $id)) throw new ValidateException('数据不存在!');
|
||||
if($this->isService($data['uid'], $id)) throw new ValidateException('该用户已绑定商户!');
|
||||
if($this->isService($data['uid'], $id, $data['mer_id'])) throw new ValidateException('该用户已绑定商户!');
|
||||
if($this->dao->fieldExists('account', $data['account'], $id)) throw new ValidateException('账号已存在!');
|
||||
// 数据修改
|
||||
if ($data['pwd']) $data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class UserMerchantRepository extends BaseRepository
|
|||
$item->svip_endtime = date('Y-m-d H:i:s', strtotime("+100 year"));
|
||||
$item->merchant_integral = $integralMake->getMerIntegral((int)$item->uid,(int)$where['mer_id']);
|
||||
// 当前用户是否已经绑定店员身份
|
||||
$item->is_store_service = (int)app()->make(StoreServiceRepository::class)->isService((int)$item->uid);
|
||||
$item->is_store_service = (int)app()->make(StoreServiceRepository::class)->isService((int)$item->uid, 0, 1);
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class MerchantIntention extends BaseController
|
|||
$typeIsHas = app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id']);
|
||||
if($data['mer_type_id'] && !$typeIsHas) throw new ValidateException('店铺类型不存在');
|
||||
// 判断:当前管理员身份是否有效
|
||||
$isService = app()->make(StoreServiceRepository::class)->isService($data['manage_uid'], $id);// 是否存在店员信息
|
||||
$isService = app()->make(StoreServiceRepository::class)->isService($data['manage_uid'], $id, 1);// 是否存在店员信息
|
||||
if($isService) throw new ValidateException('管理员身份无效,已成为其他商户管理员或店员!');
|
||||
$isManage = app()->make(repository::class)->isManage($data['manage_uid'], $id);// 是否存在审核中店长信息
|
||||
if($isManage) throw new ValidateException('管理员身份无效,已成为其他商户管理员!');
|
||||
|
|
@ -148,7 +148,7 @@ class MerchantIntention extends BaseController
|
|||
'msg' => '有效'
|
||||
];
|
||||
// 判断:当前管理员身份是否有效
|
||||
$isService = app()->make(StoreServiceRepository::class)->isService((int)$data['manage_uid'], (int)$data['service_id']);// 是否存在店员信息
|
||||
$isService = app()->make(StoreServiceRepository::class)->isService((int)$data['manage_uid'], (int)$data['service_id'], 1);// 是否存在店员信息
|
||||
if($isService){
|
||||
$returnData = [
|
||||
'is_eligible' => false,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class StoreService extends BaseController
|
|||
'pwd',
|
||||
'confirm_pwd',
|
||||
'is_open',
|
||||
'status',
|
||||
['status',0],
|
||||
'customer',
|
||||
'is_verify',
|
||||
'is_goods',
|
||||
|
|
|
|||
Loading…
Reference in New Issue