document
API test

SKU折扣

POST
http://localhost:88/api/coupon/skufullreduction//save/discount

API description

保存SKU的折扣信息

Description or Example

# 核心代码 ```java @Override public void saveDiscount(SkuDiscountTO skuDiscountTO) { // 封装价格满减信息 SkuFullReductionEntity skuFullReductionEntity = new SkuFullReductionEntity(); BeanUtils.copyProperties(skuDiscountTO, skuFullReductionEntity); skuFullReductionEntity.setAddOther(skuDiscountTO.getPriceStatus()); // price满减是否可以叠加 this.save(skuFullReductionEntity); // 封装会员价格信息 List<MemberPrice> memberPrices = skuDiscountTO.getMemberPrice(); // 被JSR303校验, 传输的会员价格信息不可能为空, 但是里面的数据可能为空 List<MemberPriceEntity> memberPriceEntities = memberPrices.stream().map(memberPrice -> { MemberPriceEntity memberPriceEntity = new MemberPriceEntity(); memberPriceEntity.setSkuId(skuDiscountTO.getSkuId()) .setMemberLevelId(memberPrice.getId()) .setMemberLevelName(memberPrice.getName()) .setMemberPrice(memberPrice.getPrice()) .setAddOther(1); return memberPriceEntity; }).collect(Collectors.toList()); // 保存会员价格信息 memberPriceService.saveBatch(memberPriceEntities); // 保存数量满减信息 SkuLadderEntity skuLadderEntity = new SkuLadderEntity(); BeanUtils.copyProperties(skuDiscountTO, skuLadderEntity); skuLadderEntity.setAddOther(skuDiscountTO.getCountStatus()); // 数量满减是否可以叠加 skuLadderService.save(skuLadderEntity); } ```