diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php index 47b0a75a8..e75d464ac 100644 --- a/Application/Admin/Controller/AutoController.class.php +++ b/Application/Admin/Controller/AutoController.class.php @@ -1083,18 +1083,22 @@ public function auto_rrdae(){ $error_repeat = 0; if (!empty($promotes)) { + switch ($settlement) { + case 1: + $fun = 'promoteWithdrawWeeklyByPromote'; + break; + case 2: + $fun = 'promoteWithdrawPerMonthByPromote'; + break; + case 3: + $fun = 'promoteWithdrawRecoupByPromote'; + break; + } foreach ($promotes as $promote) { - if ($settlement == 3) { - $result = $withdrawModel->promoteWithdrawRecoupByPromote($promote); + if ($fun == 'promoteWithdrawRecoupByPromote') { + $result = $withdrawModel->$fun($promote); } else { - switch ($promote['settlement_type']) { - case 1: - $result = $withdrawModel->promoteWithdrawWeeklyByPromote($promote, $initial); - break; - case 2: - $result = $withdrawModel->promoteWithdrawPerMonthByPromote($promote, $initial); - break; - } + $result = $withdrawModel->$fun($promote, $initial); } switch ($result) { case -4: @@ -1119,6 +1123,6 @@ 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} error_unset:{$error_unset} error_repeat:{$error_repeat}"; } } diff --git a/Application/Admin/Model/WithdrawModel.class.php b/Application/Admin/Model/WithdrawModel.class.php index 0c03b4703..7cb4ac54a 100644 --- a/Application/Admin/Model/WithdrawModel.class.php +++ b/Application/Admin/Model/WithdrawModel.class.php @@ -179,13 +179,13 @@ class WithdrawModel extends Model{ return -2;//余额不足 } - $gameRatios = []; if ($initial === false) { $beginTime = date('Y-m-d', $settlementBeginTime); - $endTime = date('Y-m-d', $settlementEndTime); - $gameRatios = $this->getGameRatio($spendMap, $beginTime, $endTime); + } else { + $beginTime = '初始'; } - + $endTime = date('Y-m-d', $settlementEndTime); + $gameRatios = $this->getGameRatio($spendMap, $beginTime, $endTime); $gameRatios = $gameRatios ? json_encode($gameRatios) : ''; $thisTime = time(); @@ -237,9 +237,11 @@ class WithdrawModel extends Model{ if ($initial) { $settlementType = 9; $settlementBeginTime = 0; + $beginTime = '初始'; + } else { + $beginTime = date('Y-m-d', $settlementBeginTime); } - $beginTime = date('Y-m-d', $settlementBeginTime); $endTime = date('Y-m-d', $settlementEndTime); $spendMap['pay_status'] = 1; $spendMap['selle_status'] = 0; @@ -248,7 +250,6 @@ class WithdrawModel extends Model{ $spendWhere = $spendMap; $spendModel = M('spend', 'tab_'); - $gameRatios = []; $promoteGameRatioMap['status'] = 1; $promoteGameRatioMap['promote_id'] = $promote['id']; $promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time') @@ -256,11 +257,8 @@ class WithdrawModel extends Model{ ->order('update_time desc') ->select(); - if ($initial === false) { - $beginTime = date('Y-m-d', $settlementBeginTime); - $endTime = date('Y-m-d', $settlementEndTime); - $gameRatios = $this->getGameRatio($spendMap, $beginTime, $endTime); - } + $gameRatios = $this->getGameRatio($spendMap, $beginTime, $endTime); + if (empty($promoteGameRatios) || $initial) { $balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance") ->where($spendMap)