From d99f45a1c358282ab0d4333232da25f03560778f Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 29 五月 2020 18:49:31 +0800 Subject: [PATCH] 苏宁,唯品会接口修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java | 141 ++++++++++++++++++++-------------------------- 1 files changed, 61 insertions(+), 80 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java index 8d5d9a6..0db2f58 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java @@ -11,6 +11,8 @@ import com.yeshi.fanli.dao.mybatis.goods.CollectionGoodsV2Mapper; import com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; +import com.yeshi.fanli.dto.suning.SuningGoodsInfo; +import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.goods.CollectionGoodsV2; import com.yeshi.fanli.entity.goods.CommonGoods; @@ -34,99 +36,75 @@ @Resource private CommonGoodsService commonGoodsService; - @Transactional(rollbackFor=Exception.class) + private void addCollection(Long uid, CommonGoods commonGoods) throws CollectionGoodsException { + if (commonGoods == null) + throw new CollectionGoodsException(2, "鍟嗗搧淇℃伅鑾峰彇澶辫触"); + // 鍒ゆ柇鍟嗗搧鏄惁瀛樺湪 + try { + commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); + } catch (CommonGoodsException e) { + commonGoods = null; + } + if (commonGoods == null || commonGoods.getId() == null) + throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触"); + + CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper.selectByUidAndCommonGoodsId(uid, + commonGoods.getId()); + if (collectionGoodsV2 != null) + throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌"); + + collectionGoodsV2 = new CollectionGoodsV2(); + collectionGoodsV2.setCommonGoods(commonGoods); + collectionGoodsV2.setCreateTime(new Date()); + collectionGoodsV2.setUpdateTime(new Date()); + collectionGoodsV2.setUserInfo(new UserInfo(uid)); + collectionGoodsV2Mapper.insertSelective(collectionGoodsV2); + } + + @Transactional(rollbackFor = Exception.class) @Override public void addCollection(Long uid, TaoBaoGoodsBrief goods) throws CollectionGoodsException { if (uid == null || uid == 0) throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); CommonGoods commonGoods = CommonGoodsFactory.create(goods); - if (commonGoods == null) - throw new CollectionGoodsException(2, "鍟嗗搧淇℃伅鑾峰彇澶辫触"); - // 鍒ゆ柇鍟嗗搧鏄惁瀛樺湪 - try { - commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); - } catch (CommonGoodsException e) { - commonGoods = null; - } - if (commonGoods == null || commonGoods.getId() == null) - throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触"); - - CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper.selectByUidAndCommonGoodsId(uid, - commonGoods.getId()); - if (collectionGoodsV2 != null) - throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌"); - - collectionGoodsV2 = new CollectionGoodsV2(); - collectionGoodsV2.setCommonGoods(commonGoods); - collectionGoodsV2.setCreateTime(new Date()); - collectionGoodsV2.setUpdateTime(new Date()); - collectionGoodsV2.setUserInfo(new UserInfo(uid)); - collectionGoodsV2Mapper.insertSelective(collectionGoodsV2); + addCollection(uid,commonGoods); } - - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void addJDCollection(Long uid, JDGoods jdGoods) throws CollectionGoodsException { if (uid == null || uid == 0) throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); CommonGoods commonGoods = CommonGoodsFactory.create(jdGoods); - if (commonGoods == null) - throw new CollectionGoodsException(2, "鍟嗗搧淇℃伅鑾峰彇澶辫触"); - // 鍒ゆ柇鍟嗗搧鏄惁瀛樺湪 - try { - commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); - } catch (CommonGoodsException e) { - commonGoods = null; - } - if (commonGoods == null || commonGoods.getId() == null) - throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触"); - - CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper.selectByUidAndCommonGoodsId(uid, - commonGoods.getId()); - if (collectionGoodsV2 != null) - throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌"); - - collectionGoodsV2 = new CollectionGoodsV2(); - collectionGoodsV2.setCommonGoods(commonGoods); - collectionGoodsV2.setCreateTime(new Date()); - collectionGoodsV2.setUpdateTime(new Date()); - collectionGoodsV2.setUserInfo(new UserInfo(uid)); - collectionGoodsV2Mapper.insertSelective(collectionGoodsV2); + addCollection(uid,commonGoods); } - - - @Transactional(rollbackFor=Exception.class) + + @Transactional(rollbackFor = Exception.class) @Override public void addPDDCollection(Long uid, PDDGoodsDetail goods) throws CollectionGoodsException { if (uid == null || uid == 0) throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); CommonGoods commonGoods = CommonGoodsFactory.create(goods); - if (commonGoods == null) - throw new CollectionGoodsException(2, "鍟嗗搧淇℃伅鑾峰彇澶辫触"); - // 鍒ゆ柇鍟嗗搧鏄惁瀛樺湪 - try { - commonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods); - } catch (CommonGoodsException e) { - commonGoods = null; - } - if (commonGoods == null || commonGoods.getId() == null) - throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触"); - - CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper.selectByUidAndCommonGoodsId(uid, - commonGoods.getId()); - if (collectionGoodsV2 != null) - throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌"); - - collectionGoodsV2 = new CollectionGoodsV2(); - collectionGoodsV2.setCommonGoods(commonGoods); - collectionGoodsV2.setCreateTime(new Date()); - collectionGoodsV2.setUpdateTime(new Date()); - collectionGoodsV2.setUserInfo(new UserInfo(uid)); - collectionGoodsV2Mapper.insertSelective(collectionGoodsV2); + addCollection(uid,commonGoods); } - - + + @Transactional(rollbackFor = Exception.class) + @Override + public void addVIPCollection(Long uid, VIPGoodsInfo goods) throws CollectionGoodsException { + if (uid == null || uid == 0) + throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); + CommonGoods commonGoods = CommonGoodsFactory.create(goods); + addCollection(uid,commonGoods); + } + + @Override + public void addSuningCollection(Long uid, SuningGoodsInfo goods) throws CollectionGoodsException { + if (uid == null || uid == 0) + throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); + CommonGoods commonGoods = CommonGoodsFactory.create(goods); + addCollection(uid,commonGoods); + } + @Override public void addCollection(CollectionGoodsV2 goods) throws CollectionGoodsException { if (goods.getUserInfo() == null || goods.getCommonGoods() == null) @@ -148,7 +126,7 @@ collectionGoodsV2Mapper.insertSelective(goods); } - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @Override public void cancelCollection(Long uid, Long id) throws CollectionGoodsException { if (uid == null || uid == 0) @@ -166,8 +144,10 @@ } @Override - public List<CollectionGoodsV2> getCollectionGoodsList(Long uid, int page, int pageSize, Integer source, boolean notBackSuVip) { - return collectionGoodsV2Mapper.selectByUidOrderByCreateTimeDesc(uid, (page - 1) * pageSize, pageSize, source, notBackSuVip); + public List<CollectionGoodsV2> getCollectionGoodsList(Long uid, int page, int pageSize, Integer source, + boolean notBackSuVip) { + return collectionGoodsV2Mapper.selectByUidOrderByCreateTimeDesc(uid, (page - 1) * pageSize, pageSize, source, + notBackSuVip); } @Override @@ -176,7 +156,8 @@ } @Override - public void cancelCollectionByAuctionId(Long uid, Long auctionId, Integer goodsType) throws CollectionGoodsException { + public void cancelCollectionByAuctionId(Long uid, Long auctionId, Integer goodsType) + throws CollectionGoodsException { CollectionGoodsV2 goodsV2 = collectionGoodsV2Mapper.selectByUidAndGoodsType(uid, auctionId, goodsType); if (goodsV2 == null) throw new CollectionGoodsException(1, "鏃犳敹钘�"); @@ -193,12 +174,12 @@ CollectionGoodsV2 v2 = collectionGoodsV2Mapper.selectByUidAndGoodsType(uid, actionId, goodsType); return v2; } - + @Override public void deteleBYByUidAndCommonId(Long uid, Long commonId) { List<CollectionGoodsV2> list = collectionGoodsV2Mapper.getByUidAndCommonId(uid, commonId); if (list != null && list.size() > 0) { - for (CollectionGoodsV2 v2: list) { + for (CollectionGoodsV2 v2 : list) { collectionGoodsV2Mapper.deleteByPrimaryKey(v2.getId()); } } -- Gitblit v1.8.0