|
|
@@ -62,12 +62,12 @@ class MoneyBuy extends Model {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 投注记录
|
|
|
+ * 单式投注记录
|
|
|
*
|
|
|
* @access public
|
|
|
* @return String
|
|
|
*/
|
|
|
- public function bettingRecord()
|
|
|
+ public function singleBetRecord()
|
|
|
{
|
|
|
// 获取用户信息
|
|
|
$accountManagerClass = new AccountManager;
|
|
|
@@ -75,133 +75,196 @@ class MoneyBuy extends Model {
|
|
|
if (empty($userInfo['identity'])) {
|
|
|
Render([], '2001', lang('Common','Api') -> get('user does login'));
|
|
|
}
|
|
|
- $moneyBuyWhere = array();
|
|
|
// 用户ID
|
|
|
- $moneyBuyWhere['account_identity'] = $userInfo['identity'];
|
|
|
- // 游戏名称英文
|
|
|
- if (!empty($_POST['game'])) {
|
|
|
- $moneyBuyWhere['game_name'] = $_POST['game'];
|
|
|
+ $moneyBuySpxWhere['account_identity'] = $userInfo['identity'];
|
|
|
+ // 时间区间
|
|
|
+ $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
|
|
|
+ $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
|
|
|
+ $moneyBuySpxBetween = ['money_time' => [$startTime, $endTime]];
|
|
|
+ $moneyBuySpxMdl = lm('money_buy_simplex', "commons");
|
|
|
+ // 获取订单记录
|
|
|
+ $moneyBuySpxSlt = ['batch_id'];
|
|
|
+ $getMoneyBuySpx = $moneyBuySpxMdl -> moneyBuySimplex($moneyBuySpxSlt, $moneyBuySpxWhere, $moneyBuySpxBetween, '', '', 1);
|
|
|
+ // 获取全部订单id
|
|
|
+ $moneyBuyMthOr = [];
|
|
|
+ $allBatchId = array_unique($getMoneyBuySpx, SORT_REGULAR);
|
|
|
+ foreach ($allBatchId as $key => $value) {
|
|
|
+ $moneyBuyMthOr[0][$key][0] = 'batch_id';
|
|
|
+ $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
|
|
|
}
|
|
|
- // 下注时间
|
|
|
- //$moneyBuyWhere['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
|
|
|
- // 游戏期号
|
|
|
- if (!empty($_POST['no'])) {
|
|
|
- $moneyBuyWhere['game_no'] = $_POST['no'];
|
|
|
+ $moneyBuyMthWhere['bet_type'] = 1;
|
|
|
+ // 输赢
|
|
|
+ if (!empty($_POST['result']) && $_POST['result'] == 1) {
|
|
|
+ $moneyBuyMthOr[1][0][0] = 'result';
|
|
|
+ $moneyBuyMthOr[1][0][1] = 1;
|
|
|
+ $moneyBuyMthOr[1][1][0] = 'result';
|
|
|
+ $moneyBuyMthOr[1][1][1] = 3;
|
|
|
+ $moneyBuyMthOr[1][2][0] = 'result';
|
|
|
+ $moneyBuyMthOr[1][2][1] = 2;
|
|
|
+ } elseif (!empty($_POST['result']) && $_POST['result'] == 2) {
|
|
|
+ $moneyBuyMthOr[1][0][0] = 'result';
|
|
|
+ $moneyBuyMthOr[1][0][1] = -1;
|
|
|
+ $moneyBuyMthOr[1][1][0] = 'result';
|
|
|
+ $moneyBuyMthOr[1][1][1] = 4;
|
|
|
}
|
|
|
- // 开奖状态
|
|
|
- if (!empty($_POST['status'])) {
|
|
|
- $moneyBuyWhere['game_status'] = $_POST['status'];
|
|
|
+ // 当前页
|
|
|
+ $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
|
|
|
+ // 分页大小
|
|
|
+ $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
|
|
|
+ // 起始查询位置
|
|
|
+ $begin = ($currentPage - 1) * $pageSize;
|
|
|
+ // 获取注单
|
|
|
+ $moneyBuyMthMdl = lm('Money_buy_match', "commons");
|
|
|
+ $moneyBuyMthSlt = ['status', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'game_type', 'money_buy_match.odds_code'];
|
|
|
+ $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
|
|
|
+ $allCount = $moneyBuyMthMdl -> moneyBuyMatchTotal($moneyBuyMthWhere, $moneyBuyMthOr);
|
|
|
+ // 获取可加注所需要的查询条件
|
|
|
+ $commonFunction = C() -> get('commonFunction');
|
|
|
+ $stOddsWheres = [];
|
|
|
+ foreach ($getMoneyBuyMth as $key => $value) {
|
|
|
+ $match_id = $value -> match_id;
|
|
|
+ $odds_code = $value -> odds_code;
|
|
|
+ $gameType = $value -> game_type;
|
|
|
+ $where = [
|
|
|
+ 'match_id' => $match_id,
|
|
|
+ 'odds_code' => $odds_code,
|
|
|
+ ];
|
|
|
+ // 判断是否重复
|
|
|
+ if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
|
|
|
+ $stOddsWheres[$gameType][] = $where;
|
|
|
+ }
|
|
|
}
|
|
|
- // 序号
|
|
|
- if (!empty($_POST['id'])) {
|
|
|
- $moneyBuyWhere['id'] = $_POST['id'];
|
|
|
+ // 查询数据下所有可加注的游戏
|
|
|
+ $stOddsModel = lm('stOdds','commons');
|
|
|
+ $stOddsSelect = ['match_id', 'odds_code'];
|
|
|
+ $getSstOdds = [];
|
|
|
+ // 循环查询每个运动的可加注游戏 注:由于查询不同表所以必须循环查询
|
|
|
+ foreach ($stOddsWheres as $key => $value) {
|
|
|
+ if ($value) {
|
|
|
+ $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 循环添加玩法和判断玩法是否可加注
|
|
|
+ foreach ($getMoneyBuyMth as $key => $value) {
|
|
|
+ $typeSstOdds = $getSstOdds[$value -> game_type];
|
|
|
+ $thisSstOdds = [
|
|
|
+ 'match_id' => $value -> match_id,
|
|
|
+ 'odds_code' => $value -> odds_code,
|
|
|
+ ];
|
|
|
+ // 判断如果在数组中则为可加注
|
|
|
+ if (!!$commonFunction->judgeEqual($thisSstOdds, $typeSstOdds)) {
|
|
|
+ $getMoneyBuyMth[$key] -> addBet = 0;
|
|
|
+ } else {
|
|
|
+ $getMoneyBuyMth[$key] -> addBet = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取记录总数
|
|
|
+ $result['total'] = $allCount;
|
|
|
+ $result['list'] = $getMoneyBuyMth;
|
|
|
+ // 总页数计算
|
|
|
+ $result['countPage'] = ceil($result['total'] / $pageSize);
|
|
|
+ $result['currentPage'] = $currentPage;
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 串式投注记录
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ public function stringBetRecord()
|
|
|
+ {
|
|
|
+ // 获取用户信息
|
|
|
+ $accountManagerClass = new AccountManager;
|
|
|
+ $userInfo = $accountManagerClass -> getCurrentUser();
|
|
|
+ if (empty($userInfo['identity'])) {
|
|
|
+ Render([], '2001', lang('Common','Api') -> get('user does login'));
|
|
|
}
|
|
|
- // 订单id
|
|
|
- if (!empty($_POST['order_id'])) {
|
|
|
- $moneyBuyWhere['order_id'] = $_POST['order_id'];
|
|
|
+ // 用户ID
|
|
|
+ $moneyBuyStrWhere['account_identity'] = $userInfo['identity'];
|
|
|
+ // 输赢
|
|
|
+ if (!empty($_POST['result'])) {
|
|
|
+ $moneyBuyStrWhere['game_status'] = $_POST['result'];
|
|
|
}
|
|
|
// 时间区间
|
|
|
$startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
|
|
|
$endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
|
|
|
- $moneyBuyBetween = [$startTime, $endTime];
|
|
|
+ $moneyBuyStrBetween = ['money_time' => [$startTime, $endTime]];
|
|
|
+ $moneyBuyStrMdl = lm('money_buy_str', "commons");
|
|
|
// 当前页
|
|
|
$currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
|
|
|
// 分页大小
|
|
|
$pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
|
|
|
// 起始查询位置
|
|
|
$begin = ($currentPage - 1) * $pageSize;
|
|
|
- $moneyBuy = lm('money_buy', "commons");
|
|
|
- $moneyBuyStr = lm('money_buy_str', "commons");
|
|
|
- // 获取投注记录
|
|
|
- $moneyBuySelect = ['game_status', 'money', 'codes', 'money_time'];
|
|
|
- $getMoneyBuy = $moneyBuy -> moneyBuy($moneyBuySelect, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
|
|
|
- $moneyBuyStrSelect = ['game_status', 'money', 'bet_str_all', 'money_time'];
|
|
|
- $getMoneyBuyStr = $moneyBuyStr -> moneyBuyStr($moneyBuyStrSelect, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
|
|
|
- // 两数组重组排序
|
|
|
- $allMoneyBuy = [];
|
|
|
- $allCount = count($getMoneyBuy) + count($getMoneyBuyStr);
|
|
|
- $n = 0;
|
|
|
- $m = 0;
|
|
|
- for ($i = 1; $i <= $allCount; $i++) {
|
|
|
- if ($getMoneyBuy[$n]->money_time >= $getMoneyBuyStr[$m]->money_time) {
|
|
|
- $allMoneyBuy[] = $getMoneyBuy[$n];
|
|
|
- $n++;
|
|
|
- } else {
|
|
|
- $allMoneyBuy[] = $getMoneyBuyStr[$m];
|
|
|
- $m++;
|
|
|
- }
|
|
|
- }
|
|
|
- // 获取游戏类型
|
|
|
- $StGameTypeModel = lm('StGameType','commons');
|
|
|
- $getGameTypeWhere['status'] = 1;
|
|
|
- $getGameTypeSelect = ['game_code'];
|
|
|
- $getGameType = $StGameTypeModel -> getGameType($getGameTypeSelect, $getGameTypeWhere);
|
|
|
- $stOddsWheres = [];
|
|
|
- foreach ($getGameType as $value) {
|
|
|
- $stOddsWheres[$value['game_code']] = '';
|
|
|
+ // 获取订单记录
|
|
|
+ $moneyBuyStrSlt = ['batch_id', 'money'];
|
|
|
+ $getMoneyBuyStr = $moneyBuyStrMdl -> moneyBuyStr($moneyBuyStrSlt, $moneyBuyStrWhere, $moneyBuyStrBetween, $begin, $pageSize, 1);
|
|
|
+ $allCount = $moneyBuyStrMdl -> moneyBuyStrTotal($moneyBuyStrWhere, $moneyBuyStrBetween);
|
|
|
+ // 获取全部订单id
|
|
|
+ $moneyBuyMthOr = [];
|
|
|
+ $allBatchId = array_unique($getMoneyBuyStr, SORT_REGULAR);
|
|
|
+ foreach ($allBatchId as $key => $value) {
|
|
|
+ $moneyBuyMthOr[0][$key][0] = 'batch_id';
|
|
|
+ $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
|
|
|
}
|
|
|
+ $moneyBuyMthWhere['bet_type'] = 2;
|
|
|
+ // 获取注单
|
|
|
+ $moneyBuyMthMdl = lm('Money_buy_match', "commons");
|
|
|
+ $moneyBuyMthSlt = ['status', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'batch_id', 'game_type', 'money_buy_match.odds_code'];
|
|
|
+ $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
|
|
|
// 获取可加注所需要的查询条件
|
|
|
- foreach ($allMoneyBuy as $key => $value) {
|
|
|
- $codeInfo = [];
|
|
|
- if ($value->codes) {
|
|
|
- $codeInfo = json_decode($value->codes);
|
|
|
- } elseif ($value->bet_str_all) {
|
|
|
- $codeInfo = json_decode($value->bet_str_all);
|
|
|
- }
|
|
|
- foreach ($codeInfo as $k => $v) {
|
|
|
- $match_id = $v->match_id;
|
|
|
- $odds_code = $v->odds_code;
|
|
|
- $ballId = $v->ballId;
|
|
|
- $where = [
|
|
|
- 'match_id' => $match_id,
|
|
|
- 'odds_code' => $odds_code,
|
|
|
- ];
|
|
|
- // 判断是否重复
|
|
|
- if(!judgeEqual($where, $stOddsWheres[$ballId])){
|
|
|
- $stOddsWheres[$ballId][] = $where;
|
|
|
- }
|
|
|
+ $commonFunction = C() -> get('commonFunction');
|
|
|
+ $stOddsWheres = [];
|
|
|
+ foreach ($getMoneyBuyMth as $key => $value) {
|
|
|
+ $match_id = $value -> match_id;
|
|
|
+ $odds_code = $value -> odds_code;
|
|
|
+ $gameType = $value -> game_type;
|
|
|
+ $where = [
|
|
|
+ 'match_id' => $match_id,
|
|
|
+ 'odds_code' => $odds_code,
|
|
|
+ ];
|
|
|
+ // 判断是否重复
|
|
|
+ if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
|
|
|
+ $stOddsWheres[$gameType][] = $where;
|
|
|
}
|
|
|
}
|
|
|
// 查询数据下所有可加注的游戏
|
|
|
$stOddsModel = lm('stOdds','commons');
|
|
|
$stOddsSelect = ['match_id', 'odds_code'];
|
|
|
$getSstOdds = [];
|
|
|
+ // 循环查询每个运动的可加注游戏 注:由于查询不同表所以必须循环查询
|
|
|
foreach ($stOddsWheres as $key => $value) {
|
|
|
if ($value) {
|
|
|
- $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key)->toArray();;
|
|
|
+ $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
|
|
|
}
|
|
|
}
|
|
|
// 循环添加玩法和判断玩法是否可加注
|
|
|
- $stOddsCodeModel = lm('StOddsCode','commons');
|
|
|
- foreach ($allMoneyBuy as $key => $value) {
|
|
|
- $codeInfo = [];
|
|
|
- if ($value->codes) {
|
|
|
- $codeInfo = json_decode($value->codes);
|
|
|
- } elseif ($value->bet_str_all) {
|
|
|
- $codeInfo = json_decode($value->bet_str_all);
|
|
|
+ foreach ($getMoneyBuyMth as $key => $value) {
|
|
|
+ $typeSstOdds = $getSstOdds[$value -> game_type];
|
|
|
+ $thisSstOdds = [
|
|
|
+ 'match_id' => $value -> match_id,
|
|
|
+ 'odds_code' => $value -> odds_code,
|
|
|
+ ];
|
|
|
+ // 判断如果在数组中则为可加注
|
|
|
+ if (!!$commonFunction->judgeEqual($thisSstOdds, $typeSstOdds)) {
|
|
|
+ $getMoneyBuyMth[$key] -> addBet = 0;
|
|
|
+ } else {
|
|
|
+ $getMoneyBuyMth[$key] -> addBet = 1;
|
|
|
}
|
|
|
- foreach ($codeInfo as $k => $v) {
|
|
|
- $stOddsCodeWhere['odds_code'] = $v->odds_code;
|
|
|
- // 添加玩法
|
|
|
- $gameType = $stOddsCodeModel -> stOddsCode($stOddsCodeWhere);
|
|
|
- $codeInfo[$k]->gameType = $gameType;
|
|
|
- $typeSstOdds = $getSstOdds[$v->ballId];
|
|
|
- $thisSstOdds = [
|
|
|
- 'match_id' => $v->match_id,
|
|
|
- 'odds_code' => $v->odds_code,
|
|
|
- ];
|
|
|
- // 判断如果在数组中则为可加注
|
|
|
- if (!judgeEqual($thisSstOdds, $typeSstOdds)) {
|
|
|
- $codeInfo[$k]->addBet = 0;
|
|
|
- } else {
|
|
|
- $codeInfo[$k]->addBet = 1;
|
|
|
+ }
|
|
|
+ foreach ($getMoneyBuyStr as $key => $value) {
|
|
|
+ foreach ($getMoneyBuyMth as $k => $v) {
|
|
|
+ if ($value['batch_id'] == $v['batch_id']) {
|
|
|
+ $getMoneyBuyStr[$key]['money_buy'][$k] = $v;
|
|
|
}
|
|
|
}
|
|
|
- $allMoneyBuy[$key]->codes = json_encode($codeInfo);
|
|
|
}
|
|
|
// 获取记录总数
|
|
|
$result['total'] = $allCount;
|
|
|
- $result['list'] = $allMoneyBuy;
|
|
|
+ $result['list'] = $getMoneyBuyStr;
|
|
|
// 总页数计算
|
|
|
$result['countPage'] = ceil($result['total'] / $pageSize);
|
|
|
$result['currentPage'] = $currentPage;
|
|
|
@@ -242,7 +305,7 @@ class MoneyBuy extends Model {
|
|
|
// 获取盈亏记录
|
|
|
$result['list'] = $moneyRecord -> moneyRecord($moneyRecordSelect, $moneyRecordWhere, $moneyRecordBetween, $begin, $pageSize);
|
|
|
// 获取记录总数
|
|
|
- $result['total'] = count($result['list']);
|
|
|
+ $result['total'] = $moneyRecord -> moneyRecordTotal($moneyRecordWhere, $moneyRecordBetween);
|
|
|
// 总页数计算
|
|
|
$result['countPage'] = ceil($result['total'] / $pageSize);
|
|
|
$result['currentPage'] = $currentPage;
|