|
|
@@ -79,6 +79,7 @@ class CpClass extends BaseClass
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ //添加产品 ssh 20240221
|
|
|
public static function addCp($data, $currentShop)
|
|
|
{
|
|
|
$mainId = $currentShop->mainId ?? 0;
|
|
|
@@ -139,11 +140,26 @@ class CpClass extends BaseClass
|
|
|
//前面已经添加过了
|
|
|
continue;
|
|
|
}
|
|
|
- $thisMainId = $shop->mainId ?? 0;
|
|
|
- $data['shopId'] = $shopId;
|
|
|
- $data['mainId'] = $thisMainId;
|
|
|
- $data['classId'] = 0;
|
|
|
- self::add($data);
|
|
|
+ $currentMainId = $shop->mainId ?? 0;
|
|
|
+ $shopName = $shop->shopName ?? '';
|
|
|
+ $chainClassList = CpClassClass::getAllByCondition(['mainId' => $currentMainId, 'delStatus' => 0], null, '*', null, true);
|
|
|
+ $currentCpClassId = 0;
|
|
|
+ if (!empty($chainClassList)) {
|
|
|
+ foreach ($chainClassList as $chainClass) {
|
|
|
+ $chainClassId = $chainClass->id ?? 0;
|
|
|
+ if ($chainClass->name == $shopCpClassName) {
|
|
|
+ $currentCpClassId = $chainClassId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($currentCpClassId)) {
|
|
|
+ util::fail($shopName . '没有找到相应的分类');
|
|
|
+ }
|
|
|
+ $currentData = $data;
|
|
|
+ $currentData['shopId'] = $shopId;
|
|
|
+ $currentData['mainId'] = $currentMainId;
|
|
|
+ $currentData['classId'] = $currentCpClassId;
|
|
|
+ self::add($currentData);
|
|
|
}
|
|
|
}
|
|
|
$transaction->commit();
|