From f4548a3ee46afe45da4ee2a42dc169c575deee9f Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 31 七月 2019 11:57:36 +0800 Subject: [PATCH] 动态v2兼容 --- fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java | 62 ++++++++++++++++++++++++++++--- 1 files changed, 56 insertions(+), 6 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java index 9a7c479..307d1eb 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java @@ -10,6 +10,7 @@ import javax.annotation.Resource; import org.springframework.cache.annotation.Cacheable; +import org.springframework.cache.ehcache.EhCacheCacheManager; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.taobao.TLJBuyGoodsDao; @@ -25,6 +26,7 @@ import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; +import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @@ -42,20 +44,35 @@ @Resource private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService; + @Resource + private EhCacheCacheManager ehCacheCacheManager; + @Override - public void addTLJBuyGoods(TLJBuyGoods goods) { + public void addTLJBuyGoods(TLJBuyGoods goods, TaoKeAppInfo taoKeAppInfo) { if (goods == null || StringUtil.isNullOrEmpty(goods.getDay()) || goods.getGoods() == null) return; goods.setId(StringUtil.Md5(goods.getDay() + "#" + goods.getGoods().getAuctionId())); if (goods.getUpdateTime() == null) goods.setUpdateTime(new Date()); + if (taoKeAppInfo != null) + goods.setAppKey(taoKeAppInfo.getAppKey()); tljBuyGoodsDao.save(goods); } - @Cacheable(value = "commonContentCache", key = "'listByDay'+#day") + @Cacheable(value = "commonContentCache", key = "'tljBuy-listByDay'+#day") @Override public List<TLJBuyGoods> listByDay(String day) { - return listByDay(day, 10); + List<TLJBuyGoods> list = listByDay(day, 10); + // if (list.size() <= 10) + // return list; + // else { + // List<TLJBuyGoods> newList = new ArrayList<>(); + // for (int i = 0; i < 10; i++) { + // newList.add(list.get(i)); + // } + // return newList; + // } + return list; } @Override @@ -111,9 +128,7 @@ try { taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "娣樼ぜ閲戦獙璇�", new BigDecimal("1.00"), 1, new Date(), new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(), - new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), - new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, - TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT)); + new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), TaoBaoConstant.ownBuyApp); } catch (TaoKeApiException e) { if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) { // 璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖� @@ -128,9 +143,43 @@ @Override public void updateGoods(TaoBaoGoodsBrief goods) { + if (goods == null) + return; List<TLJBuyGoods> list = tljBuyGoodsDao.listByAuctionId(goods.getAuctionId()); + // 鏌ヨ鑷喘绔嬪噺鏄惁灏忎簬1鍏� + BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE); + // if (money.compareTo(new BigDecimal(1)) < 0) {// 鍒犻櫎鍟嗗搧 + // if (list != null) + // for (TLJBuyGoods tljGoods : list) { + // tljBuyGoodsDao.delete(tljGoods.getId()); + // } + // } + if (list != null) for (TLJBuyGoods TLJBuyGoods : list) { + + if (goods.getCouponInfo() == null) + goods.setCouponInfo(""); + if (goods.getCouponAmount() == null) + goods.setCouponAmount(new BigDecimal(0)); + + // 鍒ゆ柇 鍒镐俊鎭� 浠锋牸淇℃伅 杩斿埄姣斾緥淇℃伅鏄惁鏀瑰彉 + boolean change = false; + if (goods.getZkPrice().compareTo(TLJBuyGoods.getGoods().getZkPrice()) != 0) + change = true; + if (goods.getCouponAmount().compareTo(TLJBuyGoods.getGoods().getCouponAmount()) != 0) + change = true; + if (!goods.getCouponInfo().equalsIgnoreCase(TLJBuyGoods.getGoods().getCouponInfo())) + change = true; + if (goods.getTkRate().compareTo(TLJBuyGoods.getGoods().getTkRate()) != 0) + change = true; + + if (change) { + // 娓呴櫎鍒楄〃缂撳瓨 + ehCacheCacheManager.getCache("commonContentCache").evict( + "tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); + } + // 鏇存柊鍒镐俊鎭� 锛屼环鏍间俊鎭紝閿�閲忎俊鎭� TLJBuyGoods.getGoods().setZkPrice(goods.getZkPrice()); TLJBuyGoods.getGoods().setCouponAmount(goods.getCouponAmount()); @@ -141,6 +190,7 @@ TLJBuyGoods.getGoods().setCouponStartFee(goods.getCouponStartFee()); TLJBuyGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount()); TLJBuyGoods.getGoods().setBiz30day(goods.getBiz30day()); + TLJBuyGoods.getGoods().setTkRate(goods.getTkRate()); tljBuyGoodsDao.save(TLJBuyGoods); } } -- Gitblit v1.8.0