| | |
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.service.inter.user.*; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.CSJCPSApiUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.DYUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.vo.DYConvertResult; |
| | | import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail; |
| | | import kafka.utils.Json; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; |
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService; |
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; |
| | |
| | | @Controller |
| | | @RequestMapping("api/v2/share") |
| | | public class ShareControllerV2 { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(ShareControllerV2.class); |
| | | |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Resource |
| | | private UserFunctionsLimitService userFunctionsLimitService; |
| | | |
| | | private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode, |
| | | BigDecimal fanliMoney) { |
| | |
| | | return; |
| | | } |
| | | |
| | | if (userFunctionsLimitService.isLimit(uid, SystemFunction.share, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | |
| | | // 淘宝 |
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | createTaoBaoShare(acceptData, uid, Long.parseLong(goodsId), totalNum, source, needGoods, request, out); |
| | | createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | // 拼多多 |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDShare(acceptData, uid, Long.parseLong(goodsId), source, needGoods, out); |
| | | createPDDShare(acceptData, uid, goodsId, source, needGoods, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | // 抖音 |
| | | if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | try { |
| | | createDYShare(acceptData, uid,Long.parseLong( goodsId), source, needGoods, out); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("转链失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | } |
| | | |
| | | public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) { |
| | | String tempToken = ""; |
| | | String[] sts = token.split(" "); |
| | | if (sts.length > 1) { |
| | | for (int i = 0; i < sts.length - 1; i++) { |
| | | tempToken += sts[i] + " "; |
| | | } |
| | | } else { |
| | | tempToken = token; |
| | | } |
| | | tempToken = tempToken.trim(); |
| | | |
| | | try { |
| | | tempToken = URLEncoder.encode(tempToken, "UTF-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String commentText = template.replace("[原价]", goods.getZkPrice().toString()); |
| | | commentText = commentText.replace("[淘口令]", token); |
| | | commentText = commentText.replace("[淘口令]", tempToken); |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source, |
| | | public void createTaoBaoShare(AcceptData acceptData, Long uid, String goodsId, Integer totalNum, String source, |
| | | Boolean needGoods, HttpServletRequest request, PrintWriter out) { |
| | | if (needGoods == null) |
| | | needGoods = false; |
| | |
| | | createTaoLijin(uid, goodsId, totalNum, relationId, acceptData, request, out); |
| | | return; |
| | | } else {// 普通分享创建 |
| | | if("猜你喜欢".equalsIgnoreCase(source)){ |
| | | out.print(JsonUtil.loadFalseResult(4, "暂不支持分享")); |
| | | return; |
| | | } |
| | | createCommonTaoBaoShare(acceptData.getPlatform(), acceptData.getVersion(), goodsId, inviteCode, uid, |
| | | needGoods, relationId, acceptData, out); |
| | | return; |
| | |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, AcceptData acceptData, HttpServletRequest request, |
| | | public void createTaoLijin(Long uid, String auctionId, int totalNum, String relationId, AcceptData acceptData, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | TaoBaoGoodsBrief goods = null; |
| | |
| | | } |
| | | } |
| | | |
| | | public void createCommonTaoBaoShare(String platform, String version, Long goodsId, String inviteCode, Long uid, |
| | | public void createCommonTaoBaoShare(String platform, String version, String goodsId, String inviteCode, Long uid, |
| | | boolean needGoods, String relationId, AcceptData acceptData, PrintWriter out) { |
| | | |
| | | SystemEnum system = SystemInfoUtil.getSystem(acceptData); |
| | |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share); |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, uid + ""); |
| | | String jumpLink = null; |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, uid + ""); |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | } |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | |
| | | BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate); |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId + "", |
| | | Constant.SOURCE_TYPE_JD, false); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId); |
| | | history.setGoodsId(goodsId + ""); |
| | | history.setPostPicture(goods.getPicUrl()); |
| | | history.setShareImg(jumpLinkNew); |
| | | |
| | |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, |
| | | public void createPDDShare(AcceptData acceptData, Long uid, String goodsId, String source, boolean needGoods, |
| | | PrintWriter out) { |
| | | |
| | | //查询当前用户是否授权 |
| | |
| | | // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | // goodsId + ""); |
| | | |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pid, uid + ""); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pid, pddAuthService.getFanliCustomParams(uid) + ""); |
| | | |
| | | SystemEnum system = SystemInfoUtil.getSystem(acceptData); |
| | | |
| | |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId + "", |
| | | Constant.SOURCE_TYPE_PDD, false); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId); |
| | | history.setGoodsId(goodsId + ""); |
| | | history.setPostPicture(goods.getGoodsImageUrl()); |
| | | history.setShareImg(jumpLink); |
| | | List<String> imgList = null; |
| | |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId + "", |
| | | Constant.SOURCE_TYPE_VIP, false); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId); |
| | | history.setGoodsId(goodsId + ""); |
| | | history.setPostPicture(goods.getGoodsThumbUrl()); |
| | | history.setShareImg(jumpLink.getUrl()); |
| | | List<String> imgList = goods.getGoodsDetailPictures(); |
| | |
| | | |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, |
| | | Long.parseLong(sts[1]), Constant.SOURCE_TYPE_SUNING, false); |
| | | Long.parseLong(sts[1]) + "", Constant.SOURCE_TYPE_SUNING, false); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(Long.parseLong(sts[1])); |
| | | history.setGoodsId(Long.parseLong(sts[1]) + ""); |
| | | if (goods.getCommodityInfo().getPictureUrl() != null |
| | | && goods.getCommodityInfo().getPictureUrl().size() > 0) |
| | | history.setPostPicture(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl()); |
| | |
| | | if (pictureList != null) { |
| | | for (SuningGoodsImg gi : pictureList) |
| | | imgList.add(gi.getPicUrl()); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 抖音分享 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param goodsId |
| | | * @param source |
| | | * @param needGoods |
| | | * @param out void 返回类型 |
| | | * @throws |
| | | * @Title: createSuningShare |
| | | * @Description: |
| | | */ |
| | | public void createDYShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, |
| | | PrintWriter out) throws Exception { |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(goodsId); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | SystemEnum system = SystemInfoUtil.getSystem(acceptData); |
| | | |
| | | |
| | | DYConvertResult convertResult = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(), DYUtil.createShareExtraInfo(uid), ""); |
| | | |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | shareInfo.setClickUrl(convertResult.getZlink()); |
| | | shareInfo.setWxErCode(convertResult.getZlink()); |
| | | shareInfo.setCommentTexts(new ArrayList<>()); |
| | | shareInfo.setRule(configService.getValue(ConfigKeyEnum.shareRuleLinkDY.getKey(), system)); |
| | | shareInfo.setPictUrl(goods.getCover()); |
| | | if (needGoods) { |
| | | shareInfo |
| | | .setGoodsInfo(GoodsDetailVOFactory.convertDYGoods(goods, |
| | | new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())))); |
| | | } |
| | | |
| | | String template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid); |
| | | String shareText = shareGoodsTextTemplateService.createCommonShareTextDY(template, goods, convertResult.getDeeplink()); |
| | | shareInfo.setShareText(shareText); |
| | | |
| | | String descText = shareText.replace(goods.getTitle(), "").trim(); |
| | | if (descText.startsWith("\\r\\n")) { |
| | | descText = descText.substring(0); |
| | | } |
| | | shareInfo.setDescText(descText); |
| | | |
| | | // |
| | | String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(), |
| | | Integer.parseInt(acceptData.getVersion()), system); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | |
| | | shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs207.getKey(), system); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyDY.getKey(), system)); |
| | | |
| | | // 添加分享记录 |
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem()); |
| | | BigDecimal shareMoney = DYUtil.getGoodsFanLiMoney(goods, shareRate); |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, |
| | | goodsId + "", Constant.SOURCE_TYPE_DY, false); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | |
| | | |
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | String qtemplate = configService.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(), system); |
| | | recommendText = qtemplate.replace("[商品标题]", goods.getTitle()); |
| | | |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | |
| | | |
| | | String quickCommentText = configService.getValue(ConfigKeyEnum.quickShareDYCommentText.getKey(), system); |
| | | |
| | | commentText = quickCommentText.replace("[原价]", BigDecimalUtil.getWithNoZera(DYUtil.getPrice(goods.getPrice())).toString()); |
| | | //commentText = commentText.replace("[链接]", jumpLink); |
| | | commentText = commentText.replace("[口令]", convertResult.getPassword()); |
| | | |
| | | |
| | | String salesCountMidea = ""; |
| | | Integer count = goods.getSales(); |
| | | if (count < 10000) { |
| | | salesCountMidea = count + ""; |
| | | } else { |
| | | double sales = count; |
| | | salesCountMidea = String.format("%.1f", sales / 10000); |
| | | salesCountMidea = salesCountMidea + "万"; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(salesCountMidea) || salesCountMidea.equals("0")) { |
| | | recommendText = recommendText.replace("销量:[销量]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[销量]", salesCountMidea.replace("万", "w")); |
| | | } |
| | | |
| | | commentText = commentText.replace("领券抢购", "抢购").replace("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, |
| | | DYUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | | |
| | | // 异步操作 |
| | | 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(Constant.SOURCE_TYPE_DY); |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId + ""); |
| | | history.setPostPicture(goods.getCover()); |
| | | history.setShareImg(convertResult.getQrCode()); |
| | | List<String> imgList = new ArrayList<>(); |
| | | if (goods.getImgs() != null) { |
| | | for (String gi : goods.getImgs()) |
| | | imgList.add(gi); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | createTaoBaoViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), tljId, hasCoupon, out); |
| | | createTaoBaoViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, tljId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); |
| | | createPDDViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | createSuNingViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | createDYViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | } |
| | |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private void createTaoBaoViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Long tljId, |
| | | private void createTaoBaoViewText(SystemEnum system, Integer goodsType, Long uid, String template, String goodsId, Long tljId, |
| | | Boolean hasCoupon, PrintWriter out) { |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null) |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), |
| | | uid + ""); |
| | | String shortLink = null; |
| | | try { |
| | | shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), |
| | | uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | |
| | | String content = shareGoodsTextTemplateService.createContentJD(template, goods, shortLink, hasCoupon); |
| | | JSONObject data = new JSONObject(); |
| | |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private void createPDDViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, |
| | | private void createPDDViewText(SystemEnum system, Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | private void createDYViewText(SystemEnum system, Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(goodsId)); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(4, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(template)) { |
| | | template = getShareTemplate(goodsType, uid, hasCoupon, null); |
| | | } |
| | | |
| | | // 校验券模板是否正确 |
| | | try { |
| | | shareGoodsTextTemplateService.verifyRightDY(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | DYConvertResult convertResult = null; |
| | | try { |
| | | convertResult = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(), DYUtil.createShareExtraInfo(uid),""); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品转链失败")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | // 生成普通分享内容 |
| | | String content = shareGoodsTextTemplateService.createCommonShareTextDY(template, goods, convertResult.getPassword()); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("content", content); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取分享模板 |
| | | * |
| | |
| | | template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid); |
| | | }else if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | template = shareGoodsTextTemplateService.getTextTemplateByDY(uid); |
| | | } |
| | | return template; |
| | | } |
| | |
| | | out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesVIP.getKey(), system))); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesSuNing.getKey(), system))); |
| | | }else if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesDY.getKey(), system))); |
| | | } |
| | | } |
| | | |
| | |
| | | shareGoodsTextTemplateService.saveTemplateVIP(uid, template); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | shareGoodsTextTemplateService.saveTemplateSuNing(uid, template); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | shareGoodsTextTemplateService.saveTemplateDY(uid, template); |
| | | } |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | |
| | | shareGoodsTextTemplateService.resetCommonTemplateVIP(uid); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | shareGoodsTextTemplateService.resetCommonTemplateSuNing(uid); |
| | | }else if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | shareGoodsTextTemplateService.resetCommonTemplateDY(uid); |
| | | } |
| | | |
| | | if (goodsId != null) { |
| | |
| | | |
| | | // API网络接口验证是否在售 |
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null; |
| | | List<Long> listGid = new ArrayList<Long>(); |
| | | List<String> listGid = new ArrayList<>(); |
| | | for (UserShareGoodsGroup goodsGroup : list) { |
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods(); |
| | | Integer goodsType = commonGoods.getGoodsType(); |
| | |
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null |
| | | && goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | int state = 1; // 默认停售 |
| | | Long goodsId = commonGoods.getGoodsId(); |
| | | String goodsId = commonGoods.getGoodsId(); |
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) { |
| | | Long auctionId = taoKeGoods.getAuctionId(); |
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) { |
| | | String auctionId = taoKeGoods.getAuctionId(); |
| | | if (TaoBaoUtil.isEqual(goodsId, auctionId)) { |
| | | state = 0; // 在售 |
| | | break; |
| | | } |
| | |
| | | dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney()); |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO); |
| | | detailVO.setCreatetime(null); |
| | | detailVO.setId(commonGoods.getId()); |
| | | dataObject.put("goods", gson.toJson(detailVO)); |
| | | array.add(dataObject); |
| | |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(Long.parseLong(goodsId)); |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId)); |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | goods = null; |
| | | } |
| | |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); |
| | | } |
| | |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO); |
| | | } |
| | | }else if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(goodsId)); |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertDYGoods(goods, paramsDTO); |
| | | } |
| | | } |
| | | |
| | | if (goodsDetail == null) { |