|
|
@ -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;//余额不足
|
|
|
|