| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | 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 org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
|
| | | 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.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | 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.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | 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;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.goods.ShareInfoVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/share")
|
| | | public class ShareControllerV2 {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private MonitorService monitorService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsCacheUtil jdGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService;
|
| | |
|
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | |
|
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private BusinessEmergent110Service businessEmergent110Service;
|
| | |
|
| | | @Resource
|
| | | private ConfigTaoLiJinService configTaoLiJinService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | /**
|
| | | * 获取淘宝的分享链接
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * -用户ID
|
| | | * @param auctionId-商品ID
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "createShareInfo")
|
| | | public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum,
|
| | | Integer goodsType, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsId == null || goodsId <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 淘宝
|
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, request, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 京东
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | createJDShare(acceptData, uid, goodsId, source, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | // 拼多多
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | createPDDShare(acceptData, uid, goodsId, source, out);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建淘宝分享信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | | * @param totalNum
|
| | | * @param source
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | String relationId = null;
|
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
|
| | | && extraInfo.getRelationValid() == true)
|
| | | relationId = extraInfo.getRelationId();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(relationId)) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 淘礼金创建分享
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | 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(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | goodsId + "");
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | |
|
| | | shareInfo.setClickUrl(url);
|
| | | shareInfo.setToken(taoBaoLink.getTaoToken());
|
| | | shareInfo.setRule(configService.get("share_single_goods_rule"));
|
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String shareText = "";
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
|
| | | } else// 有券
|
| | | {
|
| | | String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_coupon");
|
| | |
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
|
| | | .replace("{优惠券面额}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
|
| | | .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
|
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | | 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()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get("goods_share_notify"));
|
| | |
|
| | | // 分享金额
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | |
|
| | | // 分享id
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_TAOBAO, false);
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | final TaoBaoLink taobaoLink = taoBaoLink;
|
| | | // 异步操作
|
| | | 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(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(taobaoLink.getTaoToken());
|
| | | history.setLink(taobaoLink.getClickUrl());
|
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId());
|
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl());
|
| | |
|
| | | List<String> imgList = taobaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | return;
|
| | | } catch (ShareGoodsException e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + " goodsId:" + goodsId, "");
|
| | | // 分享出错报警
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘礼金创建分享
|
| | | * |
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param totalNum
|
| | | * @param relationId
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | | } catch (TaobaoGoodsDownException e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | |
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult("商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
|
| | | LogHelper.error("推广红包比例:"+warningRate);
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
|
| | | LogHelper.error("推广红包:"+spreadMoney);
|
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘礼金不足"));
|
| | | return;
|
| | | }
|
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setSpreadMoney(" ¥" + spreadMoney.toString());
|
| | |
|
| | | String taoLiJinLink = null;
|
| | | Long tljId = null;
|
| | | try {
|
| | | UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods);
|
| | | tljId = record.getId();
|
| | | taoLiJinLink = record.getSendUrl();
|
| | | shareInfo.setTljId(tljId.toString());
|
| | | shareInfo.setSurplusMoney(record.getSurplusMoney().toString());
|
| | | } catch (UserTaoLiJinRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | return;
|
| | | }
|
| | |
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | shareInfo.setClickUrl(url);
|
| | |
|
| | | TaoBaoLink taoBaoLink = new TaoBaoLink();
|
| | | taoBaoLink.setCouponLink(taoLiJinLink);
|
| | | taoBaoLink.setClickUrl(taoLiJinLink);
|
| | |
|
| | | // 创建淘口令
|
| | | if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功
|
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink);
|
| | | if (!StringUtil.isNullOrEmpty(quanToken)) {
|
| | | taoBaoLink.setTaoToken(quanToken);
|
| | | }
|
| | | }
|
| | | shareInfo.setToken(taoBaoLink.getTaoToken());
|
| | | shareInfo.setRule(configService.get("share_single_goods_rule"));
|
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500));
|
| | |
|
| | | // 无券
|
| | | String shopType = goods.getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | | String shareText = "";
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | | shareText = text.replace("{标题}", goods.getTitle()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
|
| | | } else// 有券
|
| | | {
|
| | | String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configTaoLiJinService.getValueByKey("goods_share_text", new Date());
|
| | |
|
| | | shareText = text.replace("{标题}", goods.getTitle())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "")
|
| | | .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString())
|
| | | .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString())
|
| | | .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
|
| | | }
|
| | |
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{领券短链}", shortLink)
|
| | | .replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | | 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.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | | shareInfo.setNotifyPicture(array.optString(p));
|
| | | }
|
| | | shareInfo.setNotifyDesc(configService.get("goods_share_notify"));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
|
| | | Constant.SOURCE_TYPE_TAOBAO, true);
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | final TaoBaoLink taobaoLink = taoBaoLink;
|
| | | final TaoBaoGoodsBrief finalGoods = goods;
|
| | | // 异步操作
|
| | | 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(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(taobaoLink.getTaoToken());
|
| | | history.setLink(taobaoLink.getClickUrl());
|
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(finalGoods.getAuctionId());
|
| | | history.setPostPicture(finalGoods.getPictUrl());
|
| | |
|
| | | List<String> imgList = finalGoods.getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | return;
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + "auctionId:" + auctionId, "");
|
| | | out.print(JsonUtil.loadFalseResult("创建分享出错"));
|
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东创建分享
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | | * @param source
|
| | | * @param goodsType
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
|
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // String url = String.format("http://%s%s?uid=%s&id=%s",
|
| | | // configService.getH5Host(),
|
| | | // Constant.systemCommonConfig.getShareGoodsPagePathJD(),
|
| | | // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | // goodsId + "");
|
| | |
|
| | | String couponUrl = null;
|
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
|
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setClickUrl(jumpLink);
|
| | | shareInfo.setRule(configService.get("share_rule_link_jd"));
|
| | | shareInfo.setPictUrl(jdGoods.getPicUrl());
|
| | |
|
| | | String shareText = "";
|
| | | boolean hasCoupon = false;
|
| | |
|
| | | // 分享模板
|
| | | ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
|
| | | if (couponInfo == null) { // 无券模板
|
| | | if (textTemplate != null)
|
| | | shareText = textTemplate.getShareJDTextTemplate();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(shareText))
|
| | | shareText = configService.get("goods_share_text_nocoupon_jd");
|
| | | } else { // 有券模板
|
| | | hasCoupon = true;
|
| | | if (textTemplate != null)
|
| | | shareText = textTemplate.getShareJDTextTemplateCoupon();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(shareText))
|
| | | shareText = configService.get("goods_share_text_coupon_jd");
|
| | | }
|
| | | shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink,
|
| | | hasCoupon);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(jdGoods.getSkuName(), "").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);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | 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);
|
| | | shareInfo.setShareMoney("¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_JD, false);
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
|
| | |
|
| | | // 异步操作
|
| | | final JDGoods goods = jdGoods;
|
| | | 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_JD);
|
| | | history.setTkCode(null);
|
| | | history.setLink(null);
|
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | |
|
| | | List<String> imgList = goods.getImageList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多分享
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param goodsId
|
| | | * @param source
|
| | | * @param out
|
| | | */
|
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
|
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // String url = String.format("http://%s%s?uid=%s&id=%s",
|
| | | // configService.getH5Host(),
|
| | | // Constant.systemCommonConfig.getShareGoodsPagePathPDD(),
|
| | | // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | // goodsId + "");
|
| | |
|
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
|
| | |
|
| | | ShareInfoVO shareInfo = new ShareInfoVO();
|
| | | shareInfo.setClickUrl(jumpLink);
|
| | | shareInfo.setRule(configService.get("share_rule_link_pdd"));
|
| | | shareInfo.setPictUrl(goods.getGoodsImageUrl());
|
| | |
|
| | | String template = "";
|
| | | boolean hasCoupon = false;
|
| | | ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
|
| | | if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
|
| | | if (textTemplate != null)
|
| | | template = textTemplate.getSharePDDTextTemplate();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configService.get("goods_share_text_nocoupon_pdd");
|
| | | } else {
|
| | | hasCoupon = true;
|
| | | if (textTemplate != null)
|
| | | template = textTemplate.getSharePDDTextTemplateCoupon();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configService.get("goods_share_text_coupon_pdd");
|
| | | }
|
| | |
|
| | | // 创建口令
|
| | | String token = PinDuoDuoApiUtil.createGenerate(goodsId);
|
| | |
|
| | | // 生成分享内容
|
| | | String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink,
|
| | | hasCoupon, token);
|
| | | shareInfo.setShareText(shareText);
|
| | |
|
| | | String descText = shareText.replace(goods.getGoodsName(), "").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);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | 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());
|
| | |
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
|
| | | Constant.SOURCE_TYPE_PDD, false);
|
| | | shareInfo.setShareId(shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().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_PDD);
|
| | | history.setTkCode(null);
|
| | | history.setLink(null);
|
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getGoodsImageUrl());
|
| | |
|
| | | List<String> imgList = null;
|
| | | String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
|
| | | if (goodsGalleryUrls != null) {
|
| | | imgList = Arrays.asList(goodsGalleryUrls);
|
| | | }
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | | }
|
| | | history.setPictures(JsonUtil.getGson().toJson(imgList));
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 预览分享模板
|
| | | * |
| | | * @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_JD) {
|
| | | createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | 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 couponUrl = null;
|
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | String shortLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
|
| | |
|
| | | 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 shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
|
| | |
|
| | | // 创建口令
|
| | | 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", new Date());
|
| | | } 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", new Date())));
|
| | | } 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
|
| | | * @param recordId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getShareGoods")
|
| | | public void getShareGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
|
| | |
|
| | | if (recordId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
|
| | | if (list == null || list.size() == 0) {
|
| | | data.put("title", "分享商品");
|
| | | data.put("count", 0);
|
| | | data.put("result_list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // API网络接口验证是否在售
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | | Integer goodsType = commonGoods.getGoodsType();
|
| | | if (commonGoods == null || goodsType == null || goodsType != Constant.SOURCE_TYPE_TAOBAO) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(commonGoods.getGoodsId());
|
| | | }
|
| | |
|
| | | if (listGid.size() > 0) {
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | for (UserShareGoodsGroup goodsGroup : list) {
|
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 验证淘宝商品是否在售
|
| | | Integer goodsType = commonGoods.getGoodsType();
|
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null
|
| | | && goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | int state = 1; // 默认停售
|
| | | Long goodsId = commonGoods.getGoodsId();
|
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
|
| | | Long auctionId = taoKeGoods.getAuctionId();
|
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) {
|
| | | state = 0; // 在售
|
| | | break;
|
| | | }
|
| | | }
|
| | | commonGoods.setState(state);
|
| | | }
|
| | |
|
| | | // 今日浏览记录处理
|
| | | Date date = new Date();
|
| | | Date browseTime = goodsGroup.getBrowseTime();
|
| | | if (!DateUtil.isSameDay(browseTime, date)) {
|
| | | goodsGroup.setTodayBrowse(0); // 不是同一天浏览记录设置0
|
| | | }
|
| | |
|
| | | JSONObject dataObject = new JSONObject();
|
| | | dataObject.put("todayBrowse", goodsGroup.getTodayBrowse());
|
| | | dataObject.put("totalBrowse", goodsGroup.getTotalBrowse());
|
| | | dataObject.put("totalOrder", goodsGroup.getTotalOrder());
|
| | | dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney());
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate);
|
| | | detailVO.setId(commonGoods.getId());
|
| | | dataObject.put("goods", gson.toJson(detailVO));
|
| | | array.add(dataObject);
|
| | | }
|
| | |
|
| | | String title = "";
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(recordId);
|
| | | if (userShareGoodsRecord != null) {
|
| | | title = userShareGoodsRecord.getTitle();
|
| | | }
|
| | |
|
| | | data.put("title", title);
|
| | | data.put("count", list.size());
|
| | | data.put("result_list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | 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.BigDecimalUtil; |
| | | import org.yeshi.utils.DateUtil; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.fanli.dto.ConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo; |
| | | import com.yeshi.fanli.dto.jd.JDPingouInfo; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; |
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory; |
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord; |
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord; |
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | 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.goods.ShareGoodsTextTemplateException; |
| | | import com.yeshi.fanli.exception.share.ShareGoodsException; |
| | | 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.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService; |
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService; |
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService; |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService; |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService; |
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service; |
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | 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.SpreadUserImgService; |
| | | 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.AESUtil; |
| | | import com.yeshi.fanli.util.Constant; |
| | | 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.VersionUtil; |
| | | 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.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.jd.JDApiUtil; |
| | | import com.yeshi.fanli.util.jd.JDUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoLiJinUtil; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo; |
| | | import com.yeshi.fanli.vo.goods.ShareInfoVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/share") |
| | | public class ShareControllerV2 { |
| | | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private MonitorService monitorService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsRecordService userShareGoodsRecordService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsGroupService userShareGoodsGroupService; |
| | | |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | | |
| | | @Resource |
| | | private JDGoodsCacheUtil jdGoodsCacheUtil; |
| | | |
| | | @Resource |
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private ShareGoodsTextTemplateService shareGoodsTextTemplateService; |
| | | |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | |
| | | @Resource |
| | | private DynamicInfoService dynamicInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private SpreadUserImgService spreadUserImgService; |
| | | |
| | | @Resource |
| | | private BusinessEmergent110Service businessEmergent110Service; |
| | | |
| | | @Resource |
| | | private ConfigTaoLiJinService configTaoLiJinService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService; |
| | | |
| | | private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode, |
| | | BigDecimal fanliMoney) { |
| | | List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>(); |
| | | if (!StringUtil.isNullOrEmpty(token)) |
| | | list.add( |
| | | new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_TOKEN, "淘口令", token, true, false)); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_LINK, "链接", link, true, false)); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) { |
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_INVITE_CODE, "邀请码", |
| | | "邀请码:" + inviteCode, false, true)); |
| | | } |
| | | |
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_DOWNLOAD_LINK, "下载链接", |
| | | "下载链接:" + Constant.YINGYONGBAO_LINK, false, true)); |
| | | |
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_FANLI_MONEY, "返利金额", |
| | | String.format("【联系我下载APP】最高可返还%s元", fanliMoney + ""), false, true)); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * -用户ID |
| | | * @param goodsId-商品ID |
| | | * @param source |
| | | * @param totalNum |
| | | * @param goodsType |
| | | * @param needGoods |
| | | * -是否需要商品信息 |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "createShareInfo") |
| | | public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum, |
| | | Integer goodsType, Boolean needGoods, HttpServletRequest request, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (needGoods == null) |
| | | needGoods = false; |
| | | try { |
| | | // 日志记录 |
| | | String info = String.format("type=share&uid=%s&goodsId=%s&source=%s&goodsType=%s", uid, goodsId, source, |
| | | goodsType); |
| | | LogHelper.orderInfo(info); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | return; |
| | | } |
| | | |
| | | if (goodsId == null || goodsId <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | // 淘宝 |
| | | if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out); |
| | | return; |
| | | } |
| | | |
| | | // 京东 |
| | | if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | createJDShare(acceptData, uid, goodsId, source, needGoods, out); |
| | | return; |
| | | } |
| | | |
| | | // 拼多多 |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDShare(acceptData, uid, goodsId, source, needGoods, out); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) { |
| | | String commentText = template.replace("[原价]", goods.getZkPrice().toString()); |
| | | commentText = commentText.replace("[淘口令]", token); |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | } |
| | | |
| | | commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | | return commentText; |
| | | } |
| | | |
| | | // 淘宝分享活动 |
| | | public static String getTaoBaoActiivtyERCodeContentNew(String template, String token) { |
| | | String commentText = template.replace("[淘口令]", token); |
| | | commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | | return commentText; |
| | | } |
| | | |
| | | /** |
| | | * 创建淘宝分享信息 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param goodsId |
| | | * @param totalNum |
| | | * @param source |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source, |
| | | Boolean needGoods, HttpServletRequest request, PrintWriter out) { |
| | | if (needGoods == null) |
| | | needGoods = false; |
| | | |
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); |
| | | UserInfoExtra userExtraInfo = userInfoExtraService.getUserInfoExtra(uid); |
| | | String inviteCode = null; |
| | | if (userExtraInfo != null) { |
| | | if (!StringUtil.isNullOrEmpty(userExtraInfo.getInviteCodeVip())) { |
| | | inviteCode = userExtraInfo.getInviteCodeVip(); |
| | | } else { |
| | | inviteCode = userExtraInfo.getInviteCode(); |
| | | } |
| | | } |
| | | String relationId = null; |
| | | if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null |
| | | && extraInfo.getRelationValid() == true) |
| | | relationId = extraInfo.getRelationId(); |
| | | |
| | | if (StringUtil.isNullOrEmpty(relationId)) { |
| | | out.print(JsonUtil.loadFalseResult(3, "淘宝未授权,请前往\"我的\"绑定淘宝账号")); |
| | | return; |
| | | } |
| | | |
| | | // 淘礼金创建分享 |
| | | if (source != null && "taolijin".equals(source)) {// 淘礼金分享创建 |
| | | createTaoLijin(uid, goodsId, totalNum, relationId, request, out); |
| | | return; |
| | | } else {// 普通分享创建 |
| | | createCommonTaoBaoShare(acceptData.getPlatform(), acceptData.getVersion(), goodsId, inviteCode, uid, |
| | | needGoods, relationId, out); |
| | | return; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 淘礼金创建分享 |
| | | * |
| | | * @param uid |
| | | * @param auctionId |
| | | * @param totalNum |
| | | * @param relationId |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId); |
| | | } catch (TaobaoGoodsDownException e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult("商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | if (goods.getTkRate() == null || goods.getTkRate().compareTo(new BigDecimal(0)) <= 0) { |
| | | // TaoKeApiUtil.specialConvertCoupon(auctionId, app); |
| | | |
| | | } |
| | | |
| | | // 计算推广红包 |
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); |
| | | LogHelper.error("推广红包比例:" + warningRate); |
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); |
| | | LogHelper.error("推广红包:" + spreadMoney); |
| | | // 推广红包 不能小于1 |
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘礼金不足")); |
| | | return; |
| | | } |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | shareInfo.setSpreadMoney(" ¥" + spreadMoney.toString()); |
| | | |
| | | String taoLiJinLink = null; |
| | | Long tljId = null; |
| | | try { |
| | | UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods); |
| | | tljId = record.getId(); |
| | | taoLiJinLink = record.getSendUrl(); |
| | | shareInfo.setTljId(tljId.toString()); |
| | | shareInfo.setSurplusMoney(record.getSurplusMoney().toString()); |
| | | } catch (UserTaoLiJinRecordException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY)); |
| | | String shortLink = HttpUtil.getShortLink(url); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | shareInfo.setClickUrl(url); |
| | | |
| | | TaoBaoLink taoBaoLink = new TaoBaoLink(); |
| | | taoBaoLink.setCouponLink(taoLiJinLink); |
| | | taoBaoLink.setClickUrl(taoLiJinLink); |
| | | |
| | | // 创建淘口令 |
| | | if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功 |
| | | String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink); |
| | | if (!StringUtil.isNullOrEmpty(quanToken)) { |
| | | taoBaoLink.setTaoToken(quanToken); |
| | | } |
| | | } |
| | | shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey())); |
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500)); |
| | | |
| | | // 无券 |
| | | String shopType = goods.getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO |
| | | : TaoBaoConstant.SHARE_PRICE_TM; |
| | | String shareText = ""; |
| | | |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey()); |
| | | shareText = text.replace("{标题}", goods.getTitle()).replace("{商品原价}", |
| | | MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + ""); |
| | | } else// 有券 |
| | | { |
| | | String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); |
| | | if (StringUtil.isNullOrEmpty(text)) |
| | | text = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); |
| | | |
| | | shareText = text.replace("{标题}", goods.getTitle()) |
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "") |
| | | .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString()) |
| | | .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString()) |
| | | .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | } |
| | | |
| | | shareText = shareText.replace("{店铺类型}", shopType) |
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{领券短链}", shortLink) |
| | | .replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | 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.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey()); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPicture(array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey())); |
| | | |
| | | // 添加分享记录 |
| | | BigDecimal rate = hongBaoManageService.getShareRate(); |
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate); |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, |
| | | Constant.SOURCE_TYPE_TAOBAO, true); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo))); |
| | | |
| | | final TaoBaoLink taobaoLink = taoBaoLink; |
| | | final TaoBaoGoodsBrief finalGoods = goods; |
| | | // 异步操作 |
| | | 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(UserShareGoodsHistory.TYPE_TAOBAO); |
| | | history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); |
| | | history.setLink(taobaoLink.getClickUrl()); |
| | | history.setQuanLink(taobaoLink.getCouponLink()); |
| | | history.setGoodsId(finalGoods.getAuctionId()); |
| | | history.setPostPicture(finalGoods.getPictUrl()); |
| | | history.setShareImg(taobaoLink.getClickUrl()); |
| | | List<String> imgList = finalGoods.getImgList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + "auctionId:" + auctionId, ""); |
| | | out.print(JsonUtil.loadFalseResult("创建分享出错")); |
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); |
| | | } |
| | | } |
| | | |
| | | public void createCommonTaoBaoShare(String platform, String version, Long goodsId, String inviteCode, Long uid, |
| | | boolean needGoods, String relationId, PrintWriter out) { |
| | | try { |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId); |
| | | |
| | | if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) { |
| | | ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version); |
| | | GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto); |
| | | shareInfo.setGoodsInfo(goodsInfo); |
| | | } |
| | | |
| | | 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); |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) { |
| | | url = shortLink; |
| | | } |
| | | |
| | | shareInfo.setClickUrl(url); |
| | | shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey())); |
| | | shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); |
| | | |
| | | String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey()); |
| | | List<String> commentTexts = new ArrayList<>(); |
| | | if (!StringUtil.isNullOrEmpty(commentTextStr)) { |
| | | JSONArray array = JSONArray.fromObject(commentTextStr); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | if (array.optString(i).contains("[邀请码]")) { |
| | | continue; |
| | | } |
| | | } |
| | | if (StringUtil.isNullOrEmpty(inviteCode)) |
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK) |
| | | .replace("[淘口令]", shareInfo.getToken())); |
| | | else |
| | | commentTexts.add(array.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK) |
| | | .replace("[邀请码]", inviteCode).replace("[淘口令]", shareInfo.getToken())); |
| | | } |
| | | } |
| | | shareInfo.setCommentTexts(commentTexts); |
| | | |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | |
| | | boolean coupon = false; |
| | | if (!StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | coupon = true; |
| | | } |
| | | |
| | | String template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); |
| | | String shareText = shareGoodsTextTemplateService.createContentTB(template, goods, taoBaoLink.getTaoToken(), |
| | | coupon); |
| | | shareInfo.setShareText(shareText); |
| | | |
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); |
| | | if (descText.startsWith("\\r\\n")) { |
| | | descText = descText.substring(0); |
| | | } |
| | | shareInfo.setDescText(deleteBlankLine(descText)); |
| | | |
| | | // 测试 |
| | | // 2.0.2之前 |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) { |
| | | shareInfo.setClickUrl( |
| | | getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | } else if (!VersionUtil.greaterThan_2_0_2(platform, version)) { |
| | | shareInfo.setClickUrl( |
| | | getERCodeContentNew(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | } |
| | | |
| | | // if (VersionUtil.greaterThan_2_0_7(platform, version)) { |
| | | // shareInfo.setWxErCode( |
| | | // getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), |
| | | // taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | // } else { |
| | | shareInfo.setWxErCode(getERCodeContentNew(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | // } |
| | | |
| | | // 提示图文内容 |
| | | String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), platform, |
| | | Integer.parseInt(version)); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | |
| | | shareInfo.setNotifyPicture(array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey())); |
| | | |
| | | // 分享金额 |
| | | BigDecimal rate = hongBaoManageService.getShareRate(); |
| | | BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | |
| | | // 分享id |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, |
| | | Constant.SOURCE_TYPE_TAOBAO, false); |
| | | shareInfo.setShareId(shareRecord.getRedisKey()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) { |
| | | String template2 = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = template2.replace("[商品标题]", goods.getTitle()); |
| | | if (!coupon) { |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | } else { |
| | | if (!StringUtil.isNullOrEmpty(goods.getDescription())) { |
| | | recommendText = recommendText.replace("[推荐语]", goods.getDescription()); |
| | | } else { |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | } |
| | | } |
| | | |
| | | String sales = TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()); |
| | | if (sales.equals("0")) { |
| | | recommendText = recommendText.replace("销量:[销量]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[销量]", sales.replace("万", "w")); |
| | | } |
| | | |
| | | String quickCommentText = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | commentText = quickCommentText.replace("[原价]", goods.getZkPrice().toString()); |
| | | commentText = commentText.replace("[淘口令]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", |
| | | TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[券面额]", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()); |
| | | } |
| | | } else { |
| | | commentText = shareInfo.getShareText(); |
| | | recommendText = shareInfo.getDescText(); |
| | | } |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList( |
| | | getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, TaoBaoUtil.getGoodsHongBaoMoney( |
| | | taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | | |
| | | final TaoBaoLink taobaoLink = taoBaoLink; |
| | | // 异步操作 |
| | | 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(UserShareGoodsHistory.TYPE_TAOBAO); |
| | | history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); |
| | | history.setLink(taobaoLink.getClickUrl()); |
| | | history.setQuanLink(taobaoLink.getCouponLink()); |
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId()); |
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl()); |
| | | List<String> imgList = taobaoLink.getGoods().getImgList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | return; |
| | | } catch (ShareGoodsException e) { |
| | | LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + " goodsId:" + goodsId, ""); |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); |
| | | businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + "")); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 京东创建分享 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param goodsId |
| | | * @param source |
| | | * @param goodsType |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, |
| | | PrintWriter out) { |
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | if (jdGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | // String url = String.format("http://%s%s?uid=%s&id=%s", |
| | | // configService.getH5Host(), |
| | | // Constant.systemCommonConfig.getShareGoodsPagePathJD(), |
| | | // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | // goodsId + ""); |
| | | |
| | | String couponUrl = null; |
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods); |
| | | if (couponInfo != null) { |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | uid + ""); |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | shareInfo.setClickUrl(jumpLink); |
| | | shareInfo.setWxErCode(jumpLink); |
| | | shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkJD.getKey())); |
| | | shareInfo.setPictUrl(jdGoods.getPicUrl()); |
| | | shareInfo.setCommentTexts(new ArrayList<>()); |
| | | |
| | | if (needGoods) |
| | | shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, orderHongBaoMoneyComputeService |
| | | .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))); |
| | | |
| | | boolean hasCoupon = false; |
| | | if (couponInfo != null) { |
| | | hasCoupon = true; |
| | | } |
| | | |
| | | String template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); |
| | | String shareText = shareGoodsTextTemplateService.createContentJD(template, jdGoods, jumpLink, hasCoupon); |
| | | shareInfo.setShareText(shareText); |
| | | |
| | | String descText = shareText.replace(jdGoods.getSkuName(), "").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())); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | |
| | | shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyJD.getKey())); |
| | | |
| | | // 添加分享记录 |
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(); |
| | | BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate); |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, |
| | | Constant.SOURCE_TYPE_JD, 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 = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String template2 = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = template2.replace("[商品标题]", jdGoods.getSkuName()); |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days()); |
| | | if (sales.equals("0")) { |
| | | recommendText = recommendText.replace("销量:[销量]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[销量]", sales.replace("万", "w")); |
| | | } |
| | | |
| | | BigDecimal price = jdGoods.getPrice(); |
| | | JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo(); |
| | | if (pinGouInfo != null) { |
| | | price = pinGouInfo.getPingouPrice(); |
| | | } |
| | | |
| | | String template3 = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); |
| | | commentText = template3.replace("[原价]", BigDecimalUtil.getWithNoZera(price).toString()); |
| | | if (!hasCoupon) { |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | } else { |
| | | recommendText = recommendText.replace("[券面额]", |
| | | BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString()); |
| | | commentText = commentText.replace("[券后价]", |
| | | BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString()); |
| | | } |
| | | commentText = commentText.replace("[链接]", jumpLink); |
| | | } else { |
| | | commentText = shareInfo.getShareText(); |
| | | recommendText = shareInfo.getDescText(); |
| | | } |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, |
| | | JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | | |
| | | // 异步操作 |
| | | final JDGoods goods = jdGoods; |
| | | 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_JD); |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId); |
| | | history.setPostPicture(goods.getPicUrl()); |
| | | history.setShareImg(jumpLink); |
| | | |
| | | List<String> imgList = goods.getImageList(); |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private String deleteBlankLine(String st) { |
| | | return st.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | | } |
| | | |
| | | /** |
| | | * 拼多多分享 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param goodsId |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, |
| | | PrintWriter out) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | // String url = String.format("http://%s%s?uid=%s&id=%s", |
| | | // configService.getH5Host(), |
| | | // Constant.systemCommonConfig.getShareGoodsPagePathPDD(), |
| | | // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), |
| | | // goodsId + ""); |
| | | |
| | | String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); |
| | | |
| | | ShareInfoVO shareInfo = new ShareInfoVO(); |
| | | shareInfo.setClickUrl(jumpLink); |
| | | shareInfo.setWxErCode(jumpLink); |
| | | shareInfo.setCommentTexts(new ArrayList<>()); |
| | | shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkPDD.getKey())); |
| | | shareInfo.setPictUrl(goods.getGoodsImageUrl()); |
| | | if (needGoods) { |
| | | shareInfo |
| | | .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, |
| | | new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), |
| | | hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); |
| | | } |
| | | |
| | | // 创建口令 |
| | | // String token = PinDuoDuoApiUtil.createGenerate(goodsId); |
| | | |
| | | boolean hasCoupon = true; |
| | | if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { |
| | | hasCoupon = false; |
| | | } |
| | | String template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); |
| | | String shareText = shareGoodsTextTemplateService.createContentPDD(template, goods, jumpLink, hasCoupon); |
| | | shareInfo.setShareText(shareText); |
| | | |
| | | String descText = shareText.replace(goods.getGoodsName(), "").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())); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | |
| | | shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey())); |
| | | |
| | | // 添加分享记录 |
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(); |
| | | BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate); |
| | | shareInfo.setShareMoney("¥" + shareMoney.toString()); |
| | | |
| | | try { |
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, |
| | | Constant.SOURCE_TYPE_PDD, 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 = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = qtemplate.replace("[商品标题]", goods.getGoodsName()); |
| | | |
| | | // 总销量 |
| | | String salesTip = goods.getSalesTip(); |
| | | if (StringUtil.isNullOrEmpty(salesTip)) { |
| | | salesTip = "0"; |
| | | } |
| | | if (salesTip.equals("0")) { |
| | | recommendText = recommendText.replace("销量:[销量]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[销量]", salesTip.replace("万", "w")); |
| | | recommendText = recommendText.replace("销量", "总销量"); |
| | | } |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | |
| | | String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); |
| | | commentText = quickCommentText.replace("[原价]", MoneyBigDecimalUtil |
| | | .div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString()); |
| | | commentText = commentText.replace("[链接]", jumpLink); |
| | | if (!hasCoupon) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", |
| | | BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString()); |
| | | |
| | | BigDecimal hundred = new BigDecimal(100); |
| | | BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred); |
| | | recommendText = recommendText.replace("[券面额]", BigDecimalUtil.getWithNoZera(amount).toString()); |
| | | } |
| | | } else { |
| | | commentText = shareInfo.getShareText(); |
| | | recommendText = shareInfo.getDescText(); |
| | | } |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, |
| | | PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); |
| | | |
| | | 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_PDD); |
| | | history.setTkCode(null); |
| | | history.setLink(null); |
| | | history.setQuanLink(null); |
| | | history.setGoodsId(goodsId); |
| | | history.setPostPicture(goods.getGoodsImageUrl()); |
| | | history.setShareImg(jumpLink); |
| | | List<String> imgList = null; |
| | | String[] goodsGalleryUrls = goods.getGoodsGalleryUrls(); |
| | | if (goodsGalleryUrls != null) { |
| | | imgList = Arrays.asList(goodsGalleryUrls); |
| | | } |
| | | if (imgList == null) { |
| | | imgList = new ArrayList<>(); |
| | | } |
| | | history.setPictures(JsonUtil.getGson().toJson(imgList)); |
| | | shareGoodsService.addShareGoodsHistory(history); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 预览分享模板 |
| | | * |
| | | * @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_JD) { |
| | | createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建淘宝分享模板 |
| | | * |
| | | * @param uid |
| | | * @param template |
| | | * @param goodsType |
| | | * @param goodsId |
| | | * @param tljId |
| | | * @param hasCoupon |
| | | * @param out |
| | | */ |
| | | private 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); |
| | | } |
| | | |
| | | // 校验模板是否正确 |
| | | try { |
| | | shareGoodsTextTemplateService.verifyRightTB(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | // 查询是否有分享 |
| | | 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.createContentTB(template, goods, token, 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 |
| | | */ |
| | | private 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); |
| | | } |
| | | |
| | | // 校验券模板是否正确 |
| | | try { |
| | | shareGoodsTextTemplateService.verifyRightJD(template); |
| | | } catch (ShareGoodsTextTemplateException e) { |
| | | out.print(JsonUtil.loadFalseResult(5, e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | String couponUrl = null; |
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods); |
| | | if (couponInfo != null) { |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html"; |
| | | String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", |
| | | uid + ""); |
| | | |
| | | String content = shareGoodsTextTemplateService.createContentJD(template, 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 |
| | | */ |
| | | private 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); |
| | | } |
| | | |
| | | // 校验券模板是否正确 |
| | | try { |
| | | shareGoodsTextTemplateService.verifyRightPDD(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 shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); |
| | | |
| | | // // 创建口令 |
| | | // String token = PinDuoDuoApiUtil.createGenerate(goodsId); |
| | | |
| | | // 生成分享内容 |
| | | String content = shareGoodsTextTemplateService.createContentPDD(template, goods, shortLink, hasCoupon); |
| | | |
| | | 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) { |
| | | template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); |
| | | } |
| | | 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", new Date()))); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey()))); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesJD.getKey()))); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesPDD.getKey()))); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存模板 |
| | | * |
| | | * @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) { |
| | | shareGoodsTextTemplateService.saveTemplateTB(uid, template); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | shareGoodsTextTemplateService.saveTemplateJD(uid, template); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | shareGoodsTextTemplateService.saveTemplatePDD(uid, template); |
| | | } |
| | | } 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) { |
| | | shareGoodsTextTemplateService.resetCommonTemplate(uid); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | shareGoodsTextTemplateService.resetCommonTemplateJD(uid); |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); |
| | | } |
| | | |
| | | if (goodsId != null) { |
| | | viewShareTextTemplate(acceptData, uid, null, goodsType, goodsId, tljId, hasCoupon, out); |
| | | return; |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } |
| | | |
| | | /** |
| | | * 获取分享记录中的商品 分享信息 |
| | | * |
| | | * @param acceptData |
| | | * @param recordId |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getShareGoods") |
| | | public void getShareGoods(AcceptData acceptData, Long recordId, PrintWriter out) { |
| | | |
| | | if (recordId == null) { |
| | | out.print(JsonUtil.loadFalseResult("参数不正确")); |
| | | return; |
| | | } |
| | | |
| | | JSONArray array = new JSONArray(); |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId); |
| | | if (list == null || list.size() == 0) { |
| | | data.put("title", "分享商品"); |
| | | data.put("count", 0); |
| | | data.put("result_list", array); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | // API网络接口验证是否在售 |
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null; |
| | | List<Long> listGid = new ArrayList<Long>(); |
| | | for (UserShareGoodsGroup goodsGroup : list) { |
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods(); |
| | | Integer goodsType = commonGoods.getGoodsType(); |
| | | if (commonGoods == null || goodsType == null || goodsType != Constant.SOURCE_TYPE_TAOBAO) { |
| | | continue; |
| | | } |
| | | listGid.add(commonGoods.getGoodsId()); |
| | | } |
| | | |
| | | if (listGid.size() > 0) { |
| | | try { |
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion()); |
| | | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); |
| | | |
| | | for (UserShareGoodsGroup goodsGroup : list) { |
| | | CommonGoods commonGoods = goodsGroup.getCommonGoods(); |
| | | if (commonGoods == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 验证淘宝商品是否在售 |
| | | Integer goodsType = commonGoods.getGoodsType(); |
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0 && goodsType != null |
| | | && goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | int state = 1; // 默认停售 |
| | | Long goodsId = commonGoods.getGoodsId(); |
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) { |
| | | Long auctionId = taoKeGoods.getAuctionId(); |
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) { |
| | | state = 0; // 在售 |
| | | break; |
| | | } |
| | | } |
| | | commonGoods.setState(state); |
| | | } |
| | | |
| | | // 今日浏览记录处理 |
| | | Date date = new Date(); |
| | | Date browseTime = goodsGroup.getBrowseTime(); |
| | | if (!DateUtil.isSameDay(browseTime, date)) { |
| | | goodsGroup.setTodayBrowse(0); // 不是同一天浏览记录设置0 |
| | | } |
| | | |
| | | JSONObject dataObject = new JSONObject(); |
| | | dataObject.put("todayBrowse", goodsGroup.getTodayBrowse()); |
| | | dataObject.put("totalBrowse", goodsGroup.getTotalBrowse()); |
| | | dataObject.put("totalOrder", goodsGroup.getTotalOrder()); |
| | | dataObject.put("totalMoney", "¥" + goodsGroup.getTotalMoney()); |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO); |
| | | detailVO.setId(commonGoods.getId()); |
| | | dataObject.put("goods", gson.toJson(detailVO)); |
| | | array.add(dataObject); |
| | | } |
| | | |
| | | String title = ""; |
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(recordId); |
| | | if (userShareGoodsRecord != null) { |
| | | title = userShareGoodsRecord.getTitle(); |
| | | } |
| | | |
| | | data.put("title", title); |
| | | data.put("count", list.size()); |
| | | data.put("result_list", array); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping(value = "getShareTextQuick", method = RequestMethod.POST) |
| | | public void getShareTextQuick(AcceptData acceptData, Long goodsId, Integer goodsType, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == null || goodsId == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确的商品信息")); |
| | | return; |
| | | } |
| | | |
| | | GoodsDetailVO goodsDetail = null; |
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null) { |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | goods = null; |
| | | } |
| | | } |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); |
| | | } |
| | | } |
| | | |
| | | if (goodsDetail == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | template = template.replace("[商品标题]", goodsDetail.getTitle()).replace("[销量]", goodsDetail.getSalesCount()); |
| | | if (!StringUtil.isNullOrEmpty(goodsDetail.getDescription())) { |
| | | template = template.replace("[推荐语]", goodsDetail.getDescription()); |
| | | } else { |
| | | template = template.replace("推荐语:[推荐语]", ""); |
| | | } |
| | | |
| | | if (goodsDetail.isHasCoupon()) { |
| | | template = template.replace("[券面额]", |
| | | String.format("满%s元减%s元", |
| | | MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponInfo().getStartFee()).toString(), |
| | | MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponInfo().getAmount()).toString())); |
| | | } else { |
| | | template = template.replace("优惠券:[券面额]", ""); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("description", template); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |