|
|
|
@ -268,9 +268,12 @@ class WithdrawModel extends Model{
|
|
|
|
|
$balance = 0;
|
|
|
|
|
$notInGameIds = [-1];
|
|
|
|
|
foreach ($promoteGameRatios as $promoteGameRatio) {
|
|
|
|
|
$spendWhere['game_id'] = $promoteGameRatio['game_id'];
|
|
|
|
|
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
|
|
|
|
|
$notInGameIds[] = $promoteGameRatio['game_id'];
|
|
|
|
|
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
|
|
|
|
|
if (!empty($gameIds)) {
|
|
|
|
|
foreach ($gameIds as $gameId) {
|
|
|
|
|
$spendWhere['game_id'] = $gameId;
|
|
|
|
|
$notInGameIds[] = $gameId;
|
|
|
|
|
$ratio = $promoteGameRatio['ratio'];
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
@ -291,8 +294,8 @@ class WithdrawModel extends Model{
|
|
|
|
|
$thisBalance = $thisBalance ?? 0;
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
|
|
|
|
|
$gameRatios[$promoteGameRatio['game_id']] = [];
|
|
|
|
|
$gameRatios[$promoteGameRatio['game_id']][] = [
|
|
|
|
|
$gameRatios[$gameId] = [];
|
|
|
|
|
$gameRatios[$gameId][] = [
|
|
|
|
|
'selle_ratio' => $ratio,
|
|
|
|
|
'default_ratio' => $promoteGameRatio['ratio'],
|
|
|
|
|
'sum_amount' => $sumAmount,
|
|
|
|
@ -301,6 +304,8 @@ class WithdrawModel extends Model{
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$spendWhere['game_id'] = ['not in', $notInGameIds];
|
|
|
|
|
$otherBalance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
|
|
|
|
@ -391,7 +396,10 @@ class WithdrawModel extends Model{
|
|
|
|
|
$gameRatios = [];
|
|
|
|
|
foreach ($promoteGameRatios as $promoteGameRatio) {
|
|
|
|
|
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
|
|
|
|
|
$spendMap['game_id'] = $promoteGameRatio['game_id'];
|
|
|
|
|
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
|
|
|
|
|
if (!empty($gameIds)) {
|
|
|
|
|
foreach ($gameIds as $gameId) {
|
|
|
|
|
$spendWhere['game_id'] = $gameId;
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
@ -411,7 +419,7 @@ class WithdrawModel extends Model{
|
|
|
|
|
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
|
|
|
|
|
$gameRatios[$promoteGameRatio['game_id']][] = [
|
|
|
|
|
$gameRatios[$gameId][] = [
|
|
|
|
|
'selle_ratio' => $ratio,
|
|
|
|
|
'default_ratio' => $promoteGameRatio['ratio'],
|
|
|
|
|
'sum_amount' => $sumAmount,
|
|
|
|
@ -421,6 +429,8 @@ class WithdrawModel extends Model{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($balance == 0) {
|
|
|
|
|
return -2;//无余额
|
|
|
|
@ -477,7 +487,10 @@ class WithdrawModel extends Model{
|
|
|
|
|
$balance = 0;
|
|
|
|
|
foreach ($promoteGameRatios as $promoteGameRatio) {
|
|
|
|
|
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
|
|
|
|
|
$spendMap['game_id'] = $promoteGameRatio['game_id'];
|
|
|
|
|
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
|
|
|
|
|
if (!empty($gameIds)) {
|
|
|
|
|
foreach ($gameIds as $gameId) {
|
|
|
|
|
$spendMap['game_id'] = $gameId;
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
@ -499,6 +512,8 @@ class WithdrawModel extends Model{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $balance;
|
|
|
|
|
}
|
|
|
|
@ -532,9 +547,12 @@ class WithdrawModel extends Model{
|
|
|
|
|
$balance = 0;
|
|
|
|
|
$notInGameIds = [-1];
|
|
|
|
|
foreach ($promoteGameRatios as $promoteGameRatio) {
|
|
|
|
|
$spendWhere['game_id'] = $promoteGameRatio['game_id'];
|
|
|
|
|
if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) {
|
|
|
|
|
$notInGameIds[] = $promoteGameRatio['game_id'];
|
|
|
|
|
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
|
|
|
|
|
if (!empty($gameIds)) {
|
|
|
|
|
foreach ($gameIds as $gameId) {
|
|
|
|
|
$spendWhere['game_id'] = $gameId;
|
|
|
|
|
$notInGameIds[] = $gameId;
|
|
|
|
|
$ratio = $promoteGameRatio['ratio'];
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
@ -556,6 +574,8 @@ class WithdrawModel extends Model{
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$spendWhere['game_id'] = ['not in', $notInGameIds];
|
|
|
|
|
$otherBalance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
|
|
|
|
|