| | |
| | | package com.yeshi.fanli.controller.client.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.fasterxml.jackson.core.util.VersionUtil;
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | 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.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.dynamic.DynamicInfo;
|
| | | import com.yeshi.fanli.entity.dynamic.GoodsPicture;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | data.put("rule", configService.get("share_single_goods_rule"));
|
| | | data.put("rule", configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String shareText = "";
|
| | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
|
| | | 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");
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
|
| | |
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
|
| | | .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
|
| | |
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | //
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | |
| | | 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");
|
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | // 无券
|
| | |
| | | if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
|
| | | String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(text))
|
| | | text = configService.get("goods_share_text_nocoupon");
|
| | | text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
|
| | | shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}",
|
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
|
| | | } else// 有券
|
| | |
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | |
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | |
| | | List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>();
|
| | |
|
| | | long count = userShareGoodsRecordService.countQueryByUid(uid, source);
|
| | |
|
| | | if (count > 0) {
|
| | | list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source);
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("result_list", list);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | // 保留2位小数
|
| | | value = value.setScale(2);
|
| | | return new JsonPrimitive(value.toString());
|
| | | }
|
| | | }
|
| | | });
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("result_list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | |
| | | } else {
|
| | | String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configService.get("goods_share_text_coupon");
|
| | | template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
|
| | | return template;
|
| | | }
|
| | |
|
| | | } else {
|
| | | String template = shareGoodsTextTemplateService.getCommonTemplate(uid);
|
| | | if (StringUtil.isNullOrEmpty(template))
|
| | | template = configService.get("goods_share_text_nocoupon");
|
| | | template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
|
| | | return template;
|
| | | }
|
| | | }
|
| | |
| | | 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")));
|
| | | out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey())));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString());
|
| | |
|
| | | // 分享提醒
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | | data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
|
| | |
|
| | | // 分享提示语
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size()) {
|
| | |
| | |
|
| | | // 帮助链接
|
| | | data.put("helpLink",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | |
|
| | | if (cid == 2) { // 2 推荐好货
|
| | | ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid,
|
| | |
| | | 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("clickUrl",
|
| | | ShareControllerV2.getERCodeContentNew(
|
| | | configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods,
|
| | | taoBaoLink.getTaoToken()));
|
| | |
|
| | | data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
|
| | | |
| | | String inviteCode=null;
|
| | | UserInfoExtra extra= userInfoExtraService.getUserInfoExtra(uid);
|
| | | if(extra!=null)
|
| | | inviteCode=extra.getInviteCode();
|
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | // 测试
|
| | | 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("[邀请码]"))
|
| | | {
|
| | | String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
|
| | | 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")));
|
| | | 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")));
|
| | | 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()));
|
| | | data.put("wxErCode",
|
| | | ShareControllerV2.getERCodeContentNew(
|
| | | configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods,
|
| | | taoBaoLink.getTaoToken()));
|
| | | }
|
| | |
|
| | | } else if (cid == 4) { // 邀请分享
|
| | |
|
| | | String inviteCode = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | inviteCode = userInfoExtra.getInviteCode();
|
| | | } else {
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | out.print(JsonUtil.loadFalseResult(9001, "邀请码未激活"));
|
| | | return;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | | title = title.replace("【邀请码】", inviteCode);
|
| | | title = title.replace("【邀请链接】", UserUtil.getInviteShortLink(uid));
|
| | | title = title.replace("【邀请链接】", Constant.YINGYONGBAO_LINK);
|
| | | data.put("title", title);
|
| | |
|
| | | } else { // 有图分享
|
| | |
| | | String valueBr = valueN.replace("\n", "<br><br>");
|
| | | data.put("inviteRules", valueBr);
|
| | |
|
| | | // 邀请链接
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
|
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | data.put("inviteLink", shortLink);
|
| | | data.put("inviteLink", Constant.YINGYONGBAO_LINK);
|
| | | data.put("inviteCode", inviteCode);
|
| | | data.put("helpLink", configService.get("invite_help_link"));
|
| | | data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|