BetService.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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. /**
  19. * 投注
  20. */
  21. class BetService extends BaseService
  22. {
  23. /**
  24. * @description: 模型
  25. * @return {string}
  26. */
  27. public static function model(): string
  28. {
  29. return Bet::class;
  30. }
  31. /**
  32. * @description: 枚举
  33. * @return {*}
  34. */
  35. public static function enum(): string
  36. {
  37. return '';
  38. }
  39. /**
  40. * @description: 获取查询条件
  41. * @param {array} $search 查询内容
  42. * @return {array}
  43. */
  44. public static function getWhere(array $search = []): array
  45. {
  46. $where = [];
  47. if (isset($search['issue_no']) && !empty($search['issue_no'])) {
  48. $where[] = ['issue_no', '=', $search['issue_no']];
  49. }
  50. if (isset($search['member_id']) && !empty($search['member_id'])) {
  51. $where[] = ['member_id', '=', $search['member_id']];
  52. }
  53. if (isset($search['keywords']) && !empty($search['keywords'])) {
  54. $where[] = ['keywords', '=', $search['keywords']];
  55. }
  56. if (isset($search['issue_id']) && !empty($search['issue_id'])) {
  57. $where[] = ['issue_id', '=', $search['issue_id']];
  58. }
  59. if (isset($search['id']) && !empty($search['id'])) {
  60. $where[] = ['id', '=', $search['id']];
  61. }
  62. if (isset($search['user_id']) && !empty($search['user_id'])) {
  63. $where[] = ['user_id', '=', $search['user_id']];
  64. }
  65. if (isset($search['start_time']) && !empty($search['status'])) {
  66. $where[] = ['created_at', '>=', "{$search['start_time']} 00:00:00"];
  67. $where[] = ['created_at', '<=', "{$search['end_time']} 23:59:59"];
  68. }
  69. if (isset($search['is_winner']) && !empty($search['is_winner'])) {
  70. $where[] = ['status', '=', 2];
  71. if ($search['is_winner'] == 1) {
  72. $where[] = ['profit', '>', 0];
  73. } else {
  74. $where[] = ['profit', '<=', 0];
  75. }
  76. } else {
  77. if (isset($search['status']) && !empty($search['status'])) {
  78. $where[] = ['status', '=', $search['status']];
  79. }
  80. }
  81. return $where;
  82. }
  83. /**
  84. * @description: 查询单条数据
  85. * @param array $search
  86. * @return \App\Models\Coin|null
  87. */
  88. public static function findOne(array $search): ?Bet
  89. {
  90. return self::model()::where(self::getWhere($search))->first();
  91. }
  92. /**
  93. * @description: 查询所有数据
  94. * @param array $search
  95. * @return \Illuminate\Database\Eloquent\Collection
  96. */
  97. public static function findAll(array $search = [])
  98. {
  99. return self::model()::where(self::getWhere($search))->get();
  100. }
  101. /**
  102. * @description: 分页查询
  103. * @param array $search
  104. * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  105. */
  106. public static function paginate(array $search = [])
  107. {
  108. $limit = isset($search['limit']) ? $search['limit'] : 15;
  109. $query = self::model()::where(self::getWhere($search))
  110. ->with(['user']);
  111. if (isset($search['username']) && !empty($search['username'])) {
  112. $username = $search['username'];
  113. $query = $query->whereHas('user', function ($query) use ($username) {
  114. $query->where('username', $username);
  115. });
  116. }
  117. $paginator = $query->paginate($limit);
  118. return ['total' => $paginator->total(), 'data' => $paginator->items()];
  119. }
  120. /**
  121. * @description: 投注操作
  122. * @param {string} $memberId
  123. * @param {string} $input
  124. * @return {*}
  125. */
  126. public static function bet(string $memberId, string $input, $messageId = 0)
  127. {
  128. $msg = [];
  129. $msg['chat_id'] = $memberId;
  130. // 钱包生成
  131. // $walletInfo = WalletService::getUserWallet($memberId);
  132. // 分解投注的内容
  133. $betResult = GameplayRuleService::bettingRuleVerify($input);
  134. $serviceAccount = Config::where('field', 'service_account')->first()->val;
  135. if ($betResult == null) {
  136. $text = "消息格式错误!\n";
  137. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  138. $msg['text'] = $text;
  139. if ($messageId) {
  140. $msg['reply_to_message_id'] = $messageId;
  141. }
  142. return $msg;
  143. }
  144. $keywords = $betResult['rule']; // 玩法
  145. $amount = $betResult['amount']; // 投注金额
  146. $gameplayRuleInfo = GameplayRuleService::getGameplayRules($keywords);
  147. if ($gameplayRuleInfo == null) {
  148. $text = "玩法未配置!\n";
  149. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  150. $msg['text'] = $text;
  151. if ($messageId) {
  152. $msg['reply_to_message_id'] = $messageId;
  153. }
  154. return $msg;
  155. }
  156. if ($gameplayRuleInfo['odds'] <= 0) {
  157. $text = "赔率为0 庄家通吃 禁止投注!\n";
  158. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  159. $msg['text'] = $text;
  160. if ($messageId) {
  161. $msg['reply_to_message_id'] = $messageId;
  162. }
  163. return $msg;
  164. }
  165. // 期数验证
  166. $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
  167. if (empty($issueInfo)) {
  168. $issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
  169. if (empty($issueCloseInfo)) {
  170. $text = "暂无可下注期数,本次下注无效!\n";
  171. $msg['text'] = $text;
  172. if ($messageId) {
  173. $msg['reply_to_message_id'] = $messageId;
  174. }
  175. return $msg;
  176. } else {
  177. $text = "封盘中,本次下注无效!\n";
  178. $msg['text'] = $text;
  179. if ($messageId) {
  180. $msg['reply_to_message_id'] = $messageId;
  181. }
  182. return $msg;
  183. }
  184. }
  185. if (!is_numeric($amount) || $amount <= 0) {
  186. $text = "投注金额格式不正确!\n";
  187. $text .= "任何疑问都可以联系唯一财务:@{$serviceAccount}";
  188. $msg['text'] = $text;
  189. if ($messageId) {
  190. $msg['reply_to_message_id'] = $messageId;
  191. }
  192. return $msg;
  193. }
  194. $now_date = date('Y-m-d H:i:s',time() + 30); // 提前30秒
  195. if($issueInfo['end_time'] < $now_date){
  196. $text = "封盘中,本次下注无效!\n";
  197. $msg['text'] = $text;
  198. if ($messageId) {
  199. $msg['reply_to_message_id'] = $messageId;
  200. }
  201. return $msg;
  202. }
  203. // 投注限制校验
  204. if ($amount < $gameplayRuleInfo['mininum']) {
  205. $text = "下注失败,最小金额限制{$gameplayRuleInfo['mininum']}\n";
  206. $msg['text'] = $text;
  207. if ($messageId) {
  208. $msg['reply_to_message_id'] = $messageId;
  209. }
  210. return $msg;
  211. }
  212. // 投注限制校验
  213. if ($amount > $gameplayRuleInfo['maxinum']) {
  214. $text = "下注失败,最大金额限制{$gameplayRuleInfo['maxinum']}\n";
  215. $msg['text'] = $text;
  216. if ($messageId) {
  217. $msg['reply_to_message_id'] = $messageId;
  218. }
  219. return $msg;
  220. }
  221. // 获取用户余额
  222. $walletInfo = WalletService::findOne(['member_id' => $memberId]);
  223. $balance = $walletInfo['available_balance'];
  224. // 余额计算
  225. if ($balance < $amount) {
  226. $text = "余额不足,本次下注无效!\n";
  227. $msg['text'] = $text;
  228. if ($messageId) {
  229. $msg['reply_to_message_id'] = $messageId;
  230. }
  231. return $msg;
  232. }
  233. $userInfo = UserService::findOne(['member_id' => $memberId]);
  234. $betInfo = self::findOne(['member_id' => $memberId, 'issue_no' => $issueInfo->issue_no, 'keywords' => $keywords]); // 相同下注
  235. if ($betInfo) {
  236. $betInfo->amount = $betInfo->amount + $amount;
  237. $bet_id = $betInfo->id;
  238. $betInfo->save();
  239. } else {
  240. $data = [];
  241. $data['amount'] = $amount; // 分数
  242. $data['keywords'] = $keywords; // 玩法
  243. $data['member_id'] = $memberId;
  244. $data['user_id'] = $userInfo->id;
  245. $data['issue_no'] = $issueInfo->issue_no;
  246. $data['issue_id'] = $issueInfo->id;
  247. $data['odds'] = $gameplayRuleInfo['odds'];
  248. $newBet = self::model()::create($data);
  249. $bet_id = $newBet->id;
  250. }
  251. WalletService::updateBalance($memberId, -$amount);
  252. BalanceLogService::addLog($memberId, -$amount, $balance, ($balance - $amount), '投注', $bet_id, '');
  253. $now = Carbon::now('America/New_York')->format('Y-m-d');
  254. $rebate = Config::where('field', 'rebate')->first()->val;
  255. Rebate::addOrUpdate([
  256. 'date' => $now,
  257. 'member_id' => $memberId,
  258. 'betting_amount' => $amount,
  259. 'rebate_ratio' => $rebate,
  260. 'first_name' => $userInfo->first_name,
  261. 'username' => $userInfo->username,
  262. ]);
  263. // // 返利
  264. // $rebate = Config::where('field', 'rebate')->first()->val;
  265. // if($rebate > 0){
  266. // $rebateAmount = bcmul($amount, $rebate, 2); // 返利金额
  267. // if($rebateAmount > 0){
  268. // WalletService::updateBalance($memberId,$rebateAmount);
  269. // $walletInfo = WalletService::findOne(['member_id' => $memberId]);
  270. // $balance = $walletInfo['available_balance'];
  271. // BalanceLogService::addLog($memberId,$rebateAmount,$balance,($balance+$rebateAmount),'返水',$bet_id,'');
  272. // }
  273. // }
  274. $text = "下注期数:{$issueInfo->issue_no}\n";
  275. $text .= "下注内容\n";
  276. $text .= "--------\n";
  277. $text .= "{$input}\n";
  278. $text .= "--------\n";
  279. $text .= "下注成功\n";
  280. $msg['text'] = $text;
  281. // $lastStr = self::getLastChar($userInfo->first_name, 1);
  282. $lastStr = self::hideMiddleDigits($userInfo->member_id, 4);
  283. $groupText = "";
  284. $groupText .= "私聊下注 【" . $lastStr . "】 \n";
  285. $groupText .= "下注期数:{$issueInfo->issue_no} \n";
  286. $groupText .= "下注内容: \n";
  287. $groupText .= "----------- \n";
  288. $groupText .= "{$input} \n";
  289. $groupText .= "----------- \n";
  290. $inlineButton = self::getOperateButton();
  291. // 群通知
  292. self::bettingGroupNotice($groupText, $inlineButton); // 群通知
  293. return $msg;
  294. }
  295. // 模拟下注
  296. public static function fakeBet()
  297. {
  298. $betFake = Config::where('field', 'bet_fake')->first()->val;
  299. if ($betFake) {
  300. // 期数验证
  301. $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
  302. if ($issueInfo) {
  303. $betFakeRandAmount = Config::where('field', 'bet_fake_rand_amount')->first()->val;
  304. $betFakeRandAmount = explode(',', $betFakeRandAmount);
  305. $betMini = $betFakeRandAmount[0]??10;
  306. $betMax = $betFakeRandAmount[1]??10000;
  307. $now_date = date('Y-m-d H:i:s',time() + 30); // 提前30秒
  308. if($issueInfo['end_time'] > $now_date){
  309. $fake_bet_list = Cache::get('fake_bet_' . $issueInfo->issue_no, []);
  310. $gameplayRuleList = GameplayRuleService::model()::where('odds', '>', 0)->get();
  311. $gameplayRuleList = $gameplayRuleList->toArray();
  312. $randKey = array_rand($gameplayRuleList, 1);
  313. $gameplayRuleInfo = $gameplayRuleList[$randKey] ?? [];
  314. if ($gameplayRuleInfo) {
  315. $amount = rand($betMini, $betMax);
  316. $item = [];
  317. $item['keywords'] = $gameplayRuleInfo['keywords'];
  318. $item['odds'] = $gameplayRuleInfo['odds'];
  319. $item['amount'] = $amount;
  320. $item['first_name'] = self::generateRandomString(6);
  321. $item['member_id'] = self::generateRandomNumber(10);
  322. $item['profit'] = 0;
  323. $input = $item['keywords'] . $item['amount'];
  324. $fake_bet_list[] = $item;
  325. $lastStr = self::hideMiddleDigits($item['member_id'], 4);
  326. $groupText = "";
  327. $groupText .= "私聊下注 【" . $lastStr . "】 \n";
  328. $groupText .= "下注期数:{$issueInfo->issue_no} \n";
  329. $groupText .= "下注内容: \n";
  330. $groupText .= "----------- \n";
  331. $groupText .= "{$input} \n";
  332. $groupText .= "----------- \n";
  333. $inlineButton = self::getOperateButton();
  334. // 群通知
  335. self::bettingGroupNotice($groupText, $inlineButton); // 群通知
  336. }
  337. Cache::put('fake_bet_' . $issueInfo->issue_no, $fake_bet_list, 500);
  338. }
  339. }
  340. }
  341. }
  342. /**
  343. * @description: 当期下注
  344. * @param {*} $memberId
  345. * @return {*}
  346. */
  347. public static function currentBet($memberId)
  348. {
  349. $msg['chat_id'] = $memberId;
  350. // 期数验证
  351. $issueInfo = IssueService::model()::where('status', IssueService::model()::STATUS_BETTING)->orderBy('id', 'desc')->first();
  352. $issue_no = '';
  353. if (!empty($issueInfo)) {
  354. $issue_no = $issueInfo->issue_no;
  355. } else {
  356. $issueCloseInfo = IssueService::model()::where('status', IssueService::model()::STATUS_CLOSE)->orderBy('id', 'desc')->first();
  357. if (empty($issueCloseInfo)) {
  358. $issue_no = $issueCloseInfo->issue_no;
  359. }
  360. }
  361. if ($issue_no) {
  362. $text = "当前期号:{$issue_no} \n";
  363. $text .= "\n";
  364. $text .= "----------\n";
  365. $list = self::findAll(['member_id' => $memberId, 'issue_no' => $issue_no]);
  366. foreach ($list->toArray() as $k => $v) {
  367. $text .= "{$v['keywords']}{$v['amount']} \n";
  368. }
  369. $text .= "\n";
  370. $text .= "----------\n";
  371. $msg['text'] = $text;
  372. } else {
  373. $msg['text'] = "当前没有开放的投注期数! \n";
  374. }
  375. return $msg;
  376. }
  377. /**
  378. * @description: 近期投注
  379. * @param {*} $memberId
  380. * @return {*}
  381. */
  382. public static function recentlyRecord($memberId, $page = 1, $limit = 5)
  383. {
  384. $list = self::model()::where('member_id', $memberId)->whereIn('status', [self::model()::STATUS_STAY, self::model()::STATUS_SETTLED])->orderBy('id', 'desc')->forPage($page, $limit)->get();
  385. // $text = "```\n";
  386. $text = "";
  387. $text .= "期数--内容--盈亏 \n";
  388. foreach ($list->toArray() as $k => $v) {
  389. $profit = $v['profit'] - $v['amount'];
  390. // $text .= $v['issue_no']." ".$v['keywords']." ".$v['amount']." ".$v['profit']."\n";
  391. $item = $v['issue_no'] . "==" . $v['keywords'] . rtrim(rtrim(number_format($v['amount'], 2, '.', ''), '0'), '.') . "==" . rtrim(rtrim(number_format($profit, 2, '.', ''), '0'), '.') . "\n";
  392. $text .= $item;
  393. }
  394. // $text .= "```\n";
  395. return $text;
  396. }
  397. /**
  398. * @description: 投注记录
  399. * @param {*} $memberId
  400. * @param {*} $page
  401. * @param {*} $limit
  402. * @return {*}
  403. */
  404. public static function record($memberId, $messageId = null, $page = 1, $limit = 5)
  405. {
  406. $type = Cache::get('message_id_bet_record_' . $memberId, 0);
  407. $msg['chat_id'] = $memberId;
  408. $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();
  409. $count = self::model()::where('member_id', $memberId)->whereIn('status', [self::model()::STATUS_STAY, self::model()::STATUS_SETTLED])->where(self::getWhere(['is_winner' => $type]))->count();
  410. $keyboard = [];
  411. $total_amount = BalanceLogService::model()::where('member_id', $memberId)->where('change_type', '中奖')->sum('amount');
  412. $total_amount = number_format($total_amount, 2);
  413. $text = "历史注单 \n";
  414. $text .= "中奖总金额:{$total_amount} \n";
  415. foreach ($list as $k => $v) {
  416. if ($v->status == self::model()::STATUS_SETTLED) {
  417. $phase = $v->profit - $v->amount;
  418. } else {
  419. $phase = '待开奖';
  420. }
  421. $text .= "-------------------------------------\n";
  422. $text .= "期数:{$v->issue_no} \n";
  423. $text .= "内容:{$v->keywords} \n";
  424. $text .= "金额:{$v->amount} \n";
  425. $text .= "盈亏:{$phase} \n";
  426. }
  427. $msg['text'] = $text;
  428. $keyboard[] = [
  429. ['text' => "全部", 'callback_data' => "betRecordType@@0"],
  430. ['text' => "盈利", 'callback_data' => "betRecordType@@1"],
  431. ['text' => "亏损", 'callback_data' => "betRecordType@@2"]
  432. ];
  433. if ($page > 1) {
  434. $keyboard[] = [
  435. ['text' => "👆上一页", 'callback_data' => "betRecordNextPage@@" . ($page - 1)]
  436. ];
  437. }
  438. $allPage = ceil($count / $limit);
  439. if ($allPage > $page) {
  440. if ($page > 1) {
  441. $keyboard[count($keyboard) - 1][] = ['text' => "👇下一页", 'callback_data' => "betRecordNextPage@@" . ($page + 1)];
  442. } else {
  443. $keyboard[] = [
  444. ['text' => "👇下一页", 'callback_data' => "betRecordNextPage@@" . ($page + 1)]
  445. ];
  446. }
  447. }
  448. if ($messageId) {
  449. $msg['message_id'] = $messageId;
  450. }
  451. if ($keyboard) {
  452. $msg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
  453. }
  454. return $msg;
  455. }
  456. /**
  457. * @description: 中奖结算
  458. * @param {*} $issue_no
  459. * @param {*} $awards
  460. * @return {*}
  461. */
  462. public static function betSettled($issue_no, $awards)
  463. {
  464. $list = self::findAll(['issue_no' => $issue_no, 'status' => self::model()::STATUS_STAY]);
  465. $data = [];
  466. $text = $issue_no . "期开奖结果 \n";
  467. $text .= "-----本期开奖账单----- \n";
  468. $bet_num = 0;
  469. foreach ($list->toArray() as $k => $v) {
  470. $userInfo = UserService::findAll(['member_id' => $v['member_id']]);
  471. // $lastStr = self::getLastChar($userInfo->first_name, 1);
  472. $lastStr = self::hideMiddleDigits($v['member_id'], 4);
  473. $item = [];
  474. $item['id'] = $v['id'];
  475. $item['status'] = self::model()::STATUS_SETTLED;
  476. if (in_array($v['keywords'], $awards)) {
  477. $profit = $v['amount'] * $v['odds'];
  478. if ($profit > 880000) {
  479. $profit = 880000; // 单注最高奖金880000
  480. }
  481. $item['profit'] = $profit;
  482. $yl = $profit - $v['amount'];
  483. if ($k + 1 <= 15) {
  484. $text .= "私聊下注 【" . $lastStr . "】 {$yl}\n";
  485. $bet_num++;
  486. }
  487. // 结算
  488. WalletService::updateBalance($v['member_id'], $profit);
  489. $walletInfo = WalletService::findOne(['member_id' => $v['member_id']]);
  490. $balance = $walletInfo['available_balance'];
  491. BalanceLogService::addLog($v['member_id'], $profit, $balance, ($balance + $profit), '中奖', $v['id'], '');
  492. } else {
  493. if ($k + 1 <= 15) {
  494. $text .= "私聊下注 【******" . $lastStr . "】 -{$v['amount']}\n";
  495. $bet_num++;
  496. }
  497. }
  498. self::model()::where('id', $v['id'])->update($item);
  499. }
  500. $inlineButton = self::getOperateButton();
  501. $rand_num = 30 - $bet_num;
  502. $text .= self::fakeLotteryDraw($issue_no, $awards, $rand_num);
  503. // for ($i = 0; $i < $rand_num; $i++) {
  504. // // 生成 -100000 到 100000 的随机数,但排除 -10 到 10 的范围
  505. // $randomNumber = random_int(-1000000, 1000000) / 100;
  506. // if ($randomNumber >= -10 && $randomNumber <= 10) {
  507. // // 如果落在 -10 到 10 之间,重新生成或调整
  508. // $randomNumber = $randomNumber < 0 ? -random_int(10, 100000) : random_int(10, 100000);
  509. // }
  510. // $text .= "私聊下注 【******】 {$randomNumber}\n";
  511. // }
  512. // 群通知
  513. self::bettingGroupNotice($text, $inlineButton, '');
  514. }
  515. // 虚拟开奖
  516. public static function fakeLotteryDraw($issue_no, $awards, $rand_num = 30)
  517. {
  518. $fake_bet_list = Cache::get('fake_bet_' . $issue_no, []);
  519. $text = "";
  520. foreach ($fake_bet_list as $k => $v) {
  521. // $lastStr = self::getLastChar($v['first_name'], 1);
  522. $lastStr = self::hideMiddleDigits($v['member_id'], 4);
  523. if (in_array($v['keywords'], $awards)) {
  524. $profit = $v['amount'] * $v['odds'];
  525. if ($profit > 880000) {
  526. $profit = 880000; // 单注最高奖金880000
  527. }
  528. $item['profit'] = $profit;
  529. $yl = $profit - $v['amount'];
  530. if ($k + 1 <= $rand_num) {
  531. $text .= "私聊下注 【" . $lastStr . "】 {$yl}\n";
  532. }
  533. } else {
  534. if ($k + 1 <= $rand_num) {
  535. $text .= "私聊下注 【" . $lastStr . "】 -{$v['amount']}\n";
  536. }
  537. }
  538. }
  539. return $text;
  540. }
  541. }