Просмотр исходного кода

增加分红时上限可分配额度

sunxiaobiao 1 год назад
Родитель
Сommit
f267109dcd

+ 57 - 48
app/controller/api/store/merchant/Taskorderguquan.php

@@ -9,6 +9,7 @@ namespace app\controller\api\store\merchant;
9 9
 
10 10
 use app\common\model\user\User;
11 11
 use think\facade\Db;
12
+use think\Request;
12 13
 
13 14
 class Taskorderguquan
14 15
 {
@@ -711,10 +712,12 @@ class Taskorderguquan
711 712
 
712 713
     }
713 714
 
714
-    public function lst6()
715
+    public function lst6(Request $request)
715 716
     {
716
-        $startTime = '2025-03-10';
717
-        $endTime = '2025-03-30';
717
+        $startTime = $request->param('startTime', null);
718
+        $endTime = $request->param('endTime', null);
719
+        $isTest = $request->param('isTest', 1);
720
+        $maxAllocationAmount = $request->param('maxAllocationAmount', null);
718 721
         // 查询测试人员账号信息
719 722
         //18973958920
720 723
         //15186694339
@@ -722,7 +725,7 @@ class Taskorderguquan
722 725
         //19525470098
723 726
         //17756507016
724 727
         //18226705337
725
-        $testAccount = ['18973958920', '15186694339', '18833633835', '19525470098', '17756507016', '18226705337'];
728
+        $testAccount = ['18973958920', '15186694339', '18833633835', '19525470098', '17756507016', '18226705337', '17855366921'];
726 729
         $removeUserList = Db::name("user")
727 730
             ->whereIn('account', $testAccount)
728 731
             ->where("status", "<>", 0)
@@ -746,6 +749,11 @@ class Taskorderguquan
746 749
         if ($weekRecord <= 0) {
747 750
             return json('无效分红金额');
748 751
         }
752
+        if (!is_null($maxAllocationAmount)) {
753
+            if ($weekRecord > $maxAllocationAmount) {
754
+                $weekRecord = $maxAllocationAmount;
755
+            }
756
+        }
749 757
 
750 758
         // $stock_comm = round($weekRecord * 0.05 ,2);
751 759
         $stock_comm = floor(($weekRecord * 0.05) * 100) / 100;
@@ -776,51 +784,52 @@ class Taskorderguquan
776 784
 
777 785
                 $yj_90 = $v['getcomm'] * 0.9;
778 786
                 $fg_10 = $v['getcomm'] * 0.1;
787
+                if ($isTest == 0) {
788
+                    // // 更新 user_stock 表中的记录
789
+                    $res = db::name("old_user_stock")->where("id", $v['id'])->update([
790
+                        'getcomm' => $v['getcomm'],
791
+                        'allgetcomm' => $v['allgetcomm'],
792
+                        'update_time' => $v['update_time']
793
+                    ]);
794
+
795
+                    Db::name("user")->where("uid", $v['user_id'])->inc("brokerage_price", $yj_90)->save();
796
+                    $res1 = Db::name("user")->where("uid", $v['user_id'])->inc("total_amount_old", $yj_90)->save();
797
+                    $res2 = Db::name("user")->where("uid", $v['user_id'])->inc("amount_old", $yj_90)->save();
798
+
799
+                    $res3 = Db::name("user")->where("uid", $v['user_id'])->inc("fugou", $fg_10)->save();
800
+
801
+                    $res = true;
802
+                    if ($res) {
803
+                        $das = $this->change_user_log($v['user_id'], 'amount_old', 1, $yj_90, "member_award_stock", "股权分红入账" . "-" . $v['pack']);//释放佣金
804
+
805
+                        //入账星级分红记录表
806
+                        $week_data = [];
807
+                        $week_data['user_id'] = $v['user_id'];
808
+                        $week_data['user_star_id'] = 0;
809
+                        $week_data['award_num'] = 0;
810
+                        $week_data['award_num_sm'] = 0;
811
+                        $week_data['remark'] = "股权分红主动执行" . $yj_90;
812
+                        $week_data['week_record'] = $weekRecord;
813
+                        $week_data['all_amount'] = $stock_comm;
814
+                        $week_data['radio'] = 2;
815
+                        $week_data['owner_bill'] = 0;  //总流水金额
816
+                        $week_data['my_bill'] = 0;  //我的流水
817
+                        $week_data['create_time'] = time();
818
+
819
+
820
+                        Db::name("old_user_weekaward")->insert($week_data);
821
+
822
+                        $userdatassss = db::name("old_user_jbp")->where("id", $v['user_id'])->find();
823
+                        $datas_log = [
824
+                            'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v['user_id'] . " 新增股权佣金:" . $yj_90,
825
+                            'create_time' => date('Y-m-d H:i:s')
826
+                        ];
827
+                        $con_data = Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
779 828
 
780
-                // // 更新 user_stock 表中的记录
781
-                $res = db::name("old_user_stock")->where("id", $v['id'])->update([
782
-                    'getcomm' => $v['getcomm'],
783
-                    'allgetcomm' => $v['allgetcomm'],
784
-                    'update_time' => $v['update_time']
785
-                ]);
786
-
787
-                Db::name("user")->where("uid", $v['user_id'])->inc("brokerage_price", $yj_90)->save();
788
-                $res1 = Db::name("user")->where("uid", $v['user_id'])->inc("total_amount_old", $yj_90)->save();
789
-                $res2 = Db::name("user")->where("uid", $v['user_id'])->inc("amount_old", $yj_90)->save();
790
-
791
-                $res3 = Db::name("user")->where("uid", $v['user_id'])->inc("fugou", $fg_10)->save();
792
-
793
-                $res = true;
794
-                if ($res) {
795
-                    $das = $this->change_user_log($v['user_id'], 'amount_old', 1, $yj_90, "member_award_stock", "股权分红入账" . "-" . $v['pack']);//释放佣金
796
-
797
-                    //入账星级分红记录表
798
-                    $week_data = [];
799
-                    $week_data['user_id'] = $v['user_id'];
800
-                    $week_data['user_star_id'] = 0;
801
-                    $week_data['award_num'] = 0;
802
-                    $week_data['award_num_sm'] = 0;
803
-                    $week_data['remark'] = "股权分红主动执行" . $yj_90;
804
-                    $week_data['week_record'] = $weekRecord;
805
-                    $week_data['all_amount'] = $stock_comm;
806
-                    $week_data['radio'] = 2;
807
-                    $week_data['owner_bill'] = 0;  //总流水金额
808
-                    $week_data['my_bill'] = 0;  //我的流水
809
-                    $week_data['create_time'] = time();
810
-
811
-
812
-                    Db::name("old_user_weekaward")->insert($week_data);
813
-
814
-                    $userdatassss = db::name("old_user_jbp")->where("id", $v['user_id'])->find();
815
-                    $datas_log = [
816
-                        'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v['user_id'] . " 新增股权佣金:" . $yj_90,
817
-                        'create_time' => date('Y-m-d H:i:s')
818
-                    ];
819
-                    $con_data = Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
820
-
821
-                    $this->bill_user_log111111($v['user_id'], "股权分佣", $yj_90, "股权明细入账", 13);//股权分佣明细2.0系统
822
-
823
-                    $this->fugou_user_log($v['user_id'], $fg_10, 16, 1, 1);//复购金明细入账
829
+                        $this->bill_user_log111111($v['user_id'], "股权分佣", $yj_90, "股权明细入账", 13);//股权分佣明细2.0系统
830
+
831
+                        $this->fugou_user_log($v['user_id'], $fg_10, 16, 1, 1);//复购金明细入账
832
+                    }
824 833
                 }
825 834
             }
826 835
         }

+ 46 - 38
app/controller/api/store/merchant/Taskorderlianc.php

@@ -8,6 +8,7 @@
8 8
 namespace app\controller\api\store\merchant;
9 9
 
10 10
 use think\facade\Db;
11
+use think\Request;
11 12
 
12 13
 class Taskorderlianc
13 14
 {
@@ -271,10 +272,12 @@ class Taskorderlianc
271 272
     }
272 273
 
273 274
 
274
-    public function lst2()
275
+    public function lst2(Request $request)
275 276
     {
276
-        $startTime = '2025-03-10';
277
-        $endTime = '2025-03-30';
277
+        $startTime = $request->param('startTime', null);
278
+        $endTime = $request->param('endTime', null);
279
+        $isTest = $request->param('isTest', 1);
280
+        $maxAllocationAmount = $request->param('maxAllocationAmount', null);
278 281
         // 查询测试人员账号信息
279 282
         //18973958920
280 283
         //15186694339
@@ -282,7 +285,7 @@ class Taskorderlianc
282 285
         //19525470098
283 286
         //17756507016
284 287
         //18226705337
285
-        $testAccount = ['18973958920', '15186694339', '18833633835', '19525470098', '17756507016', '18226705337'];
288
+        $testAccount = ['18973958920', '15186694339', '18833633835', '19525470098', '17756507016', '18226705337', '17855366921'];
286 289
         $removeUserList = Db::name("user")
287 290
             ->whereIn('account', $testAccount)
288 291
             ->where("status", "<>", 0)
@@ -306,7 +309,11 @@ class Taskorderlianc
306 309
         if ($weekRecord <= 0) {
307 310
             return json('无效分红金额');
308 311
         }
309
-
312
+        if (!is_null($maxAllocationAmount)) {
313
+            if ($weekRecord > $maxAllocationAmount) {
314
+                $weekRecord = $maxAllocationAmount;
315
+            }
316
+        }
310 317
 
311 318
         $originator_award = round(($weekRecord * 0.05), 2);
312 319
 
@@ -376,39 +383,40 @@ class Taskorderlianc
376 383
                 //90给佣金,10给复购金
377 384
                 $yj_90 = $award * 0.9;
378 385
                 $fg_10 = $award * 0.1;
379
-
380
-                Db::name("user")->where("uid", $v)->inc("brokerage_price", $yj_90)->save();
381
-                $res = Db::name("user")->where("uid", $v)->inc("total_amount_old", $yj_90)->save();
382
-                Db::name("user")->where("uid", $v)->inc("amount_old", $yj_90)->save();//不用冻结金额和提现额度来限制佣金发放
383
-                $res3 = Db::name("user")->where("uid", $v)->inc("fugou", $fg_10)->save();
384
-
385
-                $res = true;
386
-                if ($res) {
387
-                    $$count = $count + 1;
388
-                    $this->change_user_log($v, 'amount_old', 1, $yj_90, "relation_profits", "联创分红入账" . "-" . $value['title']);
389
-                    //入账
390
-                    $week_data = [];
391
-                    $week_data['user_id'] = $v;
392
-                    $week_data['user_lianc_id'] = $value['id'];
393
-                    $week_data['money'] = $yj_90;
394
-                    $week_data['remark'] = "联创分红入账主动执行" . $yj_90;
395
-                    $week_data['all_record'] = $originator_award;
396
-                    $week_data['all_amount'] = $distribution_money;
397
-                    $week_data['create_time'] = time();
398
-                    Db::name("old_user_originator")->insert($week_data);
399
-
400
-                    $userdatassss = db::name("user")->where("uid", $v)->find();
401
-                    $datas_log = [
402
-                        'note' => "名称:" . $userdatassss['nickname'] . " 用户:" . $v . " 新增联创佣金:" . $yj_90,
403
-                        'create_time' => date('Y-m-d H:i:s')
404
-                    ];
405
-                    Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
406
-                    $this->bill_user_log111111($v, "联创分佣", $yj_90, "联创明细入账", 12);//股权分佣明细2.0系统
407
-
408
-                    $this->fugou_user_log($v, $fg_10, 16, 1, 1);//复购金明细入账
409
-
410
-                } else {
411
-                    // ..
386
+                if ($isTest == 0) {
387
+                    Db::name("user")->where("uid", $v)->inc("brokerage_price", $yj_90)->save();
388
+                    $res = Db::name("user")->where("uid", $v)->inc("total_amount_old", $yj_90)->save();
389
+                    Db::name("user")->where("uid", $v)->inc("amount_old", $yj_90)->save();//不用冻结金额和提现额度来限制佣金发放
390
+                    $res3 = Db::name("user")->where("uid", $v)->inc("fugou", $fg_10)->save();
391
+
392
+                    $res = true;
393
+                    if ($res) {
394
+                        $$count = $count + 1;
395
+                        $this->change_user_log($v, 'amount_old', 1, $yj_90, "relation_profits", "联创分红入账" . "-" . $value['title']);
396
+                        //入账
397
+                        $week_data = [];
398
+                        $week_data['user_id'] = $v;
399
+                        $week_data['user_lianc_id'] = $value['id'];
400
+                        $week_data['money'] = $yj_90;
401
+                        $week_data['remark'] = "联创分红入账主动执行" . $yj_90;
402
+                        $week_data['all_record'] = $originator_award;
403
+                        $week_data['all_amount'] = $distribution_money;
404
+                        $week_data['create_time'] = time();
405
+                        Db::name("old_user_originator")->insert($week_data);
406
+
407
+                        $userdatassss = db::name("user")->where("uid", $v)->find();
408
+                        $datas_log = [
409
+                            'note' => "名称:" . $userdatassss['nickname'] . " 用户:" . $v . " 新增联创佣金:" . $yj_90,
410
+                            'create_time' => date('Y-m-d H:i:s')
411
+                        ];
412
+                        Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
413
+                        $this->bill_user_log111111($v, "联创分佣", $yj_90, "联创明细入账", 12);//股权分佣明细2.0系统
414
+
415
+                        $this->fugou_user_log($v, $fg_10, 16, 1, 1);//复购金明细入账
416
+
417
+                    } else {
418
+                        // ..
419
+                    }
412 420
                 }
413 421
             }
414 422
         }