|
@@ -9,6 +9,8 @@ use App\Models\PcCaoHistory;
|
|
|
use App\Models\PcIssue;
|
|
use App\Models\PcIssue;
|
|
|
use App\Models\PcPrediction;
|
|
use App\Models\PcPrediction;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class PcIssueService extends BaseService
|
|
class PcIssueService extends BaseService
|
|
|
{
|
|
{
|
|
@@ -105,7 +107,7 @@ class PcIssueService extends BaseService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //开奖
|
|
|
private static function lotteryDraw($issue_no, $winning_numbers, $combo, $recordImage)
|
|
private static function lotteryDraw($issue_no, $winning_numbers, $combo, $recordImage)
|
|
|
{
|
|
{
|
|
|
$info = PcIssue::where('issue_no', $issue_no)->first();
|
|
$info = PcIssue::where('issue_no', $issue_no)->first();
|
|
@@ -119,44 +121,50 @@ class PcIssueService extends BaseService
|
|
|
$winArr = array_map('intval', explode(',', $winning_numbers));
|
|
$winArr = array_map('intval', explode(',', $winning_numbers));
|
|
|
// 计算中奖
|
|
// 计算中奖
|
|
|
$awards = IssueService::award(explode(',', $winning_numbers));
|
|
$awards = IssueService::award(explode(',', $winning_numbers));
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $info->status = self::model()::STATUS_DRAW;
|
|
|
|
|
+ $info->winning_numbers = $winning_numbers;
|
|
|
|
|
+ $info->combo = $combo;
|
|
|
|
|
+ $info->image = $recordImage;
|
|
|
|
|
+ $info->save();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $replyInfo = KeyboardService::findOne(['button' => '本期开奖']);
|
|
|
|
|
+
|
|
|
|
|
+ if ($replyInfo) {
|
|
|
|
|
+ $text = $replyInfo->reply;
|
|
|
|
|
+ $text .= "\n";
|
|
|
|
|
+ $text .= $info->issue_no . "期 " . implode('+', explode(',', $winning_numbers)) . "=" . array_sum($winArr) . " " . $combo;
|
|
|
|
|
+
|
|
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
|
|
+ $image = $replyInfo->image;
|
|
|
|
|
+ if ($image) {
|
|
|
|
|
+ $image = url($image);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($buttons)) {
|
|
|
|
|
+ $serviceAccount = Config::where('field', 'service_account')->first()->val;
|
|
|
|
|
+ $buttons[] = [['text' => '✅唯一财务', 'callback_data' => "", 'url' => "https://t.me/{$serviceAccount}"]];
|
|
|
|
|
|
|
|
- $info->status = self::model()::STATUS_DRAW;
|
|
|
|
|
- $info->winning_numbers = $winning_numbers;
|
|
|
|
|
- $info->combo = $combo;
|
|
|
|
|
- $info->image = $recordImage;
|
|
|
|
|
- $info->save();
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- $replyInfo = KeyboardService::findOne(['button' => '本期开奖']);
|
|
|
|
|
-
|
|
|
|
|
- if ($replyInfo) {
|
|
|
|
|
- $text = $replyInfo->reply;
|
|
|
|
|
- $text .= "\n";
|
|
|
|
|
- $text .= $info->issue_no . "期 " . implode('+', explode(',', $winning_numbers)) . "=" . array_sum($winArr) . " " . $combo;
|
|
|
|
|
-
|
|
|
|
|
- $buttons = json_decode($replyInfo->buttons, true);
|
|
|
|
|
- $image = $replyInfo->image;
|
|
|
|
|
- if ($image) {
|
|
|
|
|
- $image = url($image);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ SendTelegramGroupMessageJob::dispatch($text, $buttons, $image, true);
|
|
|
}
|
|
}
|
|
|
- if (empty($buttons)) {
|
|
|
|
|
- $serviceAccount = Config::where('field', 'service_account')->first()->val;
|
|
|
|
|
- $buttons[] = [['text' => '✅唯一财务', 'callback_data' => "", 'url' => "https://t.me/{$serviceAccount}"]];
|
|
|
|
|
|
|
|
|
|
|
|
+ if (config('app.url') != 'https://bot28dev.testx2.cc') {
|
|
|
|
|
+ $recordImage = self::lotteryImage($info->issue_no);
|
|
|
}
|
|
}
|
|
|
- // self::bettingGroupNotice($text, $buttons, $image, true);
|
|
|
|
|
- SendTelegramGroupMessageJob::dispatch($text, $buttons, $image, true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (config('app.url') != 'https://bot28dev.testx2.cc') {
|
|
|
|
|
- $recordImage = self::lotteryImage($info->issue_no);
|
|
|
|
|
- }
|
|
|
|
|
- if ($recordImage) {
|
|
|
|
|
- // self::bettingGroupNotice('', [], url($recordImage));
|
|
|
|
|
- SendTelegramGroupMessageJob::dispatch('', [], url($recordImage), false);
|
|
|
|
|
|
|
+ if ($recordImage) {
|
|
|
|
|
+ // self::bettingGroupNotice('', [], url($recordImage));
|
|
|
|
|
+ SendTelegramGroupMessageJob::dispatch('', [], url($recordImage), false);
|
|
|
|
|
+ }
|
|
|
|
|
+ BetService::betSettled($info->issue_no, $awards);
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return ['code' => self::YES, 'msg' => '开奖成功'];
|
|
|
|
|
+ }catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ Log::error('开奖失败: ' . $e->getMessage() . $winning_numbers);
|
|
|
|
|
+ return ['code' => self::NOT, 'msg' => '开奖失败'];
|
|
|
}
|
|
}
|
|
|
- BetService::betSettled($info->issue_no, $awards);
|
|
|
|
|
- return ['code' => self::YES, 'msg' => '开奖成功'];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 生成开奖图片
|
|
// 生成开奖图片
|