|
|
@@ -2481,4 +2481,70 @@ class SportsNoteList extends BaseModel
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新投注数据
|
|
|
+ * $order_type int订单类型 1单式 2串式
|
|
|
+ * $order_id str 订单id
|
|
|
+ * $order_match arr 投注赛事数据
|
|
|
+ */
|
|
|
+ public function upOrder($order_type='',$order_id='',$order_match=[]){
|
|
|
+ //处理单式注单
|
|
|
+ if($order_type == 1){
|
|
|
+ //球类代码
|
|
|
+ $game_code = $order_match[0]['game_code'];
|
|
|
+ //赛事id
|
|
|
+ $match_id = $order_match[0]['match_id'];
|
|
|
+ //投注玩法代码
|
|
|
+ $odds_code = $order_match[0]['odds_code'];
|
|
|
+ //投注赔率值
|
|
|
+ $odds = $order_match[0]['odds'];
|
|
|
+ //投注条件
|
|
|
+ $condition = $order_match[0]['condition'];
|
|
|
+
|
|
|
+ //拼接 投注 赛事查询条件
|
|
|
+ $where_match = [
|
|
|
+ ['bet_type','=',$order_type],
|
|
|
+ ['order_id','=',$order_id],
|
|
|
+ ['game_code','=',$game_code],
|
|
|
+ ['odds_code','=',$odds_code],
|
|
|
+ ];
|
|
|
+ //订单查询条件
|
|
|
+ $where_order = [
|
|
|
+ ['order_id','=',$order_id],
|
|
|
+ ];
|
|
|
+
|
|
|
+ //获取订单数据
|
|
|
+ $orderData = $this->where($where_order)->first();
|
|
|
+ //订单不存在
|
|
|
+ if(empty($orderData)) throw new \Exception(Response::generate('', Response::ORDER_NULL));
|
|
|
+ //订单不是投注状态
|
|
|
+ if($orderData->status != 1) throw new \Exception(Response::generate('订单状态:$orderData->status;', Response::ORDER_STATUS_ERR));
|
|
|
+ //根据新的赔率计算预期中奖金额
|
|
|
+ $orderData->prize_money = $orderData->money * $odds;
|
|
|
+ $orderData->remark = '模拟第三方投注,修正订单';
|
|
|
+ if(!$orderData->save()) throw new \Exception(Response::generate('', Response::ORDER_UP_ERR));
|
|
|
+
|
|
|
+ //更新投注详情数据
|
|
|
+ $match_up = [
|
|
|
+ 'utime'=>date("Y-m-d H:i:s", time()),//更新时间
|
|
|
+ 'condition'=>$condition,//投注条件
|
|
|
+ 'odds' =>$odds,//投注赔率
|
|
|
+ ];
|
|
|
+ $ret_money_buy_match = \App\Models\MoneyBuyMatch::where('order_id',$order_id)->update($match_up);
|
|
|
+ //订单详情更新失败
|
|
|
+ if($ret_money_buy_match < 1) throw new \Exception(Response::generate('', Response::ORDER_UP_XQ_ERR));
|
|
|
+ }
|
|
|
+ //处理串式订单
|
|
|
+ else if($order_type == 2){
|
|
|
+ throw new \Exception(Response::generate('串式订单:', Response::WAIT_FOR));
|
|
|
+
|
|
|
+ }
|
|
|
+ //订单类型错误
|
|
|
+ else{
|
|
|
+ throw new \Exception(Response::generate('', Response::ORDER_TYPE_ERR));
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
}
|