Explorar o código

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

- 添加了独立的用户创建时间筛选条件变量 $userDayWhere
- 修正了共富计划今日新增会员统计的时间条件
- 将原有的 take_time 条件更改为 create_time 条件用于会员统计
- 确保数据查询准确性并避免时间筛选错误
shichen hai 3 meses
pai
achega
27cc11cf13
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  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
         $sWeekWhere = " 1=1";
485
         $sWeekWhere = " 1=1";
486
         $weekWhere = " 1=1";
486
         $weekWhere = " 1=1";
487
         $dayWhere = " 1=1";
487
         $dayWhere = " 1=1";
488
+        $userDayWhere = " 1=1";
488
 
489
 
489
         // 获取当前 ISO 年份和周数
490
         // 获取当前 ISO 年份和周数
490
         $year = $today->format('o'); // ISO-8601 年份
491
         $year = $today->format('o'); // ISO-8601 年份
@@ -508,12 +509,14 @@ class FinanceRepository extends BaseRepository
508
         $weekWhere .= " and DATE(take_time) >= '" . $thisMonday->format('Y-m-d') . "' and DATE(take_time) < '" . $nextMonday->format('Y-m-d') . "'";
509
         $weekWhere .= " and DATE(take_time) >= '" . $thisMonday->format('Y-m-d') . "' and DATE(take_time) < '" . $nextMonday->format('Y-m-d') . "'";
509
         //今日时间条件
510
         //今日时间条件
510
         $dayWhere .= " and DATE(take_time) = '" . $todayFormatted . "'";
511
         $dayWhere .= " and DATE(take_time) = '" . $todayFormatted . "'";
512
+        // 今日新增会员条件
513
+        $userDayWhere .= " and DATE(create_time) >= '" . $todayFormatted . "'";
511
 
514
 
512
         // 测试账号
515
         // 测试账号
513
         $testUids = Db::name('user')->where('test_user',  '1')->column('uid');
516
         $testUids = Db::name('user')->where('test_user',  '1')->column('uid');
514
 
517
 
515
         $sharedUserCount = Db::name('shared_prosperity_user')->count(); //共富会员总人数
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
         $sharedUserPvCount = Db::name('shared_prosperity_reward_record')
520
         $sharedUserPvCount = Db::name('shared_prosperity_reward_record')
518
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
521
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
519
             ->whereNotIn('user_id',$testUids)
522
             ->whereNotIn('user_id',$testUids)