作者 lihan
1 个管道 的构建 通过 耗费 1 秒

支付宝

... ... @@ -115,6 +115,7 @@ class OrderController extends HomeBaseController
$data['room'] = $post['room'];
$data['desc'] = $post['desc'];
$final_price = $this->getFinalPrice($data['activity_id'], $data['schedule_id'], $post['num'], $data['discount_coupon_id']);
$data['order_amount'] = $final_price;
$post['escort'] = substr($post['escort'], 0, strlen($post['escort']) - 1);
if (empty($post['escort'])) {
echo json_encode(['msg' => '请选择出行人', 'code' => 40000]);
... ... @@ -167,7 +168,7 @@ class OrderController extends HomeBaseController
$this->success('微信支付', url('user/Center/orderDetail', ['oid' => $oid]), $this->wxPay($info));
} //支付宝支付
elseif ($data['payment'] == 2) {
echo json_encode(['msg'=>'支付宝', 'url'=>url('order/Order/temp',['oid'=>$oid]), 'code'=>20000]);
echo json_encode(['msg'=>'支付宝', 'url'=>url('order/Order/temp',['oid'=>$oid,'step'=>1]), 'code'=>20000]);
exit();
} //余额支付
elseif ($data['payment'] == 0) {
... ... @@ -228,8 +229,8 @@ class OrderController extends HomeBaseController
Db::name('order_info')->update(['id' => $oid, 'payment' => $payment]);
if ($payment == 0) {
$model = new OrderModel;
$balance = Db::name('user')->where(['id'=>session('user.id')])->value('balance');
if($balance < $order_amount) {
$balance = Db::name('user')->where(['id' => session('user.id')])->value('balance');
if ($balance < $order_amount) {
echo json_encode(['msg' => '您的余额不足', 'code' => 40000]);
exit();
}
... ... @@ -254,7 +255,8 @@ class OrderController extends HomeBaseController
echo json_encode(['msg' => '微信支付', 'data' => $this->wxPay($data), 'code' => 20000, 'url' => url('user/Center/orderDetail', ['oid' => $oid])]);
exit();
} elseif ($payment == 2) {
echo json_encode(['msg' => '支付宝支付', 'code' => 20000]);
echo json_encode(['msg' => '支付宝', 'url' => url('order/Order/temp', ['oid' => $oid, 'step' => 2]), 'code' => 20000]);
exit();
} else {
echo json_encode(['msg' => '未知错误', 'code' => 40000]);
exit();
... ... @@ -360,27 +362,57 @@ class OrderController extends HomeBaseController
//微信支付宝中转页面
public function temp() {
if(cmf_is_wechat()) {
echo '<div style="">点击右上角,在浏览器打开</div>';
return $this->fetch(':temp');
}else {
$
$this->alipay(1);
$request = request();
$oid = $request->param('oid');
$step = $request->param('step');
$this->alipay($oid, $step);
}
}
//欢迎支付宝支付
private function alipay($oid)
private function alipay($oid, $step)
{
if($step == 1) {
$out_trade_no = '2018101210215'.$step;
$subject = '支付宝支付';
$total_amount = Db::name('order_info')->where(['id'=>$oid])->value('order_amount');
$body = '商品';
}elseif ($step == 2) {
$info = Db::name('order_info')->alias('o')
->field('status,order_type,a.down_price,s.price')
->join('activity a', 'o.activity_id=a.id')
->join('activity_schedule s ', 'o.schedule_id=s.id')
->where(['o.id' => $oid])->find();
$num = Db::name('order_detail')->where(['oid' => $oid, 'status' => ['neq', 2]])->count();
if ($info['status'] == 1) {
if ($info['order_type'] == 0) {
$order_amount = $num * $info['price'];
} elseif ($info['order_type'] == 1) {
$order_amount = $num * $info['down_price'];
} else {
$order_amount = 0;
}
} elseif ($info['status'] == 3) {
$order_amount = $num * $info['price'];
} else {
$order_amount = 0;
}
$out_trade_no = '2018101210215'.$step;
$subject = '支付宝支付';
$total_amount = $order_amount;
$body = '商品';
}else {
return false;
}
if(!cmf_is_wechat()) {
header("Content-type: text/html; charset=utf-8");
require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
require_once EXTEND_PATH . '/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
require EXTEND_PATH . '/alipay/config.php';
$out_trade_no = '2018101210215';
$subject = '购买';
$total_amount = 0.01;
$body = '商品';
//超时时间
$timeout_express = "1m";
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>支付宝</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name='apple-touch-fullscreen' content='yes'>
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="address=no">
<style>
body{margin:0}a:active,a:hover{outline:0}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}img{vertical-align:middle;border:0}@-ms-viewport{width:device-width}html{font-size:312.5%;-webkit-tap-highlight-color:transparent;height:100%;min-width:320px;overflow-x:hidden}body{font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;font-size:.28em;line-height:1;color:#333;background-color:#F0EFED}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-weight:500;line-height:1.2;line-height:1.1}h1 small,h1 .small,h2 small,h2 .small,h3 small,h3 .small,h4 small,h4 .small,h5 small,h5 .small,h6 small,h6 .small,.h1 small,.h1 .small,.h2 small,.h2 .small,.h3 small,.h3 .small,.h4 small,.h4 .small,.h5 small,.h5 .small,.h6 small,.h6 .small{font-weight:400;line-height:1}h1,.h1,h2,.h2,h3,.h3{margin-top:.28rem;margin-bottom:.14rem}h1 small,h1 .small,.h1 small,.h1 .small,h2 small,h2 .small,.h2 small,.h2 .small,h3 small,h3 .small,.h3 small,.h3 .small{font-size:65%}h4,.h4,h5,.h5,h6,.h6{margin-top:.14rem;margin-bottom:.14rem}h4 small,h4 .small,.h4 small,.h4 .small,h5 small,h5 .small,.h5 small,.h5 .small,h6 small,h6 .small,.h6 small,.h6 .small{font-size:75%}h1,.h1{font-size:.364rem}h2,.h2{font-size:.2996rem}h3,.h3{font-size:.238rem}h4,.h4{font-size:.175rem}h5,.h5{font-size:.14rem}h6,.h6{font-size:.119rem}h6{margin-top:0;margin-bottom:0}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#2BB2A3;text-decoration:none;outline:0}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}ul{margin:0;padding:0;list-style-type:none}hr{margin-top:.28rem;margin-bottom:.28rem;border:0;border-top:1px solid #DDD8CE}p,h6{line-height:1.41;text-align:justify;margin:-.2em 0;word-break:break-all}weak,small{color:#666}space{display:inline-block;width:.12rem}.imgbox img{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%, -50%);-ms-transform:translate(-50%, -50%);-moz-transform:translate(-50%, -50%)}input.mt[type=radio],input.mt[type=checkbox]{-webkit-appearance:none;width:.45rem;height:.45rem;margin:-.07rem 0;border-radius:50%;border:.02rem solid #DDD8CE;text-align:center;vertical-align:middle;line-height:.45rem;outline:0}input.mt[type=checkbox]{border-radius:.06rem}label.mt{margin-right:.16rem;vertical-align:middle;font-size:.3rem}input.mt[type=radio]:checked,input.mt[type=checkbox]:checked{background-color:#2BB2A3;border:0;color:#FFF}input.mt[type=radio]:checked:after,input.mt[type=checkbox]:checked:after{content:"✓";font-size:.4rem;font-family:base_icon}.mt[disabled=disabled]{background:#EEE;border-color:#CCC;color:#CCC}.stepper input{outline:0}.stepper .btn{width:.6rem;padding:0;outline:0;font-size:.5rem;line-height:.6rem;font-weight:lighter;font-family:CourierNewPSMT, "Times New Roman"}.stepper .btn.minus{font-family:CourierNewPSMT, Verdana}.automove .page{-webkit-transition:-webkit-transform .2s}.albumContainer .page img{display:block}.albumContainer .page-number-container{z-index:2;position:absolute;color:#FFF;font-size:.4rem;left:0;top:0;text-align:center;width:100%;margin-top:.3rem}.albumContainer .page-number{padding:.2rem;background:rgba(0, 0, 0, .5)}button:focus{outline:0}.btn{display:inline-block;margin:20px 0 0;text-align:center;height:.6rem;padding:0 .32rem;border-radius:.06rem;color:#FFF;border:0;background-color:#FE6000;font-size:.28rem;vertical-align:middle;line-height:.6rem;box-sizing:border-box;cursor:pointer;-webkit-user-select:none}.btn-block{display:block;width:100%}.btn-larger{height:.94rem;line-height:.94rem;font-size:.4rem}.wrapper{overflow:hidden;padding:0 .2rem}.wrapper h4{font-size:.3rem}.wrapper-list h4{margin:.6rem .2rem .2rem;font-size:.34rem;font-weight:400}.weapper-list h4:first-of-type{margin-top:.3rem}.box-btn a{padding:.2rem}dl.list{border-top:1px solid #DDD8CE;border-bottom:1px solid #DDD8CE;margin-top:.2rem;margin-bottom:0;background-color:#FFF}dl.list dt,dl.list dd{margin:0;border-bottom:1px solid #DDD8CE;overflow:hidden;font-size:inherit;font-weight:400;position:relative}dl.list dt:last-child,dl.list dd:last-of-type{border-bottom:0}dl.list .dd-padding,dl.list dt,dl.list dd > .react{padding:.28rem .2rem}dl.list dt{font-size:.34rem;padding-bottom:.2rem;color:#333}dl.list .db{height:.88rem;line-height:.88rem;font-size:.3rem}dl.list dd dl{margin:0;margin-bottom:-1px;padding-left:.2rem;border:0}dl.list dd dl > .dd-padding,dl.list dd dl dd > .react,dl.list dd dl > dt{padding-left:0}dl.list .db > .react{color:#2BB2A3;padding:0 .2rem}dl.list-in{margin:0;border-top:0}dl.list:first-child{margin:0;border-top:0}dl.list dd > .input-weak{width:100%;display:block}dl.list dd > .btn{margin-top:-.15rem;margin-bottom:-.15rem}.kv-line > h6,.kv-line > .kv-k{display:block;width:5em;font-size:inherit;font-weight:400}.kv-line > .kv-v,.kv-line > p{display:block;-webkit-box-flex:1;-moz-box-flex:1;-ms-flex:1}.kv-line-r{display:-webkit-box;display:-ms-flexbox;margin:.2rem 0}.kv-line-r > h6,.kv-line-r > .kv-k{-webkit-box-flex:1;-moz-box-flex:1;-ms-flex:1;font-size:inherit;font-weight:400;margin-right:.2rem;display:block}.kv-line-r > .kv-v,.kv-line-r > p{display:block}ul.tab-strong{border-color:#2BB2A3;color:#2BB2A3}.tab-strong li{border-right-color:#2BB2A3}.tab-strong li.active{background:#2BB2A3}.taba li{display:block;text-align:center;-webkit-box-flex:1;-ms-flex:1;position:relative}.taba.noslide li.active:after{content:null}.taba li.active:after{content:"";display:block;position:absolute;bottom:-.08rem;border-bottom:.08rem solid #2BB2A3;width:100%}.taba li a.react{padding-top:.28rem;padding-bottom:.2rem}.taba.noslide li.active:after{content:none}.navbar{height:1.01rem;color:#FFF;background:#FE6000;display:-webkit-box;display:-ms-flexbox;position:relative}.navbar h1.nav-header{-webkit-box-flex:1;-ms-flex:1;font-size:.36rem;font-weight:lighter;text-align:center;line-height:1rem;margin:0;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}
</style>
</head>
<body id="order-check" data-com="pagecommon">
<div class="wrapper-list">
<div id="pay-methods-panel" class="pay-methods-panel">
<div class="wrapper buy-wrapper">
<a href="" class="J-btn-submit btn mj-submit btn-strong btn-larger btn-block">点击右上角,从浏览器打开</a>
</div>
</div>
</div>
</body>
</html>
... ...