Browse Source

freebonus礼包

laowu 12 giờ trước cách đây
mục cha
commit
1b026a34ef

+ 1 - 0
app/Http/Controllers/Admin/RechargeController.php

@@ -277,6 +277,7 @@ class RechargeController extends Controller
                 '303' => '每日首充礼包',
                 '304' => '每日礼包',
                 '305' => '召回礼包',
+                '306' => 'freeBonus礼包',
                 '401' => '转盘活动充值',
                 '402' => '圣诞活动',
             ];

+ 38 - 0
app/Http/Controllers/Game/PayRechargeController.php

@@ -1615,7 +1615,45 @@ class PayRechargeController extends Controller
         }
     }
 
+    public function freeBonusGifts(Request $request)
+    {
+        $user = $request->user();
+        $this->setUserLocale($request);
+
+        $gifts = DB::table('agent.dbo.recharge_gift')
+            ->where('gift_id', 306)
+            ->orderBy('recommend', 'asc')
+            ->get();
+        $gifts = $gifts->keyBy('recommend');
+        $moneyList = [];
+        foreach ($gifts as $gift) {
+            $money = sprintf('%.2f', $gift->recommend);
+            $moneyList[$money] = $gift;
+        }
 
+        $result = [];
+        $gears = DB::table('agent.dbo.recharge_gear')
+            ->select('money', 'favorable_price', 'gear')
+            ->whereIn('money', array_keys($moneyList))
+            ->where('status', 1)
+            ->get();
+
+        foreach ($gears as $gear) {
+            if (empty($moneyList[$gear->money])) {
+                continue;
+            }
+            $gear->amount = 0;
+            $gear->gift_id = $moneyList[$gear->money]->gift_id;
+            $gear->task_bonus = $moneyList[$gear->money]->task_bonus;
+            $gear->recommend = sprintf('%.2f', $moneyList[$gear->money]->recommend);
+            $result[] = $gear;
+        }
+
+
+        return apiReturnSuc([
+            'list' => $result,
+        ]);
+    }
 
 
 

+ 3 - 0
app/Models/Order.php

@@ -275,6 +275,9 @@ class Order extends Model
             case 305:
                 $GiftsName = '召回礼包';
                 break;
+            case 306:
+                $GiftsName = 'freebonus礼包';
+                break;
             case 401:
                 $GiftsName = '大转盘';
                 break;

+ 21 - 1
app/Services/OrderServices.php

@@ -212,7 +212,13 @@ class  OrderServices
                     $this->createInactiveVipGiftRecord($user_id, $payAmt);
                 }
 
-            }else if ($GiftsID > 400) {
+            } else if ($GiftsID == 306) { // free bonus礼包
+                $Recharge = $payAmt;
+                $give = 0;
+                $favorable_price = $Recharge + $give;
+                $czReason = 50;
+                $cjReason = 51;
+            } else if ($GiftsID > 400) {
                 $Status = 1;
                 $recharge_gear = DB::connection('write')->table('agent.dbo.recharge_gear')->where('status', $Status)->where('money', $payAmt)->select('favorable_price', 'give')->first();
                 if(!$recharge_gear){
@@ -352,6 +358,20 @@ class  OrderServices
                 }
             }
         }
+        // free bonus 礼包:充值后赠送 InsureScore(单位为分)
+        if (in_array($GiftsID, [306]) && $payAmt > 0) {
+            $gift = DB::table('agent.dbo.recharge_gift')->lock('with(nolock)')
+                ->where(['gift_id' => $GiftsID, 'recommend' => $Recharge])
+                ->first();
+            if ($gift && $gift->task_bonus > 0) {
+                $bonus = (int) round($gift->task_bonus * NumConfig::NUM_VALUE);
+                if ($bonus > 0) {
+                    DB::table('QPTreasureDB.dbo.GameScoreInfo')
+                        ->where('UserID', $user_id)
+                        ->increment('InsureScore', $bonus);
+                }
+            }
+        }
         $favorable_price =  (int) round($favorable_price * NumConfig::NUM_VALUE) + ($vipSendChips ?? 0);
         $firstScore = DB::connection('write')->table('QPTreasureDB.dbo.GameScoreInfo')->where('UserID', $user_id)->value('Score');
         $Score = $favorable_price + $firstScore;

+ 1 - 0
routes/game.php

@@ -254,6 +254,7 @@ Route::group([
     $route->any('/pay/vip_inactive_gift', 'Game\PayRechargeController@vipInactiveGift'); // 连续未充值VIP礼包入口
     $route->any('/pay/vip_inactive_gift_info', 'Game\PayRechargeController@vipInactiveGiftSevenDays'); // 连续未充值VIP礼包7日礼包信息
     $route->any('/pay/claim_vip_inactive_gift_day', 'Game\PayRechargeController@claimVipInactiveGiftDayReward'); // 领取连续未充值VIP礼包某日奖励
+    $route->any('/pay/free_bonus_gift', 'Game\PayRechargeController@freeBonusGifts');
 
     $route->any('/reward-code/redeem', 'Game\RewardCodeController@redeem');