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