Просмотр исходного кода

fix(finance): 修复共富计划数据统计中的日期筛选逻辑

- 添加了独立的用户创建时间筛选条件变量 $userDayWhere
- 修正了共富计划今日新增会员统计的时间条件
- 将原有的 take_time 条件更改为 create_time 条件用于会员统计
- 确保数据查询准确性并避免时间筛选错误
shichen месяцев назад: 3
Родитель
Сommit
27cc11cf13
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      app/common/repositories/finance/FinanceRepository.php

+ 4 - 1
app/common/repositories/finance/FinanceRepository.php

@@ -485,6 +485,7 @@ class FinanceRepository extends BaseRepository
485 485
         $sWeekWhere = " 1=1";
486 486
         $weekWhere = " 1=1";
487 487
         $dayWhere = " 1=1";
488
+        $userDayWhere = " 1=1";
488 489
 
489 490
         // 获取当前 ISO 年份和周数
490 491
         $year = $today->format('o'); // ISO-8601 年份
@@ -508,12 +509,14 @@ class FinanceRepository extends BaseRepository
508 509
         $weekWhere .= " and DATE(take_time) >= '" . $thisMonday->format('Y-m-d') . "' and DATE(take_time) < '" . $nextMonday->format('Y-m-d') . "'";
509 510
         //今日时间条件
510 511
         $dayWhere .= " and DATE(take_time) = '" . $todayFormatted . "'";
512
+        // 今日新增会员条件
513
+        $userDayWhere .= " and DATE(create_time) >= '" . $todayFormatted . "'";
511 514
 
512 515
         // 测试账号
513 516
         $testUids = Db::name('user')->where('test_user',  '1')->column('uid');
514 517
 
515 518
         $sharedUserCount = Db::name('shared_prosperity_user')->count(); //共富会员总人数
516
-        $sharedUserDayCount = Db::name('shared_prosperity_user')->where($dayWhere)->count(); //共富今日新增会员
519
+        $sharedUserDayCount = Db::name('shared_prosperity_user')->where($userDayWhere)->count(); //共富今日新增会员
517 520
         $sharedUserPvCount = Db::name('shared_prosperity_reward_record')
518 521
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
519 522
             ->whereNotIn('user_id',$testUids)