Sfoglia il codice sorgente

我的部门本周业绩时间范围调整

sunxbiao 1 anno fa
parent
commit
0bae10697f
1 ha cambiato i file con 17 aggiunte e 4 eliminazioni
  1. 17 4
      app/controller/api/user/User.php

+ 17 - 4
app/controller/api/user/User.php

@@ -1640,7 +1640,11 @@ class User extends BaseController
1640 1640
         $child_nums = $this->getdepartmentStatistics($user_id, 'level_id');
1641 1641
         $child_nums_Tree = $this->buildTreePv($child_nums, $user['level_id'], 'level_id');
1642 1642
         $new_performance = 0; //一周内新增总业绩
1643
-        $end_time = date('Y-m-d ' . '00:00:00', strtotime('-7 days'));
1643
+        // 这周的时间区间
1644
+//        $end_time = date('Y-m-d ' . '00:00:00', strtotime('-7 days'));
1645
+        $now = time();
1646
+        $startTime = date('Y-m-d 00:00:00', strtotime('monday this week', $now)); // 这周星期一的开始时间
1647
+        $endTime = date('Y-m-d 23:59:59', strtotime('sunday this week', $now)); // 这周星期日的结束时间
1644 1648
         $person_nums_pv = 0;//大部门业绩
1645 1649
         $common_nums_pv = 0;//小部门业绩
1646 1650
         $aLL_list = [];//直推数据
@@ -1650,14 +1654,20 @@ class User extends BaseController
1650 1654
             // 计算总新增业绩
1651 1655
             $uid_list = array_column($child_nums, 'uid');
1652 1656
             $uid_list = array_diff($uid_list, [$user_id]);
1653
-            $new_performance = Db::name("user_pv_log")->where([['uid', 'in', $uid_list], ['settlement_time', '>', $end_time]])->sum('pv');
1657
+            $new_performance = Db::name("user_pv_log")
1658
+                ->whereIn('uid', $uid_list)
1659
+                ->whereBetween('settlement_time', [$startTime, $endTime])
1660
+                ->sum('pv');
1654 1661
             //获取大部门的key
1655 1662
             $maxBalanceIndex = array_search(max(array_column($child_nums_Tree[0]['children'], 'total_pv')), array_column($child_nums_Tree[0]['children'], 'total_pv'));
1656 1663
             foreach ($child_nums_Tree[0]['children'] as $k => $v) {
1657 1664
                 $child_nums = $this->getdepartmentStatistics($v['uid'], 'level_id');
1658 1665
                 $uid_list = array_column($child_nums, 'uid');
1659 1666
                 array_push($uid_list, $v['uid']);
1660
-                $new_performance_child = Db::name("user_pv_log")->where([['uid', 'in', $uid_list], ['settlement_time', '>', $end_time]])->sum('pv');
1667
+                $new_performance_child = Db::name("user_pv_log")
1668
+                    ->whereIn('uid', $uid_list)
1669
+                    ->whereBetween('settlement_time', [$startTime, $endTime])
1670
+                    ->sum('pv');
1661 1671
                 if ($k == $maxBalanceIndex) {
1662 1672
                     $person_list[] = [
1663 1673
                         "uid" => $v["uid"],
@@ -1746,7 +1756,10 @@ class User extends BaseController
1746 1756
                     $child_nums = $this->getdepartmentStatistics($v['uid']);
1747 1757
                     $uid_list = array_column($child_nums, 'uid');
1748 1758
                     array_push($uid_list, $v['uid']);
1749
-                    $new_performance_child = Db::name("user_pv_log")->where([['uid', 'in', $uid_list], ['settlement_time', '>', $end_time]])->sum('pv');
1759
+                    $new_performance_child = Db::name("user_pv_log")
1760
+                        ->whereIn('uid', $uid_list)
1761
+                        ->whereBetween('settlement_time', [$startTime, $endTime])
1762
+                        ->sum('pv');
1750 1763
 
1751 1764
                     $aLL_list[] =  [
1752 1765
                         "uid" => $v["uid"],