From 8ce7c720e4e7a604b0ff770349b5556f39d37759 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 13 九月 2021 11:44:38 +0800 Subject: [PATCH] 好省呗应用兼容 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 200 insertions(+), 15 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java index fa8f530..9e367ba 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java @@ -13,15 +13,39 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.annotation.Resource; +import com.ks.lib.common.exception.ParamsException; +import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.entity.SystemEnum; import com.yeshi.fanli.entity.SystemFunction; +import com.yeshi.fanli.entity.SystemPIDInfo; +import com.yeshi.fanli.exception.pdd.PDDAuthException; +import com.yeshi.fanli.exception.pdd.PDDGoodsException; import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; +import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException; +import com.yeshi.fanli.service.inter.pdd.PDDAuthService; +import com.yeshi.fanli.service.manger.ClipboardContentType; +import com.yeshi.fanli.service.manger.PIDManager; import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; +import com.yeshi.fanli.service.manger.goods.jd.JDConvertLinkManager; +import com.yeshi.fanli.service.manger.goods.pdd.PDDConvertLinkManager; +import com.yeshi.fanli.service.manger.goods.suning.SuningConvertLinkManager; +import com.yeshi.fanli.service.manger.goods.tb.TBConvertLinkManager; +import com.yeshi.fanli.service.manger.goods.vipshop.VipShopConvertLinkManager; import com.yeshi.fanli.util.*; import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.exception.ExceptionConstant; +import com.yeshi.fanli.util.goods.GoodsJumpUtil; +import com.yeshi.fanli.util.goods.GoodsTextUtil; +import com.yeshi.fanli.util.suning.SuningUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; +import com.yeshi.fanli.util.vipshop.VipShopUtil; +import com.yeshi.fanli.vo.goods.ConvertLinkJumpVO; +import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO; import org.apache.commons.beanutils.PropertyUtils; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Controller; @@ -142,7 +166,19 @@ private ConvertLinkManager convertLinkManager; @Resource - private ShareGoodsService shareGoodsService; + private TBConvertLinkManager tbConvertLinkManager; + + @Resource + private JDConvertLinkManager jdConvertLinkManager; + + @Resource + private PDDConvertLinkManager pddConvertLinkManager; + + @Resource + private SuningConvertLinkManager suningConvertLinkManager; + + @Resource + private VipShopConvertLinkManager vipShopConvertLinkManager; @Resource private DailyCountMomentsService dailyCountMomentsService; @@ -151,7 +187,11 @@ private CommonShareInfoService commonShareInfoService; @Resource - private UserCloudService userCloudService; + private PDDAuthService pddAuthService; + + + @Resource + private PIDManager pidManager; @Resource(name = "taskExecutor") private TaskExecutor executor; @@ -623,7 +663,7 @@ } else if (cid == TYPE_SUCAI) { type = 2; } - List<GoodsEvaluate> listNew = new ArrayList<GoodsEvaluate>(); + List<GoodsEvaluate> listNew = new ArrayList<>(); List<GoodsEvaluate> list = goodsEvaluateService.queryMaterialsCache((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, type, acceptData.getSystem()); @@ -642,6 +682,9 @@ } for (GoodsEvaluate goodsEvaluate : list) { + if (goodsEvaluate.getGoods() != null) { + goodsEvaluate.getGoods().setCreatetime(null); + } GoodsEvaluate evaluateNew = new GoodsEvaluate(); try { PropertyUtils.copyProperties(evaluateNew, goodsEvaluate); @@ -676,8 +719,16 @@ List<ImgInfo> listInfoNew = new ArrayList<ImgInfo>(); for (ImgInfo imgInfo : goodsEvaluate.getImgList()) { + + if (acceptData.getSystem() == SystemEnum.yhqjx||acceptData.getSystem() == SystemEnum.hsb) { + imgInfo.setGoods(null); + imgInfo.setGoodsVO(null); + } + if (imgInfo.getType() != ImgEnum.activity) { listInfoNew.add(imgInfo); + + continue; } ImgInfo infoNew = new ImgInfo(); @@ -813,6 +864,124 @@ } + + /** + * 杞摼 + * + * @param acceptData + * @param uid + * @param link + * @param out + */ + @RequestMapping(value = "convertLink", method = RequestMethod.POST) + public void convertLink(AcceptData acceptData, Long uid, String link, PrintWriter out) { + if (StringUtil.isNullOrEmpty(link)) { + out.print(JsonUtil.loadFalseResult("閾炬帴涓虹┖")); + return; + } + + ConvertLinkJumpVO convertLinkJumpVO = null; + //鍒ゆ柇result鏄惁涓烘窐鍙d护 + List<String> urlList = UrlUtils.parseUrlsFromText(link); + if (urlList.size() > 0) { + //鍙鐞嗕含涓�/鎷煎澶氶摼鎺� + String url = urlList.get(0); + if (JDUtil.isJDLink(url)) { + try { + url = jdConvertLinkManager.convertShortUrl(url, uid, acceptData.getSystem(), uid == null ? SystemPIDInfo.PidType.coupon : SystemPIDInfo.PidType.fanli); + } catch (ParamsException e) { + e.printStackTrace(); + } + convertLinkJumpVO = new ConvertLinkJumpVO(GoodsJumpUtil.getJDJumpInfo(url), Constant.SOURCE_TYPE_JD); + outPrintConvertResult(convertLinkJumpVO, out); + return; + } + + if (PinDuoDuoUtil.isPDDLink(url)) { + String pddGoodsId = PinDuoDuoUtil.getPDDGoodsId(url); + String customParams = pddAuthService.getFanliCustomParams(uid); + PDDConvertLinkResultVO convertLinkResult = null; + try { + convertLinkResult = pddConvertLinkManager.convertGoods(Long.parseLong(pddGoodsId), acceptData.getSystem(), customParams, uid == null ? SystemPIDInfo.PidType.coupon : SystemPIDInfo.PidType.fanli); + convertLinkJumpVO = new ConvertLinkJumpVO(GoodsJumpUtil.getPDDJumpInfo(convertLinkResult), Constant.SOURCE_TYPE_PDD); + outPrintConvertResult(convertLinkJumpVO, out); + return; + } catch (PDDGoodsException e) { + e.printStackTrace(); + //鍟嗗搧涓嬬嚎 + out.print(JsonUtil.loadFalseResult(ExceptionConstant.CODE_GOODS_OFFLINE, "鍟嗗搧宸蹭笅绾�")); + return; + } catch (PDDAuthException e) { + e.printStackTrace(); + //鎷煎澶氭湭鎺堟潈 + out.print(JsonUtil.loadFalseResult(ExceptionConstant.CODE_AUTH_PDD_NO_AUTH, "鎷煎澶氬皻鏈巿鏉冿紝璇锋巿鏉�")); + return; + } + } + + + return; + } + + List<String> tokenList = TaoBaoUtil.getTokenListFromTextWithKuoHao(link); + if (tokenList.size() > 0) { + //杩樺師鍙d护 + try { + TaoKeApiUtil.TokenConvertResult convertResult = TaoKeApiUtil.tokenConvert(tokenList.get(0)); + if (convertResult != null) { + String originUrl = convertResult.getOrigin_url(); + long goodsId = convertResult.getNum_iid(); + TaoBaoLink taoBaoLink = tbConvertLinkManager.convertGoods(goodsId, uid, acceptData.getSystem(), uid == null ? SystemPIDInfo.PidType.coupon : SystemPIDInfo.PidType.fanli); + convertLinkJumpVO = new ConvertLinkJumpVO(GoodsJumpUtil.getTBJumpInfo(taoBaoLink), Constant.SOURCE_TYPE_TAOBAO); + outPrintConvertResult(convertLinkJumpVO, out); + return; + } else { + throw new Exception("杞摼澶辫触"); + } + } catch (Exception e) { + e.printStackTrace(); + //杈撳嚭鍘熸潵鐨勬窐鍙d护 + JSONObject root = new JSONObject(); + root.put("data", new Gson().toJson(new ConvertLinkJumpVO(null, Constant.SOURCE_TYPE_TAOBAO))); + root.put("code", ExceptionConstant.CODE_JUMP_NO_SUPPORT); + out.print(root.toString()); + return; + } + + } + out.print(JsonUtil.loadFalseResult("涓嶆敮鎸佺殑绫诲瀷")); + } + + + private void outPrintConvertResult(ConvertLinkJumpVO vo, PrintWriter out) { + out.print(JsonUtil.loadTrueResult(new Gson().toJson(vo))); + } + + + /** + * 澶嶅埗鎺ㄨ崘璇� + * + * @param acceptData + * @param uid + * @param id + * @param type + * @param goodsId + * @param goodsType + * @param out + */ + @RequestMapping(value = "evaluateCopyRecommend", method = RequestMethod.POST) + public void evaluateCopyRecommend(AcceptData acceptData, Long uid, String id, PrintWriter out) { + GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id); + if (goodsEvaluate == null) { + out.print(JsonUtil.loadFalseResult("璇ュ唴瀹瑰凡涓嶅瓨鍦�")); + return; + } + JSONObject data = new JSONObject(); + String result = GoodsTextUtil.decodeAppHtmlText(goodsEvaluate.getTitle()); + data.put("content", result); + out.print(JsonUtil.loadTrueResult(data)); + } + /** * @param acceptData * @param uid @@ -870,7 +1039,7 @@ } String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); if (SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.threeSale)) { - inviteCode = userInfoExtraService.getInviteCodeByUid(uid); + inviteCode = userInfoExtraService.getInviteCodeByUid(uid); if (StringUtil.isNullOrEmpty(inviteCode)) { out.print(JsonUtil.loadFalseResult(1, "閭�璇风爜鏈縺娲�")); return; @@ -977,7 +1146,7 @@ } if (list.size() == 0) { - out.print(JsonUtil.loadFalseResult("璇ヤ俊鎭凡涓嬫灦")); + out.print(JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); return; } @@ -997,7 +1166,7 @@ if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { TaoBaoLink taoBaoLink = null; try { - taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(user.getId(), Long.parseLong(goodsVO.getGoodsId()), + taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(system, user.getId(), Long.parseLong(goodsVO.getGoodsId()), relationId, null); } catch (TaoBaoConvertLinkException e) { e.printStackTrace(); @@ -1017,11 +1186,15 @@ couponUrl = couponInfo.getLink(); } String materialId = "https://item.jd.com/" + goodsVO.getGoodsId() + ".html"; - jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), user.getId() + ""); } else if (goodsVO.getGoodsType() == Constant.SOURCE_TYPE_PDD) { - jumpLink = PinDuoDuoApiUtil.getPromotionUrl(Long.parseLong(goodsVO.getGoodsId()), - PinDuoDuoApiUtil.PID_SHARE + "", user.getId() + ""); + PDDGoodsDetail pddGoodsDetail = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsVO.getGoodsId())); + if (pddGoodsDetail == null) { + return null; + } + + jumpLink = PinDuoDuoApiUtil.getPromotionUrl(pddGoodsDetail.getGoodsSign(), pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), user.getId() + ""); } FileUploadResult uploadResult = qrCodeService.drawDynamicGoodsPoster(jumpLink, user.getPortrait(), inviteCode, @@ -1089,9 +1262,21 @@ } String newText = text; // 闈為�氱敤鍒搁渶瑕侀獙璇� + + //鐗逛环鍙渶瑕佸鍒舵枃瀛楋紝涓嶉渶瑕佽浆閾� + if (acceptData.getSystem() == SystemEnum.yhqjx||acceptData.getSystem() == SystemEnum.hsb) { + newText = GoodsTextUtil.decodeAppHtmlText(newText); + //鍙鍒舵枃瀛� + JSONObject data = new JSONObject(); + data.put("text", newText); + out.print(JsonUtil.loadTrueResult(data)); + return; + } + + if (comment != null && (comment.getNeedSpin() == null || comment.getNeedSpin())) { try { - newText = convertLinkManager.convertLinkFromText(text, uid, true); + newText = convertLinkManager.convertLinkFromText(acceptData.getSystem(), text, uid, true, true); } catch (ConvertLinkExceptionException e) { if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) { out.print(JsonUtil.loadFalseResult("璇勮鐢熸垚澶辫触")); @@ -1175,7 +1360,7 @@ String newText = text; if (shareInfo.getNeedSpin() != null && shareInfo.getNeedSpin()) { try { - newText = convertLinkManager.convertLinkFromText(text, uid, true); + newText = convertLinkManager.convertLinkFromText(acceptData.getSystem(), text, uid, true, true); } catch (ConvertLinkExceptionException e) { if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) { out.print(JsonUtil.loadFalseResult("璇勮鐢熸垚澶辫触")); @@ -1245,7 +1430,7 @@ int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); jumpDetail = jumpDetailV2Service.getByTypeCache("web", platformCode, - Integer.parseInt(acceptData.getVersion())); + Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); JSONObject inner = new JSONObject(); inner.put("url", jumpLink); params = inner.toString(); @@ -1370,7 +1555,7 @@ String newText = text; if (shareInfo.getNeedSpin() != null && shareInfo.getNeedSpin()) { try { - newText = convertLinkManager.convertLinkFromText(text, uid, true); + newText = convertLinkManager.convertLinkFromText(acceptData.getSystem(), text, uid, true, true); } catch (ConvertLinkExceptionException e) { if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇勮鐢熸垚澶辫触")); @@ -1502,7 +1687,7 @@ if (shareInfo.getNeedSpin() != null && shareInfo.getNeedSpin()) { try { String erCodeContent = ""; - newText = convertLinkManager.convertLinkFromText(text, uid, true); + newText = convertLinkManager.convertLinkFromText(acceptData.getSystem(), text, uid, true, true); // 鑾峰彇鍙d护 List<String> tokenList = TaoBaoUtil.getTokenListFromTextWithKuoHao(newText); if (tokenList != null && tokenList.size() > 0) { @@ -1599,7 +1784,7 @@ String newText = text; // 闈為�氱敤鍒搁渶瑕侀獙璇� if (comment != null && (comment.getNeedSpin() == null || comment.getNeedSpin())) { try { - newText = convertLinkManager.convertLinkFromText(text, uid, true); + newText = convertLinkManager.convertLinkFromText(acceptData.getSystem(), text, uid, true, true); } catch (ConvertLinkExceptionException e) { if (e.getCode() != ConvertLinkExceptionException.CODE_NONE) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇勮鐢熸垚澶辫触")); -- Gitblit v1.8.0