|
|
@@ -7,6 +7,7 @@ use biz\goods\services\GoodsCategoryService;
|
|
|
use biz\goods\services\GoodsService;
|
|
|
use biz\merchant\services\MerchantService;
|
|
|
use biz\merchant\services\ShopService;
|
|
|
+use biz\order\services\OrderGoodsService;
|
|
|
use biz\order\services\OrderService;
|
|
|
use biz\promote\services\CouponService;
|
|
|
use biz\user\services\UserAssetService;
|
|
|
@@ -18,18 +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;
|
|
|
@@ -101,9 +101,9 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
$post['prePrice'] = $prePrice;
|
|
|
$post['actPrice'] = $actPrice;
|
|
|
- $order = OrderService::add($post);
|
|
|
+ $order = OrderService::addOrder($post);
|
|
|
$orderId = $order['id'];
|
|
|
-
|
|
|
+
|
|
|
$data = [
|
|
|
'orderId' => $orderId,
|
|
|
'goodsId' => $goodsId,
|
|
|
@@ -117,7 +117,7 @@ class OrderController extends BaseController
|
|
|
'goodsStyleId' => $goodsStyleId,
|
|
|
'createTime' => date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
- xhOrderGoodsService::add($data);//创建订单商品列表
|
|
|
+ OrderGoodsService::add($data);//创建订单商品列表
|
|
|
|
|
|
util::success(['orderId' => $orderId, 'totalPrice' => $showPrice, 'couponId' => $couponId]);
|
|
|
}
|
|
|
@@ -134,7 +134,7 @@ class OrderController extends BaseController
|
|
|
util::fail('还没开通支付功能哟');
|
|
|
}
|
|
|
$orderId = isset($post['orderId']) ? $post['orderId'] : 0;
|
|
|
- $order = xhOrderService::getById($orderId);
|
|
|
+ $order = OrderService::getById($orderId);
|
|
|
if (!empty($couponId)) {
|
|
|
$coupon = xhCouponService::getById($couponId);
|
|
|
if ($coupon['useStatus'] == 1 || $now > $coupon['deadline']) {
|
|
|
@@ -195,51 +195,6 @@ class OrderController extends BaseController
|
|
|
util::success($newParams);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 订单 - 支付宝支付
|
|
|
- */
|
|
|
- public function actionZfbPay()
|
|
|
- {
|
|
|
- header("Content-type: text/html; charset=utf-8");
|
|
|
- $alipayWap = Yii::getAlias("@vendor/alipayWap");
|
|
|
- require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
|
|
|
- require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
|
|
|
- require_once($alipayWap . '/config.php');
|
|
|
-
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- $orderId = isset($get['orderId']) ? $get['orderId'] : 0;
|
|
|
- $couponId = isset($get['couponId']) ? $get['couponId'] : 0;
|
|
|
- $orderData = xhOrderService::getById($orderId);
|
|
|
- $waitForPay = configDict::getConfig('payStatus', 'waitForPay');
|
|
|
- if ($orderData['payStatus'] != $waitForPay) {
|
|
|
- echo '已经支付成功';
|
|
|
- util::end();
|
|
|
- }
|
|
|
- $merchantId = $orderData['merchantId'];
|
|
|
- $out_trade_no = $orderId;//商户订单号,商户网站订单系统中唯一订单号,必填
|
|
|
- $subject = $orderData['orderName'];//订单名称,必填
|
|
|
- $total_amount = $orderData['actPrice'];;//付款金额,必填
|
|
|
- $body = '';//商品描述,可空
|
|
|
- $timeout_express = "1m";//超时时间
|
|
|
-
|
|
|
- $typeList = configDict::getConfig('capitalType');
|
|
|
- $capitalType = $typeList['xhOrder']['id'];
|
|
|
- $passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、代金劵传过去
|
|
|
- $passbackParams = urlencode($passbackParams);
|
|
|
-
|
|
|
- $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
|
|
|
- $payRequestBuilder->setBody($body);
|
|
|
- $payRequestBuilder->setSubject($subject);
|
|
|
- $payRequestBuilder->setOutTradeNo($out_trade_no);
|
|
|
- $payRequestBuilder->setTotalAmount($total_amount);
|
|
|
- $payRequestBuilder->setTimeExpress($timeout_express);
|
|
|
- $payRequestBuilder->setPassbackParams($passbackParams);//在异步通知时将该参数原样返回
|
|
|
- $returnUrl = Yii::$app->params['frontUrl'] . "/notice/order-alipay-sync";
|
|
|
- $payResponse = new \AlipayTradeService($config);
|
|
|
- $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $config['notify_url']);
|
|
|
- util::success($result);
|
|
|
- }
|
|
|
-
|
|
|
//快速付款订单
|
|
|
public function actionFastCreateOrder()
|
|
|
{
|
|
|
@@ -464,5 +419,50 @@ class OrderController extends BaseController
|
|
|
$result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
|
|
|
util::success($result);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单 - 支付宝支付
|
|
|
+ */
|
|
|
+ public function actionZfbPay()
|
|
|
+ {
|
|
|
+ header("Content-type: text/html; charset=utf-8");
|
|
|
+ $alipayWap = Yii::getAlias("@vendor/alipayWap");
|
|
|
+ require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
|
|
|
+ require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
|
|
|
+ require_once($alipayWap . '/config.php');
|
|
|
+
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $orderId = isset($get['orderId']) ? $get['orderId'] : 0;
|
|
|
+ $couponId = isset($get['couponId']) ? $get['couponId'] : 0;
|
|
|
+ $orderData = xhOrderService::getById($orderId);
|
|
|
+ $waitForPay = configDict::getConfig('payStatus', 'waitForPay');
|
|
|
+ if ($orderData['payStatus'] != $waitForPay) {
|
|
|
+ echo '已经支付成功';
|
|
|
+ util::end();
|
|
|
+ }
|
|
|
+ $merchantId = $orderData['merchantId'];
|
|
|
+ $out_trade_no = $orderId;//商户订单号,商户网站订单系统中唯一订单号,必填
|
|
|
+ $subject = $orderData['orderName'];//订单名称,必填
|
|
|
+ $total_amount = $orderData['actPrice'];;//付款金额,必填
|
|
|
+ $body = '';//商品描述,可空
|
|
|
+ $timeout_express = "1m";//超时时间
|
|
|
+
|
|
|
+ $typeList = configDict::getConfig('capitalType');
|
|
|
+ $capitalType = $typeList['xhOrder']['id'];
|
|
|
+ $passbackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、代金劵传过去
|
|
|
+ $passbackParams = urlencode($passbackParams);
|
|
|
+
|
|
|
+ $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
|
|
|
+ $payRequestBuilder->setBody($body);
|
|
|
+ $payRequestBuilder->setSubject($subject);
|
|
|
+ $payRequestBuilder->setOutTradeNo($out_trade_no);
|
|
|
+ $payRequestBuilder->setTotalAmount($total_amount);
|
|
|
+ $payRequestBuilder->setTimeExpress($timeout_express);
|
|
|
+ $payRequestBuilder->setPassbackParams($passbackParams);//在异步通知时将该参数原样返回
|
|
|
+ $returnUrl = Yii::$app->params['frontUrl'] . "/notice/order-alipay-sync";
|
|
|
+ $payResponse = new \AlipayTradeService($config);
|
|
|
+ $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $config['notify_url']);
|
|
|
+ util::success($result);
|
|
|
+ }
|
|
|
+
|
|
|
}
|