|
|
@@ -3,9 +3,11 @@
|
|
|
namespace mall\controllers;
|
|
|
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
+use bizMall\goods\classes\GoodsClass;
|
|
|
use bizMall\goods\services\GoodsService;
|
|
|
use bizMall\merchant\services\ExpressService;
|
|
|
use bizMall\order\classes\OrderClass;
|
|
|
+use bizMall\order\classes\OrderGoodsClass;
|
|
|
use bizMall\order\services\OrderGoodsService;
|
|
|
use bizMall\order\services\OrderService;
|
|
|
use bizMall\promote\services\CouponService;
|
|
|
@@ -74,10 +76,15 @@ class OrderController extends BaseController
|
|
|
if (empty($goodsId)) {
|
|
|
util::fail('请选择商品');
|
|
|
}
|
|
|
- $goodsInfo = GoodsService::getGoodsInfo($goodsId);
|
|
|
+ $goodsInfo = GoodsClass::getGoodsInfo($goodsId);
|
|
|
if (empty($goodsInfo)) {
|
|
|
util::fail('没有找到商品');
|
|
|
}
|
|
|
+ $stock = $goodsInfo['stock'] && is_numeric($goodsInfo['stock']) ? $goodsInfo['stock'] : 0;
|
|
|
+ $stockSet = $goodsInfo['stockSet'] && is_numeric($goodsInfo['stockSet']) ? $goodsInfo['stockSet'] : 0;
|
|
|
+ if ($stock <= 0 && $stockSet == 0) {
|
|
|
+ util::fail('库存不足');
|
|
|
+ }
|
|
|
//运费计算方式
|
|
|
$freightType = isset($goodsInfo['freightType']) ? $goodsInfo['freightType'] : 0;
|
|
|
//事务处理
|
|
|
@@ -160,10 +167,9 @@ class OrderController extends BaseController
|
|
|
'unitPrice' => $unitPrice,
|
|
|
'num' => $goodsNum,
|
|
|
'orderSn' => $orderSn,
|
|
|
- 'goodsStyleName' => isset($goodsInfo['goodsStyleList'][$goodsStyleId]['title']) ? $goodsInfo['goodsStyleList'][$goodsStyleId]['title'] : '',
|
|
|
'createTime' => date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
- OrderGoodsService::add($data);//创建订单商品列表
|
|
|
+ OrderGoodsClass::addData($data);
|
|
|
$transaction->commit();
|
|
|
util::success(['orderSn' => $orderSn, 'totalPrice' => $actPrice, 'couponId' => $couponId, 'id' => $orderId]);
|
|
|
} catch (Exception $e) {
|