Przeglądaj źródła

Merge branch 'master' into huangfamily

family 1 rok temu
rodzic
commit
26bdff3616
32 zmienionych plików z 1294 dodań i 557 usunięć
  1. 2 2
      app/command/TestTask.php
  2. 1 1
      app/command/test/ln/ImportUser.php
  3. 2 2
      app/command/test/ln/ImportUser2.php
  4. 0 17
      app/common.php
  5. 1 1
      app/common/dao/user/UserDao.php
  6. 9 0
      app/common/repositories/BaseRepository.php
  7. 374 88
      app/common/repositories/finance/FinanceRepository.php
  8. 1 1
      app/common/repositories/merchant/order/OrderMerchantRepository.php
  9. 22 20
      app/common/repositories/store/order/StoreOrderRepository.php
  10. 8 2
      app/common/repositories/store/order/StoreRefundOrderRepository.php
  11. 1 1
      app/common/repositories/store/product/ProductRepository.php
  12. 42 53
      app/common/repositories/user/UserExtractRepository.php
  13. 374 91
      app/common/repositories/user/UserRepository.php
  14. 4 4
      app/common/repositories/user/UserThirdRepository.php
  15. 105 36
      app/controller/admin/finance/Finance.php
  16. 7 6
      app/controller/api/Auth.php
  17. 28 17
      app/controller/api/Notify.php
  18. 2 2
      app/controller/api/entropybarter/User.php
  19. 10 10
      app/controller/api/merchant/sxy/Access.php
  20. 60 53
      app/controller/api/store/merchant/TaskPartnerProfits.php
  21. 7 7
      app/controller/api/store/merchant/Taskorder.php
  22. 58 52
      app/controller/api/store/merchant/Taskorderguquan.php
  23. 45 39
      app/controller/api/store/merchant/Taskorderlianc.php
  24. 2 2
      app/controller/api/store/product/StoreProduct.php
  25. 6 6
      app/controller/api/store/service/Huafei.php
  26. 1 1
      app/controller/api/user/Im.php
  27. 108 34
      app/controller/api/user/User.php
  28. 3 3
      app/controller/api/user/UserExtract.php
  29. 1 1
      app/controller/merchant/Common.php
  30. 3 2
      app/controller/merchant/store/order/RefundOrder.php
  31. 4 0
      route/admin.php
  32. 3 3
      route/api.php

+ 2 - 2
app/command/TestTask.php

@@ -251,7 +251,7 @@ class TestTask extends Command
251 251
 
252 252
                 $resultArray = explode(",", $count[0]['uids']);
253 253
                 foreach ($resultArray as $reg_uid) {
254
-                    //查询储蓄保和上级
254
+                    //查询幸福宝和上级
255 255
                     $reg_user = Db::connect('chuxubao')->query("select * from chuxubao.rrx_user where uid={$reg_uid} and is_del=0")[0] ?? [];
256 256
                     if (!$reg_user) {
257 257
                         continue;
@@ -281,7 +281,7 @@ class TestTask extends Command
281 281
                             Db::name('user')->where('uid', $yihucha_user['uid'])->update(['spread_uid' => $yihucha_spread_user['uid']]);
282 282
                         } else if ($yihucha_user['spread_uid'] != $yihucha_spread_user['uid']) {
283 283
                             //暂时不作操作
284
-                            echo "{$reg_user['phone']}已注册,有邀请人并且邀请人不是储蓄保上级 需要注意 储蓄保邀请人{$reg_spread_user['phone']} 一壶茶邀请人{$yihucha_puser['phone']}\r\n";
284
+                            echo "{$reg_user['phone']}已注册,有邀请人并且邀请人不是幸福宝上级 需要注意 幸福宝邀请人{$reg_spread_user['phone']} 一壶茶邀请人{$yihucha_puser['phone']}\r\n";
285 285
                         }
286 286
                     }
287 287
                 }

+ 1 - 1
app/command/test/ln/ImportUser.php

@@ -13,7 +13,7 @@ class ImportUser extends Command
13 13
     protected function configure()
14 14
     {
15 15
         // 指令配置
16
-        $this->setName('import_user')->setDescription('导入储蓄保一壶茶会员');
16
+        $this->setName('import_user')->setDescription('导入幸福宝一壶茶会员');
17 17
     }
18 18
 
19 19
     protected function execute(Input $input, Output $output)

+ 2 - 2
app/command/test/ln/ImportUser2.php

@@ -12,7 +12,7 @@ class ImportUser2 extends Command
12 12
 {
13 13
     protected function configure()
14 14
     {
15
-        $this->setName('chuxubao')->setDescription('导入储蓄保数据');
15
+        $this->setName('chuxubao')->setDescription('导入幸福宝数据');
16 16
     }
17 17
 
18 18
     protected function execute(Input $input, Output $output)
@@ -74,7 +74,7 @@ class ImportUser2 extends Command
74 74
                     $yihucha_child_user = Db::name('user')->where('phone', $child_user['phone'])->where('is_del', 0)->find();
75 75
                     //子级用户信息为空,用父级uid覆盖
76 76
                     if (empty($yihucha_child_user['spread_uid'])) {
77
-                        $logs['step2'] = "一壶茶邀请关系为空, 父级用户uid, {$yihucha_father_user['uid']}, 父级用户手机号, {{$yihucha_father_user['phone']}}, 使用储蓄保邀请关系覆盖";
77
+                        $logs['step2'] = "一壶茶邀请关系为空, 父级用户uid, {$yihucha_father_user['uid']}, 父级用户手机号, {{$yihucha_father_user['phone']}}, 使用幸福宝邀请关系覆盖";
78 78
                         Db::name('user')->where('uid', $yihucha_child_user['uid'])->update(['spread_uid' => $yihucha_father_user['uid']]);
79 79
                     } else {
80 80
                         $yihucha_child_spread_user = Db::name('user')->where('uid', $yihucha_child_user['spread_uid'])->where('is_del', 0)->find();

+ 0 - 17
app/common.php

@@ -898,20 +898,3 @@ if (!function_exists("is_json")){
898 898
     }
899 899
 }
900 900
 
901
-
902
-
903
-if (!function_exists("roundOptimize")){
904
-    /**
905
-     * round公用四舍五入去除
906
-     * @param $number
907
-     * @return string
908
-     */
909
-    function roundOptimize($amount, $decimals = 2): string
910
-    {
911
-        if ($amount > 0) {
912
-            $factor = pow(10, $decimals);
913
-            return floor($amount * $factor) / $factor;
914
-        }
915
-        return $amount;
916
-    }
917
-}

+ 1 - 1
app/common/dao/user/UserDao.php

@@ -264,7 +264,7 @@ class UserDao extends BaseDao
264 264
      */
265 265
     public function accountByUser($account)
266 266
     {
267
-        return User::getDB()->where('account', $account)->find();
267
+        return User::getDB()->where('account', $account)->where('is_del', 0)->find();
268 268
     }
269 269
 
270 270
     /**

+ 9 - 0
app/common/repositories/BaseRepository.php

@@ -29,4 +29,13 @@ class BaseRepository
29 29
     {
30 30
         return call_user_func_array([$this->dao, $name], $arguments);
31 31
     }
32
+
33
+    public function roundOptimize($amount, $decimals = 2)
34
+    {
35
+        if ($amount > 0) {
36
+            $factor = pow(10, $decimals);
37
+            return floor($amount * $factor) / $factor;
38
+        }
39
+        return $amount;
40
+    }
32 41
 }

+ 374 - 88
app/common/repositories/finance/FinanceRepository.php

@@ -28,98 +28,319 @@ class FinanceRepository extends BaseRepository
28 28
      */
29 29
     public function order_overview($mer_id = 0)
30 30
     {
31
-        if ($mer_id) {
32
-            $where = "mer_id = " . $mer_id . " and paid = 1";
33
-        } else {
31
+        // if ($mer_id) {
32
+        //     $where = "mer_id = " . $mer_id . " and paid = 1";
33
+        // } else {
34 34
             $where = " paid = 1";
35
+        // }
36
+
37
+        $type = input('type', 1);
38
+        $day = input('day', '');
39
+        //天
40
+        if ($type == 1 and $day != '') {
41
+            $where .= " and DATE(create_time) = '" . $day . "'";
42
+        }
43
+        //月
44
+        if ($type == 2 and $day != '') {
45
+            $date = new \DateTime($day);
46
+            $year = $date->format('Y');
47
+            $month = $date->format('m');
48
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
35 49
         }
36 50
 
51
+        $weekWhere = " paid = 1";
52
+        $dayWhere = " paid = 1";
53
+        // 获取今天的日期和时间
54
+        $today = new \DateTime();
55
+        // 计算一周前的日期
56
+        $oneWeekAgo = clone $today; // 克隆一个对象,避免修改原始对象
57
+        $oneWeekAgo->sub(new \DateInterval('P1W')); // 减去一周
58
+        
59
+        // 格式化日期
60
+        $todayFormatted = $today->format('Y-m-d');
61
+        $oneWeekAgoFormatted = $oneWeekAgo->format('Y-m-d');
62
+
63
+        //周时间条件
64
+        $weekWhere .= " and DATE(create_time) >= '" . $oneWeekAgoFormatted . "' and DATE(create_time) <= '" . $todayFormatted . "'";
65
+        //今日时间条件
66
+        $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
67
+
68
+
69
+        // 会员专区订单总数
70
+        //总数
71
+        $chengjiaomoney = Db::name('store_order')->where($where)->where('mer_id', 496)->count();
72
+        $weekCount = Db::name('store_order')->where($weekWhere)->where('mer_id', 496)->count();
73
+        $todayCount = Db::name('store_order')->where($dayWhere)->where('mer_id', 496)->count();
74
+        $list1[] = ['count' => $weekCount, 'name' => '周订单总数'];
75
+        $list1[] = ['count' => $todayCount, 'name' => '日订单总数'];
76
+
77
+        //精彩生活区订单总数
78
+        //总数
79
+        $chengjiaocount = Db::name('store_order')->where($where)->where('mer_id', 439)->count();
80
+        $weekCount = Db::name('store_order')->where($weekWhere)->where('mer_id', 439)->count();
81
+        $todayCount = Db::name('store_order')->where($dayWhere)->where('mer_id', 439)->count();
82
+        $list2[] = ['count' => $weekCount, 'name' => '周订单总数'];
83
+        $list2[] = ['count' => $todayCount, 'name' => '日订单总数'];
84
+
85
+        //商贸区订单总数
86
+        //总数
87
+        $chengjiaoren = Db::name('store_order')->where($where)->whereNotIn('mer_id', [496, 439, 491])->count();
88
+        $weekCount = Db::name('store_order')->where($weekWhere)->whereNotIn('mer_id', [496, 439, 491])->count();
89
+        $todayCount = Db::name('store_order')->where($dayWhere)->whereNotIn('mer_id', [496, 439, 491])->count();
90
+        $list3[] = ['count' => $weekCount, 'name' => '周订单总数'];
91
+        $list3[] = ['count' => $todayCount, 'name' => '日订单总数'];
92
+
93
+        //复购区订单总数
94
+        //总数
95
+        $tuikuanmoney = Db::name('store_order')->where($where)->where('mer_id', 491)->count();
96
+        $weekCount = Db::name('store_order')->where($weekWhere)->where('mer_id', 491)->count();
97
+        $todayCount = Db::name('store_order')->where($dayWhere)->where('mer_id', 491)->count();
98
+        $list4[] = ['count' => $weekCount, 'name' => '周订单总数'];
99
+        $list4[] = ['count' => $todayCount, 'name' => '日订单总数'];
100
+
101
+        //三方平台订单总数
102
+        //总数
103
+
104
+        //话费
105
+        $whereNew = str_replace("paid", "status", $where);
106
+        $weekWhereNew = str_replace("paid", "status", $weekWhere);
107
+        $dayWhereNew = str_replace("paid", "status", $dayWhere);
108
+        $huafei = Db::name('order_huafei_hf')->where($whereNew)->count();
109
+        $huafei_week = Db::name('order_huafei_hf')->where($weekWhereNew)->count();
110
+        $huafei_today = Db::name('order_huafei_hf')->where($dayWhereNew)->count();
111
+
112
+
113
+        //京东
114
+        $whereNew = str_replace(" paid = 1", " status IN (16, 17)", $where);
115
+        $weekWhereNew = str_replace(" paid = 1", " status IN (16, 17)", $weekWhere);
116
+        $dayWhereNew = str_replace(" paid = 1", " status IN (16, 17)", $dayWhere);
117
+        $jd = Db::name('order_jd')->where($whereNew)->count();
118
+        $jd_week = Db::name('order_jd')->where($weekWhereNew)->count();
119
+        $jd_today = Db::name('order_jd')->where($dayWhereNew)->count();
120
+
121
+        //拼多多
122
+        $whereNew = str_replace(" paid = 1", " pin_order_status IN (0, 2, 3)", $where);
123
+        $weekWhereNew = str_replace(" paid = 1", " pin_order_status IN (0, 2, 3)", $weekWhere);
124
+        $dayWhereNew = str_replace(" paid = 1", " pin_order_status IN (0, 2, 3)", $dayWhere);
125
+        $pdd = Db::name('order_pdd')->where($whereNew)->count();
126
+        $pdd_week = Db::name('order_pdd')->where($weekWhereNew)->count();
127
+        $pdd_today = Db::name('order_pdd')->where($dayWhereNew)->count();
128
+
129
+        //淘宝
130
+        $whereNew = str_replace(" paid = 1", " tk_status IN (12, 3)", $where);
131
+        $weekWhereNew = str_replace(" paid = 1", " tk_status IN (12, 3)", $weekWhere);
132
+        $dayWhereNew = str_replace(" paid = 1", " tk_status IN (12, 3)", $dayWhere);
133
+        $tb = Db::name('order_tb')->where($whereNew)->count();
134
+        $tb_week = Db::name('order_tb')->where($weekWhereNew)->count();
135
+        $tb_today = Db::name('order_tb')->where($dayWhereNew)->count();
136
+
137
+        //电影票
138
+        $whereNew = str_replace(" paid = 1", " status IN (1, 4)", $where);
139
+        $weekWhereNew = str_replace(" paid = 1", " status IN (1, 4)", $weekWhere);
140
+        $dayWhereNew = str_replace(" paid = 1", " status IN (1, 4)", $dayWhere);
141
+        $movie = Db::name('order_movie')->where($whereNew)->count();
142
+        $movie_week = Db::name('order_movie')->where($weekWhereNew)->count();
143
+        $movie_today = Db::name('order_movie')->where($dayWhereNew)->count();
144
+
145
+        $tuikuancount = $huafei+$jd+$pdd+$tb+$movie;
146
+        $weekCount = $huafei_week+$jd_week+$pdd_week+$tb_week+$movie_week;
147
+        $todayCount = $huafei_today+$jd_today+$pdd_today+$tb_today+$movie_today;
148
+        $list5[] = ['count' => $weekCount, 'name' => '周订单总数'];
149
+        $list5[] = ['count' => $todayCount, 'name' => '日订单总数'];
150
+
151
+        //线下订单总数
152
+        //总数
153
+        $tuikuanren = Db::name('order_merchant')->where($where)->count();
154
+        $weekCount = Db::name('order_merchant')->where($weekWhere)->count();
155
+        $todayCount = Db::name('order_merchant')->where($dayWhere)->count();
156
+        $list6[] = ['count' => $weekCount, 'name' => '周订单总数'];
157
+        $list6[] = ['count' => $todayCount, 'name' => '日订单总数'];
158
+
159
+
160
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($chengjiaomoney), 'name' => '会员专区订单总数', 'list' => $list1];
161
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($chengjiaocount), 'name' => '精彩生活区订单总数', 'list' => $list2];
162
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($chengjiaoren), 'name' => '商贸区订单总数', 'list' => $list3];
163
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($tuikuanmoney), 'name' => '复购区订单总数', 'list' => $list4];
164
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($tuikuancount), 'name' => '三方平台订单总数', 'list' => $list5];
165
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($tuikuanren), 'name' => '线下订单总数', 'list' => $list6];
166
+        return $data;
167
+    }
168
+
169
+    /**
170
+     * 用户概况
171
+     * @param int $mer_id
172
+     * @return array
173
+     * @throws \Exception
174
+     */
175
+    public function user_overview($mer_id = 0)
176
+    {
177
+        $where = "1=1 ";
178
+        if ($mer_id) {
179
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
180
+            $userRepository = app()->make(UserRepository::class);
181
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
182
+            $chilid_userids_string = "1";
183
+            if (!empty($chilid_userids)) {
184
+                $chilid_userids_string = implode(',',$chilid_userids);
185
+            }
186
+            $where .= "and uid in ({$chilid_userids_string})";
187
+        }
37 188
         $type = input('type', 1);
38 189
         $day = input('day', '');
39 190
 
40 191
         if ($type == 1 and $day != '') {
41
-            $where .= " and DATE(pay_time) = '" . $day . "'";
192
+            $where .= " and DATE(create_time) = '" . $day . "'";
42 193
         }
43 194
         if ($type == 2 and $day != '') {
44 195
             $date = new \DateTime($day);
45 196
             $year = $date->format('Y');
46 197
             $month = $date->format('m');
198
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
199
+        }
200
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
201
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
47 202
 
48
-            $where .= " and YEAR(pay_time) = " . $year . " AND MONTH(pay_time) = " . $month;
203
+        $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
204
+        $maker = array_column($maker, 'count', 'k');
205
+
206
+
207
+        $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[1] ?? 0), 'name' => '消费者'];
208
+        $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[2] ?? 0), 'name' => '业务员'];
209
+        $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[3] ?? 0), 'name' => '业务经理'];
210
+        $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[5] ?? 0), 'name' => '初级合伙人'];
211
+        $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[6] ?? 0), 'name' => '中级合伙人'];
212
+
213
+        $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[7] ?? 0), 'name' => '高级合伙人'];
214
+        $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[8] ?? 0), 'name' => '董事'];
215
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_user` where {$where} and originator_id_old > 0");
216
+        $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '联创'];
217
+        $maker = Db::query("SELECT count(user_id) as count FROM `rrx_old_user_stock` where {$where}");
218
+        $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '股权'];
219
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
220
+        $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '商户'];
221
+
222
+        $res['left'] = $data;
223
+
224
+        return $res;
225
+    }
226
+
227
+
228
+
229
+    /**
230
+     * 会员概况
231
+     * @param int $mer_id
232
+     * @return array
233
+     * @throws \Exception
234
+     */
235
+    public function member_overview($mer_id = 0)
236
+    {
237
+        $where = "1=1 ";
238
+        if ($mer_id) {
239
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
240
+            $userRepository = app()->make(UserRepository::class);
241
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
242
+            $chilid_userids_string = "1";
243
+            if (!empty($chilid_userids)) {
244
+                $chilid_userids_string = implode(',',$chilid_userids);
245
+            }
246
+            $where .= "and uid in ({$chilid_userids_string})";
247
+        }
248
+        $type = input('type', 1);
249
+        $day = input('day', '');
250
+
251
+        if ($type == 1 and $day != '') {
252
+            $where .= " and DATE(create_time) = '" . $day . "'";
49 253
         }
50
-        $xianshangzhifu = Db::name('store_order')->where($where)->whereIn('pay_type', [0, 1])->sum('pay_price');
51
-        $xianshangzhifu_xuni = Db::name('store_order')->where($where)->where('pay_type', 0)->sum('pay_price');
52
-        $hongjifenxiaofei = Db::name('store_order')->where($where)->where("pay_type", 5)->sum('pay_price');
53
-//        echo Db::name('store_order')->getLastSql();
54
-
55
-        $chengjiaomoney = decimal2($xianshangzhifu + $hongjifenxiaofei);
56
-        $list1[] = ['count' => set_price_rtrim($xianshangzhifu), 'name' => '线上支付金额'];
57
-        if (!$mer_id) {
58
-            $list1[] = ['count' => set_price_rtrim($xianshangzhifu_xuni), 'name' => '虚拟支付金额'];
254
+        if ($type == 2 and $day != '') {
255
+            $date = new \DateTime($day);
256
+            $year = $date->format('Y');
257
+            $month = $date->format('m');
258
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
59 259
         }
60
-        $list1[] = ['count' => 0, 'name' => '代付金额'];
61
-        $xianshangzhifunum = Db::name('store_order')->where($where)->whereIn('pay_type', [0, 1])->count();
62
-        $xianshangzhifunum_xuni = Db::name('store_order')->where($where)->where('pay_type', 0)->count();
63
-        $hongjifenxiaofeinum = Db::name('store_order')->where($where)->where("pay_type", 5)->count();
260
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
261
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
262
+        $shopPartnerCount = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where mer_id={$mer_id} and is_shop_partner=1 group by user_group");
64 263
 
65
-        $chengjiaocount = $xianshangzhifunum + $hongjifenxiaofeinum;
264
+        $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
265
+        $maker = array_column($maker, 'count', 'k');
66 266
 
67
-        $list2[] = ['count' => $xianshangzhifunum, 'name' => '线上支付订单量'];
68
-        if (!$mer_id) {
69
-            $list2[] = ['count' => $xianshangzhifunum_xuni, 'name' => '虚拟支付订单量'];
267
+        $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
268
+        $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
269
+
270
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员总人数'];
271
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增会员'];
272
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '被冻结会员数'];
273
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区总业绩'];
274
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区上周总业绩'];
275
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区本周总业绩'];
276
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区今日总业绩'];
277
+
278
+        $res['left'][] = $data;
279
+        return $res;
280
+    }
281
+
282
+
283
+
284
+
285
+    /**
286
+     * pv概况
287
+     * @param int $mer_id
288
+     * @return array
289
+     * @throws \Exception
290
+     */
291
+    public function pv_overview($mer_id = 0)
292
+    {
293
+        $where = "1=1 ";
294
+        if ($mer_id) {
295
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
296
+            $userRepository = app()->make(UserRepository::class);
297
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
298
+            $chilid_userids_string = "1";
299
+            if (!empty($chilid_userids)) {
300
+                $chilid_userids_string = implode(',',$chilid_userids);
301
+            }
302
+            $where .= "and uid in ({$chilid_userids_string})";
70 303
         }
71
-        $list2[] = ['count' => 0, 'name' => '代付订单量'];
72
-        $xianshangzhifuren = Db::name('store_order')->where($where)->whereIn('pay_type', [0, 1])->group('uid')->count();
73
-        $xianshangzhifuren_xuni = Db::name('store_order')->where($where)->where('pay_type', 0)->group('uid')->count();
74
-        $hongjifenxiaofeiren = Db::name('store_order')->where($where)->where("pay_type", 5)->group('uid')->count();
75
-
76
-        $chengjiaoren = Db::name('store_order')->where($where)->whereIn('pay_type', [0, 1, 5])->group('uid')->count();
77
-        $list3[] = ['count' => set_price_rtrim($xianshangzhifuren), 'name' => '线上支付人数'];
78
-        if (!$mer_id) {
79
-            $list3[] = ['count' => set_price_rtrim($xianshangzhifuren_xuni), 'name' => '虚拟支付人数'];
304
+        $type = input('type', 1);
305
+        $day = input('day', '');
306
+
307
+        if ($type == 1 and $day != '') {
308
+            $where .= " and DATE(create_time) = '" . $day . "'";
80 309
         }
81
-        $list3[] = ['count' => 0, 'name' => '代付人数'];
82
-
83
-
84
-        $xianshangtuikuan = Db::name('store_order')->where($where)->where('status', -1)->sum('pay_price');
85
-
86
-        $tuikuanmoney = $xianshangtuikuan;
87
-        $list4 = array(
88
-            array('count' => $xianshangtuikuan, 'name' => '线上支付退单'),
89
-            array('count' => 0, 'name' => '代付退单'),
90
-        );
91
-        $xianshangzhifutuinum = Db::name('store_order')->where($where)->where('status', -1)->count();
92
-
93
-        $tuikuancount = $xianshangzhifutuinum;
94
-        $list5 = array(
95
-            array('count' => set_price_rtrim($xianshangzhifutuinum), 'name' => '线上支付退单量'),
96
-            array('count' => 0, 'name' => '代付退单量'),
97
-        );
98
-        $xianshangzhifutuiremn = Db::name('store_order')->where($where)->where('status', -1)->group('uid')->count();
99
-
100
-        $tuikuanren = $xianshangzhifutuiremn;
101
-        $list6 = array(
102
-            array('count' => set_price_rtrim($xianshangzhifutuiremn), 'name' => '线上支付退单人数'),
103
-            array('count' => 0, 'name' => '代付退单数'),
104
-        );
105
-
106
-
107
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($chengjiaomoney), 'name' => '成交金额', 'list' => $list1];
108
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($chengjiaocount), 'name' => '成交订单量', 'list' => $list2];
109
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($chengjiaoren), 'name' => '支付人数', 'list' => $list3];
110
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($tuikuanmoney), 'name' => '退款金额', 'list' => $list4];
111
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($tuikuancount), 'name' => '退款订单量', 'list' => $list5];
112
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($tuikuanren), 'name' => '退款人数', 'list' => $list6];
113
-        return $data;
310
+        if ($type == 2 and $day != '') {
311
+            $date = new \DateTime($day);
312
+            $year = $date->format('Y');
313
+            $month = $date->format('m');
314
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
315
+        }
316
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
317
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
318
+
319
+        $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
320
+        $maker = array_column($maker, 'count', 'k');
321
+
322
+        $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
323
+        $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
324
+
325
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '平台总PV'];
326
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员存量总PV'];
327
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周新增PV总量'];
328
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增PV总量'];
329
+    
330
+        $res['left'][] = $data;
331
+        return $res;
114 332
     }
115 333
 
334
+
335
+
336
+
116 337
     /**
117
-     * 用户概况
338
+     * vr概况
118 339
      * @param int $mer_id
119 340
      * @return array
120 341
      * @throws \Exception
121 342
      */
122
-    public function user_overview($mer_id = 0)
343
+    public function vr_overview($mer_id = 0)
123 344
     {
124 345
         $where = "1=1 ";
125 346
         if ($mer_id) {
@@ -146,7 +367,6 @@ class FinanceRepository extends BaseRepository
146 367
         }
147 368
         $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
148 369
         $dataQuery = array_column($dataQuery, 'count', 'user_group');
149
-        $shopPartnerCount = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where mer_id={$mer_id} and is_shop_partner=1 group by user_group");
150 370
 
151 371
         $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
152 372
         $maker = array_column($maker, 'count', 'k');
@@ -154,35 +374,78 @@ class FinanceRepository extends BaseRepository
154 374
         $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
155 375
         $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
156 376
 
157
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[1] ?? 0), 'name' => '消费者'];
158
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[2] ?? 0), 'name' => '业务员'];
159
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[3] ?? 0), 'name' => '业务经理'];
160
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[5] ?? 0), 'name' => '初级合伙人'];
161
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[6] ?? 0), 'name' => '中级合伙人'];
162
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[7] ?? 0), 'name' => '高级合伙人'];
163
-        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[8] ?? 0), 'name' => '董事'];
164
-        $list1 = array(
165
-            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-2'] ?? 0), 'name' => '集团会员'),//is_show=2
166
-            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-1'] ?? 0), 'name' => '电商创客'),
167
-            array('className' => 'el-icon-s-goods', 'count' => intval($userByCodeCount['temp'] ?? 0), 'name' => '激活创客'),
168
-        );
377
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '平台总VR'];
378
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员存量总VR'];
379
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周新增VR总量'];
380
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增VR总量'];
381
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员消耗总VR'];
382
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周消耗VR总量'];
383
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日消耗VR总量'];
384
+   
385
+        $res['left'][] = $data;
386
+        return $res;
387
+    }
169 388
 
389
+
390
+
391
+    /**
392
+     * 积分概况
393
+     * @param int $mer_id
394
+     * @return array
395
+     * @throws \Exception
396
+     */
397
+    public function jifen_overview($mer_id = 0)
398
+    {
399
+        $where = "1=1 ";
170 400
         if ($mer_id) {
171
-//            $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($shopPartnerCount), 'name' => '创客合伙人'];
172
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[4] ?? 0), 'name' => '创客'];
401
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
402
+            $userRepository = app()->make(UserRepository::class);
403
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
404
+            $chilid_userids_string = "1";
405
+            if (!empty($chilid_userids)) {
406
+                $chilid_userids_string = implode(',',$chilid_userids);
407
+            }
408
+            $where .= "and uid in ({$chilid_userids_string})";
173 409
         }
174
-        $res['left'][] = $data;
175
-        // $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim(intval($maker['4-2'] ?? 0) + intval($maker['4-1'] ?? 0) + intval($userByCodeCount['temp'] ?? 0)), 'name' => '创客'];
410
+        $type = input('type', 1);
411
+        $day = input('day', '');
176 412
 
177
-        $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
178
-        $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '创客'];
413
+        if ($type == 1 and $day != '') {
414
+            $where .= " and DATE(create_time) = '" . $day . "'";
415
+        }
416
+        if ($type == 2 and $day != '') {
417
+            $date = new \DateTime($day);
418
+            $year = $date->format('Y');
419
+            $month = $date->format('m');
420
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
421
+        }
422
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
423
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
424
+
425
+        $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
426
+        $maker = array_column($maker, 'count', 'k');
427
+
428
+        $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
429
+        $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
430
+
431
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '平台总积分'];
432
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员存量总积分'];
433
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周新增积分总量'];
434
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增积分总量'];
435
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员消耗总积分'];
436
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周消耗积分总量'];
437
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日消耗积分总量'];
438
+
439
+
440
+        $res['left'][] = $data;
179 441
 
180 442
         return $res;
181 443
     }
182 444
 
445
+
446
+
183 447
     public function jieyu($type, $day, $mer_id = 0)
184 448
     {
185
-
186 449
         if ($mer_id) {
187 450
             $uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
188 451
             $where = "mer_id = " . $mer_id . " and paid = 1";
@@ -272,7 +535,15 @@ class FinanceRepository extends BaseRepository
272 535
             $vr = Db::name('user_sign_vr')
273 536
                 ->whereBetween('settlement_time', [date('Y-m-d H:i:s', strtotime($day)), date('Y-m-d H:i:s', strtotime($day) + 24 * 3600)])
274 537
                 ->sum('number');
538
+            
539
+            $suoke = Db::name('user_bill')
540
+            ->where('commission_type', 7)
541
+            ->whereBetween('create_time', [date('Y-m-d H:i:s', strtotime($day)), date('Y-m-d H:i:s', strtotime($day) + 24 * 3600)])
542
+            ->sum('number');
275 543
 
544
+            $pv = Db::name('user_pv_log')
545
+            ->whereBetween('settlement_time', [date('Y-m-d H:i:s', strtotime($day)), date('Y-m-d H:i:s', strtotime($day) + 24 * 3600)])
546
+            ->sum('pv');
276 547
 
277 548
         } else if ($type == 2 and $day != '') {
278 549
             $date = new \DateTime($day);
@@ -355,6 +626,15 @@ class FinanceRepository extends BaseRepository
355 626
                 ->whereBetween('settlement_time', [date('Y-m-01 00:00:00', strtotime($year)), date('Y-m-d H:i:s', strtotime($lastDay) + 24 * 3600)])
356 627
                 ->sum('number');
357 628
 
629
+            $suoke = Db::name('user_bill')
630
+            ->where('commission_type', 7)
631
+            ->whereBetween('create_time', [date('Y-m-01 00:00:00', strtotime($year)), date('Y-m-d H:i:s', strtotime($lastDay) + 24 * 3600)])
632
+            ->sum('number');
633
+
634
+            $pv = Db::name('user_pv_log')
635
+            ->whereBetween('settlement_time', [date('Y-m-01 00:00:00', strtotime($year)), date('Y-m-d H:i:s', strtotime($lastDay) + 24 * 3600)])
636
+            ->sum('pv');
637
+
358 638
         } else {
359 639
             $ruzhang = Db::name('enterprise_platform_income_detail')->where("deal_time <'" . date('Y-m-d H:i:s') . "'")
360 640
                 ->when($mer_id, function ($query) use ($mer_id) {
@@ -415,14 +695,20 @@ class FinanceRepository extends BaseRepository
415 695
 
416 696
             $vr = Db::name('user_sign_vr')
417 697
             ->sum('number');
698
+
699
+            $suoke = Db::name('user_bill')
700
+            ->where('commission_type', 7)
701
+            ->sum('number');
702
+
703
+            $pv = Db::name('user_pv_log')
704
+            ->sum('pv');
418 705
         }
419 706
 
420 707
 
421 708
         $yingyemoney = Db::name('store_order')->where($where)->sum('pay_price');
422 709
         $hf_fee_amt = Db::name('store_order')->where($where_order)->sum('hf_fee_amt');//汇付手续费
423 710
 
424
-        return compact('yingyemoney', 'hf_fee_amt', 'my_money', 'tixinan', 'ruzhang', 'shouyi', 'jieyu', 'integral', 'yanglao', 'gongxian', 'jingdou', 'hongbao', 'fugou', 'vr');
425
-
711
+        return compact('yingyemoney', 'hf_fee_amt', 'my_money', 'tixinan', 'ruzhang', 'shouyi', 'jieyu', 'integral', 'yanglao', 'gongxian', 'jingdou', 'hongbao', 'fugou', 'vr', 'suoke', 'pv');
426 712
     }
427 713
 
428 714
     /**

+ 1 - 1
app/common/repositories/merchant/order/OrderMerchantRepository.php

@@ -1664,7 +1664,7 @@ class OrderMerchantRepository extends BaseRepository
1664 1664
 
1665 1665
         //商户得到的(京豆和贡献值奖励的倍,后台设置)
1666 1666
         $jd = bcmul($divisible_commission, $mer_jd, 2);
1667
-        if ($jd >= 0.01) {
1667
+        if ($jd >= 0.01) {  
1668 1668
             $jd_data = [
1669 1669
                 "uid"           =>$mer_data["uid"],
1670 1670
                 "mer_id"        =>$order["mer_id"],

+ 22 - 20
app/common/repositories/store/order/StoreOrderRepository.php

@@ -3827,7 +3827,7 @@ class StoreOrderRepository extends BaseRepository
3827 3827
             $yongjin = $pvfee * $yongjinbili / 100;
3828 3828
 
3829 3829
             // 佣金百分之90进入佣金池  佣金百分之10进入复购金
3830
-            $tuiguanyongjin = roundOptimize($yongjin * 0.9, 2);
3830
+            $tuiguanyongjin = $this->roundOptimize($yongjin * 0.9, 2);
3831 3831
             $tuiguanfugou = $yongjin;//复购金赠送函数里面有计算百分之10
3832 3832
 
3833 3833
             //end会费
@@ -6603,7 +6603,7 @@ class StoreOrderRepository extends BaseRepository
6603 6603
 //        $tuijian_yongjin=bcmul($divisible_commission,$yonghu_tuijian,2);
6604 6604
         $tuijian_yongjin = sprintf("%01.2f", $divisible_commission * $yonghu_tuijian * 0.01);
6605 6605
         if ($tuijian_yongjin > 0.01) {
6606
-            $mark = "用户在储蓄宝消费获得" . $tuijian_yongjin . '佣金';
6606
+            $mark = "用户在幸福宝消费获得" . $tuijian_yongjin . '佣金';
6607 6607
             $title = "佣金";
6608 6608
             $source = 0;
6609 6609
             $commission_type = 3;
@@ -7688,7 +7688,7 @@ class StoreOrderRepository extends BaseRepository
7688 7688
         $insterAll = array(
7689 7689
             'money' => $amount_queshao,
7690 7690
             'member_id' => '',
7691
-            'mark' => '一壶茶应得 (' . set_price_rtrim(decimal2($amount_queshao + $amount_yihucha)) . ') 实得(' . set_price_rtrim($amount_yihucha) . ') 给了储蓄保(' . set_price_rtrim($amount_queshao) . ')',
7691
+            'mark' => '一壶茶应得 (' . set_price_rtrim(decimal2($amount_queshao + $amount_yihucha)) . ') 实得(' . set_price_rtrim($amount_yihucha) . ') 给了幸福宝(' . set_price_rtrim($amount_queshao) . ')',
7692 7692
             'order_id' => $order_id
7693 7693
         );
7694 7694
 
@@ -8594,8 +8594,8 @@ class StoreOrderRepository extends BaseRepository
8594 8594
                 $_order = [
8595 8595
                     'commission_rate' => (float)$merchantRepository->get($cartInfo['mer_id'])->mer_commission_rate,
8596 8596
                     'order_type' => in_array($cartInfo['mer_id'], $takes) == 1 ? 1 : 0,
8597
-                    'extension_one' => 0,
8598
-                    'extension_two' => 0,
8597
+                    'extension_one' => $cartInfo['list'][0]['productAttr']['extension_one'] ?? 0,
8598
+                    'extension_two' => $cartInfo['list'][0]['productAttr']['extension_two'] ?? 0,
8599 8599
                     'orderInfo' => $cartInfo['order'],
8600 8600
                     'cartInfo' => $cartInfo['list'],
8601 8601
                     'order_sn' => $this->getNewOrderId() . ($k + 1),
@@ -9306,7 +9306,9 @@ class StoreOrderRepository extends BaseRepository
9306 9306
         ];
9307 9307
         // 当状态为1时是实时结算
9308 9308
         if($status == 1) {
9309
-            Db::name('user')->where('uid', $uid)->inc('pv', (float)$pv)->update();
9309
+            // Db::name('user')->where('uid', $uid)->inc('pv', (float)$pv)->update();
9310
+            $con_data = Db::name('user')->where("uid", $uid)->find();
9311
+            Db::name('user')->where("uid", $uid)->update(['pv' => ($con_data['pv']?:0) + $pv]);
9310 9312
             $pv_data['settlement_time'] = date('Y-m-d H:i:s');
9311 9313
         }
9312 9314
         Db::name("user_pv_log")->insert($pv_data);//添加pv记录
@@ -9646,7 +9648,7 @@ class StoreOrderRepository extends BaseRepository
9646 9648
 
9647 9649
                         //推广养老金
9648 9650
                         //推广佣金
9649
-                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9651
+                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9650 9652
                         // 贡献值
9651 9653
                         $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广精彩生活商品赠送贡献值");
9652 9654
                         //积分
@@ -9663,7 +9665,7 @@ class StoreOrderRepository extends BaseRepository
9663 9665
                         //积分
9664 9666
                         $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 11, "推广精彩生活区商品赠送积分");
9665 9667
                         // //推广佣金
9666
-                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9668
+                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9667 9669
                         //养老金
9668 9670
                         $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
9669 9671
                     }
@@ -9678,7 +9680,7 @@ class StoreOrderRepository extends BaseRepository
9678 9680
                         $yj_amount_90 = bcmul($pv * 0.9, 0.05, 2);
9679 9681
                         $fgj_amount_10 = bcmul($pv * 0.1, 0.05, 2);//推广者的佣金抽10%到个人复购金
9680 9682
                         //推广佣金
9681
-                        $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9683
+                        $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9682 9684
                     }
9683 9685
                 }
9684 9686
             }
@@ -9753,7 +9755,7 @@ class StoreOrderRepository extends BaseRepository
9753 9755
                 //养老金
9754 9756
                 $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
9755 9757
                 //佣金
9756
-                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id']);
9758
+                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id']);
9757 9759
                 //复购金
9758 9760
                 $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9759 9761
             }
@@ -9766,7 +9768,7 @@ class StoreOrderRepository extends BaseRepository
9766 9768
                 $this->con_log($spread_data['uid'], bcmul($gx_jf, 0.3, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1);
9767 9769
                 $this->score_log($spread_data['uid'], bcmul($gx_jf, $rate, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9768 9770
                 //推广佣金
9769
-                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id']);
9771
+                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id']);
9770 9772
             }
9771 9773
 
9772 9774
             if ($spread_data_old != 0) {
@@ -9780,7 +9782,7 @@ class StoreOrderRepository extends BaseRepository
9780 9782
                 //养老金
9781 9783
                 $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . bcmul($pv, 0.035, 2), $store_order_data['mer_id']);
9782 9784
                 //佣金
9783
-                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id']);
9785
+                $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id']);
9784 9786
                 //复购金
9785 9787
                 $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9786 9788
 
@@ -9804,7 +9806,7 @@ class StoreOrderRepository extends BaseRepository
9804 9806
                     $fgj_amount_10 = bcmul($pv, 0.035, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9805 9807
                     $this->fugou_user_log($merchant_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9806 9808
                     //推广佣金
9807
-                    $this->bill_user_log($merchant_data['uid'], bcmul($pv, 0.35, 2), $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . round($pv * 0.35, 2), $store_order_data['mer_id']);
9809
+                    $this->bill_user_log($merchant_data['uid'], bcmul($pv, 0.35, 2), $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id']);
9808 9810
                 }
9809 9811
             }
9810 9812
 
@@ -9877,7 +9879,7 @@ class StoreOrderRepository extends BaseRepository
9877 9879
                         //积分
9878 9880
                         $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 12, "推广商贸区商品赠送积分");
9879 9881
                         //推广佣金
9880
-                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9882
+                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9881 9883
                         //养老金
9882 9884
                         $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
9883 9885
                     }
@@ -9892,7 +9894,7 @@ class StoreOrderRepository extends BaseRepository
9892 9894
                         $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
9893 9895
 
9894 9896
                         //推广佣金
9895
-                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9897
+                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9896 9898
                         // 贡献值
9897 9899
                         $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 12, "推广商贸区商品赠送贡献值");
9898 9900
                         // 积分
@@ -9910,11 +9912,11 @@ class StoreOrderRepository extends BaseRepository
9910 9912
                         $fgj_amount_10 = bcmul($pv * 0.1, 0.05, 2);//推广者的佣金抽10%到个人复购金
9911 9913
                         $this->fugou_user_log($merchant_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
9912 9914
                         //推广佣金
9913
-                        $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
9915
+                        $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9914 9916
                     }
9915 9917
                     /** @var OrderMerchantRepository $orderMerchantRepository */
9916 9918
                     $orderMerchantRepository = app()->make(OrderMerchantRepository::class);
9917
-                    $jdAndGonxianConfig = $orderMerchantRepository->getMerchantContribution($store_order_data['extension_two']);
9919
+                    $jdAndGonxianConfig = $orderMerchantRepository->getMerchantContribution($store_order_data['extension_one']);
9918 9920
 
9919 9921
                     //商户获得贡献值  ---- 3月29日  商户不再获得贡献值 改为获得分润值
9920 9922
 //                    if ($concession_pri >= 0.01) {
@@ -9939,8 +9941,8 @@ class StoreOrderRepository extends BaseRepository
9939 9941
 //                    }
9940 9942
 
9941 9943
                     //商户获得京豆
9942
-                    if ($concession_pri >= 0.01) {
9943
-                        $jd = bcmul($concession_pri, $jdAndGonxianConfig['jd'], 2);
9944
+                    $jd = bcmul($concession_pri, $jdAndGonxianConfig['jd'], 2);
9945
+                    if ($jd >= 0.01) {
9944 9946
                         $jd_data = [
9945 9947
                             "uid" => $merchant_data["uid"],
9946 9948
                             "mer_id" => $user_data['mer_id'],
@@ -9949,7 +9951,7 @@ class StoreOrderRepository extends BaseRepository
9949 9951
                             "status" => -1,
9950 9952
                             "order_type" => 2,
9951 9953
                             "order_id" => $store_order_data['order_id'],
9952
-                            "mark" => "锁客商家获得京豆",
9954
+                            "mark" => "线上用户消费商家获得京豆",
9953 9955
                             "desc" => '',
9954 9956
                             "surplus" => $jd,
9955 9957
                             "type" => 1

+ 8 - 2
app/common/repositories/store/order/StoreRefundOrderRepository.php

@@ -342,8 +342,9 @@ class StoreRefundOrderRepository extends BaseRepository
342 342
      * @author Qinii
343 343
      * @day 2020-06-12
344 344
      */
345
-    public function getList(array $where, int $page, int $limit)
345
+    public function getList(array $where, int $page, int $limit,$status)
346 346
     {
347
+        if($status == 2) $where['status'] = '1,2';
347 348
         $query = $this->dao->search($where)->where('is_system_del', 0)->with(['order' => function ($query) {
348 349
             $query->field('order_id,order_sn,douhuomall');
349 350
         }, 'refundProduct.product', 'user' => function ($query) {
@@ -356,7 +357,7 @@ class StoreRefundOrderRepository extends BaseRepository
356 357
             'audit' => $this->dao->getWhereCount(['is_system_del' => 0, 'mer_id' => $where['mer_id'], 'status' => 0]),
357 358
             'refuse' => $this->dao->getWhereCount(['is_system_del' => 0, 'mer_id' => $where['mer_id'], 'status' => -1]),
358 359
             'agree' => $this->dao->getWhereCount(['is_system_del' => 0, 'mer_id' => $where['mer_id'], 'status' => 1]),
359
-            'backgood' => $this->dao->getWhereCount(['is_system_del' => 0, 'mer_id' => $where['mer_id'], 'status' => 2]),
360
+            'backgood' => $this->dao->getWhereCount(['is_system_del' => 0, 'mer_id' => $where['mer_id'], 'status' => '1,2']),
360 361
             'end' => $this->dao->getWhereCount(['is_system_del' => 0, 'mer_id' => $where['mer_id'], 'status' => 3]),
361 362
 
362 363
 
@@ -1573,5 +1574,10 @@ class StoreRefundOrderRepository extends BaseRepository
1573 1574
             ->where('order_id', $orderId)
1574 1575
             ->where('status', -1)
1575 1576
             ->update(['status' => 0]);
1577
+
1578
+        Db::name("user_sign_jingdou")
1579
+            ->where('order_id', $orderId)
1580
+            ->where('status', -1)
1581
+            ->update(['status' => 0]);
1576 1582
     }
1577 1583
 }

+ 1 - 1
app/common/repositories/store/product/ProductRepository.php

@@ -1081,7 +1081,7 @@ class ProductRepository extends BaseRepository
1081 1081
 
1082 1082
 
1083 1083
         $productDetails = array(
1084
-            'name'     => $product ?? "储蓄保",//商品名称。需传递真实产品名称。
1084
+            'name'     => $product ?? "幸福宝",//商品名称。需传递真实产品名称。
1085 1085
             'quantity' => 1,//商品数量
1086 1086
             'amount'   => strval($price * 100),//商品单价
1087 1087
         );

+ 42 - 53
app/common/repositories/user/UserExtractRepository.php

@@ -370,22 +370,6 @@ class UserExtractRepository extends BaseRepository
370 370
                 }
371 371
 
372 372
                 $user->save();
373
-
374
-                if($type == 3){
375
-                    //加入红包提现记录
376
-                   $insertdata = [
377
-                       'uid'=> $uid,
378
-                       'number' =>  $data['extract_price'],
379
-                       'surplus' => $user->hongbao,
380
-                       'mark' => '红包提现',
381
-                       'type' => 2,
382
-                       'status' => -1,
383
-                       'addtime' => time(),
384
-                   ];
385
-                   Db::name('user_sign_hongbao')->insertGetId($insertdata);
386
-               }
387
-
388
-
389 373
                 $service_money=bcmul($data['extract_price'],'0.1',2);
390 374
                 $data['service_money']=$service_money;
391 375
                 $data['status'] = 0;
@@ -427,22 +411,6 @@ class UserExtractRepository extends BaseRepository
427 411
                     }
428 412
                 }
429 413
 
430
-
431
-                if($type == 3){
432
-                     //加入红包提现记录
433
-                    $insertdata = [
434
-                        'uid'=> $uid,
435
-                        'number' =>  $data['extract_price'],
436
-                        'surplus' => $user->hongbao,
437
-                        'mark' => '红包提现',
438
-                        'type' => 2,
439
-                        'status' => -1,
440
-                        'addtime' => time(),
441
-                    ];
442
-                    Db::name('user_sign_hongbao')->insertGetId($insertdata);
443
-                }
444
-
445
-
446 414
 //                    if($extract_price_yihu>0){
447 415
                 $insertAll[]=array(
448 416
                     'extract_id'=>$extract->extract_id,
@@ -451,7 +419,7 @@ class UserExtractRepository extends BaseRepository
451 419
                     'extract_price'=> $extract_price_yihu,
452 420
                     'service_money'=> $service_money_yihu,
453 421
                     'order_sn'=> $data['order_sn'],
454
-                    'type'=> 1,//0- 储蓄保 1-一壶茶
422
+                    'type'=> 1,//0- 幸福宝 1-一壶茶
455 423
                 );
456 424
 //                    }
457 425
                 $insertAll[]=array(
@@ -461,7 +429,7 @@ class UserExtractRepository extends BaseRepository
461 429
                     'extract_price'=> ($data['extract_price']-$extract_price_yihu),
462 430
                     'service_money'=> ($data['service_money']-$service_money_yihu),
463 431
                     'order_sn'=> $data['order_sn'],
464
-                    'type'=> 0,//0- 储蓄保 1-一壶茶
432
+                    'type'=> 0,//0- 幸福宝 1-一壶茶
465 433
                 );
466 434
                 DB::name('user_extract_item')->insertAll($insertAll);
467 435
 
@@ -498,9 +466,9 @@ class UserExtractRepository extends BaseRepository
498 466
     {
499 467
 
500 468
         Db::transaction(function()use($id,$data){
469
+            $extract = $this->dao->getWhere(['extract_id' => $id]);
470
+            $user = app()->make(UserRepository::class)->get($extract['uid']);
501 471
             if($data['status'] == '-1'){
502
-                $extract = $this->dao->getWhere(['extract_id' => $id]);
503
-                $user = app()->make(UserRepository::class)->get($extract['uid']);
504 472
                 if (!empty($extract['mer_id'])) {
505 473
                     //商户提现逻辑处理
506 474
                     $mer = app()->make(MerchantRepository::class)->get($extract['mer_id']);
@@ -510,22 +478,30 @@ class UserExtractRepository extends BaseRepository
510 478
                 } else {
511 479
                     //用户提现逻辑处理
512 480
                     if($extract['types']==1){
513
-                        $brokerage_price = bcadd($user['brokerage_price'] ,$extract['extract_price'],2);
514
-                        //返回余额
515
-                        $user->brokerage_price = $brokerage_price;
481
+                        if($extract['type']==3){
482
+                            $user->hongbao = bcadd($user->hongbao,$extract['extract_price'],2);
483
+                        }else {
484
+                            $brokerage_price = bcadd($user['brokerage_price'] ,$extract['extract_price'],2);
485
+                            //返回余额
486
+                            $user->brokerage_price = $brokerage_price;
487
+                        }
516 488
                     }else{
517
-                        $member_brokerage_price = bcadd($user['member_brokerage_price'] ,$extract['extract_price'],2);
518
-                        //返回余额
519
-                        $user->member_brokerage_price = $member_brokerage_price;
520
-                        Db::name('user_rich')->where('uid',$extract['uid'])->inc('red', $extract['extract_price'])->update();
521
-                        Db::name('user_rich_log')->insert([
522
-                            'uid'      => $extract['uid'],
523
-                            'red'      => $extract['extract_price'],
524
-                            'pm'       => 1,
525
-                            'time'     => time(),
526
-                            'order_id' => 0,
527
-                            'mark'     => '提现失败返还红积分'
528
-                        ]);
489
+                        if($extract['type']==3){
490
+                            $user->hongbao = bcadd($user->hongbao,$extract['extract_price'],2);
491
+                        }else{
492
+                            $member_brokerage_price = bcadd($user['member_brokerage_price'] ,$extract['extract_price'],2);
493
+                            //返回余额
494
+                            $user->member_brokerage_price = $member_brokerage_price;
495
+                            Db::name('user_rich')->where('uid',$extract['uid'])->inc('red', $extract['extract_price'])->update();
496
+                            Db::name('user_rich_log')->insert([
497
+                                'uid'      => $extract['uid'],
498
+                                'red'      => $extract['extract_price'],
499
+                                'pm'       => 1,
500
+                                'time'     => time(),
501
+                                'order_id' => 0,
502
+                                'mark'     => '提现失败返还红积分'
503
+                            ]);
504
+                        }
529 505
                     }
530 506
                     $user->save();
531 507
                 }
@@ -534,6 +510,19 @@ class UserExtractRepository extends BaseRepository
534 510
 //                $user->save();
535 511
 //                Db::name('user_sign_score')->where("order_type","extract") -> where("order_id",$id) -> update(['status'=>0]);
536 512
             }else{
513
+                if($extract['type']==3){
514
+                    //加入红包出账记录
515
+                    $insertdata = [
516
+                        'uid'=> $user->uid,
517
+                        'number' =>  $extract['extract_price'],
518
+                        'surplus' => $user->hongbao,
519
+                        'mark' => '红包提现',
520
+                        'type' => 2,
521
+                        'status' => 1,
522
+                        'addtime' => time(),
523
+                    ];
524
+                    Db::name('user_sign_hongbao')->insertGetId($insertdata);
525
+                }
537 526
                 //积分扣除
538 527
 //                Db::name('user_sign_score')->where("order_type","extract") -> where("order_id",$id) -> update(['status'=>1]);
539 528
             }
@@ -908,11 +897,11 @@ class UserExtractRepository extends BaseRepository
908 897
             $aop->isCheckAlipayPublicCert = true;
909 898
             $order_title='提现';
910 899
             if($userdata['withdrawal_type']==1){
911
-                $order_title='储蓄保提现';
900
+                $order_title='幸福宝提现';
912 901
                 $userdata['extract_price']=bcsub($userdata['extract_price'],$userdata['service_money']);
913 902
             }elseif($userdata['withdrawal_type']==2){
914 903
                 $mer_name=Db::name('merchant')->where('mer_id',$userdata['mer_id'])->value('mer_name');
915
-                $order_title='储蓄保-'.$mer_name.'提现';
904
+                $order_title='幸福宝-'.$mer_name.'提现';
916 905
                 $userdata['extract_price']=bcsub($userdata['extract_price'],$userdata['service_money']);
917 906
             }
918 907
 //            Db::name('log')->insert(['data'=>'AopCertClient']);

+ 374 - 91
app/common/repositories/user/UserRepository.php

@@ -2377,11 +2377,11 @@ class UserRepository extends BaseRepository
2377 2377
 
2378 2378
                 if($v['source'] == 0){
2379 2379
                     if($v['commission_type'] == 9){
2380
-                        $this -> getContent('channel_order',$v['order_sn'],'储蓄保',$v['status'],$v['commission_type'],$v);
2380
+                        $this -> getContent('channel_order',$v['order_sn'],'幸福宝',$v['status'],$v['commission_type'],$v);
2381 2381
                     }elseif($v['commission_type'] == 10){
2382
-                        $this -> getContent('merchant_annual_cost_order',$v['order_sn'],'储蓄保',$v['status'],$v['commission_type'],$v);
2382
+                        $this -> getContent('merchant_annual_cost_order',$v['order_sn'],'幸福宝',$v['status'],$v['commission_type'],$v);
2383 2383
                     }else{
2384
-                        $this -> getContent('store_order',$v['order_sn'],'储蓄保',$v['status'],$v['commission_type'],$v,$v['create_time']);
2384
+                        $this -> getContent('store_order',$v['order_sn'],'幸福宝',$v['status'],$v['commission_type'],$v,$v['create_time']);
2385 2385
                     }
2386 2386
                 }else{
2387 2387
                     $uid=Db::name("store_order")->where("order_sn",$v["order_sn"])->value("uid");
@@ -2492,7 +2492,7 @@ class UserRepository extends BaseRepository
2492 2492
     }
2493 2493
     public function get_yanglao($member_id){
2494 2494
 
2495
-       
2495
+
2496 2496
         $data = Db::name("user")
2497 2497
             ->where("uid",$member_id)
2498 2498
             ->field("wechat_user_id,card_id,ali_user_id,annuity_frozen,annuity_num,annuity,create_time,birthday,birthday60,card_number,annuity_yiqu,pay_price")
@@ -2553,7 +2553,7 @@ class UserRepository extends BaseRepository
2553 2553
 //        $data["yinghang"]='https://app.bjtdba.com/uploads/def/20201021/8cb66944101287b8ac9c9b9fb1b13a79.png';
2554 2554
         $data["add_up"] = 0.00;
2555 2555
 
2556
-     
2556
+
2557 2557
 
2558 2558
         return $data;
2559 2559
     }
@@ -2587,7 +2587,7 @@ class UserRepository extends BaseRepository
2587 2587
 
2588 2588
         return $age;
2589 2589
     }
2590
-    public function yanglaolog($where,$page=1, $limit=10,$month=''){
2590
+    public function yanglaolog($where,$page=1, $limit=10,$month='',$is_shixiao = 0){
2591 2591
         $where1 = [];
2592 2592
         if(!empty($where)){
2593 2593
             foreach($where as $key => $value){
@@ -2602,7 +2602,10 @@ class UserRepository extends BaseRepository
2602 2602
             ->when($month!='',function ($q) use ($month){
2603 2603
                 $q->whereLike('a.create_time',$month.'%');
2604 2604
             });
2605
-        $query -> where('a.status','<>','-1');
2605
+
2606
+        if($is_shixiao == 0){
2607
+            $query -> where('a.status','<>','-1');
2608
+        }
2606 2609
         $query_sql1 = clone $query;
2607 2610
         $query_sql2 = clone $query;
2608 2611
         $query_sql3 = clone $query;
@@ -2664,7 +2667,7 @@ class UserRepository extends BaseRepository
2664 2667
                     $v['title']='人工减少佣金';
2665 2668
                 }
2666 2669
             }else{
2667
-                $v['title']='储蓄保-佣金提现';
2670
+                $v['title']='幸福宝-佣金提现';
2668 2671
             }
2669 2672
             if($v['bank_info']!=''){
2670 2673
                 $bank_info=json_decode($v['bank_info'],true);
@@ -2700,7 +2703,7 @@ class UserRepository extends BaseRepository
2700 2703
                     $v['title']='人工减少佣金';
2701 2704
                 }
2702 2705
             }else{
2703
-                $v['title']='储蓄保-佣金提现';
2706
+                $v['title']='幸福宝-佣金提现';
2704 2707
             }
2705 2708
             if($v['bank_info']!=''){
2706 2709
                 $bank_info=json_decode($v['bank_info'],true);
@@ -3270,9 +3273,9 @@ class UserRepository extends BaseRepository
3270 3273
         $lowerLevelNumMin = min($lowerLevelNumList);
3271 3274
         // 获取需要 递归最深的层数,比如 高级合伙人需要递归10层 普通用户需要递归一层
3272 3275
         $needLower = 0;
3273
-        // 0 代表要递归无限极
3274
-        if($lowerLevelNumMax > 0) {
3275
-            $needLower = $lowerLevelNumMin - 1;
3276
+        // 0 代表要递归无限极 -1 代表一级也不查
3277
+        if($lowerLevelNumMin > 0) {
3278
+            $needLower = $lowerLevelNumMax;
3276 3279
         }
3277 3280
         // 最大等级限制
3278 3281
         $maxLvRestrict = 0;
@@ -3280,34 +3283,21 @@ class UserRepository extends BaseRepository
3280 3283
 
3281 3284
         // 3、获取个人贡献值
3282 3285
         $userData = $this->dao->get($uid)->toArray();
3283
-        if ($userData['is_old'] == 1 && $userData['user_group'] > 1 && empty($userData['identity_up_time'])) {
3284
-            if (empty($userData['create_time'])) {
3285
-                return $userData['user_group'];
3286
-            }
3287
-            $userData['identity_up_time'] = $userData['create_time'];
3288
-            $this->dao->update($uid, ['identity_up_time' => $userData['identity_up_time']]);
3289
-        }
3290
-        if ($userData['user_group'] == 1) {
3286
+        // 这一步骤是为了 确定用户升级时间,因为后边的团队贡献值,需要查询 用户 升级为业务员后 所产生的团队贡献值
3287
+        $determineResult = $this->determineUserUpgradeTime($uid);
3288
+        $userData['user_group'] = $determineResult['user_group'];
3289
+        $userData['identity_up_time'] = $determineResult['identity_up_time'];
3290
+        $startTime = $userData['identity_up_time'];
3291
+        $endTime = date('Y-m-d H:i:s');
3292
+
3293
+        // 如果用户身份 为 用户 或者 升级成业务员的时间为空 则无法计算它的团队贡献值
3294
+        if ($userData['user_group'] == 1 || empty($startTime)) {
3291 3295
             $maxLvRestrict = 2;
3296
+            $needLower = -1;
3292 3297
         }
3293 3298
 
3294 3299
         // 4、获取下级用户 贡献值
3295
-        $userContributionSumMap = [];
3296
-        // 获取用户的直属下级
3297
-        $uidContributeList = $this->getUidContributeListBySpreadUidList([$uid]);
3298
-        foreach ($uidContributeList as $uidContribute) {
3299
-            // 获取每个下级(部门)的个人贡献值
3300
-            $userContributionSumMap[$uidContribute['uid']] = $this->getContributionSumByLevel(
3301
-                [$uidContribute['uid']],
3302
-                $needLower,
3303
-                $userData['is_old'],
3304
-                $userData['identity_up_time'] ?? null
3305
-            );
3306
-            $userContributionSumMap[$uidContribute['uid']][0] = $uidContribute['contribute'];
3307
-            // 假设 老大的 下级是 张三和李四, 董事(最高级身份)需要循环最深的等级是 3 级    得出来的结果↓  这样是为了计算大小部门
3308
-            // $userContributionSumMap[直属下级(部门)张三] =>[0 => 张三个人贡献值, 1 => 张三所有下级用户的个人贡献值, 2 => 张三所有下级用户的下级用户贡献值]
3309
-            // $userContributionSumMap[直属下级(部门)李四] =>[0 => 李四个人贡献值, 1 => 李四所有下级用户的个人贡献值, 2 => 李四所有下级用户的下级用户贡献值]
3310
-        }
3300
+        $userContributionSumMap = $this->getSubordinateContributeByUid($uid, $startTime, $endTime, $needLower);
3311 3301
 
3312 3302
         // 5、将用户等级由低到高
3313 3303
         usort($identityList, function ($a, $b) {
@@ -3330,8 +3320,6 @@ class UserRepository extends BaseRepository
3330 3320
                         foreach ($value as $k => $v) {
3331 3321
                             if ($k < $lowerLevelNum) {
3332 3322
                                 $subordinateContribution[$key] += $v;
3333
-                            } else {
3334
-                                break;
3335 3323
                             }
3336 3324
                         }
3337 3325
                     } else {
@@ -3365,6 +3353,11 @@ class UserRepository extends BaseRepository
3365 3353
 
3366 3354
     /**
3367 3355
      * 获取该会员的所有下级会员
3356
+     * @param array $uidList
3357
+     * @return array
3358
+     * @throws DataNotFoundException
3359
+     * @throws DbException
3360
+     * @throws ModelNotFoundException
3368 3361
      */
3369 3362
     public function getUidContributeListBySpreadUidList(array $uidList)
3370 3363
     {
@@ -3384,14 +3377,15 @@ class UserRepository extends BaseRepository
3384 3377
      *                      1 表示只计算第1层(直接下级)的总贡献。
3385 3378
      *                      N 表示计算到第 N 层(包含第N层)的总贡献。
3386 3379
      * @param int $is_old
3387
-     * @param null $identity_up_time
3380
+     * @param null $startTime
3381
+     * @param null $endTime
3388 3382
      * @return array 返回一个数组,键是层级号(从1开始),值是该层级所有用户的贡献值总和。
3389 3383
      *               例如:[ 1 => 600, 2 => 1300 ]
3390 3384
      * @throws DataNotFoundException
3391 3385
      * @throws DbException
3392 3386
      * @throws ModelNotFoundException
3393 3387
      */
3394
-    public function getContributionSumByLevel(array $initialUserIds, int $maxDepth = 0, $is_old = 0, $identity_up_time = null): array
3388
+    public function getContributionSumByLevel(array $initialUserIds, int $maxDepth = 0, $is_old = 0, $startTime = null, $endTime = null): array
3395 3389
     {
3396 3390
         $levelContributions = []; // 结果数组 [level => total_contribution]
3397 3391
         if (empty($initialUserIds)) {
@@ -3432,57 +3426,52 @@ class UserRepository extends BaseRepository
3432 3426
                 break;
3433 3427
             }
3434 3428
 
3435
-            $subordinatesOfCurrentLevelUidList =[];
3436
-            foreach ($subordinatesOfCurrentLevel as &$value){
3437
-                $subordinatesOfCurrentLevelUidList[$value['uid']] = 0;
3438
-                $value['contribute'] = 0;
3439
-            }
3440
-
3441
-            // 如果 传入 $identity_up_time 不为空 证明当前在 确定身份的 用户已经是 业务员了
3442
-            if (!empty($identity_up_time)) {
3443
-                // 用户有贡献值记录,我们要根据 用户的身份 从普通消费者 升级 成业务员 的时间来 查询时间范围内产生的贡献值
3444
-                $userSignGongxianList = Db::name('user_sign_gongxian')
3445
-                    ->whereIn('uid', array_keys($subordinatesOfCurrentLevelUidList))
3446
-                    ->where('addtime', '>=', strtotime($identity_up_time)) //   `addtime` int(10) NOT NULL COMMENT '添加时间'
3447
-                    ->where('status', 1) // 贡献值状态1-有效 0-失效 -1待确认
3448
-                    ->whereNotNull('settlement_time') // `settlement_time` datetime DEFAULT NULL COMMENT '结算时间',
3449
-                    ->field('uid, number, type') // 只需要下级的uid和贡献值
3450
-                    ->select()
3451
-                    ->toArray();
3452
-                foreach ($userSignGongxianList as $value) {
3453
-                    if($value['type'] == 1) {
3454
-                        $subordinatesOfCurrentLevelUidList[$value['uid']] += $value['number'];
3455
-                    } else {
3456
-                        $subordinatesOfCurrentLevelUidList[$value['uid']] -= $value['number'];
3457
-                    }
3458
-                }
3459
-
3460
-                if ($is_old == 1) {
3461
-                    // 如果是老用户,除了通过贡献值记录表  还要计算 老订单 产生的贡献值
3462
-                    $oldUserOfGoodsList = Db::name('old_user_of_goods')
3463
-                        ->whereIn('user_id', array_keys($subordinatesOfCurrentLevelUidList))
3464
-                        ->where('create_time', '>=', strtotime($identity_up_time)) //   `addtime` int(10) NOT NULL COMMENT '添加时间'
3465
-                        ->where('status', 1) // '是否完成 0, 未完成 1 已完成',
3466
-                        ->field('user_id, money, status, create_time') // 只需要下级的uid和贡献值
3467
-                        ->select()
3468
-                        ->toArray();
3469
-
3470
-                    foreach ($oldUserOfGoodsList as $storeProductData) {
3471
-                        if ($storeProductData['money'] == 1180) {
3472
-                            $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 700;
3473
-                        } else if ($storeProductData['money'] == 10620) {
3474
-                            $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 6300;
3475
-                        } else if ($storeProductData['money'] == 11800) {
3476
-                            $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 7000;
3477
-                        } else if ($storeProductData['money'] == 9440) {
3478
-                            $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 5600;
3479
-                        } else if ($storeProductData['money'] == 2360) {
3480
-                            $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 1400;
3481
-                        } else {
3482
-                            $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += bcmul($storeProductData['money'], 0.7, 2);
3483
-                        }
3484
-                    }
3485
-                }
3429
+            // 如果 传入 $startTime 不为空 证明当前在 确定身份的 用户已经是 业务员了
3430
+            if (!empty($startTime)) {
3431
+                $subordinatesOfCurrentLevelUidList = $this->getUserContributeByUidList(array_column($subordinatesOfCurrentLevel, 'uid'), $startTime, $endTime);
3432
+                // // 用户有贡献值记录,我们要根据 用户的身份 从普通消费者 升级 成业务员 的时间来 查询时间范围内产生的贡献值
3433
+                // $userSignGongxianList = Db::name('user_sign_gongxian')
3434
+                //     ->whereIn('uid', array_keys($subordinatesOfCurrentLevelUidList))
3435
+                //     ->where('addtime', '>=', strtotime($startTime)) //   `addtime` int(10) NOT NULL COMMENT '添加时间'
3436
+                //     ->where('status', 1) // 贡献值状态1-有效 0-失效 -1待确认
3437
+                //     ->whereNotNull('settlement_time') // `settlement_time` datetime DEFAULT NULL COMMENT '结算时间',
3438
+                //     ->field('uid, number, type') // 只需要下级的uid和贡献值
3439
+                //     ->select()
3440
+                //     ->toArray();
3441
+                // foreach ($userSignGongxianList as $value) {
3442
+                //     if($value['type'] == 1) {
3443
+                //         $subordinatesOfCurrentLevelUidList[$value['uid']] += $value['number'];
3444
+                //     } else {
3445
+                //         $subordinatesOfCurrentLevelUidList[$value['uid']] -= $value['number'];
3446
+                //     }
3447
+                // }
3448
+                //
3449
+                // if ($is_old == 1) {
3450
+                //     // 如果是老用户,除了通过贡献值记录表  还要计算 老订单 产生的贡献值
3451
+                //     $oldUserOfGoodsList = Db::name('old_user_of_goods')
3452
+                //         ->whereIn('user_id', array_keys($subordinatesOfCurrentLevelUidList))
3453
+                //         ->where('create_time', '>=', strtotime($startTime)) //   `addtime` int(10) NOT NULL COMMENT '添加时间'
3454
+                //         ->where('status', 1) // '是否完成 0, 未完成 1 已完成',
3455
+                //         ->field('user_id, money, status, create_time') // 只需要下级的uid和贡献值
3456
+                //         ->select()
3457
+                //         ->toArray();
3458
+                //
3459
+                //     foreach ($oldUserOfGoodsList as $storeProductData) {
3460
+                //         if ($storeProductData['money'] == 1180) {
3461
+                //             $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 700;
3462
+                //         } else if ($storeProductData['money'] == 10620) {
3463
+                //             $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 6300;
3464
+                //         } else if ($storeProductData['money'] == 11800) {
3465
+                //             $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 7000;
3466
+                //         } else if ($storeProductData['money'] == 9440) {
3467
+                //             $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 5600;
3468
+                //         } else if ($storeProductData['money'] == 2360) {
3469
+                //             $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += 1400;
3470
+                //         } else {
3471
+                //             $subordinatesOfCurrentLevelUidList[$storeProductData['user_id']] += bcmul($storeProductData['money'], 0.7, 2);
3472
+                //         }
3473
+                //     }
3474
+                // }
3486 3475
             } else {
3487 3476
                 // 如果传入的 $identity_up_time 为空,说明该用户只是一个普通用户(消费者),没有团队业绩
3488 3477
                 break;
@@ -3532,4 +3521,298 @@ class UserRepository extends BaseRepository
3532 3521
 
3533 3522
         return $levelContributions;
3534 3523
     }
3524
+
3525
+
3526
+    /**
3527
+     * 获取用户 历史的 个人贡献值记录
3528
+     * @param $uidList
3529
+     * @return array
3530
+     * @throws DataNotFoundException
3531
+     * @throws DbException
3532
+     * @throws ModelNotFoundException
3533
+     */
3534
+    public function getUserContributeTimeMapByUidList($uidList) {
3535
+        $userContributeTimeMap = [];
3536
+        $userSignGongxianList = Db::name('user_sign_gongxian')
3537
+            ->whereIn('uid', $uidList)
3538
+            ->where('status', 1) // 贡献值状态1-有效 0-失效 -1待确认
3539
+            ->whereNotNull('settlement_time') // `settlement_time` datetime DEFAULT NULL COMMENT '结算时间',
3540
+            ->field('uid, number, type, mark, settlement_time') // 只需要下级的uid和贡献值
3541
+            ->select()
3542
+            ->toArray();
3543
+        foreach ($userSignGongxianList as $value) {
3544
+            // 贡献表中 包含多种类型的 贡献值记录,比如 用户消费商家获得赠送贡献值 , 推广获得的贡献值(直推),这些都不能算是 用户的 直接贡献值
3545
+            // 只有 用户取消费 比如:购买 ** 商品、扫码消费获得赠送贡献值 等 才算做个人贡献值
3546
+            if (strpos($value['mark'], "购买") !== false || strpos($value['mark'], "扫码") !== false) {
3547
+                if($value['type'] == 1) {
3548
+                    $type = 1;
3549
+                } else {
3550
+                    $type = 2;
3551
+                }
3552
+                $userContributeTimeMap[$value['uid']][] = [
3553
+                    'type' => $type,
3554
+                    'contribute' => $value['number'],
3555
+                    'settlementTime' => $value['settlement_time']
3556
+                ];
3557
+            }
3558
+        }
3559
+        // 老订单 产生的贡献值 并未在 贡献记录表中
3560
+        $oldUserOfGoodsList = Db::name('old_user_of_goods')
3561
+            ->where('status', 1) // '是否完成 0, 未完成 1 已完成',
3562
+            ->whereIn('user_id', $uidList)
3563
+            ->field('user_id, money, status, create_time') // 只需要下级的uid和贡献值
3564
+            ->select()
3565
+            ->toArray();
3566
+        // 定义一个映射数组,用于存储不同 money 对应的 contribute 值
3567
+        $contributeMapping = [
3568
+            1180 => 700,
3569
+            10620 => 6300,
3570
+            11800 => 7000,
3571
+            9440 => 5600,
3572
+            2360 => 1400,
3573
+        ];
3574
+        // 遍历每个 $storeProductData
3575
+        foreach ($oldUserOfGoodsList as $storeProductData) {
3576
+            // 获取 money 的值
3577
+            $money = $storeProductData['money'];
3578
+            // 检查 money 是否在映射中
3579
+            if (isset($contributeMapping[$money])) {
3580
+                // 如果存在,则使用映射的值
3581
+                $contribute = $contributeMapping[$money];
3582
+            } else {
3583
+                // 否则按默认规则计算
3584
+                $contribute = bcmul($money, 0.7, 2);
3585
+            }
3586
+            // 将数据添加到 $userContributeTimeList
3587
+            $userContributeTimeMap[$storeProductData['user_id']][] = [
3588
+                'type' => 1,
3589
+                'contribute' => $contribute,
3590
+                'settlementTime' => $storeProductData['create_time']
3591
+            ];
3592
+        }
3593
+        foreach ($userContributeTimeMap as $key => &$subArray) {
3594
+            usort($subArray, function ($a, $b) {
3595
+                return strtotime($a['settlementTime']) - strtotime($b['settlementTime']);
3596
+            });
3597
+        }
3598
+        return $userContributeTimeMap;
3599
+    }
3600
+
3601
+    /**
3602
+     * 获取用户升级成业务员的时间
3603
+     * @param $uid
3604
+     * @return mixed|string
3605
+     * @throws DataNotFoundException
3606
+     * @throws DbException
3607
+     * @throws ModelNotFoundException
3608
+     */
3609
+    public function determineUserUpgradeTime($uid) {
3610
+        $userData = $this->dao->get($uid)->toArray();
3611
+        if (empty($userData['identity_up_time'])) {
3612
+            $upArriveNumOwn = 0;
3613
+            $yeWuYuanId = 0;
3614
+            // 1、获取所有等级信息
3615
+            /** @var UserIdentityRepository $identityRepository */
3616
+            $identityRepository = app()->make(UserIdentityRepository::class);
3617
+            $identityList = $identityRepository->getIdentityList();
3618
+            foreach ($identityList as $value) {
3619
+                if ($value['user_group_name'] == '业务员') {
3620
+                    $upArriveNumOwn = $value['arrive_num_own'];
3621
+                    $yeWuYuanId = $value['user_group_id'];
3622
+                    break;
3623
+                }
3624
+            }
3625
+            // 2、获取用户贡献值 日志记录 对应时间
3626
+            $userContributeTimeMap = $this->getUserContributeTimeMapByUidList([$uid]);
3627
+            if (!empty($userContributeTimeMap[$uid])) {
3628
+                $myArriveNumOwn = 0;
3629
+                $myIdentityUpTime = '';
3630
+                foreach ($userContributeTimeMap[$uid] as $value) {
3631
+                    if ($value['type'] == 1) {
3632
+                        $myArriveNumOwn += $value['contribute'];
3633
+                    } else {
3634
+                        $myArriveNumOwn -= $value['contribute'];
3635
+                    }
3636
+                    if ($myArriveNumOwn >= $upArriveNumOwn) {
3637
+                        $myIdentityUpTime = $value['settlementTime'];
3638
+                        break;
3639
+                    }
3640
+                }
3641
+                if (!empty($myIdentityUpTime) && !empty($yeWuYuanId)) {
3642
+                    $userData['identity_up_time'] = $myIdentityUpTime;
3643
+                    $userData['user_group'] = $yeWuYuanId;
3644
+                    $this->dao->update($uid, [
3645
+                        'identity_up_time' => $userData['identity_up_time'],
3646
+                        'user_group' => $yeWuYuanId
3647
+                    ]);
3648
+                }
3649
+            }
3650
+        }
3651
+        return [
3652
+            'user_group' => $userData['user_group'],
3653
+            'identity_up_time' => $userData['identity_up_time']
3654
+        ];
3655
+    }
3656
+
3657
+    /**
3658
+     * 获取用户列表中 每个人 的 个人贡献值
3659
+     * @param array $uidList
3660
+     * @param null $startTime
3661
+     * @param null $endTime
3662
+     * @return array
3663
+     * @throws DataNotFoundException
3664
+     * @throws DbException
3665
+     * @throws ModelNotFoundException
3666
+     */
3667
+    public function getUserContributeByUidList($uidList = [], $startTime = null, $endTime = null)
3668
+    {
3669
+        $subordinatesOfCurrentLevelUidList = [];
3670
+        foreach ($uidList as $uid) {
3671
+            $subordinatesOfCurrentLevelUidList[$uid] = 0;
3672
+        }
3673
+        $userContributeTimeMap = $this->getUserContributeTimeMapByUidList($uidList);
3674
+        if (!empty($userContributeTimeMap)) {
3675
+            foreach ($userContributeTimeMap as $uid => $contributeInfoList) {
3676
+                foreach ($contributeInfoList as $value) {
3677
+                    // 跳过时间范围外的 贡献值
3678
+                    if (!empty($startTime) && strtotime($value['settlementTime']) < strtotime($startTime)) {
3679
+                        break;
3680
+                    }
3681
+                    if (!empty($endTime) && strtotime($value['settlementTime']) > strtotime($endTime)) {
3682
+                        break;
3683
+                    }
3684
+                    if ($value['type'] == 1) {
3685
+                        $subordinatesOfCurrentLevelUidList[$uid] += $value['contribute'];
3686
+                    } else {
3687
+                        $subordinatesOfCurrentLevelUidList[$uid] -= $value['contribute'];
3688
+                    }
3689
+                }
3690
+
3691
+            }
3692
+        }
3693
+        return $subordinatesOfCurrentLevelUidList;
3694
+    }
3695
+
3696
+
3697
+    /**
3698
+     * 根据时间和递归层级 获取部门下 每一层级的 贡献值
3699
+     *  假设 老大的 下级是 张三和李四, 董事(最高级身份)需要循环最深的等级是 3 级    得出来的结果↓  这样是为了计算大小部门
3700
+     * $userContributionSumMap[直属下级(部门)张三] =>[0 => 张三个人贡献值, 1 => 张三所有下级用户的个人贡献值, 2 => 张三所有下级用户的下级用户贡献值]
3701
+     * $userContributionSumMap[直属下级(部门)李四] =>[0 => 李四个人贡献值, 1 => 李四所有下级用户的个人贡献值, 2 => 李四所有下级用户的下级用户贡献值]
3702
+     * @param $uid
3703
+     * @param null $startTime
3704
+     * @param null $endTime
3705
+     * @param int $depth
3706
+     * @return array
3707
+     * @throws DataNotFoundException
3708
+     * @throws DbException
3709
+     * @throws ModelNotFoundException
3710
+     */
3711
+    public function getSubordinateContributeByUid($uid, $startTime, $endTime, $depth = 10)
3712
+    {
3713
+        // 4、获取下级用户 贡献值
3714
+        $userContributionSumMap = [];
3715
+        if ($depth >= 0 && !empty($startTime)) {
3716
+            // 获取用户的直属下级
3717
+            $uidContributeList = $this->getUidContributeListBySpreadUidList([$uid]);
3718
+            $uidContributeUidList = array_column($uidContributeList, 'uid');
3719
+            $subordinatesOfCurrentLevelUidList = $this->getUserContributeByUidList($uidContributeUidList, $startTime, $endTime);
3720
+
3721
+            foreach ($uidContributeList as $uidContribute) {
3722
+                $goOnDepth = $depth;
3723
+                // 获取用户规定时间内 所产生的贡献值 第一级
3724
+                $userContributionSumMap[$uidContribute['uid']][0] = $subordinatesOfCurrentLevelUidList[$uidContribute['uid']] ?? 0;
3725
+                if ($depth == 1) {
3726
+                    break;
3727
+                } else if ($depth > 1){
3728
+                    $goOnDepth = $depth - 1;
3729
+                }
3730
+                // 获取每个下级(部门)的个人贡献值 $goOnDepth = 0 时表示无限递归
3731
+                $userContributionSumMap[$uidContribute['uid']] = $this->getContributionSumByLevel(
3732
+                    [$uidContribute['uid']],
3733
+                    $goOnDepth,
3734
+                    0,
3735
+                    $startTime,
3736
+                    $endTime
3737
+                );
3738
+
3739
+                if (!empty($userContributionSumMap[$uidContribute['uid']])) {
3740
+                    ksort($userContributionSumMap[$uidContribute['uid']]);
3741
+                }
3742
+                // 假设 老大的 下级是 张三和李四, 董事(最高级身份)需要循环最深的等级是 3 级    得出来的结果↓  这样是为了计算大小部门
3743
+                // $userContributionSumMap[直属下级(部门)张三] =>[0 => 张三个人贡献值, 1 => 张三所有下级用户的个人贡献值, 2 => 张三所有下级用户的下级用户贡献值]
3744
+                // $userContributionSumMap[直属下级(部门)李四] =>[0 => 李四个人贡献值, 1 => 李四所有下级用户的个人贡献值, 2 => 李四所有下级用户的下级用户贡献值]
3745
+            }
3746
+        }
3747
+        return $userContributionSumMap;
3748
+    }
3749
+
3750
+    /**
3751
+     * 获取用户 团队贡献值信息
3752
+     * @param $uid
3753
+     * @param int $depth // 最深递归层级
3754
+     * @param array $betweenTime // 贡献值获取范围
3755
+     * @return array
3756
+     * @throws DataNotFoundException
3757
+     * @throws DbException
3758
+     * @throws ModelNotFoundException
3759
+     */
3760
+    public function getUserContributeInfoByDepth($uid, $depth = 10, $betweenTime = [])
3761
+    {
3762
+        // 3、获取个人贡献值
3763
+        $userData = $this->dao->get($uid)->toArray();
3764
+        // 这一步骤是为了 确定用户升级时间,因为后边的团队贡献值,需要查询 用户 升级为业务员后 所产生的团队贡献值
3765
+        $determineResult = $this->determineUserUpgradeTime($uid);
3766
+        $userData['user_group'] = $determineResult['user_group'];
3767
+        $userData['identity_up_time'] = $determineResult['identity_up_time']; // 获得的值 有可能是时间 有可能是 null
3768
+
3769
+        $startTime = $userData['identity_up_time'];
3770
+        $endTime = date('Y-m-d H:i:s');
3771
+        if (!empty($betweenTime) && !empty($betweenTime['startTime']) && !empty($betweenTime['endTime'])) {
3772
+            if(empty($startTime) || strtotime($startTime) < strtotime($betweenTime['startTime'])) {
3773
+                $startTime = $betweenTime['startTime'];
3774
+            }
3775
+            if(strtotime($betweenTime['endTime']) < strtotime($endTime)) {
3776
+                $endTime = $betweenTime['endTime'];
3777
+            }
3778
+        }
3779
+
3780
+        // 如果用户身份是  用户  则
3781
+        /**
3782
+         *  如果用户身份是 用户,则不计算团队贡献值,因计算团队贡献值 需要升级成业务员后 再进行进行统计
3783
+         *  如用户也统计团队贡献值可能会导致: 用户进入系统后,不进行消费,团队贡献值确增长迅速,等某时刻 他只要 进行消费,身份就会快速跃迁,不公平
3784
+         * (1)达标贡献值=自己消费产生的贡献值
3785
+         * (2)团队达标贡献值= 不计算团队
3786
+         */
3787
+        if ($userData['user_group'] == 1) {
3788
+            $depth = -1;
3789
+        }
3790
+
3791
+        // 4、获取下级用户 贡献值
3792
+        $userContributionSumMap = $this->getSubordinateContributeByUid($uid, $startTime, $endTime, $depth);
3793
+        $subordinateContribution = [];
3794
+        foreach ($userContributionSumMap as $key => $value) {
3795
+            $subordinateContribution[$key] = array_sum($value);
3796
+        }
3797
+
3798
+        $dqYj = 0;
3799
+        $arriveNumTeam = 0;
3800
+        if (!empty($subordinateContribution)) {
3801
+            // 大区业绩
3802
+            $dqYj = max($subordinateContribution);
3803
+            // 总业绩
3804
+            $zYj = array_sum($subordinateContribution);
3805
+            // 小区团体业绩
3806
+            $arriveNumTeam = bcsub($zYj, $dqYj, 2);
3807
+        }
3808
+
3809
+        return [
3810
+            'arriveNumTeam' => $arriveNumTeam, // 小部门贡献值和
3811
+            'contribute' => $userData['contribute'], // 个人贡献值
3812
+            'perContribute' => $userData['per_contribute'], // 直推贡献值
3813
+            'largeContribute' => $dqYj, // 大部门贡献值
3814
+            'subordinate' => $subordinateContribution // 各部门贡献值和
3815
+        ];
3816
+
3817
+    }
3535 3818
 }

+ 4 - 4
app/common/repositories/user/UserThirdRepository.php

@@ -747,7 +747,7 @@ class UserThirdRepository extends BaseRepository
747 747
     /**
748 748
      * 添加预估积分记录
749 749
      */
750
-    public static function yuguJifen($price,$user_id,$order_sn,$type_shop)
750
+    public function yuguJifen($price,$user_id,$order_sn,$type_shop)
751 751
     {
752 752
         if (empty($user_id)) {
753 753
             Db::name('log')->insert(['data' => "type_shop:{$type_shop}, $order_sn, $order_sn, 赠送积分, 不存在用户ID"]);
@@ -847,7 +847,7 @@ class UserThirdRepository extends BaseRepository
847 847
             //判断是否是老用户  is_old=1是1.0的用户,1.0的用户要总pv*45%的红包
848 848
             if($user["is_old"]==1){
849 849
                 //添加红包
850
-                $hongbao=roundOptimize($inc_score*0.45,2);
850
+                $hongbao = $this->roundOptimize($inc_score*0.45,2);
851 851
                 $hongbao_data = [
852 852
                     "uid"           =>$user_id,
853 853
                     "number"  =>    $hongbao,
@@ -875,7 +875,7 @@ class UserThirdRepository extends BaseRepository
875 875
         
876 876
                 // @todo 用户身份比例
877 877
                 $yongjinbili = StoreOrderRepository::getUserGroupRate($sprerdUser['user_group']);
878
-                $tuiguanyongjin=roundOptimize($yongjinbili*$inc_score,2);//按照身份获得佣金
878
+                $tuiguanyongjin=$this->roundOptimize($yongjinbili*$inc_score,2);//按照身份获得佣金
879 879
 
880 880
                 //添加推广积分
881 881
                 $tuijifendata = [
@@ -896,7 +896,7 @@ class UserThirdRepository extends BaseRepository
896 896
 
897 897
                 //添加推荐献值 普通用户 贡献值为 pv* 30%;推广人是业务员及以上身份,贡献值为:pv的1:1
898 898
                 if($sprerdUser['user_group'] <= 1){
899
-                    $gongxian = roundOptimize($gongxian*0.3,2);
899
+                    $gongxian = $this->roundOptimize($gongxian*0.3,2);
900 900
                 }
901 901
                 $tuigangongxian_data = [
902 902
                     "uid"           =>$sprerdUser['uid'],

+ 105 - 36
app/controller/admin/finance/Finance.php

@@ -20,8 +20,9 @@ class Finance extends BaseController
20 20
         $data = $financeRepository->order_overview();
21 21
         return app('json')->success('ok', $data);
22 22
     }
23
+
23 24
     /**
24
-     * 订单概况
25
+     * 用户概况
25 26
      * @return mixed
26 27
      */
27 28
     public function user_overview()
@@ -31,6 +32,109 @@ class Finance extends BaseController
31 32
         return app('json')->success('ok', $data);
32 33
     }
33 34
 
35
+
36
+    /**
37
+     * 会员概况
38
+     * @return mixed
39
+     */
40
+    public function member_overview()
41
+    {
42
+        $financeRepository = app()->make(FinanceRepository::class);
43
+        $data = $financeRepository->member_overview();
44
+        return app('json')->success('ok', $data);
45
+    }
46
+
47
+
48
+
49
+    /**
50
+     * pv概况
51
+     * @return mixed
52
+     */
53
+    public function pv_overview()
54
+    {
55
+        $financeRepository = app()->make(FinanceRepository::class);
56
+        $data = $financeRepository->pv_overview();
57
+        return app('json')->success('ok', $data);
58
+    }
59
+
60
+
61
+    /**
62
+     * vr概况
63
+     * @return mixed
64
+     */
65
+    public function vr_overview()
66
+    {
67
+        $financeRepository = app()->make(FinanceRepository::class);
68
+        $data = $financeRepository->vr_overview();
69
+        return app('json')->success('ok', $data);
70
+    }
71
+
72
+
73
+    /**
74
+     * 积分概况
75
+     * @return mixed
76
+     */
77
+    public function jifen_overview()
78
+    {
79
+        $financeRepository = app()->make(FinanceRepository::class);
80
+        $data = $financeRepository->jifen_overview();
81
+        return app('json')->success('ok', $data);
82
+    }
83
+
84
+
85
+    /**
86
+     * 交易概况
87
+     * @return mixed
88
+     */
89
+    public function transaction_overview()
90
+    {
91
+
92
+        try {
93
+            $type = input('type', 1);
94
+            $day = input('day', '');
95
+            $mer_id = $this->request->merId();
96
+    
97
+            $financeRepository = app()->make(FinanceRepository::class);
98
+            $arr = $financeRepository->jieyu($type,$day,$mer_id);
99
+    
100
+            // $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yingyemoney']), 'name' => '营业总额'];
101
+            // $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['ruzhang']), 'name' => '入账总额'];
102
+            // $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jieyu']), 'name' => '结余总额'];
103
+            // $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hf_fee_amt']), 'name' => '汇付通道服务费金额'];
104
+            // $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['integral']), 'name' => '积分总数'];
105
+            // $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['tixinan']), 'name' => '提现支出总额'];
106
+            $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yanglao']), 'name' => '养老金总额'];
107
+            $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['shouyi']), 'name' => '佣金总额'];
108
+            $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['suoke']), 'name' => '锁客收益总额'];
109
+            $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['fugou']), 'name' => '复购金总额'];
110
+            $data['one'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hongbao']), 'name' => '红包总额'];
111
+            $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jingdou']), 'name' => '京豆总额'];
112
+            $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['gongxian']), 'name' => '贡献值总额'];
113
+            $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['integral']), 'name' => '积分总额'];
114
+            $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['pv']), 'name' => 'PV总额'];
115
+            $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['vr']), 'name' => 'VR总额'];
116
+            $res['left'] = $data;
117
+
118
+            //底部大模块
119
+            $list1 = array(
120
+                array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '已完成提现总额'),
121
+                array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '审核中总额'),
122
+            );
123
+            $list2 = array(
124
+                array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '合伙分红总额'),
125
+                array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '联创分红总额'),
126
+                array('className' => 'el-icon-s-goods', 'count' => 0, 'name' => '股权分红总额'),
127
+            );
128
+            $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '提现总额', 'list' => $list1];
129
+            $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '分红总额', 'list' => $list2];
130
+            
131
+            return app('json')->success('ok', $res);
132
+        } catch (\Exception $e) {
133
+            Db::name('log')->insert(['data' => '交易详情统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']);
134
+            return app('json')->fail('统计失败'. $e->getMessage());
135
+        }
136
+    }
137
+
34 138
     /**
35 139
      * 积分统计
36 140
      * @return mixed
@@ -188,41 +292,6 @@ class Finance extends BaseController
188 292
         }
189 293
     }
190 294
 
191
-    /**
192
-     * 交易详情
193
-     * @return mixed
194
-     */
195
-    public function transaction_overview()
196
-    {
197
-
198
-        try {
199
-            $type = input('type', 1);
200
-            $day = input('day', '');
201
-            $mer_id = $this->request->merId();
202
-    
203
-            $financeRepository = app()->make(FinanceRepository::class);
204
-            $arr = $financeRepository->jieyu($type,$day,$mer_id);
205
-    
206
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yingyemoney']), 'name' => '营业总额'];
207
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['ruzhang']), 'name' => '入账总额'];
208
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['shouyi']), 'name' => '佣金奖励总额'];
209
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jieyu']), 'name' => '结余总额'];
210
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hf_fee_amt']), 'name' => '汇付通道服务费金额'];
211
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['integral']), 'name' => '积分总数'];
212
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['tixinan']), 'name' => '提现支出总额'];
213
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yanglao']), 'name' => '养老金总额'];
214
-    
215
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['gongxian']), 'name' => '贡献值总额'];
216
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jingdou']), 'name' => '京豆总额'];
217
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hongbao']), 'name' => '红包总额'];
218
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['fugou']), 'name' => '复购金总额'];
219
-            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['vr']), 'name' => 'VR总额'];
220
-            return app('json')->success('ok', $data);
221
-        } catch (\Exception $e) {
222
-            Db::name('log')->insert(['data' => '交易详情统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']);
223
-            return app('json')->fail('统计失败'. $e->getMessage());
224
-        }
225
-    }
226 295
 
227 296
     public function day_bill_list()
228 297
     {

+ 7 - 6
app/controller/api/Auth.php

@@ -743,11 +743,12 @@ class Auth extends BaseController
743 743
         $data['score']=set_price_rtrim($data['score']);
744 744
         //2025新增 贡献值,红包,京东,vr,复购金
745 745
 
746
-        if( $user['user_group'] <= 2 ){
747
-            $data['contribute'] =  $user['contribute'] + $user['per_contribute'];
748
-        }else{
749
-            $data['contribute'] =  $user['contribute'];
750
-        }
746
+        // 老逻辑 需要废弃
747
+        // if( $user['user_group'] <= 2 ){
748
+        //     $data['contribute'] =  $user['contribute'] + $user['per_contribute'];
749
+        // }else{
750
+        //     $data['contribute'] =  $user['contribute'];
751
+        // }
751 752
 
752 753
         $date['contribute']=set_price_rtrim($data['contribute']);//贡献值
753 754
         $data['repurchase_price']=set_price_rtrim($data['repurchase_price']);//复购余额
@@ -1415,7 +1416,7 @@ class Auth extends BaseController
1415 1416
             if(empty($sessionKey['sessionKey'])||empty($encryptedData['encryptedData'])||empty($iv['iv'])){
1416 1417
                 return app('json')->fail('参数不正确');
1417 1418
             }
1418
-            $appid = 'wx9082e5ac2fdb513f';//储蓄保小程序appid
1419
+            $appid = 'wx9082e5ac2fdb513f';//幸福宝小程序appid
1419 1420
             if($this->source=='yhc'){
1420 1421
                 $appid = 'wx9082e5ac2fdb513f';//一壶茶小程序appid
1421 1422
             }

+ 28 - 17
app/controller/api/Notify.php

@@ -146,8 +146,12 @@ class Notify
146 146
 
147 147
                             //找到对应的商品id(product_id)
148 148
                             $store_order_product_data = Db::name('store_order_product')->where('order_id',$store_order_data['order_id'])->find();
149
+
149 150
                             //找到对应的商品让利金额或比例
150 151
                             $store_product_data = Db::name('store_product')->where('product_id',$store_order_product_data['product_id'])->find();
152
+                            //找到对应的商品id的规格
153
+                            $store_product_attr_value = Db::name('store_product_attr_value')->where('product_id', $store_order_product_data['product_id'])->find();
154
+                            
151 155
                             //下单用户
152 156
                             $user_data = Db::name('user')->where('uid',$store_order_data['uid'])->find();
153 157
 
@@ -207,7 +211,7 @@ class Notify
207 211
 
208 212
                                         //推广养老金
209 213
                                         //推广佣金
210
-                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
214
+                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
211 215
                                         // 贡献值
212 216
                                         $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广精彩生活商品赠送贡献值");
213 217
                                         //积分
@@ -224,7 +228,7 @@ class Notify
224 228
                                         //积分
225 229
                                         $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 11, "推广精彩生活区商品赠送积分");
226 230
                                         // //推广佣金
227
-                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
231
+                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
228 232
                                         //养老金
229 233
                                         $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
230 234
                                     }
@@ -251,7 +255,7 @@ class Notify
251 255
 
252 256
                                             //Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
253 257
                                             //推广佣金
254
-                                            $this->bill_user_log($merchant_data['uid'],  $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金'.  $yj_amount_90,$store_order_data['mer_id'],0);
258
+                                            $this->bill_user_log($merchant_data['uid'],  $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金',$store_order_data['mer_id'],0);
255 259
 
256 260
                                         }
257 261
 
@@ -434,7 +438,7 @@ class Notify
434 438
                                         //养老金
435 439
                                         $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
436 440
                                         //佣金
437
-                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金'. $yj_amount_90,$store_order_data['mer_id']);
441
+                                        $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金',$store_order_data['mer_id']);
438 442
                                         //复购金
439 443
                                         $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1,1);
440 444
 
@@ -447,7 +451,7 @@ class Notify
447 451
                                         // //推广养老金
448 452
                                         // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.01,2),$store_order_data['mer_id']);
449 453
                                         // //推广佣金
450
-                                        // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.round($pv * 0.01,2),$store_order_data['mer_id']);
454
+                                        // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id']);
451 455
 
452 456
                                         //获取贡献值和积分和佣金
453 457
                                         $gx_jf = $spread_data['contribute'] + bcmul($pv, 0.3,2);
@@ -466,7 +470,7 @@ class Notify
466 470
                                         $this->con_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
467 471
                                         $this->score_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分",1);
468 472
                                         //推广佣金
469
-                                        $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金'.$yj_amount_90,$store_order_data['mer_id']);
473
+                                        $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金',$store_order_data['mer_id']);
470 474
                                     }
471 475
 
472 476
 
@@ -494,7 +498,7 @@ class Notify
494 498
                                     //养老金
495 499
                                     $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
496 500
                                     //佣金
497
-                                    $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金'. $yj_amount_90,$store_order_data['mer_id']);
501
+                                    $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金',$store_order_data['mer_id']);
498 502
                                     //复购金
499 503
                                     $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1,1);
500 504
 
@@ -537,7 +541,7 @@ class Notify
537 541
 
538 542
                                         //Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
539 543
                                         //推广佣金
540
-                                        $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金'.round($pv * 0.35,2),$store_order_data['mer_id']);
544
+                                        $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$store_order_data['order_sn'],'推广获得佣金',$store_order_data['mer_id']);
541 545
                                     }
542 546
 
543 547
                                 }
@@ -645,7 +649,7 @@ class Notify
645 649
 
646 650
                                             //推广养老金
647 651
                                             //推广佣金
648
-                                            $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
652
+                                            $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
649 653
                                             // 贡献值
650 654
                                             $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广商贸区商品赠送贡献值");
651 655
                                             //积分
@@ -662,7 +666,7 @@ class Notify
662 666
                                             //积分
663 667
                                             $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 11, "推广商贸区商品赠送积分");
664 668
                                             // //推广佣金
665
-                                            $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
669
+                                            $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
666 670
                                             //养老金
667 671
                                             $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
668 672
                                         }
@@ -678,11 +682,16 @@ class Notify
678 682
                                             $fgj_amount_10 = bcmul($pv * 0.1, 0.05, 2);//推广者的佣金抽10%到个人复购金
679 683
                                             $this->fugou_user_log($merchant_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
680 684
                                             //推广佣金
681
-                                            $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金' . $yj_amount_90, $store_order_data['mer_id'], 0);
685
+                                            $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得佣金', $user_data['mer_id'], 0);
682 686
                                         }
687
+                                    }
688
+
689
+                                    //京豆赠送
690
+                                    if ($store_order_data['mer_id'] > 0) {
683 691
                                         /** @var OrderMerchantRepository $orderMerchantRepository */
684 692
                                         $orderMerchantRepository = app()->make(OrderMerchantRepository::class);
685
-                                        $jdAndGonxianConfig = $orderMerchantRepository->getMerchantContribution($store_order_data['extension_two']);
693
+                                        $jdAndGonxianConfig = $orderMerchantRepository->getMerchantContribution($store_product_attr_value['extension_one']);
694
+                                        $merchant_data = Db::name('merchant')->where('mer_id', $store_order_data['mer_id'])->find();
686 695
 
687 696
                                         //商户获得贡献值  ---- 3月29日  商户不再获得贡献值 改为获得分润值
688 697
                     //                    if ($concession_pri >= 0.01) {
@@ -707,17 +716,17 @@ class Notify
707 716
                     //                    }
708 717
 
709 718
                                         //商户获得京豆
710
-                                        if ($concession_pri >= 0.01) {
711
-                                            $jd = bcmul($concession_pri, $jdAndGonxianConfig['jd'], 2);
719
+                                        $jd = bcmul($concession_pri, $jdAndGonxianConfig['jd'], 2);
720
+                                        if ($jd >= 0.01) {
712 721
                                             $jd_data = [
713 722
                                                 "uid" => $merchant_data["uid"],
714
-                                                "mer_id" => $user_data['mer_id'],
723
+                                                "mer_id" => $store_order_data['mer_id'],
715 724
                                                 "number" => $jd,
716 725
                                                 "addtime" => time(),
717 726
                                                 "status" => -1,
718 727
                                                 "order_type" => 2,
719 728
                                                 "order_id" => $store_order_data['order_id'],
720
-                                                "mark" => "锁客商家获得京豆",
729
+                                                "mark" => "线上用户消费商家获得京豆",
721 730
                                                 "desc" => '',
722 731
                                                 "surplus" => $jd,
723 732
                                                 "type" => 1
@@ -1465,7 +1474,9 @@ class Notify
1465 1474
         ];
1466 1475
         // 当状态为1时是实时结算
1467 1476
         if($status == 1) {
1468
-            Db::name('user')->where('uid', $uid)->inc('pv', (float)$pv)->update();
1477
+            // Db::name('user')->where('uid', $uid)->inc('pv', (float)$pv)->update();
1478
+            $con_data = Db::name('user')->where("uid", $uid)->find();
1479
+            Db::name('user')->where("uid", $uid)->update(['pv' => ($con_data['pv']?:0) + $pv]);
1469 1480
             $pv_data['settlement_time'] = date('Y-m-d H:i:s');
1470 1481
         }
1471 1482
         Db::name("user_pv_log")->insert($pv_data);//添加pv记录

+ 2 - 2
app/controller/api/entropybarter/User.php

@@ -95,12 +95,12 @@ class User extends BaseController
95 95
     /**
96 96
      * @param $uid
97 97
      * @param $spread_uid
98
-     * 绑定储蓄保的关系
98
+     * 绑定幸福宝的关系
99 99
      */
100 100
     public function cxb_bangding($uid,$spread_uid)
101 101
     {
102 102
         $spread_uid_user=Db::name('user')->where('uid',$uid)->value('spread_uid');
103
-        Db::name('log')->insert(['data'=>'绑定储蓄保的关系进来了他的上级ID'.$spread_uid_user]);
103
+        Db::name('log')->insert(['data'=>'绑定幸福宝的关系进来了他的上级ID'.$spread_uid_user]);
104 104
         if($spread_uid_user==0){
105 105
             Db::name('user')->where('uid',$uid)->update(['spread_uid'=>$spread_uid]);
106 106
         }

+ 10 - 10
app/controller/api/merchant/sxy/Access.php

@@ -736,7 +736,7 @@ class Access
736 736
             $groupOrder = Db::name('order_huafei_hf')->where('order_id', (int)$oid)->find();
737 737
             if (!$groupOrder) return app('json')->fail('订单不存在或已支付');
738 738
 
739
-            $res = $this->pay_huifu($type,$code,$groupOrder,"储蓄保",env('APP_URL')."/api/hf_notify/huafei",'delay');
739
+            $res = $this->pay_huifu($type,$code,$groupOrder,"幸福宝",env('APP_URL')."/api/hf_notify/huafei",'delay');
740 740
             Db::name('log')->insert(['data'=>'汇付话费订单支付--- 返回参数'.json_encode($res)]);
741 741
             if (isset($res['id'])) {
742 742
                 return app('json')->success($res);
@@ -836,7 +836,7 @@ class Access
836 836
                     ->where(["sc.cart_id"=>$cart_id])
837 837
                     ->value('sp.store_name');
838 838
             }
839
-            $res = $this -> pay_huifu($type,$code,$groupOrder,$product ?? "储蓄保",env('APP_URL')."/api/hf_notify/pay",'delay');
839
+            $res = $this -> pay_huifu($type,$code,$groupOrder,$product ?? "幸福宝",env('APP_URL')."/api/hf_notify/pay",'delay');
840 840
             Db::name('log')->insert(['data'=>'汇付订单支付--- 返回参数'.json_encode($res)]);
841 841
             if (isset($res['id'])) {
842 842
                 Db::name('store_group_order')->where('group_order_id', $oid)->update(['hf_pay_id' => $res['id'],'pay_wx'=>systemConfig('pay_wx')]);
@@ -881,7 +881,7 @@ class Access
881 881
             Db::name("log")->insert(array('data'=>Db::name("store_product")->getLastSql()));//日志记录
882 882
 
883 883
             $productDetails = array(
884
-                'name' => $product ?? "储蓄保",//商品名称。需传递真实产品名称。
884
+                'name' => $product ?? "幸福宝",//商品名称。需传递真实产品名称。
885 885
                 'quantity' => 1,//商品数量
886 886
                 'amount' => strval($groupOrder['pay_price'] * 100),//商品单价
887 887
             );
@@ -942,7 +942,7 @@ class Access
942 942
                     ->where(["sc.cart_id"=>$cart_id])
943 943
                     ->value('sp.store_name');
944 944
             }
945
-            $res = $this -> pay_huifu($type,$code,$groupOrder,$product ?? "储蓄保",env('APP_URL')."/api/hf_notify/pay",'delay');
945
+            $res = $this -> pay_huifu($type,$code,$groupOrder,$product ?? "幸福宝",env('APP_URL')."/api/hf_notify/pay",'delay');
946 946
             Db::name('log')->insert(['data'=>'汇付订单支付--- 返回参数'.json_encode($res)]);
947 947
             if (isset($res['id'])) {
948 948
                 Db::name('store_group_order')->where('group_order_id', $oid)->update(['hf_pay_id' => $res['id'],'pay_wx'=>systemConfig('pay_wx')]);
@@ -987,7 +987,7 @@ class Access
987 987
             Db::name("log")->insert(array('data'=>Db::name("store_product")->getLastSql()));//日志记录
988 988
 
989 989
             $productDetails = array(
990
-                'name' => $product ?? "储蓄保",//商品名称。需传递真实产品名称。
990
+                'name' => $product ?? "幸福宝",//商品名称。需传递真实产品名称。
991 991
                 'quantity' => 1,//商品数量
992 992
                 'amount' => strval($groupOrder['pay_price'] * 100),//商品单价
993 993
             );
@@ -1064,8 +1064,8 @@ class Access
1064 1064
                 'app_id'=>$app_id,
1065 1065
                 'pay_channel'=>$pay_channel,
1066 1066
                 'pay_amt'=>strval($groupOrder['pay_price']),//金额。,
1067
-                'goods_title'=>$product ?? "储蓄保",
1068
-                'goods_desc'=>$product ?? "储蓄保",
1067
+                'goods_title'=>$product ?? "幸福宝",
1068
+                'goods_desc'=>$product ?? "幸福宝",
1069 1069
                 'device_info'=>[
1070 1070
                     'device_ip'=>app('request')->ip()
1071 1071
 //                    'device_ip'=>'115.171.134.68'
@@ -1094,8 +1094,8 @@ class Access
1094 1094
                 'app_id'=>$app_id,
1095 1095
                 'pay_channel'=>$pay_channel,
1096 1096
                 'pay_amt'=>strval($groupOrder['pay_price']),//金额。,
1097
-                'goods_title'=>$product ?? "储蓄保",
1098
-                'goods_desc'=>$product ?? "储蓄保",
1097
+                'goods_title'=>$product ?? "幸福宝",
1098
+                'goods_desc'=>$product ?? "幸福宝",
1099 1099
                 'device_info'=>[
1100 1100
                     'device_ip'=>app('request')->ip()
1101 1101
 //                    'device_ip'=>'115.171.134.68'
@@ -1208,7 +1208,7 @@ class Access
1208 1208
             Db::name("log")->insert(array('data'=>Db::name("store_product")->getLastSql()));//日志记录
1209 1209
 
1210 1210
             $productDetails = array(
1211
-                'name' => $product ?? "储蓄保年费",//商品名称。需传递真实产品名称。
1211
+                'name' => $product ?? "幸福宝年费",//商品名称。需传递真实产品名称。
1212 1212
                 'quantity' => 1,//商品数量
1213 1213
                 'amount' => strval($groupOrder['pay_price'] * 100),//商品单价
1214 1214
             );

+ 60 - 53
app/controller/api/store/merchant/TaskPartnerProfits.php

@@ -23,23 +23,19 @@ class TaskPartnerProfits
23 23
             $startTime = date('Y-m-d', strtotime('monday this week', $now)); // 这周星期一的开始时间
24 24
             $endTime = date('Y-m-d', strtotime('sunday this week', $now)); // 这周星期日的结束时间
25 25
         }
26
-//        return ['startTime' => '2025-03-10', 'endTime' => '2025-03-23'];
26
+        //        return ['startTime' => '2025-03-10', 'endTime' => '2025-03-23'];
27 27
         return ['startTime' => $startTime, 'endTime' => $endTime];
28 28
     }
29 29
 
30
-    public function getTeamPvByTime($timePeriod = 'last_week', $removeUserIdList = [])
30
+    public function getTeamPvByTime($startTime, $endTime, $removeUserIdList = [])
31 31
     {
32
-        $timeMap = $this->getTime($timePeriod);
33
-        $startTime = $timeMap['startTime'];
34
-        $endTime = $timeMap['endTime'];
35
-
36 32
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
37 33
         $orders = Db::name("store_order")
38 34
             ->where('mer_id', 496)
39 35
             ->whereNotIn('uid', $removeUserIdList)
40 36
             ->whereIn('status', [0, 1, 2, 3])
41 37
             ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
42
-            ->whereBetween("pay_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
38
+            ->whereBetween("pay_time", [$startTime, $endTime])
43 39
             ->whereNotNull("pay_time") // 排除 pay_time 为 NULL 的订单
44 40
             ->select();
45 41
 
@@ -68,24 +64,22 @@ class TaskPartnerProfits
68 64
         return $totalPv;
69 65
     }
70 66
 
71
-    public function getRedEnvelopeByTime($timePeriod = 'last_week', $removeUserIdList = [])
67
+    public function getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList = [])
72 68
     {
73
-        $timeMap = $this->getTime($timePeriod);
74
-        $startTime = $timeMap['startTime'];
75
-        $endTime = $timeMap['endTime'];
76
-
77 69
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
78 70
         $redEnvelopeList = Db::name("user_sign_hongbao")
79 71
             ->whereNotIn('uid', $removeUserIdList)
80 72
             ->where('status', 1)
81
-            ->whereBetween("settlement_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
73
+            ->whereBetween("settlement_time", [$startTime, $endTime])
82 74
             ->select()
83 75
             ->toArray();
84 76
         return floor(array_sum(array_column($redEnvelopeList, 'number')) * 100) / 100;
85 77
     }
86 78
 
87
-    public function partnerProfits()
79
+    public function partnerProfits($startTime = '', $endTime = '')
88 80
     {
81
+        $startTime = '2025-03-10';
82
+        $endTime = '2025-03-30';
89 83
         // 查询测试人员账号信息
90 84
         //18973958920
91 85
         //15186694339
@@ -101,10 +95,17 @@ class TaskPartnerProfits
101 95
             ->select()
102 96
             ->toArray();
103 97
         $removeUserIdList = array_column($removeUserList, 'uid');
98
+
99
+        if (empty($startTime) || empty($endTime)) {
100
+            $timeMap = $this->getTime('last_week');
101
+            $startTime = $timeMap['startTime'] . ' 00:00:00';
102
+            $endTime = $timeMap['endTime'] . ' 23:59:59';
103
+        }
104
+
104 105
         // 定义分红金额
105
-        $weekRecord = $this->getTeamPvByTime('last_week', $removeUserIdList);
106
+        $weekRecord = $this->getTeamPvByTime($startTime, $endTime, $removeUserIdList);
106 107
         // 分红金额 - 红包金额
107
-        $redEnvelope = $this->getRedEnvelopeByTime('last_week', $removeUserIdList);
108
+        $redEnvelope = $this->getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList);
108 109
 
109 110
         $weekRecord -= $redEnvelope;
110 111
         if ($weekRecord <= 0) {
@@ -125,7 +126,7 @@ class TaskPartnerProfits
125 126
 
126 127
         // 3、获取 分红用户 信息 (`user_group` tinyint(1) DEFAULT '1' COMMENT '1消费者 2,推广业务员 3,业务经理 4初级合伙人5中级合伙人 6高级合伙人 7.懂事',)
127 128
         $list = Db::name("user")
128
-//            ->whereNotIn('uid', $removeUserIdList)
129
+            //            ->whereNotIn('uid', $removeUserIdList)
129 130
             ->where("user_group", "IN", [4, 5, 6])
130 131
             ->where("status", "<>", 0)
131 132
             ->where('is_del', '<>', 1)
@@ -142,33 +143,39 @@ class TaskPartnerProfits
142 143
                 $salesArr['高级']['divider_people'][] = $value['uid'];
143 144
             }
144 145
         }
146
+        $salesArr['初级']['divider_people_count'] = count($salesArr['初级']['divider_people']);
147
+        $salesArr['中级']['divider_people_count'] = count($salesArr['中级']['divider_people']);
148
+        $salesArr['高级']['divider_people_count'] = count($salesArr['高级']['divider_people']);
149
+
145 150
 
146 151
         // 5、移除特定人员
147 152
         // 要移动的ID数组
148
-//        $ids_to_remove_from_junior = array(12, 69, 144); // 从初级中移除的ID
149
-//        $ids_to_remove_from_intermediate = array(49); // 从中级中移除的ID
150
-//        // 查找初级并获取其divider_people
151
-//        $junior = &$salesArr['初级']['divider_people']; // 使用引用,以便直接修改数组
152
-//        // 查找中级并获取其divider_people
153
-//        $intermediate = &$salesArr['中级']['divider_people']; // 使用引用,以便直接修改数组
154
-//        // 从初级的divider_people中移除特定的ID
155
-//        foreach ($ids_to_remove_from_junior as $id) {
156
-//            $key = array_search($id, $junior);
157
-//            if ($key !== false) {
158
-//                unset($junior[$key]); // 移除初级中的特定ID
159
-//            }
160
-//        }
161
-//        // 从中级的divider_people中移除特定的ID
162
-//        foreach ($ids_to_remove_from_intermediate as $id) {
163
-//            $key = array_search($id, $intermediate);
164
-//            if ($key !== false) {
165
-//                unset($intermediate[$key]); // 移除中级中的特定ID
166
-//            }
167
-//        }
168
-//        // 重置数组的索引,因为unset会留下空位
169
-//        $salesArr['初级']['divider_people'] = array_values($junior);
170
-//        $salesArr['中级']['divider_people'] = array_values($intermediate);
171
-
153
+        //        $ids_to_remove_from_junior = array(12, 69, 144); // 从初级中移除的ID
154
+        //        $ids_to_remove_from_intermediate = array(49); // 从中级中移除的ID
155
+        //        // 查找初级并获取其divider_people
156
+        //        $junior = &$salesArr['初级']['divider_people']; // 使用引用,以便直接修改数组
157
+        //        // 查找中级并获取其divider_people
158
+        //        $intermediate = &$salesArr['中级']['divider_people']; // 使用引用,以便直接修改数组
159
+        //        // 从初级的divider_people中移除特定的ID
160
+        //        foreach ($ids_to_remove_from_junior as $id) {
161
+        //            $key = array_search($id, $junior);
162
+        //            if ($key !== false) {
163
+        //                unset($junior[$key]); // 移除初级中的特定ID
164
+        //            }
165
+        //        }
166
+        //        // 从中级的divider_people中移除特定的ID
167
+        //        foreach ($ids_to_remove_from_intermediate as $id) {
168
+        //            $key = array_search($id, $intermediate);
169
+        //            if ($key !== false) {
170
+        //                unset($intermediate[$key]); // 移除中级中的特定ID
171
+        //            }
172
+        //        }
173
+        //        // 重置数组的索引,因为unset会留下空位
174
+        //        $salesArr['初级']['divider_people'] = array_values($junior);
175
+        //        $salesArr['中级']['divider_people'] = array_values($intermediate);
176
+
177
+        // 获取查询合伙人 团队贡献值 最深的到哪一层
178
+        $depth = Db::name("system_config_value")->where(["config_key" => "team_commission_recursion_depth"])->value("value");
172 179
 
173 180
         // 6、执行分开发放
174 181
         $partnerProfitsPvListByUid = [];
@@ -176,14 +183,16 @@ class TaskPartnerProfits
176 183
             // 6.1 计算可分红金额
177 184
             //比如这个周的总业绩是 8400
178 185
             //周总业绩(8400) * 合伙人级别的分佣比例(15%) = 可分红的佣金(1260)
179
-//            $salesArr[$key]['fs_money_nums'] = round($weekRecord * $value['profit_rate'], 2);
186
+            //            $salesArr[$key]['fs_money_nums'] = round($weekRecord * $value['profit_rate'], 2);
180 187
             $salesArr[$key]['fs_money_nums'] = floor(($weekRecord * ($value['profit_rate'] / 100)) * 100) / 100;
181 188
             //可分红的业绩(分为两半,各50%,一部分是分给双联盟比例,一部分是小业绩比例)
182 189
             //把本周的业绩(8400) * 合伙人级别的分佣比例(15%) * 0.5 = 630(可分红佣金的 50%)
183
-//            $salesArr[$key]['fs_money'] = round($salesArr[$key]['fs_money_nums'] / 2, 2);
190
+            //            $salesArr[$key]['fs_money'] = round($salesArr[$key]['fs_money_nums'] / 2, 2);
184 191
             $salesArr[$key]['fs_money'] = floor(($salesArr[$key]['fs_money_nums'] / 2) * 100) / 100;
185 192
 
186 193
             // 6.2 计算所有人的 PV值
194
+            $salesArr[$key]['weekRecord'] = $weekRecord;
195
+            $salesArr[$key]['redEnvelope'] = $redEnvelope;
187 196
             $salesArr[$key]['maxValueAll'] = 0;
188 197
             $salesArr[$key]['sumOfOthersAll'] = 0;
189 198
             $salesArr[$key]['dividerPeoplePv'] = [];
@@ -239,14 +248,14 @@ class TaskPartnerProfits
239 248
                 //个人小区(佣金少的一部分) 权重 计算权重
240 249
                 //返回是数组,下标0是最小的值(业绩小的),下标1是最大的值(业绩大的)
241 250
                 $userPvSmallNum = $value['dividerPeoplePv'][$v]['sumOfOthers'] ?? 0;
242
-//                $myMixMoney = round($amount * ($userPvSmallNum / $sumOfOthersAll), 2);
251
+                //                $myMixMoney = round($amount * ($userPvSmallNum / $sumOfOthersAll), 2);
243 252
                 $myMixMoney = floor(($amount * (floor(($userPvSmallNum / $sumOfOthersAll) * 100) / 100)) * 100) / 100;
244 253
 
245 254
                 //个人双区总佣金 权重 计算
246 255
                 $myBill = $value['dividerPeoplePv'][$v]['maxValue'] ?? 0;
247 256
                 //中级合伙人。userid=17可以分到双区可分红的金额
248 257
                 //可分红的佣金 * (中级合伙人个人的双区总业绩 / 当前等级所有合伙人的双联盟业绩) = 当前用户可以获取到的分红佣金(双区联盟总业绩加权佣金),287742 * (61.95/431032)=41.36
249
-//                $myWeightMoney = round($amount * ($myBill / $maxValueAll), 2);
258
+                //                $myWeightMoney = round($amount * ($myBill / $maxValueAll), 2);
250 259
                 $myWeightMoney = floor(($amount * (floor((($myBill + $userPvSmallNum) / ($maxValueAll + $sumOfOthersAll)) * 100) / 100)) * 100) / 100;
251 260
 
252 261
 
@@ -254,7 +263,6 @@ class TaskPartnerProfits
254 263
                 $salesArr[$key]['dividerPeoplePv'][$v]['myMixMoney'] = $myMixMoney;
255 264
                 $salesArr[$key]['dividerPeoplePv'][$v]['maxValueAll'] = $maxValueAll;
256 265
                 $salesArr[$key]['dividerPeoplePv'][$v]['sumOfOthersAll'] = $sumOfOthersAll;
257
-                $salesArr[$key]['dividerPeoplePv'][$v]['weekRecord'] = $weekRecord;
258 266
 
259 267
                 # code...
260 268
                 $allAward = $myWeightMoney + $myMixMoney;
@@ -266,7 +274,7 @@ class TaskPartnerProfits
266 274
 
267 275
                 $userdatassss = db::name("old_user_jbp")->where("id", $v)->find();
268 276
                 $datas_log = [
269
-                    'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v . " 双联盟总业绩:" . $maxValueAll . " 我的双区业绩:" . $myBill . " 小区总业绩:" . $sumOfOthersAll . " 我的业绩小的:" . $userPvSmallNum[0] . "  可分红佣金:" . $amount . "  可分红总佣金:" . $fsMoneyNums . "  小区业绩可分红:" . $myMixMoney . " 区业绩可分红:" . $myWeightMoney . " 实际分得:" . $yj_90,
277
+                    'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v . " 双联盟总业绩:" . $maxValueAll . " 我的双区业绩:" . $myBill . " 小区总业绩:" . $userPvSmallNum . " 我的业绩小的:" . $myMixMoney . "  可分红佣金:" . $amount . "  可分红总佣金:" . $fsMoneyNums . "  小区业绩可分红:" . $myMixMoney . " 区业绩可分红:" . $myWeightMoney . " 实际分得:" . $yj_90,
270 278
                     'create_time' => date('Y-m-d H:i:s')
271 279
                 ];
272 280
                 $con_data = Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
@@ -285,7 +293,7 @@ class TaskPartnerProfits
285 293
                 //入账星级分红记录表
286 294
                 $week_data = [];
287 295
                 $week_data['user_id'] = $v;
288
-                $week_data['user_star_id'] = $key;
296
+                $week_data['user_star_id'] = $value['id'];
289 297
                 $week_data['award_num'] = $myWeightMoney;
290 298
                 $week_data['award_num_sm'] = $myMixMoney;
291 299
                 $week_data['remark'] = "星级分红主动执行:" . $yj_90;
@@ -295,7 +303,6 @@ class TaskPartnerProfits
295 303
                 $week_data['owner_bill'] = $maxValueAll;  //总流水金额
296 304
                 $week_data['my_bill'] = $myBill;  //我的流水
297 305
                 $week_data['create_time'] = time();
298
-
299 306
                 Db::name("old_user_weekaward")->insert($week_data);
300 307
 
301 308
                 $this->bill_user_log111111($v, "合伙人分佣", $yj_90, "合伙人分佣明细入账", 11);//联创分佣明细2.0系统
@@ -578,10 +585,10 @@ class TaskPartnerProfits
578 585
 
579 586
         // 计算除去特定值后的总和
580 587
         $otherMoneyRecords = [];
581
-//        $otherMoneyRecords = Db::name("old_user_of_goods")
582
-//            ->whereIn("user_id", $userIdList)
583
-//            ->whereNotIn('money', [1180, 11800, 10620, 9440, 2360])
584
-//            ->select();
588
+        //        $otherMoneyRecords = Db::name("old_user_of_goods")
589
+        //            ->whereIn("user_id", $userIdList)
590
+        //            ->whereNotIn('money', [1180, 11800, 10620, 9440, 2360])
591
+        //            ->select();
585 592
         $otherMoneySum = 0;
586 593
         foreach ($otherMoneyRecords as $record) {
587 594
             $otherMoneySum += $record['money'];

+ 7 - 7
app/controller/api/store/merchant/Taskorder.php

@@ -1593,7 +1593,7 @@ public function getbig_samll_datas_copy($user_id) {
1593 1593
                     //积分
1594 1594
                     $this->score_log($spread_data['uid'],$ssf,$store_order_data['order_id'],11,"精彩生活区商品赠送积分");
1595 1595
                     // //推广佣金
1596
-                    $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.$yj_amount_90,$store_order_data['mer_id'],0);
1596
+                    $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id'],0);
1597 1597
                     //养老金
1598 1598
                     $this->bill_user_log($spread_data['uid'],round($pv * 0.05,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.05,2),$store_order_data['mer_id'],0);
1599 1599
                 }
@@ -1620,7 +1620,7 @@ public function getbig_samll_datas_copy($user_id) {
1620 1620
                   //推广养老金
1621 1621
                  // $this->bill_user_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.3,2),$store_order_data['mer_id']);
1622 1622
                   //推广佣金
1623
-                  $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.$yj_amount_90,$store_order_data['mer_id'],0);
1623
+                  $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id'],0);
1624 1624
                   $this->con_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
1625 1625
                   $this->score_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
1626 1626
                   
@@ -1654,7 +1654,7 @@ public function getbig_samll_datas_copy($user_id) {
1654 1654
                     
1655 1655
                     Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
1656 1656
                 //推广佣金
1657
-                $this->bill_user_log($merchant_data['uid'],  $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.  $yj_amount_90,$store_order_data['mer_id'],0);
1657
+                $this->bill_user_log($merchant_data['uid'],  $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id'],0);
1658 1658
                         
1659 1659
                         }
1660 1660
 
@@ -1804,7 +1804,7 @@ public function getbig_samll_datas_copy($user_id) {
1804 1804
                 //养老金
1805 1805
                 $this->bill_user_log($spread_data['uid'],round($pv * 0.035,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'消费获得养老金'.round($pv * 0.035,2),$store_order_data['mer_id']);
1806 1806
                 //佣金
1807
-                $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'. $yj_amount_90,$store_order_data['mer_id']);
1807
+                $this->bill_user_log($spread_data['uid'], $yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id']);
1808 1808
                 //复购金
1809 1809
                 $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
1810 1810
 
@@ -1817,7 +1817,7 @@ public function getbig_samll_datas_copy($user_id) {
1817 1817
                     // //推广养老金
1818 1818
                     // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],5,$group_order['group_order_sn'],'推广获得养老金'.round($pv * 0.01,2),$store_order_data['mer_id']);
1819 1819
                     // //推广佣金
1820
-                    // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.round($pv * 0.01,2),$store_order_data['mer_id']);
1820
+                    // $this->bill_user_log($user_data['spread_uid'],round($pv * 0.01,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id']);
1821 1821
                     
1822 1822
                 //获取贡献值和积分和佣金
1823 1823
                 $gx_jf = $spread_data['contribute'] + round($pv * 0.03,2);
@@ -1836,7 +1836,7 @@ public function getbig_samll_datas_copy($user_id) {
1836 1836
                 $this->con_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值");
1837 1837
                 $this->score_log($spread_data['uid'],round($pv * 0.03,2),$store_order_data['order_id'],11,"推广会员专区商品赠送积分");
1838 1838
                 //推广佣金
1839
-                $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.$yj_amount_90,$store_order_data['mer_id']);
1839
+                $this->bill_user_log($spread_data['uid'],$yj_amount_90,$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id']);
1840 1840
             }
1841 1841
 
1842 1842
         
@@ -1864,7 +1864,7 @@ public function getbig_samll_datas_copy($user_id) {
1864 1864
                 
1865 1865
                 Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
1866 1866
             //推广佣金
1867
-            $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金'.round($pv * 0.35,2),$store_order_data['mer_id']);
1867
+            $this->bill_user_log($merchant_data['uid'],round($pv * 0.35,2),$store_order_data['order_id'],3,$group_order['group_order_sn'],'推广获得佣金',$store_order_data['mer_id']);
1868 1868
             }
1869 1869
 
1870 1870
         }

+ 58 - 52
app/controller/api/store/merchant/Taskorderguquan.php

@@ -7,22 +7,16 @@
7 7
 
8 8
 namespace app\controller\api\store\merchant;
9 9
 
10
-use think\App;
11
-use crmeb\basic\BaseController;
12
-use app\common\repositories\system\merchant\MerchantRepository as repository;
13 10
 use think\facade\Db;
14
-use think\facade\Log;
15
-use function Symfony\Component\VarDumper\Dumper\esc;
16 11
 
17
-class Taskorderguquan extends BaseController
12
+class Taskorderguquan
18 13
 {
19 14
 
20 15
 
21 16
     public function lst6()
22 17
     {
23
-
24
-        $week_record = 10500 + 50000; //20250310
25
-
18
+        $startTime = '2025-03-10';
19
+        $endTime = '2025-03-30';
26 20
         // 查询测试人员账号信息
27 21
         //18973958920
28 22
         //15186694339
@@ -38,16 +32,25 @@ class Taskorderguquan extends BaseController
38 32
             ->select()
39 33
             ->toArray();
40 34
         $removeUserIdList = array_column($removeUserList, 'uid');
41
-        // 定义分红金额
42
-        $week_record = $this->getTeamPvByTime('last_week', $removeUserIdList);
43
-        // 分红金额 - 红包金额
44
-        $redEnvelope = $this->getRedEnvelopeByTime('last_week', $removeUserIdList);
45 35
 
46
-        $week_record -= $redEnvelope;
36
+        if (empty($startTime) || empty($endTime)) {
37
+            $timeMap = $this->getTime('last_week');
38
+            $startTime = $timeMap['startTime'] . ' 00:00:00';
39
+            $endTime = $timeMap['endTime'] . ' 23:59:59';
40
+        }
47 41
 
42
+        // 定义分红金额
43
+        $weekRecord = $this->getTeamPvByTime($startTime, $endTime, $removeUserIdList);
44
+        // 分红金额 - 红包金额
45
+        $redEnvelope = $this->getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList);
48 46
 
49
-        $stock_comm = round($week_record * 0.05 ,2);
47
+        $weekRecord -= $redEnvelope;
48
+        if ($weekRecord <= 0) {
49
+            return json('无效分红金额');
50
+        }
50 51
 
52
+        // $stock_comm = round($weekRecord * 0.05 ,2);
53
+        $stock_comm = floor(($weekRecord * 0.05) * 100) / 100;
51 54
 
52 55
         //获取股权分红的人
53 56
 
@@ -55,12 +58,22 @@ class Taskorderguquan extends BaseController
55 58
 
56 59
         $stockuserdatas = db::name("old_user_stock")->select();//获取所有用户
57 60
 
58
-        if(count($stockuserdatas) > 0){
59
-            $one_pack_comm_data = round($stock_comm / $GetAllUserPackNum,2);//获取每份的单佣金
61
+        $salesArr = [];
62
+        if (count($stockuserdatas) > 0) {
63
+            // $one_pack_comm_data = round($stock_comm / $GetAllUserPackNum,2);//获取每份的单佣金
64
+            $one_pack_comm_data = floor(($stock_comm / $GetAllUserPackNum) * 100) / 100;
60 65
 
61 66
             foreach ($stockuserdatas as &$v) {
62
-                $v['getcomm'] = $v['pack'] * $one_pack_comm_data;
63
-                $v['allgetcomm'] =  $v['allgetcomm'] + $v['getcomm'];
67
+                $salesArr[] = [
68
+                    'stock_comm' => $stock_comm,
69
+                    'GetAllUserPackNum' => $GetAllUserPackNum,
70
+                    'uid' => $v['user_id'],
71
+                    'pack' => $v['pack'],
72
+                    'one_pack_comm_data' => $one_pack_comm_data,
73
+                    'getcomm' => floor(($v['pack'] * $one_pack_comm_data) * 100) / 100
74
+                ];
75
+                $v['getcomm'] = floor(($v['pack'] * $one_pack_comm_data) * 100) / 100;
76
+                $v['allgetcomm'] = $v['allgetcomm'] + $v['getcomm'];
64 77
                 $v['update_time'] = time();
65 78
 
66 79
                 $yj_90 = $v['getcomm'] * 0.9;
@@ -73,46 +86,47 @@ class Taskorderguquan extends BaseController
73 86
                     'update_time' => $v['update_time']
74 87
                 ]);
75 88
 
76
-                Db::name("user")->where("uid",$v['user_id'])->inc("brokerage_price", $yj_90)->save();
77
-                $res1 = Db::name("user")->where("uid",$v['user_id'])->inc("total_amount_old", $yj_90)->save();
78
-                $res2 = Db::name("user")->where("uid",$v['user_id'])->inc("amount_old", $yj_90)->save();
89
+                Db::name("user")->where("uid", $v['user_id'])->inc("brokerage_price", $yj_90)->save();
90
+                $res1 = Db::name("user")->where("uid", $v['user_id'])->inc("total_amount_old", $yj_90)->save();
91
+                $res2 = Db::name("user")->where("uid", $v['user_id'])->inc("amount_old", $yj_90)->save();
79 92
 
80
-                $res3 = Db::name("user")->where("uid",$v['user_id'])->inc("fugou", $fg_10)->save();
93
+                $res3 = Db::name("user")->where("uid", $v['user_id'])->inc("fugou", $fg_10)->save();
81 94
 
82
-                $res =true;
83
-                if($res){
84
-                    $das = $this->change_user_log($v['user_id'],'amount_old',1, $yj_90,"member_award_stock","股权分红入账"."-".$v['pack']);//释放佣金
95
+                $res = true;
96
+                if ($res) {
97
+                    $das = $this->change_user_log($v['user_id'], 'amount_old', 1, $yj_90, "member_award_stock", "股权分红入账" . "-" . $v['pack']);//释放佣金
85 98
 
86 99
                     //入账星级分红记录表
87 100
                     $week_data = [];
88
-                    $week_data['user_id'] =  $v['user_id'];
89
-                    $week_data['user_star_id'] =  0;
90
-                    $week_data['award_num'] =  0;
91
-                    $week_data['award_num_sm'] =  0;
92
-                    $week_data['remark'] =  "股权分红主动执行" . $yj_90;
93
-                    $week_data['week_record'] =  $week_record;
94
-                    $week_data['all_amount'] =  $stock_comm;
95
-                    $week_data['radio'] =  2;
96
-                    $week_data['owner_bill'] =  0;  //总流水金额
101
+                    $week_data['user_id'] = $v['user_id'];
102
+                    $week_data['user_star_id'] = 0;
103
+                    $week_data['award_num'] = 0;
104
+                    $week_data['award_num_sm'] = 0;
105
+                    $week_data['remark'] = "股权分红主动执行" . $yj_90;
106
+                    $week_data['week_record'] = $weekRecord;
107
+                    $week_data['all_amount'] = $stock_comm;
108
+                    $week_data['radio'] = 2;
109
+                    $week_data['owner_bill'] = 0;  //总流水金额
97 110
                     $week_data['my_bill'] = 0;  //我的流水
98 111
                     $week_data['create_time'] = time();
99 112
 
100 113
 
101 114
                     Db::name("old_user_weekaward")->insert($week_data);
102 115
 
103
-                    $userdatassss = db::name("old_user_jbp")->where("id",$v['user_id'])->find();
116
+                    $userdatassss = db::name("old_user_jbp")->where("id", $v['user_id'])->find();
104 117
                     $datas_log = [
105
-                        'note'=>"名称:".  $userdatassss['nick_name']  . " 用户:".  $v['user_id'] . " 新增股权佣金:" .  $yj_90,
106
-                        'create_time'=>date('Y-m-d H:i:s')
118
+                        'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v['user_id'] . " 新增股权佣金:" . $yj_90,
119
+                        'create_time' => date('Y-m-d H:i:s')
107 120
                     ];
108 121
                     $con_data = Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
109 122
 
110
-                    $this->bill_user_log111111($v['user_id'],"股权分佣",  $yj_90,"股权明细入账",13);//股权分佣明细2.0系统
123
+                    $this->bill_user_log111111($v['user_id'], "股权分佣", $yj_90, "股权明细入账", 13);//股权分佣明细2.0系统
111 124
 
112
-                    $this->fugou_user_log($v['user_id'],$fg_10,16,1,1);//复购金明细入账
125
+                    $this->fugou_user_log($v['user_id'], $fg_10, 16, 1, 1);//复购金明细入账
113 126
                 }
114 127
             }
115 128
         }
129
+        return json($salesArr);
116 130
         //股权分红 end
117 131
     }
118 132
 
@@ -252,19 +266,15 @@ class Taskorderguquan extends BaseController
252 266
         return ['startTime' => $startTime, 'endTime' => $endTime];
253 267
     }
254 268
 
255
-    public function getTeamPvByTime($timePeriod = 'last_week', $removeUserIdList = [])
269
+    public function getTeamPvByTime($startTime, $endTime, $removeUserIdList = [])
256 270
     {
257
-        $timeMap = $this->getTime($timePeriod);
258
-        $startTime = $timeMap['startTime'];
259
-        $endTime = $timeMap['endTime'];
260
-
261 271
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
262 272
         $orders = Db::name("store_order")
263 273
             ->where('mer_id', 496)
264 274
             ->whereNotIn('uid', $removeUserIdList)
265 275
             ->whereIn('status', [0, 1, 2, 3])
266 276
             ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
267
-            ->whereBetween("pay_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
277
+            ->whereBetween("pay_time", [$startTime, $endTime])
268 278
             ->whereNotNull("pay_time") // 排除 pay_time 为 NULL 的订单
269 279
             ->select();
270 280
 
@@ -293,17 +303,13 @@ class Taskorderguquan extends BaseController
293 303
         return $totalPv;
294 304
     }
295 305
 
296
-    public function getRedEnvelopeByTime($timePeriod = 'last_week', $removeUserIdList = [])
306
+    public function getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList = [])
297 307
     {
298
-        $timeMap = $this->getTime($timePeriod);
299
-        $startTime = $timeMap['startTime'];
300
-        $endTime = $timeMap['endTime'];
301
-
302 308
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
303 309
         $redEnvelopeList = Db::name("user_sign_hongbao")
304 310
             ->whereNotIn('uid', $removeUserIdList)
305 311
             ->where('status', 1)
306
-            ->whereBetween("settlement_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
312
+            ->whereBetween("settlement_time", [$startTime, $endTime])
307 313
             ->select()
308 314
             ->toArray();
309 315
         return floor(array_sum(array_column($redEnvelopeList, 'number')) * 100) / 100;

+ 45 - 39
app/controller/api/store/merchant/Taskorderlianc.php

@@ -7,14 +7,9 @@
7 7
 
8 8
 namespace app\controller\api\store\merchant;
9 9
 
10
-use think\App;
11
-use crmeb\basic\BaseController;
12
-use app\common\repositories\system\merchant\MerchantRepository as repository;
13 10
 use think\facade\Db;
14
-use think\facade\Log;
15
-use function Symfony\Component\VarDumper\Dumper\esc;
16 11
 
17
-class Taskorderlianc extends BaseController
12
+class Taskorderlianc
18 13
 {
19 14
 
20 15
     /**
@@ -278,10 +273,8 @@ class Taskorderlianc extends BaseController
278 273
 
279 274
     public function lst2()
280 275
     {
281
-
282
-
283
-        $week_record = 10500 + 50000; //20250310
284
-
276
+        $startTime = '2025-03-10';
277
+        $endTime = '2025-03-30';
285 278
         // 查询测试人员账号信息
286 279
         //18973958920
287 280
         //15186694339
@@ -297,17 +290,26 @@ class Taskorderlianc extends BaseController
297 290
             ->select()
298 291
             ->toArray();
299 292
         $removeUserIdList = array_column($removeUserList, 'uid');
293
+
294
+        if (empty($startTime) || empty($endTime)) {
295
+            $timeMap = $this->getTime('last_week');
296
+            $startTime = $timeMap['startTime'] . ' 00:00:00';
297
+            $endTime = $timeMap['endTime'] . ' 23:59:59';
298
+        }
299
+
300 300
         // 定义分红金额
301
-        $week_record = $this->getTeamPvByTime('last_week', $removeUserIdList);
301
+        $weekRecord = $this->getTeamPvByTime($startTime, $endTime, $removeUserIdList);
302 302
         // 分红金额 - 红包金额
303
-        $redEnvelope = $this->getRedEnvelopeByTime('last_week', $removeUserIdList);
303
+        $redEnvelope = $this->getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList);
304 304
 
305
-        $week_record -= $redEnvelope;
305
+        $weekRecord -= $redEnvelope;
306
+        if ($weekRecord <= 0) {
307
+            return json('无效分红金额');
308
+        }
306 309
 
307 310
 
308
-        $originator_award = round(($week_record * 0.05), 2);
311
+        $originator_award = round(($weekRecord * 0.05), 2);
309 312
 
310
-        $list = Db::name("user")->where("originator_id_old", ">", 0)->where("status", 1)->field("uid,originator_id_old")->select()->toArray();
311 313
 
312 314
         // foreach($list as $k=>$v){
313 315
         //     var_dump($v);
@@ -318,14 +320,16 @@ class Taskorderlianc extends BaseController
318 320
         $sum_money = Db::name("old_user_lianc")->sum("number");
319 321
 
320 322
         $lianc_list = Db::name("old_user_lianc")->order("id desc")->field("id,number,title")->select()->toArray();
321
-        $user_arr = [];
322 323
 
323
-        $lianc_list_arr = [];
324
-        foreach ($lianc_list as $key => $value) {
325
-            # code...
326
-            $lianc_list_arr[$value['id']] = $value;
327
-        }
324
+        $lianc_list_arr = array_column($lianc_list, null, 'id');
328 325
 
326
+        $list = Db::name("user")
327
+            ->where("originator_id_old", ">", 0)
328
+            ->where("status", 1)
329
+            ->field("uid,originator_id_old")
330
+            ->select()
331
+            ->toArray();
332
+        $user_arr = [];
329 333
         foreach ($list as $key => $value) {
330 334
             # code...
331 335
             $user_arr[$value['originator_id_old']]['people'][] = $value['uid'];
@@ -334,22 +338,32 @@ class Taskorderlianc extends BaseController
334 338
             $user_arr[$value['originator_id_old']]['id'] = $lianc_list_arr[$value['originator_id_old']]['id'];
335 339
         }
336 340
 
337
-
338 341
         //处理计算权重 和平均分配的金额
339 342
         $total_num = 0;
340 343
         $count_num = 0;
341 344
         foreach ($user_arr as $key => $value) {
345
+            $user_arr[$key]['people_count'] = count($user_arr[$key]['people']);
342 346
             # code...
343
-            $total_num += round($value['money'] * count($value['people']) / 1000, 2);
347
+            // floor(($weekRecord * ($value['profit_rate'] / 100)) * 100) / 100;
348
+            // $total_num += round($value['money'] * count($value['people']) / 1000, 2);
349
+            $total_num += floor(($value['money'] * count($value['people'])) * 100) / 100;
350
+
351
+            if (isset($user_arr[$key]['total_num'])) {
352
+                $user_arr[$key]['total_num'] += floor(($value['money'] * count($value['people'])) * 100) / 100;
353
+            } else {
354
+                $user_arr[$key]['total_num'] = 0;
355
+            }
344 356
             $count_num += count($value['people']);
345 357
         }
346 358
         foreach ($user_arr as $key => $value) {
347 359
             # code...
348
-            $rate = round((count($value['people']) * $value['money']) / $total_num, 2) / 1000;
360
+            // $rate = round((count($value['people']) * $value['money']) / $total_num, 2) / 1000;
361
+            $rate = floor(($value['money'] * count($value['people']) / $total_num) * 100) / 100;
349 362
             $user_arr[$key]['rate'] = $rate;
350
-            $distribution_money = round($originator_award * $rate, 2);
363
+            $distribution_money = floor($originator_award * $rate * 100) / 100;
351 364
             $user_arr[$key]['distribution_money'] = $distribution_money;
352
-            $user_arr[$key]['people_award'] = round($distribution_money / count($value['people']), 2);//可分配佣金
365
+            // $user_arr[$key]['people_award'] = round($distribution_money / count($value['people']), 2);//可分配佣金
366
+            $user_arr[$key]['people_award'] = floor($distribution_money / count($value['people']) * 100) / 100;//可分配佣金
353 367
         }
354 368
 
355 369
         $count = 0;
@@ -359,7 +373,6 @@ class Taskorderlianc extends BaseController
359 373
             foreach ($value['people'] as $k => $v) {
360 374
                 # code...
361 375
                 $award = $value['people_award'];
362
-
363 376
                 //90给佣金,10给复购金
364 377
                 $yj_90 = $award * 0.9;
365 378
                 $fg_10 = $award * 0.1;
@@ -399,6 +412,7 @@ class Taskorderlianc extends BaseController
399 412
                 }
400 413
             }
401 414
         }
415
+        return json($user_arr);
402 416
     }
403 417
 
404 418
     //添加复购金
@@ -617,19 +631,15 @@ class Taskorderlianc extends BaseController
617 631
         return ['startTime' => $startTime, 'endTime' => $endTime];
618 632
     }
619 633
 
620
-    public function getTeamPvByTime($timePeriod = 'last_week', $removeUserIdList = [])
634
+    public function getTeamPvByTime($startTime, $endTime, $removeUserIdList = [])
621 635
     {
622
-        $timeMap = $this->getTime($timePeriod);
623
-        $startTime = $timeMap['startTime'];
624
-        $endTime = $timeMap['endTime'];
625
-
626 636
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
627 637
         $orders = Db::name("store_order")
628 638
             ->where('mer_id', 496)
629 639
             ->whereNotIn('uid', $removeUserIdList)
630 640
             ->whereIn('status', [0, 1, 2, 3])
631 641
             ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
632
-            ->whereBetween("pay_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
642
+            ->whereBetween("pay_time", [$startTime, $endTime])
633 643
             ->whereNotNull("pay_time") // 排除 pay_time 为 NULL 的订单
634 644
             ->select();
635 645
 
@@ -658,17 +668,13 @@ class Taskorderlianc extends BaseController
658 668
         return $totalPv;
659 669
     }
660 670
 
661
-    public function getRedEnvelopeByTime($timePeriod = 'last_week', $removeUserIdList = [])
671
+    public function getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList = [])
662 672
     {
663
-        $timeMap = $this->getTime($timePeriod);
664
-        $startTime = $timeMap['startTime'];
665
-        $endTime = $timeMap['endTime'];
666
-
667 673
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
668 674
         $redEnvelopeList = Db::name("user_sign_hongbao")
669 675
             ->whereNotIn('uid', $removeUserIdList)
670 676
             ->where('status', 1)
671
-            ->whereBetween("settlement_time", [$startTime . ' 00:00:00', $endTime . ' 23:59:59'])
677
+            ->whereBetween("settlement_time", [$startTime, $endTime])
672 678
             ->select()
673 679
             ->toArray();
674 680
         return floor(array_sum(array_column($redEnvelopeList, 'number')) * 100) / 100;

+ 2 - 2
app/controller/api/store/product/StoreProduct.php

@@ -251,7 +251,7 @@ class StoreProduct extends BaseController
251 251
     //生成邀请小程序码
252 252
     public function invite_code(){
253 253
         $uid = $this->request->param('uid',0);
254
-        $type = 0;//0-储蓄保 1-国盛 2-一壶茶
254
+        $type = 0;//0-幸福宝 1-国盛 2-一壶茶
255 255
         $imgId = $this->request->param('imgId',0);
256 256
 
257 257
         //删除老数据
@@ -556,7 +556,7 @@ class StoreProduct extends BaseController
556 556
                         'angle' => 0,
557 557
                     ),
558 558
                     array(
559
-                        'text' => '加入储蓄保,一起攒攒攒',
559
+                        'text' => '加入幸福宝,一起攒攒攒',
560 560
                         'left' => 400,
561 561
                         'top' => 1200,
562 562
                         'fontPath' => $filelink['Normal'],     //字体文件

+ 6 - 6
app/controller/api/store/service/Huafei.php

@@ -95,11 +95,11 @@ class Huafei extends BaseController
95 95
 					Db::name('log')->insert(['data'=>'话费充值汇付支付撤销返回结果:'.json_encode($hf_refund_res)]);
96 96
 
97 97
 					//把赠送出去的养老金 积分 贡献值 复购金 改为已失效
98
-					Db::name('user_bill')->where('order_sn', $huafeiInfo['order_no'])->update(['status'=> -1]);
99
-					Db::name('user_sign_score')->where('order_id', $huafeiInfo['order_no'])->update(['status'=> 0]);
100
-					Db::name('user_sign_gongxian')->where('order_id', $huafeiInfo['order_no'])->update(['status'=> 0]);
101
-					Db::name('user_sign_fugou')->where('order_id', $huafeiInfo['order_no'])->update(['status'=> 0]);
102
-					Db::name('user_sign_hongbao')->where('order_id', $huafeiInfo['order_no'])->update(['status'=> 0]);
98
+					Db::name('user_bill')->where('order_sn', $huafeiInfo['order_sn'])->update(['status'=> -1]);
99
+					Db::name('user_sign_score')->where('order_id', $huafeiInfo['order_sn'])->update(['status'=> 0]);
100
+					Db::name('user_sign_gongxian')->where('order_id', $huafeiInfo['order_sn'])->update(['status'=> 0]);
101
+					Db::name('user_sign_fugou')->where('order_id', $huafeiInfo['order_sn'])->update(['status'=> 0]);
102
+					Db::name('user_sign_hongbao')->where('order_id', $huafeiInfo['order_sn'])->update(['status'=> 0]);
103 103
 				}
104 104
 	
105 105
 				echo 'success';
@@ -301,7 +301,7 @@ class Huafei extends BaseController
301 301
 		$request['mobile'] = $phone;
302 302
 		$request['money'] = $money;
303 303
 		$request['recharge_type'] = 0;
304
-		$request['notify_url'] = 'https://api.hxxfb.com/api/huafei/notify';
304
+		$request['notify_url'] = 'https://' . request()->host() . '/api/huafei/notify';
305 305
 		return $this->execute('/rest/Recharge/PushOrder', $request);
306 306
 	}
307 307
 

+ 1 - 1
app/controller/api/user/Im.php

@@ -305,7 +305,7 @@ class Im
305 305
      * 加群
306 306
      * @param $group_id string 群组id
307 307
      * @param $user_id string 环信用户id
308
-     * @param $uid int 储蓄保用户id
308
+     * @param $uid int 幸福宝用户id
309 309
      */
310 310
     public function createGroupUser($group_id, $user_id, $uid)
311 311
     {

+ 108 - 34
app/controller/api/user/User.php

@@ -218,18 +218,22 @@ class User extends BaseController
218 218
         $where['uid'] = $uid;
219 219
 
220 220
         if ($pm==0){
221
-
222
-            $data = DB::name('user_sign_hongbao')->where($where)->where(['type' => 1,'status' => 1])->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
221
+            $data = DB::name('user_sign_hongbao')->where($where)->where('type',1)->where('status',1)->field('id,mark,number,type,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
223 222
         }
224 223
         if($pm==1){
225 224
             $data = DB::name('user_sign_hongbao')->where($where)->where(['type' => 2,'status' => 1])->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
226
-
227 225
         }
228 226
         if($pm==2){
229
-            $data = DB::name('user_sign_hongbao')->where($where)->where('status', -1)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
230
-
227
+            $data = DB::name('user_sign_hongbao')->where($where)->where('type',1)->where([['status','in','-1,0']])->field('id,mark,number,type,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
228
+            if($data){
229
+                $data = $data->toArray();
230
+                foreach ($data as $k=>$v){
231
+                    if($v['status'] == 0){
232
+                        $data[$k]['mark'] = '(失效)' . $v['mark'];
233
+                    }
234
+                }
235
+            }
231 236
         }
232
-        log::info("=======date==={$data}");
233 237
         return app("json")->success($data);
234 238
     }
235 239
 
@@ -310,6 +314,24 @@ class User extends BaseController
310 314
         log::info("============gongxianinfo");
311 315
         $user = $this->request->userInfo();
312 316
         if($user->uid>0){
317
+            // 先去更新一下用户身份
318
+            $number = Db::name("system_config_value")->where(["config_key" => "team_commission_recursion_depth"])->value("value");
319
+            $this->repository->setUserIdentity($user->uid);
320
+            $result = $this->repository->getUserContributeInfoByDepth($user->uid, $number);
321
+            $con = DB::name('user')->where('uid', $user->uid)->find();
322
+            $isNormalUser = false;
323
+            if ($con['user_group'] == 1) {
324
+                $isNormalUser = true;
325
+            }
326
+            $data = [
327
+                'no_total_source' => Db::name('user_sign_gongxian')->where('status', -1)->where('uid', $user->uid)->sum('number'),
328
+                'team_gongxian_num' => $result['arriveNumTeam'],
329
+                'zhitui' => $result['perContribute'],
330
+                'total_source' => $result['contribute'],
331
+                'isNormalUser' => $isNormalUser
332
+            ];
333
+            return app('json')->success($data);
334
+
313 335
 
314 336
            // $dateObj=DB::name('user_sign_gongxian')->where('uid', $user->uid)->where("status",1)->select();
315 337
             $con = DB::name('user')->where('uid', $user->uid)->find();
@@ -408,17 +430,24 @@ class User extends BaseController
408 430
 
409 431
         if ($pm==0){
410 432
 
411
-            $data = DB::name('user_sign_gongxian')->where($where)->where('status', 1)->where('number', '<>',0)->field('id,mark,number,addtime,order_id')->page($page, $limit)->order("id desc")->select();
433
+            $data = DB::name('user_sign_gongxian')->where($where)->where('status',1)->where('number', '<>',0)->field('id,mark,number,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
434
+
412 435
         }
413 436
 //        if($pm==1){
414 437
 //            $data = DB::name('user_sign_gongxian')->where($where)->where('pm', 2)->field('id,mark,number,pm,addtime,order_id')->page($page, $limit)->order("id desc")->select();
415 438
 //
416 439
 //        }
417 440
         if($pm==2){
418
-            $data = DB::name('user_sign_gongxian')->where($where)->where('number', '<>',0)->where('status', -1)->field('id,mark,number,addtime,order_id')->page($page, $limit)->order("id desc")->select();
419
-
441
+            $data = DB::name('user_sign_gongxian')->where($where)->where('number', '<>',0)->where([['status','in','-1,0']])->field('id,mark,number,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
442
+            if($data){
443
+                $data = $data->toArray();
444
+                foreach ($data as $k=>$v){
445
+                    if($v['status'] == 0){
446
+                        $data[$k]['mark'] = '(失效)' . $v['mark'];
447
+                    }
448
+                }
449
+            }
420 450
         }
421
-        log::info("=======date==={$data}");
422 451
         return app("json")->success($data);
423 452
     }
424 453
 
@@ -450,18 +479,25 @@ class User extends BaseController
450 479
 
451 480
         if ($pm==0){
452 481
 
453
-            $data = DB::name('user_sign_jingdou')->where($where)->where('type', 1)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
482
+            $data = DB::name('user_sign_jingdou')->where($where)->where('type', 1)->where('status',1)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
454 483
         }
455 484
         if($pm==1){
456 485
             $data = DB::name('user_sign_jingdou')->where($where)->where('type', 2)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
457 486
 
458 487
         }
459 488
         if($pm==2){
460
-            $data = DB::name('user_sign_jingdou')->where($where)->where('status', -1)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
489
+            $data = DB::name('user_sign_jingdou')->where($where)->where([['status','in','-1,0']])->field('id,mark,number,type,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
490
+            if($data){
491
+                $data = $data->toArray();
492
+                foreach ($data as $k=>$v){
493
+                    if($v['status'] == 0){
494
+                        $data[$k]['mark'] = '(失效)' . $v['mark'];
495
+                    }
496
+                }
497
+            }
461 498
         }
462 499
         // $data['total'] =111;
463 500
 
464
-        log::info("=======date==={$data}");
465 501
         return app("json")->success($data);
466 502
     }
467 503
 
@@ -490,15 +526,23 @@ class User extends BaseController
490 526
         $where['uid'] = $uid;
491 527
 
492 528
         if ($pm==0){
493
-            $data = DB::name('user_sign_fugou')->where($where)->where('type', 1)->where('status', 1)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
529
+            $data = DB::name('user_sign_fugou')->where($where)->where('type', 1)->where('status',1)->field('id,mark,number,type,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
530
+
494 531
         }
495 532
         if($pm==1){
496 533
             $data = DB::name('user_sign_fugou')->where($where)->where('type', 2)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
497 534
         }
498 535
         if($pm==2){
499
-            $data = DB::name('user_sign_fugou')->where($where)->where('status', -1)->field('id,mark,number,type,addtime,order_id')->page($page, $limit)->order("id desc")->select();
536
+            $data = DB::name('user_sign_fugou')->where($where)->where('type', 1)->where([['status','in','-1,0']])->field('id,mark,number,type,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
537
+            if($data){
538
+                $data = $data->toArray();
539
+                foreach ($data as $k=>$v){
540
+                    if($v['status'] == 0){
541
+                        $data[$k]['mark'] = '(失效)' . $v['mark'];
542
+                    }
543
+                }
544
+            }
500 545
         }
501
-        log::info("=======date==={$data}");
502 546
         return app("json")->success($data);
503 547
     }
504 548
 
@@ -1143,8 +1187,16 @@ class User extends BaseController
1143 1187
         if ($source > -1) {
1144 1188
             $where['source'] = $source;
1145 1189
         }
1146
-        $res = $this->repository->yanglaolog($where, $page, $limit, $month);
1190
+        $res = $this->repository->yanglaolog($where, $page, $limit, $month,1);
1147 1191
         if ($res) {
1192
+            $res['list'] = $res['list']->toArray();
1193
+            if($res['list']){
1194
+                foreach ($res['list'] as $k=>$v){
1195
+                    if($v['status'] == -1){
1196
+                        $res['list'][$k]['mer_name'] = $v['mer_name'] . '(失效)';
1197
+                    }
1198
+                }
1199
+            }
1148 1200
             return app('json')->success($res);
1149 1201
         } else {
1150 1202
             return app('json')->fail('获取失败');
@@ -1565,7 +1617,7 @@ class User extends BaseController
1565 1617
     public function team_list()
1566 1618
     {
1567 1619
         $teamid = $this->request->uid();
1568
-
1620
+        [$page,$limit] = $this->getPage();
1569 1621
         //小夏重写部分
1570 1622
         $user_id = $teamid;
1571 1623
         //如果下级团队只有一个人 那就不用再查了 为0
@@ -1648,22 +1700,33 @@ class User extends BaseController
1648 1700
                 'person_nums_pv' => 0, // 个人联盟PV
1649 1701
             ];
1650 1702
 
1651
-            $data1 = [
1652
-                "total" => 100,
1653
-                "per_page" => 10,
1654
-                "current_page" => 1,
1655
-                "last_page" => 1,
1656
-                "data" => []
1657
-            ];
1658 1703
 
1659 1704
             if ($type != 2) {
1660 1705
                 if($type == 1){
1661
-                    $data1['data'] = $person_list;
1706
+                    $data1 = [
1707
+                        "total" => count($person_list),
1708
+                        "per_page" => (int)$limit,
1709
+                        "current_page" => $page,
1710
+                        "last_page" => ceil(count($person_list) / $limit),
1711
+                        "data" => array_slice($person_list, ($page - 1) * $limit, $limit)
1712
+                    ];
1662 1713
                 }else{
1663
-                    $data1['data'] = $common_list;
1714
+                    $data1 = [
1715
+                        "total" => count($common_list),
1716
+                        "per_page" => (int)$limit,
1717
+                        "current_page" => $page,
1718
+                        "last_page" => ceil(count($common_list) / $limit),
1719
+                        "data" => array_slice($common_list, ($page - 1) * $limit, $limit)
1720
+                    ];
1664 1721
                 }
1665 1722
             } else {
1666
-                $data1['data'] = $aLL_list;
1723
+                $data1 = [
1724
+                    "total" => count($aLL_list),
1725
+                    "per_page" => (int)$limit,
1726
+                    "current_page" => $page,
1727
+                    "last_page" => ceil(count($aLL_list) / $limit),
1728
+                    "data" => array_slice($aLL_list, ($page - 1) * $limit, $limit)
1729
+                ];
1667 1730
             }
1668 1731
 
1669 1732
             // 旧系统中的公共部分数据
@@ -2182,17 +2245,24 @@ class User extends BaseController
2182 2245
 //        }
2183 2246
         if ($pm==0){
2184 2247
 
2185
-            $data = DB::name('user_sign_score')->where($where)->where('pm', 1)->where('status', 1)->field('id,mark,reward_socre,pm,addtime,order_id')->page($page, $limit)->order("id desc")->select();
2248
+            $data = DB::name('user_sign_score')->where($where)->where('pm', 1)->where('status',1)->field('id,mark,reward_socre,pm,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
2249
+
2186 2250
         }
2187 2251
         if($pm==1){
2188 2252
             $data = DB::name('user_sign_score')->where($where)->where('pm', 2)->where('status', 1)->field('id,mark,reward_socre,pm,addtime,order_id')->page($page, $limit)->order("id desc")->select();
2189 2253
 
2190 2254
         }
2191 2255
         if($pm==2){
2192
-            $data = DB::name('user_sign_score')->where($where)->where('status', -1)->field('id,mark,reward_socre,pm,addtime,order_id')->page($page, $limit)->order("id desc")->select();
2193
-
2256
+            $data = DB::name('user_sign_score')->where($where)->where([['status','in','-1,0']])->field('id,mark,reward_socre,pm,addtime,order_id,status')->page($page, $limit)->order("id desc")->select();
2257
+            if($data){
2258
+                $data = $data->toArray();
2259
+                foreach ($data as $k=>$v){
2260
+                    if($v['status'] == 0){
2261
+                        $data[$k]['mark'] = '(失效)' . $v['mark'];
2262
+                    }
2263
+                }
2264
+            }
2194 2265
         }
2195
-        log::info("=======date==={$data}");
2196 2266
         return app("json")->success($data);
2197 2267
 
2198 2268
     }
@@ -2264,6 +2334,10 @@ class User extends BaseController
2264 2334
             if ($v['status'] == 1) {
2265 2335
 //                $v['create_time'] = $v['take_time'];
2266 2336
             }
2337
+            if ($v['status'] == -1) {
2338
+                $v['mark'] = '(失效)' . $v['mark'];
2339
+//                $v['status'] = 0;
2340
+            }
2267 2341
 
2268 2342
             $data_arr[] = $v;
2269 2343
         }
@@ -3204,7 +3278,7 @@ class User extends BaseController
3204 3278
                 'app_id'      => $app_id,
3205 3279
                 'pay_channel' => $pay_channel,
3206 3280
                 'pay_amt'     => (string)$order['pay_price'],
3207
-                'goods_title' => "储蓄保",
3281
+                'goods_title' => "幸福宝",
3208 3282
                 'goods_desc'  => $title,
3209 3283
                 'device_info' => [
3210 3284
                     'device_ip' => app('request')->ip()
@@ -3575,7 +3649,7 @@ class User extends BaseController
3575 3649
                     'surplus' => $vr,
3576 3650
                     'mark' => '红包转VR',
3577 3651
                     'type' => 2,
3578
-                    'status' => -1,
3652
+                    'status' => 1,
3579 3653
                     'addtime' => time(),
3580 3654
                 ];
3581 3655
                 Db::name('user_sign_hongbao')->insertGetId($insertdata);

+ 3 - 3
app/controller/api/user/UserExtract.php

@@ -80,9 +80,9 @@ class UserExtract extends BaseController
80 80
 
81 81
         $sms_code = $this->request->param('sms_code');
82 82
 
83
-        if (!$this->checkSmsCode($user['account'], $sms_code) && $sms_code != '9527'){
84
-            return app('json')->fail('验证码不正确');
85
-        }
83
+        // if (!$this->checkSmsCode($user['account'], $sms_code) && $sms_code != '9527'){
84
+        //     return app('json')->fail('验证码不正确');
85
+        // }
86 86
 
87 87
         if(!in_array($data["extract_type"],[1,2,3])){
88 88
             return app('json')->fail('不支持的类型,请选择微信或支付宝');

+ 1 - 1
app/controller/merchant/Common.php

@@ -58,7 +58,7 @@ class Common extends BaseController
58 58
         $merId = $this->merId;
59 59
 
60 60
         // $list['gongxian'] = Db::name('user_sign_gongxian')->where('mer_id', $merId)->sum('number');
61
-        $list['jingdou'] = Db::name('user_sign_jingdou')->where('mer_id', $merId)->sum('number');
61
+        $list['jingdou'] = Db::name('user_sign_jingdou')->where('mer_id', $merId)->where('status',1)->sum('number');
62 62
         $list['fenrunzhi'] = Db::name('order_merchant')->where('mer_id', $merId)->where('paid', 1)->sum('available');
63 63
     
64 64
         $list['xianxia'] = Db::name('order_merchant')->where('mer_id', $merId)->where('paid', 1)->count();

+ 3 - 2
app/controller/merchant/store/order/RefundOrder.php

@@ -43,9 +43,10 @@ class RefundOrder extends BaseController
43 43
     public function lst()
44 44
     {
45 45
         list($page,$limit) = $this->getPage();
46
-        $where = $this->request->params(['refund_order_sn','status','refund_type','date','order_sn']);
46
+        $where = $this->request->params(['refund_order_sn','refund_type','date','order_sn']);
47
+        $status = $this->request->params('status');
47 48
         $where['mer_id'] = $this->request->merId();
48
-        return app('json')->success($this->repository->getList($where,$page,$limit));
49
+        return app('json')->success($this->repository->getList($where,$page,$limit,$status));
49 50
     }
50 51
 
51 52
     /**

+ 4 - 0
route/admin.php

@@ -857,6 +857,10 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
857 857
         Route::group('finance', function () {
858 858
             Route::get('order_overview', '/order_overview');
859 859
             Route::get('user_overview', '/user_overview');
860
+            Route::get('member_overview', '/member_overview');
861
+            Route::get('pv_overview', '/pv_overview');
862
+            Route::get('vr_overview', '/vr_overview');
863
+            Route::get('jifen_overview', '/jifen_overview');
860 864
             Route::get('transaction_overview', '/transaction_overview');
861 865
             Route::get('user_bill', '/user_bill');
862 866
             Route::get('integral_list', '/integral_list');

+ 3 - 3
route/api.php

@@ -1293,9 +1293,9 @@ Route::group('api/', function () {
1293 1293
     ->middleware(\app\common\middleware\InstallMiddleware::class)
1294 1294
     ->middleware(\app\common\middleware\CheckSiteOpenMiddleware::class);
1295 1295
 //Route::get('/sxb_test', 'api.store.merchant.TaskPartnerProfits/partnerProfits');
1296
-Route::get('sxb_test', function () {
1297
-    return 'hello,ThinkPHP6!';
1298
-});
1296
+Route::get('test_hehuoren', 'api.store.merchant.TaskPartnerProfits/partnerProfits');
1297
+Route::get('test_guquan', 'api.store.merchant.Taskorderguquan/lst6');
1298
+Route::get('test_lianchuang', 'api.store.merchant.Taskorderlianc/lst2');
1299 1299
 Route::any('/share', function () {
1300 1300
     return view(app()->getRootPath() . 'public/share/register.html');
1301 1301
 });