| | |
| | | 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.inter.pdd.PDDAuthService; |
| | | 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.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.dto.ConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo; |
| | | import com.yeshi.fanli.dto.jd.JDPingouInfo; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | |
| | | @Resource |
| | | private PDDAuthService pddAuthService; |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode, |
| | | BigDecimal fanliMoney) { |
| | | List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>(); |
| | |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | commentText = commentText.replace("[券后价]", TaoBaoUtil.getCouponPrice(goods) + ""); |
| | | } |
| | | |
| | | commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | |
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "") |
| | | .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString()) |
| | | .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString()) |
| | | .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | .replace("{优惠券价}", TaoBaoUtil.getCouponPrice(goods) + ""); |
| | | } |
| | | |
| | | shareText = shareText.replace("{店铺类型}", shopType) |
| | |
| | | try { |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, goodsId, relationId, null); |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(acceptData.getSystem(), uid, goodsId, relationId, null); |
| | | |
| | | if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) { |
| | | ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, acceptData.getSystem()); |
| | | GoodsMoneyConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, acceptData.getSystem()); |
| | | GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto); |
| | | shareInfo.setGoodsInfo(goodsInfo); |
| | | } |
| | |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", |
| | | TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); |
| | | TaoBaoUtil.getCouponPrice(taoBaoLink.getGoods()) + ""); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share); |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, uid + ""); |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, JDApiUtil.POSITION_SHARE + "", uid + ""); |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, uid + ""); |
| | | } |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | |
| | | recommendText = recommendText.replace("[券面额]", |
| | | BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString()); |
| | | commentText = commentText.replace("[券后价]", |
| | | BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString()); |
| | | BigDecimalUtil.getWithNoZera(JDUtil.getCouponPrice(jdGoods)).toString()); |
| | | } |
| | | commentText = commentText.replace("[链接]", jumpLink); |
| | | } else { |
| | |
| | | */ |
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, |
| | | PrintWriter out) { |
| | | |
| | | //查询当前用户是否授权 |
| | | |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share); |
| | | |
| | | if (VersionUtil.greaterThan_2_1_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (!PinDuoDuoApiUtil.isAuth(pid, pddAuthService.getFanliCustomParams(uid))) { |
| | | out.print(JsonUtil.loadFalseResult(20001, "尚未备案,请先备案")); |
| | | return; |
| | | } |
| | | } else { |
| | | if (System.currentTimeMillis() > TimeUtil.convertToTimeTemp("2021-05-01", "yyyy-MM-dd") && !PinDuoDuoApiUtil.isAuth(pid, pddAuthService.getFanliCustomParams(uid))) { |
| | | out.print(JsonUtil.loadFalseResult(20001, "请升级到最新版")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); |
| | |
| | | // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | // goodsId + ""); |
| | | |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pid, pddAuthService.getFanliCustomParams(uid) + ""); |
| | | |
| | | SystemEnum system = SystemInfoUtil.getSystem(acceptData); |
| | | |
| | |
| | | if (needGoods) { |
| | | shareInfo |
| | | .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, |
| | | new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())))); |
| | | } |
| | |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", |
| | | BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString()); |
| | | BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getCouponPrice(goods)).toString()); |
| | | |
| | | BigDecimal hundred = new BigDecimal(100); |
| | | BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred); |
| | |
| | | if (needGoods) { |
| | | shareInfo |
| | | .setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods, |
| | | new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())))); |
| | | } |
| | |
| | | String couponLink = goods.getCouponInfo().getCouponUrl(); |
| | | |
| | | String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sts[0], sts[1]), |
| | | StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + ""); |
| | | StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), uid + ""); |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | shareInfo.setClickUrl(jumpLink); |
| | |
| | | if (needGoods) { |
| | | shareInfo |
| | | .setGoodsInfo(GoodsDetailVOFactory.convertSuningGoods(goods, |
| | | new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())))); |
| | | } |
| | |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | createTaoBaoViewText(goodsType, uid, template, Long.parseLong(goodsId), tljId, hasCoupon, out); |
| | | createTaoBaoViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), tljId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | createJDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); |
| | | createJDViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); |
| | | createPDDViewText(acceptData.getSystem(), goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | createSuNingViewText(goodsType, uid, template, goodsId, hasCoupon, out); |
| | | createSuNingViewText(acceptData.getSystem(), goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | } |
| | |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId, |
| | | private void createTaoBaoViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Long tljId, |
| | | Boolean hasCoupon, PrintWriter out) { |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null) |
| | |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(token)) { |
| | | String pid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.share); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]); |
| | | app.setAdzoneId(pid.split("_")[3]); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); |
| | | app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); |
| | | app.setPid(pid); |
| | | TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app, null, null); |
| | | if (goodsLink != null) |
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), |
| | |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, |
| | | private void createJDViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, JDApiUtil.POSITION_SHARE + "", |
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(system, Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.share), |
| | | uid + ""); |
| | | |
| | | String content = shareGoodsTextTemplateService.createContentJD(template, goods, shortLink, hasCoupon); |
| | |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, |
| | | private void createPDDViewText(SystemEnum system, Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | |
| | | // goodsId + ""); |
| | | // String shortLink = HttpUtil.getShortLink(url); |
| | | |
| | | String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); |
| | | String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goods.getGoodsSign(), pidManager.getPidCache(system, Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), uid + ""); |
| | | |
| | | // // 创建口令 |
| | | // String token = PinDuoDuoApiUtil.createGenerate(goodsId); |
| | |
| | | } |
| | | |
| | | |
| | | private void createSuNingViewText(Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, |
| | | private void createSuNingViewText(SystemEnum system, Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, |
| | | PrintWriter out) { |
| | | String[] ids = SuningUtil.getGoodsIdDetail(goodsId); |
| | | SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); |
| | |
| | | |
| | | String couponLink = goods.getCouponInfo().getCouponUrl(); |
| | | String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(ids[0], ids[1]), |
| | | StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + ""); |
| | | StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, pidManager.getPidCache(system, Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.share), uid + ""); |
| | | |
| | | // 生成普通分享内容 |
| | | String content = shareGoodsTextTemplateService.createCommonShareTextSuNing(template, goods, jumpLink); |
| | |
| | | } |
| | | } |
| | | |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | GoodsDetailVO goodsDetail = null; |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |