|
|
|
@ -268,37 +268,42 @@ 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'];
|
|
|
|
|
$ratio = $promoteGameRatio['ratio'];
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
$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']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['balance'];
|
|
|
|
|
$thisBalance = $thisBalance ?? 0;
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
|
|
|
|
|
$gameRatios[$gameId] = [];
|
|
|
|
|
$gameRatios[$gameId][] = [
|
|
|
|
|
'selle_ratio' => $ratio,
|
|
|
|
|
'default_ratio' => $promoteGameRatio['ratio'],
|
|
|
|
|
'sum_amount' => $sumAmount,
|
|
|
|
|
'begin_time' => $beginTime,
|
|
|
|
|
'end_time' => $endTime,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['balance'];
|
|
|
|
|
$thisBalance = $thisBalance ?? 0;
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
|
|
|
|
|
$gameRatios[$promoteGameRatio['game_id']] = [];
|
|
|
|
|
$gameRatios[$promoteGameRatio['game_id']][] = [
|
|
|
|
|
'selle_ratio' => $ratio,
|
|
|
|
|
'default_ratio' => $promoteGameRatio['ratio'],
|
|
|
|
|
'sum_amount' => $sumAmount,
|
|
|
|
|
'begin_time' => $beginTime,
|
|
|
|
|
'end_time' => $endTime,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -391,33 +396,38 @@ 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'];
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
|
->where($spendMap)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
$ratio = 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$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")
|
|
|
|
|
->where($spendMap)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
$ratio = 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($ratio > 0) {
|
|
|
|
|
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
|
|
|
|
|
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
|
|
|
|
|
$gameRatios[$promoteGameRatio['game_id']][] = [
|
|
|
|
|
'selle_ratio' => $ratio,
|
|
|
|
|
'default_ratio' => $promoteGameRatio['ratio'],
|
|
|
|
|
'sum_amount' => $sumAmount,
|
|
|
|
|
'begin_time' => date('Y-m-d', $settlementBeginTime),
|
|
|
|
|
'end_time' => date('Y-m-d', $settlementEndTime),
|
|
|
|
|
];
|
|
|
|
|
if ($ratio > 0) {
|
|
|
|
|
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
|
|
|
|
|
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
|
|
|
|
|
$gameRatios[$gameId][] = [
|
|
|
|
|
'selle_ratio' => $ratio,
|
|
|
|
|
'default_ratio' => $promoteGameRatio['ratio'],
|
|
|
|
|
'sum_amount' => $sumAmount,
|
|
|
|
|
'begin_time' => date('Y-m-d', $settlementBeginTime),
|
|
|
|
|
'end_time' => date('Y-m-d', $settlementEndTime),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -477,25 +487,30 @@ 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'];
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
|
->where($spendMap)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
$ratio = 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$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")
|
|
|
|
|
->where($spendMap)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
$ratio = 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($ratio > 0) {
|
|
|
|
|
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
|
|
|
|
|
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
if ($ratio > 0) {
|
|
|
|
|
$ratio = bcsub($ratio, $promoteGameRatio['ratio'], 2);
|
|
|
|
|
$thisBalance = bcdiv(bcmul($sumAmount, $ratio, 2), 100, 2);
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -532,28 +547,33 @@ 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'];
|
|
|
|
|
$ratio = $promoteGameRatio['ratio'];
|
|
|
|
|
$promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true);
|
|
|
|
|
$turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
$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']);
|
|
|
|
|
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['sum_amount'];
|
|
|
|
|
$sumAmount = $sumAmount ?? 0;
|
|
|
|
|
foreach ($turnoverRatios as $turnoverRatio) {
|
|
|
|
|
if ($sumAmount >= $turnoverRatio['turnover']) {
|
|
|
|
|
$ratio = $turnoverRatio['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['balance'];
|
|
|
|
|
$thisBalance = $thisBalance ?? 0;
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance")
|
|
|
|
|
->where($spendWhere)
|
|
|
|
|
->find()['balance'];
|
|
|
|
|
$thisBalance = $thisBalance ?? 0;
|
|
|
|
|
$balance = bcadd($balance, $thisBalance, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|