master
ELF 5 years ago
parent 5c4f96e352
commit 75b292b906

@ -384,7 +384,7 @@
<tr>
<td class="l">超级签URL</td>
<td class="r" >
<input type="text" class="txt " name="supersign_URL" value="{$data['supersign_url']}" placeholder="请输入超级签URL" >
<input type="text" class="txt " name="supersign_url" value="{$data['supersign_url']}" placeholder="请输入超级签URL" >
</td>
</tr>
</tbody>

@ -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'];
@ -166,6 +171,30 @@ class BaseController extends Controller {
}
}
/*
* 超级签支付成功通知验证后调用
* 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;
}
/**
* 绑币充值回调

@ -63,7 +63,6 @@ class NotifyController extends BaseController
}
$pay = new \Think\Pay($pay_way, C($apitype));
if ($pay->verifyNotify($notify)) {
//获取回调订单信息
@ -75,7 +74,6 @@ class NotifyController extends BaseController
$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;
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;

@ -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";

@ -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']) {

@ -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);

@ -83,6 +83,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()."<br>";
$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()."<br>";
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()."<br>";
$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()."<br>";
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()."<br>";
$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()."<br>";
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()."<br>";
$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()."<br>";
if ($ret['resFlag'] == 'success') {
M('pay_info', 'tab_')->where(array(
'id' => $payInfo['id'],
@ -517,7 +546,6 @@ class WapPayController extends BaseController{
{
#获取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)); */
if (empty($request)) {
@ -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']

@ -7,33 +7,33 @@ 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(

Loading…
Cancel
Save