|
|
@@ -105,7 +105,7 @@ class GoodsClass extends BaseClass
|
|
|
}
|
|
|
$goodsStyleList = isset($data['goodsStyleList']) && !empty($data['goodsStyleList']) ? $data['goodsStyleList'] : [];
|
|
|
unset($data['goodsStyleList']);
|
|
|
-
|
|
|
+
|
|
|
//处理分类
|
|
|
$merchantId = $data['merchantId'];
|
|
|
$merchantHasCategoryIdList = CategoryClass::getCategoryIdList($merchantId);
|
|
|
@@ -113,43 +113,19 @@ class GoodsClass extends BaseClass
|
|
|
if (!empty($diff)) {
|
|
|
util::fail('您使用了别人的分类');
|
|
|
}
|
|
|
- //先删除分类
|
|
|
+ //先删除再添加分类
|
|
|
GoodsCategoryClass::delGoodsCategory($id);
|
|
|
$addCategory = [];
|
|
|
foreach ($categoryIdList as $categoryId) {
|
|
|
$addCategory[] = ['gId' => $id, 'cId' => $categoryId, 'merchantId' => $data['merchantId']];
|
|
|
}
|
|
|
- //再添加分类
|
|
|
GoodsCategoryClass::batchAdd($addCategory);
|
|
|
|
|
|
//处理款式
|
|
|
if (!empty($goodsStyleList) && $data['goodsStyle'] == 1) {
|
|
|
- $goodsStyleList = [
|
|
|
- 'add' => [['styleName' => '红色', 'price' => 0.1, 'picture' => ''], ['styleName' => '蓝色', 'price' => 0.1, 'picture' => '']],
|
|
|
- 'delete' => [1, 2, 3],
|
|
|
- 'update' => [['id' => 4, 'styleName' => '红色', 'price' => 0.1, 'picture' => ''], ['id' => 5, 'styleName' => '蓝色', 'price' => 0.1, 'picture' => '']],
|
|
|
- ];
|
|
|
- if (isset($goodsStyleList['add']) && !empty($goodsStyleList['add'])) {
|
|
|
- $addStyleList = $goodsStyleList['add'];
|
|
|
- $addStyle = [];
|
|
|
- foreach ($addStyleList as $style) {
|
|
|
- $addStyle[] = ['styleName' => $style['styleName'], 'goodsId' => $id, 'picture' => $style['picture'], 'price' => $style['price']];
|
|
|
- }
|
|
|
- GoodsStyleClass::batchAdd($addStyle);
|
|
|
- }
|
|
|
- if (isset($goodsStyleList['delete']) && !empty($goodsStyleList['delete'])) {
|
|
|
- GoodsStyleClass::deleteByIds($goodsStyleList['delete']);
|
|
|
- }
|
|
|
- if (isset($goodsStyleList['update']) && !empty($goodsStyleList['update'])) {
|
|
|
- $update = $goodsStyleList['update'];
|
|
|
- foreach ($update as $up) {
|
|
|
- $currentId = $up['id'];
|
|
|
- unset($up['id']);
|
|
|
- GoodsStyleClass::updateById($currentId, $up);
|
|
|
- }
|
|
|
- }
|
|
|
+ GoodsStyleClass::updateGoodsStyle($goodsStyleList,$id);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$data['shopImg'] = json_encode($data['shopImg']);
|
|
|
self::updateById($id, $data);
|
|
|
}
|