Explorar o código

feat(api): 添加系统补贴功能并优化测试接口

- 新增系统补贴数据插入功能,为指定用户添加补贴记录
- 集成CommonEnum枚举类用于佣金类型管理
- 重构数组格式化,统一键值对间的空格规范
- 优化用户树形结构查询参数传递
- 清理冗余注释代码,提升代码可读性
shichen hai 4 meses
pai
achega
171428b883
Modificáronse 1 ficheiros con 50 adicións e 21 borrados
  1. 50 21
      app/controller/api/Test.php

+ 50 - 21
app/controller/api/Test.php

@@ -1,7 +1,9 @@
1 1
 <?php
2 2
 
3 3
 namespace app\controller\api;
4
+
4 5
 use app\common\dao\shared\SharedProsperityUserDao;
6
+use app\common\enum\CommonEnum;
5 7
 use app\common\model\shared\SharedProsperityUser;
6 8
 use app\common\repositories\shared\SharedProsperityUserRepository;
7 9
 use app\common\repositories\user\UserRepository;
@@ -13,16 +15,56 @@ class Test
13 15
     public function test()
14 16
     {
15 17
 
18
+
19
+        $title = '系统补贴';
20
+        $map = [
21
+            294 => 165,
22
+            186 => 860
23
+        ];
24
+
25
+        foreach ($map as $uid => $money) {
26
+            $bill = [
27
+                'uid' => $uid,
28
+                'link_id' => 0,
29
+                'pm' => 1,
30
+                'title' => $title,
31
+                'category' => 'now_money',
32
+                'type' => 'commission',
33
+                'number' => $money,
34
+                'balance' => 0,
35
+                'mark' => $title,
36
+                'create_time' => date('Y-m-d H:i:s'),
37
+                'status' => 1,
38
+                'commission_type' => CommonEnum::COMMISSION_TYPE['SYSTEM_SUBSIDY_COMMISSION']['code'],
39
+                'order_sn' => 0,
40
+                'tripartite' => 0,
41
+                'type_shop' => 0,
42
+                'mer_id' => 0,
43
+                'source' => 0,
44
+                'order_type' => 1,
45
+                'is_red_brokerage' => 0,
46
+                'gzc' => 3,
47
+                'take_time' => time(),
48
+                'district_id' => '',
49
+                'street_id' => '',
50
+                'month' => '',
51
+            ];
52
+            $a = Db::name('user_bill')->insert($bill);
53
+
54
+            $b = Db::name('user')->where('uid', $uid)->inc('brokerage_price', $money)->update();
55
+        }
56
+        die;
57
+
16 58
         $total = 8497.13;
17 59
         $map = [
18
-            1=>0.3,
19
-            2=>0.15,
20
-            3=>0.03,
21
-            4=>0.008,
60
+            1 => 0.3,
61
+            2 => 0.15,
62
+            3 => 0.03,
63
+            4 => 0.008,
22 64
         ];
23 65
         $groupMap = [
24
-            1=>0.05,
25
-            2=>0.1
66
+            1 => 0.05,
67
+            2 => 0.1
26 68
         ];
27 69
 
28 70
         $users = Db::name('shared_prosperity_user')->group('partner_level')->field('partner_level,count(*) as num')->select()->toArray();
@@ -46,7 +88,7 @@ class Test
46 88
                 'money' => $total * $groupMap[$groupUser['group_id']] / $groupUser['num']
47 89
             ];
48 90
         }
49
-        dd($res,$groupRes);
91
+        dd($res, $groupRes);
50 92
 
51 93
 
52 94
         // 18201226770 4858下的单  改成   13716268932 5064下单
@@ -60,19 +102,6 @@ class Test
60 102
         // 佣金修改
61 103
 
62 104
 
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76 105
         // 查询团队业绩
77 106
         // $ids = [
78 107
         //     1213
@@ -98,7 +127,7 @@ class Test
98 127
         $field = request()->param('field');
99 128
         /** @var UserRepository $userRepository */
100 129
         $userRepository = app()->make(UserRepository::class);
101
-        $list = $userRepository->getUserForTree($field,0);
130
+        $list = $userRepository->getUserForTree($field, 0);
102 131
         var_dump(json_encode($list));
103 132
         // return app('json')->success($list);
104 133
     }