|
@@ -31,11 +31,29 @@ class IssueService extends BaseService
|
|
|
|
|
|
|
|
const COUNTDOWN_TO_CLOSING_THE_MARKET = 60;//提前xx秒封盘
|
|
const COUNTDOWN_TO_CLOSING_THE_MARKET = 60;//提前xx秒封盘
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public static function init($telegram, $data, $chatId, $firstName, $messageId): void
|
|
|
|
|
+ {
|
|
|
|
|
+ switch ($data) {
|
|
|
|
|
+ default:
|
|
|
|
|
+ //查看开奖历史图片
|
|
|
|
|
+ $pattern = "/^showLotteryHistory@@\d+$/";
|
|
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
|
|
+ $id = preg_replace('/^showLotteryHistory@@/', '', $data);
|
|
|
|
|
+ IssueService::sendLotteryImage($chatId, $id);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @description: 模型
|
|
* @description: 模型
|
|
|
* @return {string}
|
|
* @return {string}
|
|
|
*/
|
|
*/
|
|
|
- public static function model(): string
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function model(): string
|
|
|
{
|
|
{
|
|
|
return Issue::class;
|
|
return Issue::class;
|
|
|
}
|
|
}
|
|
@@ -44,7 +62,8 @@ class IssueService extends BaseService
|
|
|
* @description: 枚举
|
|
* @description: 枚举
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function enum(): string
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function enum(): string
|
|
|
{
|
|
{
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
@@ -54,7 +73,8 @@ class IssueService extends BaseService
|
|
|
* @param {array} $search 查询内容
|
|
* @param {array} $search 查询内容
|
|
|
* @return {array}
|
|
* @return {array}
|
|
|
*/
|
|
*/
|
|
|
- public static function getWhere(array $search = []): array
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function getWhere(array $search = []): array
|
|
|
{
|
|
{
|
|
|
$where = [];
|
|
$where = [];
|
|
|
if (isset($search['issue_no']) && !empty($search['issue_no'])) {
|
|
if (isset($search['issue_no']) && !empty($search['issue_no'])) {
|
|
@@ -78,7 +98,8 @@ class IssueService extends BaseService
|
|
|
* @param array $search
|
|
* @param array $search
|
|
|
* @return \App\Models\Coin|null
|
|
* @return \App\Models\Coin|null
|
|
|
*/
|
|
*/
|
|
|
- public static function findOne(array $search): ?Issue
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function findOne(array $search): ?Issue
|
|
|
{
|
|
{
|
|
|
return self::model()::where(self::getWhere($search))->first();
|
|
return self::model()::where(self::getWhere($search))->first();
|
|
|
}
|
|
}
|
|
@@ -88,7 +109,8 @@ class IssueService extends BaseService
|
|
|
* @param array $search
|
|
* @param array $search
|
|
|
* @return \Illuminate\Database\Eloquent\Collection
|
|
* @return \Illuminate\Database\Eloquent\Collection
|
|
|
*/
|
|
*/
|
|
|
- public static function findAll(array $search = [])
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function findAll(array $search = [])
|
|
|
{
|
|
{
|
|
|
return self::model()::where(self::getWhere($search))->get();
|
|
return self::model()::where(self::getWhere($search))->get();
|
|
|
}
|
|
}
|
|
@@ -98,7 +120,8 @@ class IssueService extends BaseService
|
|
|
* @param array $search
|
|
* @param array $search
|
|
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
|
|
*/
|
|
*/
|
|
|
- public static function paginate(array $search = [])
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function paginate(array $search = [])
|
|
|
{
|
|
{
|
|
|
$limit = isset($search['limit']) ? $search['limit'] : 15;
|
|
$limit = isset($search['limit']) ? $search['limit'] : 15;
|
|
|
$paginator = self::model()::where(self::getWhere($search))->orderBy('issue_no', 'desc')->paginate($limit);
|
|
$paginator = self::model()::where(self::getWhere($search))->orderBy('issue_no', 'desc')->paginate($limit);
|
|
@@ -110,7 +133,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $params
|
|
* @param {*} $params
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function submit($params = [])
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function submit($params = [])
|
|
|
{
|
|
{
|
|
|
$result = false;
|
|
$result = false;
|
|
|
$msg['code'] = self::NOT;
|
|
$msg['code'] = self::NOT;
|
|
@@ -149,7 +173,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $id
|
|
* @param {*} $id
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function betting($id)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function betting($id)
|
|
|
{
|
|
{
|
|
|
$info = self::findOne(['id' => $id]);
|
|
$info = self::findOne(['id' => $id]);
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
@@ -203,7 +228,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $id
|
|
* @param {*} $id
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function closeBetting($id)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function closeBetting($id)
|
|
|
{
|
|
{
|
|
|
$info = self::findOne(['id' => $id]);
|
|
$info = self::findOne(['id' => $id]);
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
@@ -252,7 +278,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $id
|
|
* @param {*} $id
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function lotteryDrawFail($id)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function lotteryDrawFail($id)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
$result = false;
|
|
$result = false;
|
|
@@ -298,7 +325,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $recordImage 开奖图片
|
|
* @param {*} $recordImage 开奖图片
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function lotteryDraw($id, $winning_numbers, $combo, $recordImage)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function lotteryDraw($id, $winning_numbers, $combo, $recordImage)
|
|
|
{
|
|
{
|
|
|
$info = self::findOne(['id' => $id]);
|
|
$info = self::findOne(['id' => $id]);
|
|
|
if (!$info) {
|
|
if (!$info) {
|
|
@@ -373,8 +401,9 @@ class IssueService extends BaseService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- // 虚拟开奖
|
|
|
|
|
- public static function fakeLotteryDraw($issue_no, $awards)
|
|
|
|
|
|
|
+// 虚拟开奖
|
|
|
|
|
+ public
|
|
|
|
|
+ static function fakeLotteryDraw($issue_no, $awards)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
$fake_bet_list = Cache::get('fake_bet_' . $issue_no, []);
|
|
$fake_bet_list = Cache::get('fake_bet_' . $issue_no, []);
|
|
@@ -412,7 +441,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $winning_numbers
|
|
* @param {*} $winning_numbers
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function award($winning_numbers)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function award($winning_numbers)
|
|
|
{
|
|
{
|
|
|
$result = [];
|
|
$result = [];
|
|
|
|
|
|
|
@@ -508,7 +538,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $number
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function calculateOddEven($number)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function calculateOddEven($number)
|
|
|
{
|
|
{
|
|
|
if ($number & 1) {
|
|
if ($number & 1) {
|
|
|
return GameplayRuleEnum::SINGLE;
|
|
return GameplayRuleEnum::SINGLE;
|
|
@@ -522,7 +553,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $number
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function calculateSumSize($number)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function calculateSumSize($number)
|
|
|
{
|
|
{
|
|
|
if ($number >= GameplayRuleEnum::SUM_BIG) {
|
|
if ($number >= GameplayRuleEnum::SUM_BIG) {
|
|
|
return GameplayRuleEnum::BIG;
|
|
return GameplayRuleEnum::BIG;
|
|
@@ -538,7 +570,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $number
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function calculateSumExtremeSize($number)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function calculateSumExtremeSize($number)
|
|
|
{
|
|
{
|
|
|
$result = '';
|
|
$result = '';
|
|
|
if ($number >= GameplayRuleEnum::SUM_EXTREME_BIG) {
|
|
if ($number >= GameplayRuleEnum::SUM_EXTREME_BIG) {
|
|
@@ -559,7 +592,8 @@ class IssueService extends BaseService
|
|
|
* @param {int} $c
|
|
* @param {int} $c
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function isBaoZi(int $a, int $b, int $c)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function isBaoZi(int $a, int $b, int $c)
|
|
|
{
|
|
{
|
|
|
$result = '';
|
|
$result = '';
|
|
|
if ($a === $b && $b === $c) {
|
|
if ($a === $b && $b === $c) {
|
|
@@ -576,7 +610,8 @@ class IssueService extends BaseService
|
|
|
* @param {int} $c
|
|
* @param {int} $c
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function isPair($a, $b, $c)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function isPair($a, $b, $c)
|
|
|
{
|
|
{
|
|
|
$result = '';
|
|
$result = '';
|
|
|
// 确保输入都是个位数
|
|
// 确保输入都是个位数
|
|
@@ -601,7 +636,8 @@ class IssueService extends BaseService
|
|
|
* @param {int} $c
|
|
* @param {int} $c
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function isStraight($a, $b, $c)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function isStraight($a, $b, $c)
|
|
|
{
|
|
{
|
|
|
$result = '';
|
|
$result = '';
|
|
|
// 确保输入都是个位数(0-9)
|
|
// 确保输入都是个位数(0-9)
|
|
@@ -636,7 +672,8 @@ class IssueService extends BaseService
|
|
|
* @param int $number 输入数字
|
|
* @param int $number 输入数字
|
|
|
* @return int 尾数
|
|
* @return int 尾数
|
|
|
*/
|
|
*/
|
|
|
- public static function getLastDigit($number)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function getLastDigit($number)
|
|
|
{
|
|
{
|
|
|
// 确保输入是整数
|
|
// 确保输入是整数
|
|
|
$number = (int)$number;
|
|
$number = (int)$number;
|
|
@@ -652,7 +689,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $number
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function calculateOneSize($number)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function calculateOneSize($number)
|
|
|
{
|
|
{
|
|
|
if ($number >= GameplayRuleEnum::ONE_BIG) {
|
|
if ($number >= GameplayRuleEnum::ONE_BIG) {
|
|
|
return GameplayRuleEnum::BIG;
|
|
return GameplayRuleEnum::BIG;
|
|
@@ -668,7 +706,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $number
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function getSection($number)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function getSection($number)
|
|
|
{
|
|
{
|
|
|
$result = '';
|
|
$result = '';
|
|
|
if ($number >= GameplayRuleEnum::SECTION_1[0] && $number <= GameplayRuleEnum::SECTION_1[1]) {
|
|
if ($number >= GameplayRuleEnum::SECTION_1[0] && $number <= GameplayRuleEnum::SECTION_1[1]) {
|
|
@@ -687,7 +726,8 @@ class IssueService extends BaseService
|
|
|
* @description: 近期开奖记录
|
|
* @description: 近期开奖记录
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
- public static function currentLotteryResults($memberId)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function currentLotteryResults($memberId)
|
|
|
{
|
|
{
|
|
|
// $result = self::model()::where('status', self::model()::STATUS_DRAW)->orderBy('id','desc')->take(16)->get();
|
|
// $result = self::model()::where('status', self::model()::STATUS_DRAW)->orderBy('id','desc')->take(16)->get();
|
|
|
// $text = "📅 近期开奖记录\n";
|
|
// $text = "📅 近期开奖记录\n";
|
|
@@ -772,7 +812,8 @@ class IssueService extends BaseService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function getCombo($winArr)
|
|
|
|
|
|
|
+ public
|
|
|
|
|
+ static function getCombo($winArr)
|
|
|
{
|
|
{
|
|
|
// 组合
|
|
// 组合
|
|
|
$sum = array_sum($winArr);
|
|
$sum = array_sum($winArr);
|
|
@@ -813,8 +854,9 @@ class IssueService extends BaseService
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 获取最新的开奖数据
|
|
|
|
|
- public static function getLatestIssue()
|
|
|
|
|
|
|
+// 获取最新的开奖数据
|
|
|
|
|
+ public
|
|
|
|
|
+ static function getLatestIssue()
|
|
|
{
|
|
{
|
|
|
$url = "https://ydpc28.co/api/pc28/list";
|
|
$url = "https://ydpc28.co/api/pc28/list";
|
|
|
$result = file_get_contents($url);
|
|
$result = file_get_contents($url);
|
|
@@ -897,8 +939,9 @@ class IssueService extends BaseService
|
|
|
return $result['list'];
|
|
return $result['list'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 获取最新的开奖数据
|
|
|
|
|
- public static function getLatestIssue2()
|
|
|
|
|
|
|
+// 获取最新的开奖数据
|
|
|
|
|
+ public
|
|
|
|
|
+ static function getLatestIssue2()
|
|
|
{
|
|
{
|
|
|
$url = "https://ydpc28.co/api/pc28/list";
|
|
$url = "https://ydpc28.co/api/pc28/list";
|
|
|
$result = file_get_contents($url);
|
|
$result = file_get_contents($url);
|
|
@@ -981,8 +1024,9 @@ class IssueService extends BaseService
|
|
|
return $result;
|
|
return $result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 封盘倒数
|
|
|
|
|
- public static function syncCountdownIssue()
|
|
|
|
|
|
|
+// 封盘倒数
|
|
|
|
|
+ public
|
|
|
|
|
+ static function syncCountdownIssue()
|
|
|
{
|
|
{
|
|
|
$info = self::model()::where('status', self::model()::STATUS_BETTING)->orderBy('end_time', 'asc')->first();
|
|
$info = self::model()::where('status', self::model()::STATUS_BETTING)->orderBy('end_time', 'asc')->first();
|
|
|
if ($info) {
|
|
if ($info) {
|
|
@@ -1012,8 +1056,9 @@ class IssueService extends BaseService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 停止下注
|
|
|
|
|
- public static function syncCloseIssue()
|
|
|
|
|
|
|
+// 停止下注
|
|
|
|
|
+ public
|
|
|
|
|
+ static function syncCloseIssue()
|
|
|
{
|
|
{
|
|
|
$now_date = date('Y-m-d H:i:s', time() + 30); // 提前30秒
|
|
$now_date = date('Y-m-d H:i:s', time() + 30); // 提前30秒
|
|
|
$list = self::findAll(['status' => self::model()::STATUS_BETTING]);
|
|
$list = self::findAll(['status' => self::model()::STATUS_BETTING]);
|
|
@@ -1025,8 +1070,9 @@ class IssueService extends BaseService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 生成开奖图片
|
|
|
|
|
- public static function lotteryImage($issue_no)
|
|
|
|
|
|
|
+// 生成开奖图片
|
|
|
|
|
+ public
|
|
|
|
|
+ static function lotteryImage($issue_no)
|
|
|
{
|
|
{
|
|
|
$list = self::model()::where('issue_no', '<=', $issue_no)->where(self::getWhere(['status' => self::model()::STATUS_DRAW]))->orderBy('issue_no', 'desc')->take(20)->get();
|
|
$list = self::model()::where('issue_no', '<=', $issue_no)->where(self::getWhere(['status' => self::model()::STATUS_DRAW]))->orderBy('issue_no', 'desc')->take(20)->get();
|
|
|
$records = $list->toArray();
|
|
$records = $list->toArray();
|
|
@@ -1068,8 +1114,9 @@ class IssueService extends BaseService
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 发送开奖图片
|
|
|
|
|
- public static function sendLotteryImage($chatId, $issueNo)
|
|
|
|
|
|
|
+// 发送开奖图片
|
|
|
|
|
+ public
|
|
|
|
|
+ static function sendLotteryImage($chatId, $issueNo)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
$recordImage = self::lotteryImage($issueNo);
|
|
$recordImage = self::lotteryImage($issueNo);
|