From 8ebf78f9d9a2663f53f09346abdd14c5964fdfeb Mon Sep 17 00:00:00 2001 From: yj <Administrator@192> Date: 星期二, 03 三月 2020 19:11:00 +0800 Subject: [PATCH] 发圈修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java | 196 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 196 insertions(+), 0 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java index af1b5c6..f6fbe2d 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java @@ -14,6 +14,7 @@ import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate; 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.exception.goods.ShareGoodsTextTemplateException; import com.yeshi.fanli.service.inter.config.ConfigService; @@ -221,6 +222,195 @@ } @Override + public String getTextTemplateByTB(Long uid) { + String template = ""; + ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid); + if (objct != null && !StringUtil.isNullOrEmpty(objct.getShareTextTemplate())) { + template = objct.getShareTextTemplate(); + if (template.contains("{鍘熶环}")|| template.contains("{鍙d护}") || template.contains("{鍒稿悗浠穧")) { + template = ""; // 鑰佹澘鍒嗕韩 + } + } + if (StringUtil.isNullOrEmpty(template)) { + template = configService.get(ConfigKeyEnum.shareCommentTextTB.getKey()); + } + + return template; + } + + @Override + public String getTextTemplateByJD(Long uid) { + String template = ""; + ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid); + if (objct != null && !StringUtil.isNullOrEmpty(objct.getShareJDTextTemplate())) { + template = objct.getShareJDTextTemplate(); + if (template.contains("{鍘熶环}")|| template.contains("{鍒稿悗浠穧") || template.contains("{閾炬帴}")) { + template = ""; // 鑰佹澘鍒嗕韩 + } + } + if (StringUtil.isNullOrEmpty(template)) { + template = configService.get(ConfigKeyEnum.shareCommentTextJD.getKey()); + } + return template; + } + + @Override + public String getTextTemplateByPDD(Long uid) { + String template = ""; + ShareGoodsTextTemplate objct = shareGoodsTextTemplateMapper.selectByUid(uid); + if (objct != null && !StringUtil.isNullOrEmpty(objct.getSharePDDTextTemplate())) { + template = objct.getSharePDDTextTemplate(); + if (!template.contains("{鍘熶环}") && !template.contains("{鍒稿悗浠穧") && !template.contains("{閾炬帴}")) { + template = ""; // 鑰佹澘鍒嗕韩 + } + } + if (StringUtil.isNullOrEmpty(template)) { + template = configService.get(ConfigKeyEnum.shareCommentTextPDD.getKey()); + } + + return template; + } + + @Override + public void saveTemplateTB(Long uid, String template) throws ShareGoodsTextTemplateException { + verifyRightTB(template); + ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid); + if (old != null) { + ShareGoodsTextTemplate update = new ShareGoodsTextTemplate(); + update.setId(old.getId()); + update.setShareTextTemplate(template); + update.setUpdateTime(new Date()); + shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update); + } else { + ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate(); + textTemplate.setCreateTime(new Date()); + textTemplate.setShareTextTemplate(template); + textTemplate.setUid(uid); + shareGoodsTextTemplateMapper.insertSelective(textTemplate); + } + } + + @Override + public void saveTemplateJD(Long uid, String template) throws ShareGoodsTextTemplateException { + verifyRightJD(template); + ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid); + if (old != null) { + ShareGoodsTextTemplate update = new ShareGoodsTextTemplate(); + update.setId(old.getId()); + update.setShareJDTextTemplate(template); + update.setUpdateTime(new Date()); + shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update); + } else { + ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate(); + textTemplate.setCreateTime(new Date()); + textTemplate.setShareJDTextTemplate(template); + textTemplate.setUid(uid); + shareGoodsTextTemplateMapper.insertSelective(textTemplate); + } + } + + @Override + public void saveTemplatePDD(Long uid, String template) throws ShareGoodsTextTemplateException { + verifyRightPDD(template); + ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid); + if (old != null) { + ShareGoodsTextTemplate update = new ShareGoodsTextTemplate(); + update.setId(old.getId()); + update.setSharePDDTextTemplate(template); + update.setUpdateTime(new Date()); + shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update); + } else { + ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate(); + textTemplate.setCreateTime(new Date()); + textTemplate.setSharePDDTextTemplate(template); + textTemplate.setUid(uid); + shareGoodsTextTemplateMapper.insertSelective(textTemplate); + } + } + + + + @Override + public void verifyRightTB(String template) throws ShareGoodsTextTemplateException { + String[] keys = new String[] { "{鍘熶环}", "{鍒稿悗浠穧","{鍙d护}" }; + int keysCount = 0; + for (String key : keys) + if (template != null && template.contains(key)) + keysCount++; + if (keysCount == 0) + throw new ShareGoodsTextTemplateException(1, "妯℃澘鏍煎紡鏈夎"); + } + + @Override + public void verifyRightJD(String template) throws ShareGoodsTextTemplateException { + String[] keys = new String[] { "{鍘熶环}", "{鍒稿悗浠穧","{閾炬帴}" }; + int keysCount = 0; + for (String key : keys) + if (template != null && template.contains(key)) + keysCount++; + if (keysCount == 0) + throw new ShareGoodsTextTemplateException(1, "妯℃澘鏍煎紡鏈夎"); + } + + + @Override + public void verifyRightPDD(String template) throws ShareGoodsTextTemplateException { + String[] keys = new String[] { "{鍘熶环}", "{鍒稿悗浠穧","{閾炬帴}" }; + int keysCount = 0; + for (String key : keys) + if (template != null && template.contains(key)) + keysCount++; + if (keysCount == 0) + throw new ShareGoodsTextTemplateException(1, "妯℃澘鏍煎紡鏈夎"); + } + + + @Override + public String createContentTB(String template, TaoBaoGoodsBrief goods, String token, boolean coupon) { + String commentText = template.replace("{鍘熶环}", goods.getZkPrice().toString()); + commentText = commentText.replace("{鍙d护}", TaoBaoUtil.filterTaoToken(token)); + if (coupon) { + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆憑鍒稿悗浠穧鍏�", ""); + } else { + commentText = commentText.replace("{鍒稿悗浠穧", + TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); + } + return deleteBlankLine(commentText); + } + + @Override + public String createContentJD(String template, JDGoods goods, String jumpLink, boolean coupon) { + String commentText = template.replace("{鍘熶环}", goods.getPrice().toString()); + commentText = commentText.replace("{閾炬帴}", jumpLink); + if (coupon) { + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆憑鍒稿悗浠穧鍏�", ""); + } else { + commentText = commentText.replace("{鍒稿悗浠穧", + BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(goods)).toString()); + } + return deleteBlankLine(commentText); + } + + @Override + public String createContentPDD(String template, PDDGoodsDetail goods, String jumpLink, boolean coupon) { + String commentText = template.replace("{鍘熶环}", MoneyBigDecimalUtil + .div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString()); + commentText = commentText.replace("{閾炬帴}", jumpLink); + if (coupon) { + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆憑鍒稿悗浠穧鍏�", ""); + } else { + commentText = commentText.replace("{鍒稿悗浠穧", + BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString()); + } + return deleteBlankLine(commentText); + } + + + + @Override public void isCommonTemplateRight(String template) throws ShareGoodsTextTemplateException { String[] keys = new String[] { "{鏍囬}", "{搴楅摵绫诲瀷}", "{鍟嗗搧鍘熶环}", "{鏈堥攢閲弣", "{鐭摼}", "{娣樺彛浠" }; int keysCount = 0; @@ -298,6 +488,12 @@ throw new ShareGoodsTextTemplateException(1, "妯℃澘鏍煎紡鏈夎"); } + 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"); + } + + + @Override public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, String token, String shortLink, boolean hasCoupon, Long tljId) { -- Gitblit v1.8.0