admin
2019-12-04 da4c766d07a83e62992a0e287b678e13aeb6afda
Merge remote-tracking branch 'origin/div' into div
8个文件已修改
115 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJFreeBuyGoodsServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJFreeBuyGoodsUpdateServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinNewbiesServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/BrandInfoJob.java
@@ -5,6 +5,7 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
import com.yeshi.fanli.util.Constant;
@@ -32,8 +33,13 @@
        if (count == 0)
            return;
        for (int page = 0; page < (count / 80) + 1; page++) {
            brandInfoService.addShopAndGoods(page * 80, 80);
        long totalPage = (count / 100) + 1;
        for (long page = 0; page < totalPage; page++) {
            try {
                brandInfoService.addShopAndGoods(page * 100, 100);
            } catch (Exception e) {
               LogHelper.errorDetailInfo(e);
            }
        }
    }
    
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml
@@ -156,6 +156,9 @@
  <select id="listValidAll" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1
        AND (TO_DAYS(d.`bf_update_time`)<![CDATA[<]]> TO_DAYS(NOW())
             OR HOUR(NOW()) - HOUR(d.`bf_update_time`) <![CDATA[>=]]> 2)
    ORDER BY d.`bf_update_time`
    LIMIT ${start},${count}
  </select>
  
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java
@@ -21,6 +21,7 @@
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
import com.yeshi.fanli.service.inter.brand.BrandShopCaheService;
import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -47,7 +48,6 @@
    @Resource
    private BrandShopCaheService brandShopCaheService;
    
    @Override
    public BrandInfo addBrandGoods(BrandInfo brandInfo) {
        // 淘宝
@@ -64,15 +64,18 @@
        return goodsTB;
    }
    
    /**
     * 淘宝商品
     *
     * @param brandInfo
     * @return
     */
    private BrandInfo addBrandGoodsTB(BrandInfo brandInfo) {
        BrandInfo numInfo = new BrandInfo();
        Date date = new Date();
        BrandInfo numInfo = new BrandInfo();
        numInfo.setShopTotal(0);
        numInfo.setGoodsTotal(0);
        try {
        String shopKey = brandInfo.getShopKey();
        if (StringUtil.isNullOrEmpty(shopKey)) {
            // 删除之前的
@@ -80,8 +83,6 @@
            // 删除店铺
            brandShopCaheService.removeByDateAndType(brandInfo.getId(), 11, date);
            
            numInfo.setShopTotal(0);
            numInfo.setGoodsTotal(0);
            return numInfo;
        }
        
@@ -137,12 +138,13 @@
        
        // 删除之前的
        brandGoodsCaheDao.removeByDate(brandInfo.getId(), 1 , date);
        numInfo.setShopTotal(countShop);
        numInfo.setGoodsTotal(count);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        return numInfo;
    }
    
    /**
     *  京东商品
@@ -151,16 +153,18 @@
     * @return
     */
    private BrandInfo addBrandGoodsJD(BrandInfo brandInfo) {
        BrandInfo numInfo = new BrandInfo();
        Date date = new Date();
        BrandInfo numInfo = new BrandInfo();
        numInfo.setShopTotal(0);
        numInfo.setGoodsTotal(0);
        try {
        String shopKey = brandInfo.getShopKeyJD();
        if (StringUtil.isNullOrEmpty(shopKey)) {
            // 删除店铺
            brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date);
            // 删除之前
            brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2 , date);
            numInfo.setShopTotal(0);
            numInfo.setGoodsTotal(0);
            return numInfo;
        }
        
@@ -177,7 +181,6 @@
        brandShopCaheService.removeByDateAndType(brandInfo.getId(), 20, date);
        
        boolean addShop = true;
        for (int i=0; i < 2;i ++) {
            if ("1".equals(way)) {
                JDFilter filterAPI = new JDFilter();
@@ -213,7 +216,8 @@
                    if (addShop && shopInfo != null) {
                        // 包含该品牌名称
                        String shopName = shopInfo.getShopName();
                        if (!StringUtil.isNullOrEmpty(shopName) && shopName.toLowerCase().contains(shopKey.toLowerCase())) {
                            if (!StringUtil.isNullOrEmpty(shopName)
                                    && shopName.toLowerCase().contains(shopKey.toLowerCase())) {
                            addShop = false;
                            brandShopCaheService.addBrandShopJD(brandInfo, shopInfo);
                            countShop = 1;
@@ -229,29 +233,32 @@
        }
        // 删除之前
        brandGoodsCaheDao.removeByDate(brandInfo.getId(), 2 , date);
        numInfo.setShopTotal(countShop);
        numInfo.setGoodsTotal(count);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        return numInfo;    
    }
    
    /**
     * 拼多多商品
     *
     * @param brandInfo
     * @return
     */
    private BrandInfo addBrandGoodsPDD(BrandInfo brandInfo) {
        Date date = new Date();
        BrandInfo numInfo = new BrandInfo();
        numInfo.setShopTotal(0);
        numInfo.setGoodsTotal(0);
        try {
        String shopKey = brandInfo.getShopKeyPDD();
        if (StringUtil.isNullOrEmpty(shopKey)) {
            // 删除之前
            brandGoodsCaheDao.removeByDate(brandInfo.getId(), 3, date);
            // 删除之前店铺
            brandShopCaheService.removeByDateAndType(brandInfo.getId(), 30, date);
            numInfo.setShopTotal(0);
            numInfo.setGoodsTotal(0);
            return numInfo;
        }
        
@@ -295,9 +302,11 @@
        
        numInfo.setShopTotal(countShop);
        numInfo.setGoodsTotal(count);
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
        }
        return numInfo;
    }
    
    @Override
    public List<BrandGoodsCahe> getByBrandId(int start, int count, Long brandId){
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -27,6 +27,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.exception.brand.BrandInfoException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
@@ -363,7 +364,7 @@
            } else {
                updateInfo.setShopTotal(listshop.size());
            }
            updateInfo.setWeight(Math.random() * 1000);
            brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
        }
    }
@@ -376,19 +377,25 @@
            return;
        for (BrandInfo brandInfo : list) {
            try {
            String name = brandInfo.getName();
            String searchKey = brandInfo.getSearchKey();
            if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey))
                continue;
            // 添加商品
            BrandInfo numInfo = brandGoodsCaheService.addBrandGoods(brandInfo);
            brandInfo.setGoodsTotal(numInfo.getGoodsTotal());
            brandInfo.setShopTotal(numInfo.getShopTotal());
            brandInfo.setUpdateTime(new Date());
            brandInfo.setWeight(Math.random() * 1000);
            brandInfoMapper.updateByPrimaryKeySelective(brandInfo);
                BrandInfo updateInfo = new BrandInfo();
                updateInfo.setId(brandInfo.getId());
                updateInfo.setWeight(Math.random() * 1000);
                updateInfo.setGoodsTotal(numInfo.getGoodsTotal());
                updateInfo.setShopTotal(numInfo.getShopTotal());
                updateInfo.setUpdateTime(new Date());
                brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
            }
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -685,18 +685,15 @@
        if (auctionId == null || auctionId <= 0) 
            throw new ShareGoodsException(1, "商品ID不能为空");
        
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
        if (pid == null) {
            app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
        } else {
            app.setPid(pid);
        TaoBaoGoodsBrief goods = null;
        try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
        } catch (TaobaoGoodsDownException e) {
            throw new ShareGoodsException(1, "该商品已下架");
        }
        
        TaoBaoGoodsBrief goods = TaoKeApiUtil.specialConvertCoupon(auctionId, app);
        if (goods == null) 
            throw new ShareGoodsException(1, "转链接失败");
            throw new ShareGoodsException(1, "该商品已下架");
        
        String taoLiJinLink = null;
        try {
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJFreeBuyGoodsServiceImpl.java
@@ -71,7 +71,7 @@
    }
    
    @Cacheable(value = "commonContentCache", key = "'tljFreeBuy-listByDay'+#day")
    //@Cacheable(value = "commonContentCache", key = "'tljFreeBuy-listByDay'+#day")
    @Override
    public List<TLJFreeBuyGoods> listByDay(String day) {
        List<TLJFreeBuyGoods> list = listByDay(day, 10);
fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJFreeBuyGoodsUpdateServiceImpl.java
@@ -35,9 +35,18 @@
        List<TLJFreeBuyGoods> list = tljFreeBuyGoodsDao.listByGoodsId(goods.getAuctionId());
        if (list != null) {
            // 验证是否有券
            if (goods.getCouponAmount() == null || goods.getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
                for (TLJFreeBuyGoods tljGoods : list) {
                    tljFreeBuyGoodsDao.delete(tljGoods.getId());
                }
                return;
            }
            // 计算券后价  1<= n <= 2
            BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
            if (couplePrice.compareTo(new BigDecimal(1.0)) < 0 && couplePrice.compareTo(new BigDecimal(2.0)) > 0) {
            if (couplePrice.compareTo(new BigDecimal(1.0)) < 0 || couplePrice.compareTo(new BigDecimal(2.0)) > 0) {
                for (TLJFreeBuyGoods tljGoods : list) {
                    tljFreeBuyGoodsDao.delete(tljGoods.getId());
                }
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinNewbiesServiceImpl.java
@@ -217,6 +217,7 @@
        detail.setTitle(TaoLiJinDetailTypeEnum.add.getDesc());
        detail.setType(TaoLiJinDetailTypeEnum.add);
        detail.setCreateTime(new Date());
        detail.setRemark("新人红包");
        userTaoLiJinDetailService.insertSelective(detail);
        
        
@@ -252,11 +253,11 @@
        
        // 验证是否有券
        if (goods == null || goods.getCouponAmount() == null || 
                goods.getCouponAmount().compareTo(new BigDecimal(0)) == 0) {
                goods.getCouponAmount().compareTo(new BigDecimal(0)) <= 0) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    tljFreeBuyGoodsService.deleteByGoodsId(goods.getId());
                    tljFreeBuyGoodsService.deleteByGoodsId(goods.getAuctionId());
                }
            });
            throw new UserTaoLiJinNewbiesException(1, "该商品非免单商品");
@@ -264,11 +265,11 @@
        
        // 验证券后价 是否在 1-2元
        BigDecimal money = TaoBaoUtil.getAfterUseCouplePrice(goods);
        if (money.compareTo(new BigDecimal(1.0)) < 0 && money.compareTo(new BigDecimal(2.0)) > 0) {
        if (money.compareTo(new BigDecimal(1.0)) < 0 || money.compareTo(new BigDecimal(2.0)) > 0) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    tljFreeBuyGoodsService.deleteByGoodsId(goods.getId());
                    tljFreeBuyGoodsService.deleteByGoodsId(goods.getAuctionId());
                }
            });
            throw new UserTaoLiJinNewbiesException(1, "该商品非免单商品");
@@ -309,6 +310,7 @@
        detail.setTitle(TaoLiJinDetailTypeEnum.reduce.getDesc());
        detail.setType(TaoLiJinDetailTypeEnum.reduce);
        detail.setCreateTime(new Date());
        detail.setRemark("新人免单使用红包");
        userTaoLiJinDetailService.insertSelective(detail);
        
        // 创建淘礼金链接