feat:正元测试环境对接成功
This commit is contained in:
1 parent
aaf97a9b3d
commit
694f4b43cb
5 files changed
+80
-54
No files matched your search
-3
@@ -119,9 +119,6 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
try {
|
||||
// 校验订单是否可以退款
|
||||
HardOrderVo order = hardAfterSaleService.validateOrderCanRefund(dto.getOrderId());
|
||||
if (!ObjectUtil.equals(dto.getSerialNum(), order.getOrderNo())) {
|
||||
throw new RuntimeException("正元订单号不匹配");
|
||||
}
|
||||
// 用户
|
||||
UserInfo user = remoteUserService.getByUserId(order.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("用户不存在");
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ZySelfPayVo extends ZyBaseVo {
|
||||
public class ZySelfPayVo {
|
||||
|
||||
/**
|
||||
* 帐号
|
||||
@@ -31,7 +31,7 @@ public class ZySelfPayVo extends ZyBaseVo {
|
||||
private String perCode;
|
||||
|
||||
/**
|
||||
* 订单流水号,全局唯一,第三方流水号
|
||||
* 订单流水号,全局唯一,第三方流水号
|
||||
*/
|
||||
private String platformSerialNum;
|
||||
|
||||
|
||||
+54
-38
@@ -103,8 +103,9 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||
entity.setBizType(bizType.getType());
|
||||
entity.setApiUrl(ZyApi.Self.CORRECT);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(params));
|
||||
long startTime = System.currentTimeMillis();
|
||||
ZySelfCorrectVo result = new ZySelfCorrectVo();
|
||||
ZyBaseVo result = new ZyBaseVo();
|
||||
try {
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
boolean isToken = checkIsToken(accessToken);
|
||||
@@ -126,7 +127,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
result.setMsg(ZyBaseVo.defaultErrorMsg);
|
||||
ZySelfCorrectDto dto = JSONUtil.toBean(jsonRes, ZySelfCorrectDto.class);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(dto));
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(dto));
|
||||
// 获取参数
|
||||
String correctSerialNum = dto.getCorrectSerialNum();
|
||||
Long orderId = Long.parseLong(correctSerialNum);
|
||||
@@ -140,18 +141,25 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
case SUCCESS -> {
|
||||
ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getBySelfId(ThirdZyBizEnumType.SYNC_ACCOUNT_INFO, String.valueOf(refundRes.getUserId()));
|
||||
String userZyId = userIdDict.getZyId();
|
||||
result.setAccNum(userZyId);
|
||||
result.setAccName(refundRes.getUsername());
|
||||
result.setPerCode(userZyId);
|
||||
result.setPlatformSerialNum(String.valueOf(refundRes.getRefundId()));
|
||||
result.setSerialNum(refundRes.getOrderNo());
|
||||
result.setRecDate(LocalDateTimeUtil.format(refundRes.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
result.setAmount(dto.getAmount());
|
||||
ZySelfPayVo success = new ZySelfPayVo();
|
||||
success.setAccNum(userZyId);
|
||||
success.setAccName(refundRes.getUsername());
|
||||
success.setPerCode(userZyId);
|
||||
success.setPlatformSerialNum(String.valueOf(refundRes.getRefundId()));
|
||||
success.setSerialNum(refundRes.getOrderNo());
|
||||
success.setRecDate(LocalDateTimeUtil.format(refundRes.getRefundTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
success.setAmount(dto.getAmount());
|
||||
result.setMsg(ZyBaseVo.selfSuccessMsg);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(result));
|
||||
Map<String, Object> encryptionRes = zyApiTool.getSelfEncryptionMap(BeanUtil.beanToMap(result));
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(encryptionRes));
|
||||
return encryptionRes;
|
||||
Map<String, Object> resMap = BeanUtil.beanToMap(result);
|
||||
Map<String, Object> dataMap = BeanUtil.beanToMap(success);
|
||||
dataMap.put("sign", zyApiTool.generateSign(dataMap, false));
|
||||
resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap)));
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(success));
|
||||
entity.setEncipherRes(JSONUtil.toJsonStr(resMap));
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
return resMap;
|
||||
}
|
||||
default -> throw new RuntimeException();
|
||||
}
|
||||
@@ -159,11 +167,10 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
String error = String.format("|%s||correct|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
return result.getErrorMap();
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
return result.getErrorMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +185,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
entity.setBizType(bizType.getType());
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(params));
|
||||
long startTime = System.currentTimeMillis();
|
||||
ZySelfPayVo result = new ZySelfPayVo();
|
||||
ZyBaseVo result = new ZyBaseVo();
|
||||
try {
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
// 判断token
|
||||
@@ -200,7 +207,7 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
result.setCode(ZyBaseVo.errorCode);
|
||||
result.setMsg(ZyBaseVo.defaultErrorMsg);
|
||||
ZySelfPayDto dto = JSONUtil.toBean(jsonRes, ZySelfPayDto.class);
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(dto));
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(dto));
|
||||
// 获取参数
|
||||
String accNum = dto.getAccNum();
|
||||
ThirdZyIdDictEntity userIdDict = thirdZyIdDictMapper.getByZyIds(ThirdZyBizEnumType.SYNC_ACCOUNT_INFO, accNum);
|
||||
@@ -224,18 +231,25 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
result.setCode(payRes.getCode().getType());
|
||||
switch (payRes.getCode()) {
|
||||
case SUCCESS -> {
|
||||
result.setAccNum(payRes.getUserId().toString());
|
||||
result.setAccName(payRes.getUsername());
|
||||
result.setPerCode(payRes.getUserId().toString());
|
||||
result.setPlatformSerialNum(dto.getSerialNum());
|
||||
result.setSerialNum(dto.getSerialNum());
|
||||
result.setAmount(amount);
|
||||
result.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
ZySelfPayVo success = new ZySelfPayVo();
|
||||
success.setAccNum(payRes.getUserId().toString());
|
||||
success.setAccName(payRes.getUsername());
|
||||
success.setPerCode(payRes.getUserId().toString());
|
||||
success.setPlatformSerialNum(payRes.getOrderId().toString());
|
||||
success.setSerialNum(dto.getSerialNum());
|
||||
success.setAmount(amount);
|
||||
success.setRecDate(LocalDateTimeUtil.format(payRes.getPayTime(), DatePattern.NORM_DATETIME_PATTERN));
|
||||
result.setMsg(ZyBaseVo.selfSuccessMsg);
|
||||
entity.setOrgReq(JSONUtil.toJsonStr(result));
|
||||
Map<String, Object> encryptionRes = zyApiTool.getSelfEncryptionMap(BeanUtil.beanToMap(result));
|
||||
entity.setEncipherReq(JSONUtil.toJsonStr(encryptionRes));
|
||||
return encryptionRes;
|
||||
Map<String, Object> resMap = BeanUtil.beanToMap(result);
|
||||
Map<String, Object> dataMap = BeanUtil.beanToMap(success);
|
||||
dataMap.put("sign", zyApiTool.generateSign(dataMap, false));
|
||||
resMap.put("data", Base64.encode(JSONUtil.toJsonStr(dataMap)));
|
||||
entity.setOrgRes(JSONUtil.toJsonStr(success));
|
||||
entity.setEncipherRes(JSONUtil.toJsonStr(resMap));
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
return resMap;
|
||||
}
|
||||
default -> throw new RuntimeException();
|
||||
}
|
||||
@@ -243,11 +257,10 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
String error = String.format("|%s||pay|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
entity.setError(error);
|
||||
return result.getErrorMap();
|
||||
} finally {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||
thirdZyLogService.save(entity);
|
||||
return result.getErrorMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,11 +287,11 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
result.setMsg(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + "*";
|
||||
Set<String> keys = redisTemplate.keys(redisKey);
|
||||
if (ObjectUtil.isNotEmpty(keys)) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
// String redisKey = CacheConstants.THIRDPARTY_ZY_SELF_TOKEN + "*";
|
||||
// Set<String> keys = redisTemplate.keys(redisKey);
|
||||
// if (ObjectUtil.isNotEmpty(keys)) {
|
||||
// redisTemplate.delete(keys);
|
||||
// }
|
||||
try {
|
||||
// 生成token
|
||||
String token = generateToken(params);
|
||||
@@ -345,14 +358,17 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
||||
}
|
||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (ObjectUtil.isEmpty(value)) continue;
|
||||
if (value instanceof String) {
|
||||
entry.setValue(Base64.decodeStr((String) value));
|
||||
String str = Base64.decodeStr((String) value);
|
||||
entry.setValue(URLUtil.decode(str));
|
||||
} else {
|
||||
entry.setValue(Base64.decodeStr(value.toString()));
|
||||
String str = Base64.decodeStr((String) value);
|
||||
entry.setValue(URLUtil.decode(str));
|
||||
}
|
||||
}
|
||||
String string = zyApiTool.generateSign(paramsMap, false);
|
||||
if (ObjectUtil.equals(sign, string)) {
|
||||
if (ObjectUtil.equals(sign.toLowerCase(), string)) {
|
||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
|
||||
+7
-5
@@ -174,7 +174,7 @@ public class ZyApiTool {
|
||||
return body;
|
||||
}
|
||||
|
||||
private void prePost(Map<String, Object> params, boolean isZy) {
|
||||
public void prePost(Map<String, Object> params, boolean isZy) {
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
@@ -187,10 +187,12 @@ public class ZyApiTool {
|
||||
String sign = generateSign(params, isZy);
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof String) {
|
||||
entry.setValue(Base64.encode((String) value));
|
||||
} else {
|
||||
entry.setValue(Base64.encode(value.toString()));
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
if (value instanceof String) {
|
||||
entry.setValue(Base64.encode((String) value));
|
||||
} else {
|
||||
entry.setValue(Base64.encode(value.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
params.put("sign", sign);
|
||||
|
||||
+17
-6
@@ -80,15 +80,26 @@ public class ZyTest {
|
||||
ZySelfGetTokenVo token = zySelfService.getToken(tokenParams);
|
||||
String accessToken = token.getAccess_token();
|
||||
|
||||
// ZySelfPayDto params = ZySelfPayDto
|
||||
// .builder()
|
||||
// .accNum(dzcUserDict.getZyId())
|
||||
// .cardAccNum(dzcWalletId)
|
||||
// .amount("10")
|
||||
// .serialNum("01234567890123456789")
|
||||
// .dealTime(date)
|
||||
// .opId("0123456789")
|
||||
// .build();
|
||||
|
||||
ZySelfPayDto params = ZySelfPayDto
|
||||
.builder()
|
||||
.accNum(dzcUserDict.getZyId())
|
||||
.cardAccNum(dzcWalletId)
|
||||
.amount("10")
|
||||
.serialNum("01234567890123456789")
|
||||
.dealTime(date)
|
||||
.opId("0123456789")
|
||||
.accNum("1741232987425846")
|
||||
.cardAccNum("1877309001545244673")
|
||||
.amount("0.01")
|
||||
.serialNum("763")
|
||||
.dealTime("2025-03-06 17:34:11")
|
||||
.opId("")
|
||||
.build();
|
||||
String testJson = "{\"accNum\":\"MTc0MTIzMjk4NzQyNTg0Ng==\",\"amount\":\"MC4wMQ==\",\"cardAccNum\":\"MTg3NzMwOTAwMTU0NTI0NDY3Mw==\",\"dealTime\":\"MjAyNS0wMy0wNiAxNjo0NTowMA==\",\"opId\":\"\",\"serialNum\":\"NzYx\",\"sign\":\"3EFD38EA76BDC32165841852F0EEFD5E\"}";
|
||||
Map<String, Object> paramsMap = BeanUtil.beanToMap(params);
|
||||
Map<String, Object> body = zyApiTool.getSelfEncryptionMap(paramsMap, "accNum", "cardAccNum", "amount", "serialNum", "dealTime", "opId");
|
||||
ZySelfPayDto bodyObj = JSONUtil.toBean(JSONUtil.toJsonStr(body), ZySelfPayDto.class);
|
||||
|
||||
Reference in new issue
Block a user