|
|
@@ -114,8 +114,9 @@ class OrderClass extends BaseClass
|
|
|
if ($order->stockChange == 1) {
|
|
|
util::fail('您已操作过了');
|
|
|
}
|
|
|
- $sjId = $data['sjId'] ?? 0;
|
|
|
- $shopId = $data['shopId'] ?? 0;
|
|
|
+ $sjId = $order->sjId ?? 0;
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $mainId = $order->mainId ?? 0;
|
|
|
//product [{"productId":"3674","num":0,"price":1}]
|
|
|
$product = $data['product'] ?? '';
|
|
|
if (empty($product)) {
|
|
|
@@ -162,7 +163,6 @@ class OrderClass extends BaseClass
|
|
|
$val->xhPrice = $price;
|
|
|
$val->save();
|
|
|
|
|
|
- Yii::info('数量 num num' . $val->xhPreNum . ' ' . $num . ' ' . bcsub($val->xhPreNum, $num));
|
|
|
if ($val->xhPreNum > $num) {
|
|
|
//客户下单退货数增加
|
|
|
$subNum = bcsub($val->xhPreNum, $num);
|
|
|
@@ -183,11 +183,28 @@ class OrderClass extends BaseClass
|
|
|
$smallNum = 0;
|
|
|
if ($unitType == dict::getDict('unitType', 'big')) {
|
|
|
$bigNum = $num;
|
|
|
+ $itemNum = $num;
|
|
|
} else {
|
|
|
$smallNum = $num;
|
|
|
+ $itemNum = bcdiv($num, $val->ratio, 2);
|
|
|
}
|
|
|
- $option = ['relateName' => $customName, 'ptStyle' => dict::getDict('ptStyle', 'ghs')];
|
|
|
- StockClass::stockSellItem($orderSn, $sjId, $shopId, $productId, $bigNum, $smallNum, $option);
|
|
|
+
|
|
|
+ $checkStock = true;
|
|
|
+ $stockInfo = ProductClass::decreaseStock($productId, $bigNum, $smallNum, $checkStock);
|
|
|
+ $recordData = [];
|
|
|
+ $recordData['sjId'] = $sjId;
|
|
|
+ $recordData['shopId'] = $shopId;
|
|
|
+ $recordData['mainId'] = $mainId;
|
|
|
+ $recordData['itemId'] = $val->itemId;
|
|
|
+ $recordData['itemNum'] = $itemNum;
|
|
|
+ $recordData['oldStock'] = $stockInfo['oldStock'];
|
|
|
+ $recordData['newStock'] = $stockInfo['newStock'];
|
|
|
+ $recordData['productId'] = $productId;
|
|
|
+ $recordData['orderSn'] = $orderSn;
|
|
|
+ $recordData['relateName'] = $customName;
|
|
|
+ $recordData['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
+ StockRecordClass::addSellStockOrderRecord($recordData);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
$order->itemPrice = $itemPrice;
|