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/Admin/View/User/rolelist.html b/Application/Admin/View/User/rolelist.html index 634926ab9..8c25ebc62 100644 --- a/Application/Admin/View/User/rolelist.html +++ b/Application/Admin/View/User/rolelist.html @@ -25,6 +25,19 @@ height:26px;line-height:26px;font-size:12px; } .select2-results__option[aria-selected] {font-size:12px;} + .badge { + position: relative; + display: inline-block; + padding: 0 6px; + font-size: 12px; + text-align: center; + background-color: #1E9FFF; + color: #fff; + border-radius: 2px; + height: 18px; + line-height: 18px; + margin-right: 10px; + } @@ -138,7 +138,7 @@
- {$order_info.real_amount} + {$order_info.pay_amount}
diff --git a/Application/Mobile/View/Ssg/home.html b/Application/Mobile/View/Ssg/home.html index ef6f7107f..d8167fd66 100644 --- a/Application/Mobile/View/Ssg/home.html +++ b/Application/Mobile/View/Ssg/home.html @@ -75,7 +75,7 @@ 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/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index 28125e418..ebbfaa7d2 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -1169,6 +1169,7 @@ class UserController extends BaseController $res = $data = $user_play -> where($map) -> find(); $user = M('user', 'tab_'); $user_data = $user -> find($user_id); + $data['promote_id'] = $request['promote_id']; $data['promote_account'] = get_promote_account($request['promote_id']); $data['game_id'] = $request['game_id']; @@ -1176,7 +1177,7 @@ class UserController extends BaseController $data['server_id'] = $request['server_id']; $data['server_name'] = $request['server_name']; $data['role_name'] = $request['game_player_name']; -// $data['role_name'] = $request['role_name']; + $data['role_id'] = $request['game_player_id']; $data['role_level'] = $request['role_level']; $data['user_id'] = $user_id; $data['user_account'] = $user_data['account']; @@ -1770,6 +1771,24 @@ class UserController extends BaseController if (isset($r['union']) && $r['union'] == 1) $squnion_pay = 1; } + // 双乾银联快捷支付 + $shortcut_pay = 0; + $sqpay = M('tool','tab_')->field('status, config')->where(array('name'=>'sqpay'))->find(); + if ($sqpay['status'] == 1) { + $r = json_decode($sqpay['config'], true); + if (isset($r['shortcut']) && $r['shortcut'] == 1) + $shortcut_pay = 1; + } + $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'); + // pp($squnion_pay); //0:APP 1:WAP $zfb_type = pay_set_status('alipay') == 1 ? (empty(C('alipay.way')) ? 0 : C('alipay.way')) : 1; @@ -1782,7 +1801,11 @@ class UserController extends BaseController 'zfb_type' => $zfb_type, 'ptb_game' => $ptb_game, 'bind_game' => $bind_game, - 'squnion_pay' => $squnion_pay, + 'squnion_pay' => $squnion_pay, // 银联0关 1开 + 'platform_coin' => $balance, + 'bind_coin' => $bind_balance, + 'wx_type' => 0, // 0微信 1 微信小程序 双乾 + 'shortcut_pay' => 0, // 快捷支付 0关 1开 ))); } 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(