hefei 1 yıl önce
ebeveyn
işleme
a1c790adca
1 değiştirilmiş dosya ile 59 ekleme ve 163 silme
  1. 59 163
      app/controller/api/Notify.php

+ 59 - 163
app/controller/api/Notify.php

@@ -224,144 +224,6 @@ class Notify
224 224
                                         //养老金
225 225
                                         $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
226 226
                                     }
227
-                                        //业务员或以上的推荐人等级
228
-                                        //user_group=1是消费者 3%,2:业务员 5%,3:业务经理7%,4:初级合伙人9%,5:中级合伙人11%,6:高级合伙人13%,7:董事15%
229
-//                                        if($spread_data['user_group'] > 1){
230
-//
231
-//                                            // //给推广者分配佣金
232
-//                                            $yj_amount = 0;
233
-//                                            $ylj_amount = $spread_data['annuity'] + bcmul($pv, $rate,2);
234
-//                                            $ssf = 0;//变量
235
-//                                            $yj_amount_90 = 0;//90%的佣金
236
-//
237
-//                                            if($spread_data['user_group'] == 2){
238
-//                                                $ssf =bcmul($pv, $rate,2);
239
-//                                                $con       = $spread_data['contribute'] + bcmul($pv, $rate,2);
240
-//                                                $score     = $spread_data['score'] + bcmul($pv, $rate,2);
241
-//
242
-//
243
-//                                                $yj_amount_90 = bcmul($pv, $rate,2) * 0.9;
244
-//                                                $fgj_amount_10 = bcmul($pv, $rate,2) * 0.1;//推广者的佣金抽10%到个人复购金
245
-//
246
-//                                                $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
247
-//                                                $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
248
-//                                                $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
249
-//
250
-//
251
-//
252
-//                                                // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
253
-//                                            }else if($spread_data['user_group'] == 3){
254
-//                                                $ssf =bcmul($pv, 0.09,2);
255
-//                                                $con       = $spread_data['contribute'] + bcmul($pv, 0.09,2);
256
-//                                                $score     = $spread_data['score'] + bcmul($pv, 0.09,2);
257
-//
258
-//                                                $yj_amount_90 = bcmul($pv, 0.09,2) * 0.9;
259
-//                                                $fgj_amount_10 = bcmul($pv, 0.09,2) * 0.1;//推广者的佣金抽10%到个人复购金
260
-//
261
-//                                                $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
262
-//                                                $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
263
-//                                                $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
264
-//
265
-//                                                // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
266
-//                                            }else if($spread_data['user_group'] == 4){
267
-//                                                $ssf =bcmul($pv, 0.11,2);
268
-//                                                $con       = $spread_data['contribute'] + bcmul($pv, 0.11,2);
269
-//                                                $score     = $spread_data['score'] + bcmul($pv, 0.11,2);
270
-//
271
-//
272
-//                                                $yj_amount_90 = bcmul($pv, 0.11,2) * 0.9;
273
-//                                                $fgj_amount_10 = bcmul($pv, 0.11,2) * 0.1;//推广者的佣金抽10%到个人复购金
274
-//
275
-//                                                $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
276
-//                                                $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
277
-//                                                $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
278
-//
279
-//                                                //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
280
-//                                            }else if($spread_data['user_group'] == 5){
281
-//                                                $ssf =bcmul($pv, 0.13,2);
282
-//                                                $con       = $spread_data['contribute'] + bcmul($pv, 0.13,2);
283
-//                                                $score     = $spread_data['score'] + bcmul($pv, 0.13,2);
284
-//                                                // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.13,2);
285
-//
286
-//                                                $yj_amount_90 = bcmul($pv, 0.13,2) * 0.9;
287
-//                                                $fgj_amount_10 = bcmul($pv, 0.13,2) * 0.1;//推广者的佣金抽10%到个人复购金
288
-//
289
-//                                                $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
290
-//                                                $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
291
-//                                                $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
292
-//
293
-//                                                // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
294
-//                                            }else if($spread_data['user_group'] == 6){
295
-//                                                $ssf =bcmul($pv, 0.15,2);
296
-//                                                $con       = $spread_data['contribute'] + bcmul($pv, 0.15,2);
297
-//                                                $score     = $spread_data['score'] + bcmul($pv, 0.15,2);
298
-//                                                // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.15,2);
299
-//
300
-//                                                $yj_amount_90 = bcmul($pv, 0.15,2) * 0.9;
301
-//                                                $fgj_amount_10 = bcmul($pv, 0.15,2) * 0.1;//推广者的佣金抽10%到个人复购金
302
-//
303
-//                                                $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
304
-//                                                $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
305
-//                                                $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
306
-//
307
-//                                                // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
308
-//                                            }else if($spread_data['user_group'] == 7){
309
-//                                                $ssf =bcmul($pv, 0.17,2);
310
-//                                                $con       = $spread_data['contribute'] + bcmul($pv * 0.17,2);
311
-//                                                $score     = $spread_data['score'] + bcmul($pv, 0.17,2);
312
-//                                                // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.17,2);
313
-//
314
-//                                                $yj_amount_90 = bcmul($pv, 0.17,2) * 0.9;
315
-//                                                $fgj_amount_10 = bcmul($pv, 0.17,2) * 0.1;//推广者的佣金抽10%到个人复购金
316
-//
317
-//                                                $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
318
-//                                                $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
319
-//                                                $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
320
-//
321
-//                                                // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
322
-//                                            }
323
-//
324
-//                                            //贡献值
325
-//                                            $this->con_log($spread_data['uid'],$pv,$store_order_data['order_id'],11,"精彩生活区商品赠送贡献值");
326
-//                                            //积分
327
-//                                            $this->score_log($spread_data['uid'],$ssf,$store_order_data['order_id'],11,"精彩生活区商品赠送积分");
328
-//                                            // //推广佣金
329
-//                                            $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'],0);
330
-//                                            //养老金
331
-//                                            $this->bill_user_log($spread_data['uid'],round($pv * 0.05,2),$store_order_data['order_id'],5,$store_order_data['order_sn'],'推广获得养老金'.round($pv * 0.05,2),$store_order_data['mer_id'],0);
332
-//                                        }
333
-
334
-                                        //普通用户推广人
335
-//                                        if($spread_data['user_group'] == 1){
336
-//                                            //给推广者分配佣金
337
-//                                            // $ylj_amount = $spread_data['annuity'] + round($pv * 0.3,2);
338
-//                                            // $yj_amount_90 = round($pv * 0.21,2) * 0.9;
339
-//                                            $yj_amount_90 = bcmul($pv, 0.3,2) * 0.9;
340
-//                                            // $fgj_amount_10 = round($pv * 0.21,2) * 0.1;//推广者的佣金抽10%到个人复购金
341
-//                                            $fgj_amount_10 = bcmul($pv, 0.3,2) * 0.1;//推广者的佣金抽10%到个人复购金
342
-//
343
-//                                            $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
344
-//                                            $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
345
-//                                            $this->fugou_user_log($spread_data['uid'],$fgj_amount_10,$store_order_data['order_id'],1);
346
-//
347
-//                                            //Db::name('user')->where('uid',$spread_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
348
-//
349
-//                                            $con = $spread_data['contribute'] + bcmul($pv, 0.3,2);
350
-//                                            $score = $spread_data['score'] + bcmul($pv, 0.3,2);
351
-//
352
-//                                            //贡献值和积分
353
-//                                            //Db::name('user')->where('uid',$spread_data['uid'])->update(["contribute"=>$con,"score"=>$score]);
354
-//
355
-//                                            //推广养老金
356
-//
357
-//                                            //推广佣金
358
-//                                            $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'],0);
359
-//                                            $this->con_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送贡献值");
360
-//                                            $this->score_log($spread_data['uid'],round($pv * 0.3,2),$store_order_data['order_id'],11,"推广精彩生活区商品赠送积分");
361
-//
362
-//
363
-//
364
-//                                        }
365 227
 
366 228
                                     //锁客收益
367 229
                                     if($user_data['mer_id'] != 0){
@@ -764,44 +626,78 @@ class Notify
764 626
                                     // 积分
765 627
                                     $this->score_log($user_data['uid'], $pv, $store_order_data['order_id'], 12, "购买商贸区商品赠送积分");
766 628
 
767
-                                    if ($user_data['spread_uid'] != 0) {
768
-                                        //查询下单用户上级
769
-                                        $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
770
-                                        /** @var \app\common\repositories\store\order\StoreOrderRepository $StoreOrderRepository */
629
+                                    $spread_data = Db::name('user')->where('uid',$user_data['spread_uid'])->find();
630
+                                    if($spread_data) {
631
+                                        $StoreOrderRepository = app()->make(StoreOrderRepository::class);
771 632
                                         $rate = $StoreOrderRepository->getUserGroupRate($spread_data['user_group']);
772
-                                        if ($spread_data['user_group'] > 1) {
773
-                                            $ssf = bcmul($pv, $rate, 2);
633
+                                        if ($spread_data['user_group'] == 1) {
774 634
                                             $yj_amount_90 = bcmul($pv, $rate, 2) * 0.9;
775 635
                                             $fgj_amount_10 = bcmul($pv, $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
636
+
776 637
                                             $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
777 638
 
778
-                                            //贡献值
779
-                                            $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 12, "推广商贸区商品赠送贡献值");
780
-                                            //积分
781
-                                            $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 12, "推广商贸区商品赠送积分");
639
+                                            //推广养老金
782 640
                                             //推广佣金
783
-                                            $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);
784
-                                            //养老金
785
-                                            $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
786
-                                        }
787
-
788
-                                        //普通用户推广人
789
-                                        if ($spread_data['user_group'] == 1) {
790
-                                            //给推广者分配佣金
641
+                                            $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'], 0);
642
+                                            // 贡献值
643
+                                            $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广商贸区商品赠送贡献值");
644
+                                            //积分
645
+                                            $this->score_log($spread_data['uid'], bcmul($pv, $rate, 2), $store_order_data['order_id'], 11, "推广商贸区商品赠送积分");
646
+                                        } else if ($spread_data['user_group'] > 1) {
791 647
 
648
+                                            $ssf = bcmul($pv, $rate, 2);
792 649
                                             $yj_amount_90 = bcmul($pv, $rate, 2) * 0.9;
793 650
                                             $fgj_amount_10 = bcmul($pv, $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
794
-
795 651
                                             $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
796 652
 
797
-                                            //推广佣金
798
-                                            $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);
799
-                                            // 贡献值
800
-                                            $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 12, "推广商贸区商品赠送贡献值");
801
-                                            // 积分
802
-                                            $this->score_log($spread_data['uid'], bcmul($pv, $rate, 2), $store_order_data['order_id'], 12, "推广商贸区商品赠送积分");
653
+                                            //贡献值
654
+                                            $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 11, "推广商贸区商品赠送贡献值");
655
+                                            //积分
656
+                                            $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 11, "推广商贸区商品赠送积分");
657
+                                            // //推广佣金
658
+                                            $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'], 0);
659
+                                            //养老金
660
+                                            $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
803 661
                                         }
804 662
                                     }
663
+//                                    if ($user_data['spread_uid'] != 0) {
664
+//                                        //查询下单用户上级
665
+//                                        $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
666
+//                                        /** @var \app\common\repositories\store\order\StoreOrderRepository $StoreOrderRepository */
667
+//                                        $rate = $StoreOrderRepository->getUserGroupRate($spread_data['user_group']);
668
+//                                        if ($spread_data['user_group'] > 1) {
669
+//                                            $ssf = bcmul($pv, $rate, 2);
670
+//                                            $yj_amount_90 = bcmul($pv, $rate, 2) * 0.9;
671
+//                                            $fgj_amount_10 = bcmul($pv, $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
672
+//                                            $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
673
+//
674
+//                                            //贡献值
675
+//                                            $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 12, "推广商贸区商品赠送贡献值");
676
+//                                            //积分
677
+//                                            $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 12, "推广商贸区商品赠送积分");
678
+//                                            //推广佣金
679
+//                                            $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);
680
+//                                            //养老金
681
+//                                            $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
682
+//                                        }
683
+//
684
+//                                        //普通用户推广人
685
+//                                        if ($spread_data['user_group'] == 1) {
686
+//                                            //给推广者分配佣金
687
+//
688
+//                                            $yj_amount_90 = bcmul($pv, $rate, 2) * 0.9;
689
+//                                            $fgj_amount_10 = bcmul($pv, $rate, 2) * 0.1;//推广者的佣金抽10%到个人复购金
690
+//
691
+//                                            $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
692
+//
693
+//                                            //推广佣金
694
+//                                            $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);
695
+//                                            // 贡献值
696
+//                                            $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 12, "推广商贸区商品赠送贡献值");
697
+//                                            // 积分
698
+//                                            $this->score_log($spread_data['uid'], bcmul($pv, $rate, 2), $store_order_data['order_id'], 12, "推广商贸区商品赠送积分");
699
+//                                        }
700
+//                                    }
805 701
 
806 702
                                     //锁客收益
807 703
                                     if ($user_data['mer_id'] != 0) {