|
@@ -10,6 +10,14 @@ namespace App\Lib\Settlement;
|
|
|
set_time_limit(600);
|
|
set_time_limit(600);
|
|
|
ini_set('memory_limit', '256M');
|
|
ini_set('memory_limit', '256M');
|
|
|
|
|
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
+use App\Models\Comendnotice as ComendnoticeModel;
|
|
|
|
|
+
|
|
|
|
|
+use App\Lib\Settlement\Adapter\ZqRule;
|
|
|
|
|
+use App\Lib\Settlement\Adapter\LqRule;
|
|
|
|
|
+use App\Lib\Settlement\Adapter\WqRule;
|
|
|
|
|
+use App\Lib\Settlement\Adapter\BqRule ;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class SettlementSql
|
|
class SettlementSql
|
|
|
{
|
|
{
|
|
@@ -49,108 +57,285 @@ class SettlementSql
|
|
|
private $RefClass = null ;
|
|
private $RefClass = null ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ public function GetSQL(){
|
|
|
|
|
+ return $this->makeData(1,'success',$this->sqlArray);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function doRun(){
|
|
public function doRun(){
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- _beginTransaction();
|
|
|
|
|
|
|
+ DB::beginTransaction ();
|
|
|
|
|
|
|
|
$ComendNoticModel = $this->getComendNoticeModel();
|
|
$ComendNoticModel = $this->getComendNoticeModel();
|
|
|
if (!$ComendNoticModel) {
|
|
if (!$ComendNoticModel) {
|
|
|
- _commit();
|
|
|
|
|
- return $this->makeData();
|
|
|
|
|
|
|
+ DB::commit ();
|
|
|
|
|
+ return $this->makeData(1,'没有要处理的数据,直接退出');
|
|
|
}
|
|
}
|
|
|
$this->writeStatusBegin($ComendNoticModel);
|
|
$this->writeStatusBegin($ComendNoticModel);
|
|
|
|
|
|
|
|
- $allmatchs = $this->getAllMatchIdArrays($ComendNoticModel->game_code, $ComendNoticModel->match_id, 2);
|
|
|
|
|
- $this->setAdapterObj( $ComendNoticModel->game_code );
|
|
|
|
|
- $this->RefClass = new \ReflectionClass( $this->setAdapterObj ) ;
|
|
|
|
|
- $this->getCompResult($ComendNoticModel->game_code,$ComendNoticModel->match_id);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if (!$allmatchs) {
|
|
|
|
|
|
|
+ $allmatchs = $this->getAllMatchIdArrays($ComendNoticModel->game_code, $ComendNoticModel->match_id, 0);
|
|
|
|
|
+ if (empty($allmatchs)) {
|
|
|
$this->writeStatusEndOk($ComendNoticModel);
|
|
$this->writeStatusEndOk($ComendNoticModel);
|
|
|
- _commit();
|
|
|
|
|
- return $this->makeData();
|
|
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return $this->makeData(1,'本赛事无订单数据,退出');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $this->setAdapterObj($ComendNoticModel->game_code);
|
|
|
|
|
+ $this->RefClass = new \ReflectionClass( $this->AdapterObj ) ;
|
|
|
|
|
+ $this->getCompResult($ComendNoticModel->game_code,$ComendNoticModel->match_id);
|
|
|
|
|
+
|
|
|
foreach ($allmatchs as $buymatchmodel){
|
|
foreach ($allmatchs as $buymatchmodel){
|
|
|
- $this->doSettlement($buymatchmodel);
|
|
|
|
|
|
|
+ $this->domatchPresess($buymatchmodel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _commit();
|
|
|
|
|
- return $this->makeData();
|
|
|
|
|
|
|
+ DB::rollback();
|
|
|
|
|
+ return $this->makeData(1,'success-all');
|
|
|
|
|
|
|
|
}catch (\Exception $e){
|
|
}catch (\Exception $e){
|
|
|
- _rollBack();
|
|
|
|
|
|
|
+ DB::rollBack();
|
|
|
return $this->makeData(0,'false',['msg'=>$e->getMessage(),'code'=>$e->getCode()]) ;
|
|
return $this->makeData(0,'false',['msg'=>$e->getMessage(),'code'=>$e->getCode()]) ;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
//拼装 逻辑 sql;
|
|
//拼装 逻辑 sql;
|
|
|
- private function doSettlement($model){
|
|
|
|
|
|
|
+ private function domatchPresess($model){
|
|
|
$fun = $model->odds_code ;
|
|
$fun = $model->odds_code ;
|
|
|
if ( $this->RefClass->hasMethod( $fun)){
|
|
if ( $this->RefClass->hasMethod( $fun)){
|
|
|
$winorfalse = $this->AdapterObj->$fun($model,$this->resultModel,$this->resultRecords);
|
|
$winorfalse = $this->AdapterObj->$fun($model,$this->resultModel,$this->resultRecords);
|
|
|
$this->makesql_up_buymatch_winorfalse($model->id,$winorfalse,date("Y-m-d H:i:s"));
|
|
$this->makesql_up_buymatch_winorfalse($model->id,$winorfalse,date("Y-m-d H:i:s"));
|
|
|
- if ($winorfalse == -1){
|
|
|
|
|
- $this->masql_up_buymatch_false($model->batch_id);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ($model->bet_type ==2){
|
|
|
|
|
+ if ($winorfalse == -1){
|
|
|
|
|
+ //串式,一个错,全部错了.....
|
|
|
|
|
+ $this->makesql_up_serial_lose($model);
|
|
|
|
|
+ return ;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $mainmodels = $this->GetBuyStrBatchIdArrays($model->batch_id,$model->bet_type);
|
|
|
|
|
+ $lessCount = $mainmodels[0]->wait_match_num;
|
|
|
|
|
+ if ($lessCount > 0 ){
|
|
|
|
|
+ //还有没结束的赛事,不急做结算处理
|
|
|
|
|
+ $this->wait_match_num_desc($model->batch_id,$model->bet_type);
|
|
|
|
|
+ return true ;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $this->doSettlement($model);
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ throw new \Exception('找不到此玩法的胜负规则逻辑!',4005);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function wait_match_num_desc($batch_id,$type){
|
|
|
|
|
+ $table = ($type ==1)? 'money_buy_simplex': 'money_buy_str';
|
|
|
|
|
+ $sql = "update $table set wait_match_num=wait_match_num-1 where batch_id='$batch_id' ";
|
|
|
|
|
+ $this->sqlArray[] = $sql;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //实现结算相关的逻辑
|
|
|
|
|
+ //逐个计算每个下单情况给用户加钱 {加用户余额,写流水详细}
|
|
|
|
|
+ private function doSettlement($model){
|
|
|
|
|
+ $batchid = $model->batch_id ;
|
|
|
|
|
+ $bettype = $model->bet_type ;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $allbatchModels = $this->getAllBatchIdArrays($model->game_code,$batchid);
|
|
|
|
|
+ //存在相同比赛不同玩法串式,先前已经输的情况下,此时没有数据了....
|
|
|
|
|
+ if (empty($allbatchModels)){ return true; }
|
|
|
|
|
+
|
|
|
|
|
+ $allbuyModels = $this->GetBuyStrBatchIdArrays($batchid,$bettype);
|
|
|
|
|
+ $account_identity = '';
|
|
|
|
|
+
|
|
|
|
|
+ if ($bettype ==2){
|
|
|
|
|
+ //串式投注
|
|
|
|
|
+ $con_arr = [] ;
|
|
|
|
|
+ foreach ($allbatchModels as $batchModel){
|
|
|
|
|
+ $con_arr[] = ['odds'=>$batchModel->odds,'winorlose'=>$batchModel->result,'money'=>1];
|
|
|
|
|
+ }
|
|
|
|
|
+ $peilvArray = $this->winOddsCalculation(2,$con_arr);
|
|
|
|
|
+ foreach ($allbuyModels as $buyModel){
|
|
|
|
|
+ if ($account_identity==''){ $account_identity = $buyModel->account_identity; }
|
|
|
|
|
+ $money = sprintf("%.2f",$buyModel->money * $peilvArray['returnMoney']) ;
|
|
|
|
|
+ $sql = "update money_buy_str set gain_money=$money where batch_id='$batchid' and id=$buyModel->id ";
|
|
|
|
|
+ $this->sqlArray[] = $sql ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //单式投注
|
|
|
|
|
+ $money = 0 ;
|
|
|
|
|
+ if ( $account_identity ==''){ $account_identity = $allbuyModels['0']->account_identity; }
|
|
|
|
|
+ $money = 0 ;
|
|
|
|
|
+ foreach ($allbatchModels as $batchModel){
|
|
|
|
|
+ $con_arr[] = ['odds'=>$model->odds,'winorlose'=>$batchModel->result,'money'=>$allbuyModels['0']->money];
|
|
|
|
|
+ $money_odds_array = $this->winOddsCalculation(1,$con_arr);
|
|
|
|
|
+ $money += sprintf("%.2f",$batchModel->bet_money * $money_odds_array['returnMoney'] ) ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $sql = "update money_buy_simplex set gain_money=$money where batch_id=$batchid ";
|
|
|
|
|
+ $this->sqlArray[] = $sql ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $money_diff = $this->get_money_chage($batchid,$bettype);
|
|
|
|
|
+ $this->sql_accountdetail_money($account_identity,$money_diff);
|
|
|
|
|
+ $this->sql_moneydetqil_log($allbuyModels['0'],$model,$money_diff);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 注单返现计算
|
|
|
|
|
+ * @param mixed $dataArray 结果表数据 [['odds'=>xx,'winOrLose'=>1],[...]];
|
|
|
|
|
+ * @return array 注单返现额
|
|
|
|
|
+ */
|
|
|
|
|
+ private function winOddsCalculation($dataArray){
|
|
|
|
|
+ $returnMoney = 1;
|
|
|
|
|
+ // 循环计算每注返现赔率
|
|
|
|
|
+ foreach ($dataArray as $value) {
|
|
|
|
|
+ $odds = intval($value['odds']);
|
|
|
|
|
+ // 因结果不同更改赔率
|
|
|
|
|
+ switch (intval($value['winOrLose'])) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ $oddsDiscount = 1 + $odds * 1;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ $oddsDiscount = 1;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ $oddsDiscount = 1 + $odds * 0.5;
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ $oddsDiscount = 0.5;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 计算每注返现
|
|
|
|
|
+ $returnMoney = $returnMoney * $oddsDiscount;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 计算赚钱
|
|
|
|
|
+ $earnMoney = $returnMoney - 1;
|
|
|
|
|
+
|
|
|
|
|
+ return ['earnMoney' => $earnMoney, 'returnMoney' => $returnMoney];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * UUID 生成
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function UUID() {
|
|
|
|
|
+ $prefix = '';
|
|
|
|
|
+ $uuid = '';
|
|
|
|
|
+ $str = md5(uniqid(mt_rand(), true));
|
|
|
|
|
+ $uuid = substr($str, 0, 8) . '-';
|
|
|
|
|
+ $uuid .= substr($str, 8, 4) . '-';
|
|
|
|
|
+ $uuid .= substr($str, 12, 4) . '-';
|
|
|
|
|
+ $uuid .= substr($str, 16, 4) . '-';
|
|
|
|
|
+ $uuid .= substr($str, 20, 12);
|
|
|
|
|
+ return $prefix . $uuid;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private function sql_accountdetail_money($acount ,$moneycg){
|
|
|
|
|
+ $sql = "update account_detail set account_detailed set available_cash=available_cash+$moneycg,cash=cash+$moneycg where account_identity='$acount' ";
|
|
|
|
|
+ $this->sql[] = $sql ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function sql_moneydetqil_log($allbuyModel,$model,$money_diff){
|
|
|
|
|
+ $uuid = self::UUID();
|
|
|
|
|
+ $dtime = date("Y-m-d H:i:s");
|
|
|
|
|
+ $detailModel = DB::table('Account_detailed')->where(['account_identity',$allbuyModel->account_indentity])->first();
|
|
|
|
|
+ if (!$detailModel){
|
|
|
|
|
+ throw new \Exception('查无此用户数据account_detail='.$allbuyModel->account_indentity,41002);
|
|
|
|
|
+ }
|
|
|
|
|
+ $money_cash = $detailModel->cash ;
|
|
|
|
|
|
|
|
|
|
+ $SQL = "inser into account_detailed set identity='$uuid',trade_id='$allbuyModel->order_id',account_name='$allbuyModel->account_name', " ;
|
|
|
|
|
+ $SQL .= "account_identity=='$allbuyModel->account_indentity',money='$money_diff',money_time='$dtime',money_type=1, ";
|
|
|
|
|
+ $SQL .= "trade_desc='中奖收入',status='成功',money_cash=$money_cash " ;
|
|
|
|
|
|
|
|
|
|
+ $this->sql[] = $SQL ;
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //计算 某个比赛结束后 对应订单的资金变化
|
|
|
|
|
+ private function get_money_chage($batch_id,$type){
|
|
|
|
|
+ if ($type ==1 ){
|
|
|
|
|
+ $ret = DB::select("select sum(gain_money-money) as dfmoney from money_buy_simplex where batch_id='$batch_id'");
|
|
|
|
|
+ if (!isset( $ret['0']['dfmoney'])){
|
|
|
|
|
+ throw new \Exception("资金变化不正确!");
|
|
|
|
|
+ }
|
|
|
|
|
+ $moneydiff = sprintf("%.2f",$ret['0']['dfmoney']);
|
|
|
}else{
|
|
}else{
|
|
|
- throw new \Exception('找不到此玩法的胜负规则逻辑!',4005);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $ret = DB::select("select sum(gain_money-money) as dfmoney from money_buy_str where batch_id='$batch_id'");
|
|
|
|
|
+ if (!isset( $ret['0']['dfmoney'])){
|
|
|
|
|
+ throw new \Exception("资金变化不正确!");
|
|
|
|
|
+ }
|
|
|
|
|
+ $moneydiff = sprintf("%.2f",$ret['0']['dfmoney']);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ return $moneydiff ;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //生成串式失败的逻辑sql;
|
|
|
|
|
+ private function makesql_up_serial_lose($model){
|
|
|
|
|
+ $batchid = $model->batch_id ;
|
|
|
|
|
+ $sql = "update money_buy_match set result=-1 where bet_type=2 and batch_id=$batchid ";
|
|
|
|
|
+ $this->sqlArray[] = $sql;
|
|
|
|
|
+
|
|
|
|
|
+ $sql = "update money_buy_str set game_status=3,wait_match_num=0 where batch_id=$batchid ";
|
|
|
|
|
+ $this->sqlArray[] = $sql ;
|
|
|
|
|
+
|
|
|
|
|
+ return true ;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
private function makesql_up_buymatch_winorfalse($id,$result,$utime){
|
|
private function makesql_up_buymatch_winorfalse($id,$result,$utime){
|
|
|
$sql = " update money_buy_match set result=$result,utime=$utime where id=$id limit 1";
|
|
$sql = " update money_buy_match set result=$result,utime=$utime where id=$id limit 1";
|
|
|
$this->sqlArray[] = $sql;
|
|
$this->sqlArray[] = $sql;
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
- private function masql_up_buymatch_false($batch_id){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ private function masql_up_buymatch_false($batch_id,$type,$match_id=0){
|
|
|
$uptime = date("Y-m-d H:i:s");
|
|
$uptime = date("Y-m-d H:i:s");
|
|
|
- $sql = " update money_buy_match set result=-1 ,utime=$uptime,status=1 where batch_id=$batch_id ";
|
|
|
|
|
|
|
+ $sql = " update money_buy_match set result=-1 ,utime=$uptime,status=0 where batch_id=$batch_id ";
|
|
|
$this->sqlArray[] = $sql;
|
|
$this->sqlArray[] = $sql;
|
|
|
|
|
|
|
|
- $sql = "update money_buy_str set settle_status=1,game_status=3 ,wait_match_num=0 where batch_id=$batch_id " ;
|
|
|
|
|
|
|
+ if ($type==2){
|
|
|
|
|
+ $sql = "update money_buy_str set settle_status=1,game_status=3 ,wait_match_num=0 where batch_id=$batch_id " ;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $sql = "update money_buy_simplex set settle_status=1,game_status=3 ,wait_match_num=wait_match_num-1 where batch_id=$batch_id and match_id=$match_id " ;
|
|
|
|
|
+ }
|
|
|
$this->sqlArray[] = $sql;
|
|
$this->sqlArray[] = $sql;
|
|
|
|
|
|
|
|
return true ;
|
|
return true ;
|
|
|
}
|
|
}
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //设置 输赢 解析规则适配器
|
|
|
private function setAdapterObj($game_type){
|
|
private function setAdapterObj($game_type){
|
|
|
-
|
|
|
|
|
- if ( isset($this->gameAllMap)){ throw new \Exception('赛事类型错误',4002); return false; }
|
|
|
|
|
|
|
+ $game_type = strtolower($game_type);
|
|
|
|
|
+ if ( !isset($this->gameAllMap)){ throw new \Exception('赛事类型错误-'.$game_type,4002); return false; }
|
|
|
|
|
|
|
|
switch ($game_type){
|
|
switch ($game_type){
|
|
|
case 'bq':
|
|
case 'bq':
|
|
|
- C()->set('BqRule','\Biz\Settlement\Adapter\BqRule');
|
|
|
|
|
- $this->AdapterObj = C()->get('BqRule');
|
|
|
|
|
|
|
+ $this->AdapterObj = new BqRule();
|
|
|
break;
|
|
break;
|
|
|
case 'lq':
|
|
case 'lq':
|
|
|
- C()->set('LqRule','\Biz\Settlement\Adapter\LqRule');
|
|
|
|
|
- $this->AdapterObj = C()->get('LqRule');
|
|
|
|
|
|
|
+ $this->AdapterObj = new LqRule();
|
|
|
break;
|
|
break;
|
|
|
case 'wq':
|
|
case 'wq':
|
|
|
- C()->set('WqRule','\Biz\Settlement\Adapter\WqRule');
|
|
|
|
|
- $this->AdapterObj = C()->get('WqRule');
|
|
|
|
|
|
|
+ $this->AdapterObj = new WqRule();
|
|
|
break;
|
|
break;
|
|
|
case 'zq':
|
|
case 'zq':
|
|
|
- C()->set('ZqRule','\Biz\Settlement\Adapter\ZqRule');
|
|
|
|
|
- $this->AdapterObj = C()->get('ZqRule');
|
|
|
|
|
|
|
+ $this->AdapterObj = new ZqRule();
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
return true ;
|
|
return true ;
|
|
@@ -168,52 +353,75 @@ class SettlementSql
|
|
|
|
|
|
|
|
//写处理状态
|
|
//写处理状态
|
|
|
public function writeStatusBegin($comendnticeModel){
|
|
public function writeStatusBegin($comendnticeModel){
|
|
|
|
|
+
|
|
|
$comendnticeModel->status = 1 ;
|
|
$comendnticeModel->status = 1 ;
|
|
|
- $comendnticeModel->pupdatetime = date("Y-m-d H:i:s");
|
|
|
|
|
|
|
+ $comendnticeModel->done_time = date("Y-m-d H:i:s");
|
|
|
$comendnticeModel->pcount ++ ;
|
|
$comendnticeModel->pcount ++ ;
|
|
|
$comendnticeModel->logs = 'begin|';
|
|
$comendnticeModel->logs = 'begin|';
|
|
|
$ret = $comendnticeModel->save();
|
|
$ret = $comendnticeModel->save();
|
|
|
|
|
+
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//写处理状态结束
|
|
//写处理状态结束
|
|
|
public function writeStatusEndOk($comendnticeModel){
|
|
public function writeStatusEndOk($comendnticeModel){
|
|
|
|
|
+
|
|
|
$comendnticeModel->status = 4 ;
|
|
$comendnticeModel->status = 4 ;
|
|
|
$comendnticeModel->pret = 1 ;
|
|
$comendnticeModel->pret = 1 ;
|
|
|
- $comendnticeModel->puodateendtime = date("Y-m-d H:i:s");
|
|
|
|
|
|
|
+ $comendnticeModel->done_time = date("Y-m-d H:i:s");
|
|
|
$comendnticeModel->logs = $comendnticeModel->logs.'end ok';
|
|
$comendnticeModel->logs = $comendnticeModel->logs.'end ok';
|
|
|
$ret = $comendnticeModel->save();
|
|
$ret = $comendnticeModel->save();
|
|
|
|
|
+
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //是否有需要进行结果算处理的赛事记录
|
|
|
public function getComendNoticeModel(){
|
|
public function getComendNoticeModel(){
|
|
|
- $ret = lm('Comendnotice','Commons')->wherer('status',0)->order('id','asc')->first();
|
|
|
|
|
|
|
+ $ret = (new ComendnoticeModel())->where('status',0)->orderby('id','asc')->first();
|
|
|
|
|
+
|
|
|
$this->ComendNoticModel = $ret;
|
|
$this->ComendNoticModel = $ret;
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public function getAllMatchIdArrays( $type,$matchid ,$bet_type=2,$result = 0 ){
|
|
|
|
|
- $ret = lm('Money_buy_match','Commons')->where(['game_code'=>$type,'match_id'=>$matchid,'bet_type'=>$bet_type,'result'=>$result])->find();
|
|
|
|
|
|
|
+ //某个赛事 所有下单数据记录
|
|
|
|
|
+ public function getAllMatchIdArrays( $type,$matchid , $result = 0 ){
|
|
|
|
|
+ if (is_null($result)){
|
|
|
|
|
+ $ret = DB::table('money_buy_match')->where(['game_code'=>$type,'match_id'=>$matchid])->get();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $ret = DB::table('money_buy_match')->where(['game_code'=>$type,'match_id'=>$matchid,'result'=>$result])->get();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$this->AllMatchIdArrays = $ret;
|
|
$this->AllMatchIdArrays = $ret;
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getAllBatchIdArrays($type,$batchid,$owhere=[]){
|
|
|
|
|
+ if (!empty($owhere)){
|
|
|
|
|
+ $where = array_merge(['game_code'=>$type,'batch_id'=>$batchid],$owhere);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $where = ['game_code'=>$type,'batch_id'=>$batchid] ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $ret = DB::table('money_buy_match')->where($where)->order('id','asc')->get();
|
|
|
|
|
+ //if (empty($ret)){ throw new \Exception('没有记录' ,4008);}
|
|
|
|
|
+ return $ret;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ //获取到某个用户的account模型和detail模型,用于用户的余额计算等使用
|
|
|
public function getUserInfo($account_name){
|
|
public function getUserInfo($account_name){
|
|
|
if (isset($this->AccountArrays[$account_name])){
|
|
if (isset($this->AccountArrays[$account_name])){
|
|
|
return $this->AccountArrays['$account_name'];
|
|
return $this->AccountArrays['$account_name'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $accountModel = lm('Account','Commons')->where(['account',$account_name])->first();
|
|
|
|
|
|
|
+ $accountModel = DB::table('Account')->where(['account',$account_name])->first();
|
|
|
if (!$accountModel){
|
|
if (!$accountModel){
|
|
|
throw new \Exception('查无此用户数据account='.$account_name,41002);
|
|
throw new \Exception('查无此用户数据account='.$account_name,41002);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $detailModel = lm('Account_detailed','Commons')->where(['account_identity',$accountModel->identity])->first();
|
|
|
|
|
|
|
+ $detailModel = DB::table('Account_detailed','Commons')->where(['account_identity',$accountModel->identity])->first();
|
|
|
if (!$detailModel){
|
|
if (!$detailModel){
|
|
|
throw new \Exception('查无此用户数据account_detail='.$accountModel->identity,41002);
|
|
throw new \Exception('查无此用户数据account_detail='.$accountModel->identity,41002);
|
|
|
}
|
|
}
|
|
@@ -227,30 +435,37 @@ class SettlementSql
|
|
|
return $ret;
|
|
return $ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- public function GetMatchBatchIdArrays($batch_id){
|
|
|
|
|
- if (isset($this->MatchBatchIdArrays[$batch_id])){
|
|
|
|
|
- return $this->MatchBatchIdArrays[$batch_id];
|
|
|
|
|
|
|
+ //获取到某个用户某个赛事的下单记录集[]
|
|
|
|
|
+ public function GetMatchBatchIdArrays($batch_id,$type){
|
|
|
|
|
+ if (isset($this->MatchBatchIdArrays[$type][$batch_id])){
|
|
|
|
|
+ // return $this->MatchBatchIdArrays[$type][$batch_id];
|
|
|
}
|
|
}
|
|
|
- $all = lm("Money_buy_match")->getByBatchId($batch_id);
|
|
|
|
|
|
|
+ $all = DB::table("money_buy_match")->where(['batch_id',$batch_id,'result'=>0])->get();
|
|
|
if (!$all) {
|
|
if (!$all) {
|
|
|
throw new \Exception('无效的Money_buy_str->batch_id='.$batch_id , 41001);
|
|
throw new \Exception('无效的Money_buy_str->batch_id='.$batch_id , 41001);
|
|
|
}
|
|
}
|
|
|
- $this->MatchBatchIdArrays[$batch_id] = $all ;
|
|
|
|
|
|
|
+ $this->MatchBatchIdArrays[$type][$batch_id] = $all ;
|
|
|
return $all ;
|
|
return $all ;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- public function GetBuyStrBatchIdArrays($batch_id){
|
|
|
|
|
|
|
+ //根据购买批次 获取下单信息
|
|
|
|
|
+ public function GetBuyStrBatchIdArrays($batch_id,$type){
|
|
|
|
|
|
|
|
if (isset($this->BuyStrBatchIdArrays[$batch_id])){
|
|
if (isset($this->BuyStrBatchIdArrays[$batch_id])){
|
|
|
- return $this->BuyStrBatchIdArrays[$batch_id];
|
|
|
|
|
|
|
+ // return $this->BuyStrBatchIdArrays[$batch_id];
|
|
|
}
|
|
}
|
|
|
- $all = lm("Money_buy_str")->getByBatchId($batch_id);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ($type==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ $all = DB::table("money_buy_str")->where(['batch_id'=>$batch_id,'game_status'=>0])->get();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $all = DB::table("money_buy_simplex")->where(['batch_id'=>$batch_id,'game_status'=>0])->get();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!$all) {
|
|
if (!$all) {
|
|
|
- throw new \Exception('无效的Money_buy_str->batch_id='.$batch_id , 41001);
|
|
|
|
|
|
|
+ throw new \Exception('无效的batch_id='.$batch_id , 41001);
|
|
|
}
|
|
}
|
|
|
- $this->BuyStrBatchIdArrays[$batch_id] = $all ;
|
|
|
|
|
|
|
+ // $this->BuyStrBatchIdArrays[$batch_id] = $all ;
|
|
|
return $all ;
|
|
return $all ;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -261,23 +476,24 @@ class SettlementSql
|
|
|
$model = null ;
|
|
$model = null ;
|
|
|
switch ($type){
|
|
switch ($type){
|
|
|
case 'bq':
|
|
case 'bq':
|
|
|
- $model = lm('St_bq_result','Commons')->where('match_id',$match_id)->first();
|
|
|
|
|
- $models = lm('St_bq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
|
|
|
|
|
|
|
+ $model = DB::table('st_bq_result')->where('match_id',$match_id)->first();
|
|
|
|
|
+ $models = DB::table('st_bq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
|
|
|
break;
|
|
break;
|
|
|
case 'lq':
|
|
case 'lq':
|
|
|
- $model = lm('St_lq_resultn','Commons')->where('match_id',$match_id)->first();
|
|
|
|
|
- $models = lm('St_lq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
|
|
|
|
|
|
|
+ $model = DB::table('st_lq_resultn')->where('match_id',$match_id)->first();
|
|
|
|
|
+ $models = DB::table('st_lq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
|
|
|
break;
|
|
break;
|
|
|
case 'wq':
|
|
case 'wq':
|
|
|
- $model = lm('St_wq_result','Commons')->where('match_id',$match_id)->first();
|
|
|
|
|
- $models = lm('St_wq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
|
|
|
|
|
|
|
+ $model = DB::table('st_wq_result')->where('match_id',$match_id)->first();
|
|
|
|
|
+ $models = DB::table('st_wq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
|
|
|
break;
|
|
break;
|
|
|
case 'zq':
|
|
case 'zq':
|
|
|
- $model = lm('St_zq_result','Commons')->where('match_id',$match_id)->first();
|
|
|
|
|
- $models = lm('St_zq_result_record','Commons')->where('match_id',$match_id)->orderBy('id','asc')->get();
|
|
|
|
|
|
|
+ $model = DB::table('st_zq_result')->where('match_id',$match_id)->first();
|
|
|
|
|
+ $models = DB::table('st_zq_result_record')->where('match_id',$match_id)->orderBy('id','asc')->get()->toArray();
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- if (empty($model)){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($model) || empty($models)){
|
|
|
throw new \Exception('没找到比赛结果记录match_id_'.$type.'-'.$match_id,4007);
|
|
throw new \Exception('没找到比赛结果记录match_id_'.$type.'-'.$match_id,4007);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|