From 554de444b87aab5f93cb1593a8095612cf9479a7 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期二, 09 六月 2020 17:34:30 +0800 Subject: [PATCH] 订单 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java | 92 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 73 insertions(+), 19 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 1baa5dd..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 @@ -10,12 +10,16 @@ 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.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.goods.CollectionGoodsException; import com.yeshi.fanli.exception.goods.CommonGoodsException; -import com.yeshi.fanli.goods.CollectionGoodsV2; -import com.yeshi.fanli.goods.CommonGoods; import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; import com.yeshi.fanli.service.inter.goods.CommonGoodsService; import com.yeshi.fanli.util.factory.CommonGoodsFactory; @@ -32,12 +36,7 @@ @Resource private CommonGoodsService commonGoodsService; - @Transactional - @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); + private void addCollection(Long uid, CommonGoods commonGoods) throws CollectionGoodsException { if (commonGoods == null) throw new CollectionGoodsException(2, "鍟嗗搧淇℃伅鑾峰彇澶辫触"); // 鍒ゆ柇鍟嗗搧鏄惁瀛樺湪 @@ -62,6 +61,50 @@ 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 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) @@ -83,7 +126,7 @@ collectionGoodsV2Mapper.insertSelective(goods); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public void cancelCollection(Long uid, Long id) throws CollectionGoodsException { if (uid == null || uid == 0) @@ -101,19 +144,21 @@ } @Override - public List<CollectionGoodsV2> getCollectionGoodsList(Long uid, int page, int pageSize) { - return collectionGoodsV2Mapper.selectByUidOrderByCreateTimeDesc(uid, (page - 1) * pageSize, pageSize); + 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) { - return collectionGoodsV2Mapper.selectCountByUid(uid); + public long getCollectionGoodsCount(Long uid, Integer source, boolean notBackSuVip) { + return collectionGoodsV2Mapper.selectCountByUid(uid, source, notBackSuVip); } @Override - public void cancelCollectionByAuctionId(Long uid, Long auctionId) throws CollectionGoodsException { - CollectionGoodsV2 goodsV2 = collectionGoodsV2Mapper.selectByUidAndGoodsTypeAndGoodsId(uid, - CommonGoods.GOODS_TYPE_TB, auctionId); + 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()); @@ -125,10 +170,19 @@ } @Override - public CollectionGoodsV2 findByUidAndAuctionId(Long uid, Long actionId) { - CollectionGoodsV2 v2 = collectionGoodsV2Mapper.selectByUidAndGoodsTypeAndGoodsId(uid, CommonGoods.GOODS_TYPE_TB, - actionId); + 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()); + } + } + } + } -- Gitblit v1.8.0