From db15df0a61b5bf99748217f9040b0992baf9a4f9 Mon Sep 17 00:00:00 2001 From: tping Date: Thu, 19 Aug 2021 18:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=98=E6=89=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/BaseController.class.php | 53 ++++++++++++++++++- Application/Common/Common/extend.php | 20 +++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Application/Callback/Controller/BaseController.class.php b/Application/Callback/Controller/BaseController.class.php index d737da08..5d9c827d 100644 --- a/Application/Callback/Controller/BaseController.class.php +++ b/Application/Callback/Controller/BaseController.class.php @@ -135,6 +135,7 @@ class BaseController extends Controller $out_trade_no = "PF_" . date('Ymd') . date('His') . sp_random_string(4); $request = $d; + $request['discount_amount'] = 0; $request['pay_order_number'] = $out_trade_no; $request['price'] = $bind_balance; $request['deduction_amount'] = 0; @@ -186,8 +187,58 @@ 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'] = 1; + $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']; diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 1a6ca8e3..c397db41 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -3216,3 +3216,23 @@ function post_async($url="'http://47.111.118.107:9501/game-event/recharge'", $da return true; } + +function discountInfo($gameId, $time=0) +{ + if (!$time) $time = time(); + $baseGame = M('base_game', 'tab_')->where([ + 'android_game_id|ios_game_id' => $gameId + ])->find(); + if (!$baseGame) { + return false; + } + + $discount = M('game_discount','tab_')->where([ + 'base_game_id' => $baseGame['id'], + 'start_time' => ['elt', $time], + 'end_time' => ['gt', $time], + 'status' => 1, + ])->find(); + + return $discount; +}