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

支付宝

@@ -115,6 +115,7 @@ class OrderController extends HomeBaseController @@ -115,6 +115,7 @@ class OrderController extends HomeBaseController
115 $data['room'] = $post['room']; 115 $data['room'] = $post['room'];
116 $data['desc'] = $post['desc']; 116 $data['desc'] = $post['desc'];
117 $final_price = $this->getFinalPrice($data['activity_id'], $data['schedule_id'], $post['num'], $data['discount_coupon_id']); 117 $final_price = $this->getFinalPrice($data['activity_id'], $data['schedule_id'], $post['num'], $data['discount_coupon_id']);
  118 + $data['order_amount'] = $final_price;
118 $post['escort'] = substr($post['escort'], 0, strlen($post['escort']) - 1); 119 $post['escort'] = substr($post['escort'], 0, strlen($post['escort']) - 1);
119 if (empty($post['escort'])) { 120 if (empty($post['escort'])) {
120 echo json_encode(['msg' => '请选择出行人', 'code' => 40000]); 121 echo json_encode(['msg' => '请选择出行人', 'code' => 40000]);
@@ -167,7 +168,7 @@ class OrderController extends HomeBaseController @@ -167,7 +168,7 @@ class OrderController extends HomeBaseController
167 $this->success('微信支付', url('user/Center/orderDetail', ['oid' => $oid]), $this->wxPay($info)); 168 $this->success('微信支付', url('user/Center/orderDetail', ['oid' => $oid]), $this->wxPay($info));
168 } //支付宝支付 169 } //支付宝支付
169 elseif ($data['payment'] == 2) { 170 elseif ($data['payment'] == 2) {
170 - echo json_encode(['msg'=>'支付宝', 'url'=>url('order/Order/temp',['oid'=>$oid]), 'code'=>20000]); 171 + echo json_encode(['msg'=>'支付宝', 'url'=>url('order/Order/temp',['oid'=>$oid,'step'=>1]), 'code'=>20000]);
171 exit(); 172 exit();
172 } //余额支付 173 } //余额支付
173 elseif ($data['payment'] == 0) { 174 elseif ($data['payment'] == 0) {
@@ -228,8 +229,8 @@ class OrderController extends HomeBaseController @@ -228,8 +229,8 @@ class OrderController extends HomeBaseController
228 Db::name('order_info')->update(['id' => $oid, 'payment' => $payment]); 229 Db::name('order_info')->update(['id' => $oid, 'payment' => $payment]);
229 if ($payment == 0) { 230 if ($payment == 0) {
230 $model = new OrderModel; 231 $model = new OrderModel;
231 - $balance = Db::name('user')->where(['id'=>session('user.id')])->value('balance');  
232 - if($balance < $order_amount) { 232 + $balance = Db::name('user')->where(['id' => session('user.id')])->value('balance');
  233 + if ($balance < $order_amount) {
233 echo json_encode(['msg' => '您的余额不足', 'code' => 40000]); 234 echo json_encode(['msg' => '您的余额不足', 'code' => 40000]);
234 exit(); 235 exit();
235 } 236 }
@@ -254,7 +255,8 @@ class OrderController extends HomeBaseController @@ -254,7 +255,8 @@ class OrderController extends HomeBaseController
254 echo json_encode(['msg' => '微信支付', 'data' => $this->wxPay($data), 'code' => 20000, 'url' => url('user/Center/orderDetail', ['oid' => $oid])]); 255 echo json_encode(['msg' => '微信支付', 'data' => $this->wxPay($data), 'code' => 20000, 'url' => url('user/Center/orderDetail', ['oid' => $oid])]);
255 exit(); 256 exit();
256 } elseif ($payment == 2) { 257 } elseif ($payment == 2) {
257 - echo json_encode(['msg' => '支付宝支付', 'code' => 20000]); 258 + echo json_encode(['msg' => '支付宝', 'url' => url('order/Order/temp', ['oid' => $oid, 'step' => 2]), 'code' => 20000]);
  259 + exit();
258 } else { 260 } else {
259 echo json_encode(['msg' => '未知错误', 'code' => 40000]); 261 echo json_encode(['msg' => '未知错误', 'code' => 40000]);
260 exit(); 262 exit();
@@ -360,27 +362,57 @@ class OrderController extends HomeBaseController @@ -360,27 +362,57 @@ class OrderController extends HomeBaseController
360 //微信支付宝中转页面 362 //微信支付宝中转页面
361 public function temp() { 363 public function temp() {
362 if(cmf_is_wechat()) { 364 if(cmf_is_wechat()) {
363 - echo '<div style="">点击右上角,在浏览器打开</div>'; 365 + return $this->fetch(':temp');
364 }else { 366 }else {
365 - $  
366 - $this->alipay(1); 367 + $request = request();
  368 + $oid = $request->param('oid');
  369 + $step = $request->param('step');
  370 + $this->alipay($oid, $step);
367 } 371 }
368 372
369 } 373 }
370 374
371 //欢迎支付宝支付 375 //欢迎支付宝支付
372 - private function alipay($oid) 376 + private function alipay($oid, $step)
373 { 377 {
  378 + if($step == 1) {
  379 + $out_trade_no = '2018101210215'.$step;
  380 + $subject = '支付宝支付';
  381 + $total_amount = Db::name('order_info')->where(['id'=>$oid])->value('order_amount');
  382 + $body = '商品';
  383 + }elseif ($step == 2) {
  384 + $info = Db::name('order_info')->alias('o')
  385 + ->field('status,order_type,a.down_price,s.price')
  386 + ->join('activity a', 'o.activity_id=a.id')
  387 + ->join('activity_schedule s ', 'o.schedule_id=s.id')
  388 + ->where(['o.id' => $oid])->find();
  389 + $num = Db::name('order_detail')->where(['oid' => $oid, 'status' => ['neq', 2]])->count();
  390 + if ($info['status'] == 1) {
  391 + if ($info['order_type'] == 0) {
  392 + $order_amount = $num * $info['price'];
  393 + } elseif ($info['order_type'] == 1) {
  394 + $order_amount = $num * $info['down_price'];
  395 + } else {
  396 + $order_amount = 0;
  397 + }
  398 + } elseif ($info['status'] == 3) {
  399 + $order_amount = $num * $info['price'];
  400 + } else {
  401 + $order_amount = 0;
  402 + }
  403 + $out_trade_no = '2018101210215'.$step;
  404 + $subject = '支付宝支付';
  405 + $total_amount = $order_amount;
  406 + $body = '商品';
  407 + }else {
  408 + return false;
  409 + }
374 if(!cmf_is_wechat()) { 410 if(!cmf_is_wechat()) {
375 header("Content-type: text/html; charset=utf-8"); 411 header("Content-type: text/html; charset=utf-8");
376 require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php'; 412 require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
377 require_once EXTEND_PATH . '/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php'; 413 require_once EXTEND_PATH . '/alipay/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php';
378 require EXTEND_PATH . '/alipay/config.php'; 414 require EXTEND_PATH . '/alipay/config.php';
379 415
380 - $out_trade_no = '2018101210215';  
381 - $subject = '购买';  
382 - $total_amount = 0.01;  
383 - $body = '商品';  
384 //超时时间 416 //超时时间
385 $timeout_express = "1m"; 417 $timeout_express = "1m";
386 418
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta charset="utf-8"/>
  5 + <title>支付宝</title>
  6 + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
  7 + <meta name="apple-mobile-web-app-capable" content="yes">
  8 + <meta name='apple-touch-fullscreen' content='yes'>
  9 + <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10 + <meta name="format-detection" content="telephone=no">
  11 + <meta name="format-detection" content="address=no">
  12 + <style>
  13 + 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}
  14 + </style>
  15 +</head>
  16 +<body id="order-check" data-com="pagecommon">
  17 +<div class="wrapper-list">
  18 + <div id="pay-methods-panel" class="pay-methods-panel">
  19 + <div class="wrapper buy-wrapper">
  20 +
  21 + <a href="" class="J-btn-submit btn mj-submit btn-strong btn-larger btn-block">点击右上角,从浏览器打开</a>
  22 + </div>
  23 + </div>
  24 +</div>
  25 +</body>
  26 +</html>