优化:判断用户是否已经成为商户员工时 区分商户类别 每个类别只能存在一个员工信息
This commit is contained in:
parent
bae34e6a4d
commit
a7aab6174b
|
|
@ -350,20 +350,20 @@ class StoreServiceRepository extends BaseRepository
|
|||
Cache::set('ser_captcha' . $key, $code, Config::get('admin.captcha_exp', 5) * 60);
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 判断:指定用户是否为有效员工
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/22 11:35
|
||||
* @param int $uid
|
||||
* @param int $id
|
||||
* @param int $merId
|
||||
* @param int $uid
|
||||
* @param int $id
|
||||
* @param int $merId
|
||||
* @param string $merchantType
|
||||
* @return bool
|
||||
*/
|
||||
public function isService(int $uid,int $id = 0,int $merId = 0):bool{
|
||||
public function isService(int $uid,int $id = 0,int $merId = 0, $merchantType = 0):bool{
|
||||
$count = $this->dao->getSearch([])
|
||||
->hasWhere('merchant',function($query){
|
||||
$query->where('is_del', 0)->where('merchant_type', 0);
|
||||
->hasWhere('merchant',function($query) use ($merchantType){
|
||||
$query->where('is_del', 0)->where('merchant_type', $merchantType);
|
||||
})
|
||||
->where('StoreService.uid',$uid)
|
||||
->where('StoreService.is_del', 0)
|
||||
|
|
|
|||
|
|
@ -198,23 +198,27 @@ class MerchantIntentionRepository extends BaseRepository
|
|||
$intention->save($data);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 判断:指定用户是否存在审核中店铺的管理员信息
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/19 15:59
|
||||
* @param int $uid
|
||||
* @param int $id
|
||||
* @param int $uid
|
||||
* @param int $id
|
||||
* @param string $merchantType
|
||||
* @return bool
|
||||
*/
|
||||
public function isManage(int $uid,int $id = 0):bool{
|
||||
public function isManage(int $uid,int $id = 0, $merchantType = ''):bool{
|
||||
$count = $this->dao->getSearch([])
|
||||
->where('manage_uid',$uid)
|
||||
->where('status',0)
|
||||
->where('is_del',0)
|
||||
->when($id > 0,function($query) use ($id){
|
||||
$query->where('mer_intention_id','<>',$id);
|
||||
})->count();
|
||||
})
|
||||
->when(isset($merchantType) && $merchantType !== '',function($query) use ($merchantType){
|
||||
$query->where('merchant_type',$merchantType);
|
||||
})
|
||||
->count();
|
||||
|
||||
return $count > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,20 +148,20 @@ class MerchantIntention extends BaseController
|
|||
* @return mixed
|
||||
*/
|
||||
public function manageIsEligible(){
|
||||
$data = $this->request->params(['service_id', 'mer_intention_id' ,'manage_uid']);
|
||||
$data = $this->request->params(['service_id', 'mer_intention_id' , 'manage_uid', 'merchant_type']);
|
||||
$returnData = [
|
||||
'is_eligible' => true,
|
||||
'msg' => '有效'
|
||||
];
|
||||
// 判断:当前管理员身份是否有效
|
||||
$isService = app()->make(StoreServiceRepository::class)->isService((int)$data['manage_uid'], (int)$data['service_id'], 1);// 是否存在店员信息
|
||||
$isService = app()->make(StoreServiceRepository::class)->isService((int)$data['manage_uid'], (int)$data['service_id'], 1, $data['merchant_type']);// 是否存在店员信息
|
||||
if($isService){
|
||||
$returnData = [
|
||||
'is_eligible' => false,
|
||||
'msg' => '管理员身份无效,已成为其他商户管理员或店员!'
|
||||
];
|
||||
}
|
||||
$isManage = app()->make(repository::class)->isManage((int)$data['manage_uid'], (int)$data['mer_intention_id']);// 是否存在审核中店长信息
|
||||
$isManage = app()->make(repository::class)->isManage((int)$data['manage_uid'], (int)$data['mer_intention_id'], $data['merchant_type']);// 是否存在审核中店长信息
|
||||
if($isManage) {
|
||||
$returnData = [
|
||||
'is_eligible' => false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue