|
|
@@ -14,6 +14,11 @@ use App\Models\MoneyBuyMatchb;
|
|
|
use App\Http\Response\Response;
|
|
|
use App\Http\Model\StZqResult;
|
|
|
|
|
|
+use App\Http\Model\StZqMatch as ZqMatchModel;
|
|
|
+use App\Http\Model\StLqMatch as LqMatchModel;
|
|
|
+use App\Http\Model\StWqMatch as WqMatchModel;
|
|
|
+use App\Http\Model\StBqMatch as BqMatchModel;
|
|
|
+
|
|
|
|
|
|
class SportsNoteList extends BaseModel
|
|
|
{
|
|
|
@@ -1190,7 +1195,6 @@ class SportsNoteList extends BaseModel
|
|
|
}
|
|
|
public static function getOrderData($time=60){
|
|
|
|
|
|
- $time = 100;
|
|
|
$db = new \App\Models\Setinfo();
|
|
|
//获取设定需审核时间 秒
|
|
|
$handle_time = $db->getInfo(1003)['infocontent']?:90;
|
|
|
@@ -1370,9 +1374,9 @@ class SportsNoteList extends BaseModel
|
|
|
/**
|
|
|
* 滚球自动审核 账户资金处理
|
|
|
* v2
|
|
|
- * 处理一个用户下 多个注单退款时的 余额计算
|
|
|
+ * 处理多用户下 多个注单退款时的 余额计算
|
|
|
*/
|
|
|
- public static function HandleMoney_v2($account_identitys=[],$order_ids=[],$orders=[]){
|
|
|
+ public static function HandleMoney_v2($account_identitys=[],$order_ids=[],$orders=[],$type = 0){
|
|
|
|
|
|
//获取 用户 初始余额
|
|
|
$account_money = \App\Models\Account_detailed::whereIn('account_identity',$account_identitys)->SELECT('account_identity','available_cash')->get()->toArray();
|
|
|
@@ -1408,37 +1412,74 @@ class SportsNoteList extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- foreach($orders as $k=>$v){
|
|
|
- //需退回金额 = 投注金额-反水金额
|
|
|
- $money = abs($v['money'] - $v['fanshui']);
|
|
|
- //用户剩余金额
|
|
|
- $new_available_cash = $v['available_cash'] + $money;
|
|
|
- $models = new \App\Models\Money_details();
|
|
|
- $models->info_identity = UUID();
|
|
|
- $models->trade_id = $v['order_id'];
|
|
|
- $models->account_name = $v['account_name'];
|
|
|
- $models->account_identity = $v['account_identity'];
|
|
|
- $models->money = $money;
|
|
|
- $models->money_time = date("Y-m-d H:i:s", time());
|
|
|
- $models->money_type = '1';
|
|
|
+ //滚球注单审核 处理
|
|
|
+ if($type == 0){
|
|
|
+ foreach($orders as $k=>$v){
|
|
|
+ //需退回金额 = 投注金额-反水金额
|
|
|
+ $money = abs($v['money'] - $v['fanshui']);
|
|
|
+ //用户剩余金额
|
|
|
+ $new_available_cash = $v['available_cash'] + $money;
|
|
|
+ $models = new \App\Models\Money_details();
|
|
|
+ $models->info_identity = UUID();
|
|
|
+ $models->trade_id = $v['order_id'];
|
|
|
+ $models->account_name = $v['account_name'];
|
|
|
+ $models->account_identity = $v['account_identity'];
|
|
|
+ $models->money = $money;
|
|
|
+ $models->money_time = date("Y-m-d H:i:s", time());
|
|
|
+ $models->money_type = '1';
|
|
|
+
|
|
|
+ $models->money_cash = $new_available_cash;
|
|
|
+ $models->trade_type = '25';
|
|
|
+ $models->trade_desc = trans('handleOrder.handle_order_auto_fail').',退回投注资金:¥'.$money.';订单号:'.$v['order_id'].'';
|
|
|
+ $models->status = '1';
|
|
|
|
|
|
- $models->money_cash = $new_available_cash;
|
|
|
- $models->trade_type = '25';
|
|
|
- $models->trade_desc = trans('handleOrder.handle_order_auto_fail').',退回投注资金:¥'.$money.';订单号:'.$v['order_id'].'';
|
|
|
- $models->status = '1';
|
|
|
-
|
|
|
- //更新订单数据
|
|
|
- $ret_order = self::where('id', $v['id'])->update(['roll_ratify' => '-1','status' => '2','use_mark'=>$v['use_mark']]);//trans('handleOrder.handle_order_auto_fail')
|
|
|
- if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
+ //更新订单数据
|
|
|
+ $ret_order = self::where('id', $v['id'])->update(['roll_ratify' => '-1','status' => '2','use_mark'=>$v['use_mark']]);//trans('handleOrder.handle_order_auto_fail')
|
|
|
+ if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
|
|
|
- //更新用户数据
|
|
|
- $ret_user = \App\Models\Account_detailed::where('account_identity', $v['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
- if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
+ //更新用户数据
|
|
|
+ $ret_user = \App\Models\Account_detailed::where('account_identity', $v['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
+ if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
|
|
|
- //更新用户资金数据
|
|
|
- if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
+ //更新用户资金数据
|
|
|
+ if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //已取消赛事注单相关处理
|
|
|
+ else{
|
|
|
+ foreach($orders as $k=>$v){
|
|
|
+ //需退回金额 = 投注金额-反水金额
|
|
|
+ $money = abs($v['money'] - $v['fanshui']);
|
|
|
+ //用户剩余金额
|
|
|
+ $new_available_cash = $v['available_cash'] + $money;
|
|
|
+ $models = new \App\Models\Money_details();
|
|
|
+ $models->info_identity = UUID();
|
|
|
+ $models->trade_id = $v['order_id'];//交易id
|
|
|
+ $models->account_name = $v['account_name'];//用户名
|
|
|
+ $models->account_identity = $v['account_identity'];//用户uuid
|
|
|
+ $models->money = $money;//变动金额
|
|
|
+ $models->money_time = date("Y-m-d H:i:s", time());//资金发生时间
|
|
|
+ $models->money_type = '1';//1.增加 2.减少
|
|
|
+
|
|
|
+ $models->money_cash = $new_available_cash;//剩余金额
|
|
|
+ $models->trade_type = '3';//交易类型 3撤单
|
|
|
+ $models->trade_desc = '因赛事取消,退回投注资金:¥'.$money.';订单号:'.$v['order_id'].'';//交易描述
|
|
|
+ $models->status = '1';//1成功 2失败
|
|
|
+
|
|
|
+ //更新订单数据
|
|
|
+ $ret_order = self::where('id', $v['id'])->update(['status' => '2','use_mark'=>'因赛事取消,作废注单']);
|
|
|
+ if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
|
|
|
+ //更新用户数据
|
|
|
+ $ret_user = \App\Models\Account_detailed::where('account_identity', $v['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
+ if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
+
|
|
|
+ //更新用户资金数据
|
|
|
+ if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1458,5 +1499,81 @@ class SportsNoteList extends BaseModel
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 定时处理 已取消赛事相关注单
|
|
|
+ * $time 查询时间 默认60秒
|
|
|
+ */
|
|
|
+ public static function HandleOrderInvalid($time = 60){
|
|
|
+ //获取指定时间内已取消赛事
|
|
|
+ //拼接查询条件
|
|
|
+ $time_unx_max = time() - $time ;//查询最大时间 时间戳 5分钟前
|
|
|
+ $time_unx_min = $time_unx_max - $time;//查询最小时间 时间戳 10分钟前
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ ['utime','>',date('Y-m-d H:i:s',$time_unx_min)],
|
|
|
+ ['utime','<',date('Y-m-d H:i:s',$time_unx_max)],
|
|
|
+ ['status','=',6]
|
|
|
+ ];
|
|
|
+ //足球
|
|
|
+ $ZqMatchData = ZqMatchModel::where($where)->SELECT('id')->get()->toArray();
|
|
|
+ //篮球
|
|
|
+ $LqMatchData = LqMatchModel::where($where)->SELECT('id')->get()->toArray();
|
|
|
+ //网球
|
|
|
+ $WqMatchData = WqMatchModel::where($where)->SELECT('id')->get()->toArray();
|
|
|
+ //棒球
|
|
|
+ $BqMatchData = BqMatchModel::where($where)->SELECT('id')->get()->toArray();
|
|
|
+
|
|
|
+ //===取消注单处理===
|
|
|
+ $moneyBuyMatch = new \App\Models\MoneyBuyMatch();
|
|
|
+
|
|
|
+ //获取赛事下所有单式注单
|
|
|
+ $select = ['money_buy_simplex.id','money_buy_simplex.match_id','money_buy_simplex.account_name','money_buy_simplex.account_identity','money_buy_simplex.order_id','money_buy_simplex.money_time','money_buy_simplex.roll_ratify','money_buy_simplex.money','money_buy_simplex.gain_money','money_buy_match.p_code'];
|
|
|
+ //足球 单式注单
|
|
|
+ $zq_match_order_sim = [];
|
|
|
+ if(!empty($ZqMatchData)){
|
|
|
+ $zqMatch_ids = array_column($ZqMatchData,'id');
|
|
|
+ $zq_match_order_sim = $moneyBuyMatch->allsimplexorder('','zq',$select,$zqMatch_ids)->toArray();
|
|
|
+ //将所有赛事下串式注单 作废 (设置为 平)
|
|
|
+ \App\Models\MoneyBuyMatch::whereIn('match_id',$zqMatch_ids)->where('game_code','zq')->where('bet_type',2)->update(['result'=>2]);
|
|
|
+ }
|
|
|
+ //篮球 单式注单
|
|
|
+ $lq_match_order_sim = [];
|
|
|
+ if(!empty($LqMatchData)){
|
|
|
+ $lqMatch_ids = array_column($LqMatchData,'id');
|
|
|
+ $lq_match_order_sim = $moneyBuyMatch->allsimplexorder('','lq',$select,$lqMatch_ids)->toArray();
|
|
|
+ //将所有赛事下串式注单 作废 (设置为 平)
|
|
|
+ \App\Models\MoneyBuyMatch::whereIn('match_id',$lqMatch_ids)->where('game_code','lq')->where('bet_type',2)->update(['result'=>2]);
|
|
|
+ }
|
|
|
+ //网球 单式注单
|
|
|
+ $wq_match_order_sim = [];
|
|
|
+ if(!empty($WqMatchData)){
|
|
|
+ $wqMatch_ids = array_column($WqMatchData,'id');
|
|
|
+ $wq_match_order_sim = $moneyBuyMatch->allsimplexorder('','wq',$select,$wqMatch_ids)->toArray();
|
|
|
+ //将所有赛事下串式注单 作废 (设置为 平)
|
|
|
+ \App\Models\MoneyBuyMatch::whereIn('match_id',$wqMatch_ids)->where('game_code','wq')->where('bet_type',2)->update(['result'=>2]);
|
|
|
+ }
|
|
|
+ //棒球 单式注单
|
|
|
+ $bq_match_order_sim = [];
|
|
|
+ if(!empty($BqMatchData)){
|
|
|
+ $bqMatch_ids = array_column($BqMatchData,'id');
|
|
|
+ $bq_match_order_sim = $moneyBuyMatch->allsimplexorder('','bq',$select,$bqMatch_ids)->toArray();
|
|
|
+ //将所有赛事下串式注单 作废 (设置为 平)
|
|
|
+ \App\Models\MoneyBuyMatch::whereIn('match_id',$bqMatch_ids)->where('game_code','bq')->where('bet_type',2)->update(['result'=>2]);
|
|
|
+ }
|
|
|
|
|
|
+ //合并单式注单
|
|
|
+ $order_sim = array_merge($zq_match_order_sim,$lq_match_order_sim,$wq_match_order_sim,$bq_match_order_sim);
|
|
|
+ // dd($order_sim);
|
|
|
+
|
|
|
+ //如果有单式注单
|
|
|
+ if(!empty($order_sim)){
|
|
|
+ //用户uuid
|
|
|
+ $account_identitys = array_column($order_sim,'account_identity');
|
|
|
+ //注单id
|
|
|
+ $order_ids = array_column($order_sim,'order_id');
|
|
|
+
|
|
|
+ //注单作废处理
|
|
|
+ self::HandleMoney_v2($account_identitys,$order_ids,$order_sim,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|