admin
2019-08-05 34e65d72e73acab040b68d01ef6b4764b4408624
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -10,6 +10,7 @@
import org.yeshi.utils.BigDecimalUtil;
import com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper;
import com.yeshi.fanli.dto.jd.JDPingouInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
@@ -18,6 +19,7 @@
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
@@ -235,7 +237,7 @@
   @Override
   public void isCommonTemplateRightJD(String template) throws ShareGoodsTextTemplateException {
      String[] keys = new String[] { "{标题}",  "{商品原价}", "{月销量}", "{短链接}" };
      String[] keys = new String[] { "{标题}","{京东价}", "{商品原价}", "{月销量}", "{短链接}" };
      int keysCount = 0;
      for (String key : keys)
         if (template != null && template.contains(key))
@@ -246,7 +248,7 @@
   
   @Override
   public void isCommonTemplateRightPDD(String template) throws ShareGoodsTextTemplateException {
      String[] keys = new String[] { "{标题}", "{商品原价}", "{月销量}", "{短链接}", "{多多口令}" };
      String[] keys = new String[] { "{标题}", "{商品原价}", "{月销量}", "{短链接}"};
      int keysCount = 0;
      for (String key : keys)
         if (template != null && template.contains(key))
@@ -269,7 +271,7 @@
   
   @Override
   public void isCouponTemplateRightJD(String template) throws ShareGoodsTextTemplateException {
      String[] keys = new String[] { "{标题}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{月销量}", "{短链接}" };
      String[] keys = new String[] { "{标题}","{京东价}", "{商品原价}", "{优惠券面额}", "{优惠券价}", "{月销量}", "{短链接}" };
      int keysCount = 0;
      for (String key : keys)
         if (template != null && template.contains(key))
@@ -321,8 +323,8 @@
      
      if (!hasCoupon) {
         return template.replace("{标题}", goods.getTitle()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(goods.getZkPrice()).toString())
               .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{短链}", shortLink)
               .replace("{淘口令}", "").replace("{店铺类型}", goods.getUserType() == 1 ? "天猫价"
               .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{领券短链}", shortLink)
               .replace("{淘口令}", token).replace("{店铺类型}", goods.getUserType() == 1 ? "天猫价"
                     : "淘宝价");
      } else {
         return template.replace("{标题}", goods.getTitle()).replace("{商品原价}", BigDecimalUtil.getWithNoZera( goods.getZkPrice()).toString())
@@ -336,35 +338,56 @@
   
   @Override
   public String createContentByTemplateJD(String template, Long uid, JDGoods goods, String shortLink, boolean hasCoupon) {
      BigDecimal price = goods.getPrice();
      JDPingouInfo pinGouInfo = goods.getPinGouInfo();
      if (pinGouInfo != null) {
         price = pinGouInfo.getPingouPrice();
      }
      if (!hasCoupon) {
         return template.replace("{标题}", goods.getSkuName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(goods.getPrice()).toString())
         template = template.replace("{标题}", goods.getSkuName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(price).toString())
               .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink);
      } else {
         return template.replace("{标题}", goods.getSkuName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera( goods.getPrice()).toString())
         template = template.replace("{标题}", goods.getSkuName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera(price).toString())
               .replace("{月销量}", JDUtil.getSaleCount(goods.getInOrderCount30Days())).replace("{短链接}", shortLink)
               .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(goods.getCouponInfo().getDiscount()).toString())
               .replace("{优惠券价}", BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(goods)).toString());
      }
      if (pinGouInfo != null) {
         template = template.replace("{京东价}", "拼购价");
      } else {
         template = template.replace("{京东价}", "京东价");
      }
      return template;
   }
   
   
   @Override
   public String createContentByTemplatePDD(String template, Long uid, PDDGoodsDetail goods, 
         String shortLink, boolean hasCoupon, String token) {
      BigDecimal hundred = new BigDecimal(100);
      BigDecimal price =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), hundred);
      if (!hasCoupon) {
         template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())).toString())
         template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(price).toString())
               .replace("{总销量}", goods.getSalesTip()).replace("{短链接}", shortLink);
         if (StringUtil.isNullOrEmpty(token)) {
            template = template.replace("复制本条信息,{多多口令}打开拼多多,立即购买", "点击链接,打开拼多多,立即购买");
         } else {
            template = template.replace("{多多口令}", token);
         }
      } else {
         template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())).toString())
         BigDecimal amount =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
         template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera(price).toString())
               .replace("{总销量}", goods.getSalesTip()).replace("{短链接}", shortLink)
               .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())).toString())
               .replace("{优惠券价}", BigDecimalUtil.getWithNoZera( PinDuoDuoUtil.getQuanPrice(goods)).toString());
      }
      if (StringUtil.isNullOrEmpty(token)) {
         template = template.replace("{多多口令}打开拼多多,", "");
      } else {
         template = template.replace("{多多口令}", token);
               .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(amount).toString())
               .replace("{优惠券价}", BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString());
         if (StringUtil.isNullOrEmpty(token)) {
            template = template.replace("复制本条信息,{多多口令}打开拼多多,免费领券", "点击链接,打开拼多多,免费领券");
         } else {
            template = template.replace("{多多口令}", token);
         }
      }
      
      return template;