| | |
| | | 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 org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | // 苏宁 |
| | | if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | createSuningShare(acceptData, uid, goodsId, source, needGoods, out); |
| | | return; |
| | | } |
| | | |
| | | // 抖音 |
| | | if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | createDYShare(acceptData, uid,Long.parseLong( goodsId), source, needGoods, out); |
| | | return; |
| | | } |
| | | |
| | |
| | | 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); |
| | | |
| | |
| | | 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) { |
| | | 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.getQrCode()); |
| | | shareInfo.setWxErCode(convertResult.getQrCode()); |
| | | 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_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; |
| | | } |
| | | } |
| | |
| | | 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 = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(),DYUtil.createShareExtraInfo(uid),""); |
| | | |
| | | |
| | | // 生成普通分享内容 |
| | | 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) { |
| | |
| | | String goodsId = commonGoods.getGoodsId(); |
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) { |
| | | String auctionId = taoKeGoods.getAuctionId(); |
| | | if (TaoBaoUtil.isEqual(goodsId , auctionId)) { |
| | | if (TaoBaoUtil.isEqual(goodsId, auctionId)) { |
| | | state = 0; // 在售 |
| | | break; |
| | | } |
| | |
| | | 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) { |