| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | |
| | | @RequestMapping("api/v1/share")
|
| | | public class ShareController {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | |
|
| | |
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setTkCode(taoBaoLink.getTaoToken());
|
| | | history.setLink(taoBaoLink.getClickUrl());
|
| | | history.setQuanLink(taoBaoLink.getCouponLink());
|
| | |
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsId(taoBaoLink.getGoods().getAuctionId());
|
| | | history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setHongbao(TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate));
|
| | | List<String> imgList = taoBaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | history.setUser(new UserInfo(uid));
|
| | | history.setPostPicture(taoBaoLink.getGoods().getPictUrl());
|
| | |
|
| | | data.put("shareMoney", "¥" + history.getHongbao().toString());
|
| | |
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | |
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 异步操作
|
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | //异步操作 添加分享记录
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setUser(new UserInfo(uid));
|
| | | history.setHongbao(shareMoney);
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(taoBaoLink.getTaoToken());
|
| | | history.setLink(taoBaoLink.getClickUrl());
|
| | | history.setQuanLink(taoBaoLink.getCouponLink());
|
| | | history.setGoodsId(taoBaoLink.getGoods().getAuctionId());
|
| | | history.setPostPicture(taoBaoLink.getGoods().getPictUrl());
|
| | | |
| | | List<String> imgList = taoBaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | return;
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (ShareGoodsException e) {
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | |
| | |
|
| | |
|
| | |
|
| | | |
| | | /**
|
| | | * 查询顶部分类
|
| | | * @param acceptData
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | // 分类id
|
| | | long cid = dynamicInfo.getClassId();
|
| | |
|
| | | if (cid == 1) { // 热销单品
|
| | | // 文字内容
|
| | | data.put("title", JsonUtil.getApiCommonGson().toJson(dynamicInfo.getTitle()));
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | data.put("title", title);
|
| | | data.put("content", "我在返利券发现了一个很好的商品,快来看看~");
|
| | | |
| | | // 分享奖金
|
| | | ClientTextStyleVO desc = dynamicInfo.getDesc();
|
| | | String content = desc.getContent();
|
| | | int index = content.indexOf("¥");
|
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())));
|
| | | |
| | | // 商品分享链接
|
| | | List<GoodsPicture> imgs2 = dynamicInfo.getImgs();
|
| | | GoodsPicture goodsPicture = imgs2.get(0);
|
| | | Long auctionId = goodsPicture.getGoods().getAuctionId();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | auctionId + "");
|
| | |
|
| | | // 分享链接
|
| | | String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s",
|
| | | configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), id, "dynamic");
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | data.put("clickUrl", url);
|
| | | // 分享文字图标
|
| | | |
| | | // 分享提示图片
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | |
| | | data.put("notifyPicture", array.optString(p));
|
| | | }
|
| | |
|
| | | |
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | String relationId = null;
|
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
|
| | | && extraInfo.getRelationValid() == true) {
|
| | | relationId = extraInfo.getRelationId();
|
| | | }
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, 42472466270L, relationId);
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
|
| | |
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(goodsPicture.getUrl(), 500));
|
| | | // 淘宝口令
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | // 商品图片链接
|
| | | data.put("shareLink", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | | // 帮助链接
|
| | | data.put("helpLink","https://img.alicdn.com/imgextra/i1/2200656425615/O1CN01dst9HQ1rLiPN7xmhD_!!0-item_pic.jpg");
|
| | | data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | // 分享记录id
|
| | | data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId));
|
| | |
|
| | | } else if (cid == 2) { // 推荐好货
|
| | |
|
| | | String picUrl = null;
|
| | | List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<GoodsPicture> listImgs = dynamicInfo.getImgs();
|
| | | for (GoodsPicture goodsPicture: listImgs) {
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | listGoods.add(goods);
|
| | | }
|
| | | |
| | | String title = "";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | for (ClientTextStyleVO textStyleVO: listTitle) {
|
| | | title = title + textStyleVO.getContent();
|
| | | }
|
| | | |
| | | if (title.length() > 250) {
|
| | | title = title.substring(0, 250);
|
| | | |
| | | if (picUrl == null) {
|
| | | picUrl = goodsPicture.getUrl();
|
| | | }
|
| | | }
|
| | |
|
| | | // 文字内容
|
| | | data.put("title", JsonUtil.getApiCommonGson().toJson(dynamicInfo.getTitle()));
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | data.put("title", title);
|
| | | data.put("content", "我在返利券发现了一个很好的商品,快来看看~");
|
| | | |
| | | // 分享奖金
|
| | | ClientTextStyleVO desc = dynamicInfo.getDesc();
|
| | | String content = desc.getContent();
|
| | | int index = content.indexOf("¥");
|
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())));
|
| | | // 分享文字图标
|
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1 , content.length())));
|
| | | |
| | | // 分享链接
|
| | | ShareInfoDTO shareInfo = userShareGoodsRecordService.saveShareRecord(uid, |
| | | ShareSourceTypeEnum.activity, title, listGoods);
|
| | | data.put("shareId", shareInfo.getShareId());
|
| | | data.put("clickUrl", shareInfo.getShareUrl());
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(picUrl, 500));
|
| | | // 帮助链接
|
| | | data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | // 分享提醒语
|
| | | String notifyImgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(notifyImgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | }
|
| | | |
| | | ShareInfoDTO shareInfo = userShareGoodsRecordService.saveShareRecord(uid, ShareSourceTypeEnum.activity, title, listGoods);
|
| | | data.put("shareId", shareInfo.getShareId());
|
| | | data.put("clickUrl", shareInfo.getCodeUrl());
|
| | | // 商品图片链接
|
| | | data.put("shareLink", shareInfo.getShareUrl());
|
| | | // 帮助链接
|
| | | data.put("helpLink","https://img.alicdn.com/imgextra/i1/2200656425615/O1CN01dst9HQ1rLiPN7xmhD_!!0-item_pic.jpg");
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | } else if (cid == 4) { // 邀请分享
|
| | |
|
| | |
| | |
|
| | | Integer showType = dynamicInfo.getShowType();
|
| | | if (showType == 0) { // 无图分享
|
| | | String shortLink = UserUtil.getInviteShortLink(uid);
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | for (ClientTextStyleVO textStyleVO: listTitle) {
|
| | | String content = textStyleVO.getContent();
|
| | | content = content.replace("邀请码", inviteCode);
|
| | | content = content.replace("邀请链接", shortLink);
|
| | | textStyleVO .setContent(content);
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | data.put("title", listTitle);
|
| | | title = title.replace("【邀请码】", inviteCode);
|
| | | title = title.replace("【邀请链接】", UserUtil.getInviteShortLink(uid));
|
| | | data.put("title", title);
|
| | |
|
| | | } else { // 有图分享
|
| | | // 1、邀请规则
|
| | | |
| | | // 邀请链接
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | data.put("inviteLink", shortLink);
|
| | | data.put("inviteCode", inviteCode);
|
| | | |
| | | // 邀请图片
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | String imgLink = spreadUserImgService.getInviteImg(uid, imgs.get(0).getUrl(), inviteCode);
|
| | | data.put("imgLink", imgLink);
|
| | | |
| | | // 邀请规则
|
| | | BusinessSystem system = new BusinessSystem();
|
| | | system.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | system.setPlatform(1);
|
| | |
| | | String valueN = values.getValue();
|
| | | String valueBr = valueN.replace("\n", "<br><br>");
|
| | | data.put("inviteRules", valueBr);
|
| | | |
| | | // 邀请链接
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | data.put("inviteLink", shortLink);
|
| | | |
| | | // 邀请图片
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | String imgLink = spreadUserImgService.getUserSpreadImg(uid, imgs.get(0).getUrl());
|
| | | data.put("imgLink", imgLink);
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | // 更新分享次数
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | Integer shareCount = dynamicInfo.getShareCount();
|
| | | dynamicInfo.setShareCount(shareCount + 1);
|
| | | dynamicInfoService.updateShareCount(dynamicInfo);
|
| | | }
|
| | | });
|
| | | |
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享记录失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | }
|