master
chenxiaojun 5 years ago
commit c8fd6309a7

@ -1094,6 +1094,17 @@ public function auto_rrdae(){
echo "success{$success} error_withdraw{$error_withdraw} error_spend{$error_spend} error_balance{$error_balance}"; echo "success{$success} error_withdraw{$error_withdraw} error_spend{$error_spend} error_balance{$error_balance}";
} }
private function promoteWithdrawWeeklyByPromote($promote, $initial = false)
{
$promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"];
$promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true);
$promoteIds[] = $promote['id'];
$settlementType = $promote['settlement_type'];
$settlementEndTime = strtotime(date('Y-m-d')) - 1;
}
private function promoteWithdrawByPromote($promote, $initial = false) private function promoteWithdrawByPromote($promote, $initial = false)
{ {
$promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"]; $promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"];
@ -1121,9 +1132,49 @@ public function auto_rrdae(){
$spendMap['promote_id'] = ['in', $promoteIds]; $spendMap['promote_id'] = ['in', $promoteIds];
$spendMap['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]]; $spendMap['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]];
$spendModel = M('spend', 'tab_'); $spendModel = M('spend', 'tab_');
$balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
->where($spendMap) $promoteGameRatioMap['status'] = 1;
->find()['balance']; $promoteGameRatioMap['promote_id'] = $promote['id'];
$promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time')
->where($promoteGameRatioMap)
->select();
if (empty($promoteGameRatios)) {
$balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
->where($spendMap)
->find()['balance'];
} else {
$balance = 0;
foreach ($promoteGameRatios as $promoteGameRatio) {
if ($settlementType == 1) {
$thisSettlementBeginTime = $settlementBeginTime;
$thisSettlementEndTime = $settlementEndTime;
if ($promoteGameRatio['begin_time'] > $settlementBeginTime) {
$thisSettlementBeginTime = $promoteGameRatio['begin_time'];
} elseif (!empty($promoteGameRatio['end_time']) && $promoteGameRatio['end_time'] < $settlementEndTime) {
$thisSettlementEndTime = $promoteGameRatio['end_time'];
}
$spendMap['pay_time'] = ['between', [$thisSettlementBeginTime, $thisSettlementEndTime]];
$balance += $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
->where($spendMap)
->find()['balance'];
} elseif ($settlementType == 2) {
if ($promoteGameRatio['begin_time'] > $settlementBeginTime || (!empty($promoteGameRatio['end_time']) && $promoteGameRatio['end_time'] < $thisTime) || empty($promoteGameRatio['turnover_ratio'])) {
$spendMap['game_id'] = $promoteGameRatio['game_id'];
$balance += $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance")
->where($spendMap)
->find()['balance'];
}
if (empty($promoteGameRatio['turnover_ratio'])) {
}
}
}
$sumAmount = $spendModel->field("sum(pay_amount) as sum_amount")
->where($spendMap)
->find()['sum_amount'];
}
$balance = bcdiv($balance, 100, 2); $balance = bcdiv($balance, 100, 2);
if ($balance < 100) { if ($balance < 100) {
return -2;//余额不足 return -2;//余额不足

@ -218,7 +218,7 @@ class PromoteGameRatioController extends ThinkController
$save['ratio'] = $params['ratio'] ?? 0; $save['ratio'] = $params['ratio'] ?? 0;
$save['begin_time'] = strtotime($params['begin_time']); $save['begin_time'] = strtotime($params['begin_time']);
$save['end_time'] = $params['end_time'] ? strtotime($params['end_time']) : 0; $save['end_time'] = $params['end_time'] ? (strtotime('+1 month', strtotime($params['end_time'])) - 1) : 0;
$save['remark'] = $params['remark'] ?? ''; $save['remark'] = $params['remark'] ?? '';
$save['status'] = 0; $save['status'] = 0;
$save['update_time'] = $time; $save['update_time'] = $time;

@ -345,6 +345,7 @@ class QueryController extends ThinkController
$add['last_op_id'] = $add['op_id']; $add['last_op_id'] = $add['op_id'];
$add['last_op_type'] = 2; $add['last_op_type'] = 2;
$add['settlement_type'] = 3; $add['settlement_type'] = 3;
$add['game_ratio'] = '';
M()->startTrans();//开启事物 M()->startTrans();//开启事物
$withdrawId = M('withdraw', 'tab_')->add($add); $withdrawId = M('withdraw', 'tab_')->add($add);

Loading…
Cancel
Save