| | |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.security.utils.CodeFactoryUtil; |
| | | import com.ruoyi.goods.domain.dto.*; |
| | | import com.ruoyi.goods.domain.pojo.activity.Activity; |
| | | import com.ruoyi.goods.domain.pojo.goods.GoodsTotal; |
| | | import com.ruoyi.goods.domain.vo.*; |
| | | import com.ruoyi.goods.mapper.goods.GoodsMapper; |
| | | import com.ruoyi.goods.service.activity.ActivityGoodsService; |
| | | import com.ruoyi.goods.service.activity.ActivityService; |
| | | import com.ruoyi.goods.service.goods.GoodsFileService; |
| | | import com.ruoyi.goods.service.goods.GoodsService; |
| | | import com.ruoyi.goods.service.goods.GoodsTotalService; |
| | |
| | | @Resource |
| | | private GoodsTotalService goodsTotalService; |
| | | |
| | | |
| | | @Resource |
| | | private ActivityService activityService; |
| | | |
| | | /** |
| | | * @description 获取推荐商品列表 |
| | |
| | | public List<AppSimpleGoodsVo> pageRecommendGoods(Page page, Long shopId){ |
| | | List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsMapper.pageRecommendGoods(page,shopId); |
| | | return appSimpleGoodsVoList; |
| | | } |
| | | |
| | | /** |
| | | * @description 获取活动精选 |
| | | * @author jqs |
| | | * @date 2023/7/4 18:06 |
| | | * @param shopId |
| | | * @return List<AppSimpleGoodsVo> |
| | | */ |
| | | @Override |
| | | public AppHomeActivityVo pageActivityGoods(Long shopId){ |
| | | AppHomeActivityVo appHomeActivityVo = new AppHomeActivityVo(); |
| | | Activity activity = activityService.getRecommendActivity(shopId); |
| | | List<AppSimpleGoodsVo> simpleGoodsVoList = new ArrayList<>(); |
| | | if(activity!=null){ |
| | | appHomeActivityVo.setEndTime(activity.getActivityEndTime()); |
| | | appHomeActivityVo.setTimestamp(activity.getActivityEndTime().getTime()); |
| | | simpleGoodsVoList = goodsMapper.pageActivityGoods(activity.getActivityId(),shopId); |
| | | appHomeActivityVo.setGoodsVoList(simpleGoodsVoList); |
| | | } |
| | | return appHomeActivityVo; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<AppSimpleActivityGoodsVo> pageSearchActivityGoods(Page page, AppSearchGoodsPageDto appSearchGoodsPageDto){ |
| | | List<AppSimpleActivityGoodsVo> appSimpleGoodsVoList = goodsMapper.pageSearchActivityGoods(page,appSearchGoodsPageDto); |
| | | int activityNumber; |
| | | int salesNumber; |
| | | BigDecimal salesPercent; |
| | | for(AppSimpleActivityGoodsVo appSimpleActivityGoodsVo : appSimpleGoodsVoList){ |
| | | activityNumber = appSimpleActivityGoodsVo.getActivityNumber(); |
| | | salesNumber = appSimpleActivityGoodsVo.getSalesNumber(); |
| | | salesPercent = BigDecimal.ZERO; |
| | | if(activityNumber != 0){ |
| | | List<String> activityIdList = activityService.listActivityIdByShopId(appSearchGoodsPageDto.getShopId()); |
| | | appSearchGoodsPageDto.setActivityIdList(activityIdList); |
| | | // 获取搜索结果的商品列表 |
| | | List<AppSimpleActivityGoodsVo> appSimpleGoodsVoList = goodsMapper.pageSearchActivityGoods(page, appSearchGoodsPageDto); |
| | | // 计算销售百分比和设置时间戳 |
| | | for (AppSimpleActivityGoodsVo appSimpleActivityGoodsVo : appSimpleGoodsVoList) { |
| | | int activityNumber = appSimpleActivityGoodsVo.getActivityNumber(); |
| | | int salesNumber = appSimpleActivityGoodsVo.getSalesNumber(); |
| | | BigDecimal salesPercent = BigDecimal.ZERO; |
| | | // 计算销售百分比 |
| | | if (activityNumber != 0) { |
| | | salesPercent = BigDecimal.valueOf(salesNumber).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(activityNumber), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | // 设置销售百分比和时间戳 |
| | | appSimpleActivityGoodsVo.setSalesPercent(salesPercent); |
| | | appSimpleActivityGoodsVo.setTimestamp(appSimpleActivityGoodsVo.getEndTime().getTime()); |
| | | } |
| | | // 返回结果 |
| | | return appSimpleGoodsVoList; |
| | | } |
| | | |