| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.goods.ShareGoodsTextTemplateMapper;
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void saveCouponTemplate(Long uid, String template) throws ShareGoodsTextTemplateException {
|
| | | isCouponTemplateRight(template);
|
| | | ShareGoodsTextTemplate old = shareGoodsTextTemplateMapper.selectByUid(uid);
|
| | | if (old != null) {
|
| | | ShareGoodsTextTemplate update = new ShareGoodsTextTemplate();
|
| | | update.setId(old.getId());
|
| | | update.setShareCouponTextTemplate(template);
|
| | | update.setUpdateTime(new Date());
|
| | | shareGoodsTextTemplateMapper.updateByPrimaryKeySelective(update);
|
| | | } else {
|
| | | ShareGoodsTextTemplate textTemplate = new ShareGoodsTextTemplate();
|
| | | textTemplate.setCreateTime(new Date());
|
| | | textTemplate.setShareCouponTextTemplate(template);
|
| | | textTemplate.setUid(uid);
|
| | | shareGoodsTextTemplateMapper.insertSelective(textTemplate);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, boolean hasCoupon) {
|
| | | 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);
|
| | | if (!hasCoupon) {
|
| | | String token = goods.getCouponLinkTaoToken();
|
| | | if (StringUtil.isNullOrEmpty(token))
|
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), goods.getAuctionUrl());
|
| | | public String createContentByTemplate(String template, Long uid, TaoBaoGoodsBrief goods, String token,
|
| | | String shortLink, boolean hasCoupon) {
|
| | |
|
| | | if (!hasCoupon) {
|
| | | return template.replace("{标题}", goods.getTitle()).replace("{商品原价}", goods.getZkPrice().toString())
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{短链}", shortLink)
|
| | | .replace("{淘口令}", "").replace("{店铺类型}", goods.getUserType() == 1 ? "天猫价"
|
| | | : "淘宝价");
|
| | | } else {
|
| | | String token = goods.getCouponLinkTaoToken();
|
| | | if (StringUtil.isNullOrEmpty(token))
|
| | | token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), goods.getCouponLink());
|
| | |
|
| | | return template.replace("{标题}", goods.getTitle()).replace("{商品原价}", goods.getZkPrice().toString())
|
| | | .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{领券短链}", shortLink)
|
| | | .replace("{淘口令}", token).replace("{优惠券面额}", goods.getCouponAmount().toString())
|