92 lines
3.1 KiB
PHP
92 lines
3.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\store\lists\user;
|
|
|
|
|
|
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
|
use app\common\model\user_sign\UserSign;
|
|
use app\store\lists\BaseAdminDataLists;
|
|
use app\common\model\user\User;
|
|
use app\common\model\user_ship\UserShip;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\user\UserAddress;
|
|
use app\common\model\user_sign_log\UserSignLog;
|
|
use app\common\model\vip_flow\VipFlow;
|
|
|
|
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
/**
|
|
* @notes 搜索条件
|
|
* @return array
|
|
* @author 乔峰
|
|
* @date 2022/9/22 15:50
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['id','user_ship','store_id'],
|
|
'%like%' => ['mobile'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @notes 获取用户列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author 乔峰
|
|
* @date 2022/9/22 15:50
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
$street=$this->request->get('street','');
|
|
if($street){
|
|
$uid=UserAddress::where('street',$street)->group('uid')->column('uid');
|
|
if($uid){
|
|
$this->searchWhere[]=['id','in',$uid];
|
|
}else{
|
|
return [];
|
|
}
|
|
}
|
|
$query = User::where($this->searchWhere);
|
|
if (!empty($this->params['nickname'])) {
|
|
$query->whereLike('real_name|mobile', "%{$this->params['nickname']}%");
|
|
}
|
|
$field = "id,nickname,real_name,sex,avatar,account,mobile,now_money,user_ship,create_time,purchase_funds,integral";
|
|
$lists = $query->limit($this->limitOffset, $this->limitLength)
|
|
->field($field)
|
|
->order('id desc')
|
|
->select()->each(function($data){
|
|
$data['sex_text'] = $data->sex_text;
|
|
$data['mobile'] = substr_replace($data['mobile'], '****', 3, 4);
|
|
$data['user_ship_name'] =$data['user_ship']==0?'一般用户':UserShip::where('id',$data['user_ship'])->value('title');
|
|
$data['return_money'] = VipFlow::
|
|
where(['user_id'=>$data['id'],'status'=>0])
|
|
->sum('number')??0;
|
|
$data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number');
|
|
$number1 = UserSignLog::where('uid',$data['id'])->where(['status'=>1,'order_type'=>0,'financial_pm'=>1])->sum('number');
|
|
$number2 = UserSignLog::where('uid',$data['id'])->where(['status'=>1,'order_type'=>0,'financial_pm'=>0])->sum('number');
|
|
if($number1<$number2){
|
|
$data['get_frozen']=0;
|
|
}else{
|
|
$data['get_frozen']=bcsub($number2,$number1,2)??0;
|
|
}
|
|
|
|
})->toArray();
|
|
return $lists;
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取数量
|
|
* @return int
|
|
* @author 乔峰
|
|
* @date 2022/9/22 15:51
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return User::where($this->searchWhere)->count();
|
|
}
|
|
} |