From fe879975a3e8a0a1aa280fb839e02d159bfbcff8 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 27 八月 2019 18:04:38 +0800 Subject: [PATCH] 金币任务多次获取bug修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java | 29 ++++++++++++++--------------- 1 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java index f8cc44f..c7056a0 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java @@ -10,6 +10,7 @@ import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.JsonUtil; import org.yeshi.utils.entity.FileUploadResult; @@ -32,6 +33,7 @@ import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; +import com.yeshi.fanli.util.CommonGoodsUtil; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; @@ -160,15 +162,15 @@ jdGoods = JDApiUtil.getGoodsDetail(auctionId); } if (jdGoods == null) { - throw new UserGoodsStorageException(1, "auctionId鍟嗗搧宸蹭笅鏋�"); + throw new UserGoodsStorageException(1, auctionId + "鍟嗗搧宸蹭笅鏋�"); } commonGoods = CommonGoodsFactory.create(jdGoods); - } else if (goodsType == Constant.SOURCE_TYPE_JD) { + } else if (goodsType == Constant.SOURCE_TYPE_PDD) { // 鎷煎澶� PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(auctionId); if (pddGoods == null) { - throw new UserGoodsStorageException(1, "auctionId鍟嗗搧宸蹭笅鏋�"); + throw new UserGoodsStorageException(1, auctionId + "鍟嗗搧宸蹭笅鏋�"); } commonGoods = CommonGoodsFactory.create(pddGoods); } else { @@ -178,7 +180,7 @@ TaoBaoGoodsBrief goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId); commonGoods = CommonGoodsFactory.create(goodsBrief); } catch (TaobaoGoodsDownException e) { - throw new UserGoodsStorageException(1, "auctionId鍟嗗搧宸蹭笅鏋�"); + throw new UserGoodsStorageException(1, auctionId + "鍟嗗搧宸蹭笅鏋�"); } } @@ -215,6 +217,7 @@ @Override + @Transactional public void addCommonGoods(Long uid, Set<Long> ids) throws UserGoodsStorageException { if (uid == null) { @@ -348,7 +351,7 @@ } return state; } - + @Override public JSONObject shareGoods(Long uid, List<Long> listStorageID) throws UserGoodsStorageException, UserShareGoodsRecordException { @@ -403,7 +406,6 @@ throw new UserGoodsStorageException(1, "閫夊搧搴撳晢鍝佷笉瀛樺湪"); } - List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>(); // 杩樺師椤哄簭 鐢ㄤ簬鍒跺浘 for (Long sid: listStorageID) { @@ -417,30 +419,27 @@ } BigDecimal totalMoney = new BigDecimal(0.00); - List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>(); + List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>(); Integer goodsType = null; BigDecimal rate = hongBaoManageService.getShareRate(); for (UserGoodsStorage userGoodsStorage: listResult) { CommonGoods commonGoods = userGoodsStorage.getCommonGoods(); + BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate); + totalMoney = MoneyBigDecimalUtil.add(totalMoney, money); + listCommonGoods.add(commonGoods); if (goodsType == null) { goodsType = commonGoods.getGoodsType(); } - - TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); - listGoodsBrief.add(goodsBrief); - - BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate); - totalMoney = MoneyBigDecimalUtil.add(totalMoney, money); } - ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listGoodsBrief, listStorageID); + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods, listStorageID); FileUploadResult uploadResult = new FileUploadResult(); uploadResult.setUrl(shareRecord.getSharePictureUrl()); JSONObject data = new JSONObject(); - data.put("revenue", listGoodsBrief.size() + "涓晢鍝侀浼板垎浜閲戯細楼"+totalMoney); + data.put("revenue", listCommonGoods.size() + "涓晢鍝侀浼板垎浜閲戯細楼"+totalMoney); data.put("shareId", shareRecord.getRedisKey()); data.put("shareImg", uploadResult); -- Gitblit v1.8.0