添加小程序订阅消息后台管理
This commit is contained in:
@ -75,17 +75,6 @@ logging:
|
||||
yshop:
|
||||
#相关配置
|
||||
version: 3.0
|
||||
#小程序订阅消息配置
|
||||
subscribe:
|
||||
subscribeMaps:
|
||||
#付款成功
|
||||
pay_success: W5r2c2kzhbq8uxStkPAVx_sk-5aapMFCqe7b7KU5jXI
|
||||
#发货成功
|
||||
delivery-success: 2CB_1UyQrbnlyjJa5syraqJ3cfztPPDOAHe3DEXpMjg
|
||||
#退款成功
|
||||
refund_success:
|
||||
#充值成功
|
||||
recharge_success:
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
|
@ -1,14 +0,0 @@
|
||||
package co.yixiang.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "yshop.subscribe")
|
||||
public class SubscribeProperties {
|
||||
private Map<String, String> subscribeMaps;
|
||||
}
|
@ -47,6 +47,8 @@ public class YxWechatTemplate extends BaseDomain {
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
|
||||
/** 类型:template:模板消息 subscribe:订阅消息 */
|
||||
private String type;
|
||||
|
||||
public void copy(YxWechatTemplate source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
@ -36,4 +36,6 @@ public class YxWechatTemplateDto implements Serializable {
|
||||
|
||||
/** 状态 */
|
||||
private Integer status;
|
||||
/** 类型:template:模板消息 subscribe:订阅消息 */
|
||||
private String type;
|
||||
}
|
||||
|
@ -3,11 +3,13 @@ package co.yixiang.mp.service;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.config.SubscribeProperties;
|
||||
import co.yixiang.api.YshopException;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.modules.user.domain.YxUser;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.service.dto.WechatUserDto;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatTemplate;
|
||||
import co.yixiang.modules.wechat.service.YxWechatTemplateService;
|
||||
import co.yixiang.mp.enums.WechatTempateEnum;
|
||||
import co.yixiang.tools.config.WxMaConfiguration;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
@ -29,11 +31,7 @@ public class WeiXinSubscribeService {
|
||||
@Autowired
|
||||
private YxUserService userService;
|
||||
@Autowired
|
||||
private SubscribeProperties subscribeProperties;
|
||||
|
||||
|
||||
|
||||
|
||||
private YxWechatTemplateService yxWechatTemplateService;
|
||||
/**
|
||||
* 充值成功通知
|
||||
* @param time 时间
|
||||
@ -163,13 +161,14 @@ public class WeiXinSubscribeService {
|
||||
* @return string
|
||||
*/
|
||||
private String getTempId(String key){
|
||||
AtomicReference<String> tempId = new AtomicReference<>();
|
||||
subscribeProperties.getSubscribeMaps().forEach((k,v)->{
|
||||
if(key.equals(k)){
|
||||
tempId.set(v);
|
||||
YxWechatTemplate yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
|
||||
.eq(YxWechatTemplate::getType,"subscribe")
|
||||
.eq(YxWechatTemplate::getTempkey,key)
|
||||
.one();
|
||||
if (yxWechatTemplate == null) {
|
||||
throw new YshopException("请后台配置key:" + key + "订阅消息id");
|
||||
}
|
||||
});
|
||||
return tempId.get();
|
||||
return yxWechatTemplate.getTempid();
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,6 +182,7 @@ public class WeixinTemplateService {
|
||||
*/
|
||||
private String getTempId(String key){
|
||||
YxWechatTemplate yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
|
||||
.eq(YxWechatTemplate::getType,"template")
|
||||
.eq(YxWechatTemplate::getTempkey,key)
|
||||
.one();
|
||||
if (yxWechatTemplate == null) {
|
||||
|
Reference in New Issue
Block a user