|
|
@@ -651,7 +651,7 @@ class ProductClass extends BaseClass
|
|
|
$bigItemPrice = $itemPrice;
|
|
|
|
|
|
if ($smallNum > 0) {
|
|
|
- //如果是小单位数量,则传过来的就是小单位价格,无需转换
|
|
|
+ //如果是小单位数量,则传过来的就是小单位价格,无需转换
|
|
|
if (empty($changePrice)) {
|
|
|
$itemPrice = bcdiv($itemPrice, $ratio, 2);
|
|
|
$itemPrice = bcmul($itemPrice, $smallRatio, 2);
|
|
|
@@ -1079,7 +1079,7 @@ class ProductClass extends BaseClass
|
|
|
//没有库存则下架
|
|
|
$data['status'] = $stock == 0 ? 2 : 1;
|
|
|
|
|
|
- if (!$classId) {
|
|
|
+ if (empty($classId)) {
|
|
|
util::fail("请选择分类");
|
|
|
}
|
|
|
if (isset($data['price']) == false || is_numeric($data['price']) == false || $data['price'] < 0) {
|
|
|
@@ -1107,6 +1107,8 @@ class ProductClass extends BaseClass
|
|
|
if ($cat->mainId != $mainId) {
|
|
|
util::fail('不是您的分类');
|
|
|
}
|
|
|
+ $catName = $cat->name ?? '';
|
|
|
+
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
@@ -1230,17 +1232,28 @@ class ProductClass extends BaseClass
|
|
|
$thisMainId = $shop->mainId ?? 0;
|
|
|
$data['shopId'] = $shopId;
|
|
|
$data['mainId'] = $thisMainId;
|
|
|
- //不是当前门店,库存默认为0并且是下架状态
|
|
|
- //不是当前门店,花材分类放在默认分类下
|
|
|
+ //不是当前门店,库存默认为0并且是下架状态。花材分类放在同名分类下,如果没有则放默认分类
|
|
|
if ($currentShopId != $shopId) {
|
|
|
$data['stock'] = 0;
|
|
|
$data['status'] = 2;
|
|
|
- $defaultCat = ItemClassClass::getByCondition(['mainId' => $thisMainId, 'isDefault' => 1], true);
|
|
|
- $defaultCatId = $defaultCat->id ?? 0;
|
|
|
- if (empty($defaultCatId)) {
|
|
|
- util::fail($shop->shopName . "没有默认分类");
|
|
|
+ $currentClassId = 0;
|
|
|
+ $classList = ItemClassClass::getAllByCondition(['mainId' => $thisMainId], null, '*', null, true);
|
|
|
+ if (!empty($classList)) {
|
|
|
+ foreach ($classList as $currentClass) {
|
|
|
+ $currentName = $currentClass->name ?? '';
|
|
|
+ if ($currentName == $catName) {
|
|
|
+ $currentClassId = $currentClass->id ?? 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($currentClassId)) {
|
|
|
+ $defaultCat = ItemClassClass::getByCondition(['mainId' => $thisMainId, 'isDefault' => 1], true);
|
|
|
+ $currentClassId = $defaultCat->id ?? 0;
|
|
|
+ }
|
|
|
+ if (empty($currentClassId)) {
|
|
|
+ util::fail('直营店没有分类,也没有默认分类');
|
|
|
}
|
|
|
- $data['classId'] = $defaultCatId;
|
|
|
+ $data['classId'] = $currentClassId;
|
|
|
}
|
|
|
//已经有了不再添加
|
|
|
$chainHas = self::getByCondition(['mainId' => $thisMainId, 'itemId' => $ptItemId], true);
|