Browse Source

邀请礼物调整单个数量

zhangxiaobin 1 year ago
parent
commit
0ba1d5c0d6
1 changed files with 15 additions and 12 deletions
  1. 15 12
      application/common/service/UserService.php

+ 15 - 12
application/common/service/UserService.php

@@ -254,18 +254,21 @@ class UserService
                                         $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=邀请获得
-                                                'createtime' => time(),
-                                            ];
-                                            $giftBackRes = model('GiftBack')->insertGetId($giftBack);
+                                            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('赠送礼物失败');
                                             }