|
|
@@ -466,9 +466,8 @@ class ProductClass extends BaseClass
|
|
|
public static function complementProduct($sjId, $mainId, $shopId, $itemInfo)
|
|
|
{
|
|
|
$itemIds = array_column($itemInfo, "itemId");
|
|
|
- $itemData = array_column($itemInfo, null, "itemId");
|
|
|
+ $oldProductIds = array_column($itemInfo, "productId");
|
|
|
$productData = self::getGhsProductDataByItemIds($mainId, $itemIds);
|
|
|
-
|
|
|
$defaultClass = ItemClassClass::getByCondition(['mainId' => $mainId, 'isDefault' => 1], true);
|
|
|
$defaultClassId = $defaultClass->id ?? 0;
|
|
|
if (empty($defaultClassId)) {
|
|
|
@@ -485,35 +484,40 @@ class ProductClass extends BaseClass
|
|
|
//取差集
|
|
|
$diffItemIds = array_diff($itemIds, $productDataItemIds);
|
|
|
if ($diffItemIds) {
|
|
|
+
|
|
|
+ $oldProductInfo = ProductClass::getAllByCondition(['id' => ['in', $oldProductIds]], null, '*', 'itemId');
|
|
|
+
|
|
|
//新增到product表,price = itemPrice (出库时的售价), stock=0
|
|
|
foreach ($diffItemIds as $v) {
|
|
|
+
|
|
|
$addData = [];
|
|
|
$addData['sjId'] = $sjId;
|
|
|
$addData['shopId'] = $shopId;
|
|
|
$addData['mainId'] = $mainId;
|
|
|
$addData['itemId'] = $v;
|
|
|
- $addData['name'] = $itemData[$v]['name'] ?? '';
|
|
|
- $addData['price'] = $itemData[$v]['price'] ?? 0;
|
|
|
+ $addData['name'] = $oldProductInfo[$v]['name'] ?? '';
|
|
|
+ $addData['price'] = $oldProductInfo[$v]['price'] ?? 0;
|
|
|
$addData['classId'] = $defaultClassId;
|
|
|
- $addData['smallRatio'] = $itemData[$v]['smallRatio'] ?? 2;
|
|
|
- $addData['skPrice'] = $itemData[$v]['skPrice'] ?? 0;
|
|
|
- $addData['hjPrice'] = $itemData[$v]['hjPrice'] ?? 0;
|
|
|
- $addData['cost'] = $itemData[$v]['cost'] ?? 0;
|
|
|
- $addData['addPrice'] = $itemData[$v]['addPrice'] ?? 0;
|
|
|
- $addData['skAddPrice'] = $itemData[$v]['skAddPrice'] ?? 0;
|
|
|
- $addData['hjAddPrice'] = $itemData[$v]['hjAddPrice'] ?? 0;
|
|
|
- $addData['stockWarning'] = $itemData[$v]['stockWarning'] ?? 5;
|
|
|
- $addData['weight'] = $itemData[$v]['weight'] ?? 0;
|
|
|
- $addData['alias'] = $itemData[$v]['alias'] ?? '';
|
|
|
- $addData['py'] = $itemData[$v]['py'] ?? '';
|
|
|
- $addData['ratio'] = $itemData[$v]['ratio'] ?? 20;
|
|
|
- $addData['bigUnit'] = $itemData[$v]['bigUnit'] ?? '';
|
|
|
- $addData['smallUnit'] = $itemData[$v]['smallUnit'] ?? '';
|
|
|
- $addData['bigUnitId'] = $itemData[$v]['bigUnitId'] ?? 0;
|
|
|
- $addData['smallUnitId'] = $itemData[$v]['smallUnitId'] ?? 0;
|
|
|
+ $addData['smallRatio'] = $oldProductInfo[$v]['smallRatio'] ?? 2;
|
|
|
+ $addData['skPrice'] = $oldProductInfo[$v]['skPrice'] ?? 0;
|
|
|
+ $addData['hjPrice'] = $oldProductInfo[$v]['hjPrice'] ?? 0;
|
|
|
+ $addData['cost'] = $oldProductInfo[$v]['cost'] ?? 0;
|
|
|
+ $addData['addPrice'] = $oldProductInfo[$v]['addPrice'] ?? 0;
|
|
|
+ $addData['skAddPrice'] = $oldProductInfo[$v]['skAddPrice'] ?? 0;
|
|
|
+ $addData['hjAddPrice'] = $oldProductInfo[$v]['hjAddPrice'] ?? 0;
|
|
|
+ $addData['stockWarning'] = $oldProductInfo[$v]['stockWarning'] ?? 5;
|
|
|
+ $addData['weight'] = $oldProductInfo[$v]['weight'] ?? 0;
|
|
|
+ $addData['alias'] = $oldProductInfo[$v]['alias'] ?? '';
|
|
|
+ $addData['py'] = $oldProductInfo[$v]['py'] ?? '';
|
|
|
+ $addData['ratio'] = $oldProductInfo[$v]['ratio'] ?? 20;
|
|
|
+ $addData['bigUnit'] = $oldProductInfo[$v]['bigUnit'] ?? '';
|
|
|
+ $addData['smallUnit'] = $oldProductInfo[$v]['smallUnit'] ?? '';
|
|
|
+ $addData['bigUnitId'] = $oldProductInfo[$v]['bigUnitId'] ?? 0;
|
|
|
+ $addData['smallUnitId'] = $oldProductInfo[$v]['smallUnitId'] ?? 0;
|
|
|
$addData['status'] = 1;
|
|
|
$addData['delStatus'] = 0;
|
|
|
$addData['inTurn'] = 100;
|
|
|
+
|
|
|
self::addProduct($addData, $shop);
|
|
|
}
|
|
|
}
|