| | |
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | 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.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
|
| | |
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsCacheUtil jdGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 创建淘宝分享信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | |
| | | out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 淘礼金创建分享
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
|
| | |
| | |
|
| | | try {
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | |
| | |
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | |
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | | |
| | |
|
| | | shareInfo.setShareText(shareText);
|
| | | |
| | | // String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | // if (descText.startsWith("\\r\\n"))
|
| | | // descText = descText.substring(0);
|
| | | // data.put("descText", descText);
|
| | | |
| | | |
| | |
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n")) {
|
| | | descText = descText.substring(0);
|
| | | }
|
| | | shareInfo.setDescText(descText);
|
| | |
|
| | | // 提示图文内容
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | |
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | | |
| | |
|
| | | // 分享id
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | final TaoBaoLink taobaoLink = taoBaoLink;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("spreadMoney", " ¥" + spreadMoney.toString());
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setSpreadMoney(" ¥" + spreadMoney.toString());
|
| | |
|
| | | String taoLiJinLink = null;
|
| | | Long tljId = null;
|
| | |
| | | UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods);
|
| | | tljId = record.getId();
|
| | | taoLiJinLink = record.getSendUrl();
|
| | | data.put("tljId", tljId);
|
| | | data.put("surplusMoney", record.getSurplusMoney());
|
| | | shareInfo.setTljId(tljId.toString());
|
| | | shareInfo.setSurplusMoney(record.getSurplusMoney().toString());
|
| | | } catch (UserTaoLiJinRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | return;
|
| | |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | data.put("clickUrl", url);
|
| | | shareInfo.setClickUrl(url);
|
| | |
|
| | | // 创建淘口令
|
| | | if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功
|
| | |
| | | taoBaoLink.setTaoToken(quanToken);
|
| | | }
|
| | | }
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | |
|
| | | data.put("rule",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | | shareInfo.setToken(taoBaoLink.getTaoToken());
|
| | | shareInfo.setRule(configService.get("share_single_goods_rule"));
|
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | |
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | | data.put("shareText", shareText);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | |
|
| | | shareInfo.setDescText(descText);
|
| | |
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | if (p < array.size()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get("goods_share_notify"));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | final TaoBaoLink taobaoLink = taoBaoLink;
|
| | | // 异步操作
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | // TODO
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "", Constant.SOURCE_TYPE_JD);
|
| | |
| | | url = shortLink;
|
| | | }
|
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("rule", configService.get("share_rule_link_jd"));
|
| | | data.put("pictUrl", jdGoods.getPicUrl());
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setRule(configService.get("share_rule_link_jd"));
|
| | | shareInfo.setPictUrl(jdGoods.getPicUrl());
|
| | |
|
| | | String shareText = "";
|
| | |
|
| | | String shopType = "京东价";
|
| | |
|
| | | // 分享模板
|
| | |
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())).replace("{领券短链}", shortLink)
|
| | | .replace("{淘口令}", null);
|
| | | data.put("shareText", shareText);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | | if (descText.startsWith("\\r\\n")) {
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | }
|
| | | shareInfo.setDescText(descText);
|
| | |
|
| | | //
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify_jd"));
|
| | | if (p < array.size()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get("goods_share_notify_jd"));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate);
|
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | // 异步操作
|
| | | final JDGoods goods = jdGoods;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | |
|
| | | // TODO
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "", Constant.SOURCE_TYPE_PDD);
|
| | |
| | | url = shortLink;
|
| | | }
|
| | |
|
| | | data.put("clickUrl", url);
|
| | | // 帮助中心-介绍
|
| | | data.put("rule", configService.get("share_rule_link_pdd"));
|
| | | data.put("pictUrl", goods.getGoodsImageUrl());
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setRule(configService.get("share_rule_link_pdd"));
|
| | | shareInfo.setPictUrl(goods.getGoodsImageUrl());
|
| | |
|
| | | String shareText = "";
|
| | |
|
| | | String shopType = "拼多多价";
|
| | |
|
| | | // 无券
|
| | |
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{领券短链}", shortLink)
|
| | | .replace("{淘口令}", null);
|
| | | data.put("shareText", shareText);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(goods.getGoodsName(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | | if (descText.startsWith("\\r\\n")) {
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | }
|
| | | shareInfo.setDescText(descText);
|
| | |
|
| | | //
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | |
|
| | | data.put("notifyDesc", configService.get("goods_share_notify_pdd"));
|
| | | if (p < array.size()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get("goods_share_notify_pdd"));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | // 异步操作
|
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 预览分享模板
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param template
|
| | | * @param goodsId
|
| | | * @param hasCoupon
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST)
|
| | | public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, Long goodsId,
|
| | | Long tljId, Boolean hasCoupon, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsId == null) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "商品ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == null || goodsType > 3 || goodsType < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | createTaoBaoViewText(goodsType, uid, template, goodsId, tljId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建淘宝分享模板
|
| | | * |
| | | * @param uid
|
| | | * @param template
|
| | | * @param goodsType
|
| | | * @param goodsId
|
| | | * @param tljId
|
| | | * @param hasCoupon
|
| | | * @param out
|
| | | */
|
| | | public void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId,
|
| | | Boolean hasCoupon, PrintWriter out) {
|
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId);
|
| | | if (goods == null)
|
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | goods = null;
|
| | | }
|
| | |
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(4, "商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = getShareTemplate(goodsType, uid, hasCoupon, tljId);
|
| | | }
|
| | |
|
| | | // 校验券模板是否正确
|
| | | if (hasCoupon) {
|
| | | // 有券商品
|
| | | if (tljId != null) {
|
| | | try {
|
| | | shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | | } else {
|
| | | try {
|
| | | shareGoodsTextTemplateService.isCouponTemplateRight(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | | }
|
| | | } else {
|
| | | // 普通商品
|
| | | try {
|
| | | shareGoodsTextTemplateService.isCommonTemplateRight(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | String url = null;
|
| | | if (tljId != null) {
|
| | | UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId);
|
| | | if (userTaoLiJinRecord == null) {
|
| | | out.print(JsonUtil.loadFalseResult(5, "淘礼金领取链接不存在"));
|
| | | return;
|
| | | }
|
| | | url = userTaoLiJinRecord.getSendUrl();
|
| | | } else {
|
| | | url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goods.getAuctionId() + "");
|
| | | }
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | |
|
| | | // 查询是否有分享
|
| | | UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId());
|
| | | String token = "";
|
| | | if (userShareHistory != null) {
|
| | | token = userShareHistory.getTkCode();
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(token)) {
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT);
|
| | | TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
|
| | | if (goodsLink != null)
|
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
|
| | | StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl()
|
| | | : goodsLink.getCouponLink());
|
| | | }
|
| | | String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink,
|
| | | hasCoupon, tljId);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("content", content);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建京东分享模板
|
| | | * |
| | | * @param uid
|
| | | * @param template
|
| | | * @param goodsType
|
| | | * @param goodsId
|
| | | * @param tljId
|
| | | * @param hasCoupon
|
| | | * @param out
|
| | | */
|
| | | public void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
|
| | | PrintWriter out) {
|
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(4, "商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = getShareTemplate(goodsType, uid, hasCoupon, null);
|
| | | }
|
| | |
|
| | | // 校验券模板是否正确
|
| | | if (hasCoupon) {
|
| | | // 有券商品
|
| | | try {
|
| | | shareGoodsTextTemplateService.isCouponTemplateRightJD(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 普通商品
|
| | | try {
|
| | | shareGoodsTextTemplateService.isCommonTemplateRightJD(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | |
|
| | | String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
|
| | | hasCoupon);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("content", content);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建京东分享模板
|
| | | * |
| | | * @param uid
|
| | | * @param template
|
| | | * @param goodsType
|
| | | * @param goodsId
|
| | | * @param tljId
|
| | | * @param hasCoupon
|
| | | * @param out
|
| | | */
|
| | | public void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon,
|
| | | PrintWriter out) {
|
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(4, "商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = getShareTemplate(goodsType, uid, hasCoupon, null);
|
| | | }
|
| | |
|
| | | // 校验券模板是否正确
|
| | | if (hasCoupon) {
|
| | | // 有券商品
|
| | | try {
|
| | | shareGoodsTextTemplateService.isCouponTemplateRightPDD(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 普通商品
|
| | | try {
|
| | | shareGoodsTextTemplateService.isCommonTemplateRightPDD(template);
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | // 创建h5连接
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | |
|
| | | // 创建口令
|
| | | String token = PinDuoDuoApiUtil.createGenerate(goodsId);
|
| | |
|
| | | // 生成分享内容
|
| | | String content = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
|
| | | hasCoupon, token);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("content", content);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享模板
|
| | | * |
| | | * @param uid
|
| | | * @param hasCoupon
|
| | | * @param tljId
|
| | | * @return
|
| | | */
|
| | | private String getShareTemplate(int goodsType, Long uid, boolean hasCoupon, Long tljId) {
|
| | | String template = "";
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | if (hasCoupon) {
|
| | | if (tljId != null) {
|
| | | template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configTaoLiJinService.getValueByKey("goods_share_text");
|
| | | } else {
|
| | | template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configService.get("goods_share_text_coupon");
|
| | | }
|
| | |
|
| | | } else {
|
| | | template = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configService.get("goods_share_text_nocoupon");
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
|
| | | if (hasCoupon) {
|
| | | if (textTemplate != null) {
|
| | | template = textTemplate.getShareJDTextTemplateCoupon();
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = configService.get("goods_share_text_coupon_jd");
|
| | | }
|
| | | } else {
|
| | | if (textTemplate != null) {
|
| | | template = textTemplate.getShareJDTextTemplate();
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = configService.get("goods_share_text_nocoupon_jd");
|
| | | }
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
|
| | | if (hasCoupon) {
|
| | | if (textTemplate != null) {
|
| | | template = textTemplate.getSharePDDTextTemplateCoupon();
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = configService.get("goods_share_text_coupon_pdd");
|
| | | }
|
| | | } else {
|
| | | if (textTemplate != null) {
|
| | | template = textTemplate.getSharePDDTextTemplate();
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | template = configService.get("goods_share_text_nocoupon_pdd");
|
| | | }
|
| | | }
|
| | | }
|
| | | return template;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享模板
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param hasCoupon
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST)
|
| | | public void getShareTextTemplate(AcceptData acceptData, Integer goodsType, Long uid, Long tljId, Boolean hasCoupon,
|
| | | PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (hasCoupon == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "是否有券字段为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("template", getShareTemplate(goodsType, uid, hasCoupon, tljId));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享模板编辑规则
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST)
|
| | | public void getShareTextTemplateRules(AcceptData acceptData, Integer goodsType, Long tljId, PrintWriter out) {
|
| | | if (goodsType == null || goodsType > 3 || goodsType < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | if (tljId != null) {
|
| | | out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_jd")));
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_pdd")));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 保存模板
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param hasCoupon
|
| | | * @param template
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST)
|
| | | public void saveShareTextTemplate(AcceptData acceptData, Integer goodsType, Long uid, Long tljId, Boolean hasCoupon,
|
| | | String template, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(template)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "分享模板为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == null || goodsType > 3 || goodsType < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | // 校验券模板是否正确
|
| | | if (hasCoupon) {
|
| | | // 有券商品
|
| | | if (tljId != null) {
|
| | | shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
|
| | | shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template);
|
| | | } else {
|
| | | shareGoodsTextTemplateService.isCouponTemplateRight(template);
|
| | | shareGoodsTextTemplateService.saveCouponTemplate(uid, template);
|
| | | }
|
| | | } else {
|
| | | // 普通商品
|
| | | shareGoodsTextTemplateService.isCommonTemplateRight(template);
|
| | | shareGoodsTextTemplateService.saveCommonTemplate(uid, template);
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | if (hasCoupon) {
|
| | | shareGoodsTextTemplateService.isCouponTemplateRightJD(template);
|
| | | shareGoodsTextTemplateService.saveCouponTemplateJD(uid, template);
|
| | | } else {
|
| | | shareGoodsTextTemplateService.isCommonTemplateRightJD(template);
|
| | | shareGoodsTextTemplateService.saveCommonTemplateJD(uid, template);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | if (hasCoupon) {
|
| | | shareGoodsTextTemplateService.isCouponTemplateRightPDD(template);
|
| | | shareGoodsTextTemplateService.saveCouponTemplatePDD(uid, template);
|
| | | } else {
|
| | | shareGoodsTextTemplateService.isCommonTemplateRightPDD(template);
|
| | | shareGoodsTextTemplateService.saveCommonTemplatePDD(uid, template);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | }
|
| | | } catch (ShareGoodsTextTemplateException e) {
|
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
|
| | | return;
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 还原模板
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param hasCoupon -是否有券
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST)
|
| | | public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon,
|
| | | Integer goodsType, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == null || goodsType > 3 || goodsType < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "平台类型不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | if (hasCoupon) {
|
| | | if (tljId != null) {
|
| | | shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
|
| | | } else {
|
| | | shareGoodsTextTemplateService.resetCouponTemplate(uid);
|
| | | }
|
| | | } else {
|
| | | shareGoodsTextTemplateService.resetCommonTemplate(uid);
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | if (hasCoupon) {
|
| | | shareGoodsTextTemplateService.resetCouponTemplateJD(uid);
|
| | | } else {
|
| | | shareGoodsTextTemplateService.resetCommonTemplateJD(uid);
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | if (hasCoupon) {
|
| | | shareGoodsTextTemplateService.resetCouponTemplatePDD(uid);
|
| | | } else {
|
| | | shareGoodsTextTemplateService.resetCommonTemplatePDD(uid);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | if (goodsId != null) {
|
| | | viewShareTextTemplate(acceptData, uid, null, goodsType, goodsId, tljId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享记录中的商品 分享信息
|
| | | *
|
| | | * @param acceptData
|