|
|
@@ -21,14 +21,14 @@ use App\Jobs\SendTelegramMessageJob;
|
|
|
|
|
|
/**
|
|
|
* 投注
|
|
|
-*/
|
|
|
-class IssueService extends BaseService
|
|
|
+ */
|
|
|
+class IssueService extends BaseService
|
|
|
{
|
|
|
/**
|
|
|
* @description: 模型
|
|
|
* @return {string}
|
|
|
- */
|
|
|
- public static function model() :string
|
|
|
+ */
|
|
|
+ public static function model(): string
|
|
|
{
|
|
|
return Issue::class;
|
|
|
}
|
|
|
@@ -36,8 +36,8 @@ class IssueService extends BaseService
|
|
|
/**
|
|
|
* @description: 枚举
|
|
|
* @return {*}
|
|
|
- */
|
|
|
- public static function enum() :string
|
|
|
+ */
|
|
|
+ public static function enum(): string
|
|
|
{
|
|
|
return '';
|
|
|
}
|
|
|
@@ -46,23 +46,23 @@ class IssueService extends BaseService
|
|
|
* @description: 获取查询条件
|
|
|
* @param {array} $search 查询内容
|
|
|
* @return {array}
|
|
|
- */
|
|
|
- public static function getWhere(array $search = []) :array
|
|
|
+ */
|
|
|
+ public static function getWhere(array $search = []): array
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(isset($search['issue_no']) && !empty($search['issue_no'])){
|
|
|
+ if (isset($search['issue_no']) && !empty($search['issue_no'])) {
|
|
|
$where[] = ['issue_no', '=', $search['issue_no']];
|
|
|
}
|
|
|
- if(isset($search['id']) && !empty($search['id'])){
|
|
|
+ if (isset($search['id']) && !empty($search['id'])) {
|
|
|
$where[] = ['id', '=', $search['id']];
|
|
|
}
|
|
|
- if(isset($search['status']) && !empty($search['status'])){
|
|
|
+ if (isset($search['status']) && !empty($search['status'])) {
|
|
|
$where[] = ['status', '=', $search['status']];
|
|
|
}
|
|
|
return $where;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* @description: 查询单条数据
|
|
|
* @param array $search
|
|
|
* @return \App\Models\Coin|null
|
|
|
@@ -89,29 +89,29 @@ class IssueService extends BaseService
|
|
|
*/
|
|
|
public static function paginate(array $search = [])
|
|
|
{
|
|
|
- $limit = isset($search['limit'])?$search['limit']:15;
|
|
|
- $paginator = self::model()::where(self::getWhere($search))->orderBy('issue_no','desc')->paginate($limit);
|
|
|
+ $limit = isset($search['limit']) ? $search['limit'] : 15;
|
|
|
+ $paginator = self::model()::where(self::getWhere($search))->orderBy('issue_no', 'desc')->paginate($limit);
|
|
|
return ['total' => $paginator->total(), 'data' => $paginator->items()];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description:
|
|
|
+ * @description:
|
|
|
* @param {*} $params
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function submit($params = [])
|
|
|
{
|
|
|
$result = false;
|
|
|
$msg['code'] = self::NOT;
|
|
|
$msg['msg'] = '';
|
|
|
-
|
|
|
+
|
|
|
// 2. 判断是否是更新
|
|
|
if (!empty($params['id'])) {
|
|
|
// 更新
|
|
|
- $info = self::findOne(['id'=>$params['id']] );
|
|
|
+ $info = self::findOne(['id' => $params['id']]);
|
|
|
if (!$info) {
|
|
|
$msg['msg'] = '期号不存在!';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$result = $info->update($params);
|
|
|
$id = $params['id'];
|
|
|
}
|
|
|
@@ -120,14 +120,14 @@ class IssueService extends BaseService
|
|
|
$result = $info = self::model()::create($params);
|
|
|
$id = $result->id;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if($result){
|
|
|
- $msg['code'] = self::YES;
|
|
|
- $msg['msg'] = '设置成功';
|
|
|
- $msg['key'] = $id;
|
|
|
- }else{
|
|
|
- $msg['msg'] = empty($msg['msg']) ?'操作失败':$msg['msg'];
|
|
|
+
|
|
|
+
|
|
|
+ if ($result) {
|
|
|
+ $msg['code'] = self::YES;
|
|
|
+ $msg['msg'] = '设置成功';
|
|
|
+ $msg['key'] = $id;
|
|
|
+ } else {
|
|
|
+ $msg['msg'] = empty($msg['msg']) ? '操作失败' : $msg['msg'];
|
|
|
}
|
|
|
|
|
|
return $msg;
|
|
|
@@ -140,13 +140,13 @@ class IssueService extends BaseService
|
|
|
*/
|
|
|
public static function betting($id)
|
|
|
{
|
|
|
- $info = self::findOne(['id'=>$id]);
|
|
|
- if(!$info){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'期号不存在'];
|
|
|
+ $info = self::findOne(['id' => $id]);
|
|
|
+ if (!$info) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '期号不存在'];
|
|
|
}
|
|
|
|
|
|
- if(!in_array($info->status, [self::model()::STATUS_DRAFT,self::model()::STATUS_BETTING])){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'期号状态不正确'];
|
|
|
+ if (!in_array($info->status, [self::model()::STATUS_DRAFT, self::model()::STATUS_BETTING])) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '期号状态不正确'];
|
|
|
}
|
|
|
|
|
|
$info->status = self::model()::STATUS_BETTING;
|
|
|
@@ -156,30 +156,30 @@ class IssueService extends BaseService
|
|
|
// $text .= "第".$info->issue_no."期\n";
|
|
|
// $text .= "🔥🔥🔥🔥🔥开始下注🔥🔥🔥🔥🔥\n";
|
|
|
$replyInfo = KeyboardService::findOne(['button' => '开始下注']);
|
|
|
- if($replyInfo){
|
|
|
+ if ($replyInfo) {
|
|
|
$text = $replyInfo->reply;
|
|
|
- $buttons = json_decode($replyInfo->buttons,true);
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
$image = $replyInfo->image;
|
|
|
- if($image){
|
|
|
+ if ($image) {
|
|
|
$image = url($image);
|
|
|
}
|
|
|
self::bettingGroupNotice($text, $buttons, $image);
|
|
|
}
|
|
|
$replyInfo = KeyboardService::findOne(['button' => '玩法规则']);
|
|
|
- if($replyInfo){
|
|
|
+ if ($replyInfo) {
|
|
|
$text = $replyInfo->reply;
|
|
|
- $buttons = json_decode($replyInfo->buttons,true);
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
$image = $replyInfo->image;
|
|
|
- if($image){
|
|
|
+ if ($image) {
|
|
|
$image = url($image);
|
|
|
}
|
|
|
- if(empty($buttons)){
|
|
|
+ if (empty($buttons)) {
|
|
|
$buttons = self::getOperateButton();
|
|
|
}
|
|
|
self::bettingGroupNotice($text, $buttons, $image);
|
|
|
}
|
|
|
- return ['code'=>self::YES, 'msg'=>'开始下注'];
|
|
|
- }
|
|
|
+ return ['code' => self::YES, 'msg' => '开始下注'];
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @description: 封盘
|
|
|
@@ -188,38 +188,38 @@ class IssueService extends BaseService
|
|
|
*/
|
|
|
public static function closeBetting($id)
|
|
|
{
|
|
|
- $info = self::findOne(['id'=>$id]);
|
|
|
- if(!$info){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'期号不存在'];
|
|
|
+ $info = self::findOne(['id' => $id]);
|
|
|
+ if (!$info) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '期号不存在'];
|
|
|
}
|
|
|
|
|
|
- if($info->status != self::model()::STATUS_BETTING){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'期号状态不正确'];
|
|
|
+ if ($info->status != self::model()::STATUS_BETTING) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '期号状态不正确'];
|
|
|
}
|
|
|
|
|
|
$info->status = self::model()::STATUS_CLOSE;
|
|
|
$info->save();
|
|
|
$replyInfo = KeyboardService::findOne(['button' => '停止下注']);
|
|
|
- if($replyInfo){
|
|
|
+ if ($replyInfo) {
|
|
|
$text = $replyInfo->reply;
|
|
|
- $buttons = json_decode($replyInfo->buttons,true);
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
$image = $replyInfo->image;
|
|
|
- if($image){
|
|
|
+ if ($image) {
|
|
|
$image = url($image);
|
|
|
}
|
|
|
self::bettingGroupNotice($text, $buttons, $image);
|
|
|
}
|
|
|
$replyInfo = KeyboardService::findOne(['button' => '封盘开奖']);
|
|
|
- if($replyInfo){
|
|
|
+ if ($replyInfo) {
|
|
|
$text = $replyInfo->reply;
|
|
|
- $buttons = json_decode($replyInfo->buttons,true);
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
$image = $replyInfo->image;
|
|
|
- if($image){
|
|
|
+ if ($image) {
|
|
|
$image = url($image);
|
|
|
}
|
|
|
self::bettingGroupNotice($text, $buttons, $image);
|
|
|
}
|
|
|
- return ['code'=>self::YES, 'msg'=>'封盘成功'];
|
|
|
+ return ['code' => self::YES, 'msg' => '封盘成功'];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -230,20 +230,20 @@ class IssueService extends BaseService
|
|
|
* @param {*} $recordImage 开奖图片
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- public static function lotteryDraw($id, $winning_numbers ,$combo ,$recordImage)
|
|
|
+ public static function lotteryDraw($id, $winning_numbers, $combo, $recordImage)
|
|
|
{
|
|
|
- $info = self::findOne(['id'=>$id]);
|
|
|
- if(!$info){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'期号不存在'];
|
|
|
+ $info = self::findOne(['id' => $id]);
|
|
|
+ if (!$info) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '期号不存在'];
|
|
|
}
|
|
|
|
|
|
- if($info->status != self::model()::STATUS_CLOSE){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'期号状态不正确'];
|
|
|
+ if ($info->status != self::model()::STATUS_CLOSE) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '期号状态不正确'];
|
|
|
}
|
|
|
|
|
|
- $winArr = array_map('intval',explode(',',$winning_numbers));
|
|
|
+ $winArr = array_map('intval', explode(',', $winning_numbers));
|
|
|
// 计算中奖
|
|
|
- $awards = self::award(explode(',',$winning_numbers));
|
|
|
+ $awards = self::award(explode(',', $winning_numbers));
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
$info->status = self::model()::STATUS_DRAW;
|
|
|
@@ -253,26 +253,26 @@ class IssueService extends BaseService
|
|
|
$info->save();
|
|
|
|
|
|
$replyInfo = KeyboardService::findOne(['button' => '本期开奖']);
|
|
|
- if($replyInfo){
|
|
|
+ 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);
|
|
|
+ $text .= $info->issue_no . "期 " . implode('+', explode(',', $winning_numbers)) . "=" . array_sum($winArr) . " " . $combo;
|
|
|
+
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
$image = $replyInfo->image;
|
|
|
- if($image){
|
|
|
+ if ($image) {
|
|
|
$image = url($image);
|
|
|
}
|
|
|
- if(empty($buttons)){
|
|
|
+ if (empty($buttons)) {
|
|
|
$serviceAccount = Config::where('field', 'service_account')->first()->val;
|
|
|
$buttons[] = [['text' => '✅唯一财务', 'callback_data' => "", 'url' => "https://t.me/{$serviceAccount}"]];
|
|
|
|
|
|
}
|
|
|
// dispatch(new SendTelegramMessageJob($text, $buttons, $image, true));
|
|
|
- self::bettingGroupNotice($text, $buttons, $image ,true);
|
|
|
+ self::bettingGroupNotice($text, $buttons, $image, true);
|
|
|
}
|
|
|
$recordImage = self::lotteryImage($info->issue_no);
|
|
|
- if($recordImage){
|
|
|
+ if ($recordImage) {
|
|
|
self::bettingGroupNotice('', [], url($recordImage));
|
|
|
// dispatch(new SendTelegramMessageJob('', [], url($recordImage)));
|
|
|
}
|
|
|
@@ -280,45 +280,44 @@ class IssueService extends BaseService
|
|
|
BetService::betSettled($info->issue_no, $awards);
|
|
|
|
|
|
|
|
|
-
|
|
|
DB::commit();
|
|
|
- return ['code'=>self::YES, 'msg'=>'开奖成功'];
|
|
|
+ return ['code' => self::YES, 'msg' => '开奖成功'];
|
|
|
} catch (\Exception $e) {
|
|
|
DB::rollBack();
|
|
|
- Log::error('开奖失败: '.$e->getMessage().$winning_numbers);
|
|
|
- return ['code'=>self::NOT, 'msg'=>'开奖失败'];
|
|
|
+ Log::error('开奖失败: ' . $e->getMessage() . $winning_numbers);
|
|
|
+ return ['code' => self::NOT, 'msg' => '开奖失败'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// 虚拟开奖
|
|
|
- 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, []);
|
|
|
$text = "";
|
|
|
|
|
|
- foreach($fake_bet_list as $k => $v){
|
|
|
- $lastStr = self::getLastChar($v['first_name'],1);
|
|
|
- if(in_array($v['keywords'],$awards)){
|
|
|
+ foreach ($fake_bet_list as $k => $v) {
|
|
|
+ $lastStr = self::getLastChar($v['first_name'], 1);
|
|
|
+ if (in_array($v['keywords'], $awards)) {
|
|
|
$amount = (float)$v['amount'];
|
|
|
$odds = (float)$v['odds'];
|
|
|
$profit = $amount * $odds;
|
|
|
- if($profit > 880000){
|
|
|
+ if ($profit > 880000) {
|
|
|
$profit = 880000; // 单注最高奖金880000
|
|
|
}
|
|
|
$item['profit'] = $profit;
|
|
|
|
|
|
$yl = $profit - $amount;
|
|
|
- if($k+1 <= 30){
|
|
|
- $text .= "私聊下注 【******".$lastStr."】 {$yl}\n";
|
|
|
+ if ($k + 1 <= 30) {
|
|
|
+ $text .= "私聊下注 【******" . $lastStr . "】 {$yl}\n";
|
|
|
}
|
|
|
- }else{
|
|
|
- if($k+1 <= 30){
|
|
|
- $text .= "私聊下注 【******".$lastStr."】 -{$v['amount']}\n";
|
|
|
+ } else {
|
|
|
+ if ($k + 1 <= 30) {
|
|
|
+ $text .= "私聊下注 【******" . $lastStr . "】 -{$v['amount']}\n";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return $text;
|
|
|
@@ -329,11 +328,11 @@ class IssueService extends BaseService
|
|
|
* @description: 获取中奖的奖项
|
|
|
* @param {*} $winning_numbers
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function award($winning_numbers)
|
|
|
{
|
|
|
$result = [];
|
|
|
-
|
|
|
+
|
|
|
// 组合
|
|
|
$sum = array_sum($winning_numbers);
|
|
|
|
|
|
@@ -346,25 +345,25 @@ class IssueService extends BaseService
|
|
|
$sumSize = self::calculateSumSize($sum); // 总和大小
|
|
|
$result[] = $sumSize;
|
|
|
$sumExtremeSize = self::calculateSumExtremeSize($sum); // 总和极值
|
|
|
- if($sumExtremeSize){
|
|
|
+ if ($sumExtremeSize) {
|
|
|
$result[] = $sumExtremeSize;
|
|
|
}
|
|
|
$sumCao = $sum . '操'; // 总和数字
|
|
|
$result[] = $sumCao;
|
|
|
- $sumCombo = $sumSize. $sumOddEven; // 总和大小单双组合
|
|
|
+ $sumCombo = $sumSize . $sumOddEven; // 总和大小单双组合
|
|
|
$result[] = $sumCombo;
|
|
|
|
|
|
$sumBaoZi = self::isBaoZi($winning_numbers[0], $winning_numbers[1], $winning_numbers[2]); // 豹子
|
|
|
- if($sumBaoZi){
|
|
|
+ if ($sumBaoZi) {
|
|
|
$result[] = $sumBaoZi;
|
|
|
}
|
|
|
$sumPair = self::isPair($winning_numbers[0], $winning_numbers[1], $winning_numbers[2]); // 对子
|
|
|
- if($sumPair){
|
|
|
+ if ($sumPair) {
|
|
|
$result[] = $sumPair;
|
|
|
}
|
|
|
|
|
|
$sumStraight = self::isStraight($winning_numbers[0], $winning_numbers[1], $winning_numbers[2]); // 顺子
|
|
|
- if($sumStraight){
|
|
|
+ if ($sumStraight) {
|
|
|
$result[] = $sumStraight;
|
|
|
}
|
|
|
|
|
|
@@ -372,44 +371,44 @@ class IssueService extends BaseService
|
|
|
$result[] = $tail . '尾'; // 尾数
|
|
|
|
|
|
$tailOddEven = self::calculateOddEven($tail); // 尾数单双
|
|
|
- $result[] = '尾'.$tailOddEven;
|
|
|
+ $result[] = '尾' . $tailOddEven;
|
|
|
|
|
|
$tailSize = self::calculateOneSize($tail); // 尾数大小
|
|
|
- $result[] = '尾'.$tailSize;
|
|
|
+ $result[] = '尾' . $tailSize;
|
|
|
|
|
|
- $tailCombo = '尾'.$tailSize . $tailOddEven; // 尾数大小单双组合
|
|
|
+ $tailCombo = '尾' . $tailSize . $tailOddEven; // 尾数大小单双组合
|
|
|
$result[] = $tailCombo;
|
|
|
|
|
|
$numA = $winning_numbers[0]; // A球
|
|
|
- $result[] = $numA.'A';
|
|
|
+ $result[] = $numA . 'A';
|
|
|
|
|
|
$numAOddEven = self::calculateOddEven($numA); // A球单双
|
|
|
- $result[] = 'A'.$numAOddEven;
|
|
|
+ $result[] = 'A' . $numAOddEven;
|
|
|
|
|
|
$numASize = self::calculateOneSize($numA); // A球大小
|
|
|
- $result[] = 'A'.$numASize;
|
|
|
+ $result[] = 'A' . $numASize;
|
|
|
|
|
|
- $result[] = 'A'.$numASize.$numAOddEven; // A球大小单双组合
|
|
|
+ $result[] = 'A' . $numASize . $numAOddEven; // A球大小单双组合
|
|
|
|
|
|
|
|
|
$numB = $winning_numbers[1]; // B球
|
|
|
- $result[] = $numB.'B';
|
|
|
+ $result[] = $numB . 'B';
|
|
|
|
|
|
$numBOddEven = self::calculateOddEven($numB); // B球
|
|
|
- $result[] = 'B'.$numBOddEven;
|
|
|
+ $result[] = 'B' . $numBOddEven;
|
|
|
$numBSize = self::calculateOneSize($numB); // B球大小
|
|
|
- $result[] = 'B'.$numBSize;
|
|
|
+ $result[] = 'B' . $numBSize;
|
|
|
|
|
|
- $result[] = 'B'.$numBSize.$numBOddEven; // B球大小单双组合
|
|
|
+ $result[] = 'B' . $numBSize . $numBOddEven; // B球大小单双组合
|
|
|
|
|
|
$numC = $winning_numbers[2];
|
|
|
- $result[] = $numC.'C';
|
|
|
+ $result[] = $numC . 'C';
|
|
|
$numCOddEven = self::calculateOddEven($numC); // C球单双
|
|
|
- $result[] = 'C'.$numCOddEven;
|
|
|
+ $result[] = 'C' . $numCOddEven;
|
|
|
$numCSize = self::calculateOneSize($numC); // C球大小
|
|
|
- $result[] = 'C'.$numCSize;
|
|
|
+ $result[] = 'C' . $numCSize;
|
|
|
|
|
|
- $result[] = 'C'.$numCSize.$numCOddEven; // C球大小单双组合
|
|
|
+ $result[] = 'C' . $numCSize . $numCOddEven; // C球大小单双组合
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
@@ -420,7 +419,7 @@ class IssueService extends BaseService
|
|
|
* @description: 算单双
|
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function calculateOddEven($number)
|
|
|
{
|
|
|
if ($number & 1) {
|
|
|
@@ -434,14 +433,14 @@ class IssueService extends BaseService
|
|
|
* @description: 总和大小
|
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function calculateSumSize($number)
|
|
|
{
|
|
|
- if($number >= GameplayRuleEnum::SUM_BIG) {
|
|
|
+ if ($number >= GameplayRuleEnum::SUM_BIG) {
|
|
|
return GameplayRuleEnum::BIG;
|
|
|
}
|
|
|
|
|
|
- if($number <= GameplayRuleEnum::SUM_SMALL){
|
|
|
+ if ($number <= GameplayRuleEnum::SUM_SMALL) {
|
|
|
return GameplayRuleEnum::SMALL;
|
|
|
}
|
|
|
}
|
|
|
@@ -450,15 +449,15 @@ class IssueService extends BaseService
|
|
|
* @description: 总和极值
|
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function calculateSumExtremeSize($number)
|
|
|
{
|
|
|
$result = '';
|
|
|
- if($number >= GameplayRuleEnum::SUM_EXTREME_BIG) {
|
|
|
+ if ($number >= GameplayRuleEnum::SUM_EXTREME_BIG) {
|
|
|
$result = GameplayRuleEnum::EXTREME_BIG;
|
|
|
}
|
|
|
|
|
|
- if($number <= GameplayRuleEnum::SUM_EXTREME_SMALL){
|
|
|
+ if ($number <= GameplayRuleEnum::SUM_EXTREME_SMALL) {
|
|
|
$result = GameplayRuleEnum::EXTREME_SMALL;
|
|
|
}
|
|
|
|
|
|
@@ -471,11 +470,11 @@ class IssueService extends BaseService
|
|
|
* @param {int} $b
|
|
|
* @param {int} $c
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function isBaoZi(int $a, int $b, int $c)
|
|
|
{
|
|
|
$result = '';
|
|
|
- if($a === $b && $b === $c){
|
|
|
+ if ($a === $b && $b === $c) {
|
|
|
$result = GameplayRuleEnum::BAO_ZI;
|
|
|
}
|
|
|
|
|
|
@@ -489,17 +488,18 @@ class IssueService extends BaseService
|
|
|
* @param {int} $c
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- public static function isPair($a, $b, $c) {
|
|
|
+ public static function isPair($a, $b, $c)
|
|
|
+ {
|
|
|
$result = '';
|
|
|
// 确保输入都是个位数
|
|
|
if (!is_numeric($a) || !is_numeric($b) || !is_numeric($c) ||
|
|
|
$a < 0 || $a > 9 || $b < 0 || $b > 9 || $c < 0 || $c > 9) {
|
|
|
return ''; // 或者抛出异常
|
|
|
}
|
|
|
-
|
|
|
- if(($a == $b && $a != $c) ||
|
|
|
- ($a == $c && $a != $b) ||
|
|
|
- ($b == $c && $b != $a)){
|
|
|
+
|
|
|
+ if (($a == $b && $a != $c) ||
|
|
|
+ ($a == $c && $a != $b) ||
|
|
|
+ ($b == $c && $b != $a)) {
|
|
|
$result = GameplayRuleEnum::PAIRS;
|
|
|
}
|
|
|
// 判断是否为对子情况
|
|
|
@@ -513,41 +513,43 @@ class IssueService extends BaseService
|
|
|
* @param {int} $c
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- public static function isStraight($a, $b, $c) {
|
|
|
+ public static function isStraight($a, $b, $c)
|
|
|
+ {
|
|
|
$result = '';
|
|
|
// 确保输入都是个位数(0-9)
|
|
|
if (!is_numeric($a) || !is_numeric($b) || !is_numeric($c) ||
|
|
|
$a < 0 || $a > 9 || $b < 0 || $b > 9 || $c < 0 || $c > 9) {
|
|
|
return '';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 去重(顺子必须三个不同数字)
|
|
|
if ($a == $b || $a == $c || $b == $c) {
|
|
|
return '';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 检查是否是完全升序或完全降序的连续数字
|
|
|
$numbers = [$a, $b, $c];
|
|
|
sort($numbers); // 排序后检查是否是 x, x+1, x+2
|
|
|
list($x, $y, $z) = $numbers;
|
|
|
-
|
|
|
+
|
|
|
// 情况1:升序连续(1,2,3)
|
|
|
$isAscending = ($x + 1 == $y) && ($y + 1 == $z);
|
|
|
-
|
|
|
+
|
|
|
// 情况2:降序连续(3,2,1)
|
|
|
$isDescending = ($z + 1 == $y) && ($y + 1 == $x);
|
|
|
- if($isAscending || $isDescending){
|
|
|
+ if ($isAscending || $isDescending) {
|
|
|
$result = GameplayRuleEnum::STRAIGHT;
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取数字的尾数
|
|
|
* @param int $number 输入数字
|
|
|
* @return int 尾数
|
|
|
*/
|
|
|
- public static function getLastDigit($number) {
|
|
|
+ public static function getLastDigit($number)
|
|
|
+ {
|
|
|
// 确保输入是整数
|
|
|
$number = (int)$number;
|
|
|
// 取绝对值,处理负数情况
|
|
|
@@ -561,14 +563,14 @@ class IssueService extends BaseService
|
|
|
* @description: 尾大小
|
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function calculateOneSize($number)
|
|
|
{
|
|
|
- if($number >= GameplayRuleEnum::ONE_BIG) {
|
|
|
+ if ($number >= GameplayRuleEnum::ONE_BIG) {
|
|
|
return GameplayRuleEnum::BIG;
|
|
|
}
|
|
|
|
|
|
- if($number <= GameplayRuleEnum::ONE_SMALL){
|
|
|
+ if ($number <= GameplayRuleEnum::ONE_SMALL) {
|
|
|
return GameplayRuleEnum::SMALL;
|
|
|
}
|
|
|
}
|
|
|
@@ -578,7 +580,8 @@ class IssueService extends BaseService
|
|
|
* @param {*} $number
|
|
|
* @return {*}
|
|
|
*/
|
|
|
- public static function getSection($number) {
|
|
|
+ public static function getSection($number)
|
|
|
+ {
|
|
|
$result = '';
|
|
|
if ($number >= GameplayRuleEnum::SECTION_1[0] && $number <= GameplayRuleEnum::SECTION_1[1]) {
|
|
|
$result = GameplayRuleEnum::ONE;
|
|
|
@@ -595,7 +598,7 @@ class IssueService extends BaseService
|
|
|
/**
|
|
|
* @description: 近期开奖记录
|
|
|
* @return {*}
|
|
|
- */
|
|
|
+ */
|
|
|
public static function currentLotteryResults($memberId)
|
|
|
{
|
|
|
// $result = self::model()::where('status', self::model()::STATUS_DRAW)->orderBy('id','desc')->take(16)->get();
|
|
|
@@ -620,7 +623,7 @@ class IssueService extends BaseService
|
|
|
// if(empty($sumExtremeSize)){
|
|
|
// $sumExtremeSize = "-";
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
// $tail = self::getLastDigit($sum); // 总和尾数
|
|
|
// if($tail == 0){
|
|
|
@@ -628,7 +631,6 @@ class IssueService extends BaseService
|
|
|
// }else{
|
|
|
// $tail = '尾'.$tail; // 尾数
|
|
|
// }
|
|
|
-
|
|
|
|
|
|
|
|
|
// $text .= "回合:{$v->issue_no}期 \n";
|
|
|
@@ -648,28 +650,28 @@ class IssueService extends BaseService
|
|
|
// 'text' => "暂无开奖记录",
|
|
|
// ]);
|
|
|
// }
|
|
|
- $result = self::model()::where('status', self::model()::STATUS_DRAW)->orderBy('id','desc')->first();
|
|
|
- if($result){
|
|
|
- if($result->image){
|
|
|
+ $result = self::model()::where('status', self::model()::STATUS_DRAW)->orderBy('id', 'desc')->first();
|
|
|
+ if ($result) {
|
|
|
+ if ($result->image) {
|
|
|
self::telegram()->sendPhoto([
|
|
|
'chat_id' => $memberId,
|
|
|
'photo' => InputFile::create(url($result->image)),
|
|
|
]);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// if($result->combo){
|
|
|
// self::telegram()->sendMessage([
|
|
|
// 'chat_id' => $memberId,
|
|
|
// 'text' => "",
|
|
|
// ]);
|
|
|
// }else{
|
|
|
- self::telegram()->sendMessage([
|
|
|
- 'chat_id' => $memberId,
|
|
|
- 'text' => "暂无开奖记录",
|
|
|
- ]);
|
|
|
+ self::telegram()->sendMessage([
|
|
|
+ 'chat_id' => $memberId,
|
|
|
+ 'text' => "暂无开奖记录",
|
|
|
+ ]);
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -678,9 +680,9 @@ class IssueService extends BaseService
|
|
|
{
|
|
|
$url = "https://ydpc28.co/api/pc28/list";
|
|
|
$result = file_get_contents($url);
|
|
|
- $result = json_decode($result,true);
|
|
|
- if($result['errorCode'] != 0){
|
|
|
- return ['code'=>self::NOT, 'msg'=>'获取最新期号失败'];
|
|
|
+ $result = json_decode($result, true);
|
|
|
+ if ($result['errorCode'] != 0) {
|
|
|
+ return ['code' => self::NOT, 'msg' => '获取最新期号失败'];
|
|
|
|
|
|
}
|
|
|
$nextDrawInfo = $result['data']['nextDrawInfo'];
|
|
|
@@ -691,22 +693,22 @@ class IssueService extends BaseService
|
|
|
// $endTime = date('Y-m-d',strtotime('+1 day')).' '.$nextDrawInfo['nextDrawTime']; // 下一期的截止时间
|
|
|
// }
|
|
|
|
|
|
- $endTime = date('Y-m-d H:i:s',strtotime($startTime) + 210);
|
|
|
-
|
|
|
+ $endTime = date('Y-m-d H:i:s', strtotime($startTime) + 210);
|
|
|
+
|
|
|
|
|
|
$list = $result['data']['list'];
|
|
|
$listKey = [];
|
|
|
- foreach($list as $k => $v){
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
$listKey[$v['lotNumber']] = $v;
|
|
|
}
|
|
|
|
|
|
$oldList = self::findAll(['status' => self::model()::STATUS_CLOSE]); // 获取所有封盘的期号
|
|
|
- foreach($oldList as $k => $v){
|
|
|
- if(isset($listKey[$v->issue_no])){
|
|
|
+ foreach ($oldList as $k => $v) {
|
|
|
+ if (isset($listKey[$v->issue_no])) {
|
|
|
$issue = $listKey[$v->issue_no];
|
|
|
$winning_numbers = implode(',', str_split((string)$issue['openCode']));
|
|
|
|
|
|
- $winArr = array_map('intval',explode(',',$winning_numbers));
|
|
|
+ $winArr = array_map('intval', explode(',', $winning_numbers));
|
|
|
|
|
|
// 组合
|
|
|
$sum = array_sum($winArr);
|
|
|
@@ -720,48 +722,48 @@ class IssueService extends BaseService
|
|
|
$combo[] = $sumSize;
|
|
|
|
|
|
$sumExtremeSize = self::calculateSumExtremeSize($sum); // 总和极值
|
|
|
- if($sumExtremeSize){
|
|
|
+ if ($sumExtremeSize) {
|
|
|
$combo[] = $sumExtremeSize;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$sumBaoZi = self::isBaoZi($winArr[0], $winArr[1], $winArr[2]); // 豹子
|
|
|
- if($sumBaoZi){
|
|
|
+ if ($sumBaoZi) {
|
|
|
$combo[] = $sumBaoZi;
|
|
|
}
|
|
|
$sumPair = self::isPair($winArr[0], $winArr[1], $winArr[2]); // 对子
|
|
|
- if($sumPair){
|
|
|
+ if ($sumPair) {
|
|
|
$combo[] = $sumPair;
|
|
|
}
|
|
|
|
|
|
$sumStraight = self::isStraight($winArr[0], $winArr[1], $winArr[2]); // 顺子
|
|
|
- if($sumStraight){
|
|
|
+ if ($sumStraight) {
|
|
|
$combo[] = $sumStraight;
|
|
|
}
|
|
|
|
|
|
$tail = self::getLastDigit($sum); // 总和尾数
|
|
|
- if($tail == 0 || $tail == 9){
|
|
|
-
|
|
|
- }else{
|
|
|
- $combo[] = '尾'.$tail; // 尾数
|
|
|
+ if ($tail == 0 || $tail == 9) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $combo[] = '尾' . $tail; // 尾数
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$combo = implode(' ', $combo);
|
|
|
- self::lotteryDraw($v->id, $winning_numbers, $combo,'');
|
|
|
+ self::lotteryDraw($v->id, $winning_numbers, $combo, '');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
sleep(3); // 等待开奖完成
|
|
|
|
|
|
$latestIssue = $list[0]; // 最后开奖
|
|
|
-
|
|
|
+
|
|
|
$new_issue_no = $latestIssue['lotNumber'] + 1; // 新期号
|
|
|
|
|
|
$newInfo = self::findOne(['issue_no' => $new_issue_no]); // 找新的期号
|
|
|
-
|
|
|
+
|
|
|
// 不存在
|
|
|
- if(!$newInfo){
|
|
|
+ if (!$newInfo) {
|
|
|
|
|
|
$res = self::submit([
|
|
|
'issue_no' => $new_issue_no,
|
|
|
@@ -770,56 +772,55 @@ class IssueService extends BaseService
|
|
|
'end_time' => $endTime,
|
|
|
]);
|
|
|
|
|
|
- $id = $res['key']??0;
|
|
|
- if($id){
|
|
|
+ $id = $res['key'] ?? 0;
|
|
|
+ if ($id) {
|
|
|
self::betting($id); // 开始下注
|
|
|
}
|
|
|
- Cache::set('new_issue_no',$new_issue_no, 10); // 缓存
|
|
|
+ Cache::set('new_issue_no', $new_issue_no, 10); // 缓存
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
// 封盘倒数
|
|
|
public static function syncCountdownIssue()
|
|
|
{
|
|
|
- $now_date = date('Y-m-d H:i:s',time() + 50); // 提前50秒
|
|
|
- $info = self::model()::where('status', self::model()::STATUS_BETTING)->orderBy('end_time','asc')->first();
|
|
|
- if($info){
|
|
|
- if($info['end_time'] < $now_date){
|
|
|
+ $now_date = date('Y-m-d H:i:s', time() + 50); // 提前50秒
|
|
|
+ $info = self::model()::where('status', self::model()::STATUS_BETTING)->orderBy('end_time', 'asc')->first();
|
|
|
+ if ($info) {
|
|
|
+ if ($info['end_time'] < $now_date) {
|
|
|
$replyInfo = KeyboardService::findOne(['button' => '封盘倒数']);
|
|
|
- if($replyInfo){
|
|
|
-
|
|
|
+ if ($replyInfo) {
|
|
|
+
|
|
|
$text = $replyInfo->reply;
|
|
|
- $buttons = json_decode($replyInfo->buttons,true);
|
|
|
+ $buttons = json_decode($replyInfo->buttons, true);
|
|
|
$image = $replyInfo->image;
|
|
|
- if($image){
|
|
|
+ if ($image) {
|
|
|
$image = url($image);
|
|
|
}
|
|
|
- if(Cache::has('issue_countdown_'.$info->id)){
|
|
|
-
|
|
|
- }else{
|
|
|
+ if (Cache::has('issue_countdown_' . $info->id)) {
|
|
|
+
|
|
|
+ } else {
|
|
|
self::bettingGroupNotice($text, $buttons, $image);
|
|
|
- Cache::put('issue_countdown_'.$info->id, true, 60); // 缓存50秒,防止多次发送
|
|
|
+ Cache::put('issue_countdown_' . $info->id, true, 60); // 缓存50秒,防止多次发送
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 停止下注
|
|
|
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]);
|
|
|
|
|
|
- foreach($list as $k => $v){
|
|
|
- if($v['end_time'] < $now_date){
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ if ($v['end_time'] < $now_date) {
|
|
|
self::closeBetting($v->id);
|
|
|
}
|
|
|
}
|
|
|
@@ -828,11 +829,11 @@ class IssueService extends BaseService
|
|
|
// 生成开奖图片
|
|
|
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();
|
|
|
|
|
|
- foreach($records as $k => $v){
|
|
|
- $winning_numbers = explode(',',$v['winning_numbers']);
|
|
|
+ foreach ($records as $k => $v) {
|
|
|
+ $winning_numbers = explode(',', $v['winning_numbers']);
|
|
|
$v['winning_numbers'] = $winning_numbers;
|
|
|
|
|
|
// 组合
|
|
|
@@ -845,15 +846,15 @@ class IssueService extends BaseService
|
|
|
$v['combo'] = $sumSize . ' ' . $sumOddEven;
|
|
|
|
|
|
$sumExtremeSize = self::calculateSumExtremeSize($sum); // 总和极值
|
|
|
- if(!$sumExtremeSize){
|
|
|
+ if (!$sumExtremeSize) {
|
|
|
$sumExtremeSize = '-';
|
|
|
}
|
|
|
$v['extreme'] = $sumExtremeSize;
|
|
|
|
|
|
$tail = self::getLastDigit($sum); // 总和尾数
|
|
|
- if($tail === 0 || $tail === 9){
|
|
|
+ if ($tail === 0 || $tail === 9) {
|
|
|
$tailStr = '-';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$tailStr = '尾' . $tail;
|
|
|
}
|
|
|
$v['tail'] = $tailStr;
|