init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
38
addons/shopro/controller/user/WalletLog.php
Normal file
38
addons/shopro/controller/user/WalletLog.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace addons\shopro\controller\user;
|
||||
|
||||
use addons\shopro\controller\Common;
|
||||
use app\admin\model\shopro\user\WalletLog as UserWalletLogModel;
|
||||
|
||||
class WalletLog extends Common
|
||||
{
|
||||
|
||||
protected $noNeedLogin = [];
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$type = $this->request->param('type', 'money');
|
||||
$tab = $this->request->param('tab', 'all');
|
||||
$list_rows = $this->request->param('list_rows', 10);
|
||||
$date = $this->request->param('date/a');
|
||||
$user = auth_user();
|
||||
$where['user_id'] = $user->id;
|
||||
|
||||
switch ($tab) {
|
||||
case 'income':
|
||||
$where['amount'] = ['>', 0];
|
||||
break;
|
||||
case 'expense':
|
||||
$where['amount'] = ['<', 0];
|
||||
break;
|
||||
}
|
||||
|
||||
$income = UserWalletLogModel::where('user_id', $user->id)->{$type}()->where('amount', '>', 0)->whereTime('createtime', 'between', $date)->sum('amount');
|
||||
$expense = UserWalletLogModel::where('user_id', $user->id)->{$type}()->where('amount', '<', 0)->whereTime('createtime', 'between', $date)->sum('amount');
|
||||
$logs = UserWalletLogModel::where($where)->{$type}()->whereTime('createtime', 'between', $date)->order('createtime', 'desc')->paginate($list_rows);
|
||||
$this->success('获取成功', ['list' => $logs, 'income' => $income, 'expense' => $expense]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user