yj
2020-03-12 1ae3dc5a7eca13744f0a9e6e9c93bebfdfa41a55
加入缓存 商品更新问题
6个文件已修改
114 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/GoodsEvaluate.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/SimpleGoods.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/GoodsEvaluate.java
@@ -125,6 +125,10 @@
    private String startTimeChar;
    private String endTimeChar;
    
    // 备注
    private String remarks;
    public String getId() {
        return id;
    }
@@ -292,5 +296,12 @@
    public void setDynamicType(Integer dynamicType) {
        this.dynamicType = dynamicType;
    }
    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/SimpleGoods.java
@@ -23,6 +23,10 @@
    // 状态
    @Expose
    private Integer state;
    // 备注
    private String remarks;
    public Long getGoodsId() {
        return goodsId;
@@ -64,4 +68,12 @@
        this.state = state;
    }
    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
}
fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java
@@ -379,4 +379,25 @@
        }
    }
    /**
     *  每一个小时随机在分享数的基础上加10~100。增加的时间段是每天8~22点。
     * 早上6,7,15,16,21,22,23点更新1次
     */
    @Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ? ")
    public void addRanDomShareCount() {
        if (!Constant.IS_TASK) {
            return;
        }
        try {
            goodsEvaluateService.addRanDomShareCount();
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -1465,6 +1465,45 @@
        return goodsEvaluateDao.count(key, state, dynamicType);
    }
    @Override
    public void addRanDomShareCount() {
        // 发圈
        try {
            List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(0, Integer.MAX_VALUE, 1);
            if (list != null) {
                for (GoodsEvaluate goodsEvaluate: list) {
                    Integer shareNum = goodsEvaluate.getShareNum();
                    if (shareNum == null) {
                        shareNum = 0;
                    }
                    goodsEvaluate.setShareNum(shareNum + (int) (Math.random() * 100) + 10);
                    goodsEvaluateDao.save(goodsEvaluate);
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        // 素材
        try {
            List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(0, Integer.MAX_VALUE, 2);
            if (list != null) {
                for (GoodsEvaluate goodsEvaluate: list) {
                    Integer shareNum = goodsEvaluate.getShareNum();
                    if (shareNum == null) {
                        shareNum = 0;
                    }
                    goodsEvaluate.setShareNum(shareNum + (int) (Math.random() * 100) + 10);
                    goodsEvaluateDao.save(goodsEvaluate);
                }
            }
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
    @Override
    @Cacheable(value = "dynamicCache", key = "'queryValidEvaluateCache-'+#start")
    public List<GoodsEvaluate> queryValidEvaluateCache(int start, int count) {
@@ -1487,7 +1526,7 @@
    }
    @Override
//    @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type")
    @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type")
    public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type) throws Exception {
        List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type);
        if (list == null) {
@@ -2214,6 +2253,7 @@
        ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
        paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
        GoodsDetailVO goodsNew = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
        updateGoods(queryExist, goodsNew);
    }
    
@@ -2240,7 +2280,12 @@
            GoodsDetailVO goodsDetailVO = goodsEvaluate.getGoods();
            if (goodsDetailVO != null && goodsDetailVO.getGoodsId() != null 
                && goodsDetailVO.getGoodsId() == goodsId && goodsDetailVO.getGoodsType() == goodsType ) {
                goodsEvaluate.setGoods(goodsNew);
                if (goodsDetailVO.getTitle().equalsIgnoreCase(goodsNew.getTitle())) {
                    goodsEvaluate.setGoods(goodsNew);
                } else {
                    goodsEvaluate.setState(1);
                    goodsEvaluate.setRemarks("商品标题发生变化下架:" + goodsDetailVO.getTitle() +" / 新:" + goodsNew.getTitle());
                }
            }
            
            // 更新商品信息
@@ -2251,11 +2296,21 @@
            for (ImgInfo imgInfo : imgList) {
                SimpleGoods simpleGoods = imgInfo.getGoods();
                if (simpleGoods == null) {
                if (simpleGoods == null || simpleGoods.getGoodsId() != goodsId
                        || goodsType != simpleGoods.getGoodsType()) {
                    continue;
                }
                simpleGoods.setState(0);
                GoodsDetailVO goodsVO = imgInfo.getGoodsVO();
                if (goodsVO != null) {
                    if (goodsVO.getTitle().equalsIgnoreCase(goodsNew.getTitle())) {
                        simpleGoods.setState(0);
                    } else {
                        simpleGoods.setState(1);
                        simpleGoods.setRemarks("商品标题发生变化下架:" + goodsVO.getTitle() +" / 新:" + goodsNew.getTitle());
                    }
                }
                simpleGoods.setPrice(goodsDetailVO.getCouponPrice());
                CouponInfoVO couponInfo = goodsDetailVO.getCouponInfo();
                if (couponInfo == null) {
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/GoodsEvaluateService.java
@@ -159,4 +159,7 @@
    public void updatePDDGoods(PDDGoodsDetail pddGoods);
    public void addRanDomShareCount();
}
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -160,7 +160,7 @@
        "💌",
        "💭",
        "🌼",
        "🍀",
        "🍀"
    };