用户余额列表、积分列表接口
This commit is contained in:
parent
42af6df23e
commit
e4f6a62b16
|
@ -5,6 +5,8 @@ namespace app\adminapi\controller\user;
|
|||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\user\UserLists;
|
||||
use app\adminapi\logic\user\UserLogic;
|
||||
use app\common\validate\user\UserBalanceValidate;
|
||||
use app\common\validate\user\UserIntegralValidate;
|
||||
use app\common\validate\user\UserValidate;
|
||||
use think\response\Json;
|
||||
|
||||
|
@ -24,8 +26,21 @@ class UserController extends BaseAdminController
|
|||
return $this->success('', $detail);
|
||||
}
|
||||
|
||||
// 用户余额列表
|
||||
public function balanceLists() {
|
||||
// 获取用户余额列表
|
||||
public function balance(): Json
|
||||
{
|
||||
//获取参数
|
||||
$params = (new UserBalanceValidate())->get()->goCheck('list');
|
||||
$data = UserLogic::balanceList($params);
|
||||
return $this->success('', $data);
|
||||
}
|
||||
|
||||
// 获取用户积分列表
|
||||
public function integral():Json
|
||||
{
|
||||
//获取参数
|
||||
$params = (new UserIntegralValidate())->get()->goCheck('list');
|
||||
$data = UserLogic::integralList($params);
|
||||
return $this->success('', $data);
|
||||
}
|
||||
}
|
|
@ -21,13 +21,12 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||
public function lists(): array
|
||||
{
|
||||
$field = "id,phone,avatar,nick_name,real_name,id_card,gender,age,total_balance,total_integral,status,create_time";
|
||||
$lists = User::field($field)->where($this->searchWhere)->where('status','<>',2)
|
||||
return User::field($field)->where($this->searchWhere)->where('status','<>',2)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id desc')->select()->each(function($item){
|
||||
$item['status_text'] = $item->status_text;
|
||||
$item['gender_text'] = $item->gender_text;
|
||||
})->toArray();
|
||||
return $lists;
|
||||
}
|
||||
|
||||
// 获取数量
|
||||
|
|
|
@ -3,19 +3,73 @@
|
|||
namespace app\adminapi\logic\user;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\systems\System;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserBalance;
|
||||
use app\common\model\user\UserIntegral;
|
||||
|
||||
class UserLogic extends BaseLogic
|
||||
{
|
||||
//用户详情
|
||||
public static function detail(int $userId): array
|
||||
{
|
||||
//获取用户信息
|
||||
$field = ['id','phone','avatar','nick_name','real_name','id_card','gender','age','total_balance','total_integral','province','city','area','street','village','brigade','address','status','last_login_time','last_login_ip','create_time'];
|
||||
$user = User::field($field)->where(['id' => $userId])->findOrEmpty();
|
||||
$user['address'] = $user->province_text.$user->city_text.$user->area_text.$user->street_text.$user->village_text.$user->brigade_text.$user->address;
|
||||
$user['gender_text'] = $user->gender_text;
|
||||
$user['status_text'] = $user->status_text;
|
||||
//获取用户余额列表
|
||||
$user['balance_list'] = UserBalance::field('id,record_id,amount,total_amount,type,pay_type,mark,appid,create_time')->where('user_id',$userId)->limit(10)->order('create_time desc')->select()->each(function($item){
|
||||
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
||||
$item['type_text'] = $item->type_text;
|
||||
$item['pay_type_text'] = $item->pay_type_text;
|
||||
unset($item['appid']);
|
||||
})->toArray();
|
||||
//获取用户积分列表
|
||||
$user['integral_list'] = UserIntegral::field('id,record_id,amount,total_amount,type,mark,appid,create_time')->where('user_id',$userId)->limit(10)->order('create_time desc')->select()->each(function($item){
|
||||
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
||||
$item['type_text'] = $item->type_text;
|
||||
})->toArray();
|
||||
unset($user['province'],$user['city'],$user['area'],$user['street'],$user['village'],$user['brigade']);
|
||||
return $user->toArray();
|
||||
}
|
||||
|
||||
//用户余额列表
|
||||
public static function balanceList($params): array
|
||||
{
|
||||
//获取用户余额列表
|
||||
$fields = 'id,record_id,amount,total_amount,type,pay_type,mark,appid,create_time';
|
||||
$lists = UserBalance::field($fields)->where('user_id',$params['uid'])->page($params['page_no'],$params['page_size'])->order('create_time desc')->select()->each(function($item){
|
||||
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
||||
$item['type_text'] = $item->type_text;
|
||||
$item['pay_type_text'] = $item->pay_type_text;
|
||||
unset($item['appid']);
|
||||
})->toArray();
|
||||
$count = UserBalance::field('id')->where('user_id',$params['uid'])->count();
|
||||
return [
|
||||
'count' => $count,
|
||||
'page_no' => $params['page_no'],
|
||||
'page_size' => $params['page_size'],
|
||||
'lists' => $lists
|
||||
];
|
||||
}
|
||||
|
||||
//用户积分列表
|
||||
public static function integralList($params): array
|
||||
{
|
||||
//获取用户积分列表
|
||||
$fields = 'id,record_id,amount,total_amount,type,mark,appid,create_time';
|
||||
$lists = UserIntegral::field($fields)->where('user_id',$params['uid'])->page($params['page_no'],$params['page_size'])->order('create_time desc')->select()->each(function($item){
|
||||
$item['app'] = System::where('app_id',$item['appid'])->value('name');
|
||||
$item['type_text'] = $item->type_text;
|
||||
})->toArray();
|
||||
$count = UserIntegral::field('id')->where('user_id',$params['uid'])->count();
|
||||
return [
|
||||
'count' => $count,
|
||||
'page_no' => $params['page_no'],
|
||||
'page_size' => $params['page_size'],
|
||||
'lists' => $lists
|
||||
];
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ class UserBalance extends BaseModel
|
|||
|
||||
public function getPayTypeTextAttr($value,$data): string
|
||||
{
|
||||
$pay_type = [ 0=>'微信支付', 2=>'支付宝支付', 3=>'银行卡支付', 4=>'余额支付', 5=>'其他'];
|
||||
$pay_type = [ 0=>'微信支付', 1=>'支付宝支付', 2=>'银行卡支付', 3=>'余额支付', 4=>'其他'];
|
||||
return $pay_type[$data['pay_type']];
|
||||
}
|
||||
}
|
|
@ -12,8 +12,11 @@ class UserBalanceValidate extends BaseValidate
|
|||
'record_table' => 'require',
|
||||
'amount' => 'require|float|gt:0',
|
||||
'type' => 'require|in:0,1',
|
||||
'pay_type' => 'require|in:0,1,2,3,4,5',
|
||||
'pay_type' => 'require|in:0,1,2,3,4',
|
||||
'mark' => 'require',
|
||||
'uid' => 'require',
|
||||
'page_no' => 'require|number|gt:0',
|
||||
'page_size' => 'require|number|gt:0'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
|
@ -28,8 +31,20 @@ class UserBalanceValidate extends BaseValidate
|
|||
'pay_type.require' => '请选择支付方式',
|
||||
'pay_type.in' => '支付方式值错误',
|
||||
'mark.require' => '请填写金额变更具体详情',
|
||||
'uid.require' => '缺少用户id',
|
||||
'page_no.require' => '缺少分页页码',
|
||||
'page_no.number' => '分页页码数据格式错误',
|
||||
'page_no.gt' => '分页页码必须大于0',
|
||||
'page_size.require' => '缺少分页条数',
|
||||
'page_size.number' => '分页条数数据格式错误',
|
||||
'page_size.gt' => '分页条数必须大于0',
|
||||
];
|
||||
|
||||
public function sceneList(): UserBalanceValidate
|
||||
{
|
||||
return $this->only(['uid','page_no','page_size']);
|
||||
}
|
||||
|
||||
public function sceneAdd(): UserBalanceValidate
|
||||
{
|
||||
return $this->only(['record_id','record_table','amount','type','pay_type','mark']);
|
||||
|
|
|
@ -13,20 +13,35 @@ class UserIntegralValidate extends BaseValidate
|
|||
'amount' => 'require|float|gt:0',
|
||||
'type' => 'require|in:0,1',
|
||||
'mark' => 'require',
|
||||
'uid' => 'require',
|
||||
'page_no' => 'require|number|gt:0',
|
||||
'page_size' => 'require|number|gt:0'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少数据主键',
|
||||
'record_id.require' => '请填写本地记录id',
|
||||
'record_table.require' => '请填写本地记录表名',
|
||||
'amount.require' => '请填写金额',
|
||||
'amount.float' => '金额数据格式错误',
|
||||
'amount.gt' => '金额必须大于零',
|
||||
'type.require' => '请选择金额变更类型',
|
||||
'type.in' => '金额变更类型值错误',
|
||||
'mark.require' => '请填写金额变更具体详情',
|
||||
'amount.require' => '请填写积分数目',
|
||||
'amount.float' => '积分数目数据格式错误',
|
||||
'amount.gt' => '积分数目必须大于零',
|
||||
'type.require' => '请选择积分数目变更类型',
|
||||
'type.in' => '积分数目变更类型值错误',
|
||||
'mark.require' => '请填写积分数目变更具体详情',
|
||||
'uid.require' => '缺少用户id',
|
||||
'page_no.require' => '缺少分页页码',
|
||||
'page_no.number' => '分页页码数据格式错误',
|
||||
'page_no.gt' => '分页页码必须大于0',
|
||||
'page_size.require' => '缺少分页条数',
|
||||
'page_size.number' => '分页条数数据格式错误',
|
||||
'page_size.gt' => '分页条数必须大于0',
|
||||
];
|
||||
|
||||
public function sceneList(): UserIntegralValidate
|
||||
{
|
||||
return $this->only(['uid','page_no','page_size']);
|
||||
}
|
||||
|
||||
public function sceneAdd(): UserIntegralValidate
|
||||
{
|
||||
return $this->only(['record_id','record_table','amount','type','mark']);
|
||||
|
|
Loading…
Reference in New Issue