lizhen_gitee 1 vuosi sitten
vanhempi
commit
ddd883d4b2
2 muutettua tiedostoa jossa 73 lisäystä ja 12 poistoa
  1. 72 0
      application/api/controller/Notify.php
  2. 1 12
      application/api/controller/User.php

+ 72 - 0
application/api/controller/Notify.php

@@ -80,8 +80,11 @@ class Notify extends Api
             Db::rollback();
             return false;
         }
+        //上供到上级
+
         //逻辑结束
 
+
         //状态
         $ros = Db::name('pay_order')->where(['out_trade_no' => $out_trade_no])->update(['order_status'=>1,'notifytime'=>time()]);
         if($ros === false) {
@@ -94,6 +97,75 @@ class Notify extends Api
         return true;
     }
 
+    public function recharge($user_id,$gold,$payorder_id){
+        //充值者本人
+        $userinfo = Db::name('user')->field('id,username,group_id,intro_uid,gender')->where('id',$user_id)->find();
+
+        //没有推荐人,自己等级最高,女性充值不返
+        if(empty($userinfo['intro_uid']) || $userinfo['group_id'] == 3 || $userinfo['gender'] == 0){
+            return true;
+        }
+
+        //充值者上级
+        $intro_userinfo = Db::name('user')->field('id,username,group_id,intro_uid,gender')->where('id',$userinfo['intro_uid'])->find();
+        if(empty($intro_userinfo)){return true;}
+
+        //精确小数点
+        bcscale(1);
+
+        //上级是一级邀请A,本人为B普、B1(二级邀请人),贡献给A
+        if($intro_userinfo['group_id'] == 3){
+
+            $recharge_b2a_rate = config('site.recharge_b2a_rate');
+            $jewel = bcdiv(bcmul($gold,$recharge_b2a_rate),100);
+
+            $result = model('Wallet')->lockChangeAccountRemain($intro_userinfo['id'],'jewel',$jewel,41, $userinfo['username'].'充值','pay_order',$payorder_id);
+            if($result['status']===false)
+            {
+                Db::rollback();
+                return false;
+            }
+
+            return true;//结束了
+        }
+
+        //上级是二级邀请B0、B1,本人C1,贡献给A和B(表面上说B的钱在A那里,但是有记录,有总额,不能提现即可)
+        if($intro_userinfo['group_id'] == 2){
+            $recharge_c2b_rate = config('site.recharge_c2b_rate');
+            $jewel = bcdiv(bcmul($gold,$recharge_c2b_rate),100);
+
+            $result = model('Wallet')->lockChangeAccountRemain($intro_userinfo['id'],'jewel',$jewel,41, $userinfo['username'].'充值','pay_order',$payorder_id);
+            if($result['status']===false)
+            {
+                Db::rollback();
+                return false;
+            }
+
+            //充值者上上级,也就是A
+            $intro_intro_userinfo = Db::name('user')->field('id,username,group_id,intro_uid,gender')->where('id',$intro_userinfo['intro_uid'])->find();
+            if(empty($intro_intro_userinfo)){return true;}
+
+            if($intro_intro_userinfo['group_id'] == 3){
+
+                $recharge_b2a_rate = config('site.recharge_b2a_rate');
+                $jewel = bcdiv(bcmul($jewel,$recharge_b2a_rate),100);
+
+                $result = model('Wallet')->lockChangeAccountRemain($intro_intro_userinfo['id'],'jewel',$jewel,41, $userinfo['username'].'充值','pay_order',$payorder_id);
+                if($result['status']===false)
+                {
+                    Db::rollback();
+                    return false;
+                }
+            }
+
+        }
+
+        //上级是普通用户,则上级可能是C1、D1,再向上找到B
+
+
+
+    }
+
 
     //充值VIP 异步回调对外方法
     public function vip_notify_base(){

+ 1 - 12
application/api/controller/User.php

@@ -519,18 +519,7 @@ class User extends Api
             unset($data['introcode']);//别人的邀请码,不能改了自己的
             $data['intro_uid'] = $intro_user;
 
-            //邀请用户注册,给邀请人奖励
-            if(isset($data['intro_uid']) && !empty($data['intro_uid'])){
-                $intro_money = config('site.intro_newuser_gift_moneynum') ?: 0;
-                if($intro_money > 0){
-                    $wallet_rs = model('wallet')->lockChangeAccountRemain($data['intro_uid'],'money',$intro_money,63,'邀请'.$this->auth->username);
-                    if($wallet_rs['status'] === false){
-                        Db::rollback();
-                        $this->setError($wallet_rs['msg']);
-                        return false;
-                    }
-                }
-            }
+
         }
     }