1111
This commit is contained in:
1 parent
63401b3343
commit
b8ed71f81b
10 files changed
+262
-39
No files matched your search
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.bsd.pjcloud.hard.api.feign;
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@FeignClient(contextId = "remoteHardThirdSelfZyService", value = ServiceNameConstants.HARDWARE_SERVICE)
|
||||||
|
public interface RemoteHardThirdSelfZyService {
|
||||||
|
|
||||||
|
@NoToken
|
||||||
|
@PostMapping("/hard-third-callback/pay")
|
||||||
|
void pay();
|
||||||
|
|
||||||
|
@NoToken
|
||||||
|
@PostMapping("/hard-third-callback/refund")
|
||||||
|
void refund();
|
||||||
|
|
||||||
|
}
|
||||||
+1
@@ -1 +1,2 @@
|
|||||||
com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService
|
com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService
|
||||||
|
com.bsd.pjcloud.hard.api.feign.RemoteHardThirdSelfZyService
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package com.bsd.pjcloud.hard.controller.third;
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.common.core.util.R;
|
||||||
|
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||||
|
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||||
|
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||||
|
import com.bsd.pjcloud.hard.service.HardThirdSelfZyService;
|
||||||
|
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/hard-third-callback")
|
||||||
|
@Tag(description = "hard-third-zy", name = "正元第三方接口调用回调")
|
||||||
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||||
|
public class HardThirdSelfZyController {
|
||||||
|
|
||||||
|
private final HardThirdSelfZyService hardThirdSelfZyService;
|
||||||
|
|
||||||
|
/* ************************************* start 远程调用 start ************************************* */
|
||||||
|
|
||||||
|
@Inner(value = false)
|
||||||
|
@PostMapping("/pay")
|
||||||
|
@SysLog("正元支付")
|
||||||
|
@Operation(summary = "正元支付")
|
||||||
|
public void pay() {
|
||||||
|
hardThirdSelfZyService.pay();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inner(value = false)
|
||||||
|
@PostMapping("/refund")
|
||||||
|
@SysLog("正元退款")
|
||||||
|
@Operation(summary = "正元退款")
|
||||||
|
public void refund() {
|
||||||
|
hardThirdSelfZyService.refund();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************* end 远程调用 end ************************************* */
|
||||||
|
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bsd.pjcloud.hard.service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface HardThirdSelfZyService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正元支付
|
||||||
|
*/
|
||||||
|
void pay();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正元退款
|
||||||
|
*/
|
||||||
|
void refund();
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package com.bsd.pjcloud.hard.service.impl.hard;
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.hard.service.HardThirdSelfZyService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pay() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refund() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
@@ -41,6 +41,9 @@ public class ZyBaseVo {
|
|||||||
// 无效的access_token
|
// 无效的access_token
|
||||||
public static String accessTokenError = "40004";
|
public static String accessTokenError = "40004";
|
||||||
|
|
||||||
|
// 成功的消息
|
||||||
|
public static String selfSuccessMsg = "成功";
|
||||||
|
|
||||||
public static String defaultErrorMsg = "服务异常,请重试或联系管理员";
|
public static String defaultErrorMsg = "服务异常,请重试或联系管理员";
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|||||||
@@ -115,10 +115,22 @@
|
|||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt</artifactId>
|
||||||
<version>0.9.1</version>
|
<version>0.9.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
<version>2.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 重复提交 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bsd</groupId>
|
<groupId>com.bsd</groupId>
|
||||||
<artifactId>pjcloud-common-idempotent</artifactId>
|
<artifactId>pjcloud-common-idempotent</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bsd</groupId>
|
||||||
|
<artifactId>pjcloud-hardware-api</artifactId>
|
||||||
|
<version>5.7.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
|||||||
+9
-7
@@ -1,6 +1,7 @@
|
|||||||
package com.bsd.pjcloud.thirdparty.controller.zy;
|
package com.bsd.pjcloud.thirdparty.controller.zy;
|
||||||
|
|
||||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||||
|
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
||||||
@@ -9,10 +10,8 @@ import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfCorrectVo;
|
|||||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfGetTokenVo;
|
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfGetTokenVo;
|
||||||
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfPayVo;
|
import com.bsd.pjcloud.thirdparty.vo.zy.self.ZySelfPayVo;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -21,11 +20,11 @@ import java.util.Map;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/third-zy-self")
|
@RequestMapping("/third-zy-self")
|
||||||
@Tag(description = "/third-zy-self", name = "正元接口对接")
|
@Tag(description = "/third-zy-self", name = "正元接口对接")
|
||||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
|
||||||
public class ThirdZySelfController {
|
public class ThirdZySelfController {
|
||||||
|
|
||||||
private final ThirdZySelfService zySelfService;
|
private final ThirdZySelfService zySelfService;
|
||||||
|
|
||||||
|
@Inner(value = false)
|
||||||
@GetMapping("/checkSystemStatus")
|
@GetMapping("/checkSystemStatus")
|
||||||
@Operation(summary = "第三方url健康探测", description = "第三方url健康探测")
|
@Operation(summary = "第三方url健康探测", description = "第三方url健康探测")
|
||||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||||
@@ -33,23 +32,26 @@ public class ThirdZySelfController {
|
|||||||
return zySelfService.checkSystemStatus();
|
return zySelfService.checkSystemStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inner(value = false)
|
||||||
@GetMapping("/getToken")
|
@GetMapping("/getToken")
|
||||||
@Operation(summary = "第三方提供获取token", description = "第三方提供获取token")
|
@Operation(summary = "第三方提供获取token", description = "第三方提供获取token")
|
||||||
|
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||||
public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) {
|
public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) {
|
||||||
return zySelfService.getToken(params);
|
return zySelfService.getToken(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inner(value = false)
|
||||||
@PostMapping("/correct")
|
@PostMapping("/correct")
|
||||||
@Operation(summary = "第三方一卡通系统提供冲正接口", description = "第三方一卡通系统提供冲正接口")
|
@Operation(summary = "第三方一卡通系统提供冲正接口", description = "第三方一卡通系统提供冲正接口")
|
||||||
public ZySelfCorrectVo correct(@RequestBody ZySelfCorrectDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
public ZySelfCorrectVo correct(ZySelfCorrectDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||||
return zySelfService.correct(params, accessToken);
|
return zySelfService.correct(params, accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getToken")
|
@Inner(value = false)
|
||||||
|
@PostMapping("/pay")
|
||||||
@Operation(summary = "第三方一卡通系统提供扣费接口", description = "第三方一卡通系统提供扣费接口")
|
@Operation(summary = "第三方一卡通系统提供扣费接口", description = "第三方一卡通系统提供扣费接口")
|
||||||
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
@Idempotent(expireTime = 10, info = "请勿重复调用")
|
||||||
public ZySelfPayVo pay(@RequestBody ZySelfPayDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
public ZySelfPayVo pay(ZySelfPayDto params, @RequestParam(value = "access_token", required = false) String accessToken) {
|
||||||
return zySelfService.pay(params, accessToken);
|
return zySelfService.pay(params, accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+123
-31
@@ -1,11 +1,14 @@
|
|||||||
package com.bsd.pjcloud.thirdparty.service.impl.zy;
|
package com.bsd.pjcloud.thirdparty.service.impl.zy;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||||
|
import com.bsd.pjcloud.hard.api.feign.RemoteHardThirdSelfZyService;
|
||||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||||
|
import com.bsd.pjcloud.thirdparty.constant.ThirdZyBizEnumType;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfCorrectDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfGetTokenDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.self.ZySelfPayDto;
|
||||||
@@ -26,10 +29,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -46,12 +46,16 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
|
|
||||||
private final ThirdZyLogServiceImpl thirdZyLogService;
|
private final ThirdZyLogServiceImpl thirdZyLogService;
|
||||||
|
|
||||||
|
private final RemoteHardThirdSelfZyService hardCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方url健康探测
|
* 第三方url健康探测
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> checkSystemStatus() {
|
public Map<String, Object> checkSystemStatus() {
|
||||||
|
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SELF_CHECK_SYSTEM_STATUS;
|
||||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||||
|
entity.setBizType(bizType.getType());
|
||||||
entity.setApiUrl(ZyApi.Self.CHECK_SYSTEM_STATUS);
|
entity.setApiUrl(ZyApi.Self.CHECK_SYSTEM_STATUS);
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
@@ -76,16 +80,40 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ZySelfCorrectVo correct(ZySelfCorrectDto params, String accessToken) {
|
public ZySelfCorrectVo correct(ZySelfCorrectDto params, String accessToken) {
|
||||||
ZySelfCorrectVo result = new ZySelfCorrectVo();
|
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SELF_CORRECT;
|
||||||
result.setCode(ZyBaseVo.errorCode);
|
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||||
boolean isToken = checkIsToken(accessToken);
|
entity.setBizType(bizType.getType());
|
||||||
if (!isToken) {
|
long startTime = System.currentTimeMillis();
|
||||||
result.setCode(ZyBaseVo.accessTokenError);
|
try {
|
||||||
result.setMsg("无效的access_token");
|
ZySelfCorrectVo result = new ZySelfCorrectVo();
|
||||||
return result;
|
result.setCode(ZyBaseVo.errorCode);
|
||||||
|
boolean isToken = checkIsToken(accessToken);
|
||||||
|
// 判断token
|
||||||
|
if (!isToken) {
|
||||||
|
String msg = "无效的access_token";
|
||||||
|
result.setCode(ZyBaseVo.accessTokenError);
|
||||||
|
result.setMsg(msg);
|
||||||
|
throw new RuntimeException(msg);
|
||||||
|
}
|
||||||
|
// 校验加密参数
|
||||||
|
boolean isSign = checkSign(params);
|
||||||
|
if (!isSign) {
|
||||||
|
String msg = "数据加密认证失败!sign值验证失败";
|
||||||
|
result.setCode(ZyBaseVo.signError);
|
||||||
|
result.setMsg(msg);
|
||||||
|
throw new RuntimeException(msg);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
String error = String.format("|%s||correct|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||||
|
log.error(error);
|
||||||
|
entity.setError(error);
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
|
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||||
|
thirdZyLogService.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,15 +121,40 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ZySelfPayVo pay(ZySelfPayDto params, String accessToken) {
|
public ZySelfPayVo pay(ZySelfPayDto params, String accessToken) {
|
||||||
ZySelfCorrectVo result = new ZySelfCorrectVo();
|
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SELF_PAY;
|
||||||
result.setCode(ZyBaseVo.errorCode);
|
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||||
boolean isToken = checkIsToken(accessToken);
|
entity.setBizType(bizType.getType());
|
||||||
if (!isToken) {
|
long startTime = System.currentTimeMillis();
|
||||||
result.setCode(ZyBaseVo.accessTokenError);
|
ZySelfPayVo result = new ZySelfPayVo();
|
||||||
result.setMsg("无效的access_token");
|
try {
|
||||||
|
result.setCode(ZyBaseVo.errorCode);
|
||||||
|
// 判断token
|
||||||
|
boolean isToken = checkIsToken(accessToken);
|
||||||
|
if (!isToken) {
|
||||||
|
String msg = "无效的access_token";
|
||||||
|
result.setCode(ZyBaseVo.accessTokenError);
|
||||||
|
result.setMsg(msg);
|
||||||
|
throw new RuntimeException(msg);
|
||||||
|
}
|
||||||
|
// 校验加密参数
|
||||||
|
boolean isSign = checkSign(params);
|
||||||
|
if (!isSign) {
|
||||||
|
String msg = "数据加密认证失败!sign值验证失败";
|
||||||
|
result.setCode(ZyBaseVo.signError);
|
||||||
|
result.setMsg(msg);
|
||||||
|
throw new RuntimeException(msg);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
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;
|
||||||
|
} finally {
|
||||||
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
|
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||||
|
thirdZyLogService.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,24 +162,33 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) {
|
public ZySelfGetTokenVo getToken(ZySelfGetTokenDto params) {
|
||||||
|
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SELF_GET_TOKEN;
|
||||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||||
|
entity.setBizType(bizType.getType());
|
||||||
entity.setApiUrl(ZyApi.Self.GET_TOKEN);
|
entity.setApiUrl(ZyApi.Self.GET_TOKEN);
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
ZySelfGetTokenVo result = new ZySelfGetTokenVo();
|
ZySelfGetTokenVo result = new ZySelfGetTokenVo();
|
||||||
result.setCode(ZyBaseVo.errorCode);
|
result.setCode(ZyBaseVo.errorCode);
|
||||||
if (ObjectUtil.isEmpty(params.getAppid()) || ObjectUtil.equals(params.getAppid(), zyConfig.getSelfAppId())) {
|
result.setMsg(ZyBaseVo.defaultErrorMsg);
|
||||||
result.setMsg("appid 无效");
|
if (ObjectUtil.isEmpty(params.getAppid()) || ObjectUtil.notEqual(params.getAppid(), zyConfig.getSelfAppId())) {
|
||||||
return result;
|
String msg = "appid 无效";
|
||||||
|
result.setMsg(msg);
|
||||||
|
throw new RuntimeException(msg);
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isEmpty(params.getAppsecret()) || ObjectUtil.equals(params.getAppsecret(), zyConfig.getSelfAppSecret())) {
|
if (ObjectUtil.isEmpty(params.getAppsecret()) || ObjectUtil.notEqual(params.getAppsecret(), zyConfig.getSelfAppSecret())) {
|
||||||
result.setMsg("appSecret 无效");
|
String msg = "appSecret 无效";
|
||||||
return result;
|
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;
|
|
||||||
redisTemplate.opsForValue().getAndDelete(redisKey);
|
|
||||||
try {
|
try {
|
||||||
// 生成token
|
// 生成token
|
||||||
String token = generateToken(params);
|
String token = generateToken(params);
|
||||||
|
result.setMsg(ZyBaseVo.selfSuccessMsg);
|
||||||
result.setCode(ZyBaseVo.successCode);
|
result.setCode(ZyBaseVo.successCode);
|
||||||
result.setAccess_token(token);
|
result.setAccess_token(token);
|
||||||
result.setExpires_in(zyConfig.getSelfExpiresIn().toString());
|
result.setExpires_in(zyConfig.getSelfExpiresIn().toString());
|
||||||
@@ -135,7 +197,6 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
String error = String.format("|%s||getToken|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
String error = String.format("|%s||getToken|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||||
log.error(error);
|
log.error(error);
|
||||||
entity.setError(error);
|
entity.setError(error);
|
||||||
result.setMsg(ZyBaseVo.defaultErrorMsg);
|
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
@@ -164,6 +225,33 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验参数
|
||||||
|
*/
|
||||||
|
private boolean checkSign(Object obj) {
|
||||||
|
if (ObjectUtil.isEmpty(obj)) return false;
|
||||||
|
try {
|
||||||
|
Map<String, Object> map = BeanUtil.beanToMap(obj);
|
||||||
|
if (ObjectUtil.isEmpty(map)) return false;
|
||||||
|
Map<String, Object> paramsMap = new TreeMap<>(map);
|
||||||
|
paramsMap.remove("sign");
|
||||||
|
String sign = map.getOrDefault("sign", "").toString();
|
||||||
|
if (ObjectUtil.isEmpty(sign)) {
|
||||||
|
log.error("|{}|checkSign意外的错误,sign为空", sign);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(paramsMap)) {
|
||||||
|
log.error("|{}|checkSign意外的错误,paramsMap为空", paramsMap);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("|{}|checkSign意外的错误,加密参数|{}|", TAG, JSONUtil.toJsonStr(obj), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 生成token
|
// 生成token
|
||||||
private String generateToken(ZySelfGetTokenDto dto) {
|
private String generateToken(ZySelfGetTokenDto dto) {
|
||||||
ZySelfTokenDto selfTokenDto = new ZySelfTokenDto();
|
ZySelfTokenDto selfTokenDto = new ZySelfTokenDto();
|
||||||
@@ -175,9 +263,13 @@ public class ThirdZySelfServiceImpl implements ThirdZySelfService {
|
|||||||
selfTokenDto.setAppid(dto.getAppid());
|
selfTokenDto.setAppid(dto.getAppid());
|
||||||
selfTokenDto.setAppSecret(dto.getAppsecret());
|
selfTokenDto.setAppSecret(dto.getAppsecret());
|
||||||
refreshToken(selfTokenDto);
|
refreshToken(selfTokenDto);
|
||||||
return Jwts.builder()
|
String compact = Jwts.builder()
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
.signWith(SignatureAlgorithm.HS512, zyConfig.getSelfTokenSecret()).compact();
|
.signWith(SignatureAlgorithm.HS512, zyConfig.getSelfTokenSecret()).compact();
|
||||||
|
if (ObjectUtil.isEmpty(compact)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return compact;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 刷新token
|
/// 刷新token
|
||||||
|
|||||||
+3
-1
@@ -73,7 +73,9 @@ public class WalletThirdZyServiceImpl implements WalletThirdZyService {
|
|||||||
@Override
|
@Override
|
||||||
public void syncAllMch(Long mchId, Boolean isDel) {
|
public void syncAllMch(Long mchId, Boolean isDel) {
|
||||||
MchManageDto dto = new MchManageDto();
|
MchManageDto dto = new MchManageDto();
|
||||||
dto.setId(mchId);
|
if (ObjectUtil.isNotEmpty(mchId)) {
|
||||||
|
dto.setId(mchId);
|
||||||
|
}
|
||||||
List<MchManageVo> mchList = mchManageService.list(dto);
|
List<MchManageVo> mchList = mchManageService.list(dto);
|
||||||
if (ObjectUtil.isEmpty(mchList)) {
|
if (ObjectUtil.isEmpty(mchList)) {
|
||||||
log.info("|{}|同步到正元全部商户信息错误mchList为空", TAG);
|
log.info("|{}|同步到正元全部商户信息错误mchList为空", TAG);
|
||||||
|
|||||||
Reference in new issue
Block a user