|
|
@@ -11,7 +11,9 @@ use biz\stat\classes\StatCgGhsClass;
|
|
|
use biz\stat\classes\StatOutClass;
|
|
|
use bizGhs\base\classes\BaseClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
+use bizGhs\item\classes\CostChangeClass;
|
|
|
use bizGhs\order\traits\OrderTrait;
|
|
|
+use bizGhs\shop\classes\ShopAdminClass;
|
|
|
use bizGhs\stock\classes\StockRecordClass;
|
|
|
use bizGhs\stock\services\StockRecordService;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
@@ -55,6 +57,9 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$shopId = $data['shopId'] ?? 0;
|
|
|
$mainId = $data['mainId'] ?? 0;
|
|
|
$ghsName = $data['ghsName'] ?? '';
|
|
|
+ $staffId = $data['staffId'] ?? 0;
|
|
|
+ $staffName = $data['staffName'] ?? '';
|
|
|
+ $adminId = $data['adminId'] ?? 0;
|
|
|
$data['status'] = self::PURCHASE_ORDER_STATUS_COMPLETE;
|
|
|
$orderSn = orderSn::getGhsPurchaseSn();
|
|
|
$data['orderSn'] = $orderSn;
|
|
|
@@ -240,6 +245,23 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$product->priceLabel = ProductClass::PRICE_LABEL_AUTO;
|
|
|
$product->save();
|
|
|
|
|
|
+ //成本变动记录
|
|
|
+ $changeData = [
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'itemId' => $productId,
|
|
|
+ 'ptItemId' => $itemId,
|
|
|
+ 'cost' => $unitCost,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'name' => $product->name ?? '',
|
|
|
+ 'cover' => $product->cover ?? '',
|
|
|
+ 'targetId' => $order->id ?? 0,
|
|
|
+ 'event' => '采购',
|
|
|
+ ];
|
|
|
+ CostChangeClass::addData($changeData);
|
|
|
+
|
|
|
if (isset($shop->default) && $shop->default == 1) {
|
|
|
//直营门店的成本价也要一起改掉
|
|
|
$allShop = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
|
|
|
@@ -253,7 +275,28 @@ class PurchaseOrderClass extends BaseClass
|
|
|
if (isset($currentShop->join) && $currentShop->join == 1) {
|
|
|
continue;
|
|
|
}
|
|
|
- ProductClass::updateByCondition(['mainId' => $currentId, 'itemId' => $currentItemId], ['cost' => $unitCost]);
|
|
|
+ $currentProduct = ProductClass::getByCondition(['mainId' => $currentId, 'itemId' => $currentItemId], true);
|
|
|
+ if (!empty($currentProduct)) {
|
|
|
+ $currentProduct->cost = $unitCost;
|
|
|
+ $currentProduct->save();
|
|
|
+ $currentStaff = ShopAdminClass::getByCondition(['mainId' => $currentProduct->mainId, 'adminId' => $adminId], true);
|
|
|
+ //成本变动记录
|
|
|
+ $changeData = [
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'sjId' => $currentProduct->sjId ?? 0,
|
|
|
+ 'mainId' => $currentProduct->mainId ?? 0,
|
|
|
+ 'itemId' => $currentProduct->id ?? 0,
|
|
|
+ 'ptItemId' => $currentProduct->itemId ?? 0,
|
|
|
+ 'cost' => $unitCost,
|
|
|
+ 'staffId' => $currentStaff->id ?? 0,
|
|
|
+ 'staffName' => $currentStaff->name ?? '',
|
|
|
+ 'name' => $currentProduct->name ?? '',
|
|
|
+ 'cover' => $currentProduct->cover ?? '',
|
|
|
+ 'targetId' => $order->id ?? 0,
|
|
|
+ 'event' => $shop->shopName . '采购',
|
|
|
+ ];
|
|
|
+ CostChangeClass::addData($changeData);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|