瀏覽代碼

邀请充值满足金额赠送奖励

zhangxiaobin 1 年之前
父節點
當前提交
6cd7fc28a5

+ 3 - 0
application/api/controller/Noble.php

@@ -138,6 +138,9 @@ class Noble extends Api
         // 获取当前用户贵族等级
         if($userInfo["noble"] == $level_id) {
             $duetime = $userInfo["noble_duetime"];
+            if ($duetime < $time) {//过期时间过期验证
+                $duetime = $time;
+            }
         } else {
             $duetime = $time;
         }

+ 1 - 1
application/api/controller/Notify.php

@@ -143,7 +143,7 @@ class Notify extends Api
             $userInfo->chargecount = $userInfo->chargecount + $payamount;
             $userInfo->chargetime = time();
             $userInfo->save();
-            $userService = new UserService();
+            $userService = new UserService();//邀请赠送奖励
             $userService->inviteMoney(['user_id'=>$orderInfo["user_id"]]);
             // +EXP 充值任意金额
             \app\common\model\TaskLog::tofinish($orderInfo["user_id"], "5EMwg7la", 1);

+ 42 - 34
application/common/service/UserService.php

@@ -236,41 +236,49 @@ class UserService
                             $moneyLogWhere['type'] = 103;
                             $moneyLog = model('UserMoneyLog')->where($moneyLogWhere)->find();
                             if (empty($moneyLog)) {
-                                $money = config('site.invite_money');
-                                if ($money > 0) {
-                                    $remark = '邀请推广充值';
-                                    $res = model('Wallet')->lockChangeAccountRemain($preUser['id'],$money,'+',$preUser['money'],$remark,103,'money',$userId);
-                                    if (!$res['status']) {
-                                        throw new Exception($res['msg']);
+                                //充值金额满足才能获取充值奖励
+                                $inviteMaxMoney = config('site.invite_max_money');
+                                $recharWhere['user_id'] = $userId;
+                                $recharWhere['status'] = 1;
+                                $userRecharMoney = model('RecharOrder')->where($recharWhere)->sum('money');
+                                if ($userRecharMoney >= $inviteMaxMoney) {
+                                    $money = config('site.invite_money');
+                                    if ($money > 0) {
+                                        $remark = '邀请推广充值';
+                                        $res = model('Wallet')->lockChangeAccountRemain($preUser['id'],$money,'+',$preUser['money'],$remark,103,'money',$userId);
+                                        if (!$res['status']) {
+                                            throw new Exception($res['msg']);
+                                        }
                                     }
-                                }
-                                $inviteGift = config('site.invite_gift');
-                                if ($inviteGift > 0) {
-                                    $inviteGiftNum = config('site.invite_gift_num');
-                                    $giftWhere['id'] = $inviteGift;
-                                    $gift = model('Gift')->where($giftWhere)->find();
-                                    if (!empty($gift) && $inviteGiftNum > 0) {
-                                        $userGiftBackWhere['user_id'] = $preUser['id'];
-                                        $userGiftBackWhere['get_way'] = 5;
-                                        $userGiftBack = model('GiftBack')->where($userGiftBackWhere)->find();
-                                        if (empty($userGiftBack)) {
-                                            for($i=1;$i<=$inviteGiftNum;$i++) {
-                                                $giftBack[] = [
-                                                    'user_id' => $preUser['id'],//用户ID
-                                                    'gift_id' => $inviteGift,//礼物ID
-                                                    'name' => $gift['name'],//礼物名称
-                                                    'image' => $gift['image'],//礼物静图
-                                                    'gif_image' => $gift['special'],//礼物动图
-                                                    'value' => $gift['value'],//购买价值
-                                                    'number' => 1,//数量
-                                                    'get_way' => 5,//获得途径:1=活动获得,2=充值购买,3=爵位赠送,4=签到赠送,5=邀请获得
-                                                    'createtime' => time(),
-                                                ];
-                                            }
-                                            //$giftBackRes = model('GiftBack')->insertGetId($giftBack);
-                                            $giftBackRes = model('GiftBack')->insertAll($giftBack);
-                                            if (!$giftBackRes) {
-                                                throw new Exception('赠送礼物失败');
+                                    $inviteGift = config('site.invite_gift');
+                                    if ($inviteGift > 0) {
+                                        $inviteGiftNum = config('site.invite_gift_num');
+                                        $giftWhere['id'] = $inviteGift;
+                                        $gift = model('Gift')->where($giftWhere)->find();
+                                        if (!empty($gift) && $inviteGiftNum > 0) {
+                                            $userGiftBackWhere['user_id'] = $preUser['id'];
+                                            $userGiftBackWhere['invite_user_id'] = $userId;
+                                            $userGiftBackWhere['get_way'] = 5;
+                                            $userGiftBack = model('GiftBack')->where($userGiftBackWhere)->find();
+                                            if (empty($userGiftBack)) {
+                                                for($i=1;$i<=$inviteGiftNum;$i++) {
+                                                    $giftBack[] = [
+                                                        'user_id' => $preUser['id'],//用户ID
+                                                        'gift_id' => $inviteGift,//礼物ID
+                                                        'name' => $gift['name'],//礼物名称
+                                                        'image' => $gift['image'],//礼物静图
+                                                        'gif_image' => $gift['special'],//礼物动图
+                                                        'value' => $gift['value'],//购买价值
+                                                        'number' => 1,//数量
+                                                        'get_way' => 5,//获得途径:1=活动获得,2=充值购买,3=爵位赠送,4=签到赠送,5=邀请获得
+                                                        'createtime' => time(),
+                                                    ];
+                                                }
+                                                //$giftBackRes = model('GiftBack')->insertGetId($giftBack);
+                                                $giftBackRes = model('GiftBack')->insertAll($giftBack);
+                                                if (!$giftBackRes) {
+                                                    throw new Exception('赠送礼物失败');
+                                                }
                                             }
                                         }
                                     }