| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | @RequestMapping("api/v1/share") |
| | | public class ShareController { |
| | | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | |
| | | @Resource |
| | | private TaoBaoLinkManager taoBaoLinkManager; |
| | | @Resource |
| | | private TaoBaoLinkManager taoBaoLinkManager; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private MonitorService monitorService; |
| | | @Resource |
| | | private MonitorService monitorService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsRecordService userShareGoodsRecordService; |
| | | @Resource |
| | | private UserShareGoodsRecordService userShareGoodsRecordService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsGroupService userShareGoodsGroupService; |
| | | @Resource |
| | | private UserShareGoodsGroupService userShareGoodsGroupService; |
| | | |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService; |
| | | @Resource |
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService; |
| | | |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | |
| | | @Resource |
| | | private DynamicInfoService dynamicInfoService; |
| | | @Resource |
| | | private DynamicInfoService dynamicInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private SpreadUserImgService spreadUserImgService; |
| | | @Resource |
| | | private SpreadUserImgService spreadUserImgService; |
| | | |
| | | @Resource |
| | | private BusinessEmergent110Service businessEmergent110Service; |
| | | @Resource |
| | | private BusinessEmergent110Service businessEmergent110Service; |
| | | |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | |
| | | // 获取商品分享链接 |
| | | @RequestMapping(value = "getGoodsShareUrl") |
| | | public void getGoodsShareUrl(AcceptData acceptData, long id, PrintWriter out) { |
| | | out.print(JsonUtil |
| | | .loadTrueResult(String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()))); |
| | | } |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | /** |
| | | * 获取淘宝的分享链接 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * -用户ID |
| | | * @param auctionId-商品ID |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "gettaobaosharelink") |
| | | public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, String source, Integer totalNum, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | // 获取商品分享链接 |
| | | @RequestMapping(value = "getGoodsShareUrl") |
| | | public void getGoodsShareUrl(AcceptData acceptData, long id, PrintWriter out) { |
| | | out.print(JsonUtil |
| | | .loadTrueResult(String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()))); |
| | | } |
| | | |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空")); |
| | | return; |
| | | } |
| | | /** |
| | | * 获取淘宝的分享链接 |
| | | * |
| | | * @param acceptData |
| | | * @param uid -用户ID |
| | | * @param auctionId-商品ID |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "gettaobaosharelink") |
| | | public void getTaobaoShareLink(AcceptData acceptData, Long uid, String auctionId, String source, Integer totalNum, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | return; |
| | | } |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (auctionId == null || auctionId <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | return; |
| | | } |
| | | |
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); |
| | | String relationId = null; |
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null |
| | | && extraInfo.getRelationValid() == true) |
| | | relationId = extraInfo.getRelationId(); |
| | | if (StringUtil.isNullOrEmpty( auctionId)) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(relationId)) { |
| | | out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号")); |
| | | return; |
| | | } |
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); |
| | | String relationId = null; |
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null |
| | | && extraInfo.getRelationValid() == true) |
| | | relationId = extraInfo.getRelationId(); |
| | | |
| | | if (source != null && "taolijin".equals(source)) { |
| | | createTaoLijin(uid, auctionId, totalNum, relationId,acceptData.getSystem(), request, out); |
| | | return; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(relationId)) { |
| | | out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,null); |
| | | if (source != null && "taolijin".equals(source)) { |
| | | createTaoLijin(uid, auctionId, totalNum, relationId, acceptData.getSystem(), request, out); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | auctionId + ""); |
| | | try { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(acceptData.getSystem(), uid, auctionId, relationId, null); |
| | | |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | auctionId + ""); |
| | | |
| | | data.put("clickUrl", url); |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("rule", configService.getValue(ConfigKeyEnum.shareSingleGoodsRule.getKey(),acceptData.getSystem())); |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | |
| | | String shareText = ""; |
| | | // 无券 |
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO |
| | | : TaoBaoConstant.SHARE_PRICE_TM; |
| | | data.put("clickUrl", url); |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("rule", configService.getValue(ConfigKeyEnum.shareSingleGoodsRule.getKey(), acceptData.getSystem())); |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); |
| | | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),acceptData.getSystem()); |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); |
| | | } else// 有券 |
| | | { |
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(),acceptData.getSystem()); |
| | | String shareText = ""; |
| | | // 无券 |
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO |
| | | : TaoBaoConstant.SHARE_PRICE_TM; |
| | | |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()) |
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") |
| | | .replace("{优惠券面额}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) |
| | | .replace("{优惠券价}", TaoBaoUtil.getCouponPrice(taoBaoLink.getGoods()) + ""); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(), acceptData.getSystem()); |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); |
| | | } else// 有券 |
| | | { |
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(), acceptData.getSystem()); |
| | | |
| | | shareText = shareText.replace("{店铺类型}", shopType) |
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) |
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("shareText", shareText); |
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); |
| | | if (descText.startsWith("\\r\\n")) |
| | | descText = descText.substring(0); |
| | | data.put("descText", descText); |
| | | // |
| | | String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),acceptData.getSystem()); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | int p = (int) (array.size() * Math.random()); |
| | | if (p < array.size()) |
| | | data.put("notifyPicture", array.optString(p)); |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem())); |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()) |
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") |
| | | .replace("{优惠券面额}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) |
| | | .replace("{优惠券价}", TaoBaoUtil.getCouponPrice(taoBaoLink.getGoods()) + ""); |
| | | } |
| | | |
| | | // 添加分享记录 |
| | | BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem()); |
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); |
| | | shareText = shareText.replace("{店铺类型}", shopType) |
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) |
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("shareText", shareText); |
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); |
| | | if (descText.startsWith("\\r\\n")) |
| | | descText = descText.substring(0); |
| | | data.put("descText", descText); |
| | | // |
| | | String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getSystem()); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | int p = (int) (array.size() * Math.random()); |
| | | if (p < array.size()) |
| | | data.put("notifyPicture", array.optString(p)); |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(), acceptData.getSystem())); |
| | | |
| | | data.put("shareMoney", "¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, |
| | | Constant.SOURCE_TYPE_TAOBAO, false); |
| | | data.put("shareId", shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | // 添加分享记录 |
| | | BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem()); |
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); |
| | | |
| | | final TaoBaoLink taobaoLink = taoBaoLink; |
| | | // 异步操作 |
| | | 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(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); |
| | | history.setLink(taobaoLink.getClickUrl()); |
| | | history.setQuanLink(taobaoLink.getCouponLink()); |
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId()); |
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl()); |
| | | data.put("shareMoney", "¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, |
| | | Constant.SOURCE_TYPE_TAOBAO, false); |
| | | data.put("shareId", shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | List<String> imgList = taobaoLink.getGoods().getImgList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (TaoBaoConvertLinkException 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 + ""),acceptData.getSystem()); |
| | | } |
| | | } |
| | | final TaoBaoLink taobaoLink = taoBaoLink; |
| | | // 异步操作 |
| | | 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(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); |
| | | history.setLink(taobaoLink.getClickUrl()); |
| | | history.setQuanLink(taobaoLink.getCouponLink()); |
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId()); |
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl()); |
| | | |
| | | /** |
| | | * 淘礼金创建分享 |
| | | * |
| | | * @param uid |
| | | * @param auctionId |
| | | * @param totalNum |
| | | * @param relationId |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, SystemEnum system, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForShare(uid, auctionId, relationId,null); |
| | | List<String> imgList = taobaoLink.getGoods().getImgList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (TaoBaoConvertLinkException 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 + ""), acceptData.getSystem()); |
| | | } |
| | | } |
| | | |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | /** |
| | | * 淘礼金创建分享 |
| | | * |
| | | * @param uid |
| | | * @param auctionId |
| | | * @param totalNum |
| | | * @param relationId |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createTaoLijin(Long uid, String auctionId, int totalNum, String relationId, SystemEnum system, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForShare(system, uid, auctionId, relationId, null); |
| | | |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘礼金不足")); |
| | | return; |
| | | } |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", null); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("spreadMoney", " ¥" + spreadMoney.toString()); |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘礼金不足")); |
| | | return; |
| | | } |
| | | |
| | | String taoLiJinLink = null; |
| | | Long tljId = null; |
| | | try { |
| | | UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods); |
| | | tljId = record.getId(); |
| | | taoLiJinLink = record.getSendUrl(); |
| | | data.put("tljId", tljId); |
| | | data.put("surplusMoney", record.getSurplusMoney()); |
| | | } catch (UserTaoLiJinRecordException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | return; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("spreadMoney", " ¥" + spreadMoney.toString()); |
| | | |
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(system), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY)); |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | data.put("clickUrl", url); |
| | | String taoLiJinLink = null; |
| | | Long tljId = null; |
| | | try { |
| | | UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods); |
| | | tljId = record.getId(); |
| | | taoLiJinLink = record.getSendUrl(); |
| | | data.put("tljId", tljId); |
| | | data.put("surplusMoney", record.getSurplusMoney()); |
| | | } catch (UserTaoLiJinRecordException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | // 创建淘口令 |
| | | if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功 |
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink); |
| | | if (!StringUtil.isNullOrEmpty(quanToken)) { |
| | | taoBaoLink.setTaoToken(quanToken); |
| | | } |
| | | } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) { |
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), |
| | | taoBaoLink.getClickUrl()); |
| | | if (!StringUtil.isNullOrEmpty(quanToken)) { |
| | | taoBaoLink.setTaoToken(quanToken); |
| | | } |
| | | } |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(system), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY)); |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | data.put("clickUrl", url); |
| | | |
| | | data.put("rule", |
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); |
| | | // 创建淘口令 |
| | | if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功 |
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink); |
| | | if (!StringUtil.isNullOrEmpty(quanToken)) { |
| | | taoBaoLink.setTaoToken(quanToken); |
| | | } |
| | | } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) { |
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), |
| | | taoBaoLink.getClickUrl()); |
| | | if (!StringUtil.isNullOrEmpty(quanToken)) { |
| | | taoBaoLink.setTaoToken(quanToken); |
| | | } |
| | | } |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | |
| | | // 无券 |
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO |
| | | : TaoBaoConstant.SHARE_PRICE_TM; |
| | | String shareText = ""; |
| | | data.put("rule", |
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); |
| | | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system); |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); |
| | | } else// 有券 |
| | | { |
| | | String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); |
| | | // 无券 |
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO |
| | | : TaoBaoConstant.SHARE_PRICE_TM; |
| | | String shareText = ""; |
| | | |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()) |
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") |
| | | .replace("{优惠券面额}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) |
| | | .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString()) |
| | | .replace("{优惠券价}", TaoBaoUtil.getCouponPrice(taoBaoLink.getGoods()) + ""); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(), system); |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); |
| | | } else// 有券 |
| | | { |
| | | String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); |
| | | |
| | | shareText = shareText.replace("{店铺类型}", shopType) |
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) |
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("shareText", shareText); |
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); |
| | | if (descText.startsWith("\\r\\n")) |
| | | descText = descText.substring(0); |
| | | data.put("descText", descText); |
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()) |
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") |
| | | .replace("{优惠券面额}", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) |
| | | .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString()) |
| | | .replace("{优惠券价}", TaoBaoUtil.getCouponPrice(taoBaoLink.getGoods()) + ""); |
| | | } |
| | | |
| | | String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),system); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | int p = (int) (array.size() * Math.random()); |
| | | if (p < array.size()) |
| | | data.put("notifyPicture", array.optString(p)); |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system)); |
| | | shareText = shareText.replace("{店铺类型}", shopType) |
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) |
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("shareText", shareText); |
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); |
| | | if (descText.startsWith("\\r\\n")) |
| | | descText = descText.substring(0); |
| | | data.put("descText", descText); |
| | | |
| | | // 添加分享记录 |
| | | BigDecimal rate = hongBaoManageService.getShareRate(system); |
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); |
| | | String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), system); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | int p = (int) (array.size() * Math.random()); |
| | | if (p < array.size()) |
| | | data.put("notifyPicture", array.optString(p)); |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(), system)); |
| | | |
| | | data.put("shareMoney", "¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | data.put("shareId", shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | // 添加分享记录 |
| | | BigDecimal rate = hongBaoManageService.getShareRate(system); |
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); |
| | | |
| | | final TaoBaoLink taobaoLink = taoBaoLink; |
| | | // 异步操作 |
| | | 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(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); |
| | | history.setLink(taobaoLink.getClickUrl()); |
| | | history.setQuanLink(taobaoLink.getCouponLink()); |
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId()); |
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl()); |
| | | data.put("shareMoney", "¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | data.put("shareId", shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | List<String> imgList = taobaoLink.getGoods().getImgList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (TaoBaoConvertLinkException 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 + ""),system); |
| | | } |
| | | } |
| | | final TaoBaoLink taobaoLink = taoBaoLink; |
| | | // 异步操作 |
| | | 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(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); |
| | | history.setLink(taobaoLink.getClickUrl()); |
| | | history.setQuanLink(taobaoLink.getCouponLink()); |
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId()); |
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl()); |
| | | |
| | | /** |
| | | * 分享记录统计列表 |
| | | * |
| | | * @param acceptData |
| | | * @param page |
| | | * 初始1 |
| | | * @param uid |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getlistrecord", method = RequestMethod.POST) |
| | | public void getListRecord(AcceptData acceptData, Integer page, Long uid, String source, PrintWriter out) { |
| | | List<String> imgList = taobaoLink.getGoods().getImgList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (TaoBaoConvertLinkException 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 + ""), system); |
| | | } |
| | | } |
| | | |
| | | if (page == null || page < 1) { |
| | | out.print(JsonUtil.loadFalseResult("页码不正确")); |
| | | } |
| | | /** |
| | | * 分享记录统计列表 |
| | | * |
| | | * @param acceptData |
| | | * @param page 初始1 |
| | | * @param uid |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getlistrecord", method = RequestMethod.POST) |
| | | public void getListRecord(AcceptData acceptData, Integer page, Long uid, String source, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | } |
| | | if (page == null || page < 1) { |
| | | out.print(JsonUtil.loadFalseResult("页码不正确")); |
| | | } |
| | | |
| | | if ("all".equals(source)) { |
| | | source = null;// 查询全部 |
| | | } |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | } |
| | | |
| | | try { |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | if ("all".equals(source)) { |
| | | source = null;// 查询全部 |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>(); |
| | | try { |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | |
| | | long count = userShareGoodsRecordService.countQueryByUid(uid, source); |
| | | if (count > 0) { |
| | | list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>(); |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() { |
| | | @Override |
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | // 保留2位小数 |
| | | value = value.setScale(2); |
| | | return new JsonPrimitive(value.toString()); |
| | | } |
| | | } |
| | | }); |
| | | Gson gson = gsonBuilder.create(); |
| | | long count = userShareGoodsRecordService.countQueryByUid(uid, source); |
| | | if (count > 0) { |
| | | list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source); |
| | | } |
| | | |
| | | data.put("count", count); |
| | | data.put("result_list", gson.toJson(list)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() { |
| | | @Override |
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | // 保留2位小数 |
| | | value = value.setScale(2); |
| | | return new JsonPrimitive(value.toString()); |
| | | } |
| | | } |
| | | }); |
| | | Gson gson = gsonBuilder.create(); |
| | | |
| | | /** |
| | | * 获取分享商品 |
| | | * |
| | | * @param acceptData |
| | | * @param recordId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getrecordgoods", method = RequestMethod.POST) |
| | | public void getRecordGoods(AcceptData acceptData, Long recordId, PrintWriter out) { |
| | | data.put("count", count); |
| | | data.put("result_list", gson.toJson(list)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | if (recordId == null) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | } |
| | | /** |
| | | * 获取分享商品 |
| | | * |
| | | * @param acceptData |
| | | * @param recordId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getrecordgoods", method = RequestMethod.POST) |
| | | public void getRecordGoods(AcceptData acceptData, Long recordId, PrintWriter out) { |
| | | |
| | | try { |
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId,acceptData.getSystem()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if (recordId == null) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | } |
| | | |
| | | /** |
| | | * 获取分享商品单个统计信息 |
| | | * |
| | | * @param acceptData |
| | | * @param groupId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsdata", method = RequestMethod.POST) |
| | | public void getGoodsData(AcceptData acceptData, Long groupId, PrintWriter out) { |
| | | try { |
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId, acceptData.getSystem()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | if (groupId == null) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | } |
| | | /** |
| | | * 获取分享商品单个统计信息 |
| | | * |
| | | * @param acceptData |
| | | * @param groupId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getgoodsdata", method = RequestMethod.POST) |
| | | public void getGoodsData(AcceptData acceptData, Long groupId, PrintWriter out) { |
| | | |
| | | try { |
| | | UserShareGoodsGroup userShareGoodsGroup = userShareGoodsGroupService.selectByPrimaryKey(groupId); |
| | | if (userShareGoodsGroup != null) { |
| | | userShareGoodsGroup.setBrowseTime(null); |
| | | userShareGoodsGroup.setCreateTime(null); |
| | | userShareGoodsGroup.setUpdateTime(null); |
| | | userShareGoodsGroup.setRecordId(null); |
| | | } |
| | | if (groupId == null) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goodsData", userShareGoodsGroup); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | try { |
| | | UserShareGoodsGroup userShareGoodsGroup = userShareGoodsGroupService.selectByPrimaryKey(groupId); |
| | | if (userShareGoodsGroup != null) { |
| | | userShareGoodsGroup.setBrowseTime(null); |
| | | userShareGoodsGroup.setCreateTime(null); |
| | | userShareGoodsGroup.setUpdateTime(null); |
| | | userShareGoodsGroup.setRecordId(null); |
| | | } |
| | | |
| | | /** |
| | | * 商品详情分享 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * 用户id |
| | | * @param auctionId |
| | | * 商品id |
| | | * @param type |
| | | * 图片分享类型 单图single 多图many |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "sharedetail", method = RequestMethod.POST) |
| | | public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) { |
| | | try { |
| | | userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO); |
| | | out.print(JsonUtil.loadTrueResult("分享成功")); |
| | | } catch (UserShareGoodsRecordException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("goodsData", userShareGoodsGroup); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("加载失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新分享记录 |
| | | * |
| | | * @param acceptData |
| | | * @param shareId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "updaterecord", method = RequestMethod.POST) |
| | | public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(shareId)) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | return; |
| | | } |
| | | /** |
| | | * 商品详情分享 |
| | | * |
| | | * @param acceptData |
| | | * @param uid 用户id |
| | | * @param auctionId 商品id |
| | | * @param type 图片分享类型 单图single 多图many |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "sharedetail", method = RequestMethod.POST) |
| | | public void shareDetail(AcceptData acceptData, Long uid, String auctionId, String type, PrintWriter out) { |
| | | try { |
| | | userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO); |
| | | 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(acceptData, shareId); |
| | | } catch (UserShareGoodsRecordException eu) { |
| | | /** |
| | | * 更新分享记录 |
| | | * |
| | | * @param acceptData |
| | | * @param shareId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "updaterecord", method = RequestMethod.POST) |
| | | public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(shareId)) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | return; |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | out.print(JsonUtil.loadTrueResult("分享成功")); |
| | | } |
| | | // 更新分享生效 |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | userShareGoodsRecordService.takeEffectShareRecord(acceptData, shareId); |
| | | } catch (UserShareGoodsRecordException eu) { |
| | | |
| | | /** |
| | | * 预览分享模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param template |
| | | * @param goodsId |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST) |
| | | public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId, Long tljId, |
| | | Boolean hasCoupon, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | out.print(JsonUtil.loadTrueResult("分享成功")); |
| | | } |
| | | |
| | | /** |
| | | * 预览分享模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param template |
| | | * @param goodsId |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST) |
| | | public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, String goodsId, Long tljId, |
| | | Boolean hasCoupon, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (goodsId == null) { |
| | | out.print(JsonUtil.loadFalseResult(3, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | if (goodsId == null) { |
| | | out.print(JsonUtil.loadFalseResult(3, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null) |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | goods = null; |
| | | } |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null) |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | goods = null; |
| | | } |
| | | |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(4, "商品已下架")); |
| | | return; |
| | | } |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(4, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = getShareTemplate(uid, hasCoupon, tljId,acceptData.getSystem()); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = getShareTemplate(uid, hasCoupon, tljId, acceptData.getSystem()); |
| | | |
| | | // 校验券模板是否正确 |
| | | if (hasCoupon) { |
| | | // 有券商品 |
| | | if (tljId != null) { |
| | | try { |
| | | shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } else { |
| | | try { |
| | | shareGoodsTextTemplateService.isCouponTemplateRight(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | } else { |
| | | // 普通商品 |
| | | try { |
| | | shareGoodsTextTemplateService.isCommonTemplateRight(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | // 校验券模板是否正确 |
| | | if (hasCoupon) { |
| | | // 有券商品 |
| | | if (tljId != null) { |
| | | try { |
| | | shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } else { |
| | | try { |
| | | shareGoodsTextTemplateService.isCouponTemplateRight(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | } else { |
| | | // 普通商品 |
| | | try { |
| | | shareGoodsTextTemplateService.isCommonTemplateRight(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | String url = null; |
| | | if (tljId != null) { |
| | | UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId); |
| | | if (userTaoLiJinRecord == null) { |
| | | out.print(JsonUtil.loadFalseResult(5, "淘礼金领取链接不存在")); |
| | | return; |
| | | } |
| | | url = userTaoLiJinRecord.getSendUrl(); |
| | | } else { |
| | | url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | goods.getAuctionId() + ""); |
| | | } |
| | | String url = null; |
| | | if (tljId != null) { |
| | | UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId); |
| | | if (userTaoLiJinRecord == null) { |
| | | out.print(JsonUtil.loadFalseResult(5, "淘礼金领取链接不存在")); |
| | | return; |
| | | } |
| | | url = userTaoLiJinRecord.getSendUrl(); |
| | | } else { |
| | | url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | goods.getAuctionId() + ""); |
| | | } |
| | | |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | |
| | | // 查询是否有分享 |
| | | UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId()); |
| | | String token = ""; |
| | | if (userShareHistory != null) { |
| | | token = userShareHistory.getTkCode(); |
| | | } |
| | | // 查询是否有分享 |
| | | UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId()); |
| | | String token = ""; |
| | | if (userShareHistory != null) { |
| | | token = userShareHistory.getTkCode(); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); |
| | | TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app,null,null); |
| | | if (goodsLink != null) |
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), |
| | | StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl() |
| | | : goodsLink.getCouponLink()); |
| | | } |
| | | String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink, |
| | | hasCoupon, tljId); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("content", content); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | app.setPid(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.share)); |
| | | app.setAdzoneId(app.getPid().split("_")[3]); |
| | | TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCouponV2(goods.getAuctionId(), app, null, null); |
| | | if (goodsLink != null) |
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), |
| | | StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl() |
| | | : goodsLink.getCouponLink()); |
| | | } |
| | | String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink, |
| | | hasCoupon, tljId); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("content", content); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 保存模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param hasCoupon |
| | | * @param template |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST) |
| | | public void saveShareTextTemplate(AcceptData acceptData, Long uid, Long tljId, Boolean hasCoupon, String template, |
| | | PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(template)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "分享模板为空")); |
| | | return; |
| | | } |
| | | // 校验券模板是否正确 |
| | | if (hasCoupon) { |
| | | // 有券商品 |
| | | if (tljId != null) { |
| | | try { |
| | | shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); |
| | | shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } else { |
| | | try { |
| | | shareGoodsTextTemplateService.isCouponTemplateRight(template); |
| | | shareGoodsTextTemplateService.saveCouponTemplate(uid, template); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | } else { |
| | | // 普通商品 |
| | | try { |
| | | shareGoodsTextTemplateService.isCommonTemplateRight(template); |
| | | shareGoodsTextTemplateService.saveCommonTemplate(uid, template); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | /** |
| | | * 保存模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param hasCoupon |
| | | * @param template |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST) |
| | | public void saveShareTextTemplate(AcceptData acceptData, Long uid, Long tljId, Boolean hasCoupon, String template, |
| | | PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(template)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "分享模板为空")); |
| | | return; |
| | | } |
| | | // 校验券模板是否正确 |
| | | if (hasCoupon) { |
| | | // 有券商品 |
| | | if (tljId != null) { |
| | | try { |
| | | shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); |
| | | shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } else { |
| | | try { |
| | | shareGoodsTextTemplateService.isCouponTemplateRight(template); |
| | | shareGoodsTextTemplateService.saveCouponTemplate(uid, template); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | } else { |
| | | // 普通商品 |
| | | try { |
| | | shareGoodsTextTemplateService.isCommonTemplateRight(template); |
| | | shareGoodsTextTemplateService.saveCommonTemplate(uid, template); |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 还原模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param hasCoupon |
| | | * -是否有券 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) |
| | | public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | /** |
| | | * 还原模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param hasCoupon -是否有券 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) |
| | | public void resetShareTextTemplate(AcceptData acceptData, Long uid, String goodsId, Long tljId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (hasCoupon) { |
| | | if (tljId != null) { |
| | | shareGoodsTextTemplateService.resetTaoLijinTemplate(uid); |
| | | } else { |
| | | shareGoodsTextTemplateService.resetCouponTemplate(uid); |
| | | } |
| | | } else { |
| | | shareGoodsTextTemplateService.resetCommonTemplate(uid); |
| | | } |
| | | if (hasCoupon) { |
| | | if (tljId != null) { |
| | | shareGoodsTextTemplateService.resetTaoLijinTemplate(uid); |
| | | } else { |
| | | shareGoodsTextTemplateService.resetCouponTemplate(uid); |
| | | } |
| | | } else { |
| | | shareGoodsTextTemplateService.resetCommonTemplate(uid); |
| | | } |
| | | |
| | | if (goodsId != null) { |
| | | preViewShareTextTemplate(acceptData, uid, null, goodsId, tljId, hasCoupon, out); |
| | | return; |
| | | } |
| | | if (goodsId != null) { |
| | | preViewShareTextTemplate(acceptData, uid, null, goodsId, tljId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } |
| | | |
| | | private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId,SystemEnum system) { |
| | | if (hasCoupon) { |
| | | if (tljId != null) { |
| | | String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); |
| | | return template; |
| | | } else { |
| | | String template = shareGoodsTextTemplateService.geteCouponTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(),system); |
| | | return template; |
| | | } |
| | | private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId, SystemEnum system) { |
| | | if (hasCoupon) { |
| | | if (tljId != null) { |
| | | String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); |
| | | return template; |
| | | } else { |
| | | String template = shareGoodsTextTemplateService.geteCouponTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(), system); |
| | | return template; |
| | | } |
| | | |
| | | } else { |
| | | String template = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system); |
| | | return template; |
| | | } |
| | | } |
| | | } else { |
| | | String template = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(template)) |
| | | template = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(), system); |
| | | return template; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取分享模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST) |
| | | public void getShareTextTemplate(AcceptData acceptData, Long uid, Long tljId, Boolean hasCoupon, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | /** |
| | | * 获取分享模板 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST) |
| | | public void getShareTextTemplate(AcceptData acceptData, Long uid, Long tljId, Boolean hasCoupon, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (hasCoupon == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "是否有券字段为空")); |
| | | return; |
| | | } |
| | | if (hasCoupon == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "是否有券字段为空")); |
| | | return; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("template", getShareTemplate(uid, hasCoupon, tljId,acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("template", getShareTemplate(uid, hasCoupon, tljId, acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 获取分享模板编辑规则 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST) |
| | | public void getShareTextTemplateRules(AcceptData acceptData, Long tljId, PrintWriter out) { |
| | | if (tljId != null) { |
| | | out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date()))); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRules.getKey(),acceptData.getSystem()))); |
| | | } |
| | | } |
| | | /** |
| | | * 获取分享模板编辑规则 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST) |
| | | public void getShareTextTemplateRules(AcceptData acceptData, Long tljId, PrintWriter out) { |
| | | if (tljId != null) { |
| | | out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date()))); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRules.getKey(), acceptData.getSystem()))); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询顶部分类 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "shareDynamic", method = RequestMethod.POST) |
| | | public void shareDynamic(AcceptData acceptData, String id, Long uid, PrintWriter out) { |
| | | try { |
| | | /** |
| | | * 查询顶部分类 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @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 (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult("参数不能为空")); |
| | | return; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult("参数不能为空")); |
| | | return; |
| | | } |
| | | |
| | | DynamicInfo dynamicInfo = dynamicInfoService.getById(id); |
| | | if (dynamicInfo == null) { |
| | | 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(); |
| | | JSONObject data = new JSONObject(); |
| | | // 分类id |
| | | long cid = dynamicInfo.getClassId(); |
| | | |
| | | if (cid == 1 || cid == 2) { // 1 热销单品 2 推荐好货 |
| | | if (cid == 1) { |
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs(); |
| | | if (imgs == null || imgs.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | if (cid == 1 || cid == 2) { // 1 热销单品 2 推荐好货 |
| | | if (cid == 1) { |
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs(); |
| | | if (imgs == null || imgs.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | GoodsPicture goodsPicture = imgs.get(0); |
| | | if (goodsPicture.getGoodState() == 1) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | GoodsPicture goodsPicture = imgs.get(0); |
| | | if (goodsPicture.getGoodState() == 1) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | if (goods.getState() != null && goods.getState() == 1) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | if (goods.getState() != null && goods.getState() == 1) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | if (!goods.isCoupon()) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | if (!goods.isCoupon()) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId()); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | try { |
| | | TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId()); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | out.print(JsonUtil.loadFalseResult("该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | } else { |
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs(); |
| | | if (imgs == null || imgs.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult("所有商品已抢光")); |
| | | return; |
| | | } |
| | | } else { |
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs(); |
| | | if (imgs == null || imgs.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult("所有商品已抢光")); |
| | | return; |
| | | } |
| | | |
| | | int count = 0; |
| | | for (GoodsPicture goodsPicture : imgs) { |
| | | if (goodsPicture.getGoodState() == 1) { |
| | | count++; |
| | | continue; |
| | | } |
| | | int count = 0; |
| | | for (GoodsPicture goodsPicture : imgs) { |
| | | if (goodsPicture.getGoodState() == 1) { |
| | | count++; |
| | | continue; |
| | | } |
| | | |
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); |
| | | if (goods == null) { |
| | | count++; |
| | | continue; |
| | | } |
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); |
| | | if (goods == null) { |
| | | count++; |
| | | continue; |
| | | } |
| | | |
| | | if (goods.getState() != null && goods.getState() == 1) { |
| | | count++; |
| | | continue; |
| | | } |
| | | if (goods.getState() != null && goods.getState() == 1) { |
| | | count++; |
| | | continue; |
| | | } |
| | | |
| | | if (!goods.isCoupon()) { |
| | | count++; |
| | | continue; |
| | | } |
| | | } |
| | | if (!goods.isCoupon()) { |
| | | count++; |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (count >= imgs.size()) { |
| | | out.print(JsonUtil.loadFalseResult("所有商品已抢光")); |
| | | return; |
| | | } |
| | | } |
| | | if (count >= imgs.size()) { |
| | | 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(); |
| | | } |
| | | } |
| | | // 分享文字 |
| | | 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", String.format("我在%s发现了一个很好的商品,快来看看~", |
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); |
| | | if (StringUtil.isNullOrEmpty(title)) { |
| | | title = "给你推荐精选好物优惠券,购物前先领券,别错过优惠哦~"; |
| | | } |
| | | data.put("title", title); |
| | | data.put("content", String.format("我在%s发现了一个很好的商品,快来看看~", |
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))); |
| | | |
| | | // 分享奖金 |
| | | ClientTextStyleVO desc = dynamicInfo.getDesc(); |
| | | String content = desc.getContent(); |
| | | int index = content.indexOf("¥"); |
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString()); |
| | | // 分享奖金 |
| | | ClientTextStyleVO desc = dynamicInfo.getDesc(); |
| | | String content = desc.getContent(); |
| | | int index = content.indexOf("¥"); |
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString()); |
| | | |
| | | // 分享提醒 |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem())); |
| | | // 分享提醒 |
| | | data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(), acceptData.getSystem())); |
| | | |
| | | // 分享提示语 |
| | | String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),acceptData.getSystem()); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | int p = (int) (array.size() * Math.random()); |
| | | if (p < array.size()) { |
| | | data.put("notifyPicture", array.optString(p)); |
| | | } |
| | | // 分享提示语 |
| | | String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getSystem()); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | int p = (int) (array.size() * Math.random()); |
| | | if (p < array.size()) { |
| | | data.put("notifyPicture", array.optString(p)); |
| | | } |
| | | |
| | | // 分享出去的图片 |
| | | String pictUrl = dynamicInfo.getImgs().get(0).getUrl(); |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(pictUrl, 500)); |
| | | // 分享出去的图片 |
| | | String pictUrl = dynamicInfo.getImgs().get(0).getUrl(); |
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(pictUrl, 500)); |
| | | |
| | | // 帮助链接 |
| | | data.put("helpLink", |
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); |
| | | // 帮助链接 |
| | | data.put("helpLink", |
| | | "http://apph5.banliapp.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()); |
| | | 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(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), |
| | | AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + ""); |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | String auctionId = dynamicInfo.getImgs().get(0).getGoods().getAuctionId(); |
| | | // 商品分享链接 |
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | 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("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 = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,null); |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | if (!com.yeshi.fanli.util.VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), |
| | | acceptData.getVersion())) |
| | | data.put("clickUrl", |
| | | ShareControllerV2.getERCodeContentNew( |
| | | configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),acceptData.getSystem()), goods, |
| | | taoBaoLink.getTaoToken())); |
| | | // 淘宝口令 |
| | | 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 = taoBaoLinkManager.getTaoBaoLinkForShare(acceptData.getSystem(), uid, auctionId, relationId, null); |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | if (!com.yeshi.fanli.util.VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), |
| | | acceptData.getVersion())) |
| | | data.put("clickUrl", |
| | | ShareControllerV2.getERCodeContentNew( |
| | | configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(), acceptData.getSystem()), goods, |
| | | taoBaoLink.getTaoToken())); |
| | | |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | // 测试 |
| | | List<String> commentTexts = new ArrayList<>(); |
| | | String commentTextStr = configService.getValue(ConfigKeyEnum.shareSingleGoodsCommentText.getKey(),acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(commentTextStr)) { |
| | | JSONArray arr = JSONArray.fromObject(commentTextStr); |
| | | for (int i = 0; i < arr.size(); i++) { |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | if (arr.optString(i).contains("[邀请码]")) { |
| | | continue; |
| | | } |
| | | } |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) |
| | | commentTexts.add(arr.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK) |
| | | .replace("[淘口令]", data.optString("token"))); |
| | | else |
| | | commentTexts.add(arr.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK) |
| | | .replace("[邀请码]", inviteCode).replace("[淘口令]", data.optString("token"))); |
| | | } |
| | | } |
| | | data.put("commentTexts", commentTexts); |
| | | data.put("wxErCode", |
| | | ShareControllerV2.getERCodeContentNew( |
| | | configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),acceptData.getSystem()), goods, |
| | | taoBaoLink.getTaoToken())); |
| | | } |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | // 测试 |
| | | List<String> commentTexts = new ArrayList<>(); |
| | | String commentTextStr = configService.getValue(ConfigKeyEnum.shareSingleGoodsCommentText.getKey(), acceptData.getSystem()); |
| | | if (!StringUtil.isNullOrEmpty(commentTextStr)) { |
| | | JSONArray arr = JSONArray.fromObject(commentTextStr); |
| | | for (int i = 0; i < arr.size(); i++) { |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | if (arr.optString(i).contains("[邀请码]")) { |
| | | continue; |
| | | } |
| | | } |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) |
| | | commentTexts.add(arr.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK) |
| | | .replace("[淘口令]", data.optString("token"))); |
| | | else |
| | | commentTexts.add(arr.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK) |
| | | .replace("[邀请码]", inviteCode).replace("[淘口令]", data.optString("token"))); |
| | | } |
| | | } |
| | | data.put("commentTexts", commentTexts); |
| | | data.put("wxErCode", |
| | | ShareControllerV2.getERCodeContentNew( |
| | | configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(), acceptData.getSystem()), goods, |
| | | taoBaoLink.getTaoToken())); |
| | | } |
| | | |
| | | } else if (cid == 4) { // 邀请分享 |
| | | } else if (cid == 4) { // 邀请分享 |
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | out.print(JsonUtil.loadFalseResult(9001, "邀请码未激活")); |
| | | return; |
| | | } |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | out.print(JsonUtil.loadFalseResult(9001, "邀请码未激活")); |
| | | return; |
| | | } |
| | | |
| | | Integer showType = dynamicInfo.getShowType(); |
| | | 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("【邀请链接】", Constant.YINGYONGBAO_LINK); |
| | | data.put("title", title); |
| | | Integer showType = dynamicInfo.getShowType(); |
| | | 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("【邀请链接】", Constant.YINGYONGBAO_LINK); |
| | | data.put("title", title); |
| | | |
| | | } else { // 有图分享 |
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs(); |
| | | } else { // 有图分享 |
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs(); |
| | | |
| | | GoodsPicture goodsPicture = imgs.get(0); |
| | | String bgUrl = goodsPicture.getUrlOriginal(); |
| | | GoodsPicture goodsPicture = imgs.get(0); |
| | | String bgUrl = goodsPicture.getUrlOriginal(); |
| | | |
| | | if (StringUtil.isNullOrEmpty(bgUrl)) { |
| | | out.print(JsonUtil.loadFalseResult("图片路径不存在")); |
| | | return; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(bgUrl)) { |
| | | out.print(JsonUtil.loadFalseResult("图片路径不存在")); |
| | | return; |
| | | } |
| | | |
| | | // 用户信息 |
| | | UserInfo userInfo = userInfoService.selectByPKey(uid); |
| | | String portrait = userInfo.getPortrait(); |
| | | // 画邀请图片 |
| | | // 用户信息 |
| | | UserInfo userInfo = userInfoService.selectByPKey(uid); |
| | | String portrait = userInfo.getPortrait(); |
| | | // 画邀请图片 |
| | | |
| | | Long activityId = dynamicInfo.getActivityId(); |
| | | if (activityId != null) { |
| | | Integer pX = goodsPicture.getPx(); |
| | | ; |
| | | Integer pY = goodsPicture.getPy(); |
| | | ; |
| | | Integer size = goodsPicture.getSize(); |
| | | 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); |
| | | 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()); |
| | | data.put("imgLink", imgLink); |
| | | } |
| | | data.put("imgLink", imgLink); |
| | | } else { |
| | | String title = imgs.get(0).getTitleOriginal(); |
| | | 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); |
| | | String valueN = values.getValue(); |
| | | String valueBr = valueN.replace("\n", "<br><br>"); |
| | | data.put("inviteRules", valueBr); |
| | | // 邀请规则 |
| | | 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); |
| | | String valueN = values.getValue(); |
| | | String valueBr = valueN.replace("\n", "<br><br>"); |
| | | data.put("inviteRules", valueBr); |
| | | |
| | | data.put("inviteLink", Constant.YINGYONGBAO_LINK); |
| | | data.put("inviteCode", inviteCode); |
| | | data.put("helpLink", configService.getValue(ConfigKeyEnum.inviteHelpLink.getKey(),acceptData.getSystem())); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | data.put("inviteLink", Constant.YINGYONGBAO_LINK); |
| | | data.put("inviteCode", inviteCode); |
| | | data.put("helpLink", configService.getValue(ConfigKeyEnum.inviteHelpLink.getKey(), acceptData.getSystem())); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | // 更新分享次数 |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Integer shareCount = dynamicInfo.getShareCount(); |
| | | dynamicInfo.setShareCount(shareCount + 1); |
| | | dynamicInfoService.updateShareCount(dynamicInfo); |
| | | } |
| | | }); |
| | | // 更新分享次数 |
| | | 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("分享记录失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("分享记录失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |