Ver código fonte

邀请赠送礼物调整

zhangxiaobin 1 ano atrás
pai
commit
fee3a27e52
1 arquivos alterados com 18 adições e 13 exclusões
  1. 18 13
      application/common/service/UserService.php

+ 18 - 13
application/common/service/UserService.php

@@ -250,19 +250,24 @@ class UserService
                                     $giftWhere['id'] = $inviteGift;
                                     $gift = model('Gift')->where($giftWhere)->find();
                                     if (!empty($gift) && $inviteGiftNum > 0) {
-                                        $giftBack = [
-                                            'user_id' => $preUser['id'],//用户ID
-                                            'gift_id' => $inviteGift,//礼物ID
-                                            'name' => $gift['name'],//礼物名称
-                                            'image' => $gift['image'],//礼物静图
-                                            'gif_image' => $gift['special'],//礼物动图
-                                            'value' => $gift['value'],//购买价值
-                                            'number' => $inviteGiftNum,//数量
-                                            'get_way' => 5,//获得途径:1=活动获得,2=充值购买,3=爵位赠送,4=签到赠送,5=邀请获得
-                                        ];
-                                        $giftBackRes = model('GiftBack')->insertGetId($giftBack);
-                                        if (!$giftBackRes) {
-                                            throw new Exception('赠送礼物失败');
+                                        $userGiftBackWhere['user_id'] = $preUser['id'];
+                                        $userGiftBackWhere['get_way'] = 5;
+                                        $userGiftBack = model('GiftBack')->where($userGiftBackWhere)->find();
+                                        if (empty($userGiftBack)) {
+                                            $giftBack = [
+                                                'user_id' => $preUser['id'],//用户ID
+                                                'gift_id' => $inviteGift,//礼物ID
+                                                'name' => $gift['name'],//礼物名称
+                                                'image' => $gift['image'],//礼物静图
+                                                'gif_image' => $gift['special'],//礼物动图
+                                                'value' => $gift['value'],//购买价值
+                                                'number' => $inviteGiftNum,//数量
+                                                'get_way' => 5,//获得途径:1=活动获得,2=充值购买,3=爵位赠送,4=签到赠送,5=邀请获得
+                                            ];
+                                            $giftBackRes = model('GiftBack')->insertGetId($giftBack);
+                                            if (!$giftBackRes) {
+                                                throw new Exception('赠送礼物失败');
+                                            }
                                         }
                                     }
                                 }