|
@@ -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'],
|
|
|
- 'gift_id' => $inviteGift,
|
|
|
- 'name' => $gift['name'],
|
|
|
- 'image' => $gift['image'],
|
|
|
- 'gif_image' => $gift['special'],
|
|
|
- 'value' => $gift['value'],
|
|
|
- 'number' => 1,
|
|
|
- 'get_way' => 5,
|
|
|
- 'createtime' => time(),
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $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'],
|
|
|
+ 'gift_id' => $inviteGift,
|
|
|
+ 'name' => $gift['name'],
|
|
|
+ 'image' => $gift['image'],
|
|
|
+ 'gif_image' => $gift['special'],
|
|
|
+ 'value' => $gift['value'],
|
|
|
+ 'number' => 1,
|
|
|
+ 'get_way' => 5,
|
|
|
+ 'createtime' => time(),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $giftBackRes = model('GiftBack')->insertAll($giftBack);
|
|
|
+ if (!$giftBackRes) {
|
|
|
+ throw new Exception('赠送礼物失败');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|