admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -28,6 +28,7 @@
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -195,6 +196,28 @@
                        break;
                     }
                  }
               }
               String shareType = shareRecord.getShareType();
               if (StringUtil.isNullOrEmpty(shareType)) {
                  shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
               }
               BigDecimal totalMoney = shareRecord.getTotalMoney();
               if (totalMoney == null) {
                  shareRecord.setTotalMoney(new BigDecimal(0));
               }
            }
         } else {
            for (UserShareGoodsRecord shareRecord : list) {
               String shareType = shareRecord.getShareType();
               if (StringUtil.isNullOrEmpty(shareType)) {
                  shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
               }
               BigDecimal totalMoney = shareRecord.getTotalMoney();
               if (totalMoney == null) {
                  shareRecord.setTotalMoney(new BigDecimal(0));
               }
            }
         }
@@ -620,7 +643,7 @@
      recordDTO.setSource(ShareSourceTypeEnum.goodsDetail);
      // 分享id
      String key = StringUtil.Md5(uid + "#" + auctionId);
      String key = StringUtil.Md5(uid + "#GoodsDetail#" + auctionId);
      redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
      recordDTO.setRedisKey(key);
@@ -628,7 +651,7 @@
   }
   @Override
   public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief)
   public ShareGoodsRecordDTO addRecordGoodsStorage(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief, List<Long> listStorageID)
         throws UserShareGoodsRecordException {
      if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
         throw new UserShareGoodsRecordException(1, "传递参数不正确");
@@ -651,13 +674,14 @@
      ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
      recordDTO.setUid(uid);
      recordDTO.setShareId(id);
      recordDTO.setListGoodsBrief(listGoodsBrief);
      recordDTO.setShareUrl(shareUrl);
      recordDTO.setListId(listStorageID);
      recordDTO.setListGoodsBrief(listGoodsBrief);
      recordDTO.setSharePictureUrl(uploadResult.getUrl());
      recordDTO.setSource(ShareSourceTypeEnum.storage);
      // 缓存分享商品信息
      String key = StringUtil.Md5(uid + "##" + id);
      String key = StringUtil.Md5(uid + "#GoodsStorage#" + id);
      recordDTO.setRedisKey(key);
      redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
@@ -696,7 +720,7 @@
      recordDTO.setSharePictureUrl(uploadResult.getUrl());
      recordDTO.setSource(ShareSourceTypeEnum.activity);
      // 缓存分享商品信息
      String key = StringUtil.Md5(uid + "##" + id);
      String key = StringUtil.Md5(uid + "#Activity#" + id);
      recordDTO.setRedisKey(key);
      redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
@@ -727,12 +751,12 @@
      ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
      recordDTO.setUid(uid);
      recordDTO.setShareId(id);
      recordDTO.setListGoodsBrief(listGoodsBrief);
      recordDTO.setShareUrl(shareUrl);
      recordDTO.setListGoodsBrief(listGoodsBrief);
      recordDTO.setSource(ShareSourceTypeEnum.activity);
      // 缓存分享商品信息
      String key = StringUtil.Md5(uid + "##" + id);
      String key = StringUtil.Md5(uid + "#Dynamic#" + id);
      recordDTO.setRedisKey(key);
      redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
@@ -779,18 +803,23 @@
         shareRecord.setUpdateTime(new Date());
         updateByPrimaryKeySelective(shareRecord);
         // 保存商品信息
         multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
         // 更新选品库商品状态 为已分享
         List<UserShareGoodsGroup> listgoods = userShareGoodsGroupService.listByRecordId(shareId);
         if (listgoods != null && listgoods.size() > 0) {
            for (UserShareGoodsGroup userShareGoodsGroup : listgoods) {
               CommonGoods commonGoods = userShareGoodsGroup.getCommonGoods();
               if (commonGoods == null) {
                  continue;
               }
               userGoodsStorageService.updateShareStateByCommonGoodsId(commonGoods.getId());
         List<Long> listId = recordDTO.getListId();
         if (listId != null && listId.size() > 0) {
            for (Long id : listId) {
               UserGoodsStorage userGoodsStorage = new UserGoodsStorage();
               userGoodsStorage.setId(id);
               userGoodsStorage.setState(1);
               userGoodsStorageService.updateByPrimaryKeySelective(userGoodsStorage);
            }
         }
      }
      // 清理缓存
      redisManager.removeCommonString(shareKey);
   }
   /**
@@ -860,7 +889,7 @@
         }
      }
      InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
      InputStream inputStream = ImageUtil.drawGoodsSharePicture(erCodeInputStream, portrait, listGoods);
      FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
            "sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");