import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest; | import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest; | ||||
import cn.com.taiji.core.model.comm.protocol.SignServiceCommand; | import cn.com.taiji.core.model.comm.protocol.SignServiceCommand; | ||||
import cn.com.taiji.core.model.comm.protocol.SignServiceType; | import cn.com.taiji.core.model.comm.protocol.SignServiceType; | ||||
import cn.com.taiji.core.model.comm.protocol.ats.wx.WxMpIsSubscribedRequest; | |||||
public enum AtsServiceCmd implements SignServiceCommand { | public enum AtsServiceCmd implements SignServiceCommand { | ||||
CREATEPAYORDERV2("V2统一下单","creatOrderV2", AtsCreatPayOrderV2Request.class), | CREATEPAYORDERV2("V2统一下单","creatOrderV2", AtsCreatPayOrderV2Request.class), | ||||
CREATEPAYORDERV3("V3统一下单","creatOrderV3", AtsCreatPayOrderV3Request.class), | CREATEPAYORDERV3("V3统一下单","creatOrderV3", AtsCreatPayOrderV3Request.class), | ||||
QUERYPAYRESULT("查询支付结果","queryPayResult", AtsQueryPayResultRequest.class), | QUERYPAYRESULT("查询支付结果","queryPayResult", AtsQueryPayResultRequest.class), | ||||
ISSUBSCRIBED("用户是否订阅公众号","isSubscribed", WxMpIsSubscribedRequest.class), | |||||
; | ; | ||||
package cn.com.taiji.core.model.comm.protocol.ats.wx; | |||||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.AtsServiceCmd; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
@Getter | |||||
@Setter | |||||
public class WxMpIsSubscribedRequest extends AbstractSignTypeRequest<WxMpIsSubscribedResponse> { | |||||
public WxMpIsSubscribedRequest() { | |||||
super(AtsServiceCmd.ISSUBSCRIBED); | |||||
} | |||||
/** 微信公众号(客户端)id */ | |||||
private String clientId; | |||||
/** 微信用户对于每个特定公众号的唯一标识*/ | |||||
private String openId; | |||||
} |
package cn.com.taiji.core.model.comm.protocol.ats.wx; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.AbstractAtsResponse; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
@Getter | |||||
@Setter | |||||
public class WxMpIsSubscribedResponse extends AbstractAtsResponse { | |||||
/** 微信用户是否关注公众号 */ | |||||
private Boolean isSubscribed; | |||||
} |
implementation fileTree(dir: 'lib', include: ['*.jar']) | implementation fileTree(dir: 'lib', include: ['*.jar']) | ||||
implementation group: 'com.alibaba', name: 'fastjson', version: '2.0.4' | implementation group: 'com.alibaba', name: 'fastjson', version: '2.0.4' | ||||
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis' | |||||
implementation 'com.squareup.okhttp3:okhttp:3.14.9' | |||||
} | } | ||||
bootJar { | bootJar { |
package cn.com.taiji.ats.dict; | |||||
/*** | |||||
* 微信接口调用的AccessToken类型 | |||||
* @Author weicailin | |||||
* @Date 2023/5/23 11:04 | |||||
* @Email 13079168756@163.com | |||||
*/ | |||||
public enum WxAccessTokenType { | |||||
//规则:value = 小写的枚举名 + "-" | |||||
MINI("小程序") {}, | |||||
MP("公众号") {}, | |||||
; | |||||
private final String value; | |||||
WxAccessTokenType(String value) { | |||||
this.value = value; | |||||
} | |||||
public String getValue() { | |||||
return value; | |||||
} | |||||
} |
package cn.com.taiji.ats.manager; | |||||
import cn.com.taiji.common.entity.BaseEntity; | |||||
import cn.com.taiji.common.manager.AbstractManager; | |||||
import cn.com.taiji.common.model.dao.Pagination; | |||||
import cn.com.taiji.common.pub.StringTools; | |||||
import cn.com.taiji.common.pub.json.JsonTools; | |||||
import org.apache.commons.collections4.map.HashedMap; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.data.redis.core.Cursor; | |||||
import org.springframework.data.redis.core.HashOperations; | |||||
import org.springframework.data.redis.core.RedisTemplate; | |||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.data.redis.core.ScanOptions.ScanOptionsBuilder; | |||||
import java.io.IOException; | |||||
import java.util.*; | |||||
import java.util.Map.Entry; | |||||
import java.util.concurrent.TimeUnit; | |||||
import java.util.function.Supplier; | |||||
/** | |||||
* hash操作的方法以hash开头,如:hashGet<br> | |||||
* | |||||
* @author lijun <br> | |||||
* Create Time:2018年12月9日 下午1:43:54<br> | |||||
* mail:756915505@qq.com | |||||
* @since 1.0 | |||||
* @version 1.0 | |||||
*/ | |||||
@Service | |||||
public class RedisWrapManager extends AbstractManager { | |||||
@Autowired(required = false) | |||||
private RedisTemplate<String, String> redisTemplate; | |||||
public Set<String> key(String pattern) { | |||||
if ("*".equals(pattern)) { | |||||
throw new RuntimeException("禁止全扫描key"); | |||||
} | |||||
return redisTemplate.keys(pattern); | |||||
} | |||||
public Boolean expire(String key, final long timeout, final TimeUnit unit) { | |||||
return redisTemplate.expire(key, timeout, unit); | |||||
} | |||||
public String get(String key) { | |||||
return redisTemplate.opsForValue().get(key); | |||||
} | |||||
public String getAndSet(String key, String value) { | |||||
return redisTemplate.opsForValue().getAndSet(key, value); | |||||
} | |||||
public void set(String key, String value, long timeout, TimeUnit unit) { | |||||
redisTemplate.opsForValue().set(key, value, timeout, unit); | |||||
} | |||||
public boolean setIfAbsent(String key, String value, long timeout, TimeUnit unit) { | |||||
return redisTemplate.opsForValue().setIfAbsent(key, value, timeout, unit); | |||||
} | |||||
public long increment(String key, long delta) { | |||||
return redisTemplate.opsForValue().increment(key, delta); | |||||
} | |||||
public Boolean delete(String key) { | |||||
return redisTemplate.delete(key); | |||||
} | |||||
public long listRightPush(String key, String value) { | |||||
return redisTemplate.opsForList().rightPush(key, value); | |||||
} | |||||
/** | |||||
* 返回存储在 key 的列表里指定范围内的元素。 start 和 end 偏移量都是基于0的下标,即list的第一个元素下标是0(list的表头),第二个元素下标是1,以此类推。 | |||||
* 偏移量也可以是负数,表示偏移量是从list尾部开始计数。 例如, -1 表示列表的最后一个元素,-2 是倒数第二个,以此类推 | |||||
*/ | |||||
public List<String> listRange(String key, long start, long end) { | |||||
return redisTemplate.opsForList().range(key, start, end); | |||||
} | |||||
public Long listSize(String key) { | |||||
return redisTemplate.opsForList().size(key); | |||||
} | |||||
public Boolean hashHasKey(String key, Object hashKey) { | |||||
return opsForHash().hasKey(key, hashKey); | |||||
} | |||||
public boolean hasKey(String key) { | |||||
return redisTemplate.hasKey(key); | |||||
} | |||||
public Object hashGet(String key, Object hashKey) { | |||||
return opsForHash().get(key, hashKey); | |||||
} | |||||
public void hashPut(String key, Object hashKey, Object value) { | |||||
opsForHash().put(key, hashKey, value); | |||||
} | |||||
public Boolean hashPutIfAbsent(String key, Object hashKey, Object value) { | |||||
return opsForHash().putIfAbsent(key, hashKey, value); | |||||
} | |||||
public void hashPutAll(String key, Map<? extends Object, ? extends Object> m) { | |||||
opsForHash().putAll(key, m); | |||||
} | |||||
public Long hashIncrement(String key, Object hashKey, long delta) { | |||||
return opsForHash().increment(key, hashKey, delta); | |||||
} | |||||
public Long hashDelete(String key, Object... hashKeys) { | |||||
return opsForHash().delete(key, hashKeys); | |||||
} | |||||
public Map<Object, Object> hashScan(String key, String pattern) { | |||||
ScanOptionsBuilder b = new ScanOptionsBuilder(); | |||||
Cursor<Entry<Object, Object>> s = opsForHash().scan(key, b.match(pattern).build()); | |||||
Map<Object, Object> map = new HashMap<>(); | |||||
s.forEachRemaining(e -> map.put(e.getKey(), e.getValue())); | |||||
return map; | |||||
} | |||||
public String findStr(String key, int timeout, Supplier<String> valueSupplier) { | |||||
String str = get(key); | |||||
if (!StringTools.hasText(str)) { | |||||
str = valueSupplier.get(); | |||||
set(key, str, timeout); | |||||
} | |||||
return str; | |||||
} | |||||
public <T extends BaseEntity> T findObj(Class<T> clazz, String key, int timeout, Supplier<T> valueSupplier) { | |||||
String jsonStr = (String)get(key); | |||||
try { | |||||
if (!StringTools.hasText(jsonStr)) { | |||||
T obj = valueSupplier.get(); | |||||
jsonStr = JsonTools.toJsonStr(obj); | |||||
set(key, jsonStr, timeout); | |||||
} | |||||
return JsonTools.json2Object(jsonStr, clazz); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
return null; | |||||
} | |||||
} | |||||
public <T extends BaseEntity> T findObj(Class<T> clazz, String key) { | |||||
String jsonStr = redisTemplate.opsForValue().get(key); | |||||
try { | |||||
return JsonTools.json2Object(jsonStr, clazz); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
return null; | |||||
} | |||||
} | |||||
public <T> Map<String, T> findMap(Class<T> clazz, String key, int timeout, Supplier<Map<String, T>> valueSupplier) { | |||||
String jsonStr = get(key); | |||||
try { | |||||
if (!StringTools.hasText(jsonStr)) { | |||||
Map<String, T> map = valueSupplier.get(); | |||||
jsonStr = JsonTools.toJsonStr(map); | |||||
set(key, jsonStr, timeout); | |||||
} | |||||
return JsonTools.json2Map(jsonStr, String.class, clazz); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
return new HashedMap<>(); | |||||
} | |||||
} | |||||
public <T> List<T> findList(Class<T> clazz, String key, int timeout, Supplier<Collection<T>> valueSupplier) { | |||||
String jsonStr = get(key); | |||||
try { | |||||
if (!StringTools.hasText(jsonStr)) { | |||||
Collection<T> c = valueSupplier.get(); | |||||
jsonStr = JsonTools.toJsonStr(c); | |||||
set(key, jsonStr, timeout); | |||||
} | |||||
return JsonTools.json2List(jsonStr, clazz); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
return new ArrayList<>(); | |||||
} | |||||
} | |||||
public <T extends BaseEntity> Pagination findPagn(Class<T> clazz, String key, int timeout, | |||||
Supplier<Pagination> valueSupplier) { | |||||
String jsonStr = get(key); | |||||
try { | |||||
if (!StringTools.hasText(jsonStr)) { | |||||
Pagination c = valueSupplier.get(); | |||||
jsonStr = JsonTools.toJsonStr(c); | |||||
set(key, jsonStr, timeout); | |||||
} | |||||
return JsonTools.json2Pagn(jsonStr, clazz); | |||||
} catch (IOException e) { | |||||
e.printStackTrace(); | |||||
return new Pagination().setResult(new ArrayList<>()); | |||||
} | |||||
} | |||||
private <HK, HV> HashOperations<String, HK, HV> opsForHash() { | |||||
return redisTemplate.opsForHash(); | |||||
} | |||||
private void set(String key, String value, int timeout) { | |||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS); | |||||
} | |||||
} |
import cn.com.taiji.ats.manager.weixin.CreatePayOrderV2Manager; | import cn.com.taiji.ats.manager.weixin.CreatePayOrderV2Manager; | ||||
import cn.com.taiji.ats.manager.weixin.CreatePayOrderV3Manager; | import cn.com.taiji.ats.manager.weixin.CreatePayOrderV3Manager; | ||||
import cn.com.taiji.ats.manager.weixin.QueryPayResultManager; | import cn.com.taiji.ats.manager.weixin.QueryPayResultManager; | ||||
import cn.com.taiji.ats.manager.weixin.WxMpIsSubscribedManager; | |||||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest; | import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeRequest; | ||||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeResponse; | import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeResponse; | ||||
import cn.com.taiji.core.model.comm.protocol.SignJsonRequest; | import cn.com.taiji.core.model.comm.protocol.SignJsonRequest; | ||||
import cn.com.taiji.core.model.comm.protocol.ats.*; | import cn.com.taiji.core.model.comm.protocol.ats.*; | ||||
import cn.com.taiji.core.model.comm.protocol.ats.wx.WxMpIsSubscribedRequest; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import com.zgglyun.common.model.AbstractHttpRequestInfo; | import com.zgglyun.common.model.AbstractHttpRequestInfo; | ||||
private CreatePayOrderV3Manager createPayOrderV3Manager; | private CreatePayOrderV3Manager createPayOrderV3Manager; | ||||
@Autowired | @Autowired | ||||
private QueryPayResultManager queryPayResultManager; | private QueryPayResultManager queryPayResultManager; | ||||
@Autowired | |||||
private WxMpIsSubscribedManager isSubscribedManager; | |||||
@Override | @Override | ||||
protected <T extends AbstractSignTypeRequest<?>> AbstractSignTypeResponse handleInternal(T request, | protected <T extends AbstractSignTypeRequest<?>> AbstractSignTypeResponse handleInternal(T request, | ||||
return createPayOrderV3Manager.serviceHandle((AtsCreatPayOrderV3Request) request); | return createPayOrderV3Manager.serviceHandle((AtsCreatPayOrderV3Request) request); | ||||
case QUERYPAYRESULT: | case QUERYPAYRESULT: | ||||
return queryPayResultManager.serviceHandle((AtsQueryPayResultRequest) request); | return queryPayResultManager.serviceHandle((AtsQueryPayResultRequest) request); | ||||
case ISSUBSCRIBED: | |||||
return isSubscribedManager.serviceHandle((WxMpIsSubscribedRequest) request); | |||||
default: | default: | ||||
throw FileProtocolSystemError.NOT_SUPPORT.toHandleException(jsonReq.getIfCode()); | throw FileProtocolSystemError.NOT_SUPPORT.toHandleException(jsonReq.getIfCode()); | ||||
} | } |
package cn.com.taiji.ats.manager.weixin; | |||||
import cn.com.taiji.ats.dict.WxAccessTokenType; | |||||
import cn.com.taiji.ats.model.wx.WxUserInfoModel; | |||||
import cn.com.taiji.ats.tools.HttpClientUtil; | |||||
import cn.com.taiji.ats.tools.WxRequestAccessTokenUtil; | |||||
import cn.com.taiji.ats.tools.WxRequestUrls; | |||||
import cn.com.taiji.common.manager.AbstractManager; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||||
import cn.com.taiji.common.pub.json.JsonTools; | |||||
import cn.com.taiji.core.model.comm.protocol.AbstractSignTypeResponse; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.wx.WxMpIsSubscribedRequest; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.wx.WxMpIsSubscribedResponse; | |||||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||||
import cn.hutool.json.JSONUtil; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.http.HttpMethod; | |||||
import org.springframework.stereotype.Service; | |||||
import java.io.IOException; | |||||
import java.util.Map; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/15 20:01 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@Service | |||||
public class WxMpIsSubscribedManager extends AbstractManager { | |||||
@Value("${wx.mp.appid}") | |||||
private String mpAppid; | |||||
@Value("${wx.mp.secret}") | |||||
private String mpSecret; | |||||
@Autowired | |||||
private WxRequestAccessTokenUtil wxRequestAccessTokenUtil; | |||||
public AbstractSignTypeResponse serviceHandle(WxMpIsSubscribedRequest request) throws ServiceHandleException { | |||||
//1、获取调用微信接口的accessToken凭证 | |||||
String accessToken = null; | |||||
try { | |||||
accessToken = wxRequestAccessTokenUtil.getStableAccessToken(mpAppid, mpSecret, | |||||
false, WxAccessTokenType.MP); | |||||
} catch (ManagerException | IOException e) { | |||||
throw GlyServiceError.RESPONSE_ERROR.toHandleException(e.getMessage()); | |||||
} | |||||
//2、获取微信用户信息(包含订阅状态) | |||||
WxUserInfoModel wxMpUser = null; | |||||
try { | |||||
wxMpUser = getWxMpUser(request, accessToken); | |||||
} catch (IOException e) { | |||||
throw GlyServiceError.RESPONSE_ERROR.toHandleException(e.getMessage()); | |||||
} | |||||
WxMpIsSubscribedResponse res = new WxMpIsSubscribedResponse(); | |||||
res.setIsSubscribed(wxMpUser.getSubscribe() == 1); | |||||
return res; | |||||
} | |||||
/** | |||||
* @author: humh | |||||
* @description: 获取微信用户信息 | |||||
* @date: 2025/4/18 19:28 | |||||
* @return | |||||
*/ | |||||
private WxUserInfoModel getWxMpUser(WxMpIsSubscribedRequest request, String accessToken) throws IOException { | |||||
logger.info("********** 获取微信用户信息 START **********"); | |||||
//1、设置url参数 | |||||
String url = String.format(WxRequestUrls.MP_GET_USERINFO_URL, accessToken, request.getOpenId()); | |||||
//3、微信公众号-获取微信用户信息 | |||||
String resJson = HttpClientUtil.sendGet(url); | |||||
return JSONUtil.parseObj(resJson).toBean(WxUserInfoModel.class); | |||||
} | |||||
} |
package cn.com.taiji.ats.model.wx; | |||||
import cn.com.taiji.common.model.BaseModel; | |||||
import com.fasterxml.jackson.annotation.JsonProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/15 21:28 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@Setter | |||||
@Getter | |||||
public class WxAccessTokenModel extends BaseModel { | |||||
@JsonProperty("access_token") | |||||
private String accessToken; | |||||
@JsonProperty("expires_in") | |||||
private Integer expiresIn; | |||||
@JsonProperty("errcode") | |||||
private Integer errCode; | |||||
@JsonProperty("errmsg") | |||||
private String errMsg; | |||||
} |
package cn.com.taiji.ats.model.wx; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
/** | |||||
* 微信用户信息 | |||||
*/ | |||||
@Data | |||||
public class WxUserInfoModel implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
/** | |||||
* openId | |||||
*/ | |||||
private String openid; | |||||
/** | |||||
* 是否已关注 | |||||
*/ | |||||
private Integer subscribe; | |||||
/** | |||||
* 关注时间 | |||||
*/ | |||||
private Long subscribeTime; | |||||
/** | |||||
* unionid | |||||
*/ | |||||
private String unionid; | |||||
/** 重写set方法 */ | |||||
public void setSubscribeTime(Long subscribeTime) { | |||||
this.subscribeTime = subscribeTime * 1000; | |||||
} | |||||
} |
package cn.com.taiji.ats.tools; | |||||
import okhttp3.*; | |||||
import java.io.File; | |||||
import java.io.IOException; | |||||
import java.net.URLEncoder; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.concurrent.TimeUnit; | |||||
public class HttpClientUtil { | |||||
private static final OkHttpClient client = new OkHttpClient.Builder() | |||||
.connectTimeout(100, TimeUnit.SECONDS)//连接超时 | |||||
.readTimeout(100, TimeUnit.SECONDS)//读取响应超时 | |||||
.writeTimeout(100, TimeUnit.SECONDS)//发送请求超时 | |||||
.callTimeout(1000, TimeUnit.SECONDS)// 整个调用过程超时 | |||||
.build(); | |||||
private static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); | |||||
private static final MediaType FORM = MediaType.parse("application/x-www-form-urlencoded; charset=utf-8"); | |||||
private static final String AUTHORIZATION = "Authorization"; | |||||
private static final String BEARER = "Bearer "; | |||||
/** | |||||
* HTTP接口-POST方式,请求参数形式为body-json形式 | |||||
*/ | |||||
public static String sendPost(String url, String jsonString, String token) throws IOException { | |||||
RequestBody body = RequestBody.create(JSON, jsonString); | |||||
Request.Builder builder = new Request.Builder() | |||||
.post(body) | |||||
.url(url); | |||||
// 仅当token非空时添加Authorization头 | |||||
if (token != null && !token.trim().isEmpty()) { | |||||
builder.addHeader(AUTHORIZATION, BEARER + token); | |||||
} | |||||
Request request = builder.build(); | |||||
try (Response response = client.newCall(request).execute()) { | |||||
if (!response.isSuccessful()){ | |||||
throw new IOException("Unexpected code: " + response); | |||||
} | |||||
return response.body().string(); | |||||
} catch (IOException e) { | |||||
throw new IOException(e); | |||||
} | |||||
} | |||||
/** | |||||
* HTTP接口-GET方式,请求参数形式为params形式 | |||||
*/ | |||||
public static String sendGet(String url) throws IOException { | |||||
Request request = new Request.Builder() | |||||
.url(url) | |||||
.build(); | |||||
try (Response response = client.newCall(request).execute()) { | |||||
if (!response.isSuccessful()) { | |||||
throw new IOException("Unexpected code " + response); | |||||
} | |||||
return response.body().string(); | |||||
} | |||||
} | |||||
} |
package cn.com.taiji.ats.tools; | |||||
import cn.com.taiji.ats.dict.WxAccessTokenType; | |||||
import cn.com.taiji.ats.manager.RedisWrapManager; | |||||
import cn.com.taiji.ats.model.wx.WxAccessTokenModel; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError; | |||||
import cn.hutool.json.JSONUtil; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Component; | |||||
import java.io.IOException; | |||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
import java.util.concurrent.TimeUnit; | |||||
/** | |||||
* 获取-微信后台接口调用凭证-工具类 | |||||
* | |||||
* @Author weicailin | |||||
* @Date 2023/5/19 9:56 | |||||
* @Email 13079168756@163.com | |||||
*/ | |||||
@Component | |||||
public class WxRequestAccessTokenUtil { | |||||
private final static Logger logger = LoggerFactory.getLogger(WxRequestAccessTokenUtil.class); | |||||
//微信小程序-全局唯一后台【稳定版】接口调用凭据 | |||||
private final static String MINI_ACCESS_STABLE_TOKEN_PREFIX = "MINI_STABLE_ACCESS_TOKEN-"; | |||||
//微信公众号-全局唯一后台接口调用凭据 | |||||
private final static String MP_ACCESS_TOKEN_PREFIX = "MP_ACCESS_TOKEN-"; | |||||
//微信公众号-全局唯一后台【稳定版】接口调用凭据 | |||||
private final static String MP_ACCESS_STABLE_TOKEN_PREFIX = "MP_STABLE_ACCESS_TOKEN-"; | |||||
@Autowired | |||||
private RedisWrapManager redisWrapManager; | |||||
/*** | |||||
* 获取小程序全局后台【稳定版】接口调用凭据,调用绝大多数后台接口时都需使用 access_token。 | |||||
* forceRefresh参数: | |||||
* (1)false 时为普通调用模式,access_token 有效期内重复调用该接口不会更新 access_token | |||||
* (2)true 时为强制刷新模式,会导致上次获取的 access_token 失效,并返回新的 access_token | |||||
*/ | |||||
public String getStableAccessToken(String appid, String secret, boolean forceRefresh, WxAccessTokenType tokenType) throws ManagerException, IOException { | |||||
//根据类型设置key | |||||
String redisKey = null; | |||||
if (WxAccessTokenType.MINI.equals(tokenType)) { | |||||
redisKey = MINI_ACCESS_STABLE_TOKEN_PREFIX + appid; | |||||
} else { | |||||
redisKey = MP_ACCESS_STABLE_TOKEN_PREFIX + appid; | |||||
} | |||||
//1、判断redis中该accessToken是否有效存在 | |||||
if (redisWrapManager.hasKey(redisKey)) { | |||||
return redisWrapManager.get(redisKey); | |||||
} | |||||
//2、key不存在,说明accessToken已经过期,则需要重新获取accessToken | |||||
//设置url参数 | |||||
String url = WxRequestUrls.STABLE_ACCESS_TOKEN_URL; | |||||
Map<String, Object> paramMap = new HashMap<>(); | |||||
paramMap.put("grant_type", "client_credential"); | |||||
paramMap.put("appid", appid); | |||||
paramMap.put("secret", secret); | |||||
paramMap.put("force_refresh", forceRefresh); | |||||
String resJson = HttpClientUtil.sendPost(url, JSONUtil.toJsonStr(paramMap), null); | |||||
WxAccessTokenModel tokenModel = JSONUtil.parseObj(resJson).toBean(WxAccessTokenModel.class); | |||||
//3、responseBody非空校验 | |||||
if (tokenModel == null ) { | |||||
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("获取微信小程序accessToken失败,请重试!"); | |||||
} | |||||
// //4、微信回参,是否成功调用校验 | |||||
// if (tokenModel.getErrCode() != 0) { | |||||
// logger.error("获取微信小程序accessToken失败!原因:{}", (String) tokenModel.getErrMsg()); | |||||
// throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("获取微信小程序accessToken失败!"); | |||||
// } | |||||
//5、保存新获取的accessToken | |||||
redisWrapManager.set(redisKey, tokenModel.getAccessToken(), tokenModel.getExpiresIn(), TimeUnit.SECONDS); | |||||
logger.info("获取微信小程序内部接口调用的access_token:{}", tokenModel.getAccessToken()); | |||||
return tokenModel.getAccessToken(); | |||||
} | |||||
} |
package cn.com.taiji.ats.tools; | |||||
/** | |||||
* @Author weicailin | |||||
* @Date 2023/5/19 9:49 | |||||
* @Email 13079168756@163.com | |||||
*/ | |||||
public class WxRequestUrls { | |||||
//1、token获取 | |||||
//微信获取调用后台接口的accessToken的url | |||||
// public static final String STABLE_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/stable_token"; | |||||
public static final String STABLE_ACCESS_TOKEN_URL = "http://192.168.100.63:7098/cgi-bin/stable_token"; //nginx内网映射 | |||||
//2、公众号-模板消息(非订阅通知) | |||||
//微信公总号-获取该用户的微信基本信息类(包含是否订阅公众号) | |||||
// public static final String MP_GET_USERINFO_URL = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN"; | |||||
public static final String MP_GET_USERINFO_URL = "http://192.168.100.63:7098/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN"; | |||||
} |
refresh: true | refresh: true | ||||
- data-id: comm-client.yaml | - data-id: comm-client.yaml | ||||
refresh: true | refresh: true | ||||
- data-id: redis.yaml | |||||
refresh: true | |||||
- data-id: msgw-config.yaml | |||||
refresh: true | |||||
feign: | feign: | ||||
client: | client: | ||||
config: | config: |
package cn.com.taiji.ats.manager; | |||||
import cn.com.taiji.ats.config.JsonConfig; | |||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; | |||||
import org.springframework.boot.SpringApplication; | |||||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | |||||
import org.springframework.context.annotation.Import; | |||||
@SpringBootApplication(scanBasePackages = "cn.com.taiji.core.manager.comm.client.feign", | |||||
exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class}) | |||||
@Import({JsonConfig.class}) | |||||
public class FeignClientApplication { | |||||
public static void main(String[] args) { | |||||
System.out.println("开始启动FeignClientApplication......"); | |||||
SpringApplication.run(FeignClientApplication.class, args); | |||||
} | |||||
} | |||||
//package cn.com.taiji.ats.manager; | |||||
// | |||||
//import cn.com.taiji.ats.config.JsonConfig; | |||||
//import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; | |||||
//import org.springframework.boot.SpringApplication; | |||||
//import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
//import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | |||||
//import org.springframework.context.annotation.Import; | |||||
// | |||||
//@SpringBootApplication(scanBasePackages = "cn.com.taiji.core.manager.comm.client.feign", | |||||
// exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class}) | |||||
//@Import({JsonConfig.class}) | |||||
//public class FeignClientApplication { | |||||
// public static void main(String[] args) { | |||||
// System.out.println("开始启动FeignClientApplication......"); | |||||
// SpringApplication.run(FeignClientApplication.class, args); | |||||
// } | |||||
//} |
package cn.com.taiji.ats.manager.cs; | |||||
import cn.com.taiji.ats.Application; | |||||
import cn.com.taiji.ats.manager.AbstractCommManager; | |||||
import cn.com.taiji.ats.manager.weixin.CreatePayOrderV2Manager; | |||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.AtsCreatPayOrderV2Request; | |||||
import org.junit.jupiter.api.Test; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.boot.test.context.SpringBootTest; | |||||
import java.time.LocalDateTime; | |||||
import java.time.format.DateTimeFormatter; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/12 10:58 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@SpringBootTest(classes = Application.class) | |||||
public class TestHandler extends AbstractCommManager { | |||||
@Autowired | |||||
private CreatePayOrderV2Manager createPayOrderV2Manager; | |||||
@Test | |||||
public void test() { | |||||
AtsCreatPayOrderV2Request request = new AtsCreatPayOrderV2Request(); | |||||
try { | |||||
createPayOrderV2Manager.serviceHandle(request); | |||||
} catch (ServiceHandleException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
} | |||||
public static void main(String[] args) { | |||||
LocalDateTime parse = LocalDateTime.parse("2024-04-02 16:55:41", DateTimeFormatter.ofPattern("yyyy-MM-dd['T'][ ]HH:mm:ss")); | |||||
System.out.println(parse); | |||||
} | |||||
} |
package cn.com.taiji.ats.manager.demo; | |||||
import cn.com.taiji.ats.Application; | |||||
import cn.com.taiji.ats.manager.weixin.CreatePayOrderV3Manager; | |||||
import cn.com.taiji.ats.manager.AbstractCommManager; | |||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||||
import cn.com.taiji.core.entity.dict.pay.TradeType; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.AtsCreatPayOrderV3Request; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.AtsCreatPayOrderV3Response; | |||||
import org.junit.jupiter.api.Test; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.boot.test.context.SpringBootTest; | |||||
import org.springframework.boot.test.mock.mockito.MockBean; | |||||
import javax.annotation.Resource; | |||||
@SpringBootTest(classes = Application.class) | |||||
public class TestFeignClientRequest extends AbstractCommManager { | |||||
//package cn.com.taiji.ats.manager.demo; | |||||
// | |||||
//import cn.com.taiji.ats.Application; | |||||
//import cn.com.taiji.ats.manager.weixin.CreatePayOrderV3Manager; | |||||
//import cn.com.taiji.ats.manager.AbstractCommManager; | |||||
//import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||||
//import cn.com.taiji.core.entity.dict.pay.TradeType; | |||||
//import cn.com.taiji.core.model.comm.protocol.ats.AtsCreatPayOrderV3Request; | |||||
//import cn.com.taiji.core.model.comm.protocol.ats.AtsCreatPayOrderV3Response; | |||||
//import org.junit.jupiter.api.Test; | |||||
//import org.springframework.beans.factory.annotation.Autowired; | |||||
//import org.springframework.boot.test.context.SpringBootTest; | |||||
//import org.springframework.boot.test.mock.mockito.MockBean; | |||||
// | |||||
//import javax.annotation.Resource; | |||||
// | |||||
//@SpringBootTest(classes = Application.class) | |||||
//public class TestFeignClientRequest extends AbstractCommManager { | |||||
// | |||||
//// @Test | |||||
//// public void testSampleRequest() { | |||||
//// TypeSampleRequest req = new TypeSampleRequest(); | |||||
//// try { | |||||
//// logger.info("格式校验异常 req:" + req.toJson(true)); | |||||
//// jsonPostRepeat(req, 3); | |||||
//// } catch (ApiRequestException e) { | |||||
//// logger.error("", e); | |||||
//// } | |||||
//// req = new TypeSampleRequest(); | |||||
//// req.setCardId("cardId" + new Random().nextInt(1000000)); | |||||
//// req.setReqStr("hello"); | |||||
//// req.setValid(true); | |||||
//// try { | |||||
//// logger.info("业务校验异常 req:" + req.toJson(true)); | |||||
//// jsonPostRepeat(req, 3); | |||||
//// } catch (ApiRequestException e) { | |||||
//// logger.error("", e); | |||||
//// } | |||||
//// req = new TypeSampleRequest(); | |||||
//// req.setCardId("cardId" + new Random().nextInt(1000000)); | |||||
//// req.setReqStr("hello"); | |||||
//// req.setValid(false); | |||||
//// logger.info("成功 req:" + req.toJson(true)); | |||||
//// TypeSampleResponse res = jsonPostRepeat(req, 1); | |||||
//// logger.info("res:" + res.toJson(true)); | |||||
//// | |||||
//// } | |||||
// @Autowired | |||||
//// @Resource | |||||
//// @MockBean | |||||
// private CreatePayOrderV3Manager createPayOrderV3Manager; | |||||
// @Test | // @Test | ||||
// public void testSampleRequest() { | |||||
// TypeSampleRequest req = new TypeSampleRequest(); | |||||
// public void test1() { | |||||
// AtsCreatPayOrderV3Request request = new AtsCreatPayOrderV3Request(); | |||||
// request.setApiV3Key("yCocgAjiGMqQEfFE4SN4woJYSSfq07fd"); | |||||
// request.setAppid("wx008c60533388527a"); | |||||
// request.setMchid("1495316212");//1535705621 | |||||
//// request.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpU2Z2fk0yDxsj6fYuxFhuqWqZ4HsHpWcxATjjNKgge7aFdSacBZBoO5ZTeHj2zSy1Atx8A0SiJ8FjM39wJFl97C8xcvGZYnIM0xxQsZnCwEkCpYrPUvwx5Fs7gumzmvnNetV8Mux2gzmneQayfrVM8TVkRptLYOsPAupuvyZ6Ygpn8Omd+ZSUkCI9KFm5cY16Uzi9SbUc0dF46NrhujDabvf9IEn6sGaWqkCv+LMU5h2jL79KrgjpMHvvu58i4pMM4SxeV06u8x7T/CRxA+Jwj8FGNv9Og7VUylmZVyISIDwUZz5wYCsr/XEPHt26WWriqUlm0gpV1DaZrIHkkQztAgMBAAECggEAX0Unn4AM2x+Yu6pF86ZRw2HbMt0VHAY6e14erefQuQYiehCiOqL+z0bHnAtqtCJZBzem6rfEBCCuNKyjBWvOVoVvQDlWKmEznnehtN1YkDU0XyLZaTFd6Ix9sIxGBeIqryxvtcPJPB01cT8tP3z/cV0+Fz+K3OyZFQck9E7kzXI1Vc3Dcx6ZGPRmkFyfjgxV2kTQzfQasoYK6rZjQwzQuXyHhLZx3iQuk61Ta8gqJ9O+2Y93koe6i6wUfF2yHgwAGgAuDa5Twx02XtRmTzILedFyLezwaV7Xg3y5KPFzt2u8w6nHjSi7tzTFPeW+QMMzmjsPqegDAfLAK+hW3lWtgQKBgQDf0ErISiCXYCQRw7TaF9J4vlecY/PQENEO8S+1tK5TJdmfsFULT0wS9W1QrmYlq6aeMBYbGsbxy+1+dqOGrkt7ICRXJaLXpVaPW1jaOXZtDs8NR3oCkF/4ePt0X7G7CKHrkjErHhdElTi6PTtyNdRDK0xhiQG2GMueqrxG2HHsnQKBgQDBrSKvVqNgisNntZfgzwM8LYDC+NdsrCKL2GaOgyzb0J9kCcVMRdmDGqLm+R6K6W+pH6mJ9UjZFGmagrqowFxJ93uWGce2sNnhdmy9wgbEpyh3ddZIm+BVTRTUjSy8d1eoMoVPNx+dO/hgqHZS047buhf7EBgUvfVnRnsFXN+okQKBgCjn3uMgeThxf+YnSMSbmgIrd8PDmOosSKlcd4XUUhAsWMwQ5Fo+0f6dEK+wUEcOSlObIk8t47KJvQxiDp0s+eq1Ay9SV6LmOx3UajboTba9ACbDK4+QZ5n4Mq0gWFGA0GdHvujMhSApzcZsLpM/N15XaYxiCAgKHB0Rw3uHT7sZAoGAEhF25OiuQTlw1WIJkz18zcZo9seEQW0lo+pCVxVBwBgMZqbKszzo9+QqQmYHRWpVsm9zv50UeLwAxhtgEpIvie7+ppgtG4wQJ4qGxoUtYHc/vTVPEmMIYKzaPqIVBFgV42kjKqq31lFb8JiGwV9fOnx39EIiHP1Dwai/nVZ2vyECgYEAuJQyqO1QPBG70E3gAy1yQxLYce473V9mizPEAjhV/oBlIOlrT4JpvwKoCuRdOoluDtYOHJpHk3hrSoboMuCl9BIECQIt03/xfaQbJ7YQu2SNf3ADrd6A+r8286aKBXjI9X9oSfwAgXnHQftGKDLqt6OrEyCAl+gsM3/R7eKsOH0="); | |||||
// request.setTradeType(TradeType.NATIVE); | |||||
// request.setCreateType(1); | |||||
// request.setDescription("测试"); | |||||
// request.setOutTradeNo("123456789"); | |||||
// request.setNotifyUrl("https://skx.mynatapp.cc/qtucpaymgt/wxv3/notify/"); | |||||
// request.setTotal(1); | |||||
// request.setCurrency("CNY"); | |||||
// request.setOpenid("oQj1Z5QX3YLzRl5Z0JJYlXQ_1HY8"); | |||||
// try { | // try { | ||||
// logger.info("格式校验异常 req:" + req.toJson(true)); | |||||
// jsonPostRepeat(req, 3); | |||||
// } catch (ApiRequestException e) { | |||||
// logger.error("", e); | |||||
// } | |||||
// req = new TypeSampleRequest(); | |||||
// req.setCardId("cardId" + new Random().nextInt(1000000)); | |||||
// req.setReqStr("hello"); | |||||
// req.setValid(true); | |||||
// try { | |||||
// logger.info("业务校验异常 req:" + req.toJson(true)); | |||||
// jsonPostRepeat(req, 3); | |||||
// } catch (ApiRequestException e) { | |||||
// logger.error("", e); | |||||
// } | |||||
// req = new TypeSampleRequest(); | |||||
// req.setCardId("cardId" + new Random().nextInt(1000000)); | |||||
// req.setReqStr("hello"); | |||||
// req.setValid(false); | |||||
// logger.info("成功 req:" + req.toJson(true)); | |||||
// TypeSampleResponse res = jsonPostRepeat(req, 1); | |||||
// logger.info("res:" + res.toJson(true)); | |||||
// AtsCreatPayOrderV3Response orderV3Response = createPayOrderV3Manager.serviceHandle(request); | |||||
// } catch (ServiceHandleException e) { | |||||
// | // | ||||
// logger.info("2313"); | |||||
// } | |||||
// System.out.println("234567"); | |||||
// } | // } | ||||
@Autowired | |||||
// @Resource | |||||
// @MockBean | |||||
private CreatePayOrderV3Manager createPayOrderV3Manager; | |||||
@Test | |||||
public void test1() { | |||||
AtsCreatPayOrderV3Request request = new AtsCreatPayOrderV3Request(); | |||||
request.setApiV3Key("yCocgAjiGMqQEfFE4SN4woJYSSfq07fd"); | |||||
request.setAppid("wx008c60533388527a"); | |||||
request.setMchid("1495316212");//1535705621 | |||||
// request.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpU2Z2fk0yDxsj6fYuxFhuqWqZ4HsHpWcxATjjNKgge7aFdSacBZBoO5ZTeHj2zSy1Atx8A0SiJ8FjM39wJFl97C8xcvGZYnIM0xxQsZnCwEkCpYrPUvwx5Fs7gumzmvnNetV8Mux2gzmneQayfrVM8TVkRptLYOsPAupuvyZ6Ygpn8Omd+ZSUkCI9KFm5cY16Uzi9SbUc0dF46NrhujDabvf9IEn6sGaWqkCv+LMU5h2jL79KrgjpMHvvu58i4pMM4SxeV06u8x7T/CRxA+Jwj8FGNv9Og7VUylmZVyISIDwUZz5wYCsr/XEPHt26WWriqUlm0gpV1DaZrIHkkQztAgMBAAECggEAX0Unn4AM2x+Yu6pF86ZRw2HbMt0VHAY6e14erefQuQYiehCiOqL+z0bHnAtqtCJZBzem6rfEBCCuNKyjBWvOVoVvQDlWKmEznnehtN1YkDU0XyLZaTFd6Ix9sIxGBeIqryxvtcPJPB01cT8tP3z/cV0+Fz+K3OyZFQck9E7kzXI1Vc3Dcx6ZGPRmkFyfjgxV2kTQzfQasoYK6rZjQwzQuXyHhLZx3iQuk61Ta8gqJ9O+2Y93koe6i6wUfF2yHgwAGgAuDa5Twx02XtRmTzILedFyLezwaV7Xg3y5KPFzt2u8w6nHjSi7tzTFPeW+QMMzmjsPqegDAfLAK+hW3lWtgQKBgQDf0ErISiCXYCQRw7TaF9J4vlecY/PQENEO8S+1tK5TJdmfsFULT0wS9W1QrmYlq6aeMBYbGsbxy+1+dqOGrkt7ICRXJaLXpVaPW1jaOXZtDs8NR3oCkF/4ePt0X7G7CKHrkjErHhdElTi6PTtyNdRDK0xhiQG2GMueqrxG2HHsnQKBgQDBrSKvVqNgisNntZfgzwM8LYDC+NdsrCKL2GaOgyzb0J9kCcVMRdmDGqLm+R6K6W+pH6mJ9UjZFGmagrqowFxJ93uWGce2sNnhdmy9wgbEpyh3ddZIm+BVTRTUjSy8d1eoMoVPNx+dO/hgqHZS047buhf7EBgUvfVnRnsFXN+okQKBgCjn3uMgeThxf+YnSMSbmgIrd8PDmOosSKlcd4XUUhAsWMwQ5Fo+0f6dEK+wUEcOSlObIk8t47KJvQxiDp0s+eq1Ay9SV6LmOx3UajboTba9ACbDK4+QZ5n4Mq0gWFGA0GdHvujMhSApzcZsLpM/N15XaYxiCAgKHB0Rw3uHT7sZAoGAEhF25OiuQTlw1WIJkz18zcZo9seEQW0lo+pCVxVBwBgMZqbKszzo9+QqQmYHRWpVsm9zv50UeLwAxhtgEpIvie7+ppgtG4wQJ4qGxoUtYHc/vTVPEmMIYKzaPqIVBFgV42kjKqq31lFb8JiGwV9fOnx39EIiHP1Dwai/nVZ2vyECgYEAuJQyqO1QPBG70E3gAy1yQxLYce473V9mizPEAjhV/oBlIOlrT4JpvwKoCuRdOoluDtYOHJpHk3hrSoboMuCl9BIECQIt03/xfaQbJ7YQu2SNf3ADrd6A+r8286aKBXjI9X9oSfwAgXnHQftGKDLqt6OrEyCAl+gsM3/R7eKsOH0="); | |||||
request.setTradeType(TradeType.NATIVE); | |||||
request.setCreateType(1); | |||||
request.setDescription("测试"); | |||||
request.setOutTradeNo("123456789"); | |||||
request.setNotifyUrl("https://skx.mynatapp.cc/qtucpaymgt/wxv3/notify/"); | |||||
request.setTotal(1); | |||||
request.setCurrency("CNY"); | |||||
request.setOpenid("oQj1Z5QX3YLzRl5Z0JJYlXQ_1HY8"); | |||||
try { | |||||
AtsCreatPayOrderV3Response orderV3Response = createPayOrderV3Manager.serviceHandle(request); | |||||
} catch (ServiceHandleException e) { | |||||
logger.info("2313"); | |||||
} | |||||
System.out.println("234567"); | |||||
} | |||||
} | |||||
//} |
package cn.com.taiji.ats.manager.wx; | |||||
import cn.com.taiji.ats.Application; | |||||
import cn.com.taiji.ats.manager.AbstractCommManager; | |||||
import cn.com.taiji.ats.manager.weixin.WxMpIsSubscribedManager; | |||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||||
import cn.com.taiji.core.model.comm.protocol.ats.wx.WxMpIsSubscribedRequest; | |||||
import org.junit.jupiter.api.Test; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.boot.test.context.SpringBootTest; | |||||
/** | |||||
* @Auther: humh | |||||
* @Description: | |||||
* @Date: 2025/5/12 10:58 | |||||
* @email: huminghao@mail.taiji.com.cn | |||||
* @version: 1.0 | |||||
*/ | |||||
@SpringBootTest(classes = Application.class) | |||||
public class TestWxMpIsSubscribedManager extends AbstractCommManager { | |||||
@Autowired | |||||
private WxMpIsSubscribedManager wxMpIsSubscribedManager; | |||||
@Test | |||||
public void test() throws ServiceHandleException { | |||||
WxMpIsSubscribedRequest request = new WxMpIsSubscribedRequest(); | |||||
request.setClientId("bfc4040bda90473d8ceab246555361a3"); | |||||
request.setOpenId("ogb3at_BW9zRd0GRPrBsNjthwGeA"); | |||||
wxMpIsSubscribedManager.serviceHandle(request); | |||||
} | |||||
} |
package cn.com.taiji.ias.tools; | |||||
import cn.com.taiji.core.model.comm.protocol.ias.province.model.GetHandleRecordsLocalModel; | |||||
import cn.com.taiji.core.model.comm.protocol.ias.province.model.GetOriginListResModel; | |||||
import cn.com.taiji.core.model.comm.protocol.ias.province.model.QueryNewRefundResModel; | |||||
import cn.com.taiji.ias.model.refundHttp.model.Attachment; | |||||
import cn.com.taiji.ias.model.refundHttp.model.GetHandleRecordsModel; | |||||
import cn.com.taiji.ias.model.refundHttp.model.GetOriginListAsyncModel; | |||||
import cn.com.taiji.ias.model.refundHttp.model.QueryNewRefundAsyncModel; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import javax.annotation.processing.Generated; | |||||
@Generated( | |||||
value = "org.mapstruct.ap.MappingProcessor", | |||||
date = "2025-05-15T15:36:15+0800", | |||||
comments = "version: 1.5.5.Final, compiler: javac, environment: Java 11.0.2 (Oracle Corporation)" | |||||
) | |||||
public class SourceTargetMapperImpl implements SourceTargetMapper { | |||||
@Override | |||||
public GetOriginListResModel GetOriginListAsyncModelToModel(GetOriginListAsyncModel asyncModel) { | |||||
if ( asyncModel == null ) { | |||||
return null; | |||||
} | |||||
GetOriginListResModel getOriginListResModel = new GetOriginListResModel(); | |||||
getOriginListResModel.setPassId( asyncModel.getPassId() ); | |||||
getOriginListResModel.setYgzListNo( asyncModel.getYgzListNo() ); | |||||
getOriginListResModel.setCardId( asyncModel.getCardId() ); | |||||
getOriginListResModel.setEnVehPlate( asyncModel.getEnVehPlate() ); | |||||
getOriginListResModel.setExVehPlate( asyncModel.getExVehPlate() ); | |||||
getOriginListResModel.setEnTime( asyncModel.getEnTime() ); | |||||
getOriginListResModel.setExTime( asyncModel.getExTime() ); | |||||
getOriginListResModel.setEnTollStationName( asyncModel.getEnTollStationName() ); | |||||
getOriginListResModel.setExTollStationName( asyncModel.getExTollStationName() ); | |||||
getOriginListResModel.setUnionPayTransFlag( asyncModel.getUnionPayTransFlag() ); | |||||
getOriginListResModel.setExVehClass( asyncModel.getExVehClass() ); | |||||
getOriginListResModel.setTollAmount( asyncModel.getTollAmount() ); | |||||
getOriginListResModel.setRecordType( asyncModel.getRecordType() ); | |||||
getOriginListResModel.setOwnerId( asyncModel.getOwnerId() ); | |||||
getOriginListResModel.setOwnerName( asyncModel.getOwnerName() ); | |||||
getOriginListResModel.setRoadName( asyncModel.getRoadName() ); | |||||
getOriginListResModel.setRoad( asyncModel.getRoad() ); | |||||
getOriginListResModel.setManageName( asyncModel.getManageName() ); | |||||
getOriginListResModel.setManageUnit( asyncModel.getManageUnit() ); | |||||
getOriginListResModel.setHexCardId( asyncModel.getHexCardId() ); | |||||
getOriginListResModel.setMultiProvince( asyncModel.getMultiProvince() ); | |||||
getOriginListResModel.setIsFind( asyncModel.getIsFind() ); | |||||
getOriginListResModel.setRefundType( asyncModel.getRefundType() ); | |||||
getOriginListResModel.setRoadTime( asyncModel.getRoadTime() ); | |||||
getOriginListResModel.setHandleMessage( asyncModel.getHandleMessage() ); | |||||
getOriginListResModel.setHandleResult( asyncModel.getHandleResult() ); | |||||
getOriginListResModel.setHandlerType( asyncModel.getHandlerType() ); | |||||
getOriginListResModel.setSubmitAccount( asyncModel.getSubmitAccount() ); | |||||
return getOriginListResModel; | |||||
} | |||||
@Override | |||||
public QueryNewRefundResModel QueryNewRefundAsyncModelToModel(QueryNewRefundAsyncModel asyncModel) { | |||||
if ( asyncModel == null ) { | |||||
return null; | |||||
} | |||||
QueryNewRefundResModel queryNewRefundResModel = new QueryNewRefundResModel(); | |||||
queryNewRefundResModel.setOwnerName( asyncModel.getOwnerName() ); | |||||
queryNewRefundResModel.setManageName( asyncModel.getManageName() ); | |||||
queryNewRefundResModel.setFormNo( asyncModel.getFormNo() ); | |||||
queryNewRefundResModel.setYgzListNo( asyncModel.getYgzListNo() ); | |||||
queryNewRefundResModel.setPassId( asyncModel.getPassId() ); | |||||
queryNewRefundResModel.setCardId( asyncModel.getCardId() ); | |||||
queryNewRefundResModel.setHexCardId( asyncModel.getHexCardId() ); | |||||
queryNewRefundResModel.setExVehPlate( asyncModel.getExVehPlate() ); | |||||
queryNewRefundResModel.setEnTollStationName( asyncModel.getEnTollStationName() ); | |||||
queryNewRefundResModel.setEnTime( asyncModel.getEnTime() ); | |||||
queryNewRefundResModel.setExTollStationName( asyncModel.getExTollStationName() ); | |||||
queryNewRefundResModel.setExTime( asyncModel.getExTime() ); | |||||
queryNewRefundResModel.setTollAmount( asyncModel.getTollAmount() ); | |||||
queryNewRefundResModel.setRefundFee( asyncModel.getRefundFee() ); | |||||
queryNewRefundResModel.setExVehClass( asyncModel.getExVehClass() ); | |||||
queryNewRefundResModel.setUnionPayTransFlag( asyncModel.getUnionPayTransFlag() ); | |||||
queryNewRefundResModel.setRefundType( asyncModel.getRefundType() ); | |||||
queryNewRefundResModel.setPrintName( asyncModel.getPrintName() ); | |||||
queryNewRefundResModel.setFormType( asyncModel.getFormType() ); | |||||
queryNewRefundResModel.setCreateTime( asyncModel.getCreateTime() ); | |||||
queryNewRefundResModel.setStatus( asyncModel.getStatus() ); | |||||
queryNewRefundResModel.setHandleStatus( asyncModel.getHandleStatus() ); | |||||
queryNewRefundResModel.setHandleTime( asyncModel.getHandleTime() ); | |||||
return queryNewRefundResModel; | |||||
} | |||||
@Override | |||||
public GetHandleRecordsLocalModel GetHandleRecordsModelToModel(GetHandleRecordsModel asyncModel) { | |||||
if ( asyncModel == null ) { | |||||
return null; | |||||
} | |||||
GetHandleRecordsLocalModel getHandleRecordsLocalModel = new GetHandleRecordsLocalModel(); | |||||
getHandleRecordsLocalModel.setCreateTime( asyncModel.getCreateTime() ); | |||||
getHandleRecordsLocalModel.setHandleResult( asyncModel.getHandleResult() ); | |||||
getHandleRecordsLocalModel.setHandleMessage( asyncModel.getHandleMessage() ); | |||||
getHandleRecordsLocalModel.setHandlerType( asyncModel.getHandlerType() ); | |||||
getHandleRecordsLocalModel.setAttachments( attachmentListToAttachmentList( asyncModel.getAttachments() ) ); | |||||
getHandleRecordsLocalModel.setSubmitAccount( asyncModel.getSubmitAccount() ); | |||||
return getHandleRecordsLocalModel; | |||||
} | |||||
protected cn.com.taiji.core.model.comm.protocol.ias.province.model.Attachment attachmentToAttachment(Attachment attachment) { | |||||
if ( attachment == null ) { | |||||
return null; | |||||
} | |||||
cn.com.taiji.core.model.comm.protocol.ias.province.model.Attachment attachment1 = new cn.com.taiji.core.model.comm.protocol.ias.province.model.Attachment(); | |||||
attachment1.setId( attachment.getId() ); | |||||
attachment1.setFileName( attachment.getFileName() ); | |||||
attachment1.setUrl( attachment.getUrl() ); | |||||
attachment1.setHandleRecordId( attachment.getHandleRecordId() ); | |||||
return attachment1; | |||||
} | |||||
protected List<cn.com.taiji.core.model.comm.protocol.ias.province.model.Attachment> attachmentListToAttachmentList(List<Attachment> list) { | |||||
if ( list == null ) { | |||||
return null; | |||||
} | |||||
List<cn.com.taiji.core.model.comm.protocol.ias.province.model.Attachment> list1 = new ArrayList<cn.com.taiji.core.model.comm.protocol.ias.province.model.Attachment>( list.size() ); | |||||
for ( Attachment attachment : list ) { | |||||
list1.add( attachmentToAttachment( attachment ) ); | |||||
} | |||||
return list1; | |||||
} | |||||
} |
# 退费接口相关参数 | # 退费接口相关参数 | ||||
refund: | refund: | ||||
# baseUrl: http://10.152.224.67:40588 | |||||
baseUrl: https://74d9c63d.r5.cpolar.cn | |||||
baseUrl: http://10.152.224.67:40588 | |||||
authUrl: /api/Login/UserAuthorize | authUrl: /api/Login/UserAuthorize | ||||
account: 520201 | account: 520201 | ||||
password: 2024abC@ | password: 2024abC@ |
import cn.com.taiji.ias.Application; | import cn.com.taiji.ias.Application; | ||||
import cn.com.taiji.ias.manager.AbstractCommManager; | import cn.com.taiji.ias.manager.AbstractCommManager; | ||||
import cn.com.taiji.ias.manager.province.*; | import cn.com.taiji.ias.manager.province.*; | ||||
import cn.com.taiji.ias.model.refundHttp.GetHandleRecordsRequest; | |||||
import cn.com.taiji.ias.tools.HttpClientUtil; | import cn.com.taiji.ias.tools.HttpClientUtil; | ||||
import org.apache.commons.compress.utils.Lists; | import org.apache.commons.compress.utils.Lists; | ||||
import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; |