| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.fasterxml.jackson.core.util.VersionUtil;
|
| | | import com.yeshi.fanli.controller.client.v2.ShareControllerV2;
|
| | | 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.taobao.TaoBaoGoodsBriefExtra;
|
| | | 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.share.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
|
| | |
| | | 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.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.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.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | }
|
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | data.put("rule", configService.getConfig("share_single_goods_rule"));
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | data.put("rule", configService.get("share_single_goods_rule"));
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String shareText = "";
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
|
| | | : TaoBaoConstant.SHARE_PRICE_TM;
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | |
| | |
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | data.put("shareText", shareText);
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | |
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
|
| | | Constant.SOURCE_TYPE_TAOBAO, false);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | |
| | | history.setHongbao(shareMoney);
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(taobaoLink.getTaoToken());
|
| | | history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
|
| | | history.setLink(taobaoLink.getClickUrl());
|
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId());
|
| | |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
|
| | |
|
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value");
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", null);
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
|
| | |
|
| | | // 推广红包 不能小于1
|
| | |
| | | taoBaoLink.setTaoToken(quanToken);
|
| | | }
|
| | | }
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | |
|
| | | data.put("rule",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | // 无券
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
|
| | | String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
|
| | | : TaoBaoConstant.SHARE_PRICE_TM;
|
| | | String shareText = "";
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | |
| | | {
|
| | | String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configTaoLiJinService.getValueByKey("goods_share_text");
|
| | | text = configTaoLiJinService.getValueByKey("goods_share_text", new Date());
|
| | |
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
|
| | |
| | |
|
| | | shareText = shareText.replace("{店铺类型}", shopType)
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
|
| | | .replace("{领券短链}", shortLink).replace("{淘口令}", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | data.put("shareText", shareText);
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | |
| | |
|
| | | data.put("shareMoney", "¥" + shareMoney.toString());
|
| | | try {
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId);
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
|
| | | Constant.SOURCE_TYPE_TAOBAO, true);
|
| | | data.put("shareId", shareRecord.getRedisKey());
|
| | | } catch (Exception e) {
|
| | | try {
|
| | |
| | | history.setHongbao(shareMoney);
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
|
| | | history.setTkCode(taobaoLink.getTaoToken());
|
| | | history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
|
| | | history.setLink(taobaoLink.getClickUrl());
|
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId());
|
| | |
| | | @RequestMapping(value = "sharedetail", method = RequestMethod.POST)
|
| | | public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) {
|
| | | try {
|
| | | userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId);
|
| | | userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
|
| | | out.print(JsonUtil.loadTrueResult("分享成功"));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(shareId)) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 更新分享生效
|
| | |
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | userShareGoodsRecordService.takeEffectShareRecord(shareId);
|
| | | userShareGoodsRecordService.takeEffectShareRecord(acceptData, shareId);
|
| | | } catch (UserShareGoodsRecordException eu) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(eu);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | if (tljId != null) {
|
| | | String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configTaoLiJinService.getValueByKey("goods_share_text");
|
| | | template = configTaoLiJinService.getValueByKey("goods_share_text", new Date());
|
| | | return template;
|
| | | } else {
|
| | | String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | |
| | | @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST)
|
| | | public void getShareTextTemplateRules(AcceptData acceptData, Long tljId, PrintWriter out) {
|
| | | if (tljId != null) {
|
| | | out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules")));
|
| | | out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date())));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
|
| | | }
|
| | |
| | | if (cid == 1 || cid == 2) { // 1 热销单品 2 推荐好货
|
| | | if (cid == 1) {
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | if (imgs == null || imgs.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | GoodsPicture goodsPicture = imgs.get(0);
|
| | | if (goodsPicture.getGoodState() == 1) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | } else {
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | try {
|
| | | TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goods.getState() != null && goods.getState() == 1) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!goods.isCoupon()) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | out.print(JsonUtil.loadFalseResult("该商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | } else {
|
| | | List<GoodsPicture> imgs = dynamicInfo.getImgs();
|
| | | if (imgs == null || imgs.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("所有商品已抢光"));
|
| | | return;
|
| | | }
|
| | |
|
| | | int count = 0;
|
| | | for (GoodsPicture goodsPicture : imgs) {
|
| | | if (goodsPicture.getGoodState() == 1) {
|
| | | count++;
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | if (goods == null) {
|
| | | count++;
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (goods.getState() != null && goods.getState() == 1) {
|
| | | count++;
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (!goods.isCoupon()) {
|
| | | count++;
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | | if (count >= imgs.size()) {
|
| | | out.print(JsonUtil.loadFalseResult("所有商品已抢光"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | title = "给你推荐精选好物优惠券,购物前先领券,别错过优惠哦~";
|
| | | }
|
| | | data.put("title", title);
|
| | | data.put("content", "我在返利券发现了一个很好的商品,快来看看~");
|
| | | data.put("content", String.format("我在%s发现了一个很好的商品,快来看看~",
|
| | | Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
|
| | |
|
| | | // 分享奖金
|
| | | ClientTextStyleVO desc = dynamicInfo.getDesc();
|
| | |
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | |
|
| | | data.put("clickUrl", url);
|
| | |
|
| | | // 淘宝口令
|
| | |
| | | relationId = extraInfo.getRelationId();
|
| | | }
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
|
| | | if (!com.yeshi.fanli.util.VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(),
|
| | | acceptData.getVersion()))
|
| | | data.put("clickUrl", ShareControllerV2.getERCodeContent(goods, taoBaoLink.getTaoToken()));
|
| | |
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | |
| | | String inviteCode=null;
|
| | | UserInfoExtra extra= userInfoExtraService.getUserInfoExtra(uid);
|
| | | if(extra!=null)
|
| | | inviteCode=extra.getInviteCode();
|
| | | // 测试
|
| | | List<String> commentTexts = new ArrayList<>();
|
| | | String commentTextStr= configService.get("share_single_goods_comment_text");
|
| | | if(!StringUtil.isNullOrEmpty(commentTextStr))
|
| | | {
|
| | | JSONArray arr= JSONArray.fromObject(commentTextStr);
|
| | | for(int i=0;i<arr.size();i++)
|
| | | {
|
| | | if(StringUtil.isNullOrEmpty(inviteCode))
|
| | | {
|
| | | if(arr.optString(i).contains("[邀请码]"))
|
| | | {
|
| | | continue;
|
| | | }
|
| | | }
|
| | | if(StringUtil.isNullOrEmpty(inviteCode))
|
| | | commentTexts.add(arr.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK).replace("[淘口令]", data.optString("token")));
|
| | | else
|
| | | commentTexts.add(arr.optString(i).replace("[下载链接]", Constant.YINGYONGBAO_LINK).replace("[邀请码]", inviteCode).replace("[淘口令]", data.optString("token")));
|
| | | }
|
| | | }
|
| | | data.put("commentTexts", commentTexts);
|
| | | data.put("wxErCode", ShareControllerV2.getERCodeContent(goods, taoBaoLink.getTaoToken()));
|
| | | }
|
| | |
|
| | | } else if (cid == 4) { // 邀请分享
|
| | |
| | | }
|
| | | }
|
| | | title = title.replace("【邀请码】", inviteCode);
|
| | | title = title.replace("【邀请链接】", UserUtil.getInviteShortLink(uid));
|
| | | title = title.replace("【邀请链接】", Constant.YINGYONGBAO_LINK);
|
| | | data.put("title", title);
|
| | |
|
| | | } else { // 有图分享
|