|
|
@@ -7,10 +7,12 @@ use biz\shop\classes\ShopClass;
|
|
|
use biz\stat\classes\StatOutClass;
|
|
|
use biz\stat\classes\StatStockInClass;
|
|
|
use biz\stat\classes\StatStockOutClass;
|
|
|
+use bizGhs\item\classes\CostChangeClass;
|
|
|
use bizGhs\order\models\StockOutOrderItem;
|
|
|
use bizGhs\order\traits\OrderTrait;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\shop\classes\MainClass;
|
|
|
+use bizGhs\shop\classes\ShopAdminClass;
|
|
|
use bizGhs\stock\classes\StockInDayClass;
|
|
|
use bizGhs\stock\classes\StockRecordClass;
|
|
|
use bizHd\stat\classes\StatIncomeClass;
|
|
|
@@ -148,6 +150,11 @@ class StockInOrderClass extends BaseClass
|
|
|
public static function confirmOrder($orderSn, $shop, $adminId)
|
|
|
{
|
|
|
$shopId = $shop->id ?? 0;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $staff = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+
|
|
|
$data = ['status' => self::STATUS_COMPLETE, 'adminId' => $adminId];
|
|
|
$orderData = self::getOrderDetail($orderSn, $shopId);
|
|
|
if ($orderData['status'] != self::STATUS_WAIT) {
|
|
|
@@ -155,7 +162,14 @@ class StockInOrderClass extends BaseClass
|
|
|
}
|
|
|
$orderId = $orderData['id'];
|
|
|
self::updateById($orderId, $data);
|
|
|
- //加库存
|
|
|
+
|
|
|
+ $outShopId = $orderData['outShopId'] ?? 0;
|
|
|
+ $outShop = ShopClass::getById($outShopId, true);
|
|
|
+ $event = '从别的门店调拨过来';
|
|
|
+ if (!empty($outShop)) {
|
|
|
+ $event = '从' . $outShop->shopName . '调拨过来';
|
|
|
+ }
|
|
|
+
|
|
|
$itemInfo = $orderData['itemInfo'] ?? [];
|
|
|
if (empty($itemInfo)) {
|
|
|
util::fail("订单异常");
|
|
|
@@ -178,6 +192,23 @@ class StockInOrderClass extends BaseClass
|
|
|
$upData['skPrice'] = $currentSkPrice;
|
|
|
}
|
|
|
ProductClass::updateById($currentItemId, $upData);
|
|
|
+ //成本变动记录
|
|
|
+ $changeData = [
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'sjId' => $currentInfo->sjId ?? 0,
|
|
|
+ 'mainId' => $currentInfo->mainId ?? 0,
|
|
|
+ 'itemId' => $currentInfo->id ?? 0,
|
|
|
+ 'ptItemId' => $currentInfo->itemId ?? 0,
|
|
|
+ 'cost' => $currentCost,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'name' => $currentInfo->name ?? '',
|
|
|
+ 'cover' => $currentInfo->cover ?? '',
|
|
|
+ 'targetId' => $orderId,
|
|
|
+ 'type' => 1,
|
|
|
+ 'event' => $event,
|
|
|
+ ];
|
|
|
+ CostChangeClass::addData($changeData);
|
|
|
}
|
|
|
}
|
|
|
$stockInfo = ProductClass::addStockByItemNum($currentItemId, $v['itemNum']);
|