Kaynağa Gözat

客户的技术给改的

lizhen_gitee 1 yıl önce
ebeveyn
işleme
3bbb5056a2
1 değiştirilmiş dosya ile 42 ekleme ve 0 silme
  1. 42 0
      application/index/controller/Plantask.php

+ 42 - 0
application/index/controller/Plantask.php

@@ -207,6 +207,48 @@ class Plantask extends Controller
         foreach($order_list as $key => $order){
 
             $new_times = $order['jiesuan_times'] + 1;
+
+            //直推代理商获益
+            $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('unishop_order')->where($map)->order('have_paid asc')->value('order_price');
+                $first_order = $first_order ?: 0;
+
+                $jishu = $order['order_price'];
+                $remark_shaoshang = '';
+                if($first_order < $order['order_price']){
+                    $jishu = $first_order;
+                    $remark_shaoshang = '(烧伤)';
+                }
+
+                //奖励
+                $bili = config('site.orderpaid_zhitui_bili') ?: 5;
+                $score = bcdiv(bcmul($jishu,$bili,0),100,0);
+                if($score > 0){
+                    $rs_wallet = $walletmodel->lockChangeAccountRemain($intro_uid,'score',$score,3,$new_times.'次 直推代理奖励'.$remark_shaoshang,'unishop_order',$order['id'],$order['user_id']);
+                    if($rs_wallet['status'] === false){
+                        echo $rs_wallet['msg'];
+                        Db::rollback();
+                        exit;
+                    }
+
+                    $rs_wallet = $walletmodel->lockChangeAccountRemain($intro_uid,'shouyi',$score,31,$new_times.'次 直推代理奖励'.$remark_shaoshang,'unishop_order',$order['id'],$order['user_id']);
+                    if($rs_wallet['status'] === false){
+                        echo $rs_wallet['msg'];
+                        Db::rollback();
+                        exit;
+                    }
+                }
+            }
+
+
             //买家得到收益,两个数据同步加
             if($order['order_shouyi'] > 0){
                 $shouyi = bcsub($order['order_shouyi'],$order['order_benjin']);  //总收益 - 本金 = 可提现收益