1,更新支付意向成功记录

2,更新游戏通知成功记录
3,支付限额 平台币  游戏  支付宝  微信  易宝  双乾
master
tping 5 years ago
parent 629f2c31c0
commit 03c63ec3d2

@ -6,6 +6,7 @@ use Common\Api\GameApi;
use Org\UcenterSDK\Ucservice;
use Think\Log;
use Sdk\Controller\BaseController as sdk;
use Sdk\Model\PayChannelIntentionModel;
/**
* 支付回调控制器
* @author 小纯洁
@ -177,6 +178,10 @@ class BaseController extends Controller {
$data_save['payed_time'] = time();
$map_s['pay_order_number'] = $data['out_trade_no'];
$r = $spend->where($map_s)->save($data_save);
// 更新意向表支付成功记录
$payChannelIntention = new PayChannelIntentionModel();
$payChannelIntention->updatePaySuccess($data['out_trade_no']);
$this->set_ratio($d['pay_order_number']);
//APP邀请好友消费奖励平台币
$this->inviteFriendAward($d['user_id'],$d['pay_amount'],$data['out_trade_no']);
@ -202,6 +207,8 @@ class BaseController extends Controller {
$game = new GameApi();
$r = $game->game_pay_notify($data,1);
if ($r == 'success') {
// 更新意向表游戏通知成功记录
$payChannelIntention->updateGameNotifySuccess($data['out_trade_no']);
foreach ($notice_order as $v) {
$this->record_logs("game_notice_cp:".$v);
@ -261,6 +268,10 @@ class BaseController extends Controller {
$valueDetailLogModel = new \Sdk\Model\ValueDetailLogModel();
$valueDetailLogModel->addLog($d['user_id'], $data['out_trade_no'], $before, $d['pay_amount'], $after, $valueDetailLogModel::BALANCE, "平台币充值".$d['pay_amount'], 2);
// 更新意向表支付成功记录
$payChannelIntention = new PayChannelIntentionModel();
$payChannelIntention->updatePaySuccess($data['out_trade_no']);
$user->where("id=".$d['user_id'])->setInc("balance",$d['pay_amount']);
$user->where("id=".$d['user_id'])->setInc("cumulative",$d['pay_amount']);
//APP邀请好友消费奖励平台币

@ -11,6 +11,9 @@ use Org\HeepaySDK\Heepay;
use Qiniu\json_decode;
use Think\Log;
use Sdk\Model\ValueDetailLogModel;
use Sdk\Model\PayLimitConfModel;
use Sdk\Model\PayChannelInterntionModel;
use Sdk\Model\PayChannelIntentionModel;
class PayH5Controller extends BaseController{
@ -52,6 +55,16 @@ class PayH5Controller extends BaseController{
}
$request['pay_order_number'] = $pay_info['order_id'];
$payLimitConf = new PayLimitConfModel();
// 先判断意向记录支付请求情况
$check = $payLimitConf->check($request['user_id'], $request['price'], $payLimitConf::PAY_TYPE_ALIPAY, $request['pay_order_number']);
// 在更新历史支付请求订单提交情况
$payChannelInterntion = new PayChannelIntentionModel();
$payChannelInterntion->paySubmit($request['pay_order_number']);
if ($check) {
echo json_encode(['code'=>1001,'msg'=> "请求发起失效,编号{$request['pay_order_number']},请选择其他支付方式或联系客服"]);exit;
}
if(get_zfb_type($game_id, $user_id)==0){ // 支付宝官方
if(C('alipay.way')==1/* || ($request['is_create_ordernumer']==1 && C('alipay.way')==0) */){ /* wap */
@ -302,6 +315,16 @@ class PayH5Controller extends BaseController{
echo json_encode(['code'=>0,'msg'=>'订单号重复,请关闭支付页面重新支付']);exit;
}
$payLimitConf = new PayLimitConfModel();
// 先判断意向记录支付请求情况
$check = $payLimitConf->check($request['user_id'], $request['price'], $payLimitConf::PAY_TYPE_ALIPAY, $request['pay_order_number']);
// 在更新历史支付请求订单提交情况
$payChannelInterntion = new PayChannelIntentionModel();
$payChannelInterntion->paySubmit($request['pay_order_number']);
if ($check) {
echo json_encode(['code'=>1001,'msg'=> "请求发起失效,编号{$request['pay_order_number']},请选择其他支付方式或联系客服"]);exit;
}
$this->other_price($request);
if(get_zfb_type($game_id, $user_id)==0){ // 支付宝官方
@ -618,6 +641,16 @@ ADD COLUMN `pay_url` text NULL AFTER `check_sign`;
$request['pay_order_number'] = $pay_info['order_id']; //'PF_'.date('Ymd').date('His').sp_random_string(4);
$request['sdk_version'] = I('request.sdk_version');
$payLimitConf = new PayLimitConfModel();
// 先判断意向记录支付请求情况
$check = $payLimitConf->check($request['user_id'], $request['price'], $payLimitConf::PAY_TYPE_WXPAY, $request['pay_order_number']);
// 在更新历史支付请求订单提交情况
$payChannelInterntion = new PayChannelIntentionModel();
$payChannelInterntion->paySubmit($request['pay_order_number']);
if ($check) {
echo json_encode(['code'=>1001,'msg'=> "请求发起失效,编号{$request['pay_order_number']},请选择其他支付方式或联系客服"]);exit;
}
//0 官方 1威富通 2俊付通
if (get_wx_pay_type() == 0) {
$weixn = new Weixin();
@ -1294,7 +1327,7 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
}
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'game_id'=>$request['game_id']/* ,'pay_status'=>1 */))->find();
if($extend_data){
echo json_encode(['code'=>0,'msg'=> '订单号重复,请关闭支付页面重新支付']);exit;
echo json_encode(['code'=>0,'msg'=> '订单号重复,请关闭支付页面重新支付.']);exit;
//$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
//redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'订单号重复,请关闭支付页面重新支付', 'user_token' => $this->userToken)));exit;
}
@ -1302,6 +1335,17 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
if (pay_limit('wx')) {
echo json_encode(['code'=>0,'msg'=> '支付限额,暂不支持']);exit;
}
$payLimitConf = new PayLimitConfModel();
// 先判断意向记录支付请求情况
$check = $payLimitConf->check($request['user_id'], $request['price'], $payLimitConf::PAY_TYPE_WXPAY, $request['pay_order_number']);
// 在更新历史支付请求订单提交情况
$payChannelInterntion = new PayChannelIntentionModel();
$payChannelInterntion->paySubmit($request['pay_order_number']);
if ($check) {
echo json_encode(['code'=>1001,'msg'=> "请求发起失效,编号{$request['order_id']},请选择其他支付方式或联系客服"]);exit;
}
$table = $request['code'] == 1 ? "spend" : "deposit";
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
//折扣

@ -6,6 +6,8 @@ use Org\SqpaySDK\Sqpay;
use Qiniu\json_decode;
use Think\Log;
use Org\YeepaySDK\Yeepay;
use Sdk\Model\PayLimitConfModel;
use Sdk\Model\PayChannelIntentionModel;
class ShortcutController extends BaseController{
// 签约处理
@ -491,6 +493,16 @@ class ShortcutController extends BaseController{
exit;
}
$payLimitConf = new PayLimitConfModel();
// 先判断意向记录支付请求情况
$check = $payLimitConf->check($request['user_id'], $request['price'], $payLimitConf::PAY_TYPE_YEEPAY, $payInfo['order_id']);
// 在更新历史支付请求订单提交情况
$payChannelInterntion = new PayChannelIntentionModel();
$payChannelInterntion->paySubmit($payInfo['order_id']);
if ($check) {
echo json_encode(['code'=>1001,'msg'=> "请求发起失效,编号{$request['order_id']},请选择其他支付方式或联系客服"]);exit;
}
C(api('Config/lists'));
if (!$is_platform) {
@ -657,6 +669,15 @@ class ShortcutController extends BaseController{
echo json_encode(['code'=>0,'msg'=>'充值金额有误']);
exit;
}
// 先判断意向记录支付请求情况
$check = $payLimitConf->check($request['user_id'], $request['price'], $payLimitConf::PAY_TYPE_SQPAY, $payInfo['order_id']);
// 在更新历史支付请求订单提交情况
$payChannelInterntion = new PayChannelIntentionModel();
$payChannelInterntion->paySubmit($payInfo['order_id']);
if ($check) {
echo json_encode(['code'=>1001,'msg'=> "请求发起失效,编号{$payInfo['order_id']},请选择其他支付方式或联系客服"]);exit;
}
C(api('Config/lists'));

@ -8,6 +8,7 @@ use Org\SqpaySDK\Sqpay;
use Think\Log;
use Qiniu\json_decode;
use Sdk\Model\ValueDetailLogModel;
use Sdk\Model\PayChannelIntentionModel;
class SpendController extends Controller {
@ -572,6 +573,15 @@ ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`;
exit;
}
$payChannelIntention = new PayChannelIntentionModel();
$intentionLog = $payChannelIntention->where(array(
'pay_order_number' => $pay_info['order_id']
))->order('id desc')->find();
if ($intentionLog['pay_way'] == $pay_way) {
// 前后两次类型一样不做记录
echo json_encode(['code'=>200,'msg'=>'']);
exit;
}
// $user_info = M('user','tab_')->field('account')->where(['id'=>$user_id])->find();
$insert['user_id'] = $user_info['user_id'];

@ -31,7 +31,31 @@ class PayLimitConfModel extends Model {
parent::__construct($name, $tablePrefix, $connection);
}
// 累加充值金额
// 获取平台总流水
public function allTotal() {
$total = M('game_data', 'tab_')->sum('pay_amount');
// var_dump("total:".$total);
return $total ? $total : 0;
}
// 获取游戏总流水
public function gameTotal($gameId) {
if (!$gameId) return 0;
$gameTotal = M('game_data', 'tab_')->where(array('game_id' => $gameId))->sum('pay_amount');
// var_dump("game:".$gameTotal);
return $gameTotal ? $gameTotal : 0;
}
// 获取玩家总流水
public function userTotal($userId) {
if (!$userId) return 0;
$userTotal = M('user_data', 'tab_')->where(array('user_id' => $userId))->getField('pay_amount');
// var_dump("userTotal:".$userTotal);
return $userTotal ? $userTotal : 0;
}
/* // 累加充值金额
public function sum($userId, $price, $payType) {
$now = date("His");
@ -179,5 +203,111 @@ class PayLimitConfModel extends Model {
'clear_time' => time(),
));
}
} */
/**
* return 0 通过 1障碍 2限制 3参数有误
* {@inheritDoc}
* @see \Think\Model::check()
*/
public function check($userId, $price, $payType, $orderId, $gameId=0) {
if (!$userId || !$price || !$payType || !$orderId) {
return 3;
}
// 如果是白名单的用户 不走限制
$userPayWhitelist = new UserPayWhitelistModel();
if ($userPayWhitelist->verify($userId)) {
return 0;
}
$now = date("His");
$nowDate = date('Ymd');
$nowWeekNum = date('w');
$nowDateNum = (int)substr($nowDate, -2);
// 找出所有匹配的规则 时间范围满足的所有总流水限额
$limits = $this->where(array(
'start_time' => array('elt', $now),
'end_time' => array('gt', $now),
'pay_type' => $payType
))->select();
if (!$limits) return 0;
$result = 0;
// 处理在这个时间段内的限制
foreach ($limits as $k => $v) {
// 每日 每周 每月 固定时间
if ($v['limit_time_type'] == "day" || $v['limit_time_type'] == "week" || $v['limit_time_type'] == "month"
|| ($v['limit_time_type'] == 'fix' && $v['fix_date'] == $nowDate)) {
if ($v['limit_time_type'] == "week" && $nowWeekNum != $v['limit_time_type_remark']) {
continue;
}
if ($v['limit_time_type'] == "month" && $nowDateNum != $v['limit_time_type_remark']) {
continue;
}
// 总流水
if ($v['total_limit'] > 0 && $this->allTotal() > $v['total_limit']) {
if ($v['limit_type'] == "force") return 2;
if ($v['limit_type'] == "obstacles") {
// 障碍 第二次就可以支付
if (/* $this->enterCount($payType, $orderId) >= 2 && */$this->paySubmitCount($payType, $orderId) >= 1) {
$result = 0;
} else {
return 1;
}
}
}
// 单玩家总流水
if ($v['user_total_limit'] > 0 && $this->userTotal($userId) > $v['user_total_limit']) {
if ($v['limit_type'] == "force") return 2;
if ($v['limit_type'] == "obstacles") {
// 障碍 第二次就可以支付
if (/* $this->enterCount($payType, $orderId) >= 2 && */$this->paySubmitCount($payType, $orderId) >= 1) {
$result = 0;
} else {
return 1; // 障碍
}
}
}
// 单笔限额
if ($v['user_one_limit'] > 0 && $price >= $v['user_one_limit']) {
if ($v['limit_type'] == "force") return 2;
if ($v['limit_type'] == "obstacles") {
// 障碍 第二次就可以支付
if (/* $this->enterCount($payType, $orderId) >= 2 && */$this->paySubmitCount($payType, $orderId) >= 1) {
$result = 0;
} else {
return 1; // 障碍
}
}
}
}
}
return $result;
}
// 支付方式 进入次数
private function enterCount($payType, $orderId) {
$cnt = M('pay_channel_intention', 'tab_')->where(array(
'pay_way' => $payType,
'pay_order_number' => $orderId,
))->count();
return $cnt ? $cnt : 0;
}
// 提交支付次数
private function paySubmitCount($payType, $orderId) {
$cnt = M('pay_channel_intention', 'tab_')->where(array(
'pay_way' => $payType,
'pay_order_number' => $orderId,
'is_submit' => 1
))->count();
return $cnt ? $cnt : 0;
}
}

@ -240,6 +240,7 @@
// 业务逻辑js
var payway='';
var payurl='';
flag = false;
function small_program(status) {
if (status == "1") { // 小程序
if ($('#sdk_version').val() == 1) { // android
@ -256,8 +257,7 @@
function defaultInit(){
try {
var pay_price = '{$pay_price}';
var user_token = $('#user_token').val();
var user_token = $('#user_token').val();
if (pay_price == 0) {
payway="platform_pay";
payurl = "{:U('PayH5/platform_coin_deduction',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'), 'api_ver' => 2))}";
@ -265,7 +265,7 @@
} else {
payway="alipay";
payurl="{:U('PayH5/ali_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}";
payChannelIntentionInit(user_token);
payChannelIntentionInit(user_token);
}
} catch (error) {
@ -340,12 +340,13 @@
var img=$(this).children("div").children("img").attr("src");
var text = $(this).children("div").children("span").text();
//获取支付参数
if (payway == $(this).data("type")) return ;
payway = $(this).data("type");
payurl = $(this).data("url");
var user_token = $('#user_token').val();
payChannelIntentionInit(user_token);
payChannelIntentionInit(user_token);
$(".select_pay_info").children(".slide").attr("src",img);
$(".select_pay_info").children("div").text(text);
@ -353,10 +354,9 @@
});
//拉起支付
var flag = false;
$(".confirm_pay").on("click",function(){
if (flag){
$(".tipmsg").html("支付请求中,请勿重复提交");
$(".tipmsg").html("支付请求中,请勿重复提交.");
$(".msgdialog").show();
return false;
};
@ -406,13 +406,14 @@
success:function(result) {
if(result.code==200) {
window.location.href = result.url;
} else if(result.code!=1001){
flag=false;
} else if(result.code == 1001){
flag=false;
showWindow();
} else {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
} else {
showWindow();
}
}
},
error: function(){
flag=false;
@ -434,13 +435,14 @@
success:function(result) {
if(result.code==200) {
window.location.href = result.url;
} else if(result.code!=1001){
flag=false;
} else if(result.code == 1001){
flag=false;
showWindow();
} else {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
} else {
showWindow();
}
}
},
error:function(){
flag=false;
@ -462,13 +464,14 @@
success:function(result) {
if(result.code==200) {
window.location.href = result.url;
} else if(result.code!=1001){
} else if(result.code == 1001){
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
showWindow();
} else {
showWindow();
}
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
}
},
error:function(){
flag=false;
@ -493,12 +496,13 @@
success:function(result) {
if(result.code==200) {
window.location.href = payurl;
} else if(result.code!=1001){
} else if(result.code == 1001){
flag=false;
showWindow();
} else {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
} else {
showWindow();
}
},
error:function(){

Loading…
Cancel
Save