zoujiajian 1 год назад
Родитель
Сommit
e8a1790a17

+ 6 - 1
netflix-service/src/main/java/com/cyksj/service/goods/impl/GoodsWholesaleServiceImpl.java

@@ -24,6 +24,7 @@ import com.cyksj.service.order.OrderRefundService;
 import com.cyksj.service.user.UserBindRelationService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -162,7 +163,11 @@ public class GoodsWholesaleServiceImpl extends ServiceImpl<GoodsWholesaleMapper,
 		List<GoodsWholesale.GoodsWholesaleConfig> wholesaleConfig = wholesale.getWholesaleConfig();
 		String config = Jsons.toJson(wholesaleConfig);
 		wholesale.setConfig(config);
-		this.saveOrUpdate(wholesale);
+		try {
+			this.saveOrUpdate(wholesale);
+		} catch (DuplicateKeyException e) {
+			throw BusinessRuntimeException.getInstance("已存在该批发规格");
+		}
 	}
 
 	@Override