结算管理--更新

master
chenxiaojun 5 years ago
parent 4c42ee90e3
commit 258e10c9d1

@ -724,7 +724,7 @@ function getAllGameList($groupByRelation = false)
{
$field = 'id, game_name, relation_game_id, relation_game_name';
if ($groupByRelation) {
$games = M('game', 'tab_')->field($field)->group('relation_game_id')->select();
$games = M('game', 'tab_')->field($field)->where('id = relation_game_id')->group('relation_game_id')->select();
} else {
$games = M('game', 'tab_')->field($field)->select();
}

@ -64,7 +64,7 @@ class PromoteGameRatioController extends ThinkController
$promoteIds = array_column($promoteGameRatios, 'promote_id');
$gameIds = array_column($promoteGameRatios, 'game_id');
$promoteFiled = 'id, account, mobile_phone, create_time, status, ver_status';
$gameFiled = 'id, game_name, ratio';
$gameFiled = 'id, relation_game_name, ratio';
$promotes = M('promote', 'tab_')->where(array('id' => ['in', $promoteIds]))->getField($promoteFiled, true);
$games = M('game', 'tab_')->where(array('id' => ['in', $gameIds]))->getField($gameFiled, true);
@ -103,7 +103,7 @@ class PromoteGameRatioController extends ThinkController
$thisPromoteVerStatus = getPromoteVerStatus($promotes[$thisPromoteId]['ver_status'], 2);
}
if ($issetGame) {
$thisGameName = $games[$thisGameId]['game_name'];
$thisGameName = $games[$thisGameId]['relation_game_name'];
$thisGameRatio = $games[$thisGameId]['ratio'];
$thisGameRatio = ($thisGameRatio ?? '0.00') . '%';
}
@ -326,7 +326,7 @@ class PromoteGameRatioController extends ThinkController
$this->assign('lastRatio', $lastRatio);
}
$this->assign('gameList', getAllGameList());
$this->assign('gameList', getAllGameList(true));
$this->assign('promoteList', getPromoteByLevel(1));
$this->meta_title = $metaTitle;
$this->display();
@ -389,8 +389,11 @@ class PromoteGameRatioController extends ThinkController
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promoteId;
$gameIds = D('game')->where(array('relation_game_id' => $promoteGameRatio['game_id']))->getField('id', true);
$gameIds = $gameIds ?? [-1];
$spendMap['promote_id'] = ['in', $promoteIds];
$spendMap['game_id'] = $promoteGameRatio['game_id'];
$spendMap['game_id'] = ['in', $gameIds];
if ($promoteGameRatio['end_time'] > 0) {
$spendMap['pay_time'] = ['between', [$promoteGameRatio['begin_time'], $promoteGameRatio['end_time'] + 3600 * 24 - 1]];
} else {

@ -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")

@ -105,11 +105,11 @@
<option value="">游戏名称</option>
<empty name="record">
<volist name="gameList" id="vo">
<option value="{$vo.id}">{$vo.game_name}</option>
<option value="{$vo.id}">{$vo.relation_game_name}</option>
</volist>
<else/>
<volist name="gameList" id="vo">
<option value="{$vo.id}" <if condition="$vo['id'] eq $record['game_id']">selected</if> >{$vo.game_name}</option>
<option value="{$vo.id}" <if condition="$vo['id'] eq $record['game_id']">selected</if> >{$vo.relation_game_name}</option>
</volist>
</empty>
</select>

@ -1106,6 +1106,10 @@ function getGameSelleRatioByPromote($promoteId = null, $gameId = null)
$promoteId = intval($promoteId);
$gameId = intval($gameId);
$promote = M('promote', 'tab_')->find($promoteId);
$gameId = M('game', 'tab_')->where(array('id' => $gameId))->getField('relation_game_id');
if (empty($gameId)) {
return false;
}
if (empty($promote)) {
return false;

Loading…
Cancel
Save