Selaa lähdekoodia

烧伤与极差

lizhen_gitee 1 vuosi sitten
vanhempi
commit
652d4b094e
2 muutettua tiedostoa jossa 35 lisäystä ja 4 poistoa
  1. 1 1
      application/common/library/Auth.php
  2. 34 3
      application/index/controller/Plantask.php

+ 1 - 1
application/common/library/Auth.php

@@ -439,7 +439,7 @@ class Auth
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
         $userinfo['score'] = model('wallet')->getWallet($this->id,'score');//积分
         $userinfo['withdraw_score'] = Db::name('user_withdraw')->where('user_id',$this->id)->where('status',1)->sum('score');//已兑换积分
-        $userinfo['share_score'] = Db::name('user_score_log')->where('user_id',$this->id)->where('log_type',1)->sum('change_value');//分享奖励
+        $userinfo['share_score'] = Db::name('user_score_log')->where('user_id',$this->id)->where('log_type','IN',[3,4])->sum('change_value');//分享奖励
         $userinfo['intro_number'] = Db::name('user')->where('intro_uid',$this->id)->count('id');//我的粉丝
 
         return $userinfo;

+ 34 - 3
application/index/controller/Plantask.php

@@ -111,6 +111,7 @@ class Plantask extends Controller
     }
 
     //订单支付回调之后的任务,每分钟运行
+    //烧伤
     public function auto_order_paid(){
 
         $map = [
@@ -139,11 +140,27 @@ class Plantask extends Controller
                 }
             }
 
+
+
             //直推代理商获益
             $intro_uid = Db::name('user')->where('id',$order['user_id'])->value('intro_uid');
             if($intro_uid){
+
+                //直推的第一单金额,烧伤
+                $map = [
+                    'status' => 1,
+                    'have_paid' => ['gt',0],
+                    'user_id' => $intro_uid,
+                ];
+                $first_order = Db::name('order')->where($map)->order('have_paid asc')->value('order_price');
+                $jishu = $order['order_price'];
+                if($first_order < $order['order_price']){
+                    $jishu = $first_order;
+                }
+
+                //奖励
                 $bili = config('site.orderpaid_zhitui_bili') ?: 5;
-                $score = bcdiv(bcmul($order['order_price'],$bili,2),100,2);
+                $score = bcdiv(bcmul($jishu,$bili,2),100,2);
                 if($score > 0){
                     $rs_wallet = $walletmodel->lockChangeAccountRemain($intro_uid,'score',$score,3,'直推代理奖励','unishop_order',$order['id'],$order['user_id']);
                     if($rs_wallet['status'] === false){
@@ -157,8 +174,22 @@ class Plantask extends Controller
             //上上级
             $top_uid = Db::name('user')->where('id',$intro_uid)->value('intro_uid');
             if($top_uid){
+
+                //直推的第一单金额,烧伤
+                $map = [
+                    'status' => 1,
+                    'have_paid' => ['gt',0],
+                    'user_id' => $top_uid,
+                ];
+                $first_order = Db::name('order')->where($map)->order('have_paid asc')->value('order_price');
+                $jishu = $order['order_price'];
+                if($first_order < $order['order_price']){
+                    $jishu = $first_order;
+                }
+
+                //奖励
                 $bili = config('site.orderpaid_jiantui_bili') ?: 1;
-                $score = bcdiv(bcmul($order['order_price'],$bili,2),100,2);
+                $score = bcdiv(bcmul($jishu,$bili,2),100,2);
                 if($score > 0){
                     $rs_wallet = $walletmodel->lockChangeAccountRemain($top_uid,'score',$score,4,'间推代理奖励','unishop_order',$order['id'],$order['user_id']);
                     if($rs_wallet['status'] === false){
@@ -255,7 +286,7 @@ class Plantask extends Controller
             if($two_intro_uid > 0){
                 $two_intro_count = Db::name('user')->where('intro_uid',$two_intro_uid)->count();//上上级的直推
 //                $two_yeji = $this->jiesuan_yeji($two_intro_uid);//上上级的业绩
-                if($two_intro_count >= $rule['intronum']){//也要五个,且业绩不高于15万(极差)。这里很矛盾
+                if($two_intro_count >= $rule['intronum']){//>=5个才能拿。上上级的业绩肯定比上级高,如果大于等于五个,就同级了,因为极差,反而拿不到,这里很矛盾。除非重新计算上上级的等级
                     $score_2 = $score;//目前是一样的,不再次计算了
                     if($score_2 > 0){
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($two_intro_uid,'score',$score_2,7,$rule['level'].'级代理(间推)','unishop_order',$order['id'],$order['user_id']);