@ -529,7 +529,7 @@ class FinanceController extends BaseController
if ($withdrawId == 0) {
$this->error('参数异常');
}
$withdraw = $model->field('promote_id,status')-> where(array('id' => $withdrawId))->find();
$withdraw = $model->where(array('id' => $withdrawId))->find();
if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) {
$this->error('参数异常');
}
@ -544,7 +544,18 @@ class FinanceController extends BaseController
$parameter['user_account'] = $userAccount;
$parameter['pay_order_number'] = $payOrderNumber;
$map['withdraw_id'] = $withdrawId;
if ($withdraw['settlement_type'] == 3) {
if (empty($withdraw['game_ratio'])) {
$map['_string'] = '1 = 2';
} else {
$gameRatios = json_decode($withdraw['game_ratio'], true);
$gameIds = array_keys($gameRatios);
$map['game_id'] = ['in', $gameIds];
$map['pay_time'] = ['between', [$withdraw['settlement_begin_time'], $withdraw['settlement_end_time']]];
}
} else {
$map['withdraw_id'] = $withdrawId;
}
if (!empty($gameId)) {
$map['game_id'] = $gameId;
}
@ -613,20 +624,40 @@ class FinanceController extends BaseController
if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) {
$this->error('参数异常');
}
$settlementBeginTime = $withdraw['settlement_begin_time'];
$settlementEndTime = $withdraw['settlement_end_time'];
$withdraw['create_time'] = date('Y-m-d H:i:s', $withdraw['create_time']);
$withdraw['settlement_end_time'] = date('Y-m-d H:i:s', $withdraw['settlement_end_time']);
$withdraw['status'] = FinanceController::$withdrawStatus[$withdraw['status']];
$map['withdraw_id'] = $withdrawId;
if (empty($withdraw['game_ratio'])) {
$map['_string'] = '1 = 2';
} else {
$gameRatios = json_decode($withdraw['game_ratio'], true);
$gameIds = array_keys($gameRatios);
$map['game_id'] = ['in', $gameIds];
$map['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]];
}
if ($withdraw['settlement_type'] != 3) {
$map['withdraw_id'] = $withdrawId;
}
$data = M('spend', 'tab_')
->field('game_name,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_way,sum(pay_amount) as pay_amount_all,sum(if(selle_ratio > 0,pay_amount * selle_ratio,0)) as income')
->field('game_id,game_ name,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_way,sum(pay_amount) as pay_amount_all,sum(if(selle_ratio > 0,pay_amount * selle_ratio,0)) as income')
->where($map)
->group('game_id')
->order('game_id')
->select();
if (!empty($data)) {
foreach ($data as & $list) {
$list['income'] = bcdiv($list['income'], 100, 2);
$list['income'] = '0.00';
if (isset($gameRatios[$list['game_id']])) {
foreach ($gameRatios[$list['game_id']] as $gameIncome) {
$income = bcdiv(bcmul($gameIncome['sum_amount'], $gameIncome['selle_ratio'], 2), 100, 2);
$list['income'] = bcadd($list['income'], $income, 2);
}
}
}
}