Explorar o código

自动订单奖金

lizhen_gitee hai 1 ano
pai
achega
43f54a2466

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

@@ -208,7 +208,7 @@ class Auth
             //注册钱包
             Db::name('user_wallet')->insertGetId(['user_id'=>$user->id]);
 
-            //上级的邀请人数+1
+            //上级的直推人数+1
             if($extend['intro_uid']){
                 Db::name('user')->where('id',$extend['intro_uid'])->setInc('intro_num');
             }

+ 2 - 0
application/extra/site.php

@@ -43,4 +43,6 @@ return array (
   'min_withdrawal_money' => '1',
   'max_withdrawal_money' => '1000000',
   'contactus' => '400123456',
+  'orderpaid_zhitui_bili' => '5',
+  'orderpaid_jiantui_bili' => '1',
 );

+ 7 - 4
application/index/controller/Plantask.php

@@ -22,8 +22,9 @@ class Plantask extends Controller
             exit;
         }
 
+        //最后买东西是11天前了,intro_num在这里使用,减少查到的数据量
         $tendays_ago = $this->hualuo_tendays_ago();
-        $list = Db::name('user')->where('last_paytime','lt',$tendays_ago)->where('intro_num','gt',0)->select(); //最后买东西是11天前了
+        $list = Db::name('user')->where('last_paytime','lt',$tendays_ago)->where('intro_num','gt',0)->select();
 
         if(!empty($list)){
             Db::startTrans();
@@ -94,7 +95,8 @@ class Plantask extends Controller
             //直推代理商获益
             $intro_uid = Db::name('user')->where('id',$order['user_id'])->value('intro_uid');
             if($intro_uid){
-                $score = bcdiv(bcmul($order['total_price'],5,2),100,2);
+                $bili = config('site.orderpaid_zhitui_bili') ?: 5;
+                $score = bcdiv(bcmul($order['total_price'],$bili,2),100,2);
                 if($score > 0){
                     $rs_wallet = $walletmodel->lockChangeAccountRemain($intro_uid,'score',$score,3,'直推代理奖励','unishop_order',$order['id']);
                     if($rs_wallet['status'] === false){
@@ -108,9 +110,10 @@ class Plantask extends Controller
             //上上级
             $top_uid = Db::name('user')->where('id',$intro_uid)->value('intro_uid');
             if($top_uid){
-                $score = bcdiv(bcmul($order['total_price'],1,2),100,2);
+                $bili = config('site.orderpaid_jiantui_bili') ?: 1;
+                $score = bcdiv(bcmul($order['total_price'],$bili,2),100,2);
                 if($score > 0){
-                    $rs_wallet = $walletmodel->lockChangeAccountRemain($top_uid,'score',$score,4,'推代理奖励','unishop_order',$order['id']);
+                    $rs_wallet = $walletmodel->lockChangeAccountRemain($top_uid,'score',$score,4,'推代理奖励','unishop_order',$order['id']);
                     if($rs_wallet['status'] === false){
                         echo $rs_wallet['msg'];
                         Db::rollback();