xiaoyong931011
2021-11-10 a30578866c2c85d684dd493be3795d3bf6e40a18
20211108
3 files modified
23 ■■■■ changed files
gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiGoodsController.java 5 ●●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java 17 ●●●● patch | view | raw | blame | history
gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml 1 ●●●● patch | view | raw | blame | history
gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiGoodsController.java
@@ -60,8 +60,9 @@
            @ApiResponse(code = 200, message = "success", response = XcxGoodsDetailVo.class)
    )
    @PostMapping(value = "/goods/goodsDetails/{id}")
    public JsonResult<XcxGoodsDetailVo> goodsDetails(@PathVariable("id") Long id) {
        return JsonResult.success(goodsService.findGoodsDetails(id));
    public JsonResult<XcxGoodsDetailVo> goodsDetails(@PathVariable("id") Long id ,HttpServletRequest request) {
        String userId = getUserId(request);
        return JsonResult.success(goodsService.findGoodsDetails(id,userId));
    }
    @ApiOperation("商品搜索历史记录")
gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -359,12 +359,25 @@
        return new PageInfo<>(data);
    }
    public XcxGoodsDetailVo findGoodsDetails(Long id) {
    public XcxGoodsDetailVo findGoodsDetails(Long id, String userId) {
        XcxGoodsDetailVo data = scoreGoodsMapper.selectGoodsDetailsById(id);
        data.setQuotaTime(data.getQuotaTime() == null ? 0:data.getQuotaTime());
        XcxGoodsListDto dto = new XcxGoodsListDto();
        dto.setId(id);
        List<XcxGoodsListVo> list = scoreGoodsMapper.selectXcxGoodsList(dto);
        if(StrUtil.isNotEmpty(userId)){
            if(CollUtil.isNotEmpty(list)){
                for(XcxGoodsListVo xcxGoodsListVo : list){
                    if(ScoreGoods.ISQG_YES == xcxGoodsListVo.getIsQg()){
                        //抢购时间内,用户购买该商品的数量
                        Integer sumCnt = scoreOrderMapper.selectGoodsQuotaTime(userId,xcxGoodsListVo.getId(),xcxGoodsListVo.getQgStartTime(),xcxGoodsListVo.getQgEndTime());
                        data.setAvaQuotaTime(
                                ((xcxGoodsListVo.getQuotaTime() == null?0:xcxGoodsListVo.getQuotaTime()) - sumCnt) > 0?((xcxGoodsListVo.getQuotaTime() == null?0:xcxGoodsListVo.getQuotaTime()) - sumCnt):0
                        );
                    }
                }
            }
        }
        List<String> images = scoreGoodsImagesMapper.selectScoreGoodsImagesByGoodsId(id);
        data.setImages(images);
        if (CollUtil.isNotEmpty(list)) {
gc-shop/src/main/resources/mapper/shop/ScoreGoodsMapper.xml
@@ -133,6 +133,7 @@
        <result property="qgStartTime" column="qg_start_time" />
        <result property="qgEndTime" column="qg_end_time" />
        <result property="details" column="details" />
        <result property="quotaTime" column="quota_time" />
        <collection property="styles" ofType="com.xzx.gc.shop.vo.XcxGoodsDetailStyleVo" >
            <id property="id" column="s_id" />
            <result property="name" column="s_name" />