diff --git a/Application/Admin/View/Game/edit.html b/Application/Admin/View/Game/edit.html
index d52dd385a..b11b63848 100644
--- a/Application/Admin/View/Game/edit.html
+++ b/Application/Admin/View/Game/edit.html
@@ -384,7 +384,7 @@
超级签URL: |
-
+
|
diff --git a/Application/Callback/Controller/BaseController.class.php b/Application/Callback/Controller/BaseController.class.php
index 14bda6ada..65b29bbda 100644
--- a/Application/Callback/Controller/BaseController.class.php
+++ b/Application/Callback/Controller/BaseController.class.php
@@ -55,6 +55,11 @@ class BaseController extends Controller {
$map['pay_order_number'] = $data['out_trade_no'];
$d = $spend->where($map)->find();
if(empty($d)){$this->record_logs("数据异常");return false;}
+ // 支付金额判断 by zgc
+ if ($d['pay_amount'] != $data['money']) {
+ $this->record_logs("支付金额不一致".$data['out_trade_no'].":".$data['money']);return false;
+ }
+
if($d['pay_status'] == 0){
$data_save['pay_status'] = 1;
$data_save['order_number'] = $data['trade_no'];
@@ -165,6 +170,30 @@ class BaseController extends Controller {
return true;
}
}
+
+ /*
+ * 超级签支付成功通知验证后调用
+ * return 1订单不存在 2已支付 0成功 -1数据错误
+ */
+ protected function supersign_pay_notify($data) {
+ $order = M('game_supersign', 'tab_')->where(array(
+ 'order_id' => $data['order_id']
+ ))->find();
+ if (!$order) return 0;
+ if ($order['pay_status'] == 1) return 0;
+
+ $r = M('game_supersign', 'tab_')->where(array(
+ 'order_id' => $data['order_id'],
+ 'pay_status' => 0,
+ ))->save(array(
+ 'trade_id' => $data['trade_id'],
+ 'pay_status' => 1,
+ 'pay_time' => time()
+ ));
+ if (!$r) return -1;
+
+ return 1;
+ }
/**
diff --git a/Application/Callback/Controller/NotifyController.class.php b/Application/Callback/Controller/NotifyController.class.php
index f14c0c15e..ee8fdda34 100644
--- a/Application/Callback/Controller/NotifyController.class.php
+++ b/Application/Callback/Controller/NotifyController.class.php
@@ -23,7 +23,7 @@ class NotifyController extends BaseController
public function notify()
{
-
+
C(api('Config/lists'));
$apitype = I('get.apitype');#获取支付api类型
@@ -63,19 +63,17 @@ class NotifyController extends BaseController
}
$pay = new \Think\Pay($pay_way, C($apitype));
-
if ($pay->verifyNotify($notify)) {
//获取回调订单信息
$order_info = $pay->getInfo();
-
+
if ($order_info['status']) {
$pay_where = substr($order_info['out_trade_no'], 0, 2);
$result = false;
-
switch ($pay_where) {
case 'SP':
@@ -102,12 +100,17 @@ class NotifyController extends BaseController
break;
case 'BR':
-
- $result = $this->set_bind_recharge($order_info);
- break;
- case 'SI':
- $result = $this->set_order($order_info);
- break;
+ $result = $this->set_bind_recharge($order_info);
+ break;
+ case 'SI':
+ $result = $this->set_order($order_info);
+ break;
+ case 'SS': // 超级签
+ $this->supersign_pay_notify(array(
+ 'trade_id' => $order_info['trade_no'],
+ 'order_id' => $order_info['out_trade_no']
+ ));
+ break;
default:
exit('accident order data');
@@ -456,12 +459,6 @@ class NotifyController extends BaseController
case 'AG':
$result = $this->set_agent($order_info);
break;
- case 'SS': // 超级签
- $ipa365 = new Ipa365Controller();
- $result = $ipa365->pay_notify(array(
- 'trade_id' => $orderNo,
- 'order_id' => $billNo
- ));
default:
exit('accident order data');
break;
diff --git a/Application/Sdk/Controller/AppleController.class.php b/Application/Sdk/Controller/AppleController.class.php
index ed36f2770..833eedc9f 100644
--- a/Application/Sdk/Controller/AppleController.class.php
+++ b/Application/Sdk/Controller/AppleController.class.php
@@ -30,8 +30,7 @@ class AppleController extends BaseController{
*/
public function test() {
$sqpay=new Sqpay();
- var_dump(C("sqpay.partner"));
- $returl = 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
+ $returl = C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
$data['secret'] = C("sqpay.key");
$data['merno'] = C("sqpay.partner");
$data['amount'] = 0.01;
@@ -39,7 +38,7 @@ class AppleController extends BaseController{
$data['paymenttype'] = "ZFBZF";
$data['MerRemark'] = "mark";
$data['subject'] = "subject";
- $data['notifyurl'] = "http://"."api.wmtxkj.com"."/callback.php/Notify/sq_callback";//通知
+ $data['notifyurl'] = C('pay_header')."/callback.php/Notify/sq_callback";//通知
$data['returnurl'] = $returl;
$data['mchAppId'] = "wmtxkj.com";
$data['mchAppName'] = "mchAppName";
@@ -189,7 +188,7 @@ class AppleController extends BaseController{
$this->add_deposit($request);
}
$sqpay=new Sqpay();
- $returl = 'http://' .C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
+ $returl = C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
$data['secret'] = C("sqpay.key");
$data['merno'] = C("sqpay.partner");
$data['amount'] = $request['price'];
@@ -197,7 +196,7 @@ class AppleController extends BaseController{
$data['paymenttype'] = "ZFBZF";
$data['MerRemark'] = "mark";
$data['subject'] = "subject";
- $data['notifyurl'] = "http://".C('pay_header')."/callback.php/Notify/sq_callback";//通知
+ $data['notifyurl'] =C('pay_header')."/callback.php/Notify/sq_callback";//通知
$data['returnurl'] = $returl;
$data['mchAppId'] = "wmtxkj.com";
$data['mchAppName'] = "mchAppName";
diff --git a/Application/Sdk/Controller/BaseController.class.php b/Application/Sdk/Controller/BaseController.class.php
index fa928fee0..f55299eed 100644
--- a/Application/Sdk/Controller/BaseController.class.php
+++ b/Application/Sdk/Controller/BaseController.class.php
@@ -385,6 +385,8 @@ class BaseController extends RestController{
$data_spned['pay_order_number'] = $param["pay_order_number"];
$data_spned['props_name'] = $param["title"];
$data_spned['cost'] = $param["price"];//原价
+ $data_spned['deduction_amount'] = $param["deduction_amount"];// 抵扣价格
+ $data_spned['discount_amount'] = $param["discount_amount"];// 折扣价格
$data_spned['pay_time'] = NOW_TIME;
$data_spned['pay_status'] = $param["pay_status"];
$data_spned['pay_game_status'] = 0;
@@ -398,6 +400,8 @@ class BaseController extends RestController{
$data_spned['pay_amount'] = $param["price"];
$data_spned['discount_type'] = 0;
}
+ if (isset($param['actual_amount']) && $param['actual_amount'])
+ $data_spned['pay_amount'] = $param['actual_amount']; // 实际支付价格
$data_spned['spend_ip'] = $param["spend_ip"];
$data_spned['sdk_version'] = $param["sdk_version"];
if($param['small_user_id'] != $param['user_id']) {
diff --git a/Application/Sdk/Controller/Ipa365Controller.class.php b/Application/Sdk/Controller/Ipa365Controller.class.php
index 58ff1542a..7e1cf3c2f 100644
--- a/Application/Sdk/Controller/Ipa365Controller.class.php
+++ b/Application/Sdk/Controller/Ipa365Controller.class.php
@@ -67,29 +67,7 @@ class Ipa365Controller extends BaseController{
'game_id' => 1,
));
}
- /*
- * 支付成功通知验证后调用
- * return 1订单不存在 2已支付 0成功 -1数据错误
- */
- public function pay_notify($data) {
- $order = M('game_supersign', 'tab_')->where(array(
- 'order_id' => $data['order_id']
- ))->find();
- if (!$order) return 1;
- if ($order['pay_status'] == 1) return 2;
-
- $r = M('game_supersign', 'tab_')->where(array(
- 'order_id' => $data['order_id'],
- 'pay_status' => 0,
- ))->save(array(
- 'trade_id' => $data['trade_id'],
- 'pay_status' => 1,
- 'pay_time' => time()
- ));
- if (!$r) return -1;
-
- return 0;
- }
+
/*
* 发起支付
@@ -121,7 +99,7 @@ class Ipa365Controller extends BaseController{
'id' => $gameId,
))->find();
if (!$gameInfo['supersign_token']) {
- return "超级签token未填写";
+ $this->error("超级签token未填写!");
}
$r = M('game_supersign', 'tab_')->add(array(
@@ -150,9 +128,8 @@ class Ipa365Controller extends BaseController{
$param['payway'] = 1;
$param['title'] = $price;
$param['body'] = $price;
- $param['callback'] = "http://192.168.11.14:8088/sdk.php/Ipa365/install_show/user_id/{$userId}/game_id/{$gameId}/order_id/{$orderId}";
- $param['notifyurl'] = "https://api.wmtxkj.com/callback.php/Notify/sq_callback";
- $this->alipay($param);
+ $param['callback'] = "https://api.wmtxkj.com/sdk.php/Ipa365/install_show/user_id/{$userId}/game_id/{$gameId}/order_id/{$orderId}";
+ $param['notifyurl'] = "https://api.wmtxkj.com/callback.php/Notify/notify/apitype/alipay";
$ret = $this->alipay($param);
diff --git a/Application/Sdk/Controller/WapPayController.class.php b/Application/Sdk/Controller/WapPayController.class.php
index 5559fbc29..63fe0860e 100644
--- a/Application/Sdk/Controller/WapPayController.class.php
+++ b/Application/Sdk/Controller/WapPayController.class.php
@@ -82,6 +82,28 @@ class WapPayController extends BaseController{
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
$out_trade_no = $prefix.date('Ymd').date('His').sp_random_string(4);
+
+ // 优先扣除绑定币平台币
+ $deductionAmount = 0;
+ $user_id = $request['user_id'];
+ $game_id = $request['game_id'];
+ $balance = M ('user', 'tab_')->where (array(
+ 'id' => $user_id
+ ))->getField('balance');
+ $bind_balance = M('user_play', 'tab_')->where(array(
+ 'user_id' => $user_id,
+ 'game_id' => $game_id
+ ))->getField('bind_balance');
+ // 够抵扣的情况 不走这个接口
+ $deductionAmount = $bind_balance + $balance;
+ if ($deductionAmount > $pay_amount) {
+ $this->set_message(1089,"fail","平台币足够,请关闭支付页面重新支付");
+ }
+ // 实际支付金额 = 支付总金额 - 折扣抵扣价格 - 绑币和平台币抵扣金额
+ $request['actual_amount'] = $request['price'] - $discountAmount - $deductionAmount;
+ $pay_amount = $request['actual_amount'];
+ $request['discount_amount'] = $discountAmount;
+ $request['deduction_amount'] = $deductionAmount;
if(get_zfb_type()==0){
$game_set_data = get_game_set_info($request['game_id']);
@@ -103,7 +125,7 @@ class WapPayController extends BaseController{
"url" => $pay_url,
);
- } elseif (get_zfb_type() == 2) {
+ } elseif (get_zfb_type() == 2) { // 双乾支付H5
$request['pay_order_number'] = $out_trade_no;
$request['pay_way'] = C('PAY_WAY.SQ_ALIPAY');
$request['pay_status'] = 0;
@@ -115,7 +137,7 @@ class WapPayController extends BaseController{
$this->add_deposit($request);
}
$sqpay=new Sqpay();
- $returl = 'http://' .C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
+ $returl = C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
$data['secret'] = C("sqpay.key");
$data['merno'] = C("sqpay.partner");
$data['amount'] = $request['price'];
@@ -123,7 +145,7 @@ class WapPayController extends BaseController{
$data['paymenttype'] = "ZFBZF";
$data['MerRemark'] = "mark";
$data['subject'] = "subject";
- $data['notifyurl'] = "http://".C('pay_header')."/callback.php/Notify/sq_callback";//通知
+ $data['notifyurl'] = C('pay_header')."/callback.php/Notify/sq_callback";//通知
$data['returnurl'] = $returl;
$data['mchAppId'] = "wmtxkj.com";
$data['mchAppName'] = "mchAppName";
@@ -232,8 +254,9 @@ class WapPayController extends BaseController{
if ($payInfo['status'] == 'payed') {
$this->error("订单已支付");
}
+ // 发起支付
if (IS_POST && $param['smsCode']) {
-
+ echo "发起支付==》".time()."
";
$rsp = $sqpay->shortcut_pay(array(
'merNo' => C('sqpay.partner'),
'merOrderNo' => $payInfo['order_id'],
@@ -247,7 +270,7 @@ class WapPayController extends BaseController{
'smsCode' => $param['smsCode'],
'secret' => C('sqpay.key'),
));
-
+ echo "发起支付==》".time()."
";
sleep(5);
if ($rsp['responseCode'] == '88') {
redirect(U('Spend/pay_success',array('orderno' => $payInfo['order_id'], 'user_id'=>$param['user_id'],'game_id'=>$param['game_id'])));exit;
@@ -260,6 +283,7 @@ class WapPayController extends BaseController{
// 发送短信
if (IS_POST && !isset($param['smsCode'])) {
// 查看是否签约
+ echo "查看是否签约==》".time()."
";
$rcs = $sqpay->contract_status(array(
'merNo' => C('sqpay.partner'),
'custName' => $param['custName'],
@@ -269,6 +293,7 @@ class WapPayController extends BaseController{
'payAmount' => $payInfo['price'],
'secret' => C('sqpay.key'),
));
+ echo "查看是否签约==》".time()."
";
if ($rcs['respCode'] == 4) {
$this->error($rcs['respMessage'], '', true);
pp($rcs);
@@ -276,6 +301,7 @@ class WapPayController extends BaseController{
}
// 调用认证 签约
if ($rcs['respCode'] == 1 || $rcs['respCode'] == 2 || $rcs['respCode'] == 3) {
+ echo "调用认证 签约==》".time()."
";
$rsign = $sqpay->sign_contract(array(
'merNo' => C('sqpay.partner'),
'custName' => $param['custName'],
@@ -287,6 +313,7 @@ class WapPayController extends BaseController{
'custType' => '01',
'secret' => C('sqpay.key'),
));
+ echo "调用认证 签约==》".time()."
";
if ($rsign['respCode'] == 'success') { // 认证成功 接着签约
$rauth = $sqpay->sign_contract(array(
'merNo' => C('sqpay.partner'),
@@ -310,6 +337,7 @@ class WapPayController extends BaseController{
}
// 无需签约 发送短信
if ($rcs['respCode'] == 0 || $rcs['respCode'] == 10) {
+ echo "发送短信==》".time()."
";
$ret = $sqpay->protocol_pay_send_sms(array(
'merNo' => C('sqpay.partner'),
'custName' => $param['custName'],
@@ -322,6 +350,7 @@ class WapPayController extends BaseController{
'NotifyURL' => "http://api.wmtxkj.com"."/callback.php?Notify/sq_callback",
'purpose' => 'aaaa'
));
+ echo "发送短信==》".time()."
";
if ($ret['resFlag'] == 'success') {
M('pay_info', 'tab_')->where(array(
'id' => $payInfo['id'],
@@ -516,9 +545,8 @@ class WapPayController extends BaseController{
public function weixin_pay()
{
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
- $request = json_decode(base64_decode(file_get_contents("php://input")), true);
-
- /* file_put_contents(dirname(__FILE__) . '/weixin_paywap.txt',json_encode($request)); */
+ $request = json_decode(base64_decode(file_get_contents("php://input")), true);
+ /* file_put_contents(dirname(__FILE__) . '/weixin_paywap.txt',json_encode($request)); */
if (empty($request)) {
$this->set_message(1001, "fail", "登录数据不能为空");
@@ -545,15 +573,36 @@ class WapPayController extends BaseController{
$user = get_user_entity($request['user_id']);
$discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']);
$discount = $discount['discount'];
+ $discountAmount = 0;
if($prefix=='PF_'){
$pay_amount = $request['price'];
}else{
$pay_amount = $discount * $request['price'] / 10;
+ $discountAmount = $request['price'] - $pay_amount;
}
if(!empty($request['scheme'])) {
file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']);
}
-
+ $deductionAmount = 0;
+ $user_id = $request['user_id'];
+ $game_id = $request['game_id'];
+ $balance = M ('user', 'tab_')->where (array(
+ 'id' => $user_id
+ ))->getField('balance');
+ $bind_balance = M('user_play', 'tab_')->where(array(
+ 'user_id' => $user_id,
+ 'game_id' => $game_id
+ ))->getField('bind_balance');
+ // 够抵扣的情况 不走这个接口
+ $deductionAmount = $bind_balance + $balance;
+ if ($deductionAmount > $pay_amount) {
+ $this->set_message(1089,"fail","平台币足够,请关闭支付页面重新支付");
+ }
+ // 实际支付金额 = 支付总金额 - 折扣抵扣价格 - 绑币和平台币抵扣金额
+ $request['actual_amount'] = $request['price'] - $discountAmount - $deductionAmount;
+ $pay_amount = $request['actual_amount'];
+ $request['discount_amount'] = $discountAmount;
+ $request['deduction_amount'] = $deductionAmount;
$game_set_data = get_game_set_info($request['game_id']);
//$request['game_name']
diff --git a/ThinkPHP/Library/Org/SqpaySDK/Sqpay.class.php b/ThinkPHP/Library/Org/SqpaySDK/Sqpay.class.php
index b9072b0b8..1d7159430 100644
--- a/ThinkPHP/Library/Org/SqpaySDK/Sqpay.class.php
+++ b/ThinkPHP/Library/Org/SqpaySDK/Sqpay.class.php
@@ -7,35 +7,35 @@ use Think\Log;
class Sqpay
{
- // H5 支付 双乾
- public function sq_pay($order_no,$amount=0.01,$merno="204121",$paymenttype="UNION", $subject="测试产品1", $ip=0,$returnurl=""){
- $returnurl = empty($returnurl)?"http://".$_SERVER['HTTP_HOST']:$returnurl;//成功跳转
+ // H5 支付 双乾 PaymentType "UNION","ZFBZF"
+ public function sq_pay($data){
+ /* $returnurl = empty($returnurl)?"http://".$_SERVER['HTTP_HOST']:$returnurl;//成功跳转
$notifyurl = "http://".$_SERVER['HTTP_HOST']."/callback.php/Notify/sq_callback";//通知
$ordertime =date("Ymdhms",time());
- // 168885 12345678
- $sign = md5("Amount={$amount}&BillNo={$order_no}&MerNo={$merno}&PayType=SMZF&".strtoupper(md5("NsyJOE!e")));
+ // 168885 12345678 */
+ $sign = md5("Amount={$data['amount']}&BillNo={$data['order_no']}&MerNo={$data['merno']}&PayType=SMZF&".strtoupper(md5($data['secret'])));
$sign = strtoupper($sign);
$params=[
- 'MerNo' => $merno,
- 'Amount'=>$amount,
- 'BillNo'=>$order_no,
+ 'MerNo' => $data['merno'],
+ 'Amount'=>$data['amount'],
+ 'BillNo'=>$data['order_no'],
'TranCode'=>"SMZF012",
'PayType'=> "SMZF",
- 'PaymentType'=> $paymenttype,//"UNION","ZFBZF",
- 'MerRemark' => 'MerRemark',
- 'subject' => $subject,
- 'NotifyURL' => $notifyurl,
- 'ReturnURL' => $returnurl,
- 'mchAppId' => 'https://www.95epay.cn',
- 'mchAppName' => '追梦',
- 'deviceInfo' => 'iOS_WAP',
- 'clientIp' => $ip,
- // MD5("Amount=0.01&BillNo=1481093236896&MerNo=168885&PayType=SMZF &"+MD5("12345678").toUpperCase()).toUpperCase();
+ 'PaymentType'=> $data['paymenttype'],//"UNION","ZFBZF",
+ 'MerRemark' => $data['MerRemark'],
+ 'subject' => $data['subject'],
+ 'NotifyURL' => $data['notifyurl'],
+ 'ReturnURL' => $data['returnurl'],
+ 'mchAppId' => $data['mchAppId'],
+ 'mchAppName' => $data['mchAppName'],
+ 'deviceInfo' => $data['deviceInfo'],
+ 'clientIp' => $data['clientIp'],
'MD5info' => $sign,
];
+ var_dump($params);
$ret = curl_post("https://scan.95epay.cn/ScanCodePayment.action", $params);
-
+
return $ret;
}
@@ -210,13 +210,12 @@ class Sqpay
$data['merNo'] = 168885;
$data['secret'] = 12345678; */
- $data['custType'] = '02';
$data['transDate'] = date('Ymd');
$data['transTime'] = date('His');
$bankInfo = $this->getbankinfo($data['cardNo']);
$data['cardType'] = $bankInfo['cardType'] == 'CC' ? 2: 1;
- pp($bankInfo);
+
$sign = md5("authMsg=&bankCode={$bankInfo['bank']}&cardNo={$data['cardNo']}&cardType={$data['cardType']}&custName={$data['custName']}&custType={$data['custType']}&idNo={$data['idNo']}&idType=0&merNo={$data['merNo']}&payType=XYPAY&phoneNo={$data['phoneNo']}&reqMsgId={$data['reqMsgId']}&".strtoupper(md5($data['secret'])));
$sign = strtoupper($sign);
$param = array(