spu管理检索功能完成,测试通过

g_develop
ddyd 3 weeks ago
parent f3e3037d66
commit 44e68e4986

@ -10,6 +10,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -53,13 +54,15 @@ public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao
skuLadderEntity.setAddOther(to.getCountStatus());
skuLadderEntity.setDiscount(to.getDiscount());
skuLadderEntity.setFullCount(to.getFullCount());
skuLadderService.save(skuLadderEntity);
if (skuLadderEntity.getFullCount() >0) {
skuLadderService.save(skuLadderEntity);
}
//sku_full_reduction
SkuFullReductionEntity skuFullReductionEntity = new SkuFullReductionEntity();
BeanUtils.copyProperties(to, skuFullReductionEntity);
this.save(skuFullReductionEntity);
if (skuFullReductionEntity.getFullPrice().compareTo(new BigDecimal("0")) == 1) {
this.save(skuFullReductionEntity);
}
//sms_member_price
List<MemberPrice> memberPrice = to.getMemberPrice();
if (memberPrice == null || memberPrice.isEmpty()) {
@ -78,6 +81,9 @@ public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao
priceEntity.setMemberPrice(item.getPrice());
priceEntity.setAddOther(1);
return priceEntity;
}).filter(item->{
//true保留false舍弃
return item.getMemberPrice().compareTo(new BigDecimal("0")) == 1;
}).collect(Collectors.toList());
memberPriceService.saveBatch(collect);
}

@ -38,7 +38,7 @@ public class SpuInfoController {
@RequestMapping("/list")
//@RequiresPermissions("product:spuinfo:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = spuInfoService.queryPage(params);
PageUtils page = spuInfoService.queryPageByCondition(params);
return R.ok().put("page", page);
}

@ -21,5 +21,7 @@ public interface SpuInfoService extends IService<SpuInfoEntity> {
void saveSpuInfo(SpuSaveVo vo);
void saveBaseSpuInfo(SpuInfoEntity spuInfoEntity);
PageUtils queryPageByCondition(Map<String, Object> params);
}

@ -8,6 +8,7 @@ import com.bookstore.common.to.SkuReductionTo;
import com.bookstore.common.to.SpuBoundsTo;
import com.bookstore.common.utils.R;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import com.mysql.cj.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -146,6 +147,9 @@ public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> i
skuImagesEntity.setDefaultImg(image.getDefaultImg());
return skuImagesEntity;
}).filter(entity->{
//返回true是需要false是舍弃
return !StringUtils.isNullOrEmpty(entity.getImgUrl());
}).collect(Collectors.toList());
//todo 没有图片路径的无需保存
skuImagesService.saveBatch(skuImagesEntities);
@ -164,10 +168,14 @@ public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> i
SkuReductionTo skuReductionTo = new SkuReductionTo();
BeanUtils.copyProperties(item, skuReductionTo);
skuReductionTo.setSkuId(skuId);
R r1 = couponFeignService.saveSkuReduction(skuReductionTo);
if (r1.getCode() != 0) {
log.error("远程保存sku优惠满减信息失败");
if (skuReductionTo.getFullCount() > 0 ||
skuReductionTo.getFullPrice().compareTo(new BigDecimal("0")) == 1) {
R r1 = couponFeignService.saveSkuReduction(skuReductionTo);
if (r1.getCode() != 0) {
log.error("远程保存sku优惠满减信息失败");
}
}
});
log.info("保存完毕");
@ -186,5 +194,43 @@ public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> i
this.baseMapper.insert(spuInfoEntity);
}
@Override
public PageUtils queryPageByCondition(Map<String, Object> params) {
QueryWrapper<SpuInfoEntity> QueryWrapper = new QueryWrapper<>();
//status: 0,
//key: "华为",
//brandId: 9,
//catelogId: 225
String key = (String) params.get("key");
if (!StringUtils.isNullOrEmpty(key)) {
QueryWrapper.and((w)->{
w.eq("id",key).or().like("spu_name", key);
});
}
String status = (String) params.get("status");
if (!StringUtils.isNullOrEmpty(status)) {
QueryWrapper.eq("publish_status",status);
}
String brandId = (String) params.get("brandId");
if (!StringUtils.isNullOrEmpty(brandId) && !"0".equals(brandId)) {
QueryWrapper.eq("brand_id", brandId);
}
String catelogId = (String) params.get("catalogId");
if (!StringUtils.isNullOrEmpty(catelogId) && !"0".equals(catelogId)) {
QueryWrapper.eq("catalog_id", catelogId);
}
IPage<SpuInfoEntity> page = this.page(
new Query<SpuInfoEntity>().getPage(params), QueryWrapper);
return new PageUtils(page);
}
}

@ -17,7 +17,8 @@ spring:
# enabled: false
application:
name: mall-product
jackson:
date-format: yyyy-MM-dd HH:mm:ss
mybatis-plus:
config-locations: classpath*:/mapper/**/*.xml #classpath*中的*指的是不止引用自己路径的mapper依赖的jar包也扫描

Loading…
Cancel
Save