Explorar o código

精彩生活专区消费者、推广者获得积分、贡献值

family hai 1 ano
pai
achega
e0edd3c5e7
Modificáronse 1 ficheiros con 54 adicións e 48 borrados
  1. 54 48
      app/common/repositories/store/order/StoreOrderRepository.php

+ 54 - 48
app/common/repositories/store/order/StoreOrderRepository.php

@@ -9501,8 +9501,6 @@ class StoreOrderRepository extends BaseRepository
9501
         //var_dump($store_product_data['concession_pri']);return;
9501
         //var_dump($store_product_data['concession_pri']);return;
9502
         //精彩生活
9502
         //精彩生活
9503
         if ($store_order_data['mer_id'] == 439) {
9503
         if ($store_order_data['mer_id'] == 439) {
9504
-
9505
-
9506
             //分配参数
9504
             //分配参数
9507
             $job_par = [];
9505
             $job_par = [];
9508
             if (!empty($store_order_data)) {
9506
             if (!empty($store_order_data)) {
@@ -9521,7 +9519,9 @@ class StoreOrderRepository extends BaseRepository
9521
                 // Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,"contribute"=>$con,"score"=>$score]);
9519
                 // Db::name('user')->where('uid',$user_data['uid'])->update(['annuity'=>$ylj_amount_mine,"contribute"=>$con,"score"=>$score]);
9522
 
9520
 
9523
                 $this->bill_user_log($user_data['uid'], $ylj_pri, $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . $ylj_pri, $store_order_data['mer_id'], 0);
9521
                 $this->bill_user_log($user_data['uid'], $ylj_pri, $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . $ylj_pri, $store_order_data['mer_id'], 0);
9522
+                // 贡献值
9524
                 $this->con_log($user_data['uid'], $pv, $store_order_data['order_id'], 11, "购买精彩生活商品赠送贡献值");
9523
                 $this->con_log($user_data['uid'], $pv, $store_order_data['order_id'], 11, "购买精彩生活商品赠送贡献值");
9524
+                // 积分
9525
                 $this->score_log($user_data['uid'], $pv, $store_order_data['order_id'], 11, "购买精彩生活商品赠送积分");
9525
                 $this->score_log($user_data['uid'], $pv, $store_order_data['order_id'], 11, "购买精彩生活商品赠送积分");
9526
 
9526
 
9527
                 //给推广者分配养老金
9527
                 //给推广者分配养老金
@@ -9531,7 +9531,19 @@ class StoreOrderRepository extends BaseRepository
9531
                     $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
9531
                     $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
9532
 
9532
 
9533
                     //业务员或以上的推荐人等级
9533
                     //业务员或以上的推荐人等级
9534
-                    //user_group=1是消费者 3%,2:业务员 5%,3:业务经理7%,4:初级合伙人9%,5:中级合伙人11%,6:高级合伙人13%,7:董事15%
9534
+                    $user_group_rate = Db::name("system_config_value")->where(["config_key"=>"user_group_rate"])->value("value");
9535
+                    $user_group_rate = json_decode($user_group_rate, true);
9536
+                    $group_rate = array_column($user_group_rate, 'rate','user_groub');
9537
+                    //业务员或以上的推荐人等级
9538
+                    //[{"user_groub":1,"rate":5,"name":"用户"},
9539
+                    //{"user_groub":2,"rate":7,"name":"业务员"},
9540
+                    //{"user_groub":3,"rate":9,"name":"业务经理"},
9541
+                    //{"user_groub":4,"rate":11,"name":"初级合伙人"},
9542
+                    //{"user_groub":5,"rate":13,"name":"中级合伙人"},
9543
+                    //{"user_groub":6,"rate":15,"name":"高级合伙人"},
9544
+                    //{"user_groub":7,"rate":17,"name":"董事"}
9545
+                    //]
9546
+                    $rate = isset($group_rate[$spread_data['user_group']])?round($group_rate[$spread_data['user_group']]/100,2):0.00;
9535
                     if ($spread_data['user_group'] > 1) {
9547
                     if ($spread_data['user_group'] > 1) {
9536
 
9548
 
9537
                         // //给推广者分配佣金
9549
                         // //给推广者分配佣金
@@ -9541,13 +9553,13 @@ class StoreOrderRepository extends BaseRepository
9541
                         $yj_amount_90 = 0;//90%的佣金
9553
                         $yj_amount_90 = 0;//90%的佣金
9542
 
9554
 
9543
                         if ($spread_data['user_group'] == 2) {
9555
                         if ($spread_data['user_group'] == 2) {
9544
-                            $ssf = round($pv * 0.07, 2);
9545
-                            $con = $spread_data['contribute'] + round($pv * 0.07, 2);
9546
-                            $score = $spread_data['score'] + round($pv * 0.07, 2);
9556
+                            $ssf = round($pv * $rate, 2);
9557
+                            $con = $spread_data['contribute'] + round($pv * $rate, 2);
9558
+                            $score = $spread_data['score'] + round($pv * $rate, 2);
9547
 
9559
 
9548
 
9560
 
9549
-                            $yj_amount_90 = round($pv * 0.07, 2) * 0.9;
9550
-                            $fgj_amount_10 = round($pv * 0.07, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9561
+                            $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9562
+                            $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9551
 
9563
 
9552
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9564
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9553
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9565
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9556,12 +9568,12 @@ class StoreOrderRepository extends BaseRepository
9556
 
9568
 
9557
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9569
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9558
                         } else if ($spread_data['user_group'] == 3) {
9570
                         } else if ($spread_data['user_group'] == 3) {
9559
-                            $ssf = round($pv * 0.09, 2);
9560
-                            $con = $spread_data['contribute'] + round($pv * 0.09, 2);
9561
-                            $score = $spread_data['score'] + round($pv * 0.09, 2);
9571
+                            $ssf = round($pv * $rate, 2);
9572
+                            $con = $spread_data['contribute'] + round($pv * $rate, 2);
9573
+                            $score = $spread_data['score'] + round($pv * $rate, 2);
9562
 
9574
 
9563
-                            $yj_amount_90 = round($pv * 0.09, 2) * 0.9;
9564
-                            $fgj_amount_10 = round($pv * 0.09, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9575
+                            $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9576
+                            $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9565
 
9577
 
9566
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9578
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9567
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9579
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9569,12 +9581,12 @@ class StoreOrderRepository extends BaseRepository
9569
 
9581
 
9570
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9582
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9571
                         } else if ($spread_data['user_group'] == 4) {
9583
                         } else if ($spread_data['user_group'] == 4) {
9572
-                            $ssf = round($pv * 0.11, 2);
9573
-                            $con = $spread_data['contribute'] + round($pv * 0.11, 2);
9574
-                            $score = $spread_data['score'] + round($pv * 0.11, 2);
9584
+                            $ssf = round($pv * $rate, 2);
9585
+                            $con = $spread_data['contribute'] + round($pv * $rate, 2);
9586
+                            $score = $spread_data['score'] + round($pv * $rate, 2);
9575
 
9587
 
9576
-                            $yj_amount_90 = round($pv * 0.11, 2) * 0.9;
9577
-                            $fgj_amount_10 = round($pv * 0.11, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9588
+                            $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9589
+                            $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9578
 
9590
 
9579
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9591
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9580
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9592
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9582,13 +9594,13 @@ class StoreOrderRepository extends BaseRepository
9582
 
9594
 
9583
                             //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9595
                             //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9584
                         } else if ($spread_data['user_group'] == 5) {
9596
                         } else if ($spread_data['user_group'] == 5) {
9585
-                            $ssf = round($pv * 0.13, 2);
9586
-                            $con = $spread_data['contribute'] + round($pv * 0.13, 2);
9587
-                            $score = $spread_data['score'] + round($pv * 0.13, 2);
9588
-                            // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.13,2);
9597
+                            $ssf = round($pv * $rate, 2);
9598
+                            $con = $spread_data['contribute'] + round($pv * $rate, 2);
9599
+                            $score = $spread_data['score'] + round($pv * $rate, 2);
9600
+                            // $yj_amount = $spread_data['brokerage_price'] + round($pv * $rate,2);
9589
 
9601
 
9590
-                            $yj_amount_90 = round($pv * 0.13, 2) * 0.9;
9591
-                            $fgj_amount_10 = round($pv * 0.13, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9602
+                            $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9603
+                            $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9592
 
9604
 
9593
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9605
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9594
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9606
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9596,12 +9608,12 @@ class StoreOrderRepository extends BaseRepository
9596
 
9608
 
9597
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9609
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9598
                         } else if ($spread_data['user_group'] == 6) {
9610
                         } else if ($spread_data['user_group'] == 6) {
9599
-                            $ssf = round($pv * 0.15, 2);
9600
-                            $con = $spread_data['contribute'] + round($pv * 0.15, 2);
9601
-                            $score = $spread_data['score'] + round($pv * 0.15, 2);
9611
+                            $ssf = round($pv * $rate, 2);
9612
+                            $con = $spread_data['contribute'] + round($pv * $rate, 2);
9613
+                            $score = $spread_data['score'] + round($pv * $rate, 2);
9602
 
9614
 
9603
-                            $yj_amount_90 = round($pv * 0.15, 2) * 0.9;
9604
-                            $fgj_amount_10 = round($pv * 0.15, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9615
+                            $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9616
+                            $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9605
 
9617
 
9606
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9618
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9607
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9619
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9609,13 +9621,13 @@ class StoreOrderRepository extends BaseRepository
9609
 
9621
 
9610
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9622
                             // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
9611
                         } else if ($spread_data['user_group'] == 7) {
9623
                         } else if ($spread_data['user_group'] == 7) {
9612
-                            $ssf = round($pv * 0.17, 2);
9613
-                            $con = $spread_data['contribute'] + round($pv * 0.17, 2);
9614
-                            $score = $spread_data['score'] + round($pv * 0.17, 2);
9624
+                            $ssf = round($pv * $rate, 2);
9625
+                            $con = $spread_data['contribute'] + round($pv * $rate, 2);
9626
+                            $score = $spread_data['score'] + round($pv * $rate, 2);
9615
 
9627
 
9616
 
9628
 
9617
-                            $yj_amount_90 = round($pv * 0.17, 2) * 0.9;
9618
-                            $fgj_amount_10 = round($pv * 0.17, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9629
+                            $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9630
+                            $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9619
 
9631
 
9620
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9632
                             $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9621
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9633
                             $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9638,8 +9650,8 @@ class StoreOrderRepository extends BaseRepository
9638
                     if ($spread_data['user_group'] == 1) {
9650
                     if ($spread_data['user_group'] == 1) {
9639
                         //给推广者分配佣金
9651
                         //给推广者分配佣金
9640
 
9652
 
9641
-                        $yj_amount_90 = round($pv * 0.21, 2) * 0.9;
9642
-                        $fgj_amount_10 = round($pv * 0.21, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9653
+                        $yj_amount_90 = round($pv * $rate, 2) * 0.9;
9654
+                        $fgj_amount_10 = round($pv * $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
9643
 
9655
 
9644
                         $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9656
                         $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
9645
                         $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9657
                         $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
@@ -9647,8 +9659,8 @@ class StoreOrderRepository extends BaseRepository
9647
 
9659
 
9648
                         //Db::name('user')->where('uid',$spread_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
9660
                         //Db::name('user')->where('uid',$spread_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
9649
 
9661
 
9650
-                        $con = $spread_data['contribute'] + round($pv * 0.21, 2);
9651
-                        $score = $spread_data['score'] + round($pv * 0.21, 2);
9662
+                        $con = $spread_data['contribute'] + round($pv * $rate, 2);
9663
+                        $score = $spread_data['score'] + round($pv * $rate, 2);
9652
 
9664
 
9653
                         //贡献值和积分
9665
                         //贡献值和积分
9654
                         // Db::name('user')->where('uid',$spread_data['uid'])->update(["contribute"=>$con,"score"=>$score]);
9666
                         // Db::name('user')->where('uid',$spread_data['uid'])->update(["contribute"=>$con,"score"=>$score]);
@@ -9656,13 +9668,11 @@ class StoreOrderRepository extends BaseRepository
9656
                         //推广养老金
9668
                         //推广养老金
9657
                         //推广佣金
9669
                         //推广佣金
9658
                         $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);
9670
                         $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);
9659
-                        $this->con_log($spread_data['uid'], round($pv * 0.21, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值");
9660
-                        $this->score_log($spread_data['uid'], round($pv * 0.21, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分");
9661
-
9662
-
9671
+                        // 贡献值
9672
+                        $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值");
9673
+                        //积分
9674
+                        $this->score_log($spread_data['uid'], round($pv * $rate, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分");
9663
                     }
9675
                     }
9664
-
9665
-
9666
                 }
9676
                 }
9667
 
9677
 
9668
                 //锁客收益
9678
                 //锁客收益
@@ -9691,10 +9701,6 @@ class StoreOrderRepository extends BaseRepository
9691
                     }
9701
                     }
9692
 
9702
 
9693
                 }
9703
                 }
9694
-
9695
-
9696
-                //}
9697
-                //var_dump($ylj_amount);
9698
             }
9704
             }
9699
 
9705
 
9700
             //VIP专区
9706
             //VIP专区