From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java | 404 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 197 insertions(+), 207 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..40d8073 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 @@ -1,207 +1,197 @@ -package com.yeshi.fanli.service.impl.goods; - -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -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.entity.bus.user.UserInfo; -import com.yeshi.fanli.entity.goods.CollectionGoodsV2; -import com.yeshi.fanli.entity.goods.CommonGoods; -import com.yeshi.fanli.entity.jd.JDGoods; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.exception.goods.CollectionGoodsException; -import com.yeshi.fanli.exception.goods.CommonGoodsException; -import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; -import com.yeshi.fanli.service.inter.goods.CommonGoodsService; -import com.yeshi.fanli.util.factory.CommonGoodsFactory; - -@Service -public class CollectionGoodsV2ServiceImpl implements CollectionGoodsV2Service { - - @Resource - private CollectionGoodsV2Mapper collectionGoodsV2Mapper; - - @Resource - private CommonGoodsMapper commonGoodsMapper; - - @Resource - private CommonGoodsService commonGoodsService; - - @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); - } - - - @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); - } - - - @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); - } - - - @Override - public void addCollection(CollectionGoodsV2 goods) throws CollectionGoodsException { - if (goods.getUserInfo() == null || goods.getCommonGoods() == null) - throw new CollectionGoodsException(1, "鏁版嵁涓嶅畬鏁�"); - try { - CommonGoods commonGoods = commonGoodsService.addOrUpdateCommonGoods(goods.getCommonGoods()); - goods.setCommonGoods(commonGoods); - } catch (CommonGoodsException e) { - goods.setCommonGoods(null); - } - - if (goods.getCommonGoods() == null) - throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触"); - - CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper - .selectByUidAndCommonGoodsId(goods.getUserInfo().getId(), goods.getCommonGoods().getId()); - if (collectionGoodsV2 != null) - throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌"); - collectionGoodsV2Mapper.insertSelective(goods); - } - - @Transactional(rollbackFor=Exception.class) - @Override - public void cancelCollection(Long uid, Long id) throws CollectionGoodsException { - if (uid == null || uid == 0) - throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); - - if (id == null || id == 0) - throw new CollectionGoodsException(1, "鏃犳敹钘�"); - - CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper.selectByPrimaryKey(id); - if (collectionGoodsV2 == null) - return; - if (collectionGoodsV2.getUserInfo().getId() != uid.longValue()) - throw new CollectionGoodsException(2, "鏃犳潈闄�"); - collectionGoodsV2Mapper.deleteByPrimaryKey(id); - } - - @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); - } - - @Override - public long getCollectionGoodsCount(Long uid, Integer source, boolean notBackSuVip) { - return collectionGoodsV2Mapper.selectCountByUid(uid, source, notBackSuVip); - } - - @Override - 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, "鏃犳敹钘�"); - collectionGoodsV2Mapper.deleteByPrimaryKey(goodsV2.getId()); - } - - @Override - public void cancelCollectionByUid(Long uid) throws CollectionGoodsException { - collectionGoodsV2Mapper.deleteByUid(uid); - } - - @Override - public CollectionGoodsV2 findByUidAndAuctionId(Long uid, Long actionId, Integer goodsType) { - 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) { - collectionGoodsV2Mapper.deleteByPrimaryKey(v2.getId()); - } - } - } - -} +package com.yeshi.fanli.service.impl.goods; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +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; +import com.yeshi.fanli.entity.jd.JDGoods; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.exception.goods.CollectionGoodsException; +import com.yeshi.fanli.exception.goods.CommonGoodsException; +import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; +import com.yeshi.fanli.service.inter.goods.CommonGoodsService; +import com.yeshi.fanli.util.factory.CommonGoodsFactory; + +@Service +public class CollectionGoodsV2ServiceImpl implements CollectionGoodsV2Service { + + @Resource + private CollectionGoodsV2Mapper collectionGoodsV2Mapper; + + @Resource + private CommonGoodsMapper commonGoodsMapper; + + @Resource + private CommonGoodsService commonGoodsService; + + 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); + addCollection(uid,commonGoods); + } + + @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); + addCollection(uid,commonGoods); + } + + @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); + 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 addDYCollection(Long uid, DYGoodsDetail 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) + throw new CollectionGoodsException(1, "鏁版嵁涓嶅畬鏁�"); + try { + CommonGoods commonGoods = commonGoodsService.addOrUpdateCommonGoods(goods.getCommonGoods()); + goods.setCommonGoods(commonGoods); + } catch (CommonGoodsException e) { + goods.setCommonGoods(null); + } + + if (goods.getCommonGoods() == null) + throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触"); + + CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper + .selectByUidAndCommonGoodsId(goods.getUserInfo().getId(), goods.getCommonGoods().getId()); + if (collectionGoodsV2 != null) + throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌"); + collectionGoodsV2Mapper.insertSelective(goods); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void cancelCollection(Long uid, Long id) throws CollectionGoodsException { + if (uid == null || uid == 0) + throw new CollectionGoodsException(1, "鏃犵敤鎴稩D"); + + if (id == null || id == 0) + throw new CollectionGoodsException(1, "鏃犳敹钘�"); + + CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper.selectByPrimaryKey(id); + if (collectionGoodsV2 == null) + return; + if (collectionGoodsV2.getUserInfo().getId() != uid.longValue()) + throw new CollectionGoodsException(2, "鏃犳潈闄�"); + collectionGoodsV2Mapper.deleteByPrimaryKey(id); + } + + @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); + } + + @Override + public long getCollectionGoodsCount(Long uid, Integer source, boolean notBackSuVip) { + return collectionGoodsV2Mapper.selectCountByUid(uid, source, notBackSuVip); + } + + @Override + public void cancelCollectionByAuctionId(Long uid, String auctionId, Integer goodsType) + throws CollectionGoodsException { + CollectionGoodsV2 goodsV2 = collectionGoodsV2Mapper.selectByUidAndGoodsType(uid, auctionId, goodsType); + if (goodsV2 == null) + throw new CollectionGoodsException(1, "鏃犳敹钘�"); + collectionGoodsV2Mapper.deleteByPrimaryKey(goodsV2.getId()); + } + + @Override + public void cancelCollectionByUid(Long uid) throws CollectionGoodsException { + collectionGoodsV2Mapper.deleteByUid(uid); + } + + @Override + public CollectionGoodsV2 findByUidAndAuctionId(Long uid, String actionId, Integer goodsType) { + 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) { + collectionGoodsV2Mapper.deleteByPrimaryKey(v2.getId()); + } + } + } + +} -- Gitblit v1.8.0