feat: 修改IndexController类以优化用户交易统计查询

This commit is contained in:
mkm 2024-06-25 17:28:07 +08:00
parent 0b41bdf59c
commit b40b004e9e

View File

@ -4,6 +4,8 @@ namespace app\statistics\controller;
use app\admin\logic\statistic\TradeStatisticLogic;
use app\common\controller\BaseLikeController;
use app\common\model\user\User;
use app\common\model\user_recharge\UserRecharge;
use app\statistics\logic\OrderLogic;
use app\statistics\logic\ProductLogic;
use app\statistics\logic\UserLogic;
@ -82,11 +84,21 @@ class IndexController extends BaseLikeController
if ($store_id) {
$where['store_id'] = $store_id;
}
$res = OrderLogic::Count($where,$time);
if (ProductLogic::hasError()) {
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
$where['recharge_type']='INDUSTRYMEMBERS';
$where['status']=1;
$where['paid']=1;
// $res = OrderLogic::Count($where,$time);
// if (ProductLogic::hasError()) {
// return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
// }
$res = UserRecharge::where($where)->whereTime('create_time', $time)->select()->each(function ($item) {
if($item['uid']){
$item['nickname']=User::where('id',$item['uid'])->value('nickname');
}else{
$item['nickname']='';
}
return $this->success('ok', $res);
});
return $this->success('ok', $res?->toArray());
}
/**
* 商品销量排行榜统计