修改商品 规格
This commit is contained in:
parent
bff2ad2250
commit
8e1aa5bc19
|
|
@ -18,6 +18,8 @@ package cn.ysk.cashier.repository.product;
|
|||
import cn.ysk.cashier.pojo.product.TbProductSkuResult;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -25,4 +27,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
* @date 2024-02-08
|
||||
**/
|
||||
public interface TbProductSkuResultRepository extends JpaRepository<TbProductSkuResult, Integer>, JpaSpecificationExecutor<TbProductSkuResult> {
|
||||
|
||||
@Modifying
|
||||
@Query(value = "delete from tb_product_sku_result where id = ?1", nativeQuery = true)
|
||||
void deleteByIdN(Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -83,9 +83,9 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
case "weight":
|
||||
return "称重商品";
|
||||
case "currentPrice":
|
||||
return "套餐商品/团购卷";
|
||||
case "group":
|
||||
return "时价商品";
|
||||
case "group":
|
||||
return "套餐商品/团购卷";
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
|
|
@ -328,6 +328,9 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
TbProduct product = new TbProduct();
|
||||
//组装
|
||||
BeanUtil.copyProperties(resources, product, CopyOptions.create().setIgnoreNullValue(true));
|
||||
if(CollectionUtils.isEmpty(resources.getSkuList())){
|
||||
throw new BadRequestException("商品规格不可为空");
|
||||
}
|
||||
if (!"group".equals(resources.getTypeEnum())) {
|
||||
if (resources.getCategoryId() == null) {
|
||||
throw new BadRequestException("必填内容未填写");
|
||||
|
|
@ -446,6 +449,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
}
|
||||
}
|
||||
if (!"group".equals(product.getTypeEnum())) {
|
||||
if (resources.getCategoryId() == null) throw new BadRequestException("商品分类不可为空");
|
||||
product.setIsCombo(0);
|
||||
product.setGroupSnap(null);
|
||||
if (resources.getNotices() != null && resources.getNotices().getId() != null) {
|
||||
|
|
@ -506,15 +510,19 @@ public class TbProductServiceImpl implements TbProductService {
|
|||
productSkuResult.setTagSnap(resources.getSkuSnap());
|
||||
productSkuResult.setId(save.getId());
|
||||
tbProductSkuResultRepository.save(productSkuResult);
|
||||
}else if ("group".equals(resources.getTypeEnum())) {
|
||||
TbPurchaseNotice notices = resources.getNotices();
|
||||
if (StringUtils.isBlank(notices.getDateUsed())
|
||||
&& StringUtils.isBlank(notices.getAvailableTime())
|
||||
&& StringUtils.isBlank(notices.getBookingType())
|
||||
&& StringUtils.isBlank(notices.getRefundPolicy())) {
|
||||
throw new BadRequestException("修改购买须知失败,必填项未填写");
|
||||
}else {
|
||||
tbProductSkuResultRepository.deleteByIdN(save.getId());
|
||||
if ("group".equals(resources.getTypeEnum())) {
|
||||
TbPurchaseNotice notices = resources.getNotices();
|
||||
if (StringUtils.isBlank(notices.getDateUsed())
|
||||
&& StringUtils.isBlank(notices.getAvailableTime())
|
||||
&& StringUtils.isBlank(notices.getBookingType())
|
||||
&& StringUtils.isBlank(notices.getRefundPolicy())) {
|
||||
throw new BadRequestException("修改购买须知失败,必填项未填写");
|
||||
}
|
||||
resources.getNotices().setCouponId(save.getId());
|
||||
noticeRepository.save(resources.getNotices());
|
||||
}
|
||||
noticeRepository.save(resources.getNotices());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue