|
@@ -6,23 +6,23 @@ namespace App\Services;
|
|
|
use App\Http\Controllers\admin\GameplayRule;
|
|
use App\Http\Controllers\admin\GameplayRule;
|
|
|
use App\Models\Rebate;
|
|
use App\Models\Rebate;
|
|
|
use App\Models\User;
|
|
use App\Models\User;
|
|
|
|
|
+use App\Services\BalanceLogService;
|
|
|
use App\Services\BaseService;
|
|
use App\Services\BaseService;
|
|
|
use App\Models\Bet;
|
|
use App\Models\Bet;
|
|
|
use App\Models\Config;
|
|
use App\Models\Config;
|
|
|
|
|
+use App\Services\GameplayRuleService;
|
|
|
|
|
+use App\Services\IssueService;
|
|
|
|
|
+use App\Services\UserService;
|
|
|
|
|
+use App\Services\WalletService;
|
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\App;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Collection;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
-
|
|
|
|
|
-use App\Services\GameplayRuleService;
|
|
|
|
|
-use App\Services\WalletService;
|
|
|
|
|
-use App\Services\IssueService;
|
|
|
|
|
-use App\Services\UserService;
|
|
|
|
|
-use App\Services\BalanceLogService;
|
|
|
|
|
use App\Jobs\SendTelegramMessageJob;
|
|
use App\Jobs\SendTelegramMessageJob;
|
|
|
use App\Jobs\SendTelegramGroupMessageJob;
|
|
use App\Jobs\SendTelegramGroupMessageJob;
|
|
|
|
|
+use Exception;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 投注
|
|
* 投注
|
|
@@ -184,28 +184,64 @@ class BetService extends BaseService
|
|
|
return $msg;
|
|
return $msg;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $keywords = $betResult['rule']; // 玩法
|
|
|
|
|
- $amount = $betResult['amount']; // 投注金额
|
|
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $text = lang('下注期数') . ":{issue_no}\n";
|
|
|
|
|
+ $text .= lang("下注内容") . "\n";
|
|
|
|
|
+ $text .= "--------\n";
|
|
|
|
|
+ $errText = "";
|
|
|
|
|
+ $success = false;
|
|
|
|
|
+ foreach ($betResult as $item) {
|
|
|
|
|
+ $keywords = $item['rule'];
|
|
|
|
|
+ $amount = $item['amount'];
|
|
|
|
|
+ $issueNo = "";
|
|
|
|
|
+ $b = static::singleNote($memberId, $keywords, $amount, $issueNo, $text, $errText);
|
|
|
|
|
+ if ($b) {
|
|
|
|
|
+ $text = str_replace("{issue_no}", $issueNo, $text);
|
|
|
|
|
+ $success = true;
|
|
|
|
|
+ $text .= "\n";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $errText .= "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $text .= "--------\n";
|
|
|
|
|
+ $text .= lang("下注成功");
|
|
|
|
|
+ if (!$success) {
|
|
|
|
|
+ $msg['text'] = "投注失败";
|
|
|
|
|
+ if ($messageId) {
|
|
|
|
|
+ $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $msg['text'] = $text;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return $msg;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static function singleNote($memberId, $keywords, $amount, &$issueNo, &$text, &$errText)
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
|
|
+ $serviceAccount = Config::where('field', 'service_customer')->first()->val;
|
|
|
$gameplayRuleInfo = GameplayRuleService::getGameplayRules($keywords);
|
|
$gameplayRuleInfo = GameplayRuleService::getGameplayRules($keywords);
|
|
|
if ($gameplayRuleInfo == null) {
|
|
if ($gameplayRuleInfo == null) {
|
|
|
- $text = lang("玩法未配置!") . "\n";
|
|
|
|
|
- $text .= lang("任何疑问都可以联系唯一财务") . ":@{$serviceAccount}";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("玩法未配置!") . "\n";
|
|
|
|
|
+ $errText .= lang("任何疑问都可以联系唯一财务") . ":@{$serviceAccount}";
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($gameplayRuleInfo['odds'] <= 0) {
|
|
if ($gameplayRuleInfo['odds'] <= 0) {
|
|
|
- $text = lang("赔率为0 庄家通吃 禁止投注!") . "\n";
|
|
|
|
|
- $text .= lang("任何疑问都可以联系唯一财务") . ":@{$serviceAccount}";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("赔率为0 庄家通吃 禁止投注!") . "\n";
|
|
|
|
|
+ $errText .= lang("任何疑问都可以联系唯一财务") . ":@{$serviceAccount}";
|
|
|
|
|
+ return false;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -214,64 +250,37 @@ class BetService extends BaseService
|
|
|
if (empty($issueInfo)) {
|
|
if (empty($issueInfo)) {
|
|
|
$issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
|
|
$issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
|
|
|
if (empty($issueCloseInfo)) {
|
|
if (empty($issueCloseInfo)) {
|
|
|
- $text = lang("暂无可下注期数,本次下注无效!") . "\n";
|
|
|
|
|
-
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("暂无可下注期数,本次下注无效!");
|
|
|
|
|
+ return false;
|
|
|
} else {
|
|
} else {
|
|
|
- $text = lang("封盘中,本次下注无效!") . "\n";
|
|
|
|
|
-
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("封盘中,本次下注无效!");
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_numeric($amount) || $amount <= 0) {
|
|
if (!is_numeric($amount) || $amount <= 0) {
|
|
|
- $text = lang("投注金额格式不正确!") . "\n";
|
|
|
|
|
- $text .= lang("任何疑问都可以联系唯一财务") . ":@{$serviceAccount}";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("投注金额格式不正确!");
|
|
|
|
|
+ $errText .= lang("任何疑问都可以联系唯一财务") . ":@{$serviceAccount}";
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$now_date = date('Y-m-d H:i:s', time() + 30); // 提前30秒
|
|
$now_date = date('Y-m-d H:i:s', time() + 30); // 提前30秒
|
|
|
if ($issueInfo['end_time'] < $now_date) {
|
|
if ($issueInfo['end_time'] < $now_date) {
|
|
|
- $text = lang("封盘中,本次下注无效!") . "\n";
|
|
|
|
|
-
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("封盘中,本次下注无效!");
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 投注限制校验
|
|
// 投注限制校验
|
|
|
if ($amount < $gameplayRuleInfo['mininum']) {
|
|
if ($amount < $gameplayRuleInfo['mininum']) {
|
|
|
- $text = lang("下注失败,最小金额限制") . "{$gameplayRuleInfo['mininum']}\n";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("下注失败,最小金额限制") . "{$gameplayRuleInfo['mininum']}\n";
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 投注限制校验
|
|
// 投注限制校验
|
|
|
if ($amount > $gameplayRuleInfo['maxinum']) {
|
|
if ($amount > $gameplayRuleInfo['maxinum']) {
|
|
|
- $text = lang("下注失败,最大金额限制") . "{$gameplayRuleInfo['maxinum']}\n";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("下注失败,最大金额限制") . "{$gameplayRuleInfo['maxinum']}\n";
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取用户余额
|
|
// 获取用户余额
|
|
@@ -280,15 +289,10 @@ class BetService extends BaseService
|
|
|
|
|
|
|
|
// 余额计算
|
|
// 余额计算
|
|
|
if ($balance < $amount) {
|
|
if ($balance < $amount) {
|
|
|
- $text = lang("余额不足,本次下注无效!\n");
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ $errText = lang("余额不足,本次下注无效!\n");
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$userInfo = UserService::findOne(['member_id' => $memberId]);
|
|
$userInfo = UserService::findOne(['member_id' => $memberId]);
|
|
|
|
|
|
|
|
$betInfo = self::findOne(['member_id' => $memberId, 'issue_no' => $issueInfo->issue_no, 'keywords' => $keywords]); // 相同下注
|
|
$betInfo = self::findOne(['member_id' => $memberId, 'issue_no' => $issueInfo->issue_no, 'keywords' => $keywords]); // 相同下注
|
|
@@ -330,34 +334,25 @@ class BetService extends BaseService
|
|
|
'huishui_percentage' => $huishui_percentage,
|
|
'huishui_percentage' => $huishui_percentage,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
- if (!RebateService::BibiReturn($rebate,$amount)) {
|
|
|
|
|
- $text = lang("比比返失败");
|
|
|
|
|
- $text .= "\n";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
- if ($messageId) {
|
|
|
|
|
- $msg['reply_to_message_id'] = $messageId;
|
|
|
|
|
- }
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ if (!RebateService::BibiReturn($rebate, $amount)) {
|
|
|
|
|
+ $errText = lang("比比返失败");
|
|
|
|
|
+ $errText .= "\n";
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- $text = lang('下注期数') . ":{$issueInfo->issue_no}\n";
|
|
|
|
|
- $text .= lang("下注内容") . "\n";
|
|
|
|
|
- $text .= "--------\n";
|
|
|
|
|
- $text .= "{$input}\n";
|
|
|
|
|
- $text .= "--------\n";
|
|
|
|
|
- $text .= lang("下注成功") . "\n";
|
|
|
|
|
- $msg['text'] = $text;
|
|
|
|
|
|
|
+ $text .= "{$keywords}{$amount}\n";
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// $lastStr = self::getLastChar($userInfo->first_name, 1);
|
|
// $lastStr = self::getLastChar($userInfo->first_name, 1);
|
|
|
$lastStr = self::hideMiddleDigits($userInfo->member_id, 4);
|
|
$lastStr = self::hideMiddleDigits($userInfo->member_id, 4);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $issueNo = $issueInfo->issue_no;
|
|
|
$groupText = lang("会员下注") . " 【" . $lastStr . "】 \n";
|
|
$groupText = lang("会员下注") . " 【" . $lastStr . "】 \n";
|
|
|
$groupText .= lang('下注期数') . ":{$issueInfo->issue_no} \n";
|
|
$groupText .= lang('下注期数') . ":{$issueInfo->issue_no} \n";
|
|
|
$groupText .= lang("下注内容") . ": \n";
|
|
$groupText .= lang("下注内容") . ": \n";
|
|
|
$groupText .= "----------- \n";
|
|
$groupText .= "----------- \n";
|
|
|
- $groupText .= "{$input} \n";
|
|
|
|
|
|
|
+ $groupText .= "{$keywords}{$amount} \n";
|
|
|
$groupText .= "----------- \n";
|
|
$groupText .= "----------- \n";
|
|
|
|
|
|
|
|
|
|
|
|
@@ -367,7 +362,7 @@ class BetService extends BaseService
|
|
|
// self::bettingGroupNotice($groupText, $inlineButton); // 群通知
|
|
// self::bettingGroupNotice($groupText, $inlineButton); // 群通知
|
|
|
self::asyncBettingGroupNotice($groupText, $inlineButton); // 异步群通知
|
|
self::asyncBettingGroupNotice($groupText, $inlineButton); // 异步群通知
|
|
|
|
|
|
|
|
- return $msg;
|
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|