From 9e24fe6830393e28880cbff1dadb038f28299380 Mon Sep 17 00:00:00 2001 From: tping Date: Fri, 20 Aug 2021 15:36:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=98=E6=89=A3=E4=BC=98=E5=85=88=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/BaseController.class.php | 105 +++++++++--------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/Application/Callback/Controller/BaseController.class.php b/Application/Callback/Controller/BaseController.class.php index e545e87f..08d8febf 100644 --- a/Application/Callback/Controller/BaseController.class.php +++ b/Application/Callback/Controller/BaseController.class.php @@ -74,7 +74,59 @@ class BaseController extends Controller $valueDetailLogModel = new \Sdk\Model\ValueDetailLogModel(); if($d['pay_status'] == 0){ - // 处理绑币平台币优先处理 + // 折扣优先处理 + if ($d['discount_amount'] > 0) { // 折扣金额大于0 + $balance = M('user', 'tab_')->where(array( + 'id' => $d['user_id'], + ))->getField('balance'); + $di = discountInfo($d['game_id']); + if (!$di || $di['status'] != 1 || $di['start_time'] > time() || $di['end_time'] < time()) { + $this->record_logs($d['discount_amount'] . "折扣失效,退还平台币" . serialize($di)); + + $createTime = time(); + $depositId = M('deposit', "tab_")->add([ + 'order_number' => $data['trade_no'], + 'pay_order_number' => 'PF_' . $data['out_trade_no'], + 'user_id' => $d['user_id'], + 'user_account' => $d['user_account'], + 'user_nickname' => $d['user_nickname'], + 'promote_id' => $d['promote_id'], + 'promote_account' => $d['promote_account'], + 'pay_amount' => $d['pay_amount'], + 'pay_status' => 1, + 'pay_way' => $d['pay_way'], + 'pay_source' => 2, // 0官网 1推广后台 2移动端 + 'pay_ip' => $d['spend_ip'], + 'create_time' => $createTime, + 'payed_time' => time(), + 'sdk_version' => $d['sdk_version'], + 'check_sign' => get_check_sign($d['user_id'], $data['trade_no'], $d['pay_amount'], $createTime), + ]); + $valueDetailLogModel->addLog($d['user_id'], 'PF_' . $data['out_trade_no'], + $balance, $d['pay_amount'], $balance + $d['pay_amount'], $valueDetailLogModel::BALANCE, "游戏支付时候折扣失效,增加到平台币", 2); + $user = M("user", "tab_"); + $user->where("id=" . $d['user_id'])->setInc("balance", $d['pay_amount']); + $user->where("id=" . $d['user_id'])->setInc("cumulative", $d['pay_amount']); + //APP邀请好友消费奖励平台币 + $this->inviteFriendAward($d['user_id'], $d['pay_amount'], 'PF_' . $data['out_trade_no']); + //充值奖励积分 + $this->rechargeAwardPoint($d['user_id'], $d['pay_amount']); + // 当天累计充值 + $this->payTodayTotal($d['pay_amount'], $d['pay_way']); + + $data_save['pay_status'] = 0; + $data_save['order_number'] = $data['trade_no']; + $data_save['payed_time'] = time(); + $data_save['pay_time'] = $data_save['payed_time']; + $map_s['pay_order_number'] = $data['out_trade_no']; + $r = $spend->where($map_s)->save($data_save); + + return false; + } + + } + + // 处理绑币平台币 if ($d['deduction_amount'] > 0) { $bind_balance = M('user_play', 'tab_')->where(array( @@ -189,57 +241,6 @@ class BaseController extends Controller } } - if ($d['discount_amount'] > 0) { // 折扣金额大于0 - $balance = M('user', 'tab_')->where(array( - 'id' => $d['user_id'], - ))->getField('balance'); - $di = discountInfo($d['game_id']); - if (!$di || $di['status'] != 1 || $di['start_time'] > time() || $di['end_time'] < time()) { - $this->record_logs($d['discount_amount'] . "折扣失效,退还平台币" . serialize($di)); - - $createTime = time(); - $depositId = M('deposit', "tab_")->add([ - 'order_number' => $data['trade_no'], - 'pay_order_number' => 'PF_' . $data['out_trade_no'], - 'user_id' => $d['user_id'], - 'user_account' => $d['user_account'], - 'user_nickname' => $d['user_nickname'], - 'promote_id' => $d['promote_id'], - 'promote_account' => $d['promote_account'], - 'pay_amount' => $d['pay_amount'], - 'pay_status' => 1, - 'pay_way' => $d['pay_way'], - 'pay_source' => 2, // 0官网 1推广后台 2移动端 - 'pay_ip' => $d['spend_ip'], - 'create_time' => $createTime, - 'payed_time' => time(), - 'sdk_version' => $d['sdk_version'], - 'check_sign' => get_check_sign($d['user_id'], $data['trade_no'], $d['pay_amount'], $createTime), - ]); - $valueDetailLogModel->addLog($d['user_id'], 'PF_' . $data['out_trade_no'], - $balance, $d['pay_amount'], $balance + $d['pay_amount'], $valueDetailLogModel::BALANCE, "游戏支付时候折扣失效,增加到平台币", 2); - $user = M("user", "tab_"); - $user->where("id=" . $d['user_id'])->setInc("balance", $d['pay_amount']); - $user->where("id=" . $d['user_id'])->setInc("cumulative", $d['pay_amount']); - //APP邀请好友消费奖励平台币 - $this->inviteFriendAward($d['user_id'], $d['pay_amount'], 'PF_' . $data['out_trade_no']); - //充值奖励积分 - $this->rechargeAwardPoint($d['user_id'], $d['pay_amount']); - // 当天累计充值 - $this->payTodayTotal($d['pay_amount'], $d['pay_way']); - - $data_save['pay_status'] = 0; - $data_save['order_number'] = $data['trade_no']; - $data_save['payed_time'] = time(); - $data_save['pay_time'] = $data_save['payed_time']; - $map_s['pay_order_number'] = $data['out_trade_no']; - $r = $spend->where($map_s)->save($data_save); - - return false; - } - - } - $data_save['pay_status'] = 1; $data_save['order_number'] = $data['trade_no']; $data_save['payed_time'] = time();