| | |
| | | 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.bus.user.vip.UserLevelEnum;
|
| | | 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.service.inter.user.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | |
| | | * @param userShareGoodsRecord
|
| | | * @param listGoods
|
| | | */
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
|
| | | throws UserShareGoodsRecordException {
|
| | | // 分享记录
|
| | |
| | | * @param userShareGoodsRecord
|
| | | * @param listGoods
|
| | | */
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public FileUploadResult multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord,
|
| | | List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | |
| | | InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
|
| | |
|
| | | FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
|
| | | "sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis()
|
| | | + ".png");
|
| | |
|
| | | return shareImg;
|
| | | }
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(java.lang.System.currentTimeMillis());
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
|
| | | java.lang.System.currentTimeMillis());
|
| | |
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(java.lang.System.currentTimeMillis());
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
|
| | | java.lang.System.currentTimeMillis());
|
| | |
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | |
| | | recordDTO.setSource(ShareSourceTypeEnum.goodsDetail);
|
| | |
|
| | | // 分享id
|
| | | String key = StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#" + goodsType);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
|
| | | StringUtil.Md5(uid + "#GoodsDetail#" + auctionId + "#Type#" + goodsType));
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
|
| | | recordDTO.setRedisKey(key);
|
| | |
|
| | |
| | | recordDTO.setSource(ShareSourceTypeEnum.storage);
|
| | |
|
| | | // 缓存分享商品信息
|
| | | String key = StringUtil.Md5(uid + "#GoodsStorage#" + id);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
|
| | | recordDTO.setRedisKey(key);
|
| | |
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
|
| | |
| | | recordDTO.setSource(ShareSourceTypeEnum.storage);
|
| | |
|
| | | // 缓存分享商品信息
|
| | | String key = StringUtil.Md5(uid + "#GoodsStorage#" + id);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#GoodsStorage#" + id));
|
| | | recordDTO.setRedisKey(key);
|
| | |
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
|
| | |
| | | recordDTO.setSharePictureUrl(uploadResult.getUrl());
|
| | | recordDTO.setSource(ShareSourceTypeEnum.activity);
|
| | | // 缓存分享商品信息
|
| | | String key = StringUtil.Md5(uid + "#Activity#" + id);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Activity#" + id));
|
| | | recordDTO.setRedisKey(key);
|
| | |
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
|
| | |
| | | recordDTO.setSource(ShareSourceTypeEnum.activity);
|
| | |
|
| | | // 缓存分享商品信息
|
| | | String key = StringUtil.Md5(uid + "#Dynamic#" + id);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5(uid + "#Dynamic#" + id));
|
| | | recordDTO.setRedisKey(key);
|
| | |
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(recordDTO), 60 * 20);
|
| | |
| | | throw new UserShareGoodsRecordException(1, "传递参数不正确");
|
| | | }
|
| | | ShareGoodsRecordDTO recordDTO = null;
|
| | | String value = redisManager.getCommonString(shareKey);
|
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, shareKey);
|
| | | String value = redisManager.getCommonString(redisKey);
|
| | | if (!StringUtil.isNullOrEmpty(value)) {
|
| | | recordDTO = JsonUtil.getSimpleGson().fromJson(value, ShareGoodsRecordDTO.class);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 清理缓存
|
| | | redisManager.removeCommonString(shareKey);
|
| | | redisManager.removeCommonString(redisKey);
|
| | |
|
| | | if (singleGoods) {
|
| | | if (taolijin) {
|
| | |
| | |
|
| | | InputStream inputStream = ImageUtil.drawGoodsSharePicture(erCodeInputStream, portrait, listGoods);
|
| | | FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
|
| | | "sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis()
|
| | | + ".png");
|
| | |
|
| | | return shareImg;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void saveShareRecord(Long uid, CommonGoods goods) throws UserShareGoodsRecordException {
|
| | | if (goods == null || uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "参数缺失");
|
| | | }
|
| | |
|
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setShareState(1);
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
|
| | | CommonGoods resultCommonGoods = null;
|
| | | try {
|
| | | resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(goods);
|
| | | } catch (CommonGoodsException e) {
|
| | | throw new UserShareGoodsRecordException(1, "商品存入失败");
|
| | | }
|
| | |
|
| | | UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(), uid);
|
| | | if (singleGoods != null) {
|
| | | // 单个商品多次分享
|
| | | userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
|
| | | userShareGoodsRecord.setId(singleGoods.getRecordId());
|
| | | userShareGoodsRecord.setUpdateTime(new Date());
|
| | | userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
|
| | |
|
| | | // 最新商品
|
| | | singleGoods.setUpdateTime(new Date());
|
| | | userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
|
| | | } else {
|
| | | // 单个商品第一次分享
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | singleGoods = new UserShareGoodsGroup();
|
| | | singleGoods.setTotalOrder(0);
|
| | | singleGoods.setTotalBrowse(0);
|
| | | singleGoods.setTodayBrowse(0);
|
| | | singleGoods.setTotalMoney(new BigDecimal(0));
|
| | | singleGoods.setCreateTime(date);
|
| | | singleGoods.setUpdateTime(date);
|
| | | singleGoods.setCommonGoods(resultCommonGoods);
|
| | | singleGoods.setRecordId(userShareGoodsRecord.getId());
|
| | | userShareGoodsGroupService.insertSelective(singleGoods);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|