会员账户相关
This commit is contained in:
parent
48a54fcf5a
commit
696f10ee2a
@ -80,5 +80,46 @@ class UserController extends BaseApiController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('会员账户详情'),
|
||||||
|
ApiDoc\url('/api/user/user/capital_flow'),
|
||||||
|
ApiDoc\Method('POST'),
|
||||||
|
ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"),
|
||||||
|
ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
|
public function capital_flow()
|
||||||
|
{
|
||||||
|
$page_no = (int)$this->request->post('page_no',1);
|
||||||
|
$page_size = (int)$this->request->post('page_size',15);
|
||||||
|
$params['page_no'] = $page_no;
|
||||||
|
$params['page_size'] = $page_size;
|
||||||
|
if(empty($page_no) || empty($page_size)){
|
||||||
|
$params['page_no'] = 1;
|
||||||
|
$params['page_size'] = 15;
|
||||||
|
}
|
||||||
|
$res = UserLogic::capital_list($this->userId,$params);
|
||||||
|
|
||||||
|
$res['page_no'] =$params['page_no'];
|
||||||
|
$res['page_size'] =$params['page_size'];
|
||||||
|
return $this->success('ok',$res);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
ApiDoc\Title('会员账户统计'),
|
||||||
|
ApiDoc\url('/api/user/user/capital_count'),
|
||||||
|
ApiDoc\Method('POST'),
|
||||||
|
ApiDoc\Param(),
|
||||||
|
ApiDoc\NotHeaders(),
|
||||||
|
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||||
|
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||||
|
]
|
||||||
|
public function capital_count()
|
||||||
|
{
|
||||||
|
$res = UserLogic::capital_count($this->userId);
|
||||||
|
return $this->success('ok',$res);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ namespace app\api\logic\user;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\{logic\BaseLogic,
|
use app\common\{logic\BaseLogic,
|
||||||
|
model\finance\CapitalFlow,
|
||||||
|
model\store_order\StoreOrder,
|
||||||
model\system_store\SystemStore,
|
model\system_store\SystemStore,
|
||||||
model\user\User,
|
model\user\User,
|
||||||
model\user\UserRecharge,
|
model\user\UserRecharge,
|
||||||
@ -100,21 +102,49 @@ class UserLogic extends BaseLogic
|
|||||||
|
|
||||||
|
|
||||||
public static function getNextArrayByID($arr, $id) {
|
public static function getNextArrayByID($arr, $id) {
|
||||||
// 遍历数组
|
|
||||||
foreach ($arr as $key => $value) {
|
foreach ($arr as $key => $value) {
|
||||||
// 检查当前数组的id是否与传入的id匹配
|
|
||||||
if ($value['id'] == $id) {
|
if ($value['id'] == $id) {
|
||||||
// 如果当前数组不是最后一个,则返回下一个数组
|
|
||||||
if ($key + 1 < count($arr)) {
|
if ($key + 1 < count($arr)) {
|
||||||
return $arr[$key + 1];
|
return $arr[$key + 1];
|
||||||
}
|
}
|
||||||
// 如果当前数组是最后一个,则返回null或空数组
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果没有找到匹配的id,则返回null或空数组
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function capital_list($uid,$params)
|
||||||
|
{
|
||||||
|
$query = CapitalFlow::where('uid',$uid);
|
||||||
|
$count = $query->count();
|
||||||
|
$data = $query
|
||||||
|
->page($params['page_no'], $params['page_size'])
|
||||||
|
->select()->toArray();
|
||||||
|
foreach ($data as &$value){
|
||||||
|
if($value['link_type'] == 'order'){
|
||||||
|
$value['order_sn'] = StoreOrder::where('id',$value['link_id'])
|
||||||
|
->value('order_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'count'=>$count,
|
||||||
|
'data'=>$data,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function capital_count($uid)
|
||||||
|
{
|
||||||
|
$query = CapitalFlow::where('uid',$uid);
|
||||||
|
$recharge = $query->where('link_type','user_recharge')
|
||||||
|
->sum('amount')??0;
|
||||||
|
$query1 = CapitalFlow::where('uid',$uid);
|
||||||
|
$orderConsumption = $query1->where('link_type','<>','user_recharge')
|
||||||
|
->sum('amount')??0;
|
||||||
|
return [
|
||||||
|
'recharge'=>$recharge,
|
||||||
|
'order'=>$orderConsumption,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user