| | |
| | | package com.yeshi.fanli.service.impl.taobao;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.taobao.TLJBuyGoodsDao;
|
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | 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;
|
| | |
|
| | | @Service
|
| | | public class TLJBuyGoodsServiceImpl implements TLJBuyGoodsService {
|
| | | @Resource
|
| | | private TLJBuyGoodsDao tljBuyGoodsDao;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | @Lazy
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Override
|
| | | 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());
|
| | | if (goods.getWeight() == null)
|
| | | goods.setWeight(1);
|
| | | tljBuyGoodsDao.save(goods);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | |
|
| | | for (TaoBaoUnionConfig app : configList) {
|
| | | long count = tljBuyGoodsDao.countByDayAndAppKey(app.getAppKey(), goods.getDay());
|
| | | if (count < 12) {
|
| | | addTLJBuyGoods(goods, new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid()));
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "commonContentCache", key = "'tljBuy-listByDay'+#day")
|
| | | @Override
|
| | | public List<TLJBuyGoods> listByDay(String day) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService
|
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY);
|
| | | List<TLJBuyGoods> goodsList = new ArrayList<>();
|
| | | for (TaoBaoUnionConfig appInfo : configList) {
|
| | | List<TLJBuyGoods> list = listByDay(appInfo.getAppKey(), day, 10);
|
| | | if (list != null)
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | // 过滤淘礼金大于10块钱的
|
| | | BigDecimal hongBao = TaoBaoUtil.getGoodsHongBaoMoney(list.get(i).getGoods(),
|
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE,false);
|
| | | if (hongBao.compareTo(new BigDecimal(10)) > 0) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | |
|
| | | if (list != null && list.size() > 0)
|
| | | goodsList.addAll(list);
|
| | | }
|
| | | Collections.shuffle(goodsList);
|
| | | Comparator<TLJBuyGoods> cm = new Comparator<TLJBuyGoods>() {
|
| | |
|
| | | @Override
|
| | | public int compare(TLJBuyGoods o1, TLJBuyGoods o2) {
|
| | | return o1.getWeight() != null && o2.getWeight() != null ? o2.getWeight() - o1.getWeight() : 0;
|
| | | }
|
| | | };
|
| | | Collections.sort(goodsList, cm);
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TLJBuyGoods> listByDay(String appKey, String day, int count) {
|
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByDayOrderByUpdateTime(appKey, day, 1, count);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | if (list != null) {
|
| | | for (TLJBuyGoods shg : list)
|
| | | goodsList.add(shg.getGoods());
|
| | | }
|
| | | // 过滤基本商品信息
|
| | | goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
|
| | | // 过滤下线商品
|
| | | goodsList = taoBaoGoodsBriefService.filterOffLineGoods(goodsList);
|
| | | // 添加大淘客信息
|
| | | goodsList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goodsList);
|
| | | Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
|
| | | if (goodsList != null)
|
| | | for (TaoBaoGoodsBrief g : goodsList)
|
| | | goodsMap.put(g.getAuctionId(), g);
|
| | |
|
| | | for (int j = 0; j < list.size(); j++) {
|
| | | if (goodsMap.get(list.get(j).getGoods().getAuctionId()) == null) {
|
| | | list.remove(j);
|
| | | j--;
|
| | | }
|
| | | }
|
| | |
|
| | | // 加入更新队列
|
| | | //
|
| | | try {
|
| | | for (TLJBuyGoods tljGoods : list)
|
| | | if (tljGoods != null && tljGoods.getGoods() != null && tljGoods.getGoods().getAuctionId() != null)
|
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(tljGoods.getGoods().getAuctionId());
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteById(String id) {
|
| | | tljBuyGoodsDao.delete(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TaoBaoGoodsBrief> listPreGoods(int page) {
|
| | | List<DaTaoKeDetailV2> list = daTaoKeGoodsDetailV2Service.listPreTLJBuyGoods(page);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | if (list != null) {
|
| | | for (DaTaoKeDetailV2 v2 : list)
|
| | | goodsList.add(TaoBaoUtil.convert(v2));
|
| | | }
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByGoodsId(Long goodsId) {
|
| | | tljBuyGoodsDao.deleteByGoodsId(goodsId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean verifyCanCreateTLJ(Long auctionId, TaoKeAppInfo app) {
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | 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), app);
|
| | | } catch (TaoLiJinCreateException e1) {
|
| | | LogHelper.test("商品ID:"+auctionId);
|
| | | LogHelper.test("淘礼金验证出错:"+e1.getMsg());
|
| | | |
| | | if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {
|
| | | // 该商品不支持创建淘礼金红包
|
| | | deleteByGoodsId(auctionId);
|
| | | return false;
|
| | | } else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) {
|
| | | // 官方玩法钱包余额不足 TODO
|
| | | }
|
| | | } catch (TaoKeApiException e) {
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | @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,false);
|
| | | // 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());
|
| | | TLJBuyGoods.getGoods().setCouponInfo(goods.getCouponInfo());
|
| | | TLJBuyGoods.getGoods().setCouponEffectiveEndTime(goods.getCouponEffectiveEndTime());
|
| | | TLJBuyGoods.getGoods().setCouponEffectiveStartTime(goods.getCouponEffectiveStartTime());
|
| | | TLJBuyGoods.getGoods().setCouponLeftCount(goods.getCouponLeftCount());
|
| | | TLJBuyGoods.getGoods().setCouponStartFee(goods.getCouponStartFee());
|
| | | TLJBuyGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount());
|
| | | TLJBuyGoods.getGoods().setBiz30day(goods.getBiz30day());
|
| | | TLJBuyGoods.getGoods().setTkRate(goods.getTkRate());
|
| | | TLJBuyGoods.getGoods().setId(goods.getId());
|
| | | TLJBuyGoods.getGoods().setAuctionId(goods.getAuctionId());
|
| | | tljBuyGoodsDao.save(TLJBuyGoods);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void subHongBaoLeftCount(Long auctionId, String day, int count) {
|
| | | TLJBuyGoods goods = tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day);
|
| | | if (goods != null) {
|
| | | tljBuyGoodsDao.subHongBaoCount(goods.getId(), count);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public TLJBuyGoods selectByAuctionIdAndDay(Long auctionId, String day) {
|
| | | return tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void removeGoods(Long auctionId) {
|
| | | tljBuyGoodsDao.deleteByAuctionId(auctionId);
|
| | | // 清除列表缓存
|
| | | ehCacheCacheManager.getCache("commonContentCache")
|
| | | .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | }
|
| | |
|
| | | package com.yeshi.fanli.service.impl.taobao; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.cache.ehcache.EhCacheCacheManager; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.taobao.TLJBuyGoodsDao; |
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO; |
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; |
| | | import com.yeshi.common.entity.taobao.TaoKeAppInfo; |
| | | import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2; |
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException; |
| | | import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; |
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; |
| | | import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TaoBaoConstant; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | |
| | | @Service |
| | | public class TLJBuyGoodsServiceImpl implements TLJBuyGoodsService { |
| | | @Resource |
| | | private TLJBuyGoodsDao tljBuyGoodsDao; |
| | | |
| | | @Resource |
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | |
| | | @Resource |
| | | private EhCacheCacheManager ehCacheCacheManager; |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | |
| | | @Override |
| | | 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()); |
| | | if (goods.getWeight() == null) |
| | | goods.setWeight(1); |
| | | tljBuyGoodsDao.save(goods); |
| | | } |
| | | |
| | | @Override |
| | | public void addTLJBuyGoods(TLJBuyGoods goods) { |
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService |
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY); |
| | | |
| | | for (TaoBaoUnionConfig app : configList) { |
| | | long count = tljBuyGoodsDao.countByDayAndAppKey(app.getAppKey(), goods.getDay()); |
| | | if (count < 12) { |
| | | addTLJBuyGoods(goods, new TaoKeAppInfo(app.getAppKey(), app.getAppSecret(), app.getDefaultPid())); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Cacheable(value = "commonContentCache", key = "'tljBuy-listByDay'+#day") |
| | | @Override |
| | | public List<TLJBuyGoods> listByDay(String day) { |
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService |
| | | .getConfigByTypeCache(TaoBaoUnionConfig.TYPE_TLJ_BUY); |
| | | List<TLJBuyGoods> goodsList = new ArrayList<>(); |
| | | for (TaoBaoUnionConfig appInfo : configList) { |
| | | List<TLJBuyGoods> list = listByDay(appInfo.getAppKey(), day, 10); |
| | | if (list != null) |
| | | for (int i = 0; i < list.size(); i++) { |
| | | // 过滤淘礼金大于10块钱的 |
| | | BigDecimal hongBao = TaoBaoUtil.getGoodsHongBaoMoney(list.get(i).getGoods(), |
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE,false); |
| | | if (hongBao.compareTo(new BigDecimal(10)) > 0) { |
| | | list.remove(i--); |
| | | } |
| | | } |
| | | |
| | | if (list != null && list.size() > 0) |
| | | goodsList.addAll(list); |
| | | } |
| | | Collections.shuffle(goodsList); |
| | | Comparator<TLJBuyGoods> cm = new Comparator<TLJBuyGoods>() { |
| | | |
| | | @Override |
| | | public int compare(TLJBuyGoods o1, TLJBuyGoods o2) { |
| | | return o1.getWeight() != null && o2.getWeight() != null ? o2.getWeight() - o1.getWeight() : 0; |
| | | } |
| | | }; |
| | | Collections.sort(goodsList, cm); |
| | | return goodsList; |
| | | } |
| | | |
| | | @Override |
| | | public List<TLJBuyGoods> listByDay(String appKey, String day, int count) { |
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByDayOrderByUpdateTime(appKey, day, 1, count); |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | if (list != null) { |
| | | for (TLJBuyGoods shg : list) |
| | | goodsList.add(shg.getGoods()); |
| | | } |
| | | // 过滤基本商品信息 |
| | | goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList); |
| | | // 过滤下线商品 |
| | | goodsList = taoBaoGoodsBriefService.filterOffLineGoods(goodsList); |
| | | // 添加大淘客信息 |
| | | goodsList = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goodsList); |
| | | Map<String, TaoBaoGoodsBrief> goodsMap = new HashMap<>(); |
| | | if (goodsList != null) |
| | | for (TaoBaoGoodsBrief g : goodsList) |
| | | goodsMap.put(g.getAuctionId(), g); |
| | | |
| | | for (int j = 0; j < list.size(); j++) { |
| | | if (goodsMap.get(list.get(j).getGoods().getAuctionId()) == null) { |
| | | list.remove(j); |
| | | j--; |
| | | } |
| | | } |
| | | |
| | | // 加入更新队列 |
| | | // |
| | | try { |
| | | for (TLJBuyGoods tljGoods : list) |
| | | if (tljGoods != null && tljGoods.getGoods() != null && tljGoods.getGoods().getAuctionId() != null) |
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(tljGoods.getGoods().getAuctionId()); |
| | | } catch (Exception e) { |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | tljBuyGoodsDao.delete(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<TaoBaoGoodsBrief> listPreGoods(int page) { |
| | | List<DaTaoKeDetailV2> list = daTaoKeGoodsDetailV2Service.listPreTLJBuyGoods(page); |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | if (list != null) { |
| | | for (DaTaoKeDetailV2 v2 : list) |
| | | goodsList.add(TaoBaoUtil.convert(v2)); |
| | | } |
| | | return goodsList; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByGoodsId(String goodsId) { |
| | | tljBuyGoodsDao.deleteByGoodsId(goodsId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean verifyCanCreateTLJ(String auctionId, TaoKeAppInfo app) { |
| | | TaoLiJinDTO taoLiJinDTO = null; |
| | | 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), app); |
| | | } catch (TaoLiJinCreateException e1) { |
| | | LogHelper.test("商品ID:"+auctionId); |
| | | LogHelper.test("淘礼金验证出错:"+e1.getMsg()); |
| | | |
| | | if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) { |
| | | // 该商品不支持创建淘礼金红包 |
| | | deleteByGoodsId(auctionId); |
| | | return false; |
| | | } else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) { |
| | | // 官方玩法钱包余额不足 TODO |
| | | } |
| | | } catch (TaoKeApiException e) { |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @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,false); |
| | | // 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()); |
| | | TLJBuyGoods.getGoods().setCouponInfo(goods.getCouponInfo()); |
| | | TLJBuyGoods.getGoods().setCouponEffectiveEndTime(goods.getCouponEffectiveEndTime()); |
| | | TLJBuyGoods.getGoods().setCouponEffectiveStartTime(goods.getCouponEffectiveStartTime()); |
| | | TLJBuyGoods.getGoods().setCouponLeftCount(goods.getCouponLeftCount()); |
| | | TLJBuyGoods.getGoods().setCouponStartFee(goods.getCouponStartFee()); |
| | | TLJBuyGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount()); |
| | | TLJBuyGoods.getGoods().setBiz30day(goods.getBiz30day()); |
| | | TLJBuyGoods.getGoods().setTkRate(goods.getTkRate()); |
| | | TLJBuyGoods.getGoods().setId(goods.getId()); |
| | | TLJBuyGoods.getGoods().setAuctionId(goods.getAuctionId()); |
| | | tljBuyGoodsDao.save(TLJBuyGoods); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void subHongBaoLeftCount(String auctionId, String day, int count) { |
| | | TLJBuyGoods goods = tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day); |
| | | if (goods != null) { |
| | | tljBuyGoodsDao.subHongBaoCount(goods.getId(), count); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public TLJBuyGoods selectByAuctionIdAndDay(String auctionId, String day) { |
| | | return tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day); |
| | | } |
| | | |
| | | @Override |
| | | public void removeGoods(String auctionId) { |
| | | tljBuyGoodsDao.deleteByAuctionId(auctionId); |
| | | // 清除列表缓存 |
| | | ehCacheCacheManager.getCache("commonContentCache") |
| | | .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | } |
| | | |
| | | } |