| | |
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
|
| | | 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.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | /**
|
| | | * 获取淘宝的分享链接
|
| | | *
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * -用户ID
|
| | | * @param auctionId-商品ID
|
| | | * @param goodsId-商品ID
|
| | | * @param source
|
| | | * @param totalNum
|
| | | * @param goodsType
|
| | | * @param needGoods
|
| | | * -是否需要商品信息
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "createShareInfo")
|
| | | public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum,
|
| | | Integer goodsType, HttpServletRequest request, PrintWriter out) {
|
| | | Integer goodsType, Boolean needGoods, HttpServletRequest request, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (needGoods == null)
|
| | | needGoods = false;
|
| | | try {
|
| | | // 日志记录
|
| | | String info = String.format("type=share&uid=%s&goodsId=%s&source=%s&goodsType=%s", uid, goodsId, source,
|
| | |
| | |
|
| | | // 淘宝
|
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, request, out);
|
| | | createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 京东
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | createJDShare(acceptData, uid, goodsId, source, out);
|
| | | createJDShare(acceptData, uid, goodsId, source, needGoods, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 拼多多
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | createPDDShare(acceptData, uid, goodsId, source, out);
|
| | | createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | private String getERCodeContent(TaoBaoGoodsBrief goods, String token) {
|
| | | public static String getERCodeContent(TaoBaoGoodsBrief goods, String token) {
|
| | | String content = String.format("【%s】%s元", goods.getUserType() == 1 ? "T猫价" : "T宝价",
|
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
|
| | | content += "\n\r";
|
| | |
| | | * @param out
|
| | | */
|
| | | public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | Boolean needGoods, HttpServletRequest request, PrintWriter out) {
|
| | | if (needGoods == null)
|
| | | needGoods = false;
|
| | |
|
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | UserInfoExtra userExtraInfo = userInfoExtraService.getUserInfoExtra(uid);
|
| | | String inviteCode = null;
|
| | | if (userExtraInfo != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userExtraInfo.getInviteCodeVip())) {
|
| | | inviteCode = userExtraInfo.getInviteCodeVip();
|
| | | } else {
|
| | | inviteCode = userExtraInfo.getInviteCode();
|
| | | }
|
| | | }
|
| | | String relationId = null;
|
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
|
| | | && extraInfo.getRelationValid() == true)
|
| | |
| | | try {
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | |
|
| | | // 测试
|
| | |
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
|
| | |
|
| | | if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
|
| | | ConfigParamsDTO dto = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
|
| | | hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
|
| | | GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
|
| | | shareInfo.setGoodsInfo(goodsInfo);
|
| | | }
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | |
| | | shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | shareInfo.setRule(configService.get("share_single_goods_rule"));
|
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String commentTextStr = configService.get("share_single_goods_comment_text");
|
| | | List<String> commentTexts = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(commentTextStr)) {
|
| | | JSONArray array = JSONArray.fromObject(commentTextStr);
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | if (array.optString(i).contains("[邀请码]")) {
|
| | | continue;
|
| | | }
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(inviteCode))
|
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK)
|
| | | .replace("[淘口令]", shareInfo.getToken()));
|
| | | else
|
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK)
|
| | | .replace("[邀请码]", inviteCode).replace("[淘口令]", shareInfo.getToken()));
|
| | | }
|
| | | }
|
| | | shareInfo.setCommentTexts(commentTexts);
|
| | |
|
| | | String shareText = "";
|
| | | // 无券
|
| | |
| | | }
|
| | | shareInfo.setDescText(descText);
|
| | | // 测试
|
| | | shareInfo.setClickUrl(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | | // 2.0.2之前
|
| | | if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | shareInfo.setClickUrl(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | |
|
| | | shareInfo.setWxErCode(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | |
|
| | | // 提示图文内容
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | |
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
|
| | | public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
|
| | | PrintWriter out) {
|
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
|
| | |
| | | // goodsId + "");
|
| | |
|
| | | String couponUrl = null;
|
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
|
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | uid + "");
|
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setClickUrl(jumpLink);
|
| | | shareInfo.setWxErCode(jumpLink);
|
| | | shareInfo.setRule(configService.get("share_rule_link_jd"));
|
| | | shareInfo.setPictUrl(jdGoods.getPicUrl());
|
| | | shareInfo.setCommentTexts(new ArrayList<>());
|
| | |
|
| | | if (needGoods)
|
| | | shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, new ConfigParamsDTO(
|
| | | hongBaoManageService.getFanLiRate(), hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate())));
|
| | |
|
| | | String shareText = "";
|
| | | boolean hasCoupon = false;
|
| | |
| | | * @param source
|
| | | * @param out
|
| | | */
|
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
|
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
|
| | | PrintWriter out) {
|
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
|
| | |
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setClickUrl(jumpLink);
|
| | | shareInfo.setWxErCode(jumpLink);
|
| | | shareInfo.setCommentTexts(new ArrayList<>());
|
| | | shareInfo.setRule(configService.get("share_rule_link_pdd"));
|
| | | shareInfo.setPictUrl(goods.getGoodsImageUrl());
|
| | | if (needGoods) {
|
| | | shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, new ConfigParamsDTO(
|
| | | hongBaoManageService.getFanLiRate(), hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate())));
|
| | | }
|
| | |
|
| | | String template = "";
|
| | | boolean hasCoupon = false;
|
| | |
| | | }
|
| | |
|
| | | String couponUrl = null;
|
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods);
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String shortLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
|
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
|
| | | uid + "");
|
| | |
|
| | | String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
|
| | | hasCoupon);
|
| | |
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|