活动商品接口 #94

Merged
root merged 1 commits from sjy-two into master 2024-10-29 18:39:56 +08:00
3 changed files with 55 additions and 1 deletions

View File

@ -201,4 +201,23 @@ public class AppProductSpuController {
return pageResult; return pageResult;
} }
// TODO 芋艿商品的浏览记录 // TODO 芋艿商品的浏览记录
@GetMapping("/getActivityGoods")
public CommonResult<List<AppProductSpuRespVO>> getActivityGoods(String activityType) {
List<ProductSpuDO> list = productSpuService.getActivityGoods(activityType);
if (CollUtil.isEmpty(list)) {
return success(Collections.emptyList());
}
// 拼接返回
list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
List<AppProductSpuRespVO> voList = BeanUtils.toBean(list, AppProductSpuRespVO.class);
// 处理 vip 价格
MemberLevelRespDTO memberLevel = getMemberLevel();
voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
return success(voList);
}
} }

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReq
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@ -138,4 +139,7 @@ public interface ProductSpuService {
* @return * @return
*/ */
List<ProductSpuDO> getRecommendProductIdList(AppProductSpuRecommendPageReqVo pageVo); List<ProductSpuDO> getRecommendProductIdList(AppProductSpuRecommendPageReqVo pageVo);
List<ProductSpuDO> getActivityGoods(String activityType);
} }

View File

@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReq
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper;
@ -22,6 +23,7 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -194,6 +196,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
return productSpuMapper.selectList(wrapperX); return productSpuMapper.selectList(wrapperX);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteSpu(Long id) { public void deleteSpu(Long id) {
@ -308,4 +312,31 @@ public class ProductSpuServiceImpl implements ProductSpuService {
return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId); return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId);
} }
@Override
public List<ProductSpuDO> getActivityGoods(String activityType) {
String activity = "";
if (activityType.equals("recommendHot")){
activity = "recommend_hot";
}
if (activityType.equals("recommendBenefit")){
activity = "recommend_benefit";
}
if (activityType.equals("recommendBest")){
activity = "recommend_best";
}
if (activityType.equals("recommendNew")){
activity = "recommend_new";
}
if (activityType.equals("recommendGood")){
activity = "recommend_good";
}
QueryWrapper<ProductSpuDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(activity,1).eq("status",1);
return productSpuMapper.selectList(queryWrapper);
}
} }