Browse Source

Merge branch 'master' of https://git.bjtdba.com/shop/php

hefei 1 year ago
parent
commit
b4fa677160

+ 376 - 60
app/common/repositories/finance/FinanceRepository.php

@@ -28,98 +28,415 @@ 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[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[1] ?? 0), 'name' => '消费者'];
208
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[2] ?? 0), 'name' => '业务员'];
209
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[3] ?? 0), 'name' => '业务经理'];
210
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[5] ?? 0), 'name' => '初级合伙人'];
211
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[6] ?? 0), 'name' => '中级合伙人'];
212
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[7] ?? 0), 'name' => '高级合伙人'];
213
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[8] ?? 0), 'name' => '董事'];
214
+
215
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_user` where {$where} and originator_id_old > 0");
216
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '联创'];
217
+
218
+        $maker = Db::query("SELECT count(user_id) as count FROM `rrx_old_user_stock` where {$where}");
219
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '股权'];
220
+
221
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
222
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '商户'];
223
+
224
+        $res['left'][] = $data;
225
+        // $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
226
+        // $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '创客'];
227
+
228
+        return $res;
229
+    }
230
+
231
+
232
+
233
+    /**
234
+     * 会员概况
235
+     * @param int $mer_id
236
+     * @return array
237
+     * @throws \Exception
238
+     */
239
+    public function member_overview($mer_id = 0)
240
+    {
241
+        $where = "1=1 ";
242
+        if ($mer_id) {
243
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
244
+            $userRepository = app()->make(UserRepository::class);
245
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
246
+            $chilid_userids_string = "1";
247
+            if (!empty($chilid_userids)) {
248
+                $chilid_userids_string = implode(',',$chilid_userids);
249
+            }
250
+            $where .= "and uid in ({$chilid_userids_string})";
251
+        }
252
+        $type = input('type', 1);
253
+        $day = input('day', '');
254
+
255
+        if ($type == 1 and $day != '') {
256
+            $where .= " and DATE(create_time) = '" . $day . "'";
49 257
         }
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' => '虚拟支付金额'];
258
+        if ($type == 2 and $day != '') {
259
+            $date = new \DateTime($day);
260
+            $year = $date->format('Y');
261
+            $month = $date->format('m');
262
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
59 263
         }
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();
264
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
265
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
266
+        $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");
267
+
268
+        $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");
269
+        $maker = array_column($maker, 'count', 'k');
64 270
 
65
-        $chengjiaocount = $xianshangzhifunum + $hongjifenxiaofeinum;
271
+        $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
272
+        $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
66 273
 
67
-        $list2[] = ['count' => $xianshangzhifunum, 'name' => '线上支付订单量'];
68
-        if (!$mer_id) {
69
-            $list2[] = ['count' => $xianshangzhifunum_xuni, 'name' => '虚拟支付订单量'];
274
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[1] ?? 0), 'name' => '消费者'];
275
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[2] ?? 0), 'name' => '业务员'];
276
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[3] ?? 0), 'name' => '业务经理'];
277
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[5] ?? 0), 'name' => '初级合伙人'];
278
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[6] ?? 0), 'name' => '中级合伙人'];
279
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[7] ?? 0), 'name' => '高级合伙人'];
280
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[8] ?? 0), 'name' => '董事'];
281
+        $list1 = array(
282
+            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-2'] ?? 0), 'name' => '集团会员'),//is_show=2
283
+            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-1'] ?? 0), 'name' => '电商创客'),
284
+            array('className' => 'el-icon-s-goods', 'count' => intval($userByCodeCount['temp'] ?? 0), 'name' => '激活创客'),
285
+        );
286
+
287
+        if ($mer_id) {
288
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[4] ?? 0), 'name' => '创客'];
70 289
         }
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' => '虚拟支付人数'];
290
+        $res['left'][] = $data;
291
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
292
+        $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '创客'];
293
+
294
+        return $res;
295
+    }
296
+
297
+
298
+
299
+
300
+    /**
301
+     * pv概况
302
+     * @param int $mer_id
303
+     * @return array
304
+     * @throws \Exception
305
+     */
306
+    public function pv_overview($mer_id = 0)
307
+    {
308
+        $where = "1=1 ";
309
+        if ($mer_id) {
310
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
311
+            $userRepository = app()->make(UserRepository::class);
312
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
313
+            $chilid_userids_string = "1";
314
+            if (!empty($chilid_userids)) {
315
+                $chilid_userids_string = implode(',',$chilid_userids);
316
+            }
317
+            $where .= "and uid in ({$chilid_userids_string})";
80 318
         }
81
-        $list3[] = ['count' => 0, 'name' => '代付人数'];
319
+        $type = input('type', 1);
320
+        $day = input('day', '');
82 321
 
322
+        if ($type == 1 and $day != '') {
323
+            $where .= " and DATE(create_time) = '" . $day . "'";
324
+        }
325
+        if ($type == 2 and $day != '') {
326
+            $date = new \DateTime($day);
327
+            $year = $date->format('Y');
328
+            $month = $date->format('m');
329
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
330
+        }
331
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
332
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
333
+        $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");
83 334
 
84
-        $xianshangtuikuan = Db::name('store_order')->where($where)->where('status', -1)->sum('pay_price');
335
+        $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");
336
+        $maker = array_column($maker, 'count', 'k');
85 337
 
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();
338
+        $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
339
+        $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
92 340
 
93
-        $tuikuancount = $xianshangzhifutuinum;
94
-        $list5 = array(
95
-            array('count' => set_price_rtrim($xianshangzhifutuinum), 'name' => '线上支付退单量'),
96
-            array('count' => 0, 'name' => '代付退单量'),
341
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[1] ?? 0), 'name' => '消费者'];
342
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[2] ?? 0), 'name' => '业务员'];
343
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[3] ?? 0), 'name' => '业务经理'];
344
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[5] ?? 0), 'name' => '初级合伙人'];
345
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[6] ?? 0), 'name' => '中级合伙人'];
346
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[7] ?? 0), 'name' => '高级合伙人'];
347
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[8] ?? 0), 'name' => '董事'];
348
+        $list1 = array(
349
+            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-2'] ?? 0), 'name' => '集团会员'),//is_show=2
350
+            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-1'] ?? 0), 'name' => '电商创客'),
351
+            array('className' => 'el-icon-s-goods', 'count' => intval($userByCodeCount['temp'] ?? 0), 'name' => '激活创客'),
97 352
         );
98
-        $xianshangzhifutuiremn = Db::name('store_order')->where($where)->where('status', -1)->group('uid')->count();
99 353
 
100
-        $tuikuanren = $xianshangzhifutuiremn;
101
-        $list6 = array(
102
-            array('count' => set_price_rtrim($xianshangzhifutuiremn), 'name' => '线上支付退单人数'),
103
-            array('count' => 0, 'name' => '代付退单数'),
354
+        if ($mer_id) {
355
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[4] ?? 0), 'name' => '创客'];
356
+        }
357
+        $res['left'][] = $data;
358
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
359
+        $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '创客'];
360
+
361
+        return $res;
362
+    }
363
+
364
+
365
+
366
+
367
+    /**
368
+     * vr概况
369
+     * @param int $mer_id
370
+     * @return array
371
+     * @throws \Exception
372
+     */
373
+    public function vr_overview($mer_id = 0)
374
+    {
375
+        $where = "1=1 ";
376
+        if ($mer_id) {
377
+            $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
378
+            $userRepository = app()->make(UserRepository::class);
379
+            $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
380
+            $chilid_userids_string = "1";
381
+            if (!empty($chilid_userids)) {
382
+                $chilid_userids_string = implode(',',$chilid_userids);
383
+            }
384
+            $where .= "and uid in ({$chilid_userids_string})";
385
+        }
386
+        $type = input('type', 1);
387
+        $day = input('day', '');
388
+
389
+        if ($type == 1 and $day != '') {
390
+            $where .= " and DATE(create_time) = '" . $day . "'";
391
+        }
392
+        if ($type == 2 and $day != '') {
393
+            $date = new \DateTime($day);
394
+            $year = $date->format('Y');
395
+            $month = $date->format('m');
396
+            $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
397
+        }
398
+        $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
399
+        $dataQuery = array_column($dataQuery, 'count', 'user_group');
400
+        $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");
401
+
402
+        $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");
403
+        $maker = array_column($maker, 'count', 'k');
404
+
405
+        $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
406
+        $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
407
+
408
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[1] ?? 0), 'name' => '消费者'];
409
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[2] ?? 0), 'name' => '业务员'];
410
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[3] ?? 0), 'name' => '业务经理'];
411
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[5] ?? 0), 'name' => '初级合伙人'];
412
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[6] ?? 0), 'name' => '中级合伙人'];
413
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[7] ?? 0), 'name' => '高级合伙人'];
414
+        $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[8] ?? 0), 'name' => '董事'];
415
+        $list1 = array(
416
+            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-2'] ?? 0), 'name' => '集团会员'),//is_show=2
417
+            array('className' => 'el-icon-s-goods', 'count' => intval($maker['4-1'] ?? 0), 'name' => '电商创客'),
418
+            array('className' => 'el-icon-s-goods', 'count' => intval($userByCodeCount['temp'] ?? 0), 'name' => '激活创客'),
104 419
         );
105 420
 
421
+        if ($mer_id) {
422
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[4] ?? 0), 'name' => '创客'];
423
+        }
424
+        $res['left'][] = $data;
425
+        $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
426
+        $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '创客'];
106 427
 
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;
428
+        return $res;
114 429
     }
115 430
 
431
+
432
+
116 433
     /**
117
-     * 用户概况
434
+     * 积分概况
118 435
      * @param int $mer_id
119 436
      * @return array
120 437
      * @throws \Exception
121 438
      */
122
-    public function user_overview($mer_id = 0)
439
+    public function jifen_overview($mer_id = 0)
123 440
     {
124 441
         $where = "1=1 ";
125 442
         if ($mer_id) {
@@ -168,18 +485,17 @@ class FinanceRepository extends BaseRepository
168 485
         );
169 486
 
170 487
         if ($mer_id) {
171
-//            $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($shopPartnerCount), 'name' => '创客合伙人'];
172 488
             $data[] = ['className' => 'el-icon-s-goods', 'count' => (int)($dataQuery[4] ?? 0), 'name' => '创客'];
173 489
         }
174 490
         $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' => '创客'];
176
-
177 491
         $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
178 492
         $res['right'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '创客'];
179 493
 
180 494
         return $res;
181 495
     }
182 496
 
497
+
498
+
183 499
     public function jieyu($type, $day, $mer_id = 0)
184 500
     {
185 501
 

+ 1 - 1
app/common/repositories/store/order/StoreOrderRepository.php

@@ -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;

+ 160 - 5
app/common/repositories/user/UserRepository.php

@@ -3283,12 +3283,59 @@ class UserRepository extends BaseRepository
3283 3283
 
3284 3284
         // 3、获取个人贡献值
3285 3285
         $userData = $this->dao->get($uid)->toArray();
3286
-        if ($userData['is_old'] == 1 && $userData['user_group'] > 1 && empty($userData['identity_up_time'])) {
3287
-            if (empty($userData['create_time'])) {
3288
-                return $userData['user_group'];
3286
+        // 这一步骤是为了 确定用户升级时间,因为后边的团队贡献值,需要查询 用户 升级为业务员后 所产生的团队贡献值
3287
+        if (empty($userData['identity_up_time'])) {
3288
+            // 老用户的身份 升级时间已无法确定, 则采用用户的创建时间
3289
+            if ($userData['is_old'] == 1 && $userData['user_group'] > 1) {
3290
+                if (empty($userData['create_time'])) {
3291
+                    return $userData['user_group'];
3292
+                }
3293
+                $userData['identity_up_time'] = $userData['create_time'];
3294
+                $this->dao->update($uid, ['identity_up_time' => $userData['identity_up_time']]);
3295
+            }
3296
+            // 如果是新用户 则 根绝他的贡献值记录表 确认成为业务员的时间
3297
+            if ($userData['is_old'] == 0) {
3298
+                $upArriveNumOwn = 0;
3299
+                $yeWuYuanId = 0;
3300
+                foreach ($identityList as $value) {
3301
+                    if ($value['user_group_name'] == '业务员') {
3302
+                        $upArriveNumOwn = $value['arrive_num_own'];
3303
+                        $yeWuYuanId = $value['user_group_id'];
3304
+                        break;
3305
+                    }
3306
+                }
3307
+                if (!empty($upArriveNumOwn)) {
3308
+                    $userSignGongxianList = Db::name('user_sign_gongxian')
3309
+                        ->where('uid', $uid)
3310
+                        ->where('status', 1) // 贡献值状态1-有效 0-失效 -1待确认
3311
+                        ->whereNotNull('settlement_time') // `settlement_time` datetime DEFAULT NULL COMMENT '结算时间',
3312
+                        ->order('id asc')
3313
+                        ->field('uid, number, type, settlement_time') // 只需要下级的uid和贡献值
3314
+                        ->select()
3315
+                        ->toArray();
3316
+                    $myArriveNumOwn = 0;
3317
+                    $myIdentityUpTime = '';
3318
+                    foreach ($userSignGongxianList as $value) {
3319
+                        if ($value['type'] == 1) {
3320
+                            $myArriveNumOwn += $value['number'];
3321
+                        } else {
3322
+                            $myArriveNumOwn -= $value['number'];
3323
+                        }
3324
+                        if ($myArriveNumOwn >= $upArriveNumOwn) {
3325
+                            $myIdentityUpTime = $value['settlement_time'];
3326
+                            break;
3327
+                        }
3328
+                    }
3329
+                    if (!empty($myIdentityUpTime) && !empty($yeWuYuanId)) {
3330
+                        $userData['identity_up_time'] = $userData['create_time'];
3331
+                        $userData['user_group'] = $yeWuYuanId;
3332
+                        $this->dao->update($uid, [
3333
+                            'identity_up_time' => $myIdentityUpTime,
3334
+                            'user_group' => $yeWuYuanId
3335
+                        ]);
3336
+                    }
3337
+                }
3289 3338
             }
3290
-            $userData['identity_up_time'] = $userData['create_time'];
3291
-            $this->dao->update($uid, ['identity_up_time' => $userData['identity_up_time']]);
3292 3339
         }
3293 3340
         if ($userData['user_group'] == 1) {
3294 3341
             $maxLvRestrict = 2;
@@ -3535,4 +3582,112 @@ class UserRepository extends BaseRepository
3535 3582
 
3536 3583
         return $levelContributions;
3537 3584
     }
3585
+
3586
+    public function getUserContributeInfoByDepth($uid, $depth = 10)
3587
+    {
3588
+        // 3、获取个人贡献值
3589
+        $userData = $this->dao->get($uid)->toArray();
3590
+        // 这一步骤是为了 确定用户升级时间,因为后边的团队贡献值,需要查询 用户 升级为业务员后 所产生的团队贡献值
3591
+        if (empty($userData['identity_up_time'])) {
3592
+            // 老用户的身份 升级时间已无法确定, 则采用用户的创建时间
3593
+            if ($userData['is_old'] == 1 && $userData['user_group'] > 1) {
3594
+                if (empty($userData['create_time'])) {
3595
+                    return $userData['user_group'];
3596
+                }
3597
+                $userData['identity_up_time'] = $userData['create_time'];
3598
+                $this->dao->update($uid, ['identity_up_time' => $userData['identity_up_time']]);
3599
+            }
3600
+            // 如果是新用户 则 根绝他的贡献值记录表 确认成为业务员的时间
3601
+            if ($userData['is_old'] == 0) {
3602
+                $upArriveNumOwn = 0;
3603
+                $yeWuYuanId = 0;
3604
+                // 1、获取所有等级信息
3605
+                /** @var UserIdentityRepository $identityRepository */
3606
+                $identityRepository = app()->make(UserIdentityRepository::class);
3607
+                $identityList = $identityRepository->getIdentityList();
3608
+                foreach ($identityList as $value) {
3609
+                    if ($value['user_group_name'] == '业务员') {
3610
+                        $upArriveNumOwn = $value['arrive_num_own'];
3611
+                        $yeWuYuanId = $value['user_group_id'];
3612
+                        break;
3613
+                    }
3614
+                }
3615
+                if (!empty($upArriveNumOwn)) {
3616
+                    $userSignGongxianList = Db::name('user_sign_gongxian')
3617
+                        ->where('uid', $uid)
3618
+                        ->where('status', 1) // 贡献值状态1-有效 0-失效 -1待确认
3619
+                        ->whereNotNull('settlement_time') // `settlement_time` datetime DEFAULT NULL COMMENT '结算时间',
3620
+                        ->order('id asc')
3621
+                        ->field('uid, number, type, settlement_time') // 只需要下级的uid和贡献值
3622
+                        ->select()
3623
+                        ->toArray();
3624
+                    $myArriveNumOwn = 0;
3625
+                    $myIdentityUpTime = '';
3626
+                    foreach ($userSignGongxianList as $value) {
3627
+                        if ($value['type'] == 1) {
3628
+                            $myArriveNumOwn += $value['number'];
3629
+                        } else {
3630
+                            $myArriveNumOwn -= $value['number'];
3631
+                        }
3632
+                        if ($myArriveNumOwn >= $upArriveNumOwn) {
3633
+                            $myIdentityUpTime = $value['settlement_time'];
3634
+                            break;
3635
+                        }
3636
+                    }
3637
+                    if (!empty($myIdentityUpTime) && !empty($yeWuYuanId)) {
3638
+                        $userData['identity_up_time'] = $userData['create_time'];
3639
+                        $userData['user_group'] = $yeWuYuanId;
3640
+                        $this->dao->update($uid, [
3641
+                            'identity_up_time' => $userData['identity_up_time'],
3642
+                            'user_group' => $yeWuYuanId
3643
+                        ]);
3644
+                    }
3645
+                }
3646
+            }
3647
+        }
3648
+
3649
+        // 如果用户身份是  用户  则
3650
+        /**
3651
+         * (1)达标贡献值=自己消费产生的贡献值
3652
+         * (2)团队达标贡献值=小区团队的贡献值(用户的团队贡献值只统计一级);如果团队只有一人,那团队贡献值就是0
3653
+         */
3654
+        if ($userData['user_group'] == 1) {
3655
+            $depth = 1;
3656
+        }
3657
+
3658
+        // 4、获取下级用户 贡献值
3659
+        $userContributionSumMap = [];
3660
+        // 获取用户的直属下级
3661
+        $uidContributeList = $this->getUidContributeListBySpreadUidList([$uid]);
3662
+        foreach ($uidContributeList as $uidContribute) {
3663
+            // 获取每个下级(部门)的个人贡献值
3664
+            $userContributionSumMap[$uidContribute['uid']] = $this->getContributionSumByLevel(
3665
+                [$uidContribute['uid']],
3666
+                $depth,
3667
+                $userData['is_old'],
3668
+                $userData['identity_up_time'] ?? null
3669
+            );
3670
+            $userContributionSumMap[$uidContribute['uid']][0] = $uidContribute['contribute'];
3671
+            // 假设 老大的 下级是 张三和李四, 董事(最高级身份)需要循环最深的等级是 3 级    得出来的结果↓  这样是为了计算大小部门
3672
+            // $userContributionSumMap[直属下级(部门)张三] =>[0 => 张三个人贡献值, 1 => 张三所有下级用户的个人贡献值, 2 => 张三所有下级用户的下级用户贡献值]
3673
+            // $userContributionSumMap[直属下级(部门)李四] =>[0 => 李四个人贡献值, 1 => 李四所有下级用户的个人贡献值, 2 => 李四所有下级用户的下级用户贡献值]
3674
+        }
3675
+
3676
+        $subordinateContribution = [];
3677
+        foreach ($userContributionSumMap as $key => $value) {
3678
+            $subordinateContribution[$key] = array_sum($value);
3679
+        }
3680
+        $arriveNumTeam = 0;
3681
+        if (!empty($subordinateContribution)) {
3682
+            // 大区业绩
3683
+            $dqYj = max($subordinateContribution);
3684
+            // 总业绩
3685
+            $zYj = array_sum($subordinateContribution);
3686
+            // 小区团体业绩
3687
+            $arriveNumTeam = bcsub($zYj, $dqYj, 2);
3688
+        }
3689
+
3690
+        return ['arriveNumTeam' => $arriveNumTeam, 'contribute' => $userData['contribute'], 'per_contribute' => $userData['per_contribute']];
3691
+
3692
+    }
3538 3693
 }

+ 88 - 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,92 @@ 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['shouyi']), 'name' => '佣金奖励总额'];
103
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jieyu']), 'name' => '结余总额'];
104
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hf_fee_amt']), 'name' => '汇付通道服务费金额'];
105
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['integral']), 'name' => '积分总数'];
106
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['tixinan']), 'name' => '提现支出总额'];
107
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['yanglao']), 'name' => '养老金总额'];
108
+    
109
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['gongxian']), 'name' => '贡献值总额'];
110
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['jingdou']), 'name' => '京豆总额'];
111
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['hongbao']), 'name' => '红包总额'];
112
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['fugou']), 'name' => '复购金总额'];
113
+            $data[] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($arr['vr']), 'name' => 'VR总额'];
114
+            return app('json')->success('ok', $data);
115
+        } catch (\Exception $e) {
116
+            Db::name('log')->insert(['data' => '交易详情统计错误:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】']);
117
+            return app('json')->fail('统计失败'. $e->getMessage());
118
+        }
119
+    }
120
+
34 121
     /**
35 122
      * 积分统计
36 123
      * @return mixed
@@ -188,41 +275,6 @@ class Finance extends BaseController
188 275
         }
189 276
     }
190 277
 
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 278
 
227 279
     public function day_bill_list()
228 280
     {

+ 13 - 0
app/controller/api/user/User.php

@@ -316,6 +316,19 @@ class User extends BaseController
316 316
         log::info("============gongxianinfo");
317 317
         $user = $this->request->userInfo();
318 318
         if($user->uid>0){
319
+            $con = DB::name('user')->where('uid', $user->uid)->find();
320
+            // 先去更新一下用户身份
321
+            $number = Db::name("system_config_value")->where(["config_key" => "team_commission_recursion_depth"])->value("value");
322
+            $this->repository->setUserIdentity($user->uid);
323
+            $result = $this->repository->getUserContributeInfoByDepth($user->uid, $number);
324
+            $data = [
325
+                'no_total_source' => Db::name('user_sign_gongxian')->where('status', -1)->where('uid', $user->uid)->sum('number'),
326
+                'team_gongxian_num' => $result['arriveNumTeam'],
327
+                'zhitui' => $con['per_contribute'],
328
+                'total_source' => $con['contribute']
329
+            ];
330
+            return app('json')->success($data);
331
+
319 332
 
320 333
            // $dateObj=DB::name('user_sign_gongxian')->where('uid', $user->uid)->where("status",1)->select();
321 334
             $con = DB::name('user')->where('uid', $user->uid)->find();

+ 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');