Ken 6 days ago
parent
commit
4fb7e5c2f0
5 changed files with 35 additions and 93 deletions
  1. 10 93
      app/Services/BetService.php
  2. 22 0
      app/Services/RebateService.php
  3. 1 0
      lang/en/messages.php
  4. 1 0
      lang/vi/messages.php
  5. 1 0
      lang/zh/messages.php

+ 10 - 93
app/Services/BetService.php

@@ -320,7 +320,7 @@ class BetService extends BaseService
         $rebate = Config::where('field', 'rebate')->first()->val;
         $huishui_restriction = Config::where('field', 'huishui_restriction')->first()->val;
         $huishui_percentage = Config::where('field', 'huishui_percentage')->first()->val;
-        Rebate::addOrUpdate([
+        $rebate = Rebate::addOrUpdate([
             'date' => $now,
             'member_id' => $memberId,
             'betting_amount' => $amount,
@@ -330,20 +330,17 @@ class BetService extends BaseService
             'huishui_restriction' => $huishui_restriction,
             'huishui_percentage' => $huishui_percentage,
         ]);
-        // // 返利
-        // $rebate = Config::where('field', 'rebate')->first()->val;
-        // if($rebate > 0){
-        //     $rebateAmount = bcmul($amount, $rebate, 2); // 返利金额
-        //     if($rebateAmount > 0){
-        //         WalletService::updateBalance($memberId,$rebateAmount);
 
-        //         $walletInfo = WalletService::findOne(['member_id' => $memberId]);
-        //         $balance = $walletInfo['available_balance'];
-
-        //         BalanceLogService::addLog($memberId,$rebateAmount,$balance,($balance+$rebateAmount),'返水',$bet_id,'');
-        //     }
+        if (!RebateService::BibiReturn($rebate)) {
+            $text = lang("比比返失败");
+            $text .= "\n";
+            $msg['text'] = $text;
+            if ($messageId) {
+                $msg['reply_to_message_id'] = $messageId;
+            }
+            return $msg;
+        }
 
-        // }
 
         $text = lang('下注期数') . ":{$issueInfo->issue_no}\n";
         $text .= lang("下注内容") . "\n";
@@ -647,7 +644,6 @@ class BetService extends BaseService
     public static function betSettled($issue_no, $awards)
     {
         $list = self::findAll(['issue_no' => $issue_no, 'status' => self::model()::STATUS_STAY]);
-
         // 大小单双的
         $otherSum = self::model()::where('issue_no', $issue_no)->where('status', self::model()::STATUS_STAY)->whereIn('keywords', ['大', '小', '单', '双'])->sum('amount');
 
@@ -655,12 +651,6 @@ class BetService extends BaseService
         $keywordsList = $fakeOpenData['keywordsList'];
         $fakeOtherSum = $fakeOpenData['sum'];
         $sum = $otherSum + $fakeOtherSum;
-
-        $data = [];
-        $text = $issue_no . "期开奖结果 \n";
-        $text .= "-----本期开奖账单----- \n";
-        $text .= "\n";
-        // $text .=" 中奖类型 用户 投注金额 中奖金额 盈亏 \n";
         $betNoticeNum = Config::where('field', 'bet_notice_num')->first()->val;
         $betNoticeNum = explode(',', $betNoticeNum);
         $betNoticeMini = $betNoticeNum[0] ?? 26;
@@ -733,11 +723,6 @@ class BetService extends BaseService
                     'profit' => $profit,
                     'yl' => $yl,
                 ];
-                // if ($k + 1 <= $realNoticeNum) {
-
-                //     // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$profit} {$yl}\n";
-                //     $bet_num++;
-                // }
                 // 结算
                 WalletService::updateBalance($v['member_id'], $profit);
 
@@ -811,8 +796,6 @@ class BetService extends BaseService
                     BalanceLogService::addLog($v['member_id'], $profit, $balance, ($balance + $profit), '中奖', $v['id'], '');
                 }
 
-                
-
 
                 if (isset($openList[$v['member_id']])) {
                     $openList[$v['member_id']]['member_id'] = $v['member_id'];
@@ -831,78 +814,12 @@ class BetService extends BaseService
                     $openList[$v['member_id']]['win_amount'] = 0;
                     $openList[$v['member_id']]['is_send'] = true;
                 }
-
-                // if ($k + 1 <= $realNoticeNum) {
-                //     // $text .= "会员下注 【" . $lastStr . "】{$v['amount']} {$v['profit']} -{$v['amount']}\n";
-                //     $bet_num++;
-                // }
-
-                // $memberList[$v['member_id']][] = [
-                //     'member_id' => $v['member_id'],
-                //     'amount' => $v['amount'],
-                //     'keywords' => $v['keywords'],
-                //     'profit' => 0,
-                //     'yl' => '-'.$v['amount'],
-                // ];
             }
 
             self::model()::where('id', $v['id'])->update($item);
         }
-
-        // foreach($openList as $k => $v){
-        //     $amount = $v['amount'];
-        //     // if($v['profit'] >= 0){
-        //         $profit = number_format($v['profit'],2);
-        //         $yl = bcsub($v['profit'], $v['amount'], 2); // 盈利
-        //         // $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} {$profit} {$yl}\n";
-
-        //         if(++$bet_num <= $realNoticeNum){
-        //             if(empty($v['openKeywords'])){
-        //                 $openKeyword = '-'; 
-        //             }else{
-        //                 $openKeyword = implode(',', $v['openKeywords']);
-        //             }
-        //             $text .= "用户ID:{$v['lastStr']} \n";
-        //             $text .= "下注类型:[".implode(',', $v['keywords'])."] \n";
-        //             $text .= "中奖类型:[".$openKeyword."] \n";
-        //             $text .= "投注金额:{$amount} \n";
-        //             $text .= "中奖金额:{$v['win_amount']} \n";
-        //             $text .= "派彩金额:{$profit} \n";
-        //             $text .= "盈亏金额:{$yl} \n";
-        //             $text .= "-------------------------------- \n";
-        //         }
-
-
-        //         $text2 = "{$issue_no}期开奖结果 \n";
-        //         $text2 .= "下注类型:[".implode(',', $v['keywords'])."] \n";
-        //         $text2 .= "中奖类型:[".$openKeyword."] \n";
-        //         $text2 .= "投注金额:{$amount} \n";
-        //         $text2 .= "中奖金额:{$v['win_amount']} \n";
-        //         $text2 .= "派彩金额:{$profit} \n";
-        //         $text2 .= "盈亏金额:{$yl} \n";
-
-        //         $keyboard = [];
-        //         $keyboard[] = [
-        //             ['text' => "开奖历史", 'callback_data' => "showLotteryHistory@@" . $issue_no]
-        //         ];
-        //         SendTelegramMessageJob::dispatch($v['member_id'],$text2,$keyboard);
-        //         // self::sendMessage($v['member_id'],$text2);
-        //     // }else{
-        //     //     $text .= "会员下注 【" . $v['lastStr'] . "】 {$amount} 0 -{$amount}\n";
-        //     // }
-
-        // }
-
-        $inlineButton = self::getOperateButton();
-
-        $rand_num = $noticeNum - $bet_num;
-
         $openList = array_merge($openList, $fakeOpenData['list']);
 
-        // 群通知
-        // self::bettingGroupNotice($text, $inlineButton, '');
-        // SendTelegramGroupMessageJob::dispatch($text,$inlineButton,'');
-
         self::lotteryNotice($openList, $issue_no, $keywordsList);
     }
 

+ 22 - 0
app/Services/RebateService.php

@@ -4,6 +4,7 @@
 namespace App\Services;
 
 
+use App\Models\Config;
 use App\Models\Rebate;
 use App\Models\User;
 use Carbon\Carbon;
@@ -103,4 +104,25 @@ class RebateService extends BaseService
             ->paginate($limit);
         return ['total' => $paginator->total(), 'data' => $paginator->items()];
     }
+
+
+    //比比返水
+    public static function BibiReturn($rebate)
+    {
+        $rebate_ratio = Config::where('field', 'rebate')->first()->val;
+        $rebateAmount = bcmul($rebate->betting_amount, $rebate_ratio, 2); // 返利金额
+        if ($rebateAmount > 0) {
+            $res = WalletService::updateBalance($rebate->member_id, $rebateAmount);
+            BalanceLogService::addLog(
+                $rebate->member_id,
+                $rebateAmount,
+                $res['before_balance'],
+                $res['after_balance'],
+                '返水',
+                $rebate->id,
+                '');
+        }
+        return true;
+    }
+
 }

+ 1 - 0
lang/en/messages.php

@@ -290,6 +290,7 @@ return [
     "新用户信息" => "New User Information",
     "管理员已将指定账户转移至您的账户" => "The administrator has transferred the specified account to your account",
     "原账户信息" => "Original Account Information",
+    "比比返失败"=>"The water injection for the DSLR failed",
     
 
 

+ 1 - 0
lang/vi/messages.php

@@ -291,6 +291,7 @@ return [
     "新用户信息" => "Thông tin người dùng mới",
     "管理员已将指定账户转移至您的账户" => "Quản trị viên đã chuyển tài khoản được chỉ định sang tài khoản của bạn",
     "原账户信息" => "Thông tin tài khoản cũ",
+    "比比返失败"=>"Máy bơm nước SLR thất bại",
 
 
 

+ 1 - 0
lang/zh/messages.php

@@ -290,6 +290,7 @@ return [
     "新用户信息" => "新用户信息",
     "管理员已将指定账户转移至您的账户" => "管理员已将指定账户转移至您的账户",
     "原账户信息" => "原账户信息",
+    "比比返失败"=>"比比返失败",
 
 
 ];