test # Conflicts: # mallinkService/src/main/java/com/iformall/domain/po/WxCUser.java # mallinkService/src/main/java/com/iformall/domain/vo/WxWeappInfo.java # mallinkService/src/main/java/com/iformall/mapper/WxCUserMapper.java # mallinkService/src/main/java/com/iformall/service/WxCUserService.java # mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java # mallinkService/src/main/java/com/iformall/utils/Constant.java # mallinkService/src/main/resources/mapper/WxAuthorizerInfoMapper.xml # mallinkService/src/main/resources/mapper/WxCUserMapper.xml # mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappCodeController.java # mlWechatOpen/src/main/java/com/iformall/mp/controller/WxMemController.java # mlWechatOpen/src/main/java/com/iformall/mp/handler/SubscribeHandler.java # mlWechatOpen/src/main/java/com/iformall/mp/handler/UnsubscribeHandler.java # mlWechatOpen/src/main/java/com/iformall/schedule/AppAccessTokenSchedule.java # mlWechatOpen/src/main/java/com/iformall/schedule/UserUnionIdSchedule.javarelease
| @@ -0,0 +1,338 @@ | |||||
| package com.iformall.common; | |||||
| import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.http.HttpHost; | |||||
| import org.apache.http.NoHttpResponseException; | |||||
| import org.apache.http.auth.AuthScope; | |||||
| import org.apache.http.auth.UsernamePasswordCredentials; | |||||
| import org.apache.http.client.CredentialsProvider; | |||||
| import org.apache.http.client.HttpRequestRetryHandler; | |||||
| import org.apache.http.client.config.RequestConfig; | |||||
| import org.apache.http.config.Registry; | |||||
| import org.apache.http.config.RegistryBuilder; | |||||
| import org.apache.http.config.SocketConfig; | |||||
| import org.apache.http.conn.ConnectTimeoutException; | |||||
| import org.apache.http.conn.DnsResolver; | |||||
| import org.apache.http.conn.HttpClientConnectionManager; | |||||
| import org.apache.http.conn.socket.ConnectionSocketFactory; | |||||
| import org.apache.http.conn.socket.PlainConnectionSocketFactory; | |||||
| import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | |||||
| import org.apache.http.impl.client.BasicCredentialsProvider; | |||||
| import org.apache.http.impl.client.CloseableHttpClient; | |||||
| import org.apache.http.impl.client.HttpClientBuilder; | |||||
| import org.apache.http.impl.client.HttpClients; | |||||
| import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | |||||
| import org.apache.http.protocol.HttpContext; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import java.io.IOException; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| import java.util.concurrent.atomic.AtomicBoolean; | |||||
| /** | |||||
| * httpclient 连接管理器 自带DNS解析. | |||||
| * <p>大部分代码拷贝自:DefaultApacheHttpClientBuilder</p> | |||||
| * | |||||
| * @author Andy.Huo | |||||
| */ | |||||
| public class FmHttpClientBuilder implements ApacheHttpClientBuilder { | |||||
| protected final Logger log = LoggerFactory.getLogger(FmHttpClientBuilder.class); | |||||
| private final AtomicBoolean prepared = new AtomicBoolean(false); | |||||
| private int connectionRequestTimeout = 3000; | |||||
| private int connectionTimeout = 5000; | |||||
| private int soTimeout = 5000; | |||||
| private int idleConnTimeout = 60000; | |||||
| private int checkWaitTime = 60000; | |||||
| private int maxConnPerHost = 10; | |||||
| private int maxTotalConn = 50; | |||||
| private String userAgent; | |||||
| private DnsResolver dnsResover; | |||||
| private HttpRequestRetryHandler httpRequestRetryHandler = new HttpRequestRetryHandler() { | |||||
| @Override | |||||
| public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { | |||||
| if (executionCount > 3) { | |||||
| log.warn("Maximum tries reached for client http pool "); | |||||
| return false; | |||||
| } | |||||
| if (exception instanceof NoHttpResponseException) { // NoHttpResponseException 重试 | |||||
| log.warn("NoHttpResponseException on " + executionCount + " call"); | |||||
| return true; | |||||
| } | |||||
| if (exception instanceof ConnectTimeoutException) { // 连接超时重试 | |||||
| log.warn("ConnectTimeoutException on " + executionCount + " call"); | |||||
| return true; | |||||
| } | |||||
| //if (exception instanceof SocketTimeoutException) { //响应超时不重试,避免造成业务数据不一致 | |||||
| // log.warn("SocketTimeoutException on " + executionCount + " call"); | |||||
| //} | |||||
| return false; | |||||
| } | |||||
| }; | |||||
| private SSLConnectionSocketFactory sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory(); | |||||
| private PlainConnectionSocketFactory plainConnectionSocketFactory = PlainConnectionSocketFactory.getSocketFactory(); | |||||
| private String httpProxyHost; | |||||
| private int httpProxyPort; | |||||
| private String httpProxyUsername; | |||||
| private String httpProxyPassword; | |||||
| /** | |||||
| * 闲置连接监控线程. | |||||
| */ | |||||
| private IdleConnectionMonitorThread idleConnectionMonitorThread; | |||||
| private HttpClientBuilder httpClientBuilder; | |||||
| private FmHttpClientBuilder() { | |||||
| } | |||||
| public static FmHttpClientBuilder get() { | |||||
| return new FmHttpClientBuilder(); | |||||
| } | |||||
| @Override | |||||
| public ApacheHttpClientBuilder httpProxyHost(String httpProxyHost) { | |||||
| this.httpProxyHost = httpProxyHost; | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public ApacheHttpClientBuilder httpProxyPort(int httpProxyPort) { | |||||
| this.httpProxyPort = httpProxyPort; | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername) { | |||||
| this.httpProxyUsername = httpProxyUsername; | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword) { | |||||
| this.httpProxyPassword = httpProxyPassword; | |||||
| return this; | |||||
| } | |||||
| @Override | |||||
| public ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory) { | |||||
| this.sslConnectionSocketFactory = sslConnectionSocketFactory; | |||||
| return this; | |||||
| } | |||||
| /** | |||||
| * 获取链接的超时时间设置,默认3000ms | |||||
| * <p> | |||||
| * 设置为零时不超时,一直等待. 设置为负数是使用系统默认设置(非上述的3000ms的默认值,而是httpclient的默认设置). | |||||
| * </p> | |||||
| * | |||||
| * @param connectionRequestTimeout 获取链接的超时时间设置(单位毫秒),默认3000ms | |||||
| */ | |||||
| public void setConnectionRequestTimeout(int connectionRequestTimeout) { | |||||
| this.connectionRequestTimeout = connectionRequestTimeout; | |||||
| } | |||||
| /** | |||||
| * 建立链接的超时时间,默认为5000ms.由于是在链接池获取链接,此设置应该并不起什么作用 | |||||
| * <p> | |||||
| * 设置为零时不超时,一直等待. 设置为负数是使用系统默认设置(非上述的5000ms的默认值,而是httpclient的默认设置). | |||||
| * </p> | |||||
| * | |||||
| * @param connectionTimeout 建立链接的超时时间设置(单位毫秒),默认5000ms | |||||
| */ | |||||
| public void setConnectionTimeout(int connectionTimeout) { | |||||
| this.connectionTimeout = connectionTimeout; | |||||
| } | |||||
| /** | |||||
| * 默认NIO的socket超时设置,默认5000ms. | |||||
| * | |||||
| * @param soTimeout 默认NIO的socket超时设置,默认5000ms. | |||||
| * @see java.net.SocketOptions#SO_TIMEOUT | |||||
| */ | |||||
| public void setSoTimeout(int soTimeout) { | |||||
| this.soTimeout = soTimeout; | |||||
| } | |||||
| /** | |||||
| * 空闲链接的超时时间,默认60000ms. | |||||
| * <p> | |||||
| * 超时的链接将在下一次空闲链接检查是被销毁 | |||||
| * </p> | |||||
| * | |||||
| * @param idleConnTimeout 空闲链接的超时时间,默认60000ms. | |||||
| */ | |||||
| public void setIdleConnTimeout(int idleConnTimeout) { | |||||
| this.idleConnTimeout = idleConnTimeout; | |||||
| } | |||||
| /** | |||||
| * 检查空间链接的间隔周期,默认60000ms. | |||||
| * | |||||
| * @param checkWaitTime 检查空间链接的间隔周期,默认60000ms. | |||||
| */ | |||||
| public void setCheckWaitTime(int checkWaitTime) { | |||||
| this.checkWaitTime = checkWaitTime; | |||||
| } | |||||
| /** | |||||
| * 每路的最大链接数,默认10. | |||||
| * | |||||
| * @param maxConnPerHost 每路的最大链接数,默认10 | |||||
| */ | |||||
| public void setMaxConnPerHost(int maxConnPerHost) { | |||||
| this.maxConnPerHost = maxConnPerHost; | |||||
| } | |||||
| /** | |||||
| * 最大总连接数,默认50. | |||||
| * | |||||
| * @param maxTotalConn 最大总连接数,默认50 | |||||
| */ | |||||
| public void setMaxTotalConn(int maxTotalConn) { | |||||
| this.maxTotalConn = maxTotalConn; | |||||
| } | |||||
| /** | |||||
| * 自定义httpclient的User Agent. | |||||
| * | |||||
| * @param userAgent User Agent | |||||
| */ | |||||
| public void setUserAgent(String userAgent) { | |||||
| this.userAgent = userAgent; | |||||
| } | |||||
| public IdleConnectionMonitorThread getIdleConnectionMonitorThread() { | |||||
| return this.idleConnectionMonitorThread; | |||||
| } | |||||
| private synchronized void prepare() { | |||||
| if (prepared.get()) { | |||||
| return; | |||||
| } | |||||
| Registry<ConnectionSocketFactory> registry = | |||||
| RegistryBuilder.<ConnectionSocketFactory>create() | |||||
| .register("http", this.plainConnectionSocketFactory) | |||||
| .register("https", this.sslConnectionSocketFactory) | |||||
| .build(); | |||||
| @SuppressWarnings("resource") | |||||
| PoolingHttpClientConnectionManager connectionManager; | |||||
| if (dnsResover != null) { | |||||
| if (log.isDebugEnabled()) { | |||||
| log.debug("specified dns resolver."); | |||||
| } | |||||
| connectionManager = new PoolingHttpClientConnectionManager(registry, dnsResover); | |||||
| } else { | |||||
| if (log.isDebugEnabled()) { | |||||
| log.debug("Not specified dns resolver."); | |||||
| } | |||||
| connectionManager = new PoolingHttpClientConnectionManager(registry); | |||||
| } | |||||
| connectionManager.setMaxTotal(this.maxTotalConn); | |||||
| connectionManager.setDefaultMaxPerRoute(this.maxConnPerHost); | |||||
| connectionManager | |||||
| .setDefaultSocketConfig(SocketConfig.copy(SocketConfig.DEFAULT).setSoTimeout(this.soTimeout).build()); | |||||
| this.idleConnectionMonitorThread = new IdleConnectionMonitorThread( | |||||
| connectionManager, this.idleConnTimeout, this.checkWaitTime); | |||||
| this.idleConnectionMonitorThread.setDaemon(true); | |||||
| this.idleConnectionMonitorThread.start(); | |||||
| this.httpClientBuilder = HttpClients.custom().setConnectionManager(connectionManager) | |||||
| .setConnectionManagerShared(true) | |||||
| .setDefaultRequestConfig( | |||||
| RequestConfig.custom() | |||||
| .setSocketTimeout(this.soTimeout) | |||||
| .setConnectTimeout(this.connectionTimeout) | |||||
| .setConnectionRequestTimeout(this.connectionRequestTimeout) | |||||
| .build()) | |||||
| .setRetryHandler(this.httpRequestRetryHandler); | |||||
| if (StringUtils.isNotBlank(this.httpProxyHost) && StringUtils.isNotBlank(this.httpProxyUsername)) { | |||||
| // 使用代理服务器 需要用户认证的代理服务器 | |||||
| CredentialsProvider provider = new BasicCredentialsProvider(); | |||||
| provider.setCredentials(new AuthScope(this.httpProxyHost, this.httpProxyPort), | |||||
| new UsernamePasswordCredentials(this.httpProxyUsername, this.httpProxyPassword)); | |||||
| this.httpClientBuilder.setDefaultCredentialsProvider(provider); | |||||
| this.httpClientBuilder.setProxy(new HttpHost(this.httpProxyHost, this.httpProxyPort)); | |||||
| } | |||||
| if (StringUtils.isNotBlank(this.userAgent)) { | |||||
| this.httpClientBuilder.setUserAgent(this.userAgent); | |||||
| } | |||||
| prepared.set(true); | |||||
| } | |||||
| @Override | |||||
| public CloseableHttpClient build() { | |||||
| if (!prepared.get()) { | |||||
| prepare(); | |||||
| } | |||||
| return this.httpClientBuilder.build(); | |||||
| } | |||||
| public DnsResolver getDnsResover() { | |||||
| return dnsResover; | |||||
| } | |||||
| public void setDnsResover(DnsResolver dnsResover) { | |||||
| this.dnsResover = dnsResover; | |||||
| } | |||||
| public static class IdleConnectionMonitorThread extends Thread { | |||||
| private final HttpClientConnectionManager connMgr; | |||||
| private final int idleConnTimeout; | |||||
| private final int checkWaitTime; | |||||
| private volatile boolean shutdown; | |||||
| /** | |||||
| * 构造方法. | |||||
| */ | |||||
| public IdleConnectionMonitorThread(HttpClientConnectionManager connMgr, int idleConnTimeout, int checkWaitTime) { | |||||
| super("IdleConnectionMonitorThread"); | |||||
| this.connMgr = connMgr; | |||||
| this.idleConnTimeout = idleConnTimeout; | |||||
| this.checkWaitTime = checkWaitTime; | |||||
| } | |||||
| @Override | |||||
| public void run() { | |||||
| try { | |||||
| while (!this.shutdown) { | |||||
| synchronized (this) { | |||||
| wait(this.checkWaitTime); | |||||
| this.connMgr.closeExpiredConnections(); | |||||
| this.connMgr.closeIdleConnections(this.idleConnTimeout, TimeUnit.MILLISECONDS); | |||||
| } | |||||
| } | |||||
| } catch (InterruptedException ignore) { | |||||
| Thread.currentThread().interrupt(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 触发. | |||||
| */ | |||||
| public void trigger() { | |||||
| synchronized (this) { | |||||
| notifyAll(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 关闭. | |||||
| */ | |||||
| public void shutdown() { | |||||
| this.shutdown = true; | |||||
| synchronized (this) { | |||||
| notifyAll(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -12,7 +12,7 @@ import javax.net.ssl.SSLSocketFactory; | |||||
| * Stormeye | * Stormeye | ||||
| */ | */ | ||||
| @ConfigurationProperties(prefix = "wechat.redis") | @ConfigurationProperties(prefix = "wechat.redis") | ||||
| public class RedisProperies extends JedisPoolConfig { | |||||
| public class WechatRedisProperies extends JedisPoolConfig { | |||||
| private String host = Protocol.DEFAULT_HOST; | private String host = Protocol.DEFAULT_HOST; | ||||
| private int port = Protocol.DEFAULT_PORT; | private int port = Protocol.DEFAULT_PORT; | ||||
| private String password; | private String password; | ||||
| @@ -21,6 +21,10 @@ public class WxAuthorizerInfo implements Serializable { | |||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="1B端2C端",name="type") | |||||
| private Integer type; | |||||
| @io.swagger.annotations.ApiModelProperty(value="授权方appid",name="authorizerAppid") | @io.swagger.annotations.ApiModelProperty(value="授权方appid",name="authorizerAppid") | ||||
| private String authorizerAppid; | private String authorizerAppid; | ||||
| @io.swagger.annotations.ApiModelProperty(value="授权方头像",name="headImg") | @io.swagger.annotations.ApiModelProperty(value="授权方头像",name="headImg") | ||||
| @@ -75,6 +79,7 @@ public class WxAuthorizerInfo implements Serializable { | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||||
| ,AuthorizerAppid_ASC("`authorizer_appid` ASC"),AuthorizerAppid_DESC("`authorizer_appid` DESC") | ,AuthorizerAppid_ASC("`authorizer_appid` ASC"),AuthorizerAppid_DESC("`authorizer_appid` DESC") | ||||
| ,HeadImg_ASC("`head_img` ASC"),HeadImg_DESC("`head_img` DESC") | ,HeadImg_ASC("`head_img` ASC"),HeadImg_DESC("`head_img` DESC") | ||||
| ,Alias_ASC("`alias` ASC"),Alias_DESC("`alias` DESC") | ,Alias_ASC("`alias` ASC"),Alias_DESC("`alias` DESC") | ||||
| @@ -96,6 +101,7 @@ public class WxAuthorizerInfo implements Serializable { | |||||
| ,ReleaseTime_ASC("`release_time` ASC"),ReleaseTime_DESC("`release_time` DESC") | ,ReleaseTime_ASC("`release_time` ASC"),ReleaseTime_DESC("`release_time` DESC") | ||||
| ,OpenAppId_ASC("`open_appid` ASC"),OpenAppId_DESC("`open_appid` DESC") | ,OpenAppId_ASC("`open_appid` ASC"),OpenAppId_DESC("`open_appid` DESC") | ||||
| ,BindOpenTime_ASC("`bind_open_time` ASC"),BindOpen_DESC("`bind_open_time` DESC") | ,BindOpenTime_ASC("`bind_open_time` ASC"),BindOpen_DESC("`bind_open_time` DESC") | ||||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -157,6 +157,9 @@ public class WxCUser implements Serializable { | |||||
| private Date subsSubscribeTime; | private Date subsSubscribeTime; | ||||
| @io.swagger.annotations.ApiModelProperty(value="关注订阅号Scene",name="subsSubscribeScene") | @io.swagger.annotations.ApiModelProperty(value="关注订阅号Scene",name="subsSubscribeScene") | ||||
| private String subsSubscribeScene; | private String subsSubscribeScene; | ||||
| /**积分**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分",name="credit") | |||||
| private Integer credit; | |||||
| //渠道名称 | //渠道名称 | ||||
| @@ -488,7 +491,15 @@ public class WxCUser implements Serializable { | |||||
| this.subsSubscribeScene = subsSubscribeScene; | this.subsSubscribeScene = subsSubscribeScene; | ||||
| } | } | ||||
| public static enum Field | |||||
| public Integer getCredit() { | |||||
| return credit; | |||||
| } | |||||
| public void setCredit(Integer credit) { | |||||
| this.credit = credit; | |||||
| } | |||||
| public static enum Field | |||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | ||||
| @@ -520,7 +531,9 @@ public class WxCUser implements Serializable { | |||||
| ,LoginCount_ASC("`login_count` ASC"),LoginCount_DESC("`login_count` DESC") | ,LoginCount_ASC("`login_count` ASC"),LoginCount_DESC("`login_count` DESC") | ||||
| ,ExtraInfo_ASC("`extra_info` ASC"),ExtraInfo_DESC("`extra_info` DESC") | ,ExtraInfo_ASC("`extra_info` ASC"),ExtraInfo_DESC("`extra_info` DESC") | ||||
| ,IsSubscribe_ASC("`is_subscribe` ASC"),IsSubscribe_DESC("`is_subscribe` DESC") | ,IsSubscribe_ASC("`is_subscribe` ASC"),IsSubscribe_DESC("`is_subscribe` DESC") | ||||
| ; | |||||
| ,Credit_ASC("`credit` ASC"),Credit_DESC("`credit` DESC") | |||||
| ; | |||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| this.value = value; | this.value = value; | ||||
| @@ -575,12 +588,12 @@ public class WxCUser implements Serializable { | |||||
| } | } | ||||
| public String createToken(Date currentDate) { | public String createToken(Date currentDate) { | ||||
| if (expireTime == null || expireTime.getTime() < currentDate.getTime()) | |||||
| if (expireTime == null || expireTime.getTime() - Constant.H_EXPIRE < currentDate.getTime()) | |||||
| { | { | ||||
| //生成一个token | //生成一个token | ||||
| this.token = UUID.randomUUID().toString(); | this.token = UUID.randomUUID().toString(); | ||||
| //过期时间 | //过期时间 | ||||
| this.expireTime = new Date(currentDate.getTime() + Constant.EXPIRE * 1000); | |||||
| this.expireTime = new Date(currentDate.getTime() + Constant.EXPIRE); | |||||
| } | } | ||||
| return this.token; | return this.token; | ||||
| } | } | ||||
| @@ -11,16 +11,14 @@ import java.util.List; | |||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| public class WxWeappInfo extends WxAuthorizerInfo { | public class WxWeappInfo extends WxAuthorizerInfo { | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端 3-服务号 4-订阅号)",name="type") | |||||
| private Integer type; | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序名称",name="name") | @io.swagger.annotations.ApiModelProperty(value="小程序名称",name="name") | ||||
| private String name; | private String name; | ||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("ai.`id` ASC"),Id_DESC("ai.`id` DESC") | Id_ASC("ai.`id` ASC"),Id_DESC("ai.`id` DESC") | ||||
| ,TenantID_ASC("ai.`tenant_id` ASC"),TenantID_DESC("ai.`tenant_id` DESC") | |||||
| ,Type_ASC("ai.`type` ASC"),Type_DESC("ai.`type` DESC") | |||||
| ,AuthorizerAppid_ASC("ai.`authorizer_appid` ASC"),AuthorizerAppid_DESC("ai.`authorizer_appid` DESC") | ,AuthorizerAppid_ASC("ai.`authorizer_appid` ASC"),AuthorizerAppid_DESC("ai.`authorizer_appid` DESC") | ||||
| ,HeadImg_ASC("ai.`head_img` ASC"),HeadImg_DESC("ai.`head_img` DESC") | ,HeadImg_ASC("ai.`head_img` ASC"),HeadImg_DESC("ai.`head_img` DESC") | ||||
| ,Alias_ASC("ai.`alias` ASC"),Alias_DESC("ai.`alias` DESC") | ,Alias_ASC("ai.`alias` ASC"),Alias_DESC("ai.`alias` DESC") | ||||
| @@ -43,8 +41,6 @@ public class WxWeappInfo extends WxAuthorizerInfo { | |||||
| ,OpenAppid_ASC("ai.`open_appid` ASC"),OpenAppid_DESC("ai.`open_appid` DESC") | ,OpenAppid_ASC("ai.`open_appid` ASC"),OpenAppid_DESC("ai.`open_appid` DESC") | ||||
| ,BindOpenTime_ASC("ai.`bind_open_time` ASC"),BindOpenTime_DESC("ai.`bind_open_time` DESC") | ,BindOpenTime_ASC("ai.`bind_open_time` ASC"),BindOpenTime_DESC("ai.`bind_open_time` DESC") | ||||
| ,Name_ASC("a.`name` ASC"),Name_DESC("a.`name` DESC") | ,Name_ASC("a.`name` ASC"),Name_DESC("a.`name` DESC") | ||||
| ,TenantID_ASC("a.`tenant_id` ASC"),TenantID_DESC("a.`tenant_id` DESC") | |||||
| ,Type_ASC("a.`type` ASC"),Type_DESC("a.`type` DESC") | |||||
| ; | ; | ||||
| private String value; | private String value; | ||||
| Field(String value){ | Field(String value){ | ||||
| @@ -9,11 +9,9 @@ public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, L | |||||
| List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | ||||
| List<WxWeappInfo> findWeappList(); | |||||
| List<WxWeappInfo> findWxMpList(); | |||||
| WxAuthorizerInfo findMp(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| List<WxWeappInfo> findVoList(WxWeappInfo wxWeappInfo); | |||||
| WxAuthorizerInfo findWeChatMp(WxAuthorizerInfo wxAuthorizerInfo); | |||||
| WxWeappInfo findVo(WxWeappInfo wxWeappInfo); | WxWeappInfo findVo(WxWeappInfo wxWeappInfo); | ||||
| @@ -22,10 +20,13 @@ public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, L | |||||
| int updateRefreshToken(WxAuthorizerInfo wxAuthorizerInfo); | int updateRefreshToken(WxAuthorizerInfo wxAuthorizerInfo); | ||||
| int updateAccessToken(WxAuthorizerInfo wxAuthorizerInfo); | int updateAccessToken(WxAuthorizerInfo wxAuthorizerInfo); | ||||
| List<WxWeappInfo> findWeappList(); | |||||
| List<WxWeappInfo> findWxMpList(); | |||||
| List<WxWeappInfo> findVoList(WxWeappInfo wxWeappInfo); | |||||
| } | } | ||||
| @@ -1,7 +1,10 @@ | |||||
| package com.iformall.mapper; | package com.iformall.mapper; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| @@ -2,7 +2,9 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import me.chanjar.weixin.mp.bean.result.WxMpUser; | |||||
| public interface WxCUserService { | public interface WxCUserService { | ||||
| @@ -33,12 +35,12 @@ public interface WxCUserService { | |||||
| WxCUser getByOpenId(WxCUser record); | WxCUser getByOpenId(WxCUser record); | ||||
| /** | /** | ||||
| * 根据openId获得实体 | |||||
| * 根据object获得实体 | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxCUser getByWxOpenId(WxCUser record); | |||||
| WxCUser getByObject(WxCUser record); | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| @@ -48,6 +50,16 @@ public interface WxCUserService { | |||||
| int saveOrUpdate(WxCUser record); | int saveOrUpdate(WxCUser record); | ||||
| /** | /** | ||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param mpUser | |||||
| * @param authorizerInfo | |||||
| */ | |||||
| int saveOrUpdateMpUser(WxMpUser mpUser, WxAuthorizerInfo authorizerInfo); | |||||
| /** | |||||
| >>>>>>> refs/tags/jenkins-back_end_wechat-98 | |||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| * | * | ||||
| * @param id | * @param id | ||||
| @@ -4,9 +4,12 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.mapper.WxCUserMapper; | import com.iformall.mapper.WxCUserMapper; | ||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import me.chanjar.weixin.mp.bean.result.WxMpUser; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -38,8 +41,13 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCUser getByWxOpenId(WxCUser record) { | |||||
| return wxCUserMapper.selectOne(record); | |||||
| public WxCUser getByObject(WxCUser record) { | |||||
| try { | |||||
| return wxCUserMapper.selectOne(record); | |||||
| } catch (Exception e) { | |||||
| logger.error("NOT found: " + e.getMessage()); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -72,6 +80,66 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| @Override | |||||
| public int saveOrUpdateMpUser(WxMpUser mpUser, WxAuthorizerInfo authorizerInfo) { | |||||
| // 1. check user exist | |||||
| WxCUser userQ = new WxCUser(); | |||||
| userQ.setTenantId(authorizerInfo.getTenantId()); | |||||
| boolean bHaveUnionId = false; | |||||
| if(StringUtils.isNotBlank(mpUser.getUnionId())) { | |||||
| userQ.setUnionId(mpUser.getUnionId()); | |||||
| bHaveUnionId = true; | |||||
| } else { | |||||
| userQ.setOpenAppId(authorizerInfo.getOpenAppid()); | |||||
| if(authorizerInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setMpOpenId(mpUser.getOpenId()); | |||||
| userQ.setMpAppId(authorizerInfo.getAuthorizerAppid()); | |||||
| } else if(authorizerInfo.getType().equals(EnumAppType.MP_P.getCode())) { | |||||
| userQ.setSubsOpenId(mpUser.getOpenId()); | |||||
| userQ.setSubsAppId(authorizerInfo.getAuthorizerAppid()); | |||||
| } | |||||
| } | |||||
| WxCUser oldUser = getByObject(userQ); | |||||
| boolean bHave = false; | |||||
| if(oldUser != null) { | |||||
| userQ.setId(oldUser.getId()); | |||||
| bHave = true; | |||||
| } | |||||
| if(!bHave && !mpUser.getSubscribe()) { | |||||
| // 未找到,且是关注消息, 直接返回 | |||||
| return 0; | |||||
| } | |||||
| if(bHaveUnionId) { | |||||
| userQ.setOpenAppId(authorizerInfo.getOpenAppid()); | |||||
| if (authorizerInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setMpOpenId(mpUser.getOpenId()); | |||||
| userQ.setMpAppId(authorizerInfo.getAuthorizerAppid()); | |||||
| } else if (authorizerInfo.getType().equals(EnumAppType.MP_P.getCode())) { | |||||
| userQ.setSubsOpenId(mpUser.getOpenId()); | |||||
| userQ.setSubsAppId(authorizerInfo.getAuthorizerAppid()); | |||||
| } | |||||
| } | |||||
| if(((oldUser != null && StringUtils.isBlank(oldUser.getNickName())) || (oldUser == null)) | |||||
| && StringUtils.isNotBlank(mpUser.getNickname())) { | |||||
| userQ.setNickName(mpUser.getNickname()); | |||||
| userQ.setGender(mpUser.getSex()); | |||||
| userQ.setAvatarUrl(mpUser.getHeadImgUrl()); | |||||
| userQ.setCity(mpUser.getCity()); | |||||
| userQ.setProvince(mpUser.getProvince()); | |||||
| userQ.setLanguage(mpUser.getLanguage()); | |||||
| } | |||||
| if(authorizerInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setMpSubscribe(mpUser.getSubscribe()?1:0); | |||||
| userQ.setMpSubscribeScene(mpUser.getSubscribeScene()); | |||||
| userQ.setMpSubscribeTime(new Date(mpUser.getSubscribeTime())); | |||||
| } else if(authorizerInfo.getType().equals(EnumAppType.MP_P.getCode())) { | |||||
| userQ.setSubsSubscribe(mpUser.getSubscribe()?1:0); | |||||
| userQ.setSubsSubscribeScene(mpUser.getSubscribeScene()); | |||||
| userQ.setMpSubscribeTime(new Date(mpUser.getSubscribeTime())); | |||||
| } | |||||
| return saveOrUpdate(userQ); | |||||
| } | |||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxCUserMapper.deleteByPrimaryKey(id); | wxCUserMapper.deleteByPrimaryKey(id); | ||||
| @@ -1,23 +1,23 @@ | |||||
| package com.iformall.service.wechat; | package com.iformall.service.wechat; | ||||
| import com.iformall.common.FmHttpClientBuilder; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | import com.iformall.domain.po.WxAuthorizerInfo; | ||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | import com.iformall.domain.po.WxComponentVerifyTicket; | ||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | import com.iformall.mapper.WxAuthorizerInfoMapper; | ||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | import com.iformall.mapper.WxComponentVerifyTicketMapper; | ||||
| import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | |||||
| import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | ||||
| import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken; | import me.chanjar.weixin.open.bean.WxOpenAuthorizerAccessToken; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Component; | |||||
| import redis.clients.jedis.Jedis; | import redis.clients.jedis.Jedis; | ||||
| import redis.clients.jedis.JedisPool; | import redis.clients.jedis.JedisPool; | ||||
| import redis.clients.util.Pool; | import redis.clients.util.Pool; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| public class WxOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||||
| public class FmOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||||
| private final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:"; | private final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:"; | ||||
| private final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:"; | private final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:"; | ||||
| @@ -45,16 +45,16 @@ public class WxOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| public WxOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool) { | |||||
| public FmOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool) { | |||||
| this.jedisPool = jedisPool; | this.jedisPool = jedisPool; | ||||
| } | } | ||||
| public WxOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool, String keyPrefix) { | |||||
| public FmOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool, String keyPrefix) { | |||||
| this.jedisPool = jedisPool; | this.jedisPool = jedisPool; | ||||
| this.keyPrefix = keyPrefix; | this.keyPrefix = keyPrefix; | ||||
| } | } | ||||
| public WxOpenInRedisDBConfigStorage(JedisPool jedisPool, WxComponentVerifyTicketMapper componentVerifyTicketMapper, WxAuthorizerInfoMapper authorizerInfoMapper) { | |||||
| public FmOpenInRedisDBConfigStorage(JedisPool jedisPool, WxComponentVerifyTicketMapper componentVerifyTicketMapper, WxAuthorizerInfoMapper authorizerInfoMapper) { | |||||
| this.jedisPool = jedisPool; | this.jedisPool = jedisPool; | ||||
| this.wxComponentVerifyTicketMapper = componentVerifyTicketMapper; | this.wxComponentVerifyTicketMapper = componentVerifyTicketMapper; | ||||
| this.wxAuthorizerInfoMapper = authorizerInfoMapper; | this.wxAuthorizerInfoMapper = authorizerInfoMapper; | ||||
| @@ -245,4 +245,9 @@ public class WxOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||||
| // TODO update to DB | // TODO update to DB | ||||
| } | } | ||||
| @Override | |||||
| public ApacheHttpClientBuilder getApacheHttpClientBuilder() { | |||||
| return FmHttpClientBuilder.get(); | |||||
| } | |||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| package com.iformall.service.wechat; | package com.iformall.service.wechat; | ||||
| import com.iformall.config.RedisProperies; | |||||
| import com.iformall.config.WechatRedisProperies; | |||||
| import com.iformall.config.WechatOpenProperties; | import com.iformall.config.WechatOpenProperties; | ||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | import com.iformall.mapper.WxAuthorizerInfoMapper; | ||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | import com.iformall.mapper.WxComponentVerifyTicketMapper; | ||||
| @@ -19,13 +19,13 @@ import javax.annotation.PostConstruct; | |||||
| * Stormeye WU | * Stormeye WU | ||||
| */ | */ | ||||
| @Service | @Service | ||||
| @EnableConfigurationProperties({WechatOpenProperties.class, RedisProperies.class}) | |||||
| public class WxOpenService extends WxOpenServiceImpl { | |||||
| @EnableConfigurationProperties({WechatOpenProperties.class, WechatRedisProperies.class}) | |||||
| public class FmOpenService extends WxOpenServiceImpl { | |||||
| private Logger logger = LoggerFactory.getLogger(getClass()); | private Logger logger = LoggerFactory.getLogger(getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WechatOpenProperties wechatProperties; | private WechatOpenProperties wechatProperties; | ||||
| @Autowired | @Autowired | ||||
| private RedisProperies redisProperies; | |||||
| private WechatRedisProperies redisProperies; | |||||
| @Autowired | @Autowired | ||||
| private WxComponentVerifyTicketMapper componentVerifyTicketMapper; | private WxComponentVerifyTicketMapper componentVerifyTicketMapper; | ||||
| @@ -38,7 +38,7 @@ public class WxOpenService extends WxOpenServiceImpl { | |||||
| @PostConstruct | @PostConstruct | ||||
| public void init() { | public void init() { | ||||
| WxOpenInRedisDBConfigStorage configStorage = new WxOpenInRedisDBConfigStorage(getJedisPool(), componentVerifyTicketMapper, authorizerInfoMapper); | |||||
| FmOpenInRedisDBConfigStorage configStorage = new FmOpenInRedisDBConfigStorage(getJedisPool(), componentVerifyTicketMapper, authorizerInfoMapper); | |||||
| configStorage.setComponentAppId(wechatProperties.getComponentAppId()); | configStorage.setComponentAppId(wechatProperties.getComponentAppId()); | ||||
| configStorage.setComponentAppSecret(wechatProperties.getComponentSecret()); | configStorage.setComponentAppSecret(wechatProperties.getComponentSecret()); | ||||
| configStorage.setComponentToken(wechatProperties.getComponentToken()); | configStorage.setComponentToken(wechatProperties.getComponentToken()); | ||||
| @@ -57,7 +57,7 @@ public class WxOpenService extends WxOpenServiceImpl { | |||||
| private JedisPool getJedisPool() { | private JedisPool getJedisPool() { | ||||
| if (pool == null) { | if (pool == null) { | ||||
| synchronized (WxOpenService.class) { | |||||
| synchronized (FmOpenService.class) { | |||||
| if (pool == null) { | if (pool == null) { | ||||
| pool = new JedisPool(redisProperies, redisProperies.getHost(), | pool = new JedisPool(redisProperies, redisProperies.getHost(), | ||||
| redisProperies.getPort(), redisProperies.getConnectionTimeout(), | redisProperies.getPort(), redisProperies.getConnectionTimeout(), | ||||
| @@ -3,10 +3,10 @@ package com.iformall.utils; | |||||
| public class Constant { | public class Constant { | ||||
| // 1小时过期, | // 1小时过期, | ||||
| public final static int C_EXPIRE = 3600000; | |||||
| public final static int H_EXPIRE = 3600000; | |||||
| // TOKEN过期时间, 24小时后过期 | // TOKEN过期时间, 24小时后过期 | ||||
| public final static int EXPIRE = 3600 * 24; | |||||
| public final static int EXPIRE = H_EXPIRE * 24; | |||||
| // C端token | // C端token | ||||
| public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; | public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; | ||||
| @@ -3,6 +3,8 @@ | |||||
| <mapper namespace="com.iformall.mapper.WxAuthorizerInfoMapper"> | <mapper namespace="com.iformall.mapper.WxAuthorizerInfoMapper"> | ||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxAuthorizerInfo"> | <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxAuthorizerInfo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id"/> | <id column="id" jdbcType="BIGINT" property="id"/> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||||
| <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid"/> | <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid"/> | ||||
| <result column="head_img" jdbcType="VARCHAR" property="headImg"/> | <result column="head_img" jdbcType="VARCHAR" property="headImg"/> | ||||
| <result column="alias" jdbcType="VARCHAR" property="alias"/> | <result column="alias" jdbcType="VARCHAR" property="alias"/> | ||||
| @@ -30,7 +32,7 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status`,`auth_time`, | |||||
| `id`,`tenant_id`,`type`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status`,`auth_time`, | |||||
| `base_status`, `base_time`, `domain_status`, `domain_time`, `webdomain_status`, `webdomain_time`, `template_status`, `template_time`, | `base_status`, `base_time`, `domain_status`, `domain_time`, `webdomain_status`, `webdomain_time`, `template_status`, `template_time`, | ||||
| `current_version`,`current_desc`,`release_time`, | `current_version`,`current_desc`,`release_time`, | ||||
| `open_appid`,`bind_open_time`,`refresh_token`, | `open_appid`,`bind_open_time`,`refresh_token`, | ||||
| @@ -42,6 +44,12 @@ | |||||
| <if test=" null != id "> | <if test=" null != id "> | ||||
| and `id` = #{id} | and `id` = #{id} | ||||
| </if> | </if> | ||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != authorizerAppid "> | <if test=" null != authorizerAppid "> | ||||
| and `authorizer_appid` = #{authorizerAppid} | and `authorizer_appid` = #{authorizerAppid} | ||||
| </if> | </if> | ||||
| @@ -139,8 +147,25 @@ | |||||
| where `authorizer_appid` = #{authorizerAppid} | where `authorizer_appid` = #{authorizerAppid} | ||||
| </update> | </update> | ||||
| <select id="findMp" parameterType="com.iformall.domain.po.WxAuthorizerInfo" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| FROM wx_authorizer_info | |||||
| where open_appid = (select open_appid from wx_authorizer_info where authorizer_appid = #{authorizerAppid}) | |||||
| and `type` = 3 and `tenant_id` = #{tenantId} | |||||
| </select> | |||||
| <select id="findWeChatMp" parameterType="com.iformall.domain.po.WxAuthorizerInfo" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_authorizer_info | |||||
| where `authorizer_appid` = #{authorizerAppid} | |||||
| </select> | |||||
| <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.WxWeappInfo"> | <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.WxWeappInfo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id"/> | <id column="id" jdbcType="BIGINT" property="id"/> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||||
| <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid"/> | <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid"/> | ||||
| <result column="head_img" jdbcType="VARCHAR" property="headImg"/> | <result column="head_img" jdbcType="VARCHAR" property="headImg"/> | ||||
| <result column="alias" jdbcType="VARCHAR" property="alias"/> | <result column="alias" jdbcType="VARCHAR" property="alias"/> | ||||
| @@ -162,13 +187,11 @@ | |||||
| <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime"/> | <result column="release_time" jdbcType="TIMESTAMP" property="releaseTime"/> | ||||
| <result column="open_appid" jdbcType="VARCHAR" property="openAppid"/> | <result column="open_appid" jdbcType="VARCHAR" property="openAppid"/> | ||||
| <result column="bind_open_time" jdbcType="TIMESTAMP" property="bindOpenTime"/> | <result column="bind_open_time" jdbcType="TIMESTAMP" property="bindOpenTime"/> | ||||
| <result column="tenant_id" jdbcType="INTEGER" property="tenantId"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||||
| <result column="name" jdbcType="TIMESTAMP" property="name"/> | |||||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allVColumns"> | <sql id="allVColumns"> | ||||
| ai.`id`,ai.`authorizer_appid`,ai.`head_img`,ai.`alias`,ai.`qrcode_url`,ai.`create_time`,ai.`update_time`, | |||||
| ai.`id`,ai.`tenant_id`,ai.`type`,ai.`authorizer_appid`,ai.`head_img`,ai.`alias`,ai.`qrcode_url`,ai.`create_time`,ai.`update_time`, | |||||
| ai.`authorization_status`,ai.`auth_time`, | ai.`authorization_status`,ai.`auth_time`, | ||||
| ai.`base_status`,ai.`base_time`, | ai.`base_status`,ai.`base_time`, | ||||
| ai.`domain_status`,ai.`domain_time`, | ai.`domain_status`,ai.`domain_time`, | ||||
| @@ -176,7 +199,7 @@ | |||||
| ai.`template_status`,ai.`template_time`, | ai.`template_status`,ai.`template_time`, | ||||
| ai.`current_version`,ai.`current_desc`,ai.`release_time`, | ai.`current_version`,ai.`current_desc`,ai.`release_time`, | ||||
| ai.`open_appid`,ai.`bind_open_time`, | ai.`open_appid`,ai.`bind_open_time`, | ||||
| a.`tenant_id`,a.`type`,a.`name` | |||||
| a.`name` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicVWhereConditions"> | <sql id="dynamicVWhereConditions"> | ||||
| @@ -187,8 +210,11 @@ | |||||
| <if test=" null != name "> | <if test=" null != name "> | ||||
| and a.`name` like concat('%', #{name},'%') | and a.`name` like concat('%', #{name},'%') | ||||
| </if> | </if> | ||||
| <if test=" null != tenantId "> | |||||
| and ai.`tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != type "> | <if test=" null != type "> | ||||
| and a.`type` = #{type} | |||||
| and ai.`type` = #{type} | |||||
| </if> | </if> | ||||
| <if test=" null != authorizerAppid "> | <if test=" null != authorizerAppid "> | ||||
| and ai.`authorizer_appid` = #{authorizerAppid} | and ai.`authorizer_appid` = #{authorizerAppid} | ||||
| @@ -246,15 +272,7 @@ | |||||
| <include refid="dynamicVWhereConditions"/> | <include refid="dynamicVWhereConditions"/> | ||||
| </select> | </select> | ||||
| <select id="findVo" parameterType="com.iformall.domain.vo.WxWeappInfo" resultMap="VBaseResultMap"> | |||||
| select | |||||
| <include refid="allVColumns"/> | |||||
| from wx_authorizer_info ai | |||||
| left join wx_appinfo a on ai.`authorizer_appid` = a.app_id | |||||
| where ai.`authorizer_appid` = #{authorizerAppid} | |||||
| </select> | |||||
| <select id="findWeappList" resultMap="BaseResultMap"> | |||||
| <select id="findWeappList" resultMap="VBaseResultMap"> | |||||
| select | select | ||||
| <include refid="allVColumns"/> | <include refid="allVColumns"/> | ||||
| from wx_authorizer_info ai | from wx_authorizer_info ai | ||||
| @@ -262,7 +280,7 @@ | |||||
| where a.type = 1 or a.type = 2 | where a.type = 1 or a.type = 2 | ||||
| </select> | </select> | ||||
| <select id="findWxMpList" resultMap="BaseResultMap"> | |||||
| <select id="findWxMpList" resultMap="VBaseResultMap"> | |||||
| select | select | ||||
| <include refid="allVColumns"/> | <include refid="allVColumns"/> | ||||
| from wx_authorizer_info ai | from wx_authorizer_info ai | ||||
| @@ -43,6 +43,7 @@ | |||||
| <result column="subs_subscribe" jdbcType="TINYINT" property="subsSubscribe"/> | <result column="subs_subscribe" jdbcType="TINYINT" property="subsSubscribe"/> | ||||
| <result column="subs_subscribe_time" jdbcType="TIMESTAMP" property="subsSubscribeTime"/> | <result column="subs_subscribe_time" jdbcType="TIMESTAMP" property="subsSubscribeTime"/> | ||||
| <result column="subs_subscribe_scene" jdbcType="VARCHAR" property="subsSubscribeScene"/> | <result column="subs_subscribe_scene" jdbcType="VARCHAR" property="subsSubscribeScene"/> | ||||
| <result column="credit" jdbcType="INTEGER" property="credit"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| @@ -53,7 +54,7 @@ | |||||
| `login_count`, `extra_info`, `is_subscribe`, | `login_count`, `extra_info`, `is_subscribe`, | ||||
| `open_app_id`, | `open_app_id`, | ||||
| `mp_open_id`,`mp_app_id`,`mp_subscribe`,`mp_subscribe_time`,`mp_subscribe_scene`, | `mp_open_id`,`mp_app_id`,`mp_subscribe`,`mp_subscribe_time`,`mp_subscribe_scene`, | ||||
| `subs_open_id`,`subs_app_id`,`subs_subscribe`,`subs_subscribe_time`,`subs_subscribe_scene` | |||||
| `subs_open_id`,`subs_app_id`,`subs_subscribe`,`subs_subscribe_time`,`subs_subscribe_scene`,`credit` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -68,11 +69,11 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != openId "> | <if test=" null != openId "> | ||||
| and `open_id` like concat('%', #{openId},'%') | |||||
| and `open_id` = #{openId} | |||||
| </if> | </if> | ||||
| <if test=" null != unionId "> | <if test=" null != unionId "> | ||||
| and `union_id` like concat('%', #{unionId},'%') | |||||
| and `union_id` = #{unionId} | |||||
| </if> | </if> | ||||
| <if test=" null != nickName "> | <if test=" null != nickName "> | ||||
| @@ -175,10 +176,6 @@ | |||||
| and `extra_info` = #{extraInfo} | and `extra_info` = #{extraInfo} | ||||
| </if> | </if> | ||||
| <if test=" null != isSubscribe "> | |||||
| and `is_subscribe` = #{isSubscribe} | |||||
| </if> | |||||
| <if test=" null != openAppId "> | <if test=" null != openAppId "> | ||||
| and `open_app_id` = #{openAppId} | and `open_app_id` = #{openAppId} | ||||
| </if> | </if> | ||||
| @@ -199,6 +196,10 @@ | |||||
| and `subs_app_id` = #{subsAppId} | and `subs_app_id` = #{subsAppId} | ||||
| </if> | </if> | ||||
| <if test=" null != credit "> | |||||
| and `credit` = #{credit} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -4,7 +4,7 @@ | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPayAccount"> | <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPayAccount"> | ||||
| <id column="id" jdbcType="BIGINT" property="id"/> | <id column="id" jdbcType="BIGINT" property="id"/> | ||||
| <result column="mch_id" jdbcType="VARCHAR" property="mchId"/> | <result column="mch_id" jdbcType="VARCHAR" property="mchId"/> | ||||
| <result column="parent_mch_id" jdbcType="VARCHAR" property="parentMchId"/> | |||||
| <result column="sub_mch_id" jdbcType="VARCHAR" property="subMchId"/> | |||||
| <result column="api_key" jdbcType="VARCHAR" property="apiKey"/> | <result column="api_key" jdbcType="VARCHAR" property="apiKey"/> | ||||
| <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/> | <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/> | ||||
| <result column="cert_path" jdbcType="VARCHAR" property="certPath"/> | <result column="cert_path" jdbcType="VARCHAR" property="certPath"/> | ||||
| @@ -14,7 +14,7 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`mch_id`,`parent_mch_id`,`api_key`,`notify_url`,`cert_path`,`type`,`share`,`rate` | |||||
| `id`,`mch_id`,`sub_mch_id`,`api_key`,`notify_url`,`cert_path`,`type`,`share`,`rate` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -25,11 +25,11 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != mchId "> | <if test=" null != mchId "> | ||||
| and `mch_id` like concat('%', #{mchId},'%') | |||||
| and `mch_id` = #{mchId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentMchId "> | |||||
| and `parent_mch_id` like concat('%', #{parentMchId},'%') | |||||
| <if test=" null != subMchId "> | |||||
| and `sub_mch_id` = #{subMchId} | |||||
| </if> | </if> | ||||
| <if test=" null != apiKey "> | <if test=" null != apiKey "> | ||||
| @@ -13,8 +13,6 @@ | |||||
| <artifactId>mlWechatOpen</artifactId> | <artifactId>mlWechatOpen</artifactId> | ||||
| <properties> | <properties> | ||||
| <weixin-java-mp.version>3.3.0.A</weixin-java-mp.version> | |||||
| <weixin-java-open.version>3.3.0.A</weixin-java-open.version> | |||||
| </properties> | </properties> | ||||
| <dependencies> | <dependencies> | ||||
| @@ -23,16 +21,6 @@ | |||||
| <artifactId>mallinkService</artifactId> | <artifactId>mallinkService</artifactId> | ||||
| <version>1.0</version> | <version>1.0</version> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-open</artifactId> | |||||
| <version>${weixin-java-open.version}</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-mp</artifactId> | |||||
| <version>${weixin-java-mp.version}</version> | |||||
| </dependency> | |||||
| <dependency> | <dependency> | ||||
| <groupId>com.google.zxing</groupId> | <groupId>com.google.zxing</groupId> | ||||
| <artifactId>core</artifactId> | <artifactId>core</artifactId> | ||||
| @@ -3,7 +3,7 @@ package com.iformall.controller; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | import com.iformall.domain.po.WxAuthorizerInfo; | ||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | import com.iformall.enums.EnumWxAuthorizationStatus; | ||||
| import com.iformall.service.WxAuthorizerInfoService; | import com.iformall.service.WxAuthorizerInfoService; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| @@ -29,7 +29,7 @@ import java.util.Date; | |||||
| public class WechatAuthController { | public class WechatAuthController { | ||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | private final Logger logger = LoggerFactory.getLogger(getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxAuthorizerInfoService authorizerInfoService; | private WxAuthorizerInfoService authorizerInfoService; | ||||
| @@ -8,7 +8,7 @@ import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mp.manager.WxMpManager; | import com.iformall.mp.manager.WxMpManager; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| @@ -45,7 +45,7 @@ public class WechatCalllbackController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| protected WxOpenService openService; | |||||
| protected FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxComponentVerifyTicketService componentVerifyTicketService; | private WxComponentVerifyTicketService componentVerifyTicketService; | ||||
| @@ -234,12 +234,13 @@ public class WechatCalllbackController extends BaseController { | |||||
| return; | return; | ||||
| } | } | ||||
| WxAppinfo appinfo = appinfoService.getByAppId(appId); | |||||
| WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); | |||||
| PrintWriter printWriter = response.getWriter(); | PrintWriter printWriter = response.getWriter(); | ||||
| if(appinfo.getType().equals(EnumAppType.B.getCode()) || | |||||
| appinfo.getType().equals(EnumAppType.C.getCode())) { | |||||
| if(authorizerInfo != null && | |||||
| (authorizerInfo.getType().equals(EnumAppType.B.getCode()) || | |||||
| authorizerInfo.getType().equals(EnumAppType.C.getCode()))) { | |||||
| // 小程序 审核 消息 | // 小程序 审核 消息 | ||||
| /**判断消息类型,调用对应的方法*/ | /**判断消息类型,调用对应的方法*/ | ||||
| switch (inMessage.getMsgType()) { | switch (inMessage.getMsgType()) { | ||||
| @@ -1,6 +1,5 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.google.gson.Gson; | import com.google.gson.Gson; | ||||
| import com.google.gson.GsonBuilder; | import com.google.gson.GsonBuilder; | ||||
| import com.google.gson.reflect.TypeToken; | import com.google.gson.reflect.TypeToken; | ||||
| @@ -11,7 +10,7 @@ import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.vo.WxWeappCodeStatusVo; | import com.iformall.domain.vo.WxWeappCodeStatusVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -48,7 +47,7 @@ import java.util.Map; | |||||
| public class WechatWeappCodeController { | public class WechatWeappCodeController { | ||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | private final Logger logger = LoggerFactory.getLogger(getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxWeappCodeStatusService weappCodeStatusService; | private WxWeappCodeStatusService weappCodeStatusService; | ||||
| @@ -439,7 +438,15 @@ public class WechatWeappCodeController { | |||||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | ||||
| WxOpenResult openRet = openMaService.releaesAudited(); | WxOpenResult openRet = openMaService.releaesAudited(); | ||||
| logger.info(openRet.toString()); | logger.info(openRet.toString()); | ||||
| <<<<<<< HEAD | |||||
| if(openRet.isSuccess()) { | if(openRet.isSuccess()) { | ||||
| ======= | |||||
| boolean releaseSuccess = false; | |||||
| if(openRet.isSuccess()) { | |||||
| releaseSuccess = true; | |||||
| } | |||||
| if(releaseSuccess) { | |||||
| >>>>>>> refs/tags/jenkins-back_end_wechat-98 | |||||
| releaseStatus.setReleaseStatus(EnumWeappReleaseStatus.SUCCESS.getCode()); | releaseStatus.setReleaseStatus(EnumWeappReleaseStatus.SUCCESS.getCode()); | ||||
| } else { | } else { | ||||
| if(openRet.getErrcode().equalsIgnoreCase("85052")) { // app is already released | if(openRet.getErrcode().equalsIgnoreCase("85052")) { // app is already released | ||||
| @@ -2,7 +2,7 @@ package com.iformall.controller; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | ||||
| @@ -22,7 +22,7 @@ import java.util.List; | |||||
| public class WechatWeappDraftTemplateController { | public class WechatWeappDraftTemplateController { | ||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | private final Logger logger = LoggerFactory.getLogger(getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @GetMapping("/tempDraftList") | @GetMapping("/tempDraftList") | ||||
| @@ -8,10 +8,14 @@ import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | import com.iformall.domain.po.WxAuthorizerInfo; | ||||
| import com.iformall.domain.po.WxTemplateMsg; | |||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | import com.iformall.enums.EnumWxAuthorizationStatus; | ||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.WxAuthorizerInfoService; | import com.iformall.service.WxAuthorizerInfoService; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.WxTemplateMsgService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -34,11 +38,17 @@ import java.util.List; | |||||
| public class WechatWeappMsgTemplateController { | public class WechatWeappMsgTemplateController { | ||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | private final Logger logger = LoggerFactory.getLogger(getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxAuthorizerInfoService authorizerInfoService; | private WxAuthorizerInfoService authorizerInfoService; | ||||
| @Autowired | |||||
| private WxAppinfoService appinfoService; | |||||
| @Autowired | |||||
| private WxTemplateMsgService templateMsgService; | |||||
| @ApiOperation("获取小程序模板库标题列表") | @ApiOperation("获取小程序模板库标题列表") | ||||
| @GetMapping("getTmpLibList") | @GetMapping("getTmpLibList") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -123,6 +133,22 @@ public class WechatWeappMsgTemplateController { | |||||
| @ApiOperation("删除帐号下的某个模板") | @ApiOperation("删除帐号下的某个模板") | ||||
| @PostMapping("delTemplate") | @PostMapping("delTemplate") | ||||
| public ResultData delTemplate(@RequestParam(value = "appId") String appId, @RequestParam(value = "templateId") String templateId) { | public ResultData delTemplate(@RequestParam(value = "appId") String appId, @RequestParam(value = "templateId") String templateId) { | ||||
| // check app | |||||
| WxAppinfo appinfo = appinfoService.getByAppId(appId); | |||||
| if(appinfo == null) { | |||||
| String msg = "此appId未纳入管理,请联系管理员"; | |||||
| logger.error(msg); | |||||
| return new ResultData(Result.ERROR, msg); | |||||
| } | |||||
| WxTemplateMsg msgQ = new WxTemplateMsg(); | |||||
| msgQ.setTemplateId(templateId); | |||||
| msgQ.setTenantId(appinfo.getTenantId()); | |||||
| WxTemplateMsg msg = templateMsgService.getByObj(msgQ); | |||||
| if(msg != null) { | |||||
| String msgStr = "此模板正被使用,请不要删除"; | |||||
| logger.error(msgStr); | |||||
| return new ResultData(Result.ERROR, msgStr); | |||||
| } | |||||
| try { | try { | ||||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | ||||
| maService.getTemplateService().delTemplate(templateId); | maService.getTemplateService().delTemplate(templateId); | ||||
| @@ -8,7 +8,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | import com.iformall.domain.po.WxAuthorizerInfo; | ||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | import com.iformall.enums.EnumWxAuthorizationStatus; | ||||
| import com.iformall.service.WxAuthorizerInfoService; | import com.iformall.service.WxAuthorizerInfoService; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| @@ -33,7 +33,7 @@ import java.util.Map; | |||||
| public class WechatWeappSetController { | public class WechatWeappSetController { | ||||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | private final Logger logger = LoggerFactory.getLogger(getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxAuthorizerInfoService authorizerInfoService; | private WxAuthorizerInfoService authorizerInfoService; | ||||
| @@ -19,12 +19,11 @@ import com.iformall.domain.vo.WxWeappInfo; | |||||
| import com.iformall.domain.vo.WxWeappReleaseStatusVo; | import com.iformall.domain.vo.WxWeappReleaseStatusVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import io.swagger.models.auth.In; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | import me.chanjar.weixin.open.api.WxOpenMaService; | ||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | ||||
| @@ -73,7 +72,7 @@ public class WxWeappInfoController extends BaseController { | |||||
| private WxWeappReleaseStatusService weappReleaseStatusService; | private WxWeappReleaseStatusService weappReleaseStatusService; | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService appinfoService; | private WxAppinfoService appinfoService; | ||||
| @@ -1,10 +1,8 @@ | |||||
| package com.iformall.mp.controller; | package com.iformall.mp.controller; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.vo.WxWeappInfo; | |||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.enums.EnumWechatSubscribe; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||||
| import com.iformall.mp.manager.WxMpManager; | import com.iformall.mp.manager.WxMpManager; | ||||
| import com.iformall.service.WxAuthorizerInfoService; | import com.iformall.service.WxAuthorizerInfoService; | ||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| @@ -21,7 +19,6 @@ import org.springframework.web.bind.annotation.PathVariable; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| /** | /** | ||||
| @@ -32,68 +29,85 @@ import java.util.List; | |||||
| public class WxMemController { | public class WxMemController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private WxAuthorizerInfoService authorizerInfoService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService userService; | private WxCUserService userService; | ||||
| @Autowired | @Autowired | ||||
| private WxMpManager wxMpManager; | private WxMpManager wxMpManager; | ||||
| @Autowired | |||||
| private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; | |||||
| @GetMapping("/syncAccountFansList") | @GetMapping("/syncAccountFansList") | ||||
| public ResultData syncAccountFansList(@PathVariable String appId) throws WxErrorException { | |||||
| final WxWeappInfo weappInfo = authorizerInfoService.getWeappByAppId(appId); | |||||
| if(weappInfo.getType().equals(EnumAppType.MP_S.getCode()) || weappInfo.getType().equals(EnumAppType.MP_P.getCode())) { | |||||
| final WxMpService wxService = wxMpManager.getMpService(appId); | |||||
| public ResultData syncAccountFansList(@PathVariable String appId) { | |||||
| final WxMpService wxService = wxMpManager.getMpService(appId); | |||||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||||
| authQ.setAuthorizerAppid(appId); | |||||
| WxAuthorizerInfo authorizerInfo = wxAuthorizerInfoMapper.findWeChatMp(authQ); | |||||
| String nextOpenId = null; | |||||
| String nextOpenId = null; | |||||
| while (true) { | |||||
| WxMpUserList mpUserList; | |||||
| try { | |||||
| mpUserList = wxService.getUserService().userList(nextOpenId); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("获取粉丝openIds出错: " + e.getMessage()); | |||||
| break; | |||||
| } | |||||
| logger.info(mpUserList.toString()); | |||||
| getBatchUserInfos(wxService, mpUserList, authorizerInfo); | |||||
| nextOpenId = mpUserList.getNextOpenid(); | |||||
| if(StringUtils.isBlank(nextOpenId)) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private void getBatchUserInfos(WxMpService wxService, WxMpUserList mpUserList, WxAuthorizerInfo authorizerInfo) { | |||||
| List<String> openIds = mpUserList.getOpenids(); | |||||
| if(openIds.size() > 100) { | |||||
| int index = 0; | |||||
| int index_end = index + 100; | |||||
| while(true) { | while(true) { | ||||
| nextOpenId = syncUsers(wxService, weappInfo, nextOpenId); | |||||
| if(StringUtils.isBlank(nextOpenId)) | |||||
| if(openIds.size()-1 > index_end) { | |||||
| getBatchUserInfo(wxService, openIds.subList(index, index_end), authorizerInfo); | |||||
| } else if(openIds.size()-1 > index) { | |||||
| getBatchUserInfo(wxService, openIds.subList(index, openIds.size()-1), authorizerInfo); | |||||
| } else { | |||||
| break; | break; | ||||
| } | |||||
| index += 100; | |||||
| index_end = index + 100; | |||||
| } | } | ||||
| } else { | |||||
| getBatchUserInfo(wxService, openIds, authorizerInfo); | |||||
| } | } | ||||
| return new ResultData(); | |||||
| } | } | ||||
| private String syncUsers(WxMpService wxMpService, WxWeappInfo appinfo, String nextOpenId) throws WxErrorException { | |||||
| WxMpUserList mpUserList = wxMpService.getUserService().userList(nextOpenId); | |||||
| logger.info(mpUserList.toString()); | |||||
| if(mpUserList.getOpenids().size() <= 0){ | |||||
| return mpUserList.getNextOpenid(); | |||||
| private void getBatchUserInfo(WxMpService wxService, List<String> openIds, WxAuthorizerInfo authorizerInfo) { | |||||
| if(openIds.size() <= 0) { | |||||
| return; | |||||
| } | |||||
| List<WxMpUser> userList = null; | |||||
| try{ | |||||
| userList = wxService.getUserService().userInfoList(openIds); | |||||
| } catch (WxErrorException e) { | |||||
| logger.error("batchget userinfo list error: " + e.getMessage()); | |||||
| return; | |||||
| } | } | ||||
| List<WxMpUser> userList = wxMpService.getUserService().userInfoList(mpUserList.getOpenids()); | |||||
| logger.info(userList.toString()); | |||||
| userList.stream().forEach(mpuser -> { | |||||
| WxCUser user = new WxCUser(); | |||||
| user.setUnionId(mpuser.getUnionId()); | |||||
| user.setOpenAppId(appinfo.getOpenAppid()); | |||||
| if(appinfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| user.setMpAppId(appinfo.getAuthorizerAppid()); | |||||
| user.setMpOpenId(mpuser.getOpenId()); | |||||
| user.setMpSubscribe(EnumWechatSubscribe.YES.getCode()); | |||||
| user.setMpSubscribeTime(new Date(mpuser.getSubscribeTime())); | |||||
| user.setMpSubscribeScene(mpuser.getSubscribeScene()); | |||||
| } else if(appinfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| user.setSubsAppId(appinfo.getAuthorizerAppid()); | |||||
| user.setSubsOpenId(mpuser.getOpenId()); | |||||
| user.setSubsSubscribe(EnumWechatSubscribe.YES.getCode()); | |||||
| user.setSubsSubscribeTime(new Date(mpuser.getSubscribeTime())); | |||||
| user.setSubsSubscribeScene(mpuser.getSubscribeScene()); | |||||
| if(userList != null) { | |||||
| logger.info(userList.toString()); | |||||
| for(WxMpUser mpUser: userList) { | |||||
| try { | |||||
| userService.saveOrUpdateMpUser(mpUser, authorizerInfo); | |||||
| } catch (Exception e) { | |||||
| logger.error("保存用户出错: " + e.getMessage()); | |||||
| } | |||||
| } | } | ||||
| user.setNickName(mpuser.getNickname()); | |||||
| user.setGender(mpuser.getSex()); | |||||
| user.setLanguage(mpuser.getLanguage()); | |||||
| user.setCity(mpuser.getCity()); | |||||
| user.setProvince(mpuser.getProvince()); | |||||
| user.setCountryCode(mpuser.getCountry()); | |||||
| user.setAvatarUrl(mpuser.getHeadImgUrl()); | |||||
| user.setScene(mpuser.getQrScene()); | |||||
| user.setSceneAddress(mpuser.getQrSceneStr()); | |||||
| userService.saveOrUpdate(user); | |||||
| }); | |||||
| return mpUserList.getNextOpenid(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,11 +1,8 @@ | |||||
| package com.iformall.mp.handler; | package com.iformall.mp.handler; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.vo.WxWeappInfo; | |||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.enums.EnumWechatSubscribe; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||||
| import com.iformall.mp.builder.TextBuilder; | import com.iformall.mp.builder.TextBuilder; | ||||
| import com.iformall.service.WxAuthorizerInfoService; | |||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.common.session.WxSessionManager; | import me.chanjar.weixin.common.session.WxSessionManager; | ||||
| @@ -26,7 +23,7 @@ import java.util.Map; | |||||
| public class SubscribeHandler extends AbstractHandler { | public class SubscribeHandler extends AbstractHandler { | ||||
| @Autowired | @Autowired | ||||
| private WxAuthorizerInfoService authorizerInfoService; | |||||
| private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService userService; | private WxCUserService userService; | ||||
| @@ -38,39 +35,18 @@ public class SubscribeHandler extends AbstractHandler { | |||||
| this.logger.info("新关注用户 OPENID: " + wxMessage.getFromUser()); | this.logger.info("新关注用户 OPENID: " + wxMessage.getFromUser()); | ||||
| WxWeappInfo weappInfo = authorizerInfoService.getWeappByAppId(weixinService.getWxMpConfigStorage().getAppId()); | |||||
| String appId = weixinService.getWxMpConfigStorage().getAppId(); | |||||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||||
| authQ.setAuthorizerAppid(appId); | |||||
| WxAuthorizerInfo authorizerInfo = wxAuthorizerInfoMapper.findWeChatMp(authQ); | |||||
| // 获取微信用户基本信息 | // 获取微信用户基本信息 | ||||
| try { | try { | ||||
| WxMpUser userWxInfo = weixinService.getUserService() | WxMpUser userWxInfo = weixinService.getUserService() | ||||
| .userInfo(wxMessage.getFromUser(), null); | |||||
| .userInfo(wxMessage.getFromUser()); | |||||
| if (userWxInfo != null) { | if (userWxInfo != null) { | ||||
| WxCUser user = new WxCUser(); | |||||
| user.setUnionId(userWxInfo.getUnionId()); | |||||
| user.setOpenAppId(weappInfo.getOpenAppid()); | |||||
| if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| user.setMpAppId(weappInfo.getAuthorizerAppid()); | |||||
| user.setMpOpenId(userWxInfo.getOpenId()); | |||||
| user.setMpSubscribe(EnumWechatSubscribe.YES.getCode()); | |||||
| user.setMpSubscribeTime(new Date(userWxInfo.getSubscribeTime())); | |||||
| user.setMpSubscribeScene(userWxInfo.getSubscribeScene()); | |||||
| } else if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| user.setSubsAppId(weappInfo.getAuthorizerAppid()); | |||||
| user.setSubsOpenId(userWxInfo.getOpenId()); | |||||
| user.setSubsSubscribe(EnumWechatSubscribe.YES.getCode()); | |||||
| user.setSubsSubscribeTime(new Date(userWxInfo.getSubscribeTime())); | |||||
| user.setSubsSubscribeScene(userWxInfo.getSubscribeScene()); | |||||
| } | |||||
| user.setNickName(userWxInfo.getNickname()); | |||||
| user.setGender(userWxInfo.getSex()); | |||||
| user.setLanguage(userWxInfo.getLanguage()); | |||||
| user.setCity(userWxInfo.getCity()); | |||||
| user.setProvince(userWxInfo.getProvince()); | |||||
| user.setCountryCode(userWxInfo.getCountry()); | |||||
| user.setAvatarUrl(userWxInfo.getHeadImgUrl()); | |||||
| user.setScene(userWxInfo.getQrScene()); | |||||
| user.setSceneAddress(userWxInfo.getQrSceneStr()); | |||||
| userService.saveOrUpdate(user); | |||||
| this.logger.info(userWxInfo.toString()); | |||||
| userService.saveOrUpdateMpUser(userWxInfo, authorizerInfo); | |||||
| } | } | ||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| if (e.getError().getErrorCode() == 48001) { | if (e.getError().getErrorCode() == 48001) { | ||||
| @@ -1,15 +1,13 @@ | |||||
| package com.iformall.mp.handler; | package com.iformall.mp.handler; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.vo.WxWeappInfo; | |||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.enums.EnumWechatSubscribe; | |||||
| import com.iformall.service.WxAuthorizerInfoService; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import me.chanjar.weixin.common.session.WxSessionManager; | import me.chanjar.weixin.common.session.WxSessionManager; | ||||
| import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | ||||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | ||||
| import me.chanjar.weixin.mp.bean.result.WxMpUser; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| @@ -22,9 +20,8 @@ import java.util.Map; | |||||
| @Component | @Component | ||||
| public class UnsubscribeHandler extends AbstractHandler { | public class UnsubscribeHandler extends AbstractHandler { | ||||
| @Autowired | @Autowired | ||||
| private WxAuthorizerInfoService authorizerInfoService; | |||||
| private WxAuthorizerInfoMapper wxAuthorizerInfoMapper; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService userService; | private WxCUserService userService; | ||||
| @@ -36,32 +33,18 @@ public class UnsubscribeHandler extends AbstractHandler { | |||||
| String openId = wxMessage.getFromUser(); | String openId = wxMessage.getFromUser(); | ||||
| this.logger.info("取消关注用户 OPENID: " + openId); | this.logger.info("取消关注用户 OPENID: " + openId); | ||||
| WxWeappInfo weappInfo = authorizerInfoService.getWeappByAppId(wxMpService.getWxMpConfigStorage().getAppId()); | |||||
| try { | |||||
| WxCUser userQ = new WxCUser(); | |||||
| userQ.setOpenAppId(weappInfo.getOpenAppid()); | |||||
| if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setMpAppId(weappInfo.getAuthorizerAppid()); | |||||
| userQ.setMpOpenId(openId); | |||||
| } else if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setSubsAppId(weappInfo.getAuthorizerAppid()); | |||||
| userQ.setSubsOpenId(openId); | |||||
| } | |||||
| WxCUser oldUser = userService.getByWxOpenId(userQ); | |||||
| if(oldUser != null) { | |||||
| userQ.setId(oldUser.getId()); | |||||
| if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setMpSubscribe(EnumWechatSubscribe.NO.getCode()); | |||||
| userQ.setMpSubscribeTime(new Date(wxMessage.getCreateTime())); | |||||
| } else if(weappInfo.getType().equals(EnumAppType.MP_S.getCode())) { | |||||
| userQ.setSubsSubscribe(EnumWechatSubscribe.NO.getCode()); | |||||
| userQ.setSubsSubscribeTime(new Date(wxMessage.getCreateTime())); | |||||
| } | |||||
| userService.saveOrUpdate(userQ); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| this.logger.error(e.getMessage()); | |||||
| } | |||||
| String appId = wxMpService.getWxMpConfigStorage().getAppId(); | |||||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||||
| authQ.setAuthorizerAppid(appId); | |||||
| WxAuthorizerInfo authorizerInfo = wxAuthorizerInfoMapper.findWeChatMp(authQ); | |||||
| WxMpUser mpUser = new WxMpUser(); | |||||
| mpUser.setOpenId(wxMessage.getFromUser()); | |||||
| mpUser.setSubscribe(false); | |||||
| mpUser.setSubscribeTime(wxMessage.getCreateTime()); | |||||
| userService.saveOrUpdateMpUser(mpUser, authorizerInfo); | |||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -2,7 +2,7 @@ package com.iformall.mp.manager; | |||||
| import com.iformall.mp.handler.*; | import com.iformall.mp.handler.*; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import me.chanjar.weixin.mp.api.WxMpMessageRouter; | import me.chanjar.weixin.mp.api.WxMpMessageRouter; | ||||
| import me.chanjar.weixin.mp.api.WxMpService; | import me.chanjar.weixin.mp.api.WxMpService; | ||||
| import me.chanjar.weixin.mp.constant.WxMpEventConstants; | import me.chanjar.weixin.mp.constant.WxMpEventConstants; | ||||
| @@ -21,7 +21,7 @@ public class WxMpManager { | |||||
| @Autowired | @Autowired | ||||
| protected WxOpenService openService; | |||||
| protected FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService appinfoService; | private WxAppinfoService appinfoService; | ||||
| @@ -2,7 +2,7 @@ package com.iformall.schedule; | |||||
| import com.iformall.domain.vo.WxWeappInfo; | import com.iformall.domain.vo.WxWeappInfo; | ||||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | import com.iformall.mapper.WxAuthorizerInfoMapper; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -20,11 +20,13 @@ public class AppAccessTokenSchedule { | |||||
| private WxAuthorizerInfoMapper authorizerInfoMapper; | private WxAuthorizerInfoMapper authorizerInfoMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| //@Scheduled(cron = "0 0 0/1 * * *?") // 每小时更新一次 | |||||
| @Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| // @Scheduled(cron = "0 40 */1 * * *?") // 每小时更新一次 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| public void updateAppAccessToken() { | public void updateAppAccessToken() { | ||||
| // 暂不启用定时token设置 | |||||
| /* | |||||
| // 微信小程序 | // 微信小程序 | ||||
| List<WxWeappInfo> weappList = authorizerInfoMapper.findWeappList(); | List<WxWeappInfo> weappList = authorizerInfoMapper.findWeappList(); | ||||
| weappList.stream().forEach(weappInfo -> { | weappList.stream().forEach(weappInfo -> { | ||||
| @@ -44,6 +46,7 @@ public class AppAccessTokenSchedule { | |||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } | } | ||||
| }); | }); | ||||
| */ | |||||
| } | } | ||||
| } | } | ||||
| @@ -11,7 +11,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxPayAccountMapper; | import com.iformall.mapper.WxPayAccountMapper; | ||||
| import com.iformall.mapper.WxPayOrderMapper; | import com.iformall.mapper.WxPayOrderMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.wechat.WxOpenService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | import me.chanjar.weixin.open.api.WxOpenMaService; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -39,9 +39,7 @@ public class UserUnionIdSchedule { | |||||
| @Autowired | @Autowired | ||||
| private WxPayAccountMapper payAccountMapper; | private WxPayAccountMapper payAccountMapper; | ||||
| @Autowired | |||||
| private WxOpenService openService; | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoService wxAppinfoService; | WxAppinfoService wxAppinfoService; | ||||
| @@ -92,6 +90,7 @@ public class UserUnionIdSchedule { | |||||
| * 根据payOrder发送模板消息 | * 根据payOrder发送模板消息 | ||||
| * @param payOrderVo | * @param payOrderVo | ||||
| */ | */ | ||||
| /* | |||||
| public void sendUniformMessage(WxPayOrderVo payOrderVo) { | public void sendUniformMessage(WxPayOrderVo payOrderVo) { | ||||
| if(StringUtils.isBlank(payOrderVo.getOpenId())) { | if(StringUtils.isBlank(payOrderVo.getOpenId())) { | ||||
| return; | return; | ||||
| @@ -148,4 +147,5 @@ public class UserUnionIdSchedule { | |||||
| throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | throw new MallinkException(ErrorCode.TEMPLATE_SEND_FAILED); | ||||
| } | } | ||||
| } | } | ||||
| */ | |||||
| } | } | ||||
| @@ -27,6 +27,7 @@ | |||||
| <weixin-java-mp.version>3.3.0.A</weixin-java-mp.version> | <weixin-java-mp.version>3.3.0.A</weixin-java-mp.version> | ||||
| <weixin-java-miniapp.version>3.3.0.A</weixin-java-miniapp.version> | <weixin-java-miniapp.version>3.3.0.A</weixin-java-miniapp.version> | ||||
| <weixin-java-pay.version>3.3.0.A</weixin-java-pay.version> | <weixin-java-pay.version>3.3.0.A</weixin-java-pay.version> | ||||
| <weixin-java-open.version>3.3.0.A</weixin-java-open.version> | |||||
| <quartz.version>2.3.0</quartz.version> | <quartz.version>2.3.0</quartz.version> | ||||
| </properties> | </properties> | ||||
| @@ -322,6 +323,12 @@ | |||||
| <version>${weixin-java-pay.version}</version> | <version>${weixin-java-pay.version}</version> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-open</artifactId> | |||||
| <version>${weixin-java-open.version}</version> | |||||
| </dependency> | |||||
| <dependency> | <dependency> | ||||
| <groupId>com.github.ulisesbocchio</groupId> | <groupId>com.github.ulisesbocchio</groupId> | ||||
| <artifactId>jasypt-spring-boot</artifactId> | <artifactId>jasypt-spring-boot</artifactId> | ||||