|
|
@@ -142,9 +142,6 @@ class Lists extends Backend
|
|
|
if($item->county > 0) $areaCode[$key][3] = $item->county;
|
|
|
$areaTxt[] = [$item->address];
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
$areaCode = json_encode($areaCode);
|
|
|
$this->assignconfig('areaCode', $areaCode);
|
|
|
$this->view->assign('row', $row);
|
|
|
@@ -167,18 +164,16 @@ class Lists extends Backend
|
|
|
$row->validateFailException()->validate($validate);
|
|
|
}
|
|
|
|
|
|
- $areaArr = json_decode($params['product_area'], true);
|
|
|
- if(empty($areaArr)) throw new ValidateException('请添加商品关联地区');
|
|
|
- if(self::isEqualArea($areaArr) == false) throw new ValidateException('该商品地区存在重复');
|
|
|
- unset($params['product_area']);
|
|
|
+ $areaArr = json_decode($params['product_area'], true);
|
|
|
+ $areaArrTxt = json_decode($params['product_area_txt'], true);
|
|
|
+ if(empty($areaArr) || empty($areaArrTxt)) throw new ValidateException('请添加商品关联地区');
|
|
|
+ unset($params['product_area'], $params['product_area_txt']);
|
|
|
+
|
|
|
|
|
|
$row->allowField(true)->save($params);
|
|
|
$this->productArea::where('product_id', $ids)->delete();
|
|
|
- foreach ($areaArr as $row) {
|
|
|
- $row = (array)$row;
|
|
|
- $row['product_id'] = $ids;
|
|
|
- $result = $this->productArea::create($row);
|
|
|
- }
|
|
|
+
|
|
|
+ $result= $this->setEqualArea($ids, $areaArr, $areaArrTxt);
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|