|
|
@@ -19,17 +19,17 @@ use common\components\util;
|
|
|
|
|
|
class OrderController extends BaseController
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//商城下单操作 shish 2019.12.3
|
|
|
public function actionCreateOrder()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
//给出省市区的接口 todo
|
|
|
//给出商家门店地址接口 todo
|
|
|
//给出腾讯的接口 todo
|
|
|
//运费 计算方式 todo
|
|
|
//余额支付 要使用哪个接口 todo
|
|
|
-
|
|
|
+
|
|
|
$post = Yii::$app->request->post();
|
|
|
$goodsId = isset($post['goodsId']) ? $post['goodsId'] : 0;
|
|
|
$goodsStyleId = isset($post['goodsStyleId']) ? $post['goodsStyleId'] : 0;
|
|
|
@@ -99,11 +99,16 @@ class OrderController extends BaseController
|
|
|
//优惠券在支付成功后变更状态
|
|
|
$showPrice = stringUtil::calcSub($actPrice, $discountAmount);
|
|
|
}
|
|
|
+
|
|
|
+ $now = time();
|
|
|
+ $expireTime = $now + 1800;//订单30分钟后过期
|
|
|
+ $post['deadline'] = $expireTime;
|
|
|
+
|
|
|
$post['prePrice'] = $prePrice;
|
|
|
$post['actPrice'] = $actPrice;
|
|
|
$order = OrderService::addOrder($post);
|
|
|
$orderId = $order['id'];
|
|
|
-
|
|
|
+
|
|
|
$data = [
|
|
|
'orderId' => $orderId,
|
|
|
'goodsId' => $goodsId,
|
|
|
@@ -128,31 +133,12 @@ class OrderController extends BaseController
|
|
|
ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
$post = Yii::$app->request->post();
|
|
|
$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
|
|
|
- $now = time();
|
|
|
- $expireTime = $now + 1800;//订单30分钟后过期
|
|
|
- if ($this->merchantExtend['payment'] == 0) {
|
|
|
- util::fail('还没开通支付功能哟');
|
|
|
- }
|
|
|
$orderId = isset($post['orderId']) ? $post['orderId'] : 0;
|
|
|
$order = OrderService::getById($orderId);
|
|
|
- if (!empty($couponId)) {
|
|
|
- $coupon = xhCouponService::getById($couponId);
|
|
|
- if ($coupon['useStatus'] == 1 || $now > $coupon['deadline']) {
|
|
|
- util::fail('代金劵已经失效');
|
|
|
- }
|
|
|
- if ($coupon['meetAmount'] > $order['prePrice']) {
|
|
|
- util::fail('消费金额不足' . $coupon['meetAmount'] . '元');
|
|
|
- }
|
|
|
- }
|
|
|
- if ($order['userId'] != 0 && $order['userId'] != $this->userId) {//当 快速下单时,字段userId为0(未保存指定用户);用户操作后,就只能该用户访问
|
|
|
- util::fail('非法访问');
|
|
|
- }
|
|
|
- if (!empty($order['deadline']) && $now > $order['deadline']) {
|
|
|
- util::fail('订单已经过期');
|
|
|
- }
|
|
|
- if (ceil($order['actPrice']) <= 0) {
|
|
|
- util::fail('消费金额小于(等于)0');
|
|
|
- }
|
|
|
+
|
|
|
+ //验证订单有效性
|
|
|
+ OrderService::valid($order, $this->userId);
|
|
|
+
|
|
|
$name = $order['orderName'];
|
|
|
$totalFee = $order['actPrice'];
|
|
|
$openId = $this->user['openId'];
|
|
|
@@ -175,7 +161,6 @@ class OrderController extends BaseController
|
|
|
|
|
|
//服务商 代设置微信支付,要添加的参数设置
|
|
|
if ($this->merchantExtend['generalMerchant'] == 1) {
|
|
|
- //$input->SetOpenid($openId);
|
|
|
$input->SetSub_openid($openId);
|
|
|
//自设置 微信支付
|
|
|
} else {
|
|
|
@@ -186,17 +171,18 @@ class OrderController extends BaseController
|
|
|
$tools = new \JsApiPay();
|
|
|
$jsApiParameters = $tools->GetJsApiParameters($wxOrder, $this->merchantExtend);
|
|
|
$newParams = json_decode($jsApiParameters, true);
|
|
|
-
|
|
|
- $updateData = ['modPriceStatus' => 1];//已经请求微信不能修改价格
|
|
|
+ //已请求微信不能修改价格
|
|
|
+ $updateData = [];
|
|
|
+ $updateData['modPriceStatus'] = 1;
|
|
|
if (empty($order['deadline'])) {
|
|
|
$updateData['deadline'] = $expireTime;
|
|
|
}
|
|
|
- xhOrderService::updateById($orderId, $updateData);//已经请求微信不能修改价格
|
|
|
+ OrderService::updateById($orderId, $updateData);
|
|
|
util::success($newParams);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//快速付款订单
|
|
|
- public function actionFastCreateOrder()
|
|
|
+ public function actionFastWxPay()
|
|
|
{
|
|
|
ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
$post = Yii::$app->request->post();
|
|
|
@@ -325,7 +311,7 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
util::success(['orderId' => $orderId]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//快捷支付使用支付宝付款 shish 2019.12.3
|
|
|
public function actionFastZfbPay()
|
|
|
{
|
|
|
@@ -419,7 +405,7 @@ class OrderController extends BaseController
|
|
|
$result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
|
|
|
util::success($result);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 订单 - 支付宝支付
|
|
|
*/
|
|
|
@@ -464,5 +450,5 @@ class OrderController extends BaseController
|
|
|
$result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $config['notify_url']);
|
|
|
util::success($result);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|