BetService.php 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. <?php
  2. namespace App\Services;
  3. use App\Http\Controllers\admin\GameplayRule;
  4. use App\Models\Rebate;
  5. use App\Services\BaseService;
  6. use App\Models\Bet;
  7. use App\Models\Config;
  8. use Carbon\Carbon;
  9. use Illuminate\Support\Facades\DB;
  10. use Illuminate\Support\Collection;
  11. use Illuminate\Support\Facades\Cache;
  12. use Illuminate\Support\Facades\Log;
  13. use App\Services\GameplayRuleService;
  14. use App\Services\WalletService;
  15. use App\Services\IssueService;
  16. use App\Services\UserService;
  17. use App\Services\BalanceLogService;
  18. use App\Jobs\SendTelegramMessageJob;
  19. use App\Jobs\SendTelegramGroupMessageJob;
  20. /**
  21. * 投注
  22. */
  23. class BetService extends BaseService
  24. {
  25. public static $OTHER_BET_1 = [
  26. '大',
  27. '小',
  28. '单',
  29. '双',
  30. ];
  31. public static $OTHER_BET_2 = [
  32. '大单',
  33. '小双',
  34. '小单',
  35. '小双',
  36. ];
  37. /**
  38. * @description: 模型
  39. * @return {string}
  40. */
  41. public static function model(): string
  42. {
  43. return Bet::class;
  44. }
  45. /**
  46. * @description: 枚举
  47. * @return {*}
  48. */
  49. public static function enum(): string
  50. {
  51. return '';
  52. }
  53. /**
  54. * @description: 获取查询条件
  55. * @param {array} $search 查询内容
  56. * @return {array}
  57. */
  58. public static function getWhere(array $search = []): array
  59. {
  60. $where = [];
  61. if (isset($search['issue_no']) && !empty($search['issue_no'])) {
  62. $where[] = ['issue_no', '=', $search['issue_no']];
  63. }
  64. if (isset($search['member_id']) && !empty($search['member_id'])) {
  65. $where[] = ['member_id', '=', $search['member_id']];
  66. }
  67. if (isset($search['keywords']) && !empty($search['keywords'])) {
  68. $where[] = ['keywords', '=', $search['keywords']];
  69. }
  70. if (isset($search['issue_id']) && !empty($search['issue_id'])) {
  71. $where[] = ['issue_id', '=', $search['issue_id']];
  72. }
  73. if (isset($search['id']) && !empty($search['id'])) {
  74. $where[] = ['id', '=', $search['id']];
  75. }
  76. if (isset($search['user_id']) && !empty($search['user_id'])) {
  77. $where[] = ['user_id', '=', $search['user_id']];
  78. }
  79. if (isset($search['start_time']) && !empty($search['start_time'])) {
  80. $where[] = ['created_at', '>=', "{$search['start_time']} 00:00:00"];
  81. $where[] = ['created_at', '<=', "{$search['end_time']} 23:59:59"];
  82. }
  83. if (isset($search['is_winner']) && $search['is_winner'] != '') {
  84. $where[] = ['status', '=', 2];
  85. if ($search['is_winner'] == 1) {
  86. $where[] = ['profit', '>', 0];
  87. } else {
  88. $where[] = ['profit', '<=', 0];
  89. }
  90. } else {
  91. if (isset($search['status']) && !empty($search['status'])) {
  92. $where[] = ['status', '=', $search['status']];
  93. }
  94. }
  95. return $where;
  96. }
  97. /**
  98. * @description: 查询单条数据
  99. * @param array $search
  100. * @return \App\Models\Coin|null
  101. */
  102. public static function findOne(array $search): ?Bet
  103. {
  104. return self::model()::where(self::getWhere($search))->first();
  105. }
  106. /**
  107. * @description: 查询所有数据
  108. * @param array $search
  109. * @return \Illuminate\Database\Eloquent\Collection
  110. */
  111. public static function findAll(array $search = [])
  112. {
  113. return self::model()::where(self::getWhere($search))->get();
  114. }
  115. /**
  116. * @description: 分页查询
  117. * @param array $search
  118. * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  119. */
  120. public static function paginate(array $search = [])
  121. {
  122. $limit = isset($search['limit']) ? $search['limit'] : 15;
  123. $query = self::model()::where(self::getWhere($search))
  124. ->with(['user']);
  125. if (isset($search['username']) && !empty($search['username'])) {
  126. $username = $search['username'];
  127. $query = $query->whereHas('user', function ($query) use ($username) {
  128. $query->where('username', $username);
  129. });
  130. }
  131. $query->orderBy('id', 'desc');
  132. $paginator = $query->paginate($limit);
  133. return ['total' => $paginator->total(), 'data' => $paginator->items()];
  134. }
  135. /**
  136. * @description: 投注操作
  137. * @param {string} $memberId
  138. * @param {string} $input
  139. * @return {*}
  140. */
  141. public static function bet(string $memberId, string $input, $messageId = 0)
  142. {
  143. $msg = [];
  144. $msg['chat_id'] = $memberId;
  145. // 钱包生成
  146. // $walletInfo = WalletService::getUserWallet($memberId);
  147. // 分解投注的内容
  148. $betResult = GameplayRuleService::bettingRuleVerify($input);
  149. $serviceAccount = Config::where('field', 'service_customer')->first()->val;
  150. if ($betResult == null) {
  151. $text = "消息格式错误!\n";
  152. $text .= "任何疑问都可以联系唯一客服:@{$serviceAccount}";
  153. $msg['text'] = $text;
  154. if ($messageId) {
  155. $msg['reply_to_message_id'] = $messageId;
  156. }
  157. return $msg;
  158. }
  159. $keywords = $betResult['rule']; // 玩法
  160. $amount = $betResult['amount']; // 投注金额
  161. $gameplayRuleInfo = GameplayRuleService::getGameplayRules($keywords);
  162. if ($gameplayRuleInfo == null) {
  163. $text = "玩法未配置!\n";
  164. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  165. $msg['text'] = $text;
  166. if ($messageId) {
  167. $msg['reply_to_message_id'] = $messageId;
  168. }
  169. return $msg;
  170. }
  171. if ($gameplayRuleInfo['odds'] <= 0) {
  172. $text = "赔率为0 庄家通吃 禁止投注!\n";
  173. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  174. $msg['text'] = $text;
  175. if ($messageId) {
  176. $msg['reply_to_message_id'] = $messageId;
  177. }
  178. return $msg;
  179. }
  180. // 期数验证
  181. $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
  182. if (empty($issueInfo)) {
  183. $issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
  184. if (empty($issueCloseInfo)) {
  185. $text = "暂无可下注期数,本次下注无效!\n";
  186. $msg['text'] = $text;
  187. if ($messageId) {
  188. $msg['reply_to_message_id'] = $messageId;
  189. }
  190. return $msg;
  191. } else {
  192. $text = "封盘中,本次下注无效!\n";
  193. $msg['text'] = $text;
  194. if ($messageId) {
  195. $msg['reply_to_message_id'] = $messageId;
  196. }
  197. return $msg;
  198. }
  199. }
  200. if (!is_numeric($amount) || $amount <= 0) {
  201. $text = "投注金额格式不正确!\n";
  202. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  203. $msg['text'] = $text;
  204. if ($messageId) {
  205. $msg['reply_to_message_id'] = $messageId;
  206. }
  207. return $msg;
  208. }
  209. $now_date = date('Y-m-d H:i:s', time() + 30); // 提前30秒
  210. if ($issueInfo['end_time'] < $now_date) {
  211. $text = "封盘中,本次下注无效!\n";
  212. $msg['text'] = $text;
  213. if ($messageId) {
  214. $msg['reply_to_message_id'] = $messageId;
  215. }
  216. return $msg;
  217. }
  218. // 投注限制校验
  219. if ($amount < $gameplayRuleInfo['mininum']) {
  220. $text = "下注失败,最小金额限制{$gameplayRuleInfo['mininum']}\n";
  221. $msg['text'] = $text;
  222. if ($messageId) {
  223. $msg['reply_to_message_id'] = $messageId;
  224. }
  225. return $msg;
  226. }
  227. // 投注限制校验
  228. if ($amount > $gameplayRuleInfo['maxinum']) {
  229. $text = "下注失败,最大金额限制{$gameplayRuleInfo['maxinum']}\n";
  230. $msg['text'] = $text;
  231. if ($messageId) {
  232. $msg['reply_to_message_id'] = $messageId;
  233. }
  234. return $msg;
  235. }
  236. // 获取用户余额
  237. $walletInfo = WalletService::findOne(['member_id' => $memberId]);
  238. $balance = $walletInfo['available_balance'];
  239. // 余额计算
  240. if ($balance < $amount) {
  241. $text = "余额不足,本次下注无效!\n";
  242. $msg['text'] = $text;
  243. if ($messageId) {
  244. $msg['reply_to_message_id'] = $messageId;
  245. }
  246. return $msg;
  247. }
  248. $userInfo = UserService::findOne(['member_id' => $memberId]);
  249. $betInfo = self::findOne(['member_id' => $memberId, 'issue_no' => $issueInfo->issue_no, 'keywords' => $keywords]); // 相同下注
  250. if ($betInfo) {
  251. $betInfo->amount = $betInfo->amount + $amount;
  252. $bet_id = $betInfo->id;
  253. $betInfo->save();
  254. } else {
  255. $data = [];
  256. $data['amount'] = $amount; // 分数
  257. $data['keywords'] = $keywords; // 玩法
  258. $data['member_id'] = $memberId;
  259. $data['user_id'] = $userInfo->id;
  260. $data['issue_no'] = $issueInfo->issue_no;
  261. $data['issue_id'] = $issueInfo->id;
  262. $data['odds'] = $gameplayRuleInfo['odds'];
  263. $newBet = self::model()::create($data);
  264. $bet_id = $newBet->id;
  265. }
  266. WalletService::updateBalance($memberId, -$amount);
  267. BalanceLogService::addLog($memberId, -$amount, $balance, ($balance - $amount), '投注', $bet_id, '');
  268. $now = Carbon::now('America/New_York')->format('Y-m-d');
  269. $rebate = Config::where('field', 'rebate')->first()->val;
  270. $huishui_restriction = Config::where('field', 'huishui_restriction')->first()->val;
  271. $huishui_percentage = Config::where('field', 'huishui_percentage')->first()->val;
  272. Rebate::addOrUpdate([
  273. 'date' => $now,
  274. 'member_id' => $memberId,
  275. 'betting_amount' => $amount,
  276. 'rebate_ratio' => $rebate,
  277. 'first_name' => $userInfo->first_name,
  278. 'username' => $userInfo->username,
  279. 'huishui_restriction' => $huishui_restriction,
  280. 'huishui_percentage' => $huishui_percentage,
  281. ]);
  282. // // 返利
  283. // $rebate = Config::where('field', 'rebate')->first()->val;
  284. // if($rebate > 0){
  285. // $rebateAmount = bcmul($amount, $rebate, 2); // 返利金额
  286. // if($rebateAmount > 0){
  287. // WalletService::updateBalance($memberId,$rebateAmount);
  288. // $walletInfo = WalletService::findOne(['member_id' => $memberId]);
  289. // $balance = $walletInfo['available_balance'];
  290. // BalanceLogService::addLog($memberId,$rebateAmount,$balance,($balance+$rebateAmount),'返水',$bet_id,'');
  291. // }
  292. // }
  293. $text = "下注期数:{$issueInfo->issue_no}\n";
  294. $text .= "下注内容\n";
  295. $text .= "--------\n";
  296. $text .= "{$input}\n";
  297. $text .= "--------\n";
  298. $text .= "下注成功\n";
  299. $msg['text'] = $text;
  300. // $lastStr = self::getLastChar($userInfo->first_name, 1);
  301. $lastStr = self::hideMiddleDigits($userInfo->member_id, 4);
  302. $groupText = "";
  303. $groupText .= "会员下注 【" . $lastStr . "】 \n";
  304. $groupText .= "下注期数:{$issueInfo->issue_no} \n";
  305. $groupText .= "下注内容: \n";
  306. $groupText .= "----------- \n";
  307. $groupText .= "{$input} \n";
  308. $groupText .= "----------- \n";
  309. $inlineButton = self::getOperateButton();
  310. // 群通知
  311. // self::bettingGroupNotice($groupText, $inlineButton); // 群通知
  312. self::asyncBettingGroupNotice($groupText, $inlineButton); // 异步群通知
  313. return $msg;
  314. }
  315. // 模拟下注
  316. public static function fakeBet()
  317. {
  318. $noRule = ['0操', '27操'];
  319. // 防止一开就虚拟投注
  320. $cache = Cache::get('new_issue_no');
  321. if ($cache) {
  322. return;
  323. }
  324. $betFake = Config::where('field', 'bet_fake')->first()->val;
  325. if ($betFake) {
  326. // 期数验证
  327. $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
  328. if ($issueInfo) {
  329. $betFakeRandAmount = Config::where('field', 'bet_fake_rand_amount')->first()->val;
  330. $betFakeRandAmount = explode(',', $betFakeRandAmount);
  331. $betMini = $betFakeRandAmount[0] ?? 10;
  332. $betMax = $betFakeRandAmount[1] ?? 10000;
  333. $now_date = date('Y-m-d H:i:s', time() + 45); // 提前45秒
  334. if ($issueInfo['end_time'] > $now_date) {
  335. $fake_bet_list = Cache::get('fake_bet_' . $issueInfo->issue_no, []);
  336. $gameplayRuleList = GameplayRuleService::model()::where('odds', '>', 0)->get();
  337. $gameplayRuleList = $gameplayRuleList->toArray();
  338. $member_id = self::generateRandomNumber(10);
  339. $betTimes = rand(1, 4); // 每次下注次数
  340. for ($i = 0; $i < $betTimes; $i++) {
  341. $randKey = array_rand($gameplayRuleList, 1);
  342. $gameplayRuleInfo = $gameplayRuleList[$randKey] ?? [];
  343. if ($gameplayRuleInfo) {
  344. if (in_array($gameplayRuleInfo['keywords'], $noRule)) {
  345. return;
  346. }
  347. if ($gameplayRuleInfo['maxinum'] < $betMax) {
  348. $betMax = $gameplayRuleInfo['maxinum'];
  349. }
  350. if ($gameplayRuleInfo['mininum'] > $betMini) {
  351. $betMini = $gameplayRuleInfo['mininum'];
  352. }
  353. $amount = rand($betMini, $betMax);
  354. $amount = floor($amount / 10) * 10;
  355. $input = $gameplayRuleInfo['keywords'] . $amount;
  356. // $amount = number_format($amount,2);
  357. $item = [];
  358. $item['keywords'] = $gameplayRuleInfo['keywords'];
  359. $item['odds'] = $gameplayRuleInfo['odds'];
  360. $item['amount'] = $amount;
  361. $item['first_name'] = self::generateRandomString(6);
  362. $item['member_id'] = $member_id;
  363. $item['profit'] = 0;
  364. // $input = $item['keywords'] . $item['amount'];
  365. $fake_bet_list[] = $item;
  366. $lastStr = self::hideMiddleDigits($item['member_id'], 4);
  367. $groupText = "";
  368. $groupText .= "会员下注 【" . $lastStr . "】 \n";
  369. $groupText .= "下注期数:{$issueInfo->issue_no} \n";
  370. $groupText .= "下注内容: \n";
  371. $groupText .= "----------- \n";
  372. $groupText .= "{$input} \n";
  373. $groupText .= "----------- \n";
  374. $inlineButton = self::getOperateButton();
  375. // 群通知
  376. // self::bettingGroupNotice($groupText, $inlineButton); // 群通知
  377. self::asyncBettingGroupNotice($groupText, $inlineButton); // 异步群通知
  378. }
  379. }
  380. Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);
  381. }
  382. }
  383. }
  384. }
  385. /**
  386. * @description: 当期下注
  387. * @param {*} $memberId
  388. * @return {*}
  389. */
  390. public static function currentBet($memberId)
  391. {
  392. $msg['chat_id'] = $memberId;
  393. // 期数验证
  394. $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
  395. $issue_no = '';
  396. if (!empty($issueInfo)) {
  397. $issue_no = $issueInfo->issue_no;
  398. } else {
  399. $issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
  400. if (empty($issueCloseInfo)) {
  401. $issue_no = $issueCloseInfo->issue_no;
  402. }
  403. }
  404. if ($issue_no) {
  405. $text = "期数{$issue_no} \n";
  406. // $text .= "\n";
  407. // $text .= "----------\n";
  408. $list = self::findAll(['member_id' => $memberId, 'issue_no' => $issue_no]);
  409. $list = $list->toArray();
  410. if (empty($list)) {
  411. $text .= "本期暂未下注! \n";
  412. } else {
  413. $keywords = implode(',', array_column($list, 'keywords'));
  414. $amounts = implode(',', array_column($list, 'amount'));
  415. $text .= "下注类型:[" . $keywords . "] \n";
  416. $text .= "下注金额:" . $amounts . " \n";
  417. $text .= "下注总额:" . array_sum(array_column($list, 'amount')) . " \n";
  418. $text .= "开奖状态:等待开奖 \n";
  419. }
  420. // foreach ($list->toArray() as $k => $v) {
  421. // $text .= "{$v['keywords']}{$v['amount']} \n";
  422. // }
  423. // $text .= "\n";
  424. // $text .= "----------\n";
  425. $msg['text'] = $text;
  426. } else {
  427. $msg['text'] = "当前没有开放的投注期数! \n";
  428. }
  429. return $msg;
  430. }
  431. /**
  432. * @description: 近期投注
  433. * @param {*} $memberId
  434. * @return {*}
  435. */
  436. public static function recentlyRecord($memberId, $page = 1, $limit = 5)
  437. {
  438. $list = self::model()::where('member_id', $memberId)->whereIn('status', [self::model()::STATUS_STAY, self::model()::STATUS_SETTLED])->orderBy('id', 'desc')->forPage($page, $limit)->get();
  439. // $text = "```\n";
  440. $text = "";
  441. $text .= "期数--内容--盈亏 \n";
  442. foreach ($list->toArray() as $k => $v) {
  443. $profit = $v['profit'] - $v['amount'];
  444. // $text .= $v['issue_no']." ".$v['keywords']." ".$v['amount']." ".$v['profit']."\n";
  445. $item = $v['issue_no'] . "==" . $v['keywords'] . rtrim(rtrim(number_format($v['amount'], 2, '.', ''), '0'), '.') . "==" . rtrim(rtrim(number_format($profit, 2, '.', ''), '0'), '.') . "\n";
  446. $text .= $item;
  447. }
  448. // $text .= "```\n";
  449. return $text;
  450. }
  451. /**
  452. * @description: 投注记录
  453. * @param {*} $memberId
  454. * @param {*} $page
  455. * @param {*} $limit
  456. * @return {*}
  457. */
  458. public static function record($memberId, $messageId = null, $page = 1, $limit = 5)
  459. {
  460. $type = Cache::get('message_id_bet_record_' . $memberId, 0);
  461. if ($type == 0) {
  462. $type = '';
  463. }
  464. $msg['chat_id'] = $memberId;
  465. $list = self::model()::where('member_id', $memberId)->whereIn('status', [self::model()::STATUS_STAY, self::model()::STATUS_SETTLED])->where(self::getWhere(['is_winner' => $type]))->orderBy('id', 'desc')->forPage($page, $limit)->get();
  466. $count = self::model()::where('member_id', $memberId)->whereIn('status', [self::model()::STATUS_STAY, self::model()::STATUS_SETTLED])->where(self::getWhere(['is_winner' => $type]))->count();
  467. $keyboard = [];
  468. $total_amount = BalanceLogService::model()::where('member_id', $memberId)->where('change_type', '中奖')->sum('amount');
  469. $total_amount = number_format($total_amount, 2);
  470. $text = "历史注单 \n";
  471. $text .= "中奖总派彩:{$total_amount} \n";
  472. foreach ($list as $k => $v) {
  473. if ($v->status == self::model()::STATUS_SETTLED) {
  474. $phase = $v->profit - $v->amount;
  475. } else {
  476. $phase = '待开奖';
  477. }
  478. $text .= "-------------------------------------\n";
  479. $text .= "期数:{$v->issue_no} \n";
  480. $text .= "内容:{$v->keywords} \n";
  481. $text .= "金额:{$v->amount} \n";
  482. $text .= "盈亏:{$phase} \n";
  483. }
  484. $msg['text'] = $text;
  485. $keyboard[] = [
  486. ['text' => "全部", 'callback_data' => "betRecordType@@0"],
  487. ['text' => "盈利", 'callback_data' => "betRecordType@@1"],
  488. ['text' => "亏损", 'callback_data' => "betRecordType@@2"]
  489. ];
  490. if ($page > 1) {
  491. $keyboard[] = [
  492. ['text' => "👆上一页", 'callback_data' => "betRecordNextPage@@" . ($page - 1)]
  493. ];
  494. }
  495. $allPage = ceil($count / $limit);
  496. if ($allPage > $page) {
  497. if ($page > 1) {
  498. $keyboard[count($keyboard) - 1][] = ['text' => "👇下一页", 'callback_data' => "betRecordNextPage@@" . ($page + 1)];
  499. } else {
  500. $keyboard[] = [
  501. ['text' => "👇下一页", 'callback_data' => "betRecordNextPage@@" . ($page + 1)]
  502. ];
  503. }
  504. }
  505. if ($messageId) {
  506. $msg['message_id'] = $messageId;
  507. }
  508. if ($keyboard) {
  509. $msg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
  510. }
  511. return $msg;
  512. }
  513. /**
  514. * @description: 中奖结算
  515. * @param {*} $issue_no
  516. * @param {*} $awards
  517. * @return {*}
  518. */
  519. public static function betSettled($issue_no, $awards)
  520. {
  521. $list = self::findAll(['issue_no' => $issue_no, 'status' => self::model()::STATUS_STAY]);
  522. // 大小单双的
  523. $otherSum = self::model()::where('issue_no',$issue_no)->where('status',self::model()::STATUS_STAY)->whereIn('keywords',['大','小','单','双'])->sum('amount');
  524. $fakeOpenData = self::fakeLotteryDraw($issue_no, $awards, 0);
  525. $keywordsList = $fakeOpenData['keywordsList'];
  526. $fakeOtherSum = $fakeOpenData['sum'];
  527. $sum = $otherSum + $fakeOtherSum;
  528. $data = [];
  529. $text = $issue_no . "期开奖结果 \n";
  530. $text .= "-----本期开奖账单----- \n";
  531. $text .= "\n";
  532. // $text .=" 中奖类型 用户 投注金额 中奖金额 盈亏 \n";
  533. $betNoticeNum = Config::where('field', 'bet_notice_num')->first()->val;
  534. $betNoticeNum = explode(',', $betNoticeNum);
  535. $betNoticeMini = $betNoticeNum[0] ?? 26;
  536. $betNoticeMax = $betNoticeNum[1] ?? 38;
  537. $noticeNum = rand($betNoticeMini, $betNoticeMax);
  538. $realNoticeNum = ceil($noticeNum / 2);
  539. $openList = [];
  540. $memberList = [];
  541. $bet_num = 0;
  542. foreach ($list->toArray() as $k => $v) {
  543. if(isset($keywordsList[$v['keywords']])){
  544. $keywordsList[$v['keywords']] += $v['amount'];
  545. }else{
  546. $keywordsList[$v['keywords']] = $v['amount'];
  547. }
  548. // $userInfo = UserService::findAll(['member_id' => $v['member_id']]);
  549. // $lastStr = self::getLastChar($userInfo->first_name, 1);
  550. $lastStr = self::hideMiddleDigits($v['member_id'], 4);
  551. $item = [];
  552. $item['id'] = $v['id'];
  553. $item['status'] = self::model()::STATUS_SETTLED;
  554. if (in_array($v['keywords'], $awards)) {
  555. // $profit = $v['amount'] * $v['odds'];
  556. $amount = $v['amount'];
  557. // $amount = rtrim($amount, '0'); // 去掉右侧的 0
  558. // $amount = rtrim($amount, '.'); // 如果末尾是 . 就去掉
  559. $odds = $v['odds'];
  560. if(in_array('13操',$awards) || in_array('14操', $awards)){
  561. // 13 14特殊处理倍率
  562. if(in_array($v['keywords'],self::$OTHER_BET_1)){
  563. if($sum < 10000){
  564. $odds = 1.5;
  565. }else{
  566. $odds = 1;
  567. }
  568. }
  569. if(in_array($v['keywords'],self::$OTHER_BET_2)){
  570. $odds = 1;
  571. }
  572. }
  573. $profit = bcmul($amount, $odds, 2); // 保留两位小数
  574. if ($profit > 880000) {
  575. $profit = 880000; // 单注最高奖金880000
  576. }
  577. $item['profit'] = $profit;
  578. // $yl = $profit - $amount;
  579. $yl = bcsub($profit, $amount, 2); // 盈利
  580. if (!in_array('13操', $awards) && !in_array('14操', $awards)) {
  581. Rebate::updateProfit([
  582. 'member_id' => $v['member_id'],
  583. 'profit' => $yl,
  584. ]);
  585. }
  586. $memberList[$v['member_id']][] = [
  587. 'member_id' => $v['member_id'],
  588. 'keywords' => $v['keywords'],
  589. 'amount' => $v['amount'],
  590. 'profit' => $profit,
  591. 'yl' => $yl,
  592. ];
  593. // if ($k + 1 <= $realNoticeNum) {
  594. // // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$profit} {$yl}\n";
  595. // $bet_num++;
  596. // }
  597. // 结算
  598. WalletService::updateBalance($v['member_id'], $profit);
  599. $walletInfo = WalletService::findOne(['member_id' => $v['member_id']]);
  600. $balance = $walletInfo['available_balance'];
  601. BalanceLogService::addLog($v['member_id'], $profit, $balance, ($balance + $profit), '中奖', $v['id'], '');
  602. if (isset($openList[$v['member_id']])) {
  603. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  604. $openList[$v['member_id']]['amount'] += $v['amount'];
  605. $openList[$v['member_id']]['profit'] += $profit;
  606. $openList[$v['member_id']]['lastStr'] = $lastStr;
  607. $openList[$v['member_id']]['openKeywords'][] = $v['keywords'];
  608. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  609. $openList[$v['member_id']]['win_amount'] += $v['amount'];
  610. } else {
  611. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  612. $openList[$v['member_id']]['amount'] = $v['amount'];
  613. $openList[$v['member_id']]['profit'] = $profit;
  614. $openList[$v['member_id']]['lastStr'] = $lastStr;
  615. $openList[$v['member_id']]['openKeywords'] = [];
  616. $openList[$v['member_id']]['keywords'] = [];
  617. $openList[$v['member_id']]['openKeywords'][] = $v['keywords'];
  618. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  619. $openList[$v['member_id']]['win_amount'] = $v['amount'];
  620. $openList[$v['member_id']]['is_send'] = true;
  621. }
  622. } else {
  623. if (!in_array('13操', $awards) && !in_array('14操', $awards)) {
  624. Rebate::updateProfit([
  625. 'member_id' => $v['member_id'],
  626. 'profit' => ($v['amount'] * -1),
  627. ]);
  628. }
  629. if (isset($openList[$v['member_id']])) {
  630. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  631. $openList[$v['member_id']]['amount'] += $v['amount'];
  632. $openList[$v['member_id']]['lastStr'] = $lastStr;
  633. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  634. } else {
  635. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  636. $openList[$v['member_id']]['amount'] = $v['amount'];
  637. $openList[$v['member_id']]['profit'] = 0;
  638. $openList[$v['member_id']]['lastStr'] = $lastStr;
  639. $openList[$v['member_id']]['openKeywords'] = [];
  640. $openList[$v['member_id']]['keywords'] = [];
  641. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  642. $openList[$v['member_id']]['win_amount'] = 0;
  643. $openList[$v['member_id']]['is_send'] = true;
  644. }
  645. // if ($k + 1 <= $realNoticeNum) {
  646. // // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$v['profit']} -{$v['amount']}\n";
  647. // $bet_num++;
  648. // }
  649. // $memberList[$v['member_id']][] = [
  650. // 'member_id' => $v['member_id'],
  651. // 'amount' => $v['amount'],
  652. // 'keywords' => $v['keywords'],
  653. // 'profit' => 0,
  654. // 'yl' => '-'.$v['amount'],
  655. // ];
  656. }
  657. self::model()::where('id', $v['id'])->update($item);
  658. }
  659. // foreach($openList as $k => $v){
  660. // $amount = $v['amount'];
  661. // // if($v['profit'] >= 0){
  662. // $profit = number_format($v['profit'],2);
  663. // $yl = bcsub($v['profit'], $v['amount'], 2); // 盈利
  664. // // $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} {$profit} {$yl}\n";
  665. // if(++$bet_num <= $realNoticeNum){
  666. // if(empty($v['openKeywords'])){
  667. // $openKeyword = '-';
  668. // }else{
  669. // $openKeyword = implode(',', $v['openKeywords']);
  670. // }
  671. // $text .= "用户ID:{$v['lastStr']} \n";
  672. // $text .= "下注类型:[".implode(',', $v['keywords'])."] \n";
  673. // $text .= "中奖类型:[".$openKeyword."] \n";
  674. // $text .= "投注金额:{$amount} \n";
  675. // $text .= "中奖金额:{$v['win_amount']} \n";
  676. // $text .= "派彩金额:{$profit} \n";
  677. // $text .= "盈亏金额:{$yl} \n";
  678. // $text .= "-------------------------------- \n";
  679. // }
  680. // $text2 = "{$issue_no}期开奖结果 \n";
  681. // $text2 .= "下注类型:[".implode(',', $v['keywords'])."] \n";
  682. // $text2 .= "中奖类型:[".$openKeyword."] \n";
  683. // $text2 .= "投注金额:{$amount} \n";
  684. // $text2 .= "中奖金额:{$v['win_amount']} \n";
  685. // $text2 .= "派彩金额:{$profit} \n";
  686. // $text2 .= "盈亏金额:{$yl} \n";
  687. // $keyboard = [];
  688. // $keyboard[] = [
  689. // ['text' => "开奖历史", 'callback_data' => "showLotteryHistory@@" . $issue_no]
  690. // ];
  691. // SendTelegramMessageJob::dispatch($v['member_id'],$text2,$keyboard);
  692. // // self::sendMessage($v['member_id'],$text2);
  693. // // }else{
  694. // // $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} 0 -{$amount}\n";
  695. // // }
  696. // }
  697. $inlineButton = self::getOperateButton();
  698. $rand_num = $noticeNum - $bet_num;
  699. $openList = array_merge($openList, $fakeOpenData['list']);
  700. // 群通知
  701. // self::bettingGroupNotice($text, $inlineButton, '');
  702. // SendTelegramGroupMessageJob::dispatch($text,$inlineButton,'');
  703. self::lotteryNotice($openList, $issue_no ,$keywordsList);
  704. }
  705. /**
  706. * @description: 中奖结算
  707. * @param {*} $issue_no
  708. * @param {*} $awards
  709. * @return {*}
  710. */
  711. public static function betSettled2($issue_no, $awards)
  712. {
  713. $list = self::findAll(['issue_no' => $issue_no, 'status' => self::model()::STATUS_STAY]);
  714. $data = [];
  715. $text = $issue_no . "期开奖结果 \n";
  716. $text .= "-----本期开奖账单----- \n";
  717. // $text .=" 中奖类型 用户 投注金额 中奖金额 盈亏 \n";
  718. $text .= "\n";
  719. $betNoticeNum = Config::where('field', 'bet_notice_num')->first()->val;
  720. $betNoticeNum = explode(',', $betNoticeNum);
  721. $betNoticeMini = $betNoticeNum[0] ?? 26;
  722. $betNoticeMax = $betNoticeNum[1] ?? 38;
  723. $noticeNum = rand($betNoticeMini, $betNoticeMax);
  724. $realNoticeNum = ceil($noticeNum / 2);
  725. $openList = [];
  726. $bet_num = 0;
  727. foreach ($list->toArray() as $k => $v) {
  728. // $userInfo = UserService::findAll(['member_id' => $v['member_id']]);
  729. // $lastStr = self::getLastChar($userInfo->first_name, 1);
  730. $lastStr = self::hideMiddleDigits($v['member_id'], 4);
  731. $item = [];
  732. $item['id'] = $v['id'];
  733. $item['status'] = self::model()::STATUS_SETTLED;
  734. if (in_array($v['keywords'], $awards)) {
  735. // $profit = $v['amount'] * $v['odds'];
  736. $amount = $v['amount'];
  737. // $amount = rtrim($amount, '0'); // 去掉右侧的 0
  738. // $amount = rtrim($amount, '.'); // 如果末尾是 . 就去掉
  739. $odds = $v['odds'];
  740. $profit = bcmul($amount, $odds, 2); // 保留两位小数
  741. if ($profit > 880000) {
  742. $profit = 880000; // 单注最高奖金880000
  743. }
  744. $item['profit'] = $profit;
  745. // $yl = $profit - $amount;
  746. $yl = bcsub($profit, $amount, 2); // 盈利
  747. // if ($k + 1 <= $realNoticeNum) {
  748. // // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$profit} {$yl}\n";
  749. // $bet_num++;
  750. // }
  751. // 结算
  752. // WalletService::updateBalance($v['member_id'], $profit);
  753. // $walletInfo = WalletService::findOne(['member_id' => $v['member_id']]);
  754. // $balance = $walletInfo['available_balance'];
  755. // BalanceLogService::addLog($v['member_id'], $profit, $balance, ($balance + $profit), '中奖', $v['id'], '');
  756. if (isset($openList[$v['member_id']])) {
  757. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  758. $openList[$v['member_id']]['amount'] += $v['amount'];
  759. $openList[$v['member_id']]['profit'] += $profit;
  760. $openList[$v['member_id']]['lastStr'] = $lastStr;
  761. $openList[$v['member_id']]['openKeywords'][] = $v['keywords'];
  762. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  763. $openList[$v['member_id']]['win_amount'] += $v['amount'];
  764. } else {
  765. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  766. $openList[$v['member_id']]['amount'] = $v['amount'];
  767. $openList[$v['member_id']]['profit'] = $profit;
  768. $openList[$v['member_id']]['lastStr'] = $lastStr;
  769. $openList[$v['member_id']]['openKeywords'] = [];
  770. $openList[$v['member_id']]['keywords'] = [];
  771. $openList[$v['member_id']]['openKeywords'][] = $v['keywords'];
  772. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  773. $openList[$v['member_id']]['win_amount'] = $v['amount'];
  774. $openList[$v['member_id']]['is_send'] = true;
  775. }
  776. } else {
  777. if (isset($openList[$v['member_id']])) {
  778. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  779. $openList[$v['member_id']]['amount'] += $v['amount'];
  780. $openList[$v['member_id']]['lastStr'] = $lastStr;
  781. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  782. } else {
  783. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  784. $openList[$v['member_id']]['amount'] = $v['amount'];
  785. $openList[$v['member_id']]['profit'] = 0;
  786. $openList[$v['member_id']]['lastStr'] = $lastStr;
  787. $openList[$v['member_id']]['openKeywords'] = [];
  788. $openList[$v['member_id']]['keywords'] = [];
  789. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  790. $openList[$v['member_id']]['win_amount'] = 0;
  791. $openList[$v['member_id']]['is_send'] = true;
  792. }
  793. // if ($k + 1 <= $realNoticeNum) {
  794. // // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$v['profit']} -{$v['amount']}\n";
  795. // $bet_num++;
  796. // }
  797. }
  798. // self::model()::where('id', $v['id'])->update($item);
  799. }
  800. // foreach($openList as $k => $v){
  801. // $amount = $v['amount'];
  802. // // if($v['profit'] >= 0){
  803. // $profit = number_format($v['profit'],2);
  804. // $yl = bcsub($v['profit'], $v['amount'], 2); // 盈利
  805. // // $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} {$profit} {$yl}\n";
  806. // if(++$bet_num <= $realNoticeNum){
  807. // $text .= "用户ID:{$v['lastStr']} \n";
  808. // $text .= "下注类型:[".implode(',', $v['keywords'])."] \n";
  809. // $text .= "中奖类型:[".implode(',', $v['openKeywords'])."] \n";
  810. // $text .= "投注金额:{$amount} \n";
  811. // $text .= "中奖金额:{$v['win_amount']} \n";
  812. // $text .= "派彩金额:{$profit} \n";
  813. // $text .= "盈亏金额:{$yl} \n";
  814. // $text .= "-------------------------------- \n";
  815. // }
  816. // $text2 = "{$issue_no}期开奖结果 \n";
  817. // $text2 .= "下注类型:[".implode(',', $v['keywords'])."] \n";
  818. // $text2 .= "中奖类型:[".implode(',', $v['openKeywords'])."] \n";
  819. // $text2 .= "投注金额:{$amount} \n";
  820. // $text2 .= "中奖金额:{$v['win_amount']} \n";
  821. // $text2 .= "派彩金额:{$profit} \n";
  822. // $text2 .= "盈亏金额:{$yl} \n";
  823. // $keyboard = [];
  824. // $keyboard[] = [
  825. // ['text' => "开奖历史", 'callback_data' => "showLotteryHistory@@" . $issue_no]
  826. // ];
  827. // // SendTelegramMessageJob::dispatch($v['member_id'],$text2);
  828. // self::sendMessage($v['member_id'],$text2,$keyboard);
  829. // // }else{
  830. // // $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} 0 -{$amount}\n";
  831. // // }
  832. // }
  833. $inlineButton = self::getOperateButton();
  834. $rand_num = $noticeNum - $bet_num;
  835. $fakeOpenData = self::fakeLotteryDraw($issue_no, $awards, $rand_num);
  836. $openList = array_merge($openList, $fakeOpenData['list']);
  837. // 群通知
  838. // self::bettingGroupNotice($text, $inlineButton, '');
  839. // SendTelegramGroupMessageJob::dispatch($text,$inlineButton,'');
  840. self::lotteryNotice($openList, $issue_no);
  841. }
  842. // 虚拟开奖
  843. public static function fakeLotteryDraw($issue_no, $awards, $rand_num = 30)
  844. {
  845. $fake_bet_list = Cache::get('fake_bet_' . $issue_no, []);
  846. $text = "";
  847. $keywordsList = [];
  848. $fakeOtherSum = 0;
  849. $openList = [];
  850. foreach ($fake_bet_list as $k => $v) {
  851. if(in_array($v['keywords'],['大','小','单','双'])){
  852. $fakeOtherSum += $v['amount'];
  853. }
  854. if(isset($keywordsList[$v['keywords']])){
  855. $keywordsList[$v['keywords']] += $v['amount'];
  856. }else{
  857. $keywordsList[$v['keywords']] = $v['amount'];
  858. }
  859. // $lastStr = self::getLastChar($v['first_name'], 1);
  860. $lastStr = self::hideMiddleDigits($v['member_id'], 4);
  861. if (in_array($v['keywords'], $awards)) {
  862. $amount = $v['amount'];
  863. $odds = $v['odds'];
  864. $profit = bcmul($amount, $odds, 2); // 保留两位小数
  865. if ($profit > 880000) {
  866. $profit = 880000; // 单注最高奖金880000
  867. }
  868. $item['profit'] = $profit;
  869. // $v['amount'] = number_format($amount,2);
  870. if (isset($openList[$v['member_id']])) {
  871. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  872. $openList[$v['member_id']]['amount'] += $v['amount'];
  873. $openList[$v['member_id']]['profit'] += $profit;
  874. $openList[$v['member_id']]['lastStr'] = $lastStr;
  875. $openList[$v['member_id']]['openKeywords'][] = $v['keywords'];
  876. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  877. $openList[$v['member_id']]['win_amount'] += $v['amount'];
  878. } else {
  879. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  880. $openList[$v['member_id']]['amount'] = $v['amount'];
  881. $openList[$v['member_id']]['profit'] = $profit;
  882. $openList[$v['member_id']]['lastStr'] = $lastStr;
  883. $openList[$v['member_id']]['openKeywords'] = [];
  884. $openList[$v['member_id']]['keywords'] = [];
  885. $openList[$v['member_id']]['openKeywords'][] = $v['keywords'];
  886. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  887. $openList[$v['member_id']]['win_amount'] = $v['amount'];
  888. $openList[$v['member_id']]['is_send'] = false;
  889. }
  890. } else {
  891. if (isset($openList[$v['member_id']])) {
  892. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  893. $openList[$v['member_id']]['amount'] += $v['amount'];
  894. $openList[$v['member_id']]['lastStr'] = $lastStr;
  895. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  896. } else {
  897. $openList[$v['member_id']]['member_id'] = $v['member_id'];
  898. $openList[$v['member_id']]['amount'] = $v['amount'];
  899. $openList[$v['member_id']]['profit'] = 0;
  900. $openList[$v['member_id']]['lastStr'] = $lastStr;
  901. $openList[$v['member_id']]['openKeywords'] = [];
  902. $openList[$v['member_id']]['keywords'] = [];
  903. $openList[$v['member_id']]['keywords'][] = $v['keywords'];
  904. $openList[$v['member_id']]['win_amount'] = 0;
  905. $openList[$v['member_id']]['is_send'] = false;
  906. }
  907. }
  908. }
  909. return ['sum' => $fakeOtherSum ,'list' => $openList ,'keywordsList' => $keywordsList];
  910. }
  911. // 开奖通知
  912. public static function lotteryNotice($openList, $issue_no,$keywordsList = [])
  913. {
  914. $betNoticeNum = Config::where('field', 'bet_notice_num')->first()->val;
  915. $betNoticeNum = explode(',', $betNoticeNum);
  916. $betNoticeMini = $betNoticeNum[0] ?? 26;
  917. $betNoticeMax = $betNoticeNum[1] ?? 38;
  918. $noticeNum = rand($betNoticeMini, $betNoticeMax);
  919. shuffle($openList);
  920. $text = $issue_no . "期开奖结果 \n";
  921. $text .= "-----本期开奖账单----- \n";
  922. foreach ($openList as $k => $v) {
  923. $amount = number_format($v['amount'], 2);
  924. $v['win_amount'] = number_format($v['win_amount'], 2);
  925. $profit = number_format($v['profit'], 2);
  926. $yl = bcsub($v['profit'], $v['amount'], 2); // 盈利
  927. if (empty($v['openKeywords'])) {
  928. $openKeyword = '-';
  929. } else {
  930. $openKeyword = implode(',', $v['openKeywords']);
  931. }
  932. if (($k + 1) <= $noticeNum) {
  933. $text .= "用户ID:{$v['lastStr']} \n";
  934. $text .= "下注类型:[" . implode(',', $v['keywords']) . "] \n";
  935. $text .= "中奖类型:[" . $openKeyword . "] \n";
  936. $text .= "投注金额:{$amount} \n";
  937. $text .= "中奖金额:{$v['win_amount']} \n";
  938. $text .= "派彩金额:{$profit} \n";
  939. $text .= "盈亏金额:{$yl} \n";
  940. $text .= "-------------------------------- \n";
  941. }
  942. if ($v['is_send']) {
  943. $text2 = "{$issue_no}期开奖结果 \n";
  944. $text2 .= "下注类型:[" . implode(',', $v['keywords']) . "] \n";
  945. $text2 .= "中奖类型:[" . $openKeyword . "] \n";
  946. $text2 .= "投注金额:{$amount} \n";
  947. $text2 .= "中奖金额:{$v['win_amount']} \n";
  948. $text2 .= "派彩金额:{$profit} \n";
  949. $text2 .= "盈亏金额:{$yl} \n";
  950. $keyboard = [];
  951. $keyboard[] = [
  952. ['text' => "开奖历史", 'callback_data' => "showLotteryHistory@@" . $issue_no]
  953. ];
  954. // self::sendMessage($v['member_id'],$text2,$keyboard);
  955. SendTelegramMessageJob::dispatch($v['member_id'], $text2, $keyboard);
  956. }
  957. }
  958. $inlineButton = self::getOperateButton();
  959. // 群通知
  960. // self::bettingGroupNotice($text, $inlineButton, '');
  961. $text3 = "📝 {$issue_no}期投注统计 \n";
  962. if($keywordsList){
  963. ksort($keywordsList);
  964. foreach($keywordsList as $k => $v){
  965. $text3 .= "玩法:{$k} \n";
  966. $text3 .= "总注:{$v} \n";
  967. $text3 .= "-------------- \n";
  968. }
  969. }
  970. SendTelegramGroupMessageJob::dispatch($text3, $inlineButton, '');
  971. SendTelegramGroupMessageJob::dispatch($text, $inlineButton, '');
  972. }
  973. public static function todayExchangeRate($chatId)
  974. {
  975. $exchangeRate = Config::where('field', 'exchange_rate_rmb')->first()->val;
  976. $text = "今日汇率:1USDT = {$exchangeRate} RMB \n";
  977. // $botMsg = [
  978. // 'chat_id' => "@{$chatId}",
  979. // 'text' => $text
  980. // ];
  981. self::sendMessage($chatId, $text);
  982. // return $botMsg;
  983. }
  984. }