yujian
2019-05-30 a04db7a0622fa8ce524e15657a03b4a2b94fc47a
商品更新 更改 直接更新goodBrief
10个文件已修改
124 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/lable/QualityFactoryMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoGoodsBriefMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoGoodsBriefMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/lable/QualityFactoryService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoGoodsUpdateService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/lable/QualityFactoryMapper.java
@@ -77,12 +77,6 @@
    // 精选库查询 -- 查询所有
    List<QualityFactory> queryAll(@Param("start") long start, @Param("count") int count, @Param("days") Integer days);
    // 待更新精选商品id
    List<Long> queryNeedUpdate(@Param("start") long start, @Param("count") int count, @Param("hour") int hour);
    // 统计需更新商品数量
    long countQueryNeedUpdate();
    // 精选库查询
    List<QualityFactory> query(QualityFactoryVO qualityFactoryVO);
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoGoodsBriefMapper.java
@@ -91,4 +91,10 @@
    
    long countByShopId(@Param("shopId") Long shopId);
    
    /**
     * 长时间未更新的商品
     */
    List<Long> listNeedUpdateGoodsId(@Param("start") long start, @Param("count") int count, @Param("hour") int hour);
}
fanli/src/main/java/com/yeshi/fanli/job/UpdateTaoBaoGoodsJob.java
@@ -83,7 +83,7 @@
        }
        try {
            qualityFactoryService.updateWeight(10, 3);
            qualityFactoryService.updateWeight(1, 4);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
@@ -99,13 +99,16 @@
        taoBaoGoodsUpdateService.deleteOutOfDate();
    }
    // 添加精选库中需要更新的淘宝商品ID(2个小时执行一次)
    /**
     * 更新超过4个小时未更新的商品
     */
    @Scheduled(cron = "0 0 1/2 * * ? ")
    public void addNeddUpdateTaoBaoGoods() {
        if (!Constant.IS_TASK) 
            return;
        
        List<Long> list = qualityFactoryService.queryNeedUpdate(0, 1000, 4);
        List<Long> list = taoBaoGoodsUpdateService.listNeedUpdateGoodsId(0, 4000, 4);
        if (list == null || list.size() == 0) {
            return;
        }
fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml
@@ -294,21 +294,6 @@
    </select>
    <!-- 查询超过hour个小时未更新商品,进行更新 -->
    <select id="queryNeedUpdate" resultType="java.lang.Long">
        SELECT h.sg_goods_id FROM `yeshi_ec_quality_factory` h
        LEFT JOIN `yeshi_ec_taobao_goods` tb ON h.`sg_goods_id` = tb.id
        WHERE <![CDATA[TO_DAYS(tb.`updatetime`) < TO_DAYS(NOW()) OR (HOUR(NOW()) -HOUR(tb.`updatetime`)) >=  #{hour}]]>
        order by h.`sg_updatetime` LIMIT ${start},${count}
    </select>
    <!-- 查询超过5个小时未更新商品,进行更新 -->
    <select id="countQueryNeedUpdate" resultType="java.lang.Long">
        SELECT count(sg_id) FROM `yeshi_ec_quality_factory` h
        LEFT JOIN `yeshi_ec_taobao_goods` tb ON h.`sg_goods_id` = tb.id
        WHERE <![CDATA[TO_DAYS(tb.`updatetime`) < TO_DAYS(NOW()) OR (HOUR(NOW()) -HOUR(tb.`updatetime`)) >= 4]]>
    </select>
    <!-- 查询精选商品信息 -->
    <select id="query" parameterType="com.yeshi.fanli.vo.quality.QualityFactoryVO" resultMap="ResultMap">
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoGoodsBriefMapper.xml
@@ -432,6 +432,17 @@
        <include refid="Base_Column_List" />
        FROM yeshi_ec_taobao_goods tg WHERE tg.`auctionId` = ${auctionId}
    </select>
    <select id="listNeedUpdateGoodsId" resultType="Long">
        SELECT id FROM `yeshi_ec_taobao_goods`
        WHERE TO_DAYS(updatetime) <![CDATA[<]]> TO_DAYS(NOW())
            OR (HOUR(NOW()) -HOUR(updatetime)) <![CDATA[>=]]> #{hour}
        ORDER BY updatetime
        LIMIT ${start},${count}
    </select>
    <insert id="insertBatch" useGeneratedKeys="true" keyProperty="id"
        parameterType="java.util.List">
        insert into yeshi_ec_taobao_goods
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java
@@ -318,15 +318,6 @@
        qualityFactoryMapper.updateWeight(weight, time);
    }
    @Override
    public long queryNeedUpdateCount() {
        return qualityFactoryMapper.countQueryNeedUpdate();
    }
    @Override
    public List<Long> queryNeedUpdate(long start, int count, int hour) {
        return qualityFactoryMapper.queryNeedUpdate(start, count, hour);
    }
    /**
     * 获取缓存
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
@@ -17,6 +17,7 @@
import com.yeshi.fanli.exception.goods.CommonGoodsException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.activity.ActivityService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
@@ -207,5 +208,28 @@
        taoBaoGoodsBriefMapper.updateBatchSelective(updateList);
    }
    @Override
    public List<Long> listNeedUpdateGoodsId(long start, int count, int hour) {
        return taoBaoGoodsBriefMapper.listNeedUpdateGoodsId(start, count, hour);
    }
    @Override
    public void updateByTaoKeGoodsDetail(Long id) {
        try {
            TaoBaoGoodsBrief newGoods = TaoKeApiUtil.searchGoodsDetail(id);
            if (newGoods != null) {
                try {
                    updateTaoBaoGoods(newGoods);
                } catch (TaobaoGoodsUpdateException e) {
                    e.printStackTrace();
                }
            }
        } catch (TaobaoGoodsDownException e) {
            offlineTaoBaoGoods(id);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/lable/QualityFactoryService.java
@@ -110,21 +110,6 @@
     */
    public List<QualityFactory> queryAll(long start, int count, Integer days);
    /**
     * 查询需要更新的精选库商品id
     *
     * @param count
     * @param hour
     * @return
     */
    public List<Long> queryNeedUpdate(long start, int count, int hour);
    /**
     * 统计更新数据量
     *
     * @return
     */
    public long queryNeedUpdateCount();
    /**
     * 查询精选商品数据应用前端
fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoGoodsUpdateService.java
@@ -66,4 +66,19 @@
     */
    public TaoBaoGoodsBrief getUpdateTaoBaoGoodsBrief(TaoBaoGoodsBrief taoBaoGoodsBrief);
    /**
     * 队列更新商品
     * @param start
     * @param count
     * @param hour
     * @return
     */
    public List<Long> listNeedUpdateGoodsId(long start, int count, int hour);
    /**
     * 根据taoke更新商品信息
     * @param id
     */
    public void updateByTaoKeGoodsDetail(Long id);
}
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -27,10 +27,10 @@
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
import com.yeshi.fanli.service.inter.lable.LabelService;
import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
import com.yeshi.fanli.service.inter.push.IOSPushService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
import com.yeshi.fanli.service.inter.user.ExtractService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
@@ -69,7 +69,7 @@
    private OrderProcessService orderProcessService;
    @Resource
    private QualityFactoryService qualityFactoryService;
    private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
@@ -113,9 +113,9 @@
            doWeiQuanOrder();// 处理维权订单
            doPushIOS();// 处理发送IOS消息
            doThreeSaleUserCouponJob();// 处理邀请队列
            doUpdateGoodsJob();
            doUserMoneyDebtJob();// 债务偿还
            initScheduler();// 启动定时任务
            initScheduler();// 启动商品更新定时任务
            doUpdateGoodsJob(); // 更新商品队列
        }
    }
@@ -399,11 +399,13 @@
                            if (map != null) {
                                Iterator<String> its = map.keySet().iterator();
                                while (its.hasNext()) {
                                    qualityFactoryService.updateQualityGoods(map.get(its.next()));
                                    CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(its.next());
                                    String key = its.next();
                                    taoBaoGoodsUpdateService.updateByTaoKeGoodsDetail(Long.parseLong(key));
                                    CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(key);
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            LogHelper.error("更新商品出错:" + e.getMessage());
                        }
                    }