| | |
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper;
|
| | | import com.yeshi.fanli.dto.share.ShareInfoDTO;
|
| | | 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;
|
| | |
| | |
|
| | | return map;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 保存分享记录
|
| | | * |
| | | * @param userShareGoodsRecord
|
| | | * 分享记录: uid、picture、source 为必输入
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public ShareInfoDTO saveShareRecord(Long uid, ShareSourceTypeEnum source, String title,
|
| | | List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (listGoods == null || listGoods.size() == 0) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品数量不足");
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | |
|
| | | if (source == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享来源不能为空");
|
| | | }
|
| | |
|
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(source);
|
| | | userShareGoodsRecord.setTitle(title);
|
| | | // 取一个商品图片作为主图
|
| | | userShareGoodsRecord.setPicture(listGoods.get(0).getPictUrl());
|
| | |
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setShareState(0); // 初始未分享
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | | // 多个商品分享
|
| | | FileUploadResult loadResult = multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | | |
| | | ShareInfoDTO shareInfo = new ShareInfoDTO();
|
| | | shareInfo.setMd5(loadResult.getMd5());
|
| | | shareInfo.setCodeUrl(loadResult.getUrl());
|
| | | shareInfo.setShareId(userShareGoodsRecord.getId());
|
| | | shareInfo.setShareUrl(getShareUrl(userShareGoodsRecord));
|
| | | |
| | | return shareInfo;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 单个商品分享生成记录
|
| | |
| | | return shareImg;
|
| | | }
|
| | |
|
| | | public String getShareUrl (UserShareGoodsRecord shareRecord) {
|
| | | Long uid = shareRecord.getUid();
|
| | | Long shareId = shareRecord.getId();
|
| | | String source = shareRecord.getSource().name();
|
| | |
|
| | | String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
|
| | | configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareId + "",
|
| | | source + "");
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | return url;
|
| | | }
|
| | | |
| | | /**
|
| | | * 生成分享图
|
| | | *
|