Commit 6c74f7be authored by 刘小敏's avatar 刘小敏

上传附件文件格式增加证书;增加累计消费和累计充值金额接口;

parent fae5729e
...@@ -4,6 +4,7 @@ namespace addons\shopro\controller\user; ...@@ -4,6 +4,7 @@ namespace addons\shopro\controller\user;
use addons\shopro\controller\Common; use addons\shopro\controller\Common;
use app\admin\model\shopro\user\WalletLog as UserWalletLogModel; use app\admin\model\shopro\user\WalletLog as UserWalletLogModel;
use think\Cache;
class WalletLog extends Common class WalletLog extends Common
{ {
...@@ -35,4 +36,61 @@ class WalletLog extends Common ...@@ -35,4 +36,61 @@ class WalletLog extends Common
$logs = UserWalletLogModel::where($where)->{$type}()->whereTime('createtime', 'between', $date)->order('createtime', 'desc')->paginate($list_rows); $logs = UserWalletLogModel::where($where)->{$type}()->whereTime('createtime', 'between', $date)->order('createtime', 'desc')->paginate($list_rows);
$this->success('获取成功', ['list' => $logs, 'income' => $income, 'expense' => $expense]); $this->success('获取成功', ['list' => $logs, 'income' => $income, 'expense' => $expense]);
} }
/**
* 钱包统计( 累计充值 和 累计消费 )
* @param string $type 钱包类型:money-余额, score-积分, commission-佣金(默认money)
* @return array
*/
public function walletStats()
{
$user = auth_user();
$type = $this->request->param('type', 'score');
// 验证钱包类型
if (!in_array($type, ['money', 'score', 'commission'])) {
$this->error('参数错误');
}
// 缓存key(包含用户ID、类型)
$cacheKey = "wallet_stats_{$user->id}_{$type}";
$cacheData = Cache::get($cacheKey);
if ($cacheData !== false) {
// 返回缓存数据
$this->success('获取成功', $cacheData);
}
try {
// 累计充值(收入)- 充值相关事件
$rechargeEvents = [
'money' => ['order_recharge', 'admin_recharge', 'recharge_gift', 'activity_gift', 'transfer_by_commission'],
'score' => ['signin', 'activity_gift', 'admin_recharge', 'recharge_gift'],
'commission' => ['reward_income', 'withdraw_error']
];
$recharge = UserWalletLogModel::where('user_id', $user->id)
->where('type', $type)
->where('amount', '>', 0)
->whereIn('event', $rechargeEvents[$type])
->sum('amount') ?: 0;
// 累计消费(支出)
$consume = UserWalletLogModel::where('user_id', $user->id)
->where('type', $type)
->where('amount', '<', 0)
->sum('amount') ?: 0;
$result = [
'recharge' => round($recharge, 2),
'consume' => round(abs($consume), 2),
'type' => $type
];
} catch (\Exception $e) {
$result = [
'recharge' => 0,
'consume' => 0,
'type' => $type
];
}
// 设置1分钟缓存
Cache::set($cacheKey, $result, 60);
$this->success('获取成功', $result);
}
} }
...@@ -22,7 +22,7 @@ return [ ...@@ -22,7 +22,7 @@ return [
* 可上传的文件类型 * 可上传的文件类型
* 如配置允许 pdf,ppt,docx,svg 等可能含有脚本的文件时,请先从服务器配置此类文件直接下载而不是预览 * 如配置允许 pdf,ppt,docx,svg 等可能含有脚本的文件时,请先从服务器配置此类文件直接下载而不是预览
*/ */
'mimetype' => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm', 'mimetype' => 'jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm,pem,crt',
/** /**
* 是否支持批量上传 * 是否支持批量上传
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment