修改:非普通商户支持搜索全平台用户为店员
This commit is contained in:
parent
b8d249237d
commit
7f2c9fbf93
|
|
@ -64,37 +64,62 @@ class UserMerchantDao extends BaseDao
|
||||||
* @author xaboy
|
* @author xaboy
|
||||||
* @day 2020/10/20
|
* @day 2020/10/20
|
||||||
*/
|
*/
|
||||||
public function search(array $where)
|
public function search(array $where){
|
||||||
{
|
$merchantType = $where['merchant_type'] ?? 0;
|
||||||
return UserMerchant::getDB()->alias('A')->leftJoin('User B', 'A.uid = B.uid')
|
return UserMerchant::getDB()
|
||||||
->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
|
->alias('A')
|
||||||
$query->where('A.mer_id', $where['mer_id']);
|
->when($merchantType > 0, function($query){
|
||||||
})->when(isset($where['nickname']) && $where['nickname'], function (BaseQuery $query) use ($where) {
|
$query->rightJoin('User B','A.uid = B.uid');
|
||||||
return $query->where('B.nickname', 'like', '%' . $where['nickname'] . '%');
|
},function($query){
|
||||||
})->when(isset($where['sex']) && $where['sex'] !== '', function (BaseQuery $query) use ($where) {
|
$query->leftJoin('User B','A.uid = B.uid');
|
||||||
return $query->where('B.sex', intval($where['sex']));
|
})
|
||||||
})->when(isset($where['is_promoter']) && $where['is_promoter'] !== '', function (BaseQuery $query) use ($where) {
|
->when(isset($where['mer_id']) && $where['mer_id'] !== '',function($query) use ($where){
|
||||||
return $query->where('B.is_promoter', $where['is_promoter']);
|
$query->where('A.mer_id',$where['mer_id']);
|
||||||
})->when(isset($where['uids']), function (BaseQuery $query) use ($where) {
|
})
|
||||||
return $query->whereIn('A.uid', $where['uids']);
|
->when(isset($where['nickname']) && $where['nickname'],function(BaseQuery $query) use ($where){
|
||||||
})->when(isset($where['user_time_type']) && $where['user_time_type'] !== '' && $where['user_time'] != '', function ($query) use ($where) {
|
return $query->where('B.nickname','like','%'.$where['nickname'].'%');
|
||||||
if ($where['user_time_type'] == 'visit') {
|
})
|
||||||
getModelTime($query, $where['user_time'], 'A.last_time');
|
->when(isset($where['sex']) && $where['sex'] !== '',function(BaseQuery $query) use ($where){
|
||||||
|
return $query->where('B.sex',intval($where['sex']));
|
||||||
|
})
|
||||||
|
->when(isset($where['uid']) && $where['uid'] !== '',function(BaseQuery $query) use ($where){
|
||||||
|
return $query->where('B.uid',intval($where['uid']));
|
||||||
|
})
|
||||||
|
->when(isset($where['is_promoter']) && $where['is_promoter'] !== '',function(BaseQuery $query) use ($where){
|
||||||
|
return $query->where('B.is_promoter',$where['is_promoter']);
|
||||||
|
})
|
||||||
|
->when(isset($where['uids']),function(BaseQuery $query) use ($where){
|
||||||
|
return $query->whereIn('A.uid',$where['uids']);
|
||||||
|
})
|
||||||
|
->when(isset($where['user_time_type']) && $where['user_time_type'] !== '' && $where['user_time'] != '',function($query) use ($where){
|
||||||
|
if($where['user_time_type'] == 'visit'){
|
||||||
|
getModelTime($query,$where['user_time'],'A.last_time');
|
||||||
}
|
}
|
||||||
if ($where['user_time_type'] == 'add_time') {
|
if($where['user_time_type'] == 'add_time'){
|
||||||
getModelTime($query, $where['user_time'], 'A.create_time');
|
getModelTime($query,$where['user_time'],'A.create_time');
|
||||||
}
|
}
|
||||||
})->when(isset($where['pay_count']) && $where['pay_count'] !== '', function ($query) use ($where) {
|
})
|
||||||
if ($where['pay_count'] == -1) {
|
->when(isset($where['pay_count']) && $where['pay_count'] !== '',function($query) use ($where){
|
||||||
$query->where('A.pay_num', 0);
|
if($where['pay_count'] == -1){
|
||||||
} else {
|
$query->where('A.pay_num',0);
|
||||||
$query->where('A.pay_num', '>', $where['pay_count']);
|
|
||||||
}
|
}
|
||||||
})->when(isset($where['label_id']) && $where['label_id'] !== '', function (BaseQuery $query) use ($where) {
|
else{
|
||||||
return $query->whereRaw('CONCAT(\',\',A.label_id,\',\') LIKE \'%,' . $where['label_id'] . ',%\'');
|
$query->where('A.pay_num','>',$where['pay_count']);
|
||||||
})->when(isset($where['user_type']) && $where['user_type'] !== '', function (BaseQuery $query) use ($where) {
|
}
|
||||||
return $query->where('B.user_type', $where['user_type']);
|
})
|
||||||
})->where('A.status', 1);
|
->when(isset($where['label_id']) && $where['label_id'] !== '',function(BaseQuery $query) use ($where){
|
||||||
|
return $query->whereRaw('CONCAT(\',\',A.label_id,\',\') LIKE \'%,'.$where['label_id'].',%\'');
|
||||||
|
})
|
||||||
|
->when(isset($where['user_type']) && $where['user_type'] !== '',function(BaseQuery $query) use ($where){
|
||||||
|
return $query->where('B.user_type',$where['user_type']);
|
||||||
|
})
|
||||||
|
->whereNull('B.cancel_time')
|
||||||
|
->when($merchantType > 0, function($query){
|
||||||
|
$query->group('B.uid');
|
||||||
|
},function($query){
|
||||||
|
$query->where('A.status',1);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function numUserIds($mer_id, $min, $max = null)
|
public function numUserIds($mer_id, $min, $max = null)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,24 @@ class UserMerchantRepository extends BaseRepository
|
||||||
$make = app()->make(UserLabelRepository::class);
|
$make = app()->make(UserLabelRepository::class);
|
||||||
$integralMake = app()->make(IntegralRepository::class);
|
$integralMake = app()->make(IntegralRepository::class);
|
||||||
$list = $query->setOption('field',[])
|
$list = $query->setOption('field',[])
|
||||||
->field('A.uid,A.user_merchant_id,B.avatar,B.nickname,B.user_type,A.last_pay_time,A.first_pay_time,A.label_id,A.create_time,A.last_time,A.pay_num,A.pay_price,B.phone,B.is_svip,B.svip_endtime,B.advance_exchange_integral')
|
->field([
|
||||||
|
'B.uid',
|
||||||
|
'A.user_merchant_id',
|
||||||
|
'B.avatar',
|
||||||
|
'B.nickname',
|
||||||
|
'B.user_type',
|
||||||
|
'A.last_pay_time',
|
||||||
|
'A.first_pay_time',
|
||||||
|
'A.label_id',
|
||||||
|
'A.create_time',
|
||||||
|
'A.last_time',
|
||||||
|
'A.pay_num',
|
||||||
|
'A.pay_price',
|
||||||
|
'B.phone',
|
||||||
|
'B.is_svip',
|
||||||
|
'B.svip_endtime',
|
||||||
|
'B.advance_exchange_integral'
|
||||||
|
])
|
||||||
->page($page,$limit)
|
->page($page,$limit)
|
||||||
->order('A.user_merchant_id DESC')
|
->order('A.user_merchant_id DESC')
|
||||||
->select()
|
->select()
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace app\controller\merchant\user;
|
||||||
|
|
||||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||||
use app\common\repositories\store\order\StoreOrderRepository;
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
use app\common\repositories\user\UserLabelRepository;
|
use app\common\repositories\user\UserLabelRepository;
|
||||||
use app\common\repositories\user\UserMerchantRepository;
|
use app\common\repositories\user\UserMerchantRepository;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
|
|
@ -46,12 +47,33 @@ class UserMerchant extends BaseController
|
||||||
* @author xaboy
|
* @author xaboy
|
||||||
* @day 2020/10/20
|
* @day 2020/10/20
|
||||||
*/
|
*/
|
||||||
public function getList()
|
public function getList(){
|
||||||
{
|
$isSearch = $this->request->param('is_search', 0);
|
||||||
$where = $this->request->params(['nickname', 'sex', 'is_promoter', 'user_time_type', 'user_time', 'pay_count', 'label_id', 'user_type']);
|
$where = $this->request->params([
|
||||||
|
'nickname',
|
||||||
|
'sex',
|
||||||
|
'is_promoter',
|
||||||
|
'user_time_type',
|
||||||
|
'user_time',
|
||||||
|
'pay_count',
|
||||||
|
'label_id',
|
||||||
|
'user_type',
|
||||||
|
'uid'
|
||||||
|
]);
|
||||||
[$page, $limit] = $this->getPage();
|
[$page, $limit] = $this->getPage();
|
||||||
$where['mer_id'] = $this->request->merId();
|
$where['mer_id'] = $this->request->merId();
|
||||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
$where['merchant_type'] = (int)app()->make(MerchantRepository::class)->getSearch(['mer_id'=>$where['mer_id']])->value('merchant_type');
|
||||||
|
if($where['merchant_type'] != 0) {
|
||||||
|
// 非普通商户 查询所有用户;必须通过搜索
|
||||||
|
$where['mer_id'] = '';
|
||||||
|
// 判断:是否必须搜索
|
||||||
|
$data = [];
|
||||||
|
if(!empty($where['nickname']) || !empty($where['uid'])) $data = $this->repository->getList($where, $page, $limit);
|
||||||
|
}else{
|
||||||
|
$data = $this->repository->getList($where, $page, $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return app('json')->success($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue