123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- <?php
- namespace app\index;
- class super_buy extends Base
- {
- function index()
- {
- $ssid = SafeRequest("ssid", "get");
- $super_sign = db("super_sign")->where("id", $ssid)->find();
- if (!$super_sign) {
- exit(include_once IN_ROOT . "source/pack/error/404.php");
- }
- $item = db("item")->where("type=4")->order("id")->find();
- $link = SafeRequest("link", "get");
- if ($link) {
- setcookie("downlink", $link, time() + 3600);
- } elseif (isset($_COOKIE["downlink"])) {
- $link = $_COOKIE["downlink"];
- }
- $buylist = db("super_code")->where("udid='" . $super_sign["udid"] . "' and user_id=" . $super_sign["user_id"])->order("id desc")->select();
- ?> <!DOCTYPE html>
- <html lang="">
- <head lang="zh">
- <meta charset="UTF-8">
- <title>超级签下载码购买 -<?php echo IN_NAME;?></title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
- <meta name="renderer" content="webkit">
- <meta name="keywords" content="<?php echo IN_KEYWORDS;?>">
- <meta property="og:url" content="https://<?php echo $_SERVER["HTTP_HOST"];?>">
- <meta property="og:title" content="<?php echo IN_NAME;?>">
- <meta name="description" content="<?php echo IN_DESCRIPTION;?>">
- <link rel="stylesheet" href="/static/index/css/base.css"/>
- <style>
- header {
- padding: 10px;
- background-color: #ffe8dd;
- border: 1px solid #ffd5be;
- font-weight: bold;
- color: #ff671c;
- line-height: 1.5;
- text-align:center;
- }
- header a{position:absolute;color: #333;display:block;font-weight:normal;}
- article {
- padding: 10px;font-size:12px;
- }
- .icon {
- background: url(/static/index/image/icon-main.png?20190126) no-repeat;
- display: inline-block;
- }
- .icon-checkbox {
- width: 28px;
- height: 28px;
- background-position: 0 -39px;
- }
- .price-pay{padding:10px;}
- .price-pay li{
- height: 44px;
- border: 1px solid #eee;
- justify-content: center;
- align-items: center;
- margin-right: 0;
- margin-bottom: 10px;
- border-radius: 3px;
- padding: 12px 20px 11px;
- position: relative;
- cursor: pointer;
-
- }
- .price-pay li .left {
- padding-right: .6rem;
- float: left;
- }
- .price-pay li .text1 {
- color: #666;
- }
- .price-pay li .text2 {
- color: #333;
- margin-top: 5px;
- font-weight: 600;
- }
- .price-pay .right {
- float: right;
- color: #157df1;
- font-size: 30px;
- padding-left: 50px;
- border-left: 1px solid #e5e5e5;
- }
- .price-pay .right span {
- color: #666;
- font-size: 14px;
- }
- .price-pay li .radio-checked {
- display: none;
- position: absolute;
- right: 0;
- bottom: 0;
- }
- .price-pay li.active .radio-checked {
- display: block;
- }
- .price-pay .active {
- border-color: #157df1;
- }
- .paytype{padding: 10px;}
- .paytype .list3 li{width: 40%; border: 1px solid #eee; justify-content: center; align-items: center; margin: 2%;float:left;padding:1%;position: relative;}
- .paytype .list3 li img{display: inline-block;}
- .paytype .list3 .active{border-color: #157df1;}
- .paytype li .radio-checked {
- display: none;
- position: absolute;
- right: 0;
- bottom: 0;
- }
- .paytype li.active .radio-checked {
- display: block;
- }
- .btn {
- display: block;
- background-color: #1B8DFA;
- width: 80%;
- height: 40px;
- line-height: 40px;
- margin: 0 auto;
- text-decoration: none;
- text-align: center;
- font-size: 16px;
- color: #fff;
- border-radius: 4px;
- }
- .buylog{margin-top:20px;padding:10px;}
- .buylog .tit{border-top:solid 1px #ccc;padding:5px 0;}
- .buylog ul{margin:10px 0;}
- .buylog li{color:#333;float:left;width:25%;}
- .buylog li.c1{width:10%;}
- .buylog li.c2{width:30%;}
- .buylog li.c2 a{color:#1B8DFA;}
- .buylog li.c3{width:20%;}
- .buylog li.c4{width:40%;}
- </style>
- <script charset="utf-8" src="/static/index/js/jquery.min.js"></script>
- <script src="/static/index/js/clipboard.min.js"></script>
- </head>
- <body>
- <header><a href="<?php echo $link;?>">< 返回下载</a> 超级签下载码购买</header>
- <article>
- <p>使用说明:一个下载码对应一个手机,验证使用后,其它手机不能再使用此下载码。</p>
- </article>
- <ul class="clearfix price-pay">
- <li class="clearfix active">
- <div class="left"><div class="text1">下载码</div> <div class="text2">1个</div></div> <div class="right"><?php echo $item["price"];?><span>元</span></div> <span class="radio-checked icon icon-checkbox"></span>
- </li>
- </ul>
- <div class="paytype">
- <div class="tit">选择支付方式</div>
- <ul class="clearfix list3" id="list3">
- <?php
- $IN_PAY = json_decode(IN_PAY, true);
- $pay_type = $IN_PAY[1];
- if (in_array(1, $IN_PAY)) {
- ?> <li class="clearfix active" data="1">
- <img src="/static/index/image/pay-1.jpg" alt="">
- <span class="radio-checked icon icon-checkbox"></span>
- </li>
- <?php
- }
- ?> <?php
- if (in_array(2, $IN_PAY)) {
- ?> <li class="clearfix" data="2">
- <img src="/static/index/image/pay-2.jpg" alt="">
- <span class="radio-checked icon icon-checkbox"></span>
- </li>
- <?php
- }
- ?>
- <?php
- if (in_array(3, $IN_PAY)) {
- ?> <li class="clearfix" data="3">
- <img src="/static/index/image/pay-5.jpg" alt="">
- <span class="radio-checked icon icon-checkbox"></span>
- </li>
- <?php
- }
- ?> <?php
- if (in_array(4, $IN_PAY)) {
- ?> <li class="clearfix" data="4">
- <img src="/static/index/image/pay-7.jpg" alt="">
- <span class="radio-checked icon icon-checkbox"></span>
- </li>
- <?php
- }
- ?> </ul>
- </div>
- <div class="pay-btn" style="margin-top:20px;"><a href="javascript:;" class="btn toPay">立即支付</a></div>
-
- <div class="buylog">
- <div class="tit">您的购买记录:</div>
- <ul class="clearfix">
- <li class="c1">序号</li><li class="c2">下载码</li><li class="c3">状态</li><li class="c4">购买时间</li>
- </ul>
- <?php
- foreach ($buylist as $k => $v) {
- $use_status = $v["use_time"] ? "已使用" : "未使用";
- if ($v["use_time"] && $v["cert_iss"]) {
- $cert_st = db("super_cert")->where("iss", $v["cert_iss"])->value("status");
- if (!$cert_st || $cert_st == -1) {
- $use_status = "已失效";
- }
- }
- ?><ul class="clearfix"><li class="c1"><?php echo $k + 1;?></li><li class="c2"><a class="copy" title="<?php echo $v["code"];?>"><?php echo $v["code"];?></a></li><li class="c3"><?php echo $use_status;?></li><li class="c4"><?php echo date("Y-m-d H:i", $v["create_time"]);?></li></ul><?php
- }
- ?> </div>
- <script>
- $(function () {
- $(".paytype ul").on("click", "li:not('.disabled')", function () {
- $(this).addClass("active").siblings().removeClass("active");
- });
-
- $(document).on('click', '.toPay', function () {
- var ssid = '<?php echo $ssid;?>';
- var discount_id = '<?php echo $item["id"];?>';
- pay_type = $(".paytype li.active").attr('data');
- if (!pay_type || pay_type == 'undefined') {
- alert('请选择支付渠道');
- return;
- }
- $(".pay-btn a:last").addClass("disabled");
- $(".pay-btn a:last").removeClass("toPay");
- $.ajax({
- async: false,
- type: "POST",
- url: '/index/ajax/super_buy',
- data: 'discount_id=' + discount_id + '&pay_type=' + pay_type + '&ssid=' + ssid,
- dataType: 'json',
- success: function (result) {
- $(".pay-btn a:last").removeClass("disabled");
- $(".pay-btn a:last").addClass("toPay");
- if (result.code != 200) {
- alert(result.msg);
- return;
- }
- form = $("<form target='_self'></form>");
- form.attr('action', '/index/super_buy/pay');
- form.attr('method', 'get');
- form.append($("<input type='hidden' name='trade_id' value='" + result.data.trade_id + "'/>"));
- form.append($("<input type='hidden' name='pay_type' value='" + result.data.pay_type + "' />"));
- form.append($("<input type='hidden' name='ssid' value='" + result.data.ssid + "'/>"));
- form.appendTo("body");
- form.submit();
- }
- });
- })
-
- var clipboard = new ClipboardJS('.copy', {
- text: function (trigger) {
- alert('复制成功');
- trigger.style.color = "red";
- return trigger.getAttribute('title');
- }
- });
- });
- </script>
- </body>
- </html>
- <?php
- }
- function pay()
- {
- $trade_id = SafeRequest("trade_id", "get");
- $pay_type = SafeRequest("pay_type", "get");
- $ssid = SafeRequest("ssid", "get");
- $payinfo = db("paylog")->where("pay_id", $trade_id)->find();
- $gourl = "/index/super_buy?ssid=" . $ssid;
- if (!$payinfo || !$pay_type || !in_array($pay_type, json_decode(IN_PAY, true))) {
- exit(include_once IN_ROOT . "source/pack/error/404.php");
- }
- $ssl = is_ssl() ? "https://" : "http://";
- if ($pay_type == "1") {
- include_once IN_ROOT . "source/pack/pay/alipay/alipay.class.php";
- $returnUrl = $ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "index/super_buy?ssid=" . $ssid;
- $notifyUrl = $ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "pay/index/alipay_notify";
- $outTradeNo = $payinfo["pay_id"];
- $payAmount = $payinfo["pay_money"];
- $orderName = $payinfo["pay_tag"];
- $signType = "MD5";
- $pid = IN_ALIPAYID;
- $privateKey = IN_ALIPAYKEY;
- $aliPay = new \AlipayService($pid, $returnUrl, $notifyUrl, $signType, $privateKey);
- $sHtml = $aliPay->doPay($payAmount, $outTradeNo, $orderName, $returnUrl, $notifyUrl, 1);
- echo $sHtml;
- exit;
- }
- if ($pay_type == "2") {
- define("IN_WXUID", $this->userid);
- include_once IN_ROOT . "source/pack/pay/weixin/WxPay.Api.php";
- include_once IN_ROOT . "source/pack/pay/weixin/WxPay.NativePay.php";
- $input = new \WxPayUnifiedOrder();
- $input->SetBody($payinfo["pay_tag"]);
- $input->SetOut_trade_no($payinfo["pay_id"]);
- $input->SetTotal_fee($payinfo["pay_money"] * 100);
- $input->SetTime_start(date("YmdHis"));
- $input->SetTime_expire(date("YmdHis", time() + 600));
- $input->SetNotify_url($ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "pay/index/wxpay_notify");
- $input->SetTrade_type("NATIVE");
- $input->SetProduct_id($payinfo["in_id"]);
- $notify = new \NativePay();
- $result = $notify->GetPayUrl($input);
- if ($result["return_code"] == "FAIL") {
- $err = $result["return_msg"];
- exit(include_once IN_ROOT . "source/pack/error/404.php");
- } else {
- $code_url = $result["code_url"];
- }
- }
- if ($pay_type == "3" || $pay_type == "4") {
- $type = $pay_type == "3" ? 'alipaywap' : 'wxh5';
- $codepay_id = IN_CODEPAYID;
- $codepay_key = IN_CODEPAYKEY;
- $returnUrl = $ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "pay/index/codepay_return";
- $notifyUrl = $ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "pay/index/codepay_notify";
- $data = array("id" => $codepay_id, "pay_id" => $payinfo["pay_id"], "type" => $type, "price" => $payinfo["pay_money"], "param" => "", "notify_url" => $notifyUrl, "return_url" => $returnUrl);
- $userid=$codepay_id;
- $userkey=$codepay_key;
- $version='1.0';
- $customerid=$userid;
- $sdorderno=$payinfo["pay_id"];
- $total_fee=number_format($payinfo["pay_money"],2,'.','');
- $paytype=$type;
- $bankcode='';
- $notifyurl = $notifyUrl;
- $returnurl = $returnUrl;
- $remark='';
- $get_code='';
-
- $sign=md5('version='.$version.'&customerid='.$customerid.'&total_fee='.$total_fee.'&sdorderno='.$sdorderno.'¬ifyurl='.$notifyurl.'&returnurl='.$returnurl.'&'.$userkey);
- $native = array(
- "version" => $version,
- "customerid" => $customerid,
- "sdorderno" => $sdorderno,
- "total_fee" => $total_fee,
- "paytype" => $paytype,
- "notifyurl" => $notifyurl,
- "returnurl" => $returnurl,
- "remark" => $remark,
- "bankcode" => $bankcode,
- "sign" => $sign,
- "get_code" => $get_code,
- );
- $html = '<form name="form1" class="form-inline" method="post" action="http://pay.normalsky.cn/apisubmit">';
- foreach ($native as $key => $val) {
- $html .= '<input type="hidden" name="' . $key . '" value="' . $val . '">';
- }
- $html .= '</form>';
-
- $html .= '<script type="text/javascript">document.form1.submit()</script>';
-
- echo $html;die;
- var_dump($notifyUrl);die;
- redirect($url);
- }
- if ($pay_type == "5") {
- include_once IN_ROOT . "source/pack/pay/f2fpay/alipay.class.php";
- $notifyUrl = $ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "pay/index/f2fpay_notify";
- $orderName = $payinfo["pay_tag"];
- $config = ["appId" => IN_F2FPAYID, "signType" => IN_F2FPAY_STYPE, "privateKey" => IN_F2FPAY_MKEY, "publicKey" => IN_F2FPAY_AKEY, "notifyUrl" => $notifyUrl];
- $data = ["body" => $orderName, "subject" => $payinfo["pay_tag"], "out_trade_no" => $payinfo["pay_id"], "total_amount" => $payinfo["pay_money"]];
- $aliPay = new \AlipayService($config);
- $result = $aliPay->qrpay($data);
- if ($result["code"] != "10000") {
- $err = $result["msg"];
- exit(include_once IN_ROOT . "source/pack/error/404.php");
- } else {
- $code_url = $result["qr_code"];
- }
- }
- if ($pay_type == "7") {
- $api = "https://admin.zhanzhangfu.com/order/createOrder";
- $postDatas = array("price" => $payinfo["pay_money"], "name" => $payinfo["pay_tag"], "thirduid" => $payinfo["pay_id"], "remarks" => $payinfo["pay_tag"], "callbackurl" => $ssl . $_SERVER["HTTP_HOST"] . IN_PATH . "pay/index/zzpay_notify");
- $headers = array("Payment-Key:" . IN_ZZPAY_AppKey, "Payment-Secret:" . IN_ZZPAY_AppSecret);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $api);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postDatas);
- $output = curl_exec($ch);
- $zzpaydata = json_decode($output, true);
- curl_close($ch);
- if ($zzpaydata["code"] != 10001) {
- $err = $zzpaydata["msg"];
- exit(include_once IN_ROOT . "source/pack/error/404.php");
- }
- }
- ?> <!DOCTYPE html>
- <html lang="">
- <head lang="zh">
- <meta charset="UTF-8">
- <title>超级签下载码购买 -<?php echo IN_NAME;?></title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
- <meta name="renderer" content="webkit">
- <meta name="keywords" content="<?php echo IN_KEYWORDS;?>">
- <meta property="og:url" content="https://<?php echo $_SERVER["HTTP_HOST"];?>">
- <meta property="og:title" content="<?php echo IN_NAME;?>">
- <meta name="description" content="<?php echo IN_DESCRIPTION;?>">
- <link rel="stylesheet" href="/static/index/css/base.css"/>
- <style>
- header {
- padding: 10px;
- background-color: #ffe8dd;
- border: 1px solid #ffd5be;
- font-weight: bold;
- color: #ff671c;
- line-height: 1.5;
- text-align:center;
- }
- header a{position:absolute;color: #333;display:block;font-weight:normal;}
- article {
- padding: 10px 15px;font-size:12px;
- }
- .qrcode{
- border-color: #157df1;
- margin: 20px;
- border-radius: 3px;
- padding: 12px 20px 11px;
- text-align:center;
- }
- .qrcode img{max-width:100%;}
- </style>
- <script charset="utf-8" src="/static/index/js/jquery.min.js"></script>
- </head>
- <body>
- <header><a href="javascript:history.back();">< 返回</a>超级签下载码购买</header>
- <article>
- <p>支付说明:请保存支付二维码扫手机,然后扫码选择相册中二维码进行支付,支付完成后,会自动跳转到购买记录页面。</p>
- </article>
-
- <?php
- if ($pay_type == 2 || $pay_type == 5) {
- ?> <div class="qrcode">
- <img src="/qrcode?link=<?php echo $code_url;?>">
- <p> * 请您尽快完成支付 </p>
- </div>
- <?php
- }
- if ($pay_type == 7 && $zzpaydata) {
- ?> <link rel="stylesheet" type="text/css" href="/static/zzpay/css/onlinepay.css">
- <script>
- var timestr = "2020-09-29 14:05:20";
- var serverTime = (new Date(timestr.replace(/-/g, '/'))).getTime();//服务器初始时间
- var diffTime = (new Date()).getTime() - serverTime;//服务器校对时间差秒数
- diffTime = diffTime / 1000;
- </script>
- <div class="mod-ct">
- <h1 class="mod-title">
- <!--%e7%a6%81%e6%ad%a2%e5%80%92%e5%8d%96%2c%31%39%30%31%39%30%37%35%38%37-->
- <p style="color: rgb(51, 51, 51); font-size: 12px; margin-top: 10px; display: none;" class="n-wx-zfb">
- 请先截屏,使用支付宝"扫一扫"识别相册图片支付</p>
- <span class="ico_log ico-4"></span><span class="ico_log ico-3"></span>
- </h1>
- <div class="order"></div>
- <div class="amount" id="money"><span class="amount2"><?php echo $zzpaydata["price"];?></span></span></span></div>
- <div class="paybtn" style="display: none;"><a href="" id="alipaybtn" class="btn btn-primary" target="_blank">启动支付宝App支付</a>
- </div>
- <div class="qrcode-img-wrapper" data-role="qrPayImgWrapper">
- <div data-role="qrPayImg" class="qrcode-img-area">
- <div class="ui-loading qrcode-loading" data-role="qrPayImgLoading" style="display: none;"></div>
- <div style="position: relative;display: inline-block;">
- <!--付款码记得替换为自己的-->
- <img id="imgCode2" src="<?php echo $zzpaydata["zfbcode"];?>">
- <img id="imgCode3" src="<?php echo $zzpaydata["wxcode"];?>">
- <!--支付宝图标/微信图标-->
- <input name="istype" id="istype" type="hidden" value="1">
- <div id="qrcode"></div>
- <img src="" style="display: none" id="qrLost">
- <canvas id="imgCanvas" width="310" height="270" style="display: none;"></canvas>
- <div class="timeOut" style="display: none">过期时间<span id="timeOut">2020-09-29 14:11:20</span></div>
- <input type="hidden" id="now_time" value="2020-09-29 14:05:20">
- </div>
- </div>
- </div>
- <div class="time-item" style="padding-top: 10px">
- <div class="time-item" id="msg">
- <h1 class="overtime">订单名称:<span><?php echo $zzpaydata["name"];?></span></h1>
- </div>
- <div class="time-item"><h1>订单号:<span><?php echo $zzpaydata["orderId"];?></span></h1>
- <input type="hidden" value="<?php echo $zzpaydata["orderId"];?>" id="orderId"></div>
- <strong id="hour_show"><s id="h"></s>订单支付有效期</strong>
- <strong id="minute_show"><s></s></strong>
- <strong id="second_show"><s></s></strong>
- <div class="time-item"></div>
- <strong class='resultMsg'><s></s>20秒后自动获取支付结果</strong>
- </div>
- <div class="tip">
- <div class="ico-scan"></div>
- <div class="tip-text">
- <!--支付宝支付提示/微信支付提示-->
- <p id="showtext">打开支付宝或微信[扫一扫]</p>
- </div>
- </div>
- <!--ie判断版本-->
- <!--[if IE 8]>
- <div class="tip-text" style="color:#ff0000">您的浏览器版本较低,请升级后再试!</div>
- <![endif]-->
- <!--[if lt IE 8]>
- <div class="tip-text" style="color:#ff0000">您的浏览器版本较低,请升级后再试!</div>
- <![endif]-->
- </div>
- <script type="text/javascript" src="/static/zzpay/js/onlinepay.js"></script>
- <?php
- }
- ?> <script>
- $(document).ready(function () {
- window.setInterval(function () {
- getPayStatus();
- }, 2000);
- });
- function getPayStatus() {
- $.getJSON('/index/tradeStatus?id=<?php echo $trade_id;?>', function (data) {
- if (data.code == 200) {
- alert('支付成功!');
- window.location.href = '<?php echo $gourl;?>';
- }
- });
- }
- </script>
- </body>
- </html>
- <?php
- }
- }
|