浏览代码

充值邀请礼物调整

zhangxiaobin 1 年之前
父节点
当前提交
e821af6478
共有 2 个文件被更改,包括 32 次插入0 次删除
  1. 22 0
      application/common/service/UserService.php
  2. 10 0
      application/extra/params.php

+ 22 - 0
application/common/service/UserService.php

@@ -244,6 +244,28 @@ class UserService
                                         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) {
+                                        $giftBack = [
+                                            'user_id' => $userId,//用户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()->insertGetId($giftBack);
+                                        if (!$giftBackRes) {
+                                            throw new Exception('赠送礼物失败');
+                                        }
+                                    }
+                                }
                             }
                         }
                     }

+ 10 - 0
application/extra/params.php

@@ -0,0 +1,10 @@
+<?php
+return [
+    'get_way' => [
+        1 => '活动获得',
+        2 => '充值购买',
+        3 => '爵位赠送',
+        4 => '签到赠送',
+        5 => '邀请赠送',
+    ],
+];