xialei 1 год назад
Родитель
Сommit
a987f2f6ce
1 измененных файлов с 61 добавлено и 55 удалено
  1. 61 55
      app/common/repositories/store/order/StoreOrderRepository.php

+ 61 - 55
app/common/repositories/store/order/StoreOrderRepository.php

@@ -9796,10 +9796,15 @@ class StoreOrderRepository extends BaseRepository
9796
             //给推广者分配养老金
9796
             //给推广者分配养老金
9797
             //给推广者分配佣金
9797
             //给推广者分配佣金
9798
             // if ($user_data['spread_uid'] != 0) {
9798
             // if ($user_data['spread_uid'] != 0) {
9799
-                if ($user_data['uid'] > 611) {
9799
+                // if ($user_data['uid'] > 611) {
9800
 
9800
 
9801
 
9801
 
9802
+                //查询下单用户上级身份
9802
                 $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
9803
                 $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
9804
+
9805
+                //业务员或以上的推荐人等级
9806
+                $rate = static::getUserGroupRate($spread_data['user_group']);
9807
+
9803
                 //user_group=1是消费者,2:业务,3:业务经理,4:初级合伙人,5:中级合伙人,6:高级合伙人,7:董事
9808
                 //user_group=1是消费者,2:业务,3:业务经理,4:初级合伙人,5:中级合伙人,6:高级合伙人,7:董事
9804
                 //业务或以上等级推广人
9809
                 //业务或以上等级推广人
9805
                 //获得养老金、佣金、贡献值和积分
9810
                 //获得养老金、佣金、贡献值和积分
@@ -9818,75 +9823,76 @@ class StoreOrderRepository extends BaseRepository
9818
                     $yongjin = $spread_data['brokerage_price'] + $yj_amount_90;
9823
                     $yongjin = $spread_data['brokerage_price'] + $yj_amount_90;
9819
                     $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9824
                     $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
9820
 
9825
 
9826
+                    $this->score_log($spread_data['uid'], bcmul($pv, $rate, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9821
 
9827
 
9822
-                    if ($spread_data['user_group'] == 2) {
9828
+                    // if ($spread_data['user_group'] == 2) {
9823
 
9829
 
9824
-                        $con = $spread_data['contribute'] + bcmul($pv, 0.07, 2);
9825
-                        $score = $spread_data['brokerage_price'] + bcmul($pv, 0.07, 2);
9826
-                        //  Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9830
+                    //     $con = $spread_data['contribute'] + bcmul($pv, 0.07, 2);
9831
+                    //     $score = $spread_data['brokerage_price'] + bcmul($pv, 0.07, 2);
9832
+                    //     //  Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9827
 
9833
 
9828
-                        //贡献值
9829
-                        // $this->con_log($spread_data['uid'],round($pv * 0.07,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9830
-                        //积分
9831
-                        $this->score_log($spread_data['uid'], bcmul($pv, 0.07, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9834
+                    //     //贡献值
9835
+                    //     // $this->con_log($spread_data['uid'],round($pv * 0.07,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9836
+                    //     //积分
9837
+                    //     $this->score_log($spread_data['uid'], bcmul($pv, 0.07, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9832
 
9838
 
9833
-                    } else if ($spread_data['user_group'] == 3) {
9839
+                    // } else if ($spread_data['user_group'] == 3) {
9834
 
9840
 
9835
 
9841
 
9836
-                        $con = $spread_data['contribute'] + bcmul($pv, 0.09, 2);
9837
-                        $score = $spread_data['brokerage_price'] + bcmul($pv, 0.09, 2);
9838
-                        // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9842
+                    //     $con = $spread_data['contribute'] + bcmul($pv, 0.09, 2);
9843
+                    //     $score = $spread_data['brokerage_price'] + bcmul($pv, 0.09, 2);
9844
+                    //     // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9839
 
9845
 
9840
-                        //贡献值
9841
-                        // $this->con_log($spread_data['uid'],round($pv * 0.09,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9842
-                        //积分
9843
-                        $this->score_log($spread_data['uid'], bcmul($pv, 0.09, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9846
+                    //     //贡献值
9847
+                    //     // $this->con_log($spread_data['uid'],round($pv * 0.09,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9848
+                    //     //积分
9849
+                    //     $this->score_log($spread_data['uid'], bcmul($pv, 0.09, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9844
 
9850
 
9845
 
9851
 
9846
-                    } else if ($spread_data['user_group'] == 4) {
9847
-                        $con = $spread_data['contribute'] + bcmul($pv, 0.11, 2);
9848
-                        $score = $spread_data['brokerage_price'] + bcmul($pv, 0.11, 2);
9849
-                        // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9852
+                    // } else if ($spread_data['user_group'] == 4) {
9853
+                    //     $con = $spread_data['contribute'] + bcmul($pv, 0.11, 2);
9854
+                    //     $score = $spread_data['brokerage_price'] + bcmul($pv, 0.11, 2);
9855
+                    //     // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9850
 
9856
 
9851
-                        //贡献值
9852
-                        //$this->con_log($spread_data['uid'],round($pv * 0.11,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9853
-                        //积分
9854
-                        $this->score_log($spread_data['uid'], bcmul($pv, 0.11, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9857
+                    //     //贡献值
9858
+                    //     //$this->con_log($spread_data['uid'],round($pv * 0.11,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9859
+                    //     //积分
9860
+                    //     $this->score_log($spread_data['uid'], bcmul($pv, 0.11, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9855
 
9861
 
9856
 
9862
 
9857
-                    } else if ($spread_data['user_group'] == 5) {
9858
-                        $con = $spread_data['contribute'] + bcmul($pv, 0.13, 2);
9859
-                        $score = $spread_data['brokerage_price'] + bcmul($pv, 0.13, 2);
9860
-                        // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9863
+                    // } else if ($spread_data['user_group'] == 5) {
9864
+                    //     $con = $spread_data['contribute'] + bcmul($pv, 0.13, 2);
9865
+                    //     $score = $spread_data['brokerage_price'] + bcmul($pv, 0.13, 2);
9866
+                    //     // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9861
 
9867
 
9862
-                        //贡献值
9863
-                        // $this->con_log($spread_data['uid'],round($pv * 0.13,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9864
-                        //积分
9865
-                        $this->score_log($spread_data['uid'], bcmul($pv, 0.13, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9868
+                    //     //贡献值
9869
+                    //     // $this->con_log($spread_data['uid'],round($pv * 0.13,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9870
+                    //     //积分
9871
+                    //     $this->score_log($spread_data['uid'], bcmul($pv, 0.13, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9866
 
9872
 
9867
-                    } else if ($spread_data['user_group'] == 6) {
9868
-                        $con = $spread_data['contribute'] + bcmul($pv, 0.15, 2);
9869
-                        $score = $spread_data['brokerage_price'] + bcmul($pv, 0.15, 2);
9870
-                        // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9873
+                    // } else if ($spread_data['user_group'] == 6) {
9874
+                    //     $con = $spread_data['contribute'] + bcmul($pv, 0.15, 2);
9875
+                    //     $score = $spread_data['brokerage_price'] + bcmul($pv, 0.15, 2);
9876
+                    //     // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9871
 
9877
 
9872
-                        //贡献值
9873
-                        // $this->con_log($spread_data['uid'],round($pv * 0.15,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9874
-                        //积分
9875
-                        $this->score_log($spread_data['uid'], bcmul($pv, 0.15, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9878
+                    //     //贡献值
9879
+                    //     // $this->con_log($spread_data['uid'],round($pv * 0.15,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9880
+                    //     //积分
9881
+                    //     $this->score_log($spread_data['uid'], bcmul($pv, 0.15, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9876
 
9882
 
9877
 
9883
 
9878
-                    } else if ($spread_data['user_group'] == 7) {
9879
-                        $con = $spread_data['contribute'] + bcmul($pv, 0.17, 2);
9880
-                        $score = $spread_data['brokerage_price'] + bcmul($pv, 0.17, 2);
9881
-                        // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9884
+                    // } else if ($spread_data['user_group'] == 7) {
9885
+                    //     $con = $spread_data['contribute'] + bcmul($pv, 0.17, 2);
9886
+                    //     $score = $spread_data['brokerage_price'] + bcmul($pv, 0.17, 2);
9887
+                    //     // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yongjin,'annuity'=>$uer_bill,"fugou"=> $fgj_amount]);
9882
 
9888
 
9883
-                        //贡献值
9884
-                        //$this->con_log($spread_data['uid'],round($pv * 0.17,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9885
-                        //积分
9886
-                        $this->score_log($spread_data['uid'], bcmul($pv, 0.17, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9889
+                    //     //贡献值
9890
+                    //     //$this->con_log($spread_data['uid'],round($pv * 0.17,2),$store_order_data['order_id'],11,"推广会员专区商品赠送贡献值",1);
9891
+                    //     //积分
9892
+                    //     $this->score_log($spread_data['uid'], bcmul($pv, 0.17, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9887
 
9893
 
9888
 
9894
 
9889
-                    }
9895
+                    // }
9890
                     Db::name('test_log')->insert(['note' => "走到这里4"]);//测试
9896
                     Db::name('test_log')->insert(['note' => "走到这里4"]);//测试
9891
                     //贡献值
9897
                     //贡献值
9892
                     $this->con_log($spread_data['uid'], round($gx_jf, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1, round($gx_jf, 2));
9898
                     $this->con_log($spread_data['uid'], round($gx_jf, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1, round($gx_jf, 2));
@@ -9897,14 +9903,13 @@ class StoreOrderRepository extends BaseRepository
9897
                     $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']);
9903
                     $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']);
9898
                     //复购金
9904
                     //复购金
9899
                     $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9905
                     $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1, 1);
9900
-
9901
                 }
9906
                 }
9902
 
9907
 
9903
                 //普通的用户推广人
9908
                 //普通的用户推广人
9904
                 if ($spread_data['user_group'] == 1) {  
9909
                 if ($spread_data['user_group'] == 1) {  
9905
 
9910
 
9906
                     //获取贡献值和积分和佣金
9911
                     //获取贡献值和积分和佣金
9907
-                    $gx_jf = $spread_data['contribute'] + bcmul($pv, 0.21, 2);
9912
+                    $gx_jf = $spread_data['contribute'] + bcmul($pv, $rate, 2);
9908
 
9913
 
9909
 
9914
 
9910
                     $yj_amount_90 = bcmul($yj1, 0.9, 2);
9915
                     $yj_amount_90 = bcmul($yj1, 0.9, 2);
@@ -9916,14 +9921,15 @@ class StoreOrderRepository extends BaseRepository
9916
 
9921
 
9917
 
9922
 
9918
                     //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $gx_jf,'score'=> $gx_jf,'brokerage_price'=> $yj_amount,'fugou'=>$fgj_amount]);
9923
                     //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $gx_jf,'score'=> $gx_jf,'brokerage_price'=> $yj_amount,'fugou'=>$fgj_amount]);
9919
-                    $this->con_log($spread_data['uid'], bcmul($pv, 0.21, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1, bcmul($pv, 0.21, 2));
9920
-                    $this->score_log($spread_data['uid'], bcmul($pv, 0.21, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9924
+                    $this->con_log($spread_data['uid'], bcmul($pv, $rate, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送贡献值", 1, bcmul($pv, 0.21, 2));
9925
+                    $this->score_log($spread_data['uid'], bcmul($pv, $rate, 2), $store_order_data['order_id'], 11, "推广会员专区商品赠送积分", 1);
9921
                     //推广佣金
9926
                     //推广佣金
9922
                     $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']);
9927
                     $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']);
9923
                 }
9928
                 }
9924
 
9929
 
9925
 
9930
 
9926
-            } else if ($spread_data_old != 0) {
9931
+            // } else if ($spread_data_old != 0) {
9932
+                if ($spread_data_old != 0) {
9927
 
9933
 
9928
                 //1.0jbp系统中,如果有用户升级会员,给推荐人贡献值(90%)和养老金(10%)
9934
                 //1.0jbp系统中,如果有用户升级会员,给推荐人贡献值(90%)和养老金(10%)
9929
                 $spread_data = Db::name('user')->where('uid', $spread_data_old['id'])->find();
9935
                 $spread_data = Db::name('user')->where('uid', $spread_data_old['id'])->find();