| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.share.ShareInfoDTO;
|
| | | import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | |
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BusinessEmergent110Service businessEmergent110Service;
|
| | |
|
| | | // 获取商品分享链接
|
| | | @RequestMapping(value = "getGoodsShareUrl")
|
| | |
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | |
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | // data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId));
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | 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.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<>();
|
| | |
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | | // catch (UserShareGoodsRecordException e) {
|
| | | // out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | // e.printStackTrace();
|
| | | // } |
| | | |
| | | catch (ShareGoodsException e) {
|
| | | } catch (ShareGoodsException e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:"+uid+"auctionId:"+auctionId, "");
|
| | | // 分享出错报警
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | @RequestMapping(value = "sharedetail", method = RequestMethod.POST)
|
| | | public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) {
|
| | | try {
|
| | | userShareGoodsRecordService.saveDetail(uid, auctionId, type);
|
| | | userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId);
|
| | | out.print(JsonUtil.loadTrueResult("分享成功"));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "updaterecord", method = RequestMethod.POST)
|
| | | public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) {
|
| | | if (shareId == null) {
|
| | | public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(shareId)) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | |
|
| | | try {
|
| | | userShareGoodsRecordService.updateShareRecord(shareId);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | // 更新分享生效
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | userShareGoodsRecordService.takeEffectShareRecord(shareId);
|
| | | } catch (UserShareGoodsRecordException eu) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(eu);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | out.print(JsonUtil.loadTrueResult("分享成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 查询顶部分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param cid
|
| | |
| | | @RequestMapping(value = "shareDynamic", method = RequestMethod.POST)
|
| | | public void shareDynamic(AcceptData acceptData, String id, Long uid, PrintWriter out) {
|
| | | try {
|
| | | |
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | DynamicInfo dynamicInfo = dynamicInfoService.getById(id);
|
| | | if (dynamicInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该动态信息已不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | // 分类id
|
| | | long cid = dynamicInfo.getClassId();
|
| | | |
| | | if (cid == 1) { // 热销单品
|
| | | // 文字内容
|
| | | String title ="";
|
| | |
|
| | | if (cid == 1 || cid == 2) { // 1 热销单品 2 推荐好货
|
| | | if (cid == 1) {
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | GoodsPicture goodsPicture = imgs.get(0);
|
| | | if (goodsPicture.getGoodState() == 1) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | } else {
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | try {
|
| | | TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 分享文字
|
| | | String title = null;
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | title = "";
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | if(StringUtil.isNullOrEmpty(title)) {
|
| | | title = "给你推荐精选好物优惠券,购物前先领券,别错过优惠哦~";
|
| | | }
|
| | | 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 shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | data.put("clickUrl", url);
|
| | | |
| | | // 分享提示图片
|
| | |
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | // 分享提示语
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | 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, auctionId, relationId);
|
| | | |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(goodsPicture.getUrl(), 500));
|
| | | // 淘宝口令
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | |
|
| | | // 分享出去的图片
|
| | | String pictUrl = dynamicInfo.getImgs().get(0).getUrl();
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(pictUrl, 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"));
|
| | | // 分享记录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);
|
| | | |
| | | if (picUrl == null) {
|
| | | picUrl = goodsPicture.getUrl();
|
| | | data.put("helpLink",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | |
|
| | | if (cid == 2) { // 2 推荐好货
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid,
|
| | | dynamicInfo.getListGoodsBrief());
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | data.put("clickUrl", shareRecord.getShareUrl());
|
| | | } else {
|
| | | // 分享id
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid,
|
| | | dynamicInfo.getListGoodsBrief());
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | |
|
| | | Long auctionId = dynamicInfo.getImgs().get(0).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 shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | }
|
| | | |
| | | // 文字内容
|
| | | String title ="";
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | data.put("clickUrl", url);
|
| | |
|
| | | // 淘宝口令
|
| | | 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, auctionId, relationId);
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | }
|
| | | 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())));
|
| | | |
| | | // 分享链接
|
| | | 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));
|
| | | }
|
| | | |
| | |
|
| | | } else if (cid == 4) { // 邀请分享
|
| | | |
| | |
|
| | | String inviteCode = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | |
| | | out.print(JsonUtil.loadFalseResult(9001, "邀请码未激活"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Integer showType = dynamicInfo.getShowType();
|
| | | if (showType == 0) { // 无图分享
|
| | | String title ="";
|
| | | if (showType == 0) { // 无图分享
|
| | | String title = null;
|
| | | List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle();
|
| | | if (listTitle != null && listTitle.size() > 0) {
|
| | | title = "";
|
| | | for (ClientTextStyleVO textStyleVO : listTitle) {
|
| | | title += textStyleVO.getContent();
|
| | | }
|
| | |
| | | title = title.replace("【邀请码】", inviteCode);
|
| | | title = title.replace("【邀请链接】", UserUtil.getInviteShortLink(uid));
|
| | | data.put("title", title);
|
| | | |
| | |
|
| | | } else { // 有图分享
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | String bgUrl = imgs.get(0).getUrlOriginal();
|
| | |
|
| | | GoodsPicture goodsPicture = imgs.get(0);
|
| | | String bgUrl = goodsPicture.getUrlOriginal();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(bgUrl)) {
|
| | | out.print(JsonUtil.loadFalseResult("图片路径不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 用户信息
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | String portrait = userInfo.getPortrait();
|
| | | // 画邀请图片
|
| | | if (StringUtil.isNullOrEmpty(dynamicInfo.getInviteMaterialId())) {
|
| | | String imgLink = spreadUserImgService.drawInviteQrCodeNew(bgUrl,uid, portrait, inviteCode);
|
| | |
|
| | | Long activityId = dynamicInfo.getActivityId();
|
| | | if (activityId != null) {
|
| | | Integer pX = goodsPicture.getPx();
|
| | | ;
|
| | | Integer pY = goodsPicture.getPy();
|
| | | ;
|
| | | Integer size = goodsPicture.getSize();
|
| | |
|
| | | String imgLink = spreadUserImgService.drawInviteQrCodeNew(bgUrl, uid, portrait, pX, pY, size,
|
| | | inviteCode);
|
| | |
|
| | | data.put("imgLink", imgLink);
|
| | | } else {
|
| | | String title = imgs.get(0).getTitleOriginal();
|
| | | String imgLink = spreadUserImgService.getInviteImgToGreet(bgUrl,uid, portrait, inviteCode, title, new Date());
|
| | | String imgLink = spreadUserImgService.getInviteImgToGreet(bgUrl, uid, portrait, inviteCode,
|
| | | title, new Date());
|
| | | data.put("imgLink", imgLink);
|
| | | }
|
| | | |
| | | // 邀请规则
|
| | |
|
| | | // 邀请规则
|
| | | BusinessSystem system = new BusinessSystem();
|
| | | system.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | system.setPlatform(1);
|
| | | system.setId(4L);
|
| | | String key = "inviteRules"; // key值
|
| | | SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key);
|
| | | SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
|
| | | key);
|
| | | String valueN = values.getValue();
|
| | | String valueBr = valueN.replace("\n", "<br><br>");
|
| | | data.put("inviteRules", valueBr);
|
| | | |
| | | |
| | |
|
| | | // 邀请链接
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
|
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | data.put("inviteLink", shortLink);
|
| | | data.put("inviteCode", inviteCode);
|
| | |
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | |
|
| | | // 更新分享次数
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | |
| | | dynamicInfoService.updateShareCount(dynamicInfo);
|
| | | }
|
| | | });
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享记录失败"));
|
| | | try {
|