修复:进货后规格设置数据全部消失,导致需要重新设置的问题
This commit is contained in:
parent
2b600eba59
commit
af04c1e269
|
|
@ -602,7 +602,7 @@ class ProductRepository extends BaseRepository
|
|||
* @param int $productId
|
||||
* @return mixed
|
||||
*/
|
||||
public function setAttrValue(array $data, int $productId, int $productType, int $isUpdate = 0)
|
||||
public function setAttrValue(array $data, int $productId, int $productType, int $isUpdate = 0, int $isWith = 0)
|
||||
{
|
||||
$extension_status = systemConfig('extension_status');
|
||||
if ($isUpdate) {
|
||||
|
|
@ -663,8 +663,16 @@ class ProductRepository extends BaseRepository
|
|||
];
|
||||
|
||||
// 如果已经存在规格唯一键
|
||||
if(isset($value['unique']) && $value['unique'] !== '') $array['copy_unique'] = $value['unique'];
|
||||
if(isset($value['value_id']) && $value['value_id'] !== '') $array['copy_value_id'] = $value['value_id'];
|
||||
// if(isset($value['unique']) && $value['unique'] !== '' && isset($value['copy_unique']) && $value['copy_unique'] !== '') $array['copy_unique'] = $value['unique'];
|
||||
// if(isset($value['value_id']) && $value['value_id'] !== '' && isset($value['copy_value_id']) && $value['copy_value_id'] !== '') $array['copy_value_id'] = $value['value_id'];
|
||||
|
||||
if($isWith){
|
||||
$array['copy_unique'] = $value['unique'];
|
||||
$array['copy_value_id'] = $value['value_id'];
|
||||
}else{
|
||||
$array['copy_unique'] = $value['copy_unique'];
|
||||
$array['copy_value_id'] = $value['copy_value_id'];
|
||||
}
|
||||
|
||||
|
||||
if (isset($data['type']) && $data['type'] == 2) {
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class WineProductRepository extends BaseRepository{
|
|||
// 处理商品添加
|
||||
return Db::transaction(function () use ($item, $productInfo, $oldGood, $hasAttrValue) {
|
||||
// 规格处理
|
||||
$settleParams = app()->make(ProductRepository::class)->setAttrValue($oldGood, $productInfo->product_id, $oldGood['product_type'], 0);
|
||||
$settleParams = app()->make(ProductRepository::class)->setAttrValue($oldGood, $productInfo->product_id, $oldGood['product_type'], 0, 1);
|
||||
$attr = app()->make(ProductRepository::class)->setAttr($oldGood['attr'], $productInfo->product_id);
|
||||
// 修改规格
|
||||
$productAttrRepository = app()->make(ProductAttrRepository::class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue