|
|
@@ -6,6 +6,12 @@ use Biz\Money\Money;
|
|
|
use Biz\Account\AccountManager;
|
|
|
use App\Api\Model\St_odds_code as odds_codeModel;
|
|
|
use App\Api\Model\Dc_user_grade;
|
|
|
+
|
|
|
+use Biz\Db\Redis\Cache as Redis;
|
|
|
+use Illuminate\Support\Testing\Fakes\QueueFake;
|
|
|
+// use Illuminate\Contracts\Queue\Queue;
|
|
|
+
|
|
|
+
|
|
|
/*
|
|
|
* Class Register
|
|
|
* @package App\Api\Controller
|
|
|
@@ -23,6 +29,29 @@ class Betorder extends BaseController{
|
|
|
$this->commonFunction = C()->get('commonFunction');
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测试写队列 任务
|
|
|
+ */
|
|
|
+ public function dd(){
|
|
|
+ //laterOn
|
|
|
+
|
|
|
+ //实例化 队列
|
|
|
+ $Queue = new QueueFake();
|
|
|
+
|
|
|
+ //新建队列 任务
|
|
|
+ $Queue ->push('a','c','123');
|
|
|
+
|
|
|
+ /*
|
|
|
+ $redis = new Redis();
|
|
|
+ $redis->set('name','pengjun');
|
|
|
+
|
|
|
+ $name = $redis->get('name');
|
|
|
+ dd($name);
|
|
|
+ */
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 单式串式分类
|
|
|
* @param [array] $res 投注数据
|
|
|
@@ -110,9 +139,45 @@ class Betorder extends BaseController{
|
|
|
* @param [array] $res 单式投注数据
|
|
|
* @return [int] 1 成功 其他失败
|
|
|
* @param [int] $batch_id 批量ID
|
|
|
+ * 弃用
|
|
|
*/
|
|
|
public function Simplex_bet(array $res,array $userInfo,$batch_id){
|
|
|
|
|
|
+ if(empty($res)||empty($userInfo)||empty($batch_id)){
|
|
|
+ Render('', '7003',lang('Errors','Api')->get('error-7003'));
|
|
|
+ }
|
|
|
+ //验证与判断投注了几种
|
|
|
+ foreach($res as $k => $v){
|
|
|
+ $num = $k + 1;
|
|
|
+ if(empty($v['bet_amount'])){
|
|
|
+ $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5105');
|
|
|
+ Render([], '5105',$msg);
|
|
|
+ }
|
|
|
+ //根据类型分组
|
|
|
+ if(!isset($res[$v['ballId']])){
|
|
|
+ $res[$v['ballId']][] = $v;
|
|
|
+ unset($res[$k]);
|
|
|
+ }else{
|
|
|
+ $res[$v['ballId']][] = $v;
|
|
|
+ unset($res[$k]);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //球类联赛分类并且插入数据库
|
|
|
+ foreach($res as $k => $v){
|
|
|
+ $this->Simplex_bet_insert($v,$userInfo,$k,$batch_id);
|
|
|
+
|
|
|
+ /*
|
|
|
+ $gamedate = $this->Group_ball($res[$k]);
|
|
|
+ $this->Simplex_bet_insert($gamedate,$userInfo,$k,$batch_id);
|
|
|
+ */
|
|
|
+ }
|
|
|
+
|
|
|
+ return $odds_ids;
|
|
|
+ }
|
|
|
+ //弃用 备份
|
|
|
+ public function Simplex_bet___(array $res,array $userInfo,$batch_id){
|
|
|
+
|
|
|
if(empty($res)||empty($userInfo)||empty($batch_id)){
|
|
|
Render('', '7003',lang('Errors','Api')->get('error-7003'));
|
|
|
}
|
|
|
@@ -138,6 +203,8 @@ class Betorder extends BaseController{
|
|
|
$gamedate = $this->Group_ball($res[$k]);
|
|
|
$this->Simplex_bet_insert($gamedate,$userInfo,$k,$batch_id);
|
|
|
}
|
|
|
+
|
|
|
+ return $odds_ids;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -219,9 +286,11 @@ class Betorder extends BaseController{
|
|
|
$this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$bet_money,$OrderID);//反水
|
|
|
}
|
|
|
}
|
|
|
- public function Simplex_bet_insert($data,$userInfo,$game_code,$batch_id){
|
|
|
+ //按赛事分组 一个赛事一个注单
|
|
|
+ public function Simplex_bet_insert_v1($data,$userInfo,$game_code,$batch_id){
|
|
|
+
|
|
|
if(empty($data)||empty($userInfo)||empty($game_code)){
|
|
|
- Render('', '7003',lang('Errors','Api')->get('error-7003'));
|
|
|
+ Render('', '7003',lang('Errors','Api')->get('error-7003'));
|
|
|
}
|
|
|
foreach($data as $k => $v){
|
|
|
$OrderID = OrderID('S');//生成订单ID
|
|
|
@@ -301,7 +370,7 @@ class Betorder extends BaseController{
|
|
|
$order['single_result'] = json_encode($json_single_result);
|
|
|
}
|
|
|
//如果是滚球投注,追加字段
|
|
|
- if($is_rolling == 1){
|
|
|
+ if($is_rolling == 1 and $game_code == 'zq'){
|
|
|
$order['roll_ratify'] = 2;//未审核滚球投注
|
|
|
}
|
|
|
$insert = lm("MoneyBuySimplex",'Api')->insert($order);
|
|
|
@@ -316,8 +385,179 @@ class Betorder extends BaseController{
|
|
|
$this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$bet_money,$OrderID);//反水
|
|
|
}
|
|
|
}
|
|
|
+ //无需按赛事分组
|
|
|
+ public function Simplex_bet_insert($data,$userInfo,$game_code,$batch_id){
|
|
|
+
|
|
|
+ if(empty($data)||empty($userInfo)||empty($game_code)){
|
|
|
+ Render('', '7003',lang('Errors','Api')->get('error-7003'));
|
|
|
+ }
|
|
|
+ foreach($data as $k => $v){
|
|
|
+ $OrderID = OrderID('S');//生成订单ID
|
|
|
+ $UUID = UUID(); //生成信息ID
|
|
|
+ $bet_money = 0; //赛事总投注额
|
|
|
+ $prize_money = 0; //可赢额
|
|
|
+ //====处理 投注数据
|
|
|
+ //是否是冠军投注,如果==0 则为冠军投注
|
|
|
+ $is_champion = 0;
|
|
|
+ if($v['match_id'] == 0){
|
|
|
+ $is_champion = 1;
|
|
|
+ }
|
|
|
+ //获取联赛id lg_id
|
|
|
+ $lg_id = $v['lg_id'];
|
|
|
+ $bet_money = $v['bet_amount'];
|
|
|
+ //计算每个投注玩法下的可赢金额
|
|
|
+ $prize_money = $v['odds']* $v['bet_amount'];
|
|
|
+ //是否是滚球投注
|
|
|
+ $is_rolling = 0;
|
|
|
+ //追加滚球投注时 赛事进行时间
|
|
|
+ $roll_time = 0;
|
|
|
+ //主队得分
|
|
|
+ $home_score = 0;
|
|
|
+ //客队得分
|
|
|
+ $guest_score = 0;
|
|
|
+ if($v['oddsType']=='StRollBall'){
|
|
|
+ $is_rolling = 1;
|
|
|
+ $roll_time=$v['roll_time']?:'';
|
|
|
+ $home_score = $v['home_score']?:0;
|
|
|
+ $guest_score = $v['guest_score']?:0;
|
|
|
+ }
|
|
|
+ //===追加各球类其他状态码===
|
|
|
+ //即将
|
|
|
+ if($v['oddsType']=='StSoon'){
|
|
|
+ $is_rolling = 2;
|
|
|
+ }
|
|
|
+ //今日
|
|
|
+ if($v['oddsType']=='StToday'){
|
|
|
+ $is_rolling = 3;
|
|
|
+ }
|
|
|
+ //早盘
|
|
|
+ if($v['oddsType']=='StMorningPlate'){
|
|
|
+ $is_rolling = 4;
|
|
|
+ }
|
|
|
+ //串场
|
|
|
+ if($v['oddsType']=='StStringScene'){
|
|
|
+ $is_rolling = 5;
|
|
|
+ }
|
|
|
+ //冠军
|
|
|
+ if($v['oddsType']=='StChampion'){
|
|
|
+ $is_rolling = 6;
|
|
|
+ }
|
|
|
+ //首页
|
|
|
+ if($v['oddsType']=='home'){
|
|
|
+ $is_rolling = 7;
|
|
|
+ }
|
|
|
+
|
|
|
+ //===end===
|
|
|
+ $matchData =[
|
|
|
+ 'odds_id' =>$v['id'],
|
|
|
+ 'home_team' => $v['home_team'],
|
|
|
+ 'guest_team' => $v['guest_team'],
|
|
|
+ 'condition' => $v['condition'],
|
|
|
+ 'odds' => $v['odds'],
|
|
|
+ 'odds_code' => $v['odds_code'],
|
|
|
+ 'p_code' => $v['p_code'],
|
|
|
+ 'odds_only' => $v['odds_only'],
|
|
|
+ 'match_id' => $v['match_id'],
|
|
|
+ 'game_code' => $game_code,
|
|
|
+ 'lg_id' => $lg_id,
|
|
|
+ 'batch_id' => $batch_id,
|
|
|
+ 'bet_type' => 1,
|
|
|
+ 'bet_money' => $bet_money,
|
|
|
+ 'ctime' => $this->time,
|
|
|
+ 'utime' => $this->time,
|
|
|
+ 'is_rolling' =>$is_rolling,
|
|
|
+ 'is_champion' => $is_champion?:0,//1 冠军投注 0普通赛事投注
|
|
|
+ 'order_id'=>$OrderID,//追加所属订单id
|
|
|
+ 'roll_time'=>$roll_time,//追加滚球投注时 赛事进行时间
|
|
|
+ 'home_score'=>$home_score,//主队得分
|
|
|
+ 'guest_score'=>$guest_score,//客队得分
|
|
|
+ ];
|
|
|
+
|
|
|
+ //插入数据源
|
|
|
+ $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
|
|
|
+ if(!$moneyBuyMatch){
|
|
|
+ Render('','3205',lang('errors','Api')->get('error-3205'));
|
|
|
+ }
|
|
|
+ //===end===
|
|
|
+ $order = [];
|
|
|
+ $order =[
|
|
|
+ 'info_identity' => $UUID,
|
|
|
+ 'account_name' => $userInfo['account'],
|
|
|
+ 'account_identity' => $userInfo['account_identity'],
|
|
|
+ 'order_id' => $OrderID,//$OrderID,
|
|
|
+ 'game_code' => $game_code,
|
|
|
+ 'batch_id' => $batch_id,
|
|
|
+ 'match_id' => $v['match_id'],
|
|
|
+ 'lg_id' => $lg_id,
|
|
|
+ 'game_no' => "",
|
|
|
+ 'prize_money'=> $prize_money,
|
|
|
+ 'money' => $bet_money, //投注金额
|
|
|
+ 'money_time' => $this->time,
|
|
|
+ 'is_champion' => $is_champion?:0,//1 冠军投注 0普通赛事投注
|
|
|
+ ];
|
|
|
+
|
|
|
+ //如果是冠军投注,追加字段
|
|
|
+ if($is_champion == 1){
|
|
|
+ $json_single_result = [
|
|
|
+ 'lg_id'=> '',
|
|
|
+ 'game_name' => '',
|
|
|
+ 'result' => '',
|
|
|
+ 'updatetime' => '',
|
|
|
+ ];
|
|
|
+ $order['single_result'] = json_encode($json_single_result);
|
|
|
+ }
|
|
|
+ //如果是滚球投注,追加字段
|
|
|
+ if($is_rolling == 1 and $game_code == 'zq'){
|
|
|
+ $order['roll_ratify'] = 2;//未审核滚球投注
|
|
|
+ }
|
|
|
+ $insert = lm("MoneyBuySimplex",'Api')->insert($order);
|
|
|
+ if(!$insert){
|
|
|
+ Render('','3205',lang('errors','Api')->get('error-3205'));
|
|
|
+ }
|
|
|
+ $insertMoney = $this->M->insertMoney($userInfo['account_identity'],$bet_money,$OrderID,1,"",$UUID,$userInfo);
|
|
|
+
|
|
|
+ if($insertMoney!=1){
|
|
|
+ Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
|
|
|
+ }
|
|
|
+ $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$bet_money,$OrderID);//反水
|
|
|
+
|
|
|
+ //===追加写处理队列===
|
|
|
+ //订单号 比赛id188 开赛日期时间 比赛状态(早盘,今日,串场,滚球), 父级玩法, 子级玩法,排序
|
|
|
+ //获取开赛时间
|
|
|
+ //根据球类代码 获取相关model
|
|
|
+ $models = $this->commonFunction->getModels($v['ballId']);
|
|
|
+ $model_match = $models['model_match'];
|
|
|
+ $info = lm($model_match,'Sports')
|
|
|
+ ->select('match_date','match_time','match_identity')
|
|
|
+ ->where('id',$v['match_id'])
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ $match_time = $info->match_date.' '.$info->match_time;
|
|
|
+
|
|
|
+ $orderData = [
|
|
|
+ 'order_type'=>1,//订单类型 1单式 2串式
|
|
|
+ 'order_id'=>$OrderID,//订单ID
|
|
|
+ 'bet_money'=>$bet_money,//投注金额
|
|
|
+ 'matchData'=>[
|
|
|
+ [
|
|
|
+ 'game_code'=>$v['ballId'],//球类代码
|
|
|
+ 'other_match_id'=>$v['others_match_id'],//第三方赛事id 188
|
|
|
+ 'match_id'=>$v['match_id'],//本地赛事id
|
|
|
+ 'match_uuid'=> $info->match_identity,//赛事uuid
|
|
|
+ 'odds_code'=>$v['odds_code'],//子玩法代码
|
|
|
+ 'p_code'=>$v['p_code'],//父玩法代码
|
|
|
+ 'match_time'=>$match_time,//开赛时间
|
|
|
+ 'match_type'=>$is_rolling,//比赛盘口
|
|
|
+ 'sort'=>$v['sort'],//排序
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ $this->commonFunction->setOrderQueue($orderData);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function Bet(){
|
|
|
+
|
|
|
/*
|
|
|
// 模拟单式数据
|
|
|
$get_data = [
|
|
|
@@ -325,64 +565,64 @@ class Betorder extends BaseController{
|
|
|
[
|
|
|
'type'=>1,
|
|
|
'index'=>0,
|
|
|
- 'bet_amount'=>1,
|
|
|
+ 'bet_amount'=>100,
|
|
|
],
|
|
|
[
|
|
|
'type'=>1,
|
|
|
'index'=>1,
|
|
|
- 'bet_amount'=>1,
|
|
|
+ 'bet_amount'=>100,
|
|
|
],
|
|
|
[
|
|
|
[
|
|
|
- 'id'=>226063,
|
|
|
- 'home_team'=>'内蒙古草上飞',
|
|
|
- 'guest_team'=>'吉林百嘉',
|
|
|
- 'name'=>'内蒙古草上飞',
|
|
|
- 'odds'=>0.81,
|
|
|
- 'match_id'=>0,
|
|
|
- 'condition'=>'0.5/1',
|
|
|
+ 'id'=>10350565,
|
|
|
+ 'home_team'=>'什鲁斯伯里',
|
|
|
+ 'guest_team'=>'彼德堡',
|
|
|
+ 'name'=>'大',
|
|
|
+ 'odds'=>1.09,
|
|
|
+ 'match_id'=>1463,
|
|
|
+ 'condition'=>'2.5/3',
|
|
|
'ballId'=>'zq',
|
|
|
- 'odds_code'=>'concede_home',
|
|
|
- 'p_code'=>'concede',
|
|
|
- 'play_name'=>'让球',
|
|
|
+ 'odds_code'=>'gsb',
|
|
|
+ 'p_code'=>'GS',
|
|
|
+ 'play_name'=>'进球大小',
|
|
|
'score'=>0,
|
|
|
'bettingTime'=>date('Y-m-d H:i:s',time()),
|
|
|
- 'odds_only'=>'272af2647b112b7eb337a2ed16753c6f',
|
|
|
- 'lg_id'=>29,
|
|
|
- 'repeat'=>'false',
|
|
|
- 'match_type'=>'StRollBall',//滚球投注
|
|
|
- // 'is_champion'=>1,//是否是冠军联赛
|
|
|
+ 'odds_only'=>'6a003dec710a42849a82dd1ea978f572',
|
|
|
+ 'lg_id'=>17,
|
|
|
+ 'match_type'=>'',//滚球投注
|
|
|
+ 'odds_id'=>10350565,
|
|
|
+ 'repeat'=>'true',
|
|
|
+ 'is_champion'=>0,//是否是冠军联赛
|
|
|
],
|
|
|
[
|
|
|
- 'id'=>2260632,
|
|
|
- 'home_team'=>'内蒙古草上飞1',
|
|
|
- 'guest_team'=>'吉林百嘉2',
|
|
|
- 'name'=>'内蒙古草上飞',
|
|
|
- 'odds'=>0.81,
|
|
|
- 'match_id'=>1249,
|
|
|
- 'condition'=>'0.5/1',
|
|
|
+ 'id'=>10781633,
|
|
|
+ 'home_team'=>'什鲁斯伯里',
|
|
|
+ 'guest_team'=>'彼德堡',
|
|
|
+ 'name'=>'彼德堡',
|
|
|
+ 'odds'=>1,
|
|
|
+ 'match_id'=>1463,
|
|
|
+ 'condition'=>'-0/0.5',
|
|
|
'ballId'=>'zq',
|
|
|
- 'odds_code'=>'concede_home',
|
|
|
- 'p_code'=>'concede',
|
|
|
+ 'odds_code'=>'cog',
|
|
|
+ 'p_code'=>'CO',
|
|
|
'play_name'=>'让球',
|
|
|
'score'=>0,
|
|
|
'bettingTime'=>date('Y-m-d H:i:s',time()),
|
|
|
- 'odds_only'=>'272af2647b112b7eb337a2ed16753c6f1',
|
|
|
- 'lg_id'=>29,
|
|
|
- 'repeat'=>'false',
|
|
|
- 'match_type'=>'StRollBall',//滚球投注
|
|
|
+ 'odds_only'=>'390e2b68992587438c0020179abc94f5',
|
|
|
+ 'lg_id'=>17,
|
|
|
+ 'match_type'=>'',//滚球投注
|
|
|
+ 'odds_id'=>10781633,
|
|
|
+ 'repeat'=>'true',
|
|
|
'is_champion'=>0,//是否是冠军联赛
|
|
|
- ],
|
|
|
+ ]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
- 'token'=>'ppWGRW15682541865d79a8eacb0b1',
|
|
|
- 'bet_money'=>900,
|
|
|
- 'bet_money_arr'=>[100,200,300],
|
|
|
-
|
|
|
+ 'token'=>'Zj2aXC15738846155dcf92c78385c',
|
|
|
+ 'bet_money'=>200,
|
|
|
];
|
|
|
-
|
|
|
*/
|
|
|
+
|
|
|
/*
|
|
|
// 模拟串式数据
|
|
|
$get_data = [
|
|
|
@@ -476,7 +716,7 @@ class Betorder extends BaseController{
|
|
|
$bet_money = $_REQUEST['bet_money'];
|
|
|
$token = $_REQUEST['token'];
|
|
|
// $bet_money_arr = $_REQUEST['bet_money_arr'];
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
$data = $get_data['data'];
|
|
|
@@ -519,7 +759,7 @@ class Betorder extends BaseController{
|
|
|
_rollBack();//回滚
|
|
|
print $e->getMessage();
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* token获取用户详情
|
|
|
@@ -663,7 +903,7 @@ class Betorder extends BaseController{
|
|
|
* $userInfo 用户数据
|
|
|
* $batch_id 批次号
|
|
|
*/
|
|
|
- public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
|
|
|
+ public function stringBet__($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
|
|
|
//验证串式投注是否合法
|
|
|
$this->verify_stringType($data_all);
|
|
|
//获取串式 总赛事数量
|
|
|
@@ -764,6 +1004,152 @@ class Betorder extends BaseController{
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+ public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
|
|
|
+ //验证串式投注是否合法
|
|
|
+ $this->verify_stringType($data_all);
|
|
|
+ //获取串式 总赛事数量
|
|
|
+ $groupNum = count($data_all);//总数量
|
|
|
+
|
|
|
+ $orderData = [];
|
|
|
+ foreach ($data_str as $k=>$v){
|
|
|
+ //字符串替换
|
|
|
+ $str = str_ireplace("串","_",$v['type']);
|
|
|
+ //获取type 3_12
|
|
|
+ $after = substr($str,strpos($str,"_")+1);
|
|
|
+ //当前串式 值
|
|
|
+ $sonNum = substr($str,0,strrpos($str,"_"));
|
|
|
+ //获取倍数
|
|
|
+ if((int)$after == 1){
|
|
|
+ $multiple = $this->getMultiple($groupNum,(int)$sonNum);
|
|
|
+ }else{
|
|
|
+ $multiple =(int)$after;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当前串式投注金额及可赢金额
|
|
|
+ if($after == 1){
|
|
|
+ $money_all = $this->getmakeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
|
|
|
+ }else{
|
|
|
+ $money_all = $this->getStrAllMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
|
|
|
+ }
|
|
|
+ //投注金额
|
|
|
+ $moneyData = $money_all['moneyData'];
|
|
|
+ //可赢金额
|
|
|
+ $prize_money = $money_all['prize_money'];
|
|
|
+ $uuid = UUID();
|
|
|
+ $orderID = OrderID('T');
|
|
|
+
|
|
|
+ $orderData[$k]['info_identity'] = $uuid;
|
|
|
+ $orderData[$k]['account_name'] = $userInfo['account'];
|
|
|
+ $orderData[$k]['account_identity'] = $userInfo['account_identity'];
|
|
|
+ $orderData[$k]['order_id'] = $orderID;
|
|
|
+ $orderData[$k]['game_no'] = "";
|
|
|
+ $orderData[$k]['money'] = $moneyData;//$pay_money//总投注金额
|
|
|
+ $orderData[$k]['money_time'] = $this->time;//下注时间
|
|
|
+ $orderData[$k]['prize_money'] = $prize_money;//$expect_money ;//预期总可赢金额
|
|
|
+ $orderData[$k]['str_type'] = $v['type'];//串式类型
|
|
|
+ $orderData[$k]['batch_id'] = $batch_id;//批次号
|
|
|
+ $orderData[$k]['wait_match_num'] = count($data_all);//批次号
|
|
|
+
|
|
|
+ //写资金变动表
|
|
|
+ $insertMoney = $this->M->insertMoney($userInfo['account_identity'],$moneyData,$orderID,1,"",$uuid,$userInfo);
|
|
|
+ if($insertMoney!=1){
|
|
|
+ Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
|
|
|
+ }
|
|
|
+ $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$moneyData,$orderID);//反水
|
|
|
+
|
|
|
+ //===处理赛事数据===
|
|
|
+ foreach ($data_all as $kk=>$vv){
|
|
|
+ $getModels = $this->commonFunction->getModels($vv['ballId']);
|
|
|
+ $model_match = $getModels['model_match'];
|
|
|
+
|
|
|
+ //获取是否是滚球投注
|
|
|
+ $is_rolling = 0;
|
|
|
+
|
|
|
+ if($vv['match_type'] == 'StRollBall'){
|
|
|
+ $is_rolling = 1;
|
|
|
+ }
|
|
|
+ $matchData[] = [
|
|
|
+ 'batch_id'=>$batch_id,
|
|
|
+ 'odds_id'=>$vv['id'],
|
|
|
+ 'home_team'=>$vv['home_team'],
|
|
|
+ 'guest_team'=>$vv['guest_team'],
|
|
|
+ 'condition'=>$vv['condition'],
|
|
|
+ 'odds'=>$vv['odds'],
|
|
|
+ 'odds_code'=>$vv['odds_code'],
|
|
|
+ 'p_code'=>$vv['p_code'],
|
|
|
+ 'odds_only'=>$vv['odds_only'],
|
|
|
+ 'status'=>0,
|
|
|
+ 'match_id'=>$vv['match_id'],
|
|
|
+ 'game_code'=>$vv['ballId'],
|
|
|
+ 'lg_id'=> $vv['lg_id'],
|
|
|
+ 'ctime'=>$this->time,//写入时间
|
|
|
+ 'utime' => $this->time,
|
|
|
+ 'bet_type'=>2,
|
|
|
+ 'is_rolling'=>$is_rolling,
|
|
|
+ 'order_id'=> $orderID,
|
|
|
+ ];
|
|
|
+
|
|
|
+ //=====拼接赛事数据===
|
|
|
+ //获取开赛时间
|
|
|
+ //根据球类代码 获取相关model
|
|
|
+ $models = $this->commonFunction->getModels($vv['ballId']);
|
|
|
+ $model_match = $models['model_match'];
|
|
|
+ $info = lm($model_match,'Sports')
|
|
|
+ ->select('match_date','match_time','match_identity')
|
|
|
+ ->where('id',$vv['match_id'])
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ $match_time = $info->match_date.' '.$info->match_time;
|
|
|
+ $match_data_order[] = [
|
|
|
+ 'game_code'=>$vv['ballId'],//球类代码
|
|
|
+ 'other_match_id'=>$vv['others_match_id'],//第三方赛事id 188
|
|
|
+ 'match_id'=>$vv['match_id'],//本地赛事id
|
|
|
+ 'match_uuid'=> $info->match_identity,//赛事uuid
|
|
|
+ 'odds_code'=>$vv['odds_code'],//子玩法代码
|
|
|
+ 'p_code'=>$vv['p_code'],//父玩法代码
|
|
|
+ 'match_time'=>$match_time,//开赛时间
|
|
|
+ 'match_type'=>$is_rolling,//比赛盘口
|
|
|
+ 'sort'=>$vv['sort'],//排序
|
|
|
+ ];
|
|
|
+ //===end===
|
|
|
+ }
|
|
|
+
|
|
|
+ //===追加写处理队列===
|
|
|
+ //订单号 比赛id188 开赛日期时间 比赛状态(早盘,今日,串场,滚球), 父级玩法, 子级玩法,排序
|
|
|
+ //赛事去重
|
|
|
+ $match_data_order = $this->commonFunction->array_unset_tt($match_data_order,'match_id');
|
|
|
+ sort($match_data_order);
|
|
|
+
|
|
|
+ $orderData_queue[] = [
|
|
|
+ 'order_type'=>2,//订单类型 1单式 2串式
|
|
|
+ 'order_id'=>$orderID,//订单ID
|
|
|
+ 'bet_money' =>$moneyData,//投注金额
|
|
|
+ 'matchData'=>$match_data_order
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ //写赔率数据表
|
|
|
+ $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
|
|
|
+ if(!$moneyBuyMatch){
|
|
|
+ Render('','3205',lang('errors','Api')->get('error-3205'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //===end===
|
|
|
+
|
|
|
+ //写注单 表
|
|
|
+ $moneyBuy = lm('MoneyBuyStr','Api')->insert($orderData);
|
|
|
+
|
|
|
+ if(!$moneyBuy){
|
|
|
+ Render('','3205',lang('errors','Api')->get('error-3205'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //写队列
|
|
|
+ foreach($orderData_queue as $k=>$v){
|
|
|
+ $this->commonFunction->setOrderQueue($v);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 计算串式投注 倍率
|
|
|
@@ -942,5 +1328,122 @@ class Betorder extends BaseController{
|
|
|
];
|
|
|
Render($data, '1', lang('Tips','Sports')->get('success'));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户撤单操作 接口
|
|
|
+ * 单订单操作
|
|
|
+ */
|
|
|
+ public function reOrder(){
|
|
|
+ //获取球类代码
|
|
|
+ $order_id = $_REQUEST['order_id'];
|
|
|
+ $token = $_REQUEST['token'];
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ if(empty($order_id)){
|
|
|
+ throw new \Exception(Render([], '10001', lang('Tips','Sports')->get('PARAM_ERROR')));
|
|
|
+ }
|
|
|
+
|
|
|
+ _beginTransaction();//开启事务
|
|
|
+ // 单式 S 串式 T
|
|
|
+ if(substr($order_id,0,1) == 'S'){
|
|
|
+ //单式订单 model
|
|
|
+ $order_model = 'money_buy_simplex';
|
|
|
+ }else{
|
|
|
+ //串式订单 model
|
|
|
+ $order_model = 'money_buy_str';
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询订单信息
|
|
|
+ $order_data = lm($order_model,"Commons")
|
|
|
+ ->where('order_id',$order_id)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ //订单不存在
|
|
|
+ if(empty($order_data)) throw new \Exception(Render([], '10030', lang('Tips','Sports')->get('order_null')));
|
|
|
+
|
|
|
+ //订单非投注状态 不可撤单
|
|
|
+ if($order_data->status != 1) throw new \Exception(Render([], '10031', lang('Tips','Sports')->get('order_type_err')));
|
|
|
+ //获取用户数据
|
|
|
+ $userInfo = $this->getAgent($token);
|
|
|
+
|
|
|
+ //验证订单是否属于该用户
|
|
|
+ if($order_data->account_identity != $userInfo['account_identity']) throw new \Exception(Render([], '10025', lang('Tips','Sports')->get('auth_error').':不是该用户的订单'));
|
|
|
+
|
|
|
+ //获取用户账户余额
|
|
|
+ $cash = $userInfo['cash'];
|
|
|
+ //获取订单涉及金额
|
|
|
+ $where = [
|
|
|
+ ['trade_id','=',$order_id],
|
|
|
+ ['status','=',1]
|
|
|
+ ];
|
|
|
+ $odds_money_data = lm('money_details',"Commons")
|
|
|
+ ->select('info_identity','trade_id','account_name','account_identity','money','money_type','money_cash','trade_type','status')
|
|
|
+ ->where($where)
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ if(empty($odds_money_data)) throw new \Exception(Render([], '10026', lang('Tips','Sports')->get('order_money_err')));
|
|
|
+ $odds_money_data = $odds_money_data -> toArray();
|
|
|
+ //获取订单投注金额
|
|
|
+ $odds_money_bet = 0;
|
|
|
+ //获取订单反水金额
|
|
|
+ $odds_money_fs = 0;
|
|
|
+
|
|
|
+ foreach($odds_money_data as $k=>$v){
|
|
|
+ if($v['trade_type'] == 1){
|
|
|
+ $odds_money_bet = $v['money'];
|
|
|
+ }
|
|
|
+ if($v['trade_type'] == 7){
|
|
|
+ $odds_money_fs = $v['money'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新订单状态为已取消
|
|
|
+ $up_order = lm($order_model,"Commons")
|
|
|
+ ->where('order_id',$order_id)
|
|
|
+ ->update(['status'=>3,'use_mark'=>'用户撤单']);
|
|
|
+
|
|
|
+ if($up_order < 1) throw new \Exception(Render([], '10027', lang('Tips','Sports')->get('order_status_up_err')));
|
|
|
+
|
|
|
+ //===退款===
|
|
|
+ //需退回金额 = 投注金额-反水金额
|
|
|
+ $money = abs($odds_money_bet - $odds_money_fs);
|
|
|
+ //用户剩余金额
|
|
|
+ $new_available_cash = $cash + $money;
|
|
|
+
|
|
|
+ //组装新增数据
|
|
|
+ $set_money_data = [
|
|
|
+ 'info_identity' => UUID(),
|
|
|
+ 'trade_id' => $order_id,
|
|
|
+ 'account_name' => $userInfo['account'],
|
|
|
+ 'account_identity' => $userInfo['account_identity'],
|
|
|
+ 'money' => $money,
|
|
|
+ 'money_time' => date("Y-m-d H:i:s", time()),
|
|
|
+ 'money_type' => 1,
|
|
|
+ 'money_cash' => $new_available_cash,
|
|
|
+ 'trade_type' => 3,
|
|
|
+ 'trade_desc' => '用户撤单,退回投注资金:¥'.$money.';订单号:'.$order_id.'',
|
|
|
+ 'status' => 1,
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ //更新用户数据
|
|
|
+ $ret_user = lm('account_detailed',"Commons")
|
|
|
+ ->where('account_identity', $v['account_identity'])
|
|
|
+ ->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
+
|
|
|
+ if($ret_user < 1) throw new \Exception(Render([], '10028', lang('Tips','Sports')->get('up_user_err')));
|
|
|
+
|
|
|
+ //更新用户资金数据
|
|
|
+ $set_money = lm('money_details',"Commons")->insert($set_money_data);
|
|
|
+ if($set_money != true) throw new \Exception(Render([], '10029', lang('Tips','Sports')->get('add_money_err')));
|
|
|
+
|
|
|
+ //===end===
|
|
|
+ _commit();//提交
|
|
|
+ Render('', '1', lang('Tips','Sports')->get('success'));
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ echo $e->getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|