|
@@ -14,6 +14,8 @@ use Illuminate\Support\Facades\Log;
|
|
|
use App\Services\GameplayRuleService;
|
|
use App\Services\GameplayRuleService;
|
|
|
use App\Services\WalletService;
|
|
use App\Services\WalletService;
|
|
|
use App\Services\IssueService;
|
|
use App\Services\IssueService;
|
|
|
|
|
+use App\Services\UserService;
|
|
|
|
|
+use App\Services\BalanceLogService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 投注
|
|
* 投注
|
|
@@ -131,8 +133,8 @@ class BetService extends BaseService
|
|
|
$keywords = $betResult['rule']; // 玩法
|
|
$keywords = $betResult['rule']; // 玩法
|
|
|
$amount = $betResult['amount']; // 投注金额
|
|
$amount = $betResult['amount']; // 投注金额
|
|
|
|
|
|
|
|
- $GameplayRuleInfo = GameplayRuleService::getGameplayRules($keywords);
|
|
|
|
|
- if($GameplayRuleInfo == null){
|
|
|
|
|
|
|
+ $gameplayRuleInfo = GameplayRuleService::getGameplayRules($keywords);
|
|
|
|
|
+ if($gameplayRuleInfo == null){
|
|
|
$text = "玩法未配置!\n";
|
|
$text = "玩法未配置!\n";
|
|
|
$text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
|
|
$text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
|
|
|
$msg['text'] = $text;
|
|
$msg['text'] = $text;
|
|
@@ -142,6 +144,29 @@ class BetService extends BaseService
|
|
|
return $msg;
|
|
return $msg;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 期数验证
|
|
|
|
|
+ $issueInfo = IssueService::model()::where('status',IssueService::model()::STATUS_BETTING)->orderBy('id','desc')->first();
|
|
|
|
|
+ if(empty($issueInfo)){
|
|
|
|
|
+ $issueCloseInfo = IssueService::model()::where('status',IssueService::model()::STATUS_CLOSE)->orderBy('id','desc')->first();
|
|
|
|
|
+ if(empty($issueCloseInfo)){
|
|
|
|
|
+ $text = "暂无可下注期数,本次下注无效!\n";
|
|
|
|
|
+
|
|
|
|
|
+ $msg['text'] = $text;
|
|
|
|
|
+ if($memberId){
|
|
|
|
|
+ $msg['message_id'] = $messageId;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $msg;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $text = "封盘中,本次下注无效!\n";
|
|
|
|
|
+
|
|
|
|
|
+ $msg['text'] = $text;
|
|
|
|
|
+ if($memberId){
|
|
|
|
|
+ $msg['message_id'] = $messageId;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if(!is_numeric($amount) || $amount <= 0){
|
|
if(!is_numeric($amount) || $amount <= 0){
|
|
|
$text = "投注金额格式不正确!\n";
|
|
$text = "投注金额格式不正确!\n";
|
|
@@ -153,6 +178,25 @@ class BetService extends BaseService
|
|
|
return $msg;
|
|
return $msg;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 投注限制校验
|
|
|
|
|
+ if($amount < $gameplayRuleInfo['mininum']){
|
|
|
|
|
+ $text = "下注失败,最小金额限制{$gameplayRuleInfo['mininum']}\n";
|
|
|
|
|
+ $msg['text'] = $text;
|
|
|
|
|
+ if($memberId){
|
|
|
|
|
+ $msg['message_id'] = $messageId;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $msg;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 投注限制校验
|
|
|
|
|
+ if($amount > $gameplayRuleInfo['maxinum']){
|
|
|
|
|
+ $text = "下注失败,最大金额限制{$gameplayRuleInfo['maxinum']}\n";
|
|
|
|
|
+ $msg['text'] = $text;
|
|
|
|
|
+ if($memberId){
|
|
|
|
|
+ $msg['message_id'] = $messageId;
|
|
|
|
|
+ }
|
|
|
|
|
+ return $msg;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 获取用户余额
|
|
// 获取用户余额
|
|
|
$walletInfo = WalletService::findOne(['member_id' => $memberId]);
|
|
$walletInfo = WalletService::findOne(['member_id' => $memberId]);
|
|
@@ -167,5 +211,26 @@ class BetService extends BaseService
|
|
|
}
|
|
}
|
|
|
return $msg;
|
|
return $msg;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $userInfo = UserService::findOne(['member_id' => $memberId]);
|
|
|
|
|
+
|
|
|
|
|
+ $data = [];
|
|
|
|
|
+ $data['amount'] = $amount; // 分数
|
|
|
|
|
+ $data['keywords'] = $keywords; // 玩法
|
|
|
|
|
+ $data['member_id'] = $memberId;
|
|
|
|
|
+ $data['user_id'] = $userInfo->id;
|
|
|
|
|
+ $data['issue_no'] = $issueInfo->issue_no;
|
|
|
|
|
+ $data['issue_id'] = $issueInfo->id;
|
|
|
|
|
+ $data['odds'] = $gameplayRuleInfo['odds'];
|
|
|
|
|
+ $newBet = self::model()::create($data);
|
|
|
|
|
+
|
|
|
|
|
+ WalletService::updateBalance($memberId,-$amount);
|
|
|
|
|
+
|
|
|
|
|
+ BalanceLogService::addLog($memberId,-$amount,$balance,($balance-$amount),'投注',$newBet->id,'');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|