From 26b5b1a6bbbb5ff64dc2ec73cf8b11f1aa61c1c5 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 14 五月 2019 11:03:25 +0800 Subject: [PATCH] Merge branch 'div_8' --- fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java | 565 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 541 insertions(+), 24 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java index 4f69a9a..8e1e161 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java @@ -9,9 +9,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -19,24 +16,56 @@ import org.yeshi.utils.JsonUtil; import org.yeshi.utils.taobao.TbImgUtil; +import com.yeshi.fanli.dto.share.ShareInfoDTO; 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.share.UserShareGoodsRecord.ShareSourceTypeEnum; +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.SystemClientParams; +import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; +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.UserShareGoodsRecordException; +import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; 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.MonitorService; +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.account.UserUtil; +import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; import com.yeshi.fanli.util.factory.MonitorFactory; import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; +import com.yeshi.fanli.vo.msg.ClientTextStyleVO; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; @Controller(value = "ShareController1") @RequestMapping("api/v1/share") @@ -53,12 +82,43 @@ @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 RedisManager redisManager; + + @Resource + private ShareGoodsTextTemplateService shareGoodsTextTemplateService; + + @Resource + private SystemClientParamsService systemClientParamsService; + + @Resource + private DynamicInfoService dynamicInfoService; + + @Resource + private UserInfoExtraService userInfoExtraService; + + @Resource + private SpreadUserImgService spreadUserImgService; + // 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴 @RequestMapping(value = "getGoodsShareUrl") @@ -84,16 +144,27 @@ 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 (auctionId == null || auctionId <= 0) { out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖")); return; } + UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); try { - TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId); + String relationId = null; + if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null + && extraInfo.getRelationValid() == true) + relationId = extraInfo.getRelationId(); + TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId); JSONObject data = new JSONObject(); - String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(), + String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + ""); @@ -113,19 +184,28 @@ String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�"; if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { - String text = configService.get("goods_share_text_nocoupon"); - shareText = text.replace("[鏍囬]", taoBaoLink.getGoods().getTitle()).replace("[鍦ㄥ敭浠穄", - "楼" + taoBaoLink.getGoods().getZkPrice()); + 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 = configService.get("goods_share_text_coupon"); - shareText = text.replace("[鏍囬]", taoBaoLink.getGoods().getTitle()) - .replace("[鍦ㄥ敭浠穄", "楼" + taoBaoLink.getGoods().getZkPrice()) - .replace("[鍒稿悗浠穄", "楼" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods())); + 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); + shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) + .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) + .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken()); data.put("shareText", shareText); - String descText = shareText.replace(taoBaoLink.getGoods().getTitle() + "\r\n", ""); + String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); if (descText.startsWith("\\r\\n")) descText = descText.substring(0); data.put("descText", descText); @@ -138,7 +218,7 @@ data.put("notifyDesc", configService.get("goods_share_notify")); // 娣诲姞鍒嗕韩璁板綍 - BigDecimal rate = new BigDecimal(hongBaoManageService.get("hongbao_goods_proportion")); + BigDecimal rate = hongBaoManageService.getShareRate(); UserShareGoodsHistory history = new UserShareGoodsHistory(); history.setTkCode(taoBaoLink.getTaoToken()); history.setLink(taoBaoLink.getClickUrl()); @@ -155,6 +235,8 @@ history.setPictures(JsonUtil.getGson().toJson(imgList)); history.setUser(new UserInfo(uid)); history.setPostPicture(taoBaoLink.getGoods().getPictUrl()); + + data.put("shareMoney", "楼" + history.getHongbao().toString()); out.print(JsonUtil.loadTrueResult(data)); @@ -176,11 +258,13 @@ } } - + /** * 鍒嗕韩璁板綍缁熻鍒楄〃 + * * @param acceptData - * @param page 鍒濆1 + * @param page + * 鍒濆1 * @param uid * @param source * @param out @@ -196,6 +280,10 @@ out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); } + if ("all".equals(source)) { + source = null;// 鏌ヨ鍏ㄩ儴 + } + try { int pageSize = Constant.PAGE_SIZE; @@ -203,7 +291,7 @@ List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>(); long count = userShareGoodsRecordService.countQueryByUid(uid, source); - + if (count > 0) { list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source); } @@ -218,9 +306,9 @@ } } - /** * 鑾峰彇鍒嗕韩鍟嗗搧 + * * @param acceptData * @param recordId * @param out @@ -233,16 +321,17 @@ } try { - JSONObject data = userShareGoodsGroupService.getGoodsGroup(recordId); + JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId); out.print(JsonUtil.loadTrueResult(data)); } catch (Exception e) { out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); e.printStackTrace(); } } - + /** * 鑾峰彇鍒嗕韩鍟嗗搧鍗曚釜缁熻淇℃伅 + * * @param acceptData * @param groupId * @param out @@ -262,7 +351,7 @@ userShareGoodsGroup.setUpdateTime(null); userShareGoodsGroup.setRecordId(null); } - + JSONObject data = new JSONObject(); data.put("goodsData", userShareGoodsGroup); out.print(JsonUtil.loadTrueResult(data)); @@ -271,6 +360,434 @@ e.printStackTrace(); } } + + /** + * 鍟嗗搧璇︽儏鍒嗕韩 + * + * @param acceptData + * @param uid + * 鐢ㄦ埛id + * @param auctionId + * 鍟嗗搧id + * @param type + * 鍥剧墖鍒嗕韩绫诲瀷 鍗曞浘single 澶氬浘many + * @param out + */ + @RequestMapping(value = "sharedetail", method = RequestMethod.POST) + public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) { + try { + userShareGoodsRecordService.saveDetail(uid, auctionId, type); + out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛")); + } catch (UserShareGoodsRecordException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鏇存柊鍒嗕韩璁板綍 + * + * @param acceptData + * @param shareId + * @param out + */ + @RequestMapping(value = "updaterecord", method = RequestMethod.POST) + public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) { + if (shareId == null) { + out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�")); + } + + try { + userShareGoodsRecordService.updateShareRecord(shareId); + out.print(JsonUtil.loadTrueResult("")); + } catch (UserShareGoodsRecordException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); + e.printStackTrace(); + } + } + + /** + * 棰勮鍒嗕韩妯℃澘 + * + * @param acceptData + * @param uid + * @param template + * @param goodsId + * @param hasCoupon + * @param out + */ + @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST) + public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId, + Boolean hasCoupon, PrintWriter out) { + if (uid == null) { + out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + + if (goodsId == null) { + out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧ID涓嶈兘涓虹┖")); + return; + } + + 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(uid, hasCoupon); + + // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� + if (hasCoupon) { + // 鏈夊埜鍟嗗搧 + 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; + } + } + + // 鏌ヨ鏄惁鏈夊垎浜� + UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId()); + String 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); + 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); + JSONObject data = new JSONObject(); + data.put("content", content); + out.print(JsonUtil.loadTrueResult(data)); + } + + /** + * 淇濆瓨妯℃澘 + * + * @param acceptData + * @param uid + * @param hasCoupon + * @param template + * @param out + */ + @RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST) + public void saveShareTextTemplate(AcceptData acceptData, Long uid, Boolean hasCoupon, String template, + PrintWriter out) { + if (StringUtil.isNullOrEmpty(template)) { + out.print(JsonUtil.loadFalseResult(1, "鍒嗕韩妯℃澘涓虹┖")); + return; + } + // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� + if (hasCoupon) { + // 鏈夊埜鍟嗗搧 + try { + shareGoodsTextTemplateService.isCouponTemplateRight(template); + shareGoodsTextTemplateService.saveCouponTemplate(uid, template); + out.print(JsonUtil.loadTrueResult("")); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + + } else { + // 鏅�氬晢鍝� + try { + shareGoodsTextTemplateService.isCommonTemplateRight(template); + shareGoodsTextTemplateService.saveCommonTemplate(uid, template); + out.print(JsonUtil.loadTrueResult("")); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + } + + } + + /** + * 杩樺師妯℃澘 + * + * @param acceptData + * @param uid + * @param hasCoupon + * -鏄惁鏈夊埜 + * @param out + */ + @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) + public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Boolean hasCoupon, + PrintWriter out) { + if (uid == null) { + out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + if (hasCoupon) { + shareGoodsTextTemplateService.resetCouponTemplate(uid); + } else { + shareGoodsTextTemplateService.resetCommonTemplate(uid); + } + + if (goodsId != null) { + preViewShareTextTemplate(acceptData, uid, null, goodsId, hasCoupon, out); + return; + } + + out.print(JsonUtil.loadTrueResult("")); + } + + private String getShareTemplate(Long uid, boolean hasCoupon) { + if (hasCoupon) { + String template = shareGoodsTextTemplateService.geteCouponTemplate(uid); + if (StringUtil.isNullOrEmpty(template)) + template = configService.get("goods_share_text_coupon"); + return template; + } else { + String template = shareGoodsTextTemplateService.getCommonTemplate(uid); + if (StringUtil.isNullOrEmpty(template)) + template = configService.get("goods_share_text_nocoupon"); + return template; + } + } + + /** + * 鑾峰彇鍒嗕韩妯℃澘 + * + * @param acceptData + * @param uid + * @param hasCoupon + * @param out + */ + @RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST) + public void getShareTextTemplate(AcceptData acceptData, Long uid, Boolean hasCoupon, PrintWriter out) { + if (uid == null) { + out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + JSONObject data = new JSONObject(); + data.put("template", getShareTemplate(uid, hasCoupon)); + out.print(JsonUtil.loadTrueResult(data)); + } + + /** + * 鑾峰彇鍒嗕韩妯℃澘缂栬緫瑙勫垯 + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST) + public void getShareTextTemplateRules(AcceptData acceptData, PrintWriter out) { + out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules"))); + } + + + /** + * 鏌ヨ椤堕儴鍒嗙被 + * @param acceptData + * @param page + * @param cid + * @param out + */ + @RequestMapping(value = "shareDynamic", method = RequestMethod.POST) + public void shareDynamic(AcceptData acceptData, String id, Long uid, PrintWriter out) { + try { + + if (uid == null || uid <= 0) { + out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); + return; + } + + if (StringUtil.isNullOrEmpty(id)) { + out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶈兘涓虹┖")); + return; + } + + DynamicInfo dynamicInfo = dynamicInfoService.getById(id); + if (dynamicInfo == null) { + out.print(JsonUtil.loadFalseResult("璇ュ姩鎬佷俊鎭凡涓嶅瓨鍦�")); + return; + } + + JSONObject data = new JSONObject(); + + // 鍒嗙被id + long cid = dynamicInfo.getClassId(); + + if (cid == 1) { // 鐑攢鍗曞搧 + // 鏂囧瓧鍐呭 + data.put("title", JsonUtil.getApiCommonGson().toJson(dynamicInfo.getTitle())); + // 鍒嗕韩濂栭噾 + ClientTextStyleVO desc = dynamicInfo.getDesc(); + String content = desc.getContent(); + int index = content.indexOf("楼"); + data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length()))); + + // 鍒嗕韩閾炬帴 + String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s", + configService.getH5Host(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), id, "dynamic"); + String shortLink = HttpUtil.getShortLink(url); + if (!StringUtil.isNullOrEmpty(shortLink)) { + url = shortLink; + } + data.put("clickUrl", url); + // 鍒嗕韩鏂囧瓧鍥炬爣 + String imgs = configService.get("goods_share_notify_imgs"); + JSONArray array = JSONArray.fromObject(imgs); + int p = (int) (array.size() * Math.random()); + if (p < array.size()) { + data.put("notifyPicture", array.optString(p)); + } + + UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); + String relationId = null; + if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null + && extraInfo.getRelationValid() == true) { + relationId = extraInfo.getRelationId(); + } + TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, 42472466270L, relationId); + + // 娣樺疂鍙d护 + data.put("token", taoBaoLink.getTaoToken()); + // 鍟嗗搧鍥剧墖閾炬帴 + data.put("shareLink", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); + // 甯姪閾炬帴 + data.put("helpLink","https://img.alicdn.com/imgextra/i1/2200656425615/O1CN01dst9HQ1rLiPN7xmhD_!!0-item_pic.jpg"); + // 鍒嗕韩鎻愰啋 + data.put("notifyDesc", configService.get("goods_share_notify")); + + } else if (cid == 2) { // 鎺ㄨ崘濂借揣 + + List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>(); + List<GoodsPicture> listImgs = dynamicInfo.getImgs(); + for (GoodsPicture goodsPicture: listImgs) { + TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); + listGoods.add(goods); + } + + String title = ""; + List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); + for (ClientTextStyleVO textStyleVO: listTitle) { + title = title + textStyleVO.getContent(); + } + + if (title.length() > 250) { + title = title.substring(0, 250); + } + + // 鏂囧瓧鍐呭 + data.put("title", JsonUtil.getApiCommonGson().toJson(dynamicInfo.getTitle())); + // 鍒嗕韩濂栭噾 + ClientTextStyleVO desc = dynamicInfo.getDesc(); + String content = desc.getContent(); + int index = content.indexOf("楼"); + data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length()))); + // 鍒嗕韩鏂囧瓧鍥炬爣 + String notifyImgs = configService.get("goods_share_notify_imgs"); + JSONArray array = JSONArray.fromObject(notifyImgs); + int p = (int) (array.size() * Math.random()); + if (p < array.size()) { + data.put("notifyPicture", array.optString(p)); + } + + ShareInfoDTO shareInfo = userShareGoodsRecordService.saveShareRecord(uid, ShareSourceTypeEnum.activity, title, listGoods); + data.put("shareId", shareInfo.getShareId()); + data.put("clickUrl", shareInfo.getCodeUrl()); + // 鍟嗗搧鍥剧墖閾炬帴 + data.put("shareLink", shareInfo.getShareUrl()); + // 甯姪閾炬帴 + data.put("helpLink","https://img.alicdn.com/imgextra/i1/2200656425615/O1CN01dst9HQ1rLiPN7xmhD_!!0-item_pic.jpg"); + // 鍒嗕韩鎻愰啋 + data.put("notifyDesc", configService.get("goods_share_notify")); + + } else if (cid == 4) { // 閭�璇峰垎浜� + + String inviteCode = null; + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); + if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { + inviteCode = userInfoExtra.getInviteCode(); + } else { + out.print(JsonUtil.loadFalseResult(9001, "閭�璇风爜鏈縺娲�")); + return; + } + + Integer showType = dynamicInfo.getShowType(); + if (showType == 0) { // 鏃犲浘鍒嗕韩 + String shortLink = UserUtil.getInviteShortLink(uid); + List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); + for (ClientTextStyleVO textStyleVO: listTitle) { + String content = textStyleVO.getContent(); + content = content.replace("閭�璇风爜", inviteCode); + content = content.replace("閭�璇烽摼鎺�", shortLink); + textStyleVO .setContent(content); + } + data.put("title", listTitle); + + } else { // 鏈夊浘鍒嗕韩 + // 1銆侀個璇疯鍒� + BusinessSystem system = new BusinessSystem(); + system.setCreatetime(java.lang.System.currentTimeMillis()); + system.setPlatform(1); + system.setId(4L); + String key = "inviteRules"; // key鍊� + SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key); + String valueN = values.getValue(); + 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); + + // 閭�璇峰浘鐗� + List<GoodsPicture> imgs = dynamicInfo.getImgs(); + String imgLink = spreadUserImgService.getUserSpreadImg(uid, imgs.get(0).getUrl()); + data.put("imgLink", imgLink); + } + } + out.print(JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩璁板綍澶辫触")); + e.printStackTrace(); + } + } } -- Gitblit v1.8.0