|
|
@@ -55,6 +55,7 @@ class StoreProductAttr extends BaseModel
|
|
|
}
|
|
|
$attrCount = count($attrList);
|
|
|
foreach ($valueList as $index => $value) {
|
|
|
+ $suk = implode(',', $value['detail']);
|
|
|
if (!isset($value['detail']) || count($value['detail']) != $attrCount) return self::setErrorInfo('请填写正确的商品信息');
|
|
|
if (!isset($value['price']) || !is_numeric($value['price']) || floatval($value['price']) != $value['price'])
|
|
|
return self::setErrorInfo('请填写正确的商品价格');
|
|
|
@@ -62,6 +63,18 @@ class StoreProductAttr extends BaseModel
|
|
|
return self::setErrorInfo('请填写正确的商品库存');
|
|
|
if (!isset($value['cost']) || !is_numeric($value['cost']) || floatval($value['cost']) != $value['cost'])
|
|
|
return self::setErrorInfo('请填写正确的商品成本价格');
|
|
|
+ if (isset($value['bar_code']) && !$value['bar_code']) {
|
|
|
+ if (StoreProductAttrValue::where('bar_code', $value['bar_code'])
|
|
|
+ ->where(function ($query) use ($productId, $suk) {
|
|
|
+ $query->where('product_id', '<>', $productId)
|
|
|
+ ->whereOr('suk', '<>', $suk);
|
|
|
+ })
|
|
|
+ ->where('type', $type)
|
|
|
+ ->find()
|
|
|
+ ) {
|
|
|
+ return self::setErrorInfo('编码已存在');
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!isset($value['pic']) || empty($value['pic']))
|
|
|
return self::setErrorInfo('请上传商品图片');
|
|
|
foreach ($value['detail'] as $attrName => $attrValue) {
|