From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 30 七月 2019 09:07:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java | 637 ++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 449 insertions(+), 188 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java index 5d3b2a2..59591ae 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java @@ -17,12 +17,12 @@ import org.yeshi.utils.JsonUtil; import org.yeshi.utils.taobao.TbImgUtil; -import com.yeshi.fanli.dto.share.ShareInfoDTO; +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.share.UserShareGoodsRecord.ShareSourceTypeEnum; +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; @@ -38,6 +38,7 @@ 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.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; @@ -46,7 +47,10 @@ 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; @@ -64,6 +68,7 @@ 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.util.taobao.TaoLiJinUtil; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; import net.sf.json.JSONArray; @@ -75,7 +80,7 @@ @Resource(name = "taskExecutor") private TaskExecutor executor; - + @Resource private ShareGoodsService shareGoodsService; @@ -111,19 +116,27 @@ @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; // 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴 @RequestMapping(value = "getGoodsShareUrl") @@ -142,8 +155,9 @@ * @param out */ @RequestMapping(value = "gettaobaosharelink") - public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request, - PrintWriter out) { + public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, String source, Integer totalNum, + HttpServletRequest request, PrintWriter out) { + if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); return; @@ -161,11 +175,22 @@ } 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, auctionId, totalNum, relationId, request, out); + return; + } + try { - 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(); @@ -180,8 +205,7 @@ data.put("clickUrl", url); data.put("token", taoBaoLink.getTaoToken()); - data.put("rule", - "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); + data.put("rule", configService.get("share_single_goods_rule")); data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); String shareText = ""; @@ -206,6 +230,7 @@ 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()); @@ -225,28 +250,38 @@ // 娣诲姞鍒嗕韩璁板綍 BigDecimal rate = hongBaoManageService.getShareRate(); BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); - + data.put("shareMoney", "楼" + shareMoney.toString()); - data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId)); + try { + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId); + data.put("shareId", shareRecord.getRedisKey()); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } out.print(JsonUtil.loadTrueResult(data)); + 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(); + 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<>(); } @@ -255,17 +290,182 @@ } }); return; - } catch (UserShareGoodsRecordException e) { - out.print(JsonUtil.loadFalseResult(e.getMsg())); - e.printStackTrace(); } catch (ShareGoodsException e) { + LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, ""); + // 鍒嗕韩鍑洪敊鎶ヨ try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊")); } catch (Exception e1) { } out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); + businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); } + } + /** + * 娣樼ぜ閲戝垱寤哄垎浜� + * + * @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 { + TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId); + + TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); + + // 璁$畻鎺ㄥ箍绾㈠寘 + String warningRate = configTaoLiJinService.getValueByKey("warning_value"); + BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); + + // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1 + if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { + out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻")); + return; + } + + JSONObject data = new JSONObject(); + data.put("spreadMoney", " 楼" + spreadMoney.toString()); + + String taoLiJinLink = null; + Long tljId = null; + try { + UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods); + tljId = record.getId(); + taoLiJinLink = record.getSendUrl(); + data.put("tljId", tljId); + data.put("surplusMoney", record.getSurplusMoney()); + } 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; + } + data.put("clickUrl", url); + + // 鍒涘缓娣樺彛浠� + if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 閫氳繃绔嬪嵆鎺ㄥ箍鏂瑰紡鑾峰彇娣樺彛浠ゆ垚鍔� + String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink); + if (!StringUtil.isNullOrEmpty(quanToken)) { + taoBaoLink.setTaoToken(quanToken); + } + } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) { + String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), + taoBaoLink.getClickUrl()); + if (!StringUtil.isNullOrEmpty(quanToken)) { + taoBaoLink.setTaoToken(quanToken); + } + } + data.put("token", taoBaoLink.getTaoToken()); + + data.put("rule", + "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); + data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); + + // 鏃犲埜 + String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�"; + String shareText = ""; + + 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.getTaoLiJinTemplate(uid); + if (StringUtil.isNullOrEmpty(text)) + text = configTaoLiJinService.getValueByKey("goods_share_text"); + + shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()) + .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") + .replace("{浼樻儬鍒搁潰棰潁", + MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) + .replace("{娣樼ぜ閲戦潰棰潁", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString()) + .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); + } + + 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(), "").trim(); + if (descText.startsWith("\\r\\n")) + descText = descText.substring(0); + data.put("descText", descText); + + String imgs = configService.get("goods_share_notify_imgs"); + JSONArray array = JSONArray.fromObject(imgs); + int p = (int) (array.size() * Math.random()); + if (p < array.size()) + data.put("notifyPicture", array.optString(p)); + data.put("notifyDesc", configService.get("goods_share_notify")); + + // 娣诲姞鍒嗕韩璁板綍 + BigDecimal rate = hongBaoManageService.getShareRate(); + BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); + + data.put("shareMoney", "楼" + shareMoney.toString()); + try { + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId); + data.put("shareId", shareRecord.getRedisKey()); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + out.print(JsonUtil.loadTrueResult(data)); + + 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 + "auctionId:" + auctionId, ""); + // 鍒嗕韩鍑洪敊鎶ヨ + try { + monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊")); + } catch (Exception e1) { + } + out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); + businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); + } } /** @@ -385,7 +585,7 @@ @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); + userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId); out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛")); } catch (UserShareGoodsRecordException e) { out.print(JsonUtil.loadFalseResult(e.getMsg())); @@ -404,21 +604,33 @@ * @param out */ @RequestMapping(value = "updaterecord", method = RequestMethod.POST) - public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) { - if (shareId == null) { + public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) { + if (StringUtil.isNullOrEmpty(shareId)) { 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(); - } + // 鏇存柊鍒嗕韩鐢熸晥 + executor.execute(new Runnable() { + @Override + public void run() { + try { + userShareGoodsRecordService.takeEffectShareRecord(shareId); + } catch (UserShareGoodsRecordException eu) { + try { + LogHelper.errorDetailInfo(eu); + } catch (Exception e) { + e.printStackTrace(); + } + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + }); + out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛")); } /** @@ -432,7 +644,7 @@ * @param out */ @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST) - public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId, + public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId, Long tljId, Boolean hasCoupon, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); @@ -458,18 +670,26 @@ } if (StringUtil.isNullOrEmpty(template)) - template = getShareTemplate(uid, hasCoupon); + template = getShareTemplate(uid, hasCoupon, tljId); // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� if (hasCoupon) { // 鏈夊埜鍟嗗搧 - try { - shareGoodsTextTemplateService.isCouponTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; + 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 { @@ -480,12 +700,24 @@ } } + 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 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(); @@ -504,7 +736,7 @@ : goodsLink.getCouponLink()); } String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink, - hasCoupon); + hasCoupon, tljId); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); @@ -520,7 +752,7 @@ * @param out */ @RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST) - public void saveShareTextTemplate(AcceptData acceptData, Long uid, Boolean hasCoupon, String template, + public void saveShareTextTemplate(AcceptData acceptData, Long uid, Long tljId, Boolean hasCoupon, String template, PrintWriter out) { if (StringUtil.isNullOrEmpty(template)) { out.print(JsonUtil.loadFalseResult(1, "鍒嗕韩妯℃澘涓虹┖")); @@ -529,15 +761,25 @@ // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� 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; + if (tljId != null) { + try { + shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); + shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template); + out.print(JsonUtil.loadTrueResult("")); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + } else { + 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 { @@ -562,32 +804,45 @@ * @param out */ @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) - public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Boolean hasCoupon, + public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); return; } + if (hasCoupon) { - shareGoodsTextTemplateService.resetCouponTemplate(uid); + if (tljId != null) { + shareGoodsTextTemplateService.resetTaoLijinTemplate(uid); + } else { + shareGoodsTextTemplateService.resetCouponTemplate(uid); + } } else { shareGoodsTextTemplateService.resetCommonTemplate(uid); } if (goodsId != null) { - preViewShareTextTemplate(acceptData, uid, null, goodsId, hasCoupon, out); + preViewShareTextTemplate(acceptData, uid, null, goodsId, tljId, hasCoupon, out); return; } out.print(JsonUtil.loadTrueResult("")); } - private String getShareTemplate(Long uid, boolean hasCoupon) { + private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId) { if (hasCoupon) { - String template = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configService.get("goods_share_text_coupon"); - return template; + if (tljId != null) { + String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); + if (StringUtil.isNullOrEmpty(template)) + template = configTaoLiJinService.getValueByKey("goods_share_text"); + return template; + } else { + 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)) @@ -605,13 +860,19 @@ * @param out */ @RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST) - public void getShareTextTemplate(AcceptData acceptData, Long uid, Boolean hasCoupon, PrintWriter out) { + public void getShareTextTemplate(AcceptData acceptData, 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(uid, hasCoupon)); + data.put("template", getShareTemplate(uid, hasCoupon, tljId)); out.print(JsonUtil.loadTrueResult(data)); } @@ -622,14 +883,17 @@ * @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"))); + public void getShareTextTemplateRules(AcceptData acceptData, Long tljId, PrintWriter out) { + if (tljId != null) { + out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules"))); + } else { + out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules"))); + } } - - /** * 鏌ヨ椤堕儴鍒嗙被 + * * @param acceptData * @param page * @param cid @@ -638,139 +902,121 @@ @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) { // 鐑攢鍗曞搧 - // 鏂囧瓧鍐呭 - String title =""; + + if (cid == 1 || cid == 2) { // 1 鐑攢鍗曞搧 2 鎺ㄨ崘濂借揣 + if (cid == 1) { + List<GoodsPicture> imgs = dynamicInfo.getImgs(); + 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; + } + } + } + + // 鍒嗕韩鏂囧瓧 + String title = null; List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); if (listTitle != null && listTitle.size() > 0) { + title = ""; for (ClientTextStyleVO textStyleVO : listTitle) { title += textStyleVO.getContent(); } } + + if (StringUtil.isNullOrEmpty(title)) { + title = "缁欎綘鎺ㄨ崘绮鹃�夊ソ鐗╀紭鎯犲埜锛岃喘鐗╁墠鍏堥鍒革紝鍒敊杩囦紭鎯犲摝~"; + } data.put("title", title); data.put("content", "鎴戝湪杩斿埄鍒稿彂鐜颁簡涓�涓緢濂界殑鍟嗗搧锛屽揩鏉ョ湅鐪媬"); - + // 鍒嗕韩濂栭噾 ClientTextStyleVO desc = dynamicInfo.getDesc(); String content = desc.getContent(); int index = content.indexOf("楼"); - data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length()))); - - // 鍟嗗搧鍒嗕韩閾炬帴 - List<GoodsPicture> imgs2 = dynamicInfo.getImgs(); - GoodsPicture goodsPicture = imgs2.get(0); - Long auctionId = goodsPicture.getGoods().getAuctionId(); - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - auctionId + ""); - - String shortLink = HttpUtil.getShortLink(url); - if (!StringUtil.isNullOrEmpty(shortLink)) { - url = shortLink; - } - data.put("clickUrl", url); - - // 鍒嗕韩鎻愮ず鍥剧墖 + data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString()); + + // 鍒嗕韩鎻愰啋 + data.put("notifyDesc", configService.get("goods_share_notify")); + + // 鍒嗕韩鎻愮ず璇� 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, auctionId, relationId); - - data.put("pictUrl", TbImgUtil.getTBSizeImg(goodsPicture.getUrl(), 500)); - // 娣樺疂鍙d护 - data.put("token", taoBaoLink.getTaoToken()); + + // 鍒嗕韩鍑哄幓鐨勫浘鐗� + String pictUrl = dynamicInfo.getImgs().get(0).getUrl(); + data.put("pictUrl", TbImgUtil.getTBSizeImg(pictUrl, 500)); + // 甯姪閾炬帴 - data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); - // 鍒嗕韩鎻愰啋 - data.put("notifyDesc", configService.get("goods_share_notify")); - // 鍒嗕韩璁板綍id - data.put("shareId", userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId)); - - } else if (cid == 2) { // 鎺ㄨ崘濂借揣 - - String picUrl = null; - List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>(); - List<GoodsPicture> listImgs = dynamicInfo.getImgs(); - for (GoodsPicture goodsPicture: listImgs) { - TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods(); - listGoods.add(goods); - - if (picUrl == null) { - picUrl = goodsPicture.getUrl(); + data.put("helpLink", + "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); + + if (cid == 2) { // 2 鎺ㄨ崘濂借揣 + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid, + dynamicInfo.getListGoodsBrief()); + data.put("shareId", shareRecord.getRedisKey()); + data.put("clickUrl", shareRecord.getShareUrl()); + } else { + // 鍒嗕韩id + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid, + dynamicInfo.getListGoodsBrief()); + data.put("shareId", shareRecord.getRedisKey()); + + Long auctionId = dynamicInfo.getImgs().get(0).getGoods().getAuctionId(); + // 鍟嗗搧鍒嗕韩閾炬帴 + String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), + Constant.systemCommonConfig.getShareGoodsPagePath(), + AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + ""); + String shortLink = HttpUtil.getShortLink(url); + if (!StringUtil.isNullOrEmpty(shortLink)) { + url = shortLink; } - } - - // 鏂囧瓧鍐呭 - String title =""; - List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); - if (listTitle != null && listTitle.size() > 0) { - for (ClientTextStyleVO textStyleVO : listTitle) { - title += textStyleVO.getContent(); + data.put("clickUrl", url); + + // 娣樺疂鍙d护 + 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, auctionId, relationId); + data.put("token", taoBaoLink.getTaoToken()); } - data.put("title", title); - data.put("content", "鎴戝湪杩斿埄鍒稿彂鐜颁簡涓�涓緢濂界殑鍟嗗搧锛屽揩鏉ョ湅鐪媬"); - - // 鍒嗕韩濂栭噾 - ClientTextStyleVO desc = dynamicInfo.getDesc(); - String content = desc.getContent(); - int index = content.indexOf("楼"); - data.put("shareMoney", new BigDecimal(content.substring(index + 1 , content.length()))); - - // 鍒嗕韩閾炬帴 - ShareInfoDTO shareInfo = userShareGoodsRecordService.saveShareRecord(uid, - ShareSourceTypeEnum.activity, title, listGoods); - data.put("shareId", shareInfo.getShareId()); - data.put("clickUrl", shareInfo.getShareUrl()); - data.put("pictUrl", TbImgUtil.getTBSizeImg(picUrl, 500)); - // 甯姪閾炬帴 - data.put("helpLink","http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); - // 鍒嗕韩鎻愰啋 - data.put("notifyDesc", configService.get("goods_share_notify")); - // 鍒嗕韩鎻愰啋璇� - 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)); - } - + } else if (cid == 4) { // 閭�璇峰垎浜� - + String inviteCode = null; UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { @@ -779,12 +1025,13 @@ out.print(JsonUtil.loadFalseResult(9001, "閭�璇风爜鏈縺娲�")); return; } - + Integer showType = dynamicInfo.getShowType(); - if (showType == 0) { // 鏃犲浘鍒嗕韩 - String title =""; + if (showType == 0) { // 鏃犲浘鍒嗕韩 + String title = null; List<ClientTextStyleVO> listTitle = dynamicInfo.getTitle(); if (listTitle != null && listTitle.size() > 0) { + title = ""; for (ClientTextStyleVO textStyleVO : listTitle) { title += textStyleVO.getContent(); } @@ -792,42 +1039,56 @@ title = title.replace("銆愰個璇风爜銆�", inviteCode); title = title.replace("銆愰個璇烽摼鎺ャ��", UserUtil.getInviteShortLink(uid)); data.put("title", title); - + } else { // 鏈夊浘鍒嗕韩 List<GoodsPicture> imgs = dynamicInfo.getImgs(); - String bgUrl = imgs.get(0).getUrlOriginal(); + + GoodsPicture goodsPicture = imgs.get(0); + String bgUrl = goodsPicture.getUrlOriginal(); + if (StringUtil.isNullOrEmpty(bgUrl)) { out.print(JsonUtil.loadFalseResult("鍥剧墖璺緞涓嶅瓨鍦�")); return; } - + // 鐢ㄦ埛淇℃伅 UserInfo userInfo = userInfoService.selectByPKey(uid); String portrait = userInfo.getPortrait(); // 鐢婚個璇峰浘鐗� - if (StringUtil.isNullOrEmpty(dynamicInfo.getInviteMaterialId())) { - String imgLink = spreadUserImgService.drawInviteQrCodeNew(bgUrl,uid, portrait, inviteCode); + + Long activityId = dynamicInfo.getActivityId(); + if (activityId != null) { + Integer pX = goodsPicture.getPx(); + ; + Integer pY = goodsPicture.getPy(); + ; + Integer size = goodsPicture.getSize(); + + String imgLink = spreadUserImgService.drawInviteQrCodeNew(bgUrl, uid, portrait, pX, pY, size, + inviteCode); + data.put("imgLink", imgLink); } else { String title = imgs.get(0).getTitleOriginal(); - String imgLink = spreadUserImgService.getInviteImgToGreet(bgUrl,uid, portrait, inviteCode, title, new Date()); + String imgLink = spreadUserImgService.getInviteImgToGreet(bgUrl, uid, portrait, inviteCode, + title, new Date()); data.put("imgLink", imgLink); } - - // 閭�璇疯鍒� + + // 閭�璇疯鍒� 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); + 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() + "/" + String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); data.put("inviteLink", shortLink); data.put("inviteCode", inviteCode); @@ -835,7 +1096,7 @@ } } out.print(JsonUtil.loadTrueResult(data)); - + // 鏇存柊鍒嗕韩娆℃暟 executor.execute(new Runnable() { @Override @@ -845,7 +1106,7 @@ dynamicInfoService.updateShareCount(dynamicInfo); } }); - + } catch (Exception e) { out.print(JsonUtil.loadFalseResult("鍒嗕韩璁板綍澶辫触")); try { -- Gitblit v1.8.0