proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
jeequan_jeepay
|
jeepay/jeepay-components/jeepay-components-oss/src/main/java/com/jeequan/jeepay/components/oss/service/AliyunOssService.java
|
AliyunOssService
|
downloadFile
|
class AliyunOssService implements IOssService{
@Autowired private AliyunOssYmlConfig aliyunOssYmlConfig;
// ossClient 初始化
private OSS ossClient = null;
@PostConstruct
public void init(){
ossClient = new OSSClientBuilder().build(aliyunOssYmlConfig.getEndpoint(), aliyunOssYmlConfig.getAccessKeyId(), aliyunOssYmlConfig.getAccessKeySecret());
}
@Override
public String upload2PreviewUrl(OssSavePlaceEnum ossSavePlaceEnum, MultipartFile multipartFile, String saveDirAndFileName) {
try {
this.ossClient.putObject(ossSavePlaceEnum == OssSavePlaceEnum.PUBLIC ? aliyunOssYmlConfig.getPublicBucketName() : aliyunOssYmlConfig.getPrivateBucketName()
, saveDirAndFileName, multipartFile.getInputStream());
if(ossSavePlaceEnum == OssSavePlaceEnum.PUBLIC){
// 文档:https://www.alibabacloud.com/help/zh/doc-detail/39607.htm example: https://BucketName.Endpoint/ObjectName
return "https://" + aliyunOssYmlConfig.getPublicBucketName() + "." + aliyunOssYmlConfig.getEndpoint() + "/" + saveDirAndFileName;
}
return saveDirAndFileName;
} catch (Exception e) {
log.error("error", e);
return null;
}
}
@Override
public boolean downloadFile(OssSavePlaceEnum ossSavePlaceEnum, String source, String target) {<FILL_FUNCTION_BODY>}
}
|
try {
String bucket = ossSavePlaceEnum == OssSavePlaceEnum.PRIVATE ? aliyunOssYmlConfig.getPrivateBucketName() : aliyunOssYmlConfig.getPublicBucketName();
this.ossClient.getObject(new GetObjectRequest(bucket, source), new File(target));
return true;
} catch (Exception e) {
log.error("error", e);
return false;
}
| 453
| 119
| 572
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-components/jeepay-components-oss/src/main/java/com/jeequan/jeepay/components/oss/service/LocalFileService.java
|
LocalFileService
|
upload2PreviewUrl
|
class LocalFileService implements IOssService{
@Autowired private ISysConfigService sysConfigService;
@Autowired private OssYmlConfig ossYmlConfig;
@Override
public String upload2PreviewUrl(OssSavePlaceEnum ossSavePlaceEnum, MultipartFile multipartFile, String saveDirAndFileName) {<FILL_FUNCTION_BODY>}
@Override
public boolean downloadFile(OssSavePlaceEnum ossSavePlaceEnum, String source, String target) {
return false;
}
}
|
try {
String savePath = ossSavePlaceEnum ==
OssSavePlaceEnum.PUBLIC ? ossYmlConfig.getOss().getFilePublicPath() : ossYmlConfig.getOss().getFilePrivatePath();
File saveFile = new File(savePath + File.separator + saveDirAndFileName);
//如果文件夹不存在则创建文件夹
File dir = saveFile.getParentFile();
if(!dir.exists()) {
dir.mkdirs();
}
multipartFile.transferTo(saveFile);
} catch (Exception e) {
log.error("", e);
}
// 私有文件 不返回预览文件地址
if(ossSavePlaceEnum == OssSavePlaceEnum.PRIVATE){
return saveDirAndFileName;
}
return sysConfigService.getDBApplicationConfig().getOssPublicSiteUrl() + "/" + saveDirAndFileName;
| 136
| 243
| 379
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/beans/RequestKitBean.java
|
RequestKitBean
|
getReqParamJSON
|
class RequestKitBean {
@Autowired(required = false)
protected HttpServletRequest request; //自动注入request
/** reqContext对象中的key: 转换好的json对象 */
private static final String REQ_CONTEXT_KEY_PARAMJSON = "REQ_CONTEXT_KEY_PARAMJSON";
/** JSON 格式通过请求主体(BODY)传输 获取参数 **/
public String getReqParamFromBody() {
String body = "";
if(isConvertJSON()){
try {
String str;
while((str = request.getReader().readLine()) != null){
body += str;
}
return body;
} catch (Exception e) {
log.error("请求参数转换异常! params=[{}]", body);
throw new BizException(ApiCodeEnum.PARAMS_ERROR, "转换异常");
}
}else {
return body;
}
}
/**request.getParameter 获取参数 并转换为JSON格式 **/
public JSONObject reqParam2JSON() {
JSONObject returnObject = new JSONObject();
if(isConvertJSON()){
String body = "";
try {
body=request.getReader().lines().collect(Collectors.joining(""));
if(StringUtils.isEmpty(body)) {
return returnObject;
}
return JSONObject.parseObject(body);
} catch (Exception e) {
log.error("请求参数转换异常! params=[{}]", body);
throw new BizException(ApiCodeEnum.PARAMS_ERROR, "转换异常");
}
}
// 参数Map
Map properties = request.getParameterMap();
// 返回值Map
Iterator entries = properties.entrySet().iterator();
Map.Entry entry;
String name;
String value = "";
while (entries.hasNext()) {
entry = (Map.Entry) entries.next();
name = (String) entry.getKey();
Object valueObj = entry.getValue();
if(null == valueObj){
value = "";
}else if(valueObj instanceof String[]){
String[] values = (String[])valueObj;
for(int i=0;i<values.length;i++){
value = values[i] + ",";
}
value = value.substring(0, value.length()-1);
}else{
value = valueObj.toString();
}
if(!name.contains("[")){
returnObject.put(name, value);
continue;
}
//添加对json对象解析的支持 example: {ps[abc] : 1}
String mainKey = name.substring(0, name.indexOf("["));
String subKey = name.substring(name.indexOf("[") + 1 , name.indexOf("]"));
JSONObject subJson = new JSONObject();
if(returnObject.get(mainKey) != null) {
subJson = (JSONObject)returnObject.get(mainKey);
}
subJson.put(subKey, value);
returnObject.put(mainKey, subJson);
}
return returnObject;
}
/** 获取json格式的请求参数 **/
public JSONObject getReqParamJSON(){<FILL_FUNCTION_BODY>}
/** 判断请求参数是否转换为json格式 */
private boolean isConvertJSON(){
String contentType = request.getContentType();
//有contentType && json格式, get请求不转换
if(contentType != null
&& contentType.toLowerCase().indexOf("application/json") >= 0
&& !request.getMethod().equalsIgnoreCase("GET")
){ //application/json 需要转换为json格式;
return true;
}
return false;
}
/** 获取客户端ip地址 **/
public String getClientIp() {
String ipAddress = null;
ipAddress = request.getHeader("x-forwarded-for");
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("WL-Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr();
}
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if (ipAddress != null && ipAddress.length() > 15) {
if (ipAddress.indexOf(",") > 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
}
}
return ipAddress;
}
}
|
//将转换好的reqParam JSON格式的对象保存在当前请求上下文对象中进行保存;
// 注意1: springMVC的CTRL默认单例模式, 不可使用局部变量保存,会出现线程安全问题;
// 注意2: springMVC的请求模式为线程池,如果采用ThreadLocal保存对象信息,可能会出现不清空或者被覆盖的问题。
Object reqParamObject = RequestContextHolder.getRequestAttributes().getAttribute(REQ_CONTEXT_KEY_PARAMJSON, RequestAttributes.SCOPE_REQUEST);
if(reqParamObject == null){
JSONObject reqParam = reqParam2JSON();
RequestContextHolder.getRequestAttributes().setAttribute(REQ_CONTEXT_KEY_PARAMJSON, reqParam, RequestAttributes.SCOPE_REQUEST);
return reqParam;
}
return (JSONObject) reqParamObject;
| 1,269
| 220
| 1,489
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/cache/ITokenService.java
|
ITokenService
|
refData
|
class ITokenService {
/** 处理token信息
* 1. 如果不允许多用户则踢掉之前的所有用户信息
* 2. 更新token 缓存时间信息
* 3. 更新用户token列表
* **/
public static void processTokenCache(JeeUserDetails userDetail, String cacheKey){
userDetail.setCacheKey(cacheKey); //设置cacheKey
//当前用户的所有登录token 集合
// if(!PropKit.isAllowMultiUser()){ //不允许多用户登录
//
// List<String> allTokenList = new ArrayList<>();
// for (String token : allTokenList) {
// if(!cacheKey.equalsIgnoreCase(token)){
// RedisUtil.del(token);
// }
// }
// }
//保存token
RedisUtil.set(cacheKey, userDetail, CS.TOKEN_TIME); //缓存时间2小时, 保存具体信息而只是uid, 因为很多场景需要得到信息, 例如验证接口权限, 每次请求都需要获取。 将信息封装在一起减少磁盘请求次数, 如果放置多个key会增加非顺序读取。
}
/** 退出时,清除token信息 */
public static void removeIToken(String iToken, Long currentUID){
//1. 清除token的信息
RedisUtil.del(iToken);
}
/**
* 刷新数据
* **/
public static void refData(JeeUserDetails currentUserInfo){<FILL_FUNCTION_BODY>}
}
|
//保存token 和 tokenList信息
RedisUtil.set(currentUserInfo.getCacheKey(), currentUserInfo, CS.TOKEN_TIME); //缓存时间2小时, 保存具体信息而只是uid, 因为很多场景需要得到信息, 例如验证接口权限, 每次请求都需要获取。 将信息封装在一起减少磁盘请求次数, 如果放置多个key会增加非顺序读取。
| 411
| 112
| 523
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/cache/RedisUtil.java
|
RedisUtil
|
del
|
class RedisUtil {
private static StringRedisTemplate stringRedisTemplate = null;
/** 获取RedisTemplate对象, 默认使用 StringRedisTemplate, 客户端可查询 **/
private static final RedisTemplate getStringRedisTemplate(){
if(stringRedisTemplate == null){
if(SpringBeansUtil.getApplicationContext().containsBean("defaultStringRedisTemplate")){
stringRedisTemplate = SpringBeansUtil.getBean("defaultStringRedisTemplate", StringRedisTemplate.class);
}else{
stringRedisTemplate = SpringBeansUtil.getBean(StringRedisTemplate.class);
}
}
return stringRedisTemplate;
}
/** 获取缓存数据, String类型 */
public static String getString(String key) {
if(key == null) {
return null;
}
return (String)getStringRedisTemplate().opsForValue().get(key);
}
/** 获取缓存数据对象 */
public static <T> T getObject(String key, Class<T> cls) {
String val = getString(key);
return JSON.parseObject(val, cls);
}
/** 放置缓存对象 */
public static void setString(String key, String value) {
getStringRedisTemplate().opsForValue().set(key, value);
}
/** 普通缓存放入并设置时间, 默认单位:秒 */
public static void setString(String key, String value, long time) {
getStringRedisTemplate().opsForValue().set(key, value, time, TimeUnit.SECONDS);
}
/** 普通缓存放入并设置时间 */
public static void setString(String key, String value, long time, TimeUnit timeUnit) {
getStringRedisTemplate().opsForValue().set(key, value, time, timeUnit);
}
/** 放置缓存对象 */
public static void set(String key, Object value) {
setString(key, JSON.toJSONString(value));
}
/** 普通缓存放入并设置时间, 默认单位:秒 */
public static void set(String key, Object value, long time) {
setString(key, JSON.toJSONString(value), time);
}
/** 普通缓存放入并设置时间 */
public static void set(String key, Object value, long time, TimeUnit timeUnit) {
setString(key, JSON.toJSONString(value), time, timeUnit);
}
/** 指定缓存失效时间 */
public static void expire(String key, long time) {
getStringRedisTemplate().expire(key, time, TimeUnit.SECONDS);
}
/** 指定缓存失效时间 */
public static void expire(String key, long time, TimeUnit timeUnit) {
getStringRedisTemplate().expire(key, time, timeUnit);
}
/**
* 根据key 获取过期时间
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public static long getExpire(String key) {
return getStringRedisTemplate().getExpire(key, TimeUnit.SECONDS);
}
/** 判断key是否存在 */
public static boolean hasKey(String key) {
return getStringRedisTemplate().hasKey(key);
}
/** 删除缓存 **/
public static void del(String... key) {<FILL_FUNCTION_BODY>}
/** 查询keys */
public static Collection<String> keys(String pattern) {
return getStringRedisTemplate().keys(pattern);
}
}
|
if (key != null && key.length > 0) {
if (key.length == 1) {
getStringRedisTemplate().delete(key[0]);
} else {
getStringRedisTemplate().delete(CollectionUtils.arrayToList(key));
}
}
| 945
| 74
| 1,019
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/exception/BizExceptionResolver.java
|
BizExceptionResolver
|
resolveException
|
class BizExceptionResolver implements HandlerExceptionResolver {
private Logger logger = LogManager.getLogger(BizExceptionResolver.class);
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) {<FILL_FUNCTION_BODY>}
public void outPutJson(HttpServletResponse res, String jsonStr) throws IOException {
res.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
res.getWriter().write(jsonStr);
res.getWriter().flush();
res.getWriter().close();
}
}
|
// 是否包含ss框架
boolean hasSpringSecurity = false;
try {
hasSpringSecurity = Class.forName("org.springframework.security.access.AccessDeniedException") != null;
} catch (Exception e) {
}
String outPutJson;
//业务异常
if(ex instanceof BizException) {
logger.error("公共捕捉[Biz]异常:{}",ex.getMessage());
outPutJson = ((BizException) ex).getApiRes().toJSONString();
}else if(ex instanceof DataAccessException){
logger.error("公共捕捉[DataAccessException]异常:",ex);
outPutJson = ApiRes.fail(ApiCodeEnum.DB_ERROR).toJSONString();
}else if(hasSpringSecurity && ex instanceof org.springframework.security.access.AccessDeniedException) {
logger.error("公共捕捉[AccessDeniedException]异常:", ex);
outPutJson = ApiRes.fail(ApiCodeEnum.SYS_PERMISSION_ERROR, ex.getMessage()).toJSONString();
}else{
logger.error("公共捕捉[Exception]异常:",ex);
outPutJson = ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, ex.getMessage()).toJSONString();
}
try {
this.outPutJson(response, outPutJson);
} catch (IOException e) {
logger.error("输出错误信息异常:", e);
}
return new ModelAndView();
| 158
| 404
| 562
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/exception/ResponseException.java
|
ResponseException
|
buildText
|
class ResponseException extends RuntimeException{
private static final long serialVersionUID = 1L;
private ResponseEntity responseEntity;
/** 业务自定义异常 **/
public ResponseException(ResponseEntity resp) {
super();
this.responseEntity = resp;
}
/** 生成文本类型的响应 **/
public static ResponseException buildText(String text){<FILL_FUNCTION_BODY>}
}
|
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_HTML);
ResponseEntity entity = new ResponseEntity(text, httpHeaders, HttpStatus.OK);
return new ResponseException(entity);
| 106
| 63
| 169
|
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/jwt/JWTUtils.java
|
JWTUtils
|
parseToken
|
class JWTUtils {
/** 生成token **/
public static String generateToken(JWTPayload jwtPayload, String jwtSecret) {
return Jwts.builder()
.setClaims(jwtPayload.toMap())
//过期时间 = 当前时间 + (设置过期时间[单位 :s ] ) token放置redis 过期时间无意义
//.setExpiration(new Date(System.currentTimeMillis() + (jwtExpiration * 1000) ))
.signWith(SignatureAlgorithm.HS512, jwtSecret)
.compact();
}
/** 根据token与秘钥 解析token并转换为 JWTPayload **/
public static JWTPayload parseToken(String token, String secret){<FILL_FUNCTION_BODY>}
}
|
try {
Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
JWTPayload result = new JWTPayload();
result.setSysUserId(claims.get("sysUserId", Long.class));
result.setCreated(claims.get("created", Long.class));
result.setCacheKey(claims.get("cacheKey", String.class));
return result;
} catch (Exception e) {
return null; //解析失败
}
| 225
| 143
| 368
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/ApiPageRes.java
|
ApiPageRes
|
pages
|
class ApiPageRes<M> extends ApiRes {
/** 数据对象 **/
@ApiModelProperty(value = "业务数据")
private PageBean<M> data;
/** 业务处理成功, 封装分页数据, 仅返回必要参数 **/
public static <M> ApiPageRes<M> pages(IPage<M> iPage){<FILL_FUNCTION_BODY>}
@Data
@ApiModel
public static class PageBean<M> {
/** 数据列表 */
@ApiModelProperty(value = "数据列表")
private List<M> records;
/** 总数量 */
@ApiModelProperty(value = "总数量")
private Long total;
/** 当前页码 */
@ApiModelProperty(value = "当前页码")
private Long current;
/** 是否包含下一页, true:包含 ,false: 不包含 */
@ApiModelProperty(value = "是否包含下一页, true:包含 ,false: 不包含")
private boolean hasNext;
}
}
|
PageBean<M> innerPage = new PageBean<>();
innerPage.setRecords(iPage.getRecords()); //记录明细
innerPage.setTotal(iPage.getTotal()); //总条数
innerPage.setCurrent(iPage.getCurrent()); //当前页码
innerPage.setHasNext( iPage.getPages() > iPage.getCurrent()); //是否有下一页
ApiPageRes result = new ApiPageRes();
result.setData(innerPage);
result.setCode(ApiCodeEnum.SUCCESS.getCode());
result.setMsg(ApiCodeEnum.SUCCESS.getMsg());
return result;
| 280
| 171
| 451
|
<methods>public non-sealed void <init>() ,public static ApiRes#RAW customFail(java.lang.String) ,public static transient ApiRes#RAW fail(com.jeequan.jeepay.core.constants.ApiCodeEnum, java.lang.String[]) ,public static ApiRes#RAW ok() ,public static ApiRes<T> ok(T) ,public static ApiRes#RAW ok4newJson(java.lang.String, java.lang.Object) ,public static ApiRes#RAW okWithSign(java.lang.Object, java.lang.String) ,public static ApiRes<PageBean<T>> page(IPage<T>) ,public java.lang.String toJSONString() <variables>private java.lang.Integer code,private java.lang.Object data,private java.lang.String msg,private java.lang.String sign
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/ApiRes.java
|
ApiRes
|
fail
|
class ApiRes<T> implements Serializable {
/** 业务响应码 **/
private Integer code;
/** 业务响应信息 **/
private String msg;
/** 数据对象 **/
private T data;
/** 签名值 **/
private String sign;
/** 输出json格式字符串 **/
public String toJSONString(){
return JSON.toJSONString(this);
}
/** 业务处理成功 **/
public static ApiRes ok(){
return ok(null);
}
/** 业务处理成功 **/
public static <T> ApiRes<T> ok(T data){
return new ApiRes(ApiCodeEnum.SUCCESS.getCode(), ApiCodeEnum.SUCCESS.getMsg(), data, null);
}
/** 业务处理成功, 自动签名 **/
public static ApiRes okWithSign(Object data, String mchKey){
if(data == null){
return new ApiRes(ApiCodeEnum.SUCCESS.getCode(), ApiCodeEnum.SUCCESS.getMsg(), null, null);
}
JSONObject jsonObject = (JSONObject)JSONObject.toJSON(data);
String sign = JeepayKit.getSign(jsonObject, mchKey);
return new ApiRes(ApiCodeEnum.SUCCESS.getCode(), ApiCodeEnum.SUCCESS.getMsg(), data, sign);
}
/** 业务处理成功, 返回简单json格式 **/
public static ApiRes ok4newJson(String key, Object val){
return ok(JsonKit.newJson(key, val));
}
/** 业务处理成功, 封装分页数据, 仅返回必要参数 **/
public static <T> ApiRes<ApiPageRes.PageBean<T>> page(IPage<T> iPage){
ApiPageRes.PageBean<T> result = new ApiPageRes.PageBean<>();
result.setRecords(iPage.getRecords()); //记录明细
result.setTotal(iPage.getTotal()); //总条数
result.setCurrent(iPage.getCurrent()); //当前页码
result.setHasNext( iPage.getPages() > iPage.getCurrent()); //是否有下一页
return ok(result);
}
/** 业务处理失败 **/
public static ApiRes fail(ApiCodeEnum apiCodeEnum, String... params){<FILL_FUNCTION_BODY>}
/** 自定义错误信息, 原封不用的返回输入的错误信息 **/
public static ApiRes customFail(String customMsg){
return new ApiRes(ApiCodeEnum.CUSTOM_FAIL.getCode(), customMsg, null, null);
}
}
|
if(params == null || params.length <= 0){
return new ApiRes(apiCodeEnum.getCode(), apiCodeEnum.getMsg(), null, null);
}
return new ApiRes(apiCodeEnum.getCode(), String.format(apiCodeEnum.getMsg(), params), null, null);
| 707
| 79
| 786
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/BaseModel.java
|
BaseModel
|
addExt
|
class BaseModel<T> implements Serializable{
private static final long serialVersionUID = 1L;
/** ext参数, 用作扩展参数, 会在转换为api数据时自动将ext全部属性放置在对象的主属性上, 并且不包含ext属性 **/
/** api接口扩展字段, 当包含该字段时 将自动填充到实体对象属性中如{id:1, ext:{abc:222}} 则自动转换为: {id:1, abc:222},
* 需配合ResponseBodyAdvice使用
* **/
@TableField(exist = false)
private JSONObject ext;
//获取的时候设置默认值
public JSONObject getExt() {
return ext;
}
//设置扩展字段
public BaseModel addExt(String key, Object val) {<FILL_FUNCTION_BODY>}
/** get ext value 可直接使用JSONObject对象的函数 **/
public JSONObject extv() {
return ext == null ? new JSONObject() : ext;
}
}
|
if(ext == null) {
ext = new JSONObject();
}
ext.put(key,val);
return this;
| 275
| 40
| 315
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/DBApplicationConfig.java
|
DBApplicationConfig
|
genAlipayIsvsubMchAuthUrl
|
class DBApplicationConfig implements Serializable {
/** 运营系统地址 **/
private String mgrSiteUrl;
/** 商户系统地址 **/
private String mchSiteUrl;
/** 支付网关地址 **/
private String paySiteUrl;
/** oss公共读文件地址 **/
private String ossPublicSiteUrl;
/** 生成 【jsapi统一收银台跳转地址】 **/
public String genUniJsapiPayUrl(String payOrderId){
return getPaySiteUrl() + "/cashier/index.html#/hub/" + JeepayKit.aesEncode(payOrderId);
}
/** 生成 【jsapi统一收银台】oauth2获取用户ID回调地址 **/
public String genOauth2RedirectUrlEncode(String payOrderId){
return URLUtil.encodeAll(getPaySiteUrl() + "/cashier/index.html#/oauth2Callback/" + JeepayKit.aesEncode(payOrderId));
}
/** 生成 【商户获取渠道用户ID接口】oauth2获取用户ID回调地址 **/
public String genMchChannelUserIdApiOauth2RedirectUrlEncode(JSONObject param){
return URLUtil.encodeAll(getPaySiteUrl() + "/api/channelUserId/oauth2Callback/" + JeepayKit.aesEncode(param.toJSONString()));
}
/** 生成 【jsapi统一收银台二维码图片地址】 **/
public String genScanImgUrl(String url){
return getPaySiteUrl() + "/api/scan/imgs/" + JeepayKit.aesEncode(url) + ".png";
}
/** 生成 【支付宝 isv子商户的授权链接地址】 **/
public String genAlipayIsvsubMchAuthUrl(String isvNo, String mchAppId){<FILL_FUNCTION_BODY>}
}
|
return getPaySiteUrl() + "/api/channelbiz/alipay/redirectAppToAppAuth/" + isvNo + "_" + mchAppId;
| 507
| 43
| 550
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/IsvParams.java
|
IsvParams
|
factory
|
class IsvParams {
public static IsvParams factory(String ifCode, String paramsStr){<FILL_FUNCTION_BODY>}
/**
* 敏感数据脱敏
*/
public abstract String deSenData();
}
|
try {
return (IsvParams)JSONObject.parseObject(paramsStr, Class.forName(IsvParams.class.getPackage().getName() +"."+ ifCode +"."+ StrUtil.upperFirst(ifCode) +"IsvParams"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
| 65
| 93
| 158
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/IsvsubMchParams.java
|
IsvsubMchParams
|
factory
|
class IsvsubMchParams {
public static IsvsubMchParams factory(String ifCode, String paramsStr){<FILL_FUNCTION_BODY>}
}
|
try {
return (IsvsubMchParams)JSONObject.parseObject(paramsStr, Class.forName(IsvsubMchParams.class.getPackage().getName() +"."+ ifCode +"."+ StrUtil.upperFirst(ifCode) +"IsvsubMchParams"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
| 45
| 102
| 147
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/NormalMchParams.java
|
NormalMchParams
|
factory
|
class NormalMchParams {
public static NormalMchParams factory(String ifCode, String paramsStr) {<FILL_FUNCTION_BODY>}
/**
* 敏感数据脱敏
*/
public abstract String deSenData();
}
|
try {
return (NormalMchParams)JSONObject.parseObject(paramsStr, Class.forName(NormalMchParams.class.getPackage().getName() +"."+ ifCode +"."+ StrUtil.upperFirst(ifCode) +"NormalMchParams"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
| 68
| 96
| 164
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/alipay/AlipayIsvParams.java
|
AlipayIsvParams
|
deSenData
|
class AlipayIsvParams extends IsvParams {
/** 是否沙箱环境 */
private Byte sandbox;
/** pid */
private String pid;
/** appId */
private String appId;
/** privateKey */
private String privateKey;
/** alipayPublicKey */
private String alipayPublicKey;
/** 签名方式 **/
private String signType;
/** 是否使用证书方式 **/
private Byte useCert;
/** app 证书 **/
private String appPublicCert;
/** 支付宝公钥证书(.crt格式) **/
private String alipayPublicCert;
/** 支付宝根证书 **/
private String alipayRootCert;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
AlipayIsvParams isvParams = this;
if (StringUtils.isNotBlank(this.privateKey)) {
isvParams.setPrivateKey(StringKit.str2Star(this.privateKey, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.alipayPublicKey)) {
isvParams.setAlipayPublicKey(StringKit.str2Star(this.alipayPublicKey, 6, 6, 6));
}
return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
| 224
| 151
| 375
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.IsvParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/alipay/AlipayNormalMchParams.java
|
AlipayNormalMchParams
|
deSenData
|
class AlipayNormalMchParams extends NormalMchParams {
/** 是否沙箱环境 */
private Byte sandbox;
/** appId */
private String appId;
/** privateKey */
private String privateKey;
/** alipayPublicKey */
private String alipayPublicKey;
/** 签名方式 **/
private String signType;
/** 是否使用证书方式 **/
private Byte useCert;
/** app 证书 **/
private String appPublicCert;
/** 支付宝公钥证书(.crt格式) **/
private String alipayPublicCert;
/** 支付宝根证书 **/
private String alipayRootCert;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
AlipayNormalMchParams mchParams = this;
if (StringUtils.isNotBlank(this.privateKey)) {
mchParams.setPrivateKey(StringKit.str2Star(this.privateKey, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.alipayPublicKey)) {
mchParams.setAlipayPublicKey(StringKit.str2Star(this.alipayPublicKey, 6, 6, 6));
}
return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
| 214
| 152
| 366
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.NormalMchParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/plspay/PlspayNormalMchParams.java
|
PlspayNormalMchParams
|
deSenData
|
class PlspayNormalMchParams extends NormalMchParams {
/** 商户号 */
private String merchantNo;
/** 应用ID */
private String appId;
/** 签名方式 **/
private String signType;
/** md5秘钥 */
private String appSecret;
/** RSA2: 应用私钥 */
private String rsa2AppPrivateKey;
/** RSA2: 支付网关公钥 */
public String rsa2PayPublicKey;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
PlspayNormalMchParams mchParams = this;
if (StringUtils.isNotBlank(this.appSecret)) {
mchParams.setAppSecret(StringKit.str2Star(this.appSecret, 4, 4, 6));
}
return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
| 162
| 91
| 253
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.NormalMchParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/pppay/PppayNormalMchParams.java
|
PppayNormalMchParams
|
deSenData
|
class PppayNormalMchParams extends NormalMchParams {
/**
* 是否沙箱环境
*/
private Byte sandbox;
/**
* clientId
* 客户端 ID
*/
private String clientId;
/**
* secret
* 密钥
*/
private String secret;
/**
* 支付 Webhook 通知 ID
*/
private String notifyWebhook;
/**
* 退款 Webhook 通知 ID
*/
private String refundWebhook;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
PppayNormalMchParams mchParams = this;
if (StringUtils.isNotBlank(this.secret)) {
mchParams.setSecret(StringKit.str2Star(this.secret, 6, 6, 6));
}
return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
| 165
| 87
| 252
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.NormalMchParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/wxpay/WxpayIsvParams.java
|
WxpayIsvParams
|
deSenData
|
class WxpayIsvParams extends IsvParams {
/** 应用App ID */
private String appId;
/** 应用AppSecret */
private String appSecret;
/** 微信支付商户号 */
private String mchId;
/** oauth2地址 */
private String oauth2Url;
/** API密钥 */
private String key;
/** 签名方式 **/
private String signType;
/** 微信支付API版本 **/
private String apiVersion;
/** API V3秘钥 **/
private String apiV3Key;
/** 序列号 **/
private String serialNo;
/** API证书(.p12格式)**/
private String cert;
/** 证书文件(.pem格式) **/
private String apiClientCert;
/** 私钥文件(.pem格式) **/
private String apiClientKey;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
WxpayIsvParams isvParams = this;
if (StringUtils.isNotBlank(this.appSecret)) {
isvParams.setAppSecret(StringKit.str2Star(this.appSecret, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.key)) {
isvParams.setKey(StringKit.str2Star(this.key, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.apiV3Key)) {
isvParams.setApiV3Key(StringKit.str2Star(this.apiV3Key, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.serialNo)) {
isvParams.setSerialNo(StringKit.str2Star(this.serialNo, 4, 4, 6));
}
return ((JSONObject)JSON.toJSON(isvParams)).toJSONString();
| 268
| 249
| 517
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.IsvParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/wxpay/WxpayNormalMchParams.java
|
WxpayNormalMchParams
|
deSenData
|
class WxpayNormalMchParams extends NormalMchParams {
/**
* 应用App ID
*/
private String appId;
/**
* 应用AppSecret
*/
private String appSecret;
/**
* 微信支付商户号
*/
private String mchId;
/**
* oauth2地址
*/
private String oauth2Url;
/**
* API密钥
*/
private String key;
/**
* 微信支付API版本
**/
private String apiVersion;
/**
* API V3秘钥
**/
private String apiV3Key;
/**
* 序列号
**/
private String serialNo;
/**
* API证书(.p12格式)
**/
private String cert;
/** 证书文件(.pem格式) **/
private String apiClientCert;
/**
* 私钥文件(.pem格式)
**/
private String apiClientKey;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
WxpayNormalMchParams mchParams = this;
if (StringUtils.isNotBlank(this.appSecret)) {
mchParams.setAppSecret(StringKit.str2Star(this.appSecret, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.key)) {
mchParams.setKey(StringKit.str2Star(this.key, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.apiV3Key)) {
mchParams.setApiV3Key(StringKit.str2Star(this.apiV3Key, 4, 4, 6));
}
if (StringUtils.isNotBlank(this.serialNo)) {
mchParams.setSerialNo(StringKit.str2Star(this.serialNo, 4, 4, 6));
}
return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
| 303
| 249
| 552
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.NormalMchParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/xxpay/XxpayNormalMchParams.java
|
XxpayNormalMchParams
|
deSenData
|
class XxpayNormalMchParams extends NormalMchParams {
/** 商户号 */
private String mchId;
/** 私钥 */
private String key;
/** 支付网关地址 */
private String payUrl;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
XxpayNormalMchParams mchParams = this;
if (StringUtils.isNotBlank(this.key)) {
mchParams.setKey(StringKit.str2Star(this.key, 4, 4, 6));
}
return ((JSONObject) JSON.toJSON(mchParams)).toJSONString();
| 93
| 87
| 180
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.NormalMchParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/params/ysf/YsfpayIsvParams.java
|
YsfpayIsvParams
|
deSenData
|
class YsfpayIsvParams extends IsvParams {
/** 是否沙箱环境 */
private Byte sandbox;
/** serProvId **/
private String serProvId;
/** isvPrivateCertFile 证书 **/
private String isvPrivateCertFile;
/** isvPrivateCertPwd **/
private String isvPrivateCertPwd;
/** ysfpayPublicKey **/
private String ysfpayPublicKey;
/** acqOrgCodeList 支付机构号 **/
private String acqOrgCode;
@Override
public String deSenData() {<FILL_FUNCTION_BODY>}
}
|
YsfpayIsvParams isvParams = this;
if (StringUtils.isNotBlank(this.isvPrivateCertPwd)) {
isvParams.setIsvPrivateCertPwd(StringKit.str2Star(this.isvPrivateCertPwd, 0, 3, 6));
}
if (StringUtils.isNotBlank(this.ysfpayPublicKey)) {
isvParams.setYsfpayPublicKey(StringKit.str2Star(this.ysfpayPublicKey, 6, 6, 6));
}
return ((JSONObject) JSON.toJSON(isvParams)).toJSONString();
| 169
| 163
| 332
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String deSenData() ,public static com.jeequan.jeepay.core.model.params.IsvParams factory(java.lang.String, java.lang.String) <variables>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/model/security/JeeUserDetails.java
|
JeeUserDetails
|
getCurrentUserDetails
|
class JeeUserDetails implements UserDetails {
/** 系统用户信息 **/
private SysUser sysUser;
/** 密码 **/
private String credential;
/** 角色+权限 集合 (角色必须以: ROLE_ 开头) **/
private Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
/** 缓存标志 **/
private String cacheKey;
/** 登录IP **/
private String loginIp;
//此处的无参构造,为json反序列化提供
public JeeUserDetails() {
}
public JeeUserDetails(SysUser sysUser, String credential) {
this.setSysUser(sysUser);
this.setCredential(credential);
//做一些初始化操作
}
/** spring-security 需要验证的密码 **/
@Override
public String getPassword() {
return getCredential();
}
/** spring-security 登录名 **/
@Override
public String getUsername() {
return getSysUser().getSysUserId() + "";
}
/** 账户是否过期 **/
@Override
public boolean isAccountNonExpired() {
return true;
}
/** 账户是否已解锁 **/
@Override
public boolean isAccountNonLocked() {
return true;
}
/** 密码是否过期 **/
@Override
public boolean isCredentialsNonExpired() {
return true;
}
/** 账户是否开启 **/
@Override
public boolean isEnabled() {
return true;
}
/** 获取权限集合 **/
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
}
public static JeeUserDetails getCurrentUserDetails() {<FILL_FUNCTION_BODY>}
}
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return null;
}
try {
return (JeeUserDetails) authentication.getPrincipal();
}catch (Exception e) {
return null;
}
| 504
| 74
| 578
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/AmountUtil.java
|
AmountUtil
|
convertCent2Dollar
|
class AmountUtil {
/**
* 将字符串"元"转换成"分"
* @param str
* @return
*/
public static String convertDollar2Cent(String str) {
DecimalFormat df = new DecimalFormat("0.00");
StringBuffer sb = df.format(Double.parseDouble(str),
new StringBuffer(), new FieldPosition(0));
int idx = sb.toString().indexOf(".");
sb.deleteCharAt(idx);
for (; sb.length() != 1;) {
if(sb.charAt(0) == '0') {
sb.deleteCharAt(0);
} else {
break;
}
}
return sb.toString();
}
/**
* 将字符串"分"转换成"元"(长格式),如:100分被转换为1.00元。
* @param s
* @return
*/
public static String convertCent2Dollar(String s) {<FILL_FUNCTION_BODY>}
/**
* 将Long "分"转换成"元"(长格式),如:100分被转换为1.00元。
* @param s
* @return
*/
public static String convertCent2Dollar(Long s){
if(s == null) {
return "";
}
return new BigDecimal(s).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
}
/**
* 将字符串"分"转换成"元"(短格式),如:100分被转换为1元。
* @param s
* @return
*/
public static String convertCent2DollarShort(String s) {
String ss = convertCent2Dollar(s);
ss = "" + Double.parseDouble(ss);
if(ss.endsWith(".0")) {
return ss.substring(0, ss.length() - 2);
}
if(ss.endsWith(".00")) {
return ss.substring(0, ss.length() - 3);
} else {
return ss;
}
}
/**
* 计算百分比类型的各种费用值 (订单金额 * 真实费率 结果四舍五入并保留0位小数 )
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/8/20 14:53
* @param amount 订单金额 (保持与数据库的格式一致 ,单位:分)
* @param rate 费率 (保持与数据库的格式一致 ,真实费率值,如费率为0.55%,则传入 0.0055)
*/
public static Long calPercentageFee(Long amount, BigDecimal rate){
return calPercentageFee(amount, rate, BigDecimal.ROUND_HALF_UP);
}
/**
* 计算百分比类型的各种费用值 (订单金额 * 真实费率 结果四舍五入并保留0位小数 )
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/8/20 14:53
* @param amount 订单金额 (保持与数据库的格式一致 ,单位:分)
* @param rate 费率 (保持与数据库的格式一致 ,真实费率值,如费率为0.55%,则传入 0.0055)
* @param mode 模式 参考:BigDecimal.ROUND_HALF_UP(四舍五入) BigDecimal.ROUND_FLOOR(向下取整)
*/
public static Long calPercentageFee(Long amount, BigDecimal rate, int mode){
//费率乘以订单金额 结果四舍五入并保留0位小数
return new BigDecimal(amount).multiply(rate).setScale(0, mode).longValue();
}
}
|
if("".equals(s) || s ==null){
return "";
}
long l;
if(s.length() != 0) {
if(s.charAt(0) == '+') {
s = s.substring(1);
}
l = Long.parseLong(s);
} else {
return "";
}
boolean negative = false;
if(l < 0) {
negative = true;
l = Math.abs(l);
}
s = Long.toString(l);
if(s.length() == 1) {
return(negative ? ("-0.0" + s) : ("0.0" + s));
}
if(s.length() == 2) {
return(negative ? ("-0." + s) : ("0." + s));
} else {
return(negative ? ("-" + s.substring(0, s.length() - 2) + "." + s
.substring(s.length() - 2)) : (s.substring(0,
s.length() - 2)
+ "." + s.substring(s.length() - 2)));
}
| 1,112
| 300
| 1,412
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/ApiResBodyAdviceKit.java
|
ApiResBodyAdviceKit
|
beforeBodyWrite
|
class ApiResBodyAdviceKit {
/** 扩展字段的key名称 **/
private static final String API_EXTEND_FIELD_NAME = "ext";
public static Object beforeBodyWrite(Object body) {<FILL_FUNCTION_BODY>}
/** 处理扩展字段 and 转换为json格式 **/
private static Object procAndConvertJSON(Object object){
Object json = JSON.toJSON(object); //转换为JSON格式
if(json instanceof JSONObject){ //对象类型
processExtFieldByJSONObject((JSONObject) json);
return json;
}
if(json instanceof Collection){ //数组类型
JSONArray result = new JSONArray();
for (Object itemObj : (Collection) json) {
result.add(procAndConvertJSON(itemObj));
}
return result;
}
return json;
}
/** 处理jsonObject格式 **/
private static void processExtFieldByJSONObject(JSONObject jsonObject){
//如果包含字段, 则赋值到外层然后删除该字段
if(jsonObject.containsKey(API_EXTEND_FIELD_NAME)){
JSONObject exFieldMap = jsonObject.getJSONObject(API_EXTEND_FIELD_NAME);
if(exFieldMap != null){ //包含字段
for (String s : exFieldMap.keySet()) { //遍历赋值到外层
jsonObject.put(s, exFieldMap.get(s));
}
}
jsonObject.remove(API_EXTEND_FIELD_NAME); //删除字段
}
//处理所有值
for (String key : jsonObject.keySet()) {
jsonObject.put(key, procAndConvertJSON(jsonObject.get(key)));
}
}
}
|
//空的情况 不处理
if(body == null ) {
return null;
}
if(body instanceof OriginalRes){
return ((OriginalRes) body).getData();
}
// 返回String 避免 StringHttpMessageConverter
if(body instanceof String){
return body;
}
//返回文件流不处理
if(body instanceof InputStreamResource){
return body;
}
//返回二进制文件不处理
if(body instanceof byte[]){
return body;
}
//如果为ApiRes类型则仅处理扩展字段
if(body instanceof ApiRes) {
return procAndConvertJSON(body);
}else{
//ctrl返回其他非[ApiRes]认为处理成功, 先转换为成功状态, 在处理字段
return procAndConvertJSON(ApiRes.ok(body));
}
| 463
| 231
| 694
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/DateKit.java
|
DateKit
|
getQueryDateRange
|
class DateKit {
/** 获取参数时间当天的开始时间 **/
public static Date getBegin(Date date){
if(date == null) {
return null;
}
return DateUtil.beginOfDay(date).toJdkDate();
}
/** 获取参数时间当天的结束时间 **/
public static Date getEnd(Date date){
if(date == null) {
return null;
}
return DateUtil.endOfDay(date).toJdkDate();
}
/**
* 获取自定义查询时间
* today|0 -- 今天
* yesterday|0 -- 昨天
* near2now|7 -- 近xx天, 到今天
* near2yesterday|30 -- 近xx天, 到昨天
* customDate|2020-01-01,N -- 自定义日期格式 N表示为空, 占位使用
* customDateTime|2020-01-01 23:00:00,2020-01-01 23:00:00 -- 自定义日期时间格式
*
* @return
*/
public static Date[] getQueryDateRange(String queryParamVal){<FILL_FUNCTION_BODY>}
/** 公共函数,获取当前时间。 **/
public static Long currentTimeMillis(){
// System.currentTimeMillis(); // fortify 检测属于安全漏洞
return SystemClock.now();
}
}
|
//查询全部
if(StringUtils.isEmpty(queryParamVal)){
return new Date[]{null, null};
}
//根据 | 分割
String[] valArray = queryParamVal.split("\\|");
if(valArray.length != 2){ //参数有误
throw new BizException("查询时间参数有误");
}
String dateType = valArray[0]; //时间类型
String dateVal = valArray[1]; //搜索时间值
Date nowDateTime = new Date(); //当前时间
if("today".equals(dateType)){ //今天
return new Date[]{getBegin(nowDateTime), getEnd(nowDateTime)};
}else if("yesterday".equals(dateType)){ //昨天
Date yesterdayDateTime = DateUtil.offsetDay(nowDateTime, -1).toJdkDate(); //昨天
return new Date[]{getBegin(yesterdayDateTime), getEnd(yesterdayDateTime)};
}else if("near2now".equals(dateType)){ //近xx天, xx天之前 ~ 当前时间
Integer offsetDay = 1 - Integer.parseInt(dateVal); //获取时间偏移量
Date offsetDayDate = DateUtil.offsetDay(nowDateTime, offsetDay).toJdkDate();
return new Date[]{getBegin(offsetDayDate), getEnd(nowDateTime)};
}else if("near2yesterday".equals(dateType)){ //近xx天, xx天之前 ~ 昨天
Date yesterdayDateTime = DateUtil.offsetDay(nowDateTime, -1).toJdkDate(); //昨天
Integer offsetDay = 1 - Integer.parseInt(dateVal); //获取时间偏移量
Date offsetDayDate = DateUtil.offsetDay(yesterdayDateTime, offsetDay).toJdkDate();
return new Date[]{getBegin(offsetDayDate), getEnd(yesterdayDateTime)};
}else if("customDate".equals(dateType) || "customDateTime".equals(dateType)){ //自定义格式
String[] timeArray = dateVal.split(","); //以逗号分割
if(timeArray.length != 2) {
throw new BizException("查询自定义时间参数有误");
}
String timeStr1 = "N".equalsIgnoreCase(timeArray[0]) ? null : timeArray[0] ; //开始时间,
String timeStr2 = "N".equalsIgnoreCase(timeArray[1]) ? null : timeArray[1]; //结束时间, N表示为空, 占位使用
Date time1 = null;
Date time2 = null;
if(StringUtils.isNotEmpty(timeStr1)){
time1 = DateUtil.parseDateTime("customDate".equals(dateType) ? (timeStr1 + " 00:00:00" ) : timeStr1);
}
if(StringUtils.isNotEmpty(timeStr2)){
time2 = DateUtil.parse( ( "customDate".equals(dateType) ? (timeStr2 + " 23:59:59.999" ) : timeStr2 + ".999" ) , DatePattern.NORM_DATETIME_MS_FORMAT);
}
return new Date[]{time1, time2};
}else{
throw new BizException("查询时间参数有误");
}
| 387
| 840
| 1,227
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/FileKit.java
|
FileKit
|
getImgSuffix
|
class FileKit {
/**
* 获取文件的后缀名
* @param appendDot 是否拼接.
* @return
*/
public static String getFileSuffix(String fullFileName, boolean appendDot){
if(fullFileName == null || fullFileName.indexOf(".") < 0 || fullFileName.length() <= 1) {
return "";
}
return (appendDot? "." : "") + fullFileName.substring(fullFileName.lastIndexOf(".") + 1);
}
/** 获取有效的图片格式, 返回null: 不支持的图片类型 **/
public static String getImgSuffix(String filePath){<FILL_FUNCTION_BODY>}
}
|
String suffix = getFileSuffix(filePath, false).toLowerCase();
if(CS.ALLOW_UPLOAD_IMG_SUFFIX.contains(suffix)){
return suffix;
}
throw new BizException("不支持的图片类型");
| 182
| 71
| 253
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/JeepayKit.java
|
JeepayKit
|
md5
|
class JeepayKit {
public static byte[] AES_KEY = "4ChT08phkz59hquD795X7w==".getBytes();
/** 加密 **/
public static String aesEncode(String str){
return SecureUtil.aes(JeepayKit.AES_KEY).encryptHex(str);
}
public static String aesDecode(String str){
return SecureUtil.aes(JeepayKit.AES_KEY).decryptStr(str);
}
private static String encodingCharset = "UTF-8";
/**
* <p><b>Description: </b>计算签名摘要
* <p>2018年9月30日 上午11:32:46
* @param map 参数Map
* @param key 商户秘钥
* @return
*/
public static String getSign(Map<String,Object> map, String key){
ArrayList<String> list = new ArrayList<String>();
for(Map.Entry<String,Object> entry:map.entrySet()){
if(null != entry.getValue() && !"".equals(entry.getValue())){
list.add(entry.getKey() + "=" + entry.getValue() + "&");
}
}
int size = list.size();
String [] arrayToSort = list.toArray(new String[size]);
Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
StringBuilder sb = new StringBuilder();
for(int i = 0; i < size; i ++) {
sb.append(arrayToSort[i]);
}
String result = sb.toString();
result += "key=" + key;
log.info("signStr:{}", result);
result = md5(result, encodingCharset).toUpperCase();
log.info("sign:{}", result);
return result;
}
/**
* <p><b>Description: </b>MD5
* <p>2018年9月30日 上午11:33:19
* @param value
* @param charset
* @return
*/
public static String md5(String value, String charset) {<FILL_FUNCTION_BODY>}
public static String toHex(byte input[]) {
if (input == null) {
return null;
}
StringBuffer output = new StringBuffer(input.length * 2);
for (int i = 0; i < input.length; i++) {
int current = input[i] & 0xff;
if (current < 16) {
output.append("0");
}
output.append(Integer.toString(current, 16));
}
return output.toString();
}
/** map 转换为 url参数 **/
public static String genUrlParams(Map<String, Object> paraMap) {
if(paraMap == null || paraMap.isEmpty()) {
return "";
}
StringBuffer urlParam = new StringBuffer();
Set<String> keySet = paraMap.keySet();
int i = 0;
for(String key:keySet) {
urlParam.append(key).append("=").append( paraMap.get(key) == null ? "" : doEncode(paraMap.get(key).toString()) );
if(++i == keySet.size()) {
break;
}
urlParam.append("&");
}
return urlParam.toString();
}
static String doEncode(String str) {
if(str.contains("+")) {
return URLEncoder.encode(str);
}
return str;
}
/** 校验微信/支付宝二维码是否符合规范, 并根据支付类型返回对应的支付方式 **/
public static String getPayWayCodeByBarCode(String barCode){
if(StringUtils.isEmpty(barCode)) {
throw new BizException("条码为空");
}
//微信 : 用户付款码条形码规则:18位纯数字,以10、11、12、13、14、15开头
//文档: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1
if(barCode.length() == 18 && Pattern.matches("^(10|11|12|13|14|15)(.*)", barCode)){
return CS.PAY_WAY_CODE.WX_BAR;
}
//支付宝: 25~30开头的长度为16~24位的数字
//文档: https://docs.open.alipay.com/api_1/alipay.trade.pay/
else if(barCode.length() >= 16 && barCode.length() <= 24 && Pattern.matches("^(25|26|27|28|29|30)(.*)", barCode)){
return CS.PAY_WAY_CODE.ALI_BAR;
}
//云闪付: 二维码标准: 19位 + 62开头
//文档:https://wenku.baidu.com/view/b2eddcd09a89680203d8ce2f0066f5335a8167fa.html
else if(barCode.length() == 19 && Pattern.matches("^(62)(.*)", barCode)){
return CS.PAY_WAY_CODE.YSF_BAR;
}
else{ //暂时不支持的条码类型
throw new BizException("不支持的条码");
}
}
}
|
MessageDigest md = null;
try {
byte[] data = value.getBytes(charset);
md = MessageDigest.getInstance("MD5");
byte[] digestData = md.digest(data);
return toHex(digestData);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
| 1,496
| 122
| 1,618
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/JsonKit.java
|
JsonKit
|
newJson
|
class JsonKit {
public static JSONObject newJson(String key, Object val){<FILL_FUNCTION_BODY>}
}
|
JSONObject result = new JSONObject();
result.put(key, val);
return result;
| 36
| 31
| 67
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/RegKit.java
|
RegKit
|
match
|
class RegKit {
public static final String REG_MOBILE = "^1\\d{10}$"; //判断是否是手机号
public static final String REG_ALIPAY_USER_ID = "^2088\\d{12}$"; //判断是支付宝用户Id 以2088开头的纯16位数字
public static boolean isMobile(String str){
return match(str, REG_MOBILE);
}
public static boolean isAlipayUserId(String str){
return match(str, REG_ALIPAY_USER_ID);
}
/** 正则验证 */
public static boolean match(String text, String reg){<FILL_FUNCTION_BODY>}
}
|
if(text == null) {
return false;
}
return text.matches(reg);
| 186
| 30
| 216
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/SeqKit.java
|
SeqKit
|
genDivisionBatchId
|
class SeqKit {
private static final AtomicLong PAY_ORDER_SEQ = new AtomicLong(0L);
private static final AtomicLong REFUND_ORDER_SEQ = new AtomicLong(0L);
private static final AtomicLong MHO_ORDER_SEQ = new AtomicLong(0L);
private static final AtomicLong TRANSFER_ID_SEQ = new AtomicLong(0L);
private static final AtomicLong DIVISION_BATCH_ID_SEQ = new AtomicLong(0L);
private static final String PAY_ORDER_SEQ_PREFIX = "P";
private static final String REFUND_ORDER_SEQ_PREFIX = "R";
private static final String MHO_ORDER_SEQ_PREFIX = "M";
private static final String TRANSFER_ID_SEQ_PREFIX = "T";
private static final String DIVISION_BATCH_ID_SEQ_PREFIX = "D";
/** 是否使用MybatisPlus生成分布式ID **/
private static final boolean IS_USE_MP_ID = true;
/** 生成支付订单号 **/
public static String genPayOrderId() {
if(IS_USE_MP_ID) {
return PAY_ORDER_SEQ_PREFIX + IdWorker.getIdStr();
}
return String.format("%s%s%04d",PAY_ORDER_SEQ_PREFIX,
DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN),
(int) PAY_ORDER_SEQ.getAndIncrement() % 10000);
}
/** 生成退款订单号 **/
public static String genRefundOrderId() {
if(IS_USE_MP_ID) {
return REFUND_ORDER_SEQ_PREFIX + IdWorker.getIdStr();
}
return String.format("%s%s%04d",REFUND_ORDER_SEQ_PREFIX,
DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN),
(int) REFUND_ORDER_SEQ.getAndIncrement() % 10000);
}
/** 模拟生成商户订单号 **/
public static String genMhoOrderId() {
if(IS_USE_MP_ID) {
return MHO_ORDER_SEQ_PREFIX + IdWorker.getIdStr();
}
return String.format("%s%s%04d", MHO_ORDER_SEQ_PREFIX,
DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN),
(int) MHO_ORDER_SEQ.getAndIncrement() % 10000);
}
/** 模拟生成商户订单号 **/
public static String genTransferId() {
if(IS_USE_MP_ID) {
return TRANSFER_ID_SEQ_PREFIX + IdWorker.getIdStr();
}
return String.format("%s%s%04d", TRANSFER_ID_SEQ_PREFIX,
DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN),
(int) TRANSFER_ID_SEQ.getAndIncrement() % 10000);
}
/** 模拟生成分账批次号 **/
public static String genDivisionBatchId() {<FILL_FUNCTION_BODY>}
public static void main(String[] args) throws Exception {
System.out.println(genTransferId());
System.out.println(genRefundOrderId());
Thread.sleep(1000);
System.out.println(genMhoOrderId());
System.out.println(genTransferId());
Thread.sleep(1000);
System.out.println(genDivisionBatchId());
}
}
|
if(IS_USE_MP_ID) {
return DIVISION_BATCH_ID_SEQ_PREFIX + IdWorker.getIdStr();
}
return String.format("%s%s%04d", DIVISION_BATCH_ID_SEQ_PREFIX,
DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN),
(int) DIVISION_BATCH_ID_SEQ.getAndIncrement() % 10000);
| 1,000
| 136
| 1,136
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/SpringBeansUtil.java
|
SpringBeansUtil
|
getBean
|
class SpringBeansUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext = null;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if(SpringBeansUtil.applicationContext == null){
SpringBeansUtil.applicationContext = applicationContext;
}
}
/** 获取applicationContext */
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/** 通过name获取 Bean. */
public static Object getBean(String name){
if(!getApplicationContext().containsBean(name)){
return null;
}
return getApplicationContext().getBean(name);
}
/** 通过class获取Bean. */
public static <T> T getBean(Class<T> clazz){<FILL_FUNCTION_BODY>}
/** 通过name,以及Clazz返回指定的Bean */
public static <T> T getBean(String name, Class<T> clazz){
if(!getApplicationContext().containsBean(name)){
return null;
}
return getApplicationContext().getBean(name, clazz);
}
}
|
try {
return getApplicationContext().getBean(clazz);
} catch (BeansException e) {
return null;
}
| 293
| 39
| 332
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/StringKit.java
|
StringKit
|
autoDesensitization
|
class StringKit {
public static String getUUID(){
return UUID.randomUUID().toString().replace("-", "") + Thread.currentThread().getId();
}
public static String getUUID(int endAt){
return getUUID().substring(0, endAt);
}
/** 拼接url参数 **/
public static String appendUrlQuery(String url, Map<String, Object> map){
if(StringUtils.isEmpty(url) || map == null || map.isEmpty()){
return url;
}
StringBuilder sb = new StringBuilder(url);
if(url.indexOf("?") < 0){
sb.append("?");
}
//是否包含query条件
boolean isHasCondition = url.indexOf("=") >= 0;
for (String k : map.keySet()) {
if(k != null && map.get(k) != null){
if(isHasCondition){
sb.append("&"); //包含了查询条件, 那么应当拼接&符号
}else{
isHasCondition = true; //变更为: 已存在query条件
}
sb.append(k).append("=").append(URLUtil.encodeQuery(map.get(k).toString()));
}
}
return sb.toString();
}
/** 拼接url参数: 旧版采用Hutool方式(当回调地址是 http://abc.com/#/abc 时存在位置问题) **/
@Deprecated
public static String appendUrlQueryWithHutool(String url, Map<String, Object> map){
if(StringUtils.isEmpty(url) || map == null || map.isEmpty()){
return url;
}
UrlBuilder result = UrlBuilder.of(url);
map.forEach((k, v) -> {
if(k != null && v != null){
result.addQuery(k, v.toString());
}
});
return result.build();
}
/** 是否 http 或 https连接 **/
public static boolean isAvailableUrl(String url){
if(StringUtils.isEmpty(url)){
return false;
}
return url.startsWith("http://") ||url.startsWith("https://");
}
/**
* 对字符加星号处理:除前面几位和后面几位外,其他的字符以星号代替
*
* @param content 传入的字符串
* @param frontNum 保留前面字符的位数
* @param endNum 保留后面字符的位数
* @return 带星号的字符串
*/
public static String str2Star2(String content, int frontNum, int endNum) {
if (frontNum >= content.length() || frontNum < 0) {
return content;
}
if (endNum >= content.length() || endNum < 0) {
return content;
}
if (frontNum + endNum >= content.length()) {
return content;
}
String starStr = "";
for (int i = 0; i < (content.length() - frontNum - endNum); i++) {
starStr = starStr + "*";
}
return content.substring(0, frontNum) + starStr
+ content.substring(content.length() - endNum, content.length());
}
/**
* 对字符加星号处理:除前面几位和后面几位外,其他的字符以星号代替
*
* @param content 传入的字符串
* @param frontNum 保留前面字符的位数
* @param endNum 保留后面字符的位数
* @param starNum 指定star的数量
* @return 带星号的字符串
*/
public static String str2Star(String content, int frontNum, int endNum, int starNum) {
if (frontNum >= content.length() || frontNum < 0) {
return content;
}
if (endNum >= content.length() || endNum < 0) {
return content;
}
if (frontNum + endNum >= content.length()) {
return content;
}
String starStr = "";
for (int i = 0; i < starNum; i++) {
starStr = starStr + "*";
}
return content.substring(0, frontNum) + starStr
+ content.substring(content.length() - endNum, content.length());
}
/**
* 合并两个json字符串
* key相同,则后者覆盖前者的值
* key不同,则合并至前者
* @param originStr
* @param mergeStr
* @return 合并后的json字符串
*/
public static String marge(String originStr, String mergeStr) {
if (StringUtils.isAnyBlank(originStr, mergeStr)) {
return null;
}
JSONObject originJSON = JSONObject.parseObject(originStr);
JSONObject mergeJSON = JSONObject.parseObject(mergeStr);
if (originJSON == null || mergeJSON == null) {
return null;
}
originJSON.putAll(mergeJSON);
return originJSON.toJSONString();
}
/*
* 功能描述: 数据自动脱敏
* @param str
* @Return: java.lang.String
* @Author: terrfly
* @Date: 2021/7/20 17:07
*/
public static String autoDesensitization(String str){<FILL_FUNCTION_BODY>}
}
|
if(StringUtils.isEmpty(str)){
return str;
}
int len = str.length();
if(len == 1) return "*"; // 1位
if(len <= 3) return StringUtils.repeat("*", len - 1) + str.substring(len - 1); //小于等于三位 格式为: **A
// 公式: 脱敏数据占据2/3 的范围。
// 假设: 采用6的倍数组进行循环(最少两组) 循环次数为:n, 原始位数为 x, 加密数据为原始数据的两倍即 2x ,
// 即: 6x·n = len, 缩小范围使得x=n,即: 7X=len
int x = (len >= 7 && len % 7 == 0 ) ? len / 7 : len / 7 + 1;
int startIndex = 0; //截取原始字符串的位置
String result = ""; //最终结果
while(startIndex < len){
for(int i = 1; i <= 3; i++){ // 三个一组
if(startIndex + x > len){ // 最后一组
int y = len - startIndex;
result += i == 1 ? str.substring(startIndex, startIndex + y) : StringUtils.repeat("*", y);
startIndex = startIndex + y;
break;
}
// 只有第一组是原始数据 ,其他全部为*代替
result += i == 1 ? str.substring(startIndex, startIndex + x) : StringUtils.repeat("*", x);
startIndex = startIndex + x;
}
}
return result;
| 1,426
| 451
| 1,877
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/TreeDataBuilder.java
|
TreeDataBuilder
|
buildTreeString
|
class TreeDataBuilder {
/** 私有构造器 + 指定参数构造器 **/
private TreeDataBuilder(){}
public TreeDataBuilder(Collection nodes) {
super();
this.nodes = nodes;
}
public TreeDataBuilder(Collection nodes, String idName, String pidName, String childrenName) {
super();
this.nodes = nodes;
this.idName = idName;
this.sortName = idName; //排序字段,按照idName
this.pidName = pidName;
this.childrenName = childrenName;
}
/** 自定义字段 + 排序标志 **/
public TreeDataBuilder(Collection nodes, String idName, String pidName, String childrenName, String sortName, boolean isAscSort) {
super();
this.nodes = nodes;
this.idName = idName;
this.pidName = pidName;
this.childrenName = childrenName;
this.sortName = sortName;
this.isAscSort = isAscSort;
}
/** 所有数据集合 **/
private Collection<JSONObject> nodes;
/** 默认数据中的主键key */
private String idName = "id";
/** 默认数据中的父级id的key */
private String pidName = "pid";
/** 默认数据中的子类对象key */
private String childrenName = "children";
/** 排序字段, 默认按照ID排序 **/
private String sortName = idName;
/** 默认按照升序排序 **/
private boolean isAscSort = true;
// 构建JSON树形结构
public String buildTreeString() {<FILL_FUNCTION_BODY>}
// 构建树形结构
public List<JSONObject> buildTreeObject() {
//定义待返回的对象
List<JSONObject> resultNodes = new ArrayList<>();
//获取所有的根节点 (考虑根节点有多个的情况, 将根节点单独处理)
List<JSONObject> rootNodes = getRootNodes();
listSort(rootNodes); //排序
//遍历根节点对象
for (JSONObject rootNode : rootNodes) {
buildChildNodes(rootNode); //递归查找子节点并设置
resultNodes.add(rootNode); //添加到对象信息
}
return resultNodes;
}
/** 递归查找并赋值子节点 **/
private void buildChildNodes(JSONObject node) {
List<JSONObject> children = getChildNodes(node);
if (!children.isEmpty()) {
for (JSONObject child : children) {
buildChildNodes(child);
}
listSort(children); //排序
node.put(childrenName, children);
}
}
/** 查找当前节点的子节点 */
private List<JSONObject> getChildNodes(JSONObject currentNode) {
List<JSONObject> childNodes = new ArrayList<>();
for (JSONObject n : nodes) {
if (currentNode.getString(idName).equals(n.getString(pidName))) {
childNodes.add(n);
}
}
return childNodes;
}
/** 判断是否为根节点 */
private boolean isRootNode(JSONObject node) {
boolean isRootNode = true;
for (JSONObject n : nodes) {
if (node.getString(pidName) != null && node.getString(pidName).equals(n.getString(idName))) {
isRootNode = false;
break;
}
}
return isRootNode;
}
/** 获取集合中所有的根节点 */
private List<JSONObject> getRootNodes() {
List<JSONObject> rootNodes = new ArrayList<>();
for (JSONObject n : nodes) {
if (isRootNode(n)) {
rootNodes.add(n);
}
}
return rootNodes;
}
/** 将list进行排序 */
private void listSort(List<JSONObject> list){
Collections.sort(list, (o1, o2) -> {
int result;
if(o1.get(sortName) instanceof Integer){
result = o1.getInteger(sortName).compareTo(o2.getInteger(sortName));
}else{
result = o1.get(sortName).toString().compareTo(o2.get(sortName).toString());
}
if(!isAscSort){ //倒序, 取反数
return -result;
}
return result;
});
}
}
|
List<JSONObject> nodeTree = buildTreeObject();
JSONArray jsonArray = new JSONArray();
nodeTree.stream().forEach(item -> jsonArray.add(item));
return jsonArray.toString();
| 1,190
| 55
| 1,245
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/aop/MethodLogAop.java
|
MethodLogAop
|
setBaseLogInfo
|
class MethodLogAop {
private static final Logger logger = LoggerFactory.getLogger(MethodLogAop.class);
@Autowired
private SysLogService sysLogService;
@Autowired private RequestKitBean requestKitBean;
/**
* 异步处理线程池
*/
private final static ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(10);
/**
* 切点
*/
@Pointcut("@annotation(com.jeequan.jeepay.core.aop.MethodLog)")
public void methodCachePointcut() { }
/**
* 切面
* @param point
* @return
* @throws Throwable
*/
@Around("methodCachePointcut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
final SysLog sysLog = new SysLog();
//处理切面任务 发生异常将向外抛出 不记录日志
Object result = point.proceed();
try {
// 基础日志信息
setBaseLogInfo(point, sysLog, JeeUserDetails.getCurrentUserDetails());
sysLog.setOptResInfo(JSONObject.toJSON(result).toString());
scheduledThreadPool.execute(() -> sysLogService.save(sysLog));
} catch (Exception e) {
logger.error("methodLogError", e);
}
return result;
}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 14:04
* @describe: 记录异常操作请求信息
*/
@AfterThrowing(pointcut = "methodCachePointcut()", throwing="e")
public void doException(JoinPoint joinPoint, Throwable e) throws Exception{
final SysLog sysLog = new SysLog();
// 基础日志信息
setBaseLogInfo(joinPoint, sysLog, JeeUserDetails.getCurrentUserDetails());
sysLog.setOptResInfo(e instanceof BizException ? e.getMessage() : "请求异常");
scheduledThreadPool.execute(() -> sysLogService.save(sysLog));
}
/**
* 获取方法中的中文备注
* @param joinPoint
* @return
* @throws Exception
*/
public static String getAnnotationRemark(JoinPoint joinPoint) throws Exception {
Signature sig = joinPoint.getSignature();
Method m = joinPoint.getTarget().getClass().getMethod(joinPoint.getSignature().getName(), ((MethodSignature) sig).getParameterTypes());
MethodLog methodCache = m.getAnnotation(MethodLog.class);
if (methodCache != null) {
return methodCache.remark();
}
return "";
}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 14:12
* @describe: 日志基本信息 公共方法
*/
private void setBaseLogInfo(JoinPoint joinPoint, SysLog sysLog, JeeUserDetails userDetails) throws Exception {<FILL_FUNCTION_BODY>}
}
|
// 使用point.getArgs()可获取request,仅限于spring MVC参数包含request,改为通过contextHolder获取。
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//请求参数
sysLog.setOptReqParam( requestKitBean.getReqParamJSON().toJSONString() );
//注解备注
sysLog.setMethodRemark(getAnnotationRemark(joinPoint));
//包名 方法名
String methodName = joinPoint.getSignature().getName();
String packageName = joinPoint.getThis().getClass().getName();
if (packageName.indexOf("$$EnhancerByCGLIB$$") > -1 || packageName.indexOf("$$EnhancerBySpringCGLIB$$") > -1) { // 如果是CGLIB动态生成的类
packageName = packageName.substring(0, packageName.indexOf("$$"));
}
sysLog.setMethodName(packageName + "." + methodName);
sysLog.setReqUrl(request.getRequestURL().toString());
sysLog.setUserIp(requestKitBean.getClientIp());
sysLog.setCreatedAt(new Date());
sysLog.setSysType(CS.SYS_TYPE.MGR);
if (userDetails != null) {
sysLog.setUserId(JeeUserDetails.getCurrentUserDetails().getSysUser().getSysUserId());
sysLog.setUserName(JeeUserDetails.getCurrentUserDetails().getSysUser().getRealname());
sysLog.setSysType(JeeUserDetails.getCurrentUserDetails().getSysUser().getSysType());
}
| 810
| 422
| 1,232
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/bootstrap/InitRunner.java
|
InitRunner
|
run
|
class InitRunner implements CommandLineRunner {
@Autowired private SystemYmlConfig systemYmlConfig;
@Override
public void run(String... args) throws Exception {<FILL_FUNCTION_BODY>}
}
|
// 配置是否使用缓存模式
SysConfigService.IS_USE_CACHE = systemYmlConfig.getCacheConfig();
//初始化处理fastjson格式
SerializeConfig serializeConfig = SerializeConfig.getGlobalInstance();
serializeConfig.put(Date.class, new SimpleDateFormatSerializer(DatePattern.NORM_DATETIME_PATTERN));
//解决json 序列化时候的 $ref:问题
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
| 58
| 146
| 204
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/bootstrap/JeepayMgrApplication.java
|
JeepayMgrApplication
|
fastJsonConfig
|
class JeepayMgrApplication {
/** main启动函数 **/
public static void main(String[] args) {
//启动项目
SpringApplication.run(JeepayMgrApplication.class, args);
}
/** fastJson 配置信息 **/
@Bean
public HttpMessageConverters fastJsonConfig(){<FILL_FUNCTION_BODY>}
/** Mybatis plus 分页插件 **/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
return paginationInterceptor;
}
/**
* 功能描述: API访问地址: http://localhost:9217/doc.html
*
* @Return: springfox.documentation.spring.web.plugins.Docket
* @Author: terrfly
* @Date: 2023/6/13 15:04
*/
@Bean(value = "knife4jDockerBean")
public Docket knife4jDockerBean() {
return new Docket(DocumentationType.SWAGGER_2) //指定使用Swagger2规范
.apiInfo(new ApiInfoBuilder().version("1.0").build()) //描述字段支持Markdown语法
.groupName("运营平台") //分组名称
.select() // 配置: 如何扫描
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 只扫描: ApiOperation 注解文档。 也支持配置包名、 路径等扫描模式。
.build();
}
}
|
//新建fast-json转换器
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
// 开启 FastJSON 安全模式!
ParserConfig.getGlobalInstance().setSafeMode(true);
//fast-json 配置信息
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
converter.setFastJsonConfig(config);
//设置响应的 Content-Type
converter.setSupportedMediaTypes(Arrays.asList(new MediaType[]{MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_UTF8}));
return new HttpMessageConverters(converter);
| 522
| 179
| 701
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/config/RedisConfig.java
|
RedisConfig
|
sysStringRedisTemplate
|
class RedisConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private Integer port;
@Value("${spring.redis.timeout}")
private Integer timeout;
@Value("${spring.redis.database}")
private Integer defaultDatabase;
@Value("${spring.redis.password}")
private String password;
/** 当前系统的redis缓存操作对象 (主对象) **/
@Primary
@Bean(name = "defaultStringRedisTemplate")
public StringRedisTemplate sysStringRedisTemplate() {<FILL_FUNCTION_BODY>}
}
|
StringRedisTemplate template = new StringRedisTemplate();
LettuceConnectionFactory jedisConnectionFactory = new LettuceConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(port);
jedisConnectionFactory.setTimeout(timeout);
if (!StringUtils.isEmpty(password)) {
jedisConnectionFactory.setPassword(password);
}
if (defaultDatabase != 0) {
jedisConnectionFactory.setDatabase(defaultDatabase);
}
jedisConnectionFactory.afterPropertiesSet();
template.setConnectionFactory(jedisConnectionFactory);
return template;
| 184
| 169
| 353
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/CurrentUserController.java
|
CurrentUserController
|
modifyPwd
|
class CurrentUserController extends CommonCtrl{
@Autowired private SysEntitlementService sysEntitlementService;
@Autowired private SysUserService sysUserService;
@Autowired private SysUserAuthService sysUserAuthService;
@ApiOperation("查询当前登录者的用户信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@RequestMapping(value="/user", method = RequestMethod.GET)
public ApiRes currentUserInfo() {
///当前用户信息
JeeUserDetails jeeUserDetails = getCurrentUser();
SysUser user = jeeUserDetails.getSysUser();
//1. 当前用户所有权限ID集合
List<String> entIdList = new ArrayList<>();
jeeUserDetails.getAuthorities().stream().forEach(r->entIdList.add(r.getAuthority()));
List<SysEntitlement> allMenuList = new ArrayList<>(); //所有菜单集合
//2. 查询出用户所有菜单集合 (包含左侧显示菜单 和 其他类型菜单 )
if(!entIdList.isEmpty()){
allMenuList = sysEntitlementService.list(SysEntitlement.gw()
.in(SysEntitlement::getEntId, entIdList)
.in(SysEntitlement::getEntType, Arrays.asList(CS.ENT_TYPE.MENU_LEFT, CS.ENT_TYPE.MENU_OTHER))
.eq(SysEntitlement::getSysType, CS.SYS_TYPE.MGR)
.eq(SysEntitlement::getState, CS.PUB_USABLE));
}
//4. 转换为json树状结构
JSONArray jsonArray = (JSONArray) JSON.toJSON(allMenuList);
List<JSONObject> allMenuRouteTree = new TreeDataBuilder(jsonArray,
"entId", "pid", "children", "entSort", true)
.buildTreeObject();
//1. 所有权限ID集合
user.addExt("entIdList", entIdList);
user.addExt("allMenuRouteTree", allMenuRouteTree);
return ApiRes.ok(getCurrentUser().getSysUser());
}
/** 修改个人信息 */
@ApiOperation("修改个人信息--基本信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "avatarUrl", value = "头像地址"),
@ApiImplicitParam(name = "realname", value = "真实姓名"),
@ApiImplicitParam(name = "sex", value = "性别 0-未知, 1-男, 2-女")
})
@RequestMapping(value="/user", method = RequestMethod.PUT)
@MethodLog(remark = "修改信息")
public ApiRes modifyCurrentUserInfo() {
//修改头像
String avatarUrl = getValString("avatarUrl");
String realname = getValString("realname");
Byte sex = getValByte("sex");
SysUser updateRecord = new SysUser();
updateRecord.setSysUserId(getCurrentUser().getSysUser().getSysUserId());
if (StringUtils.isNotEmpty(avatarUrl)) {
updateRecord.setAvatarUrl(avatarUrl);
}
if (StringUtils.isNotEmpty(realname)) {
updateRecord.setRealname(realname);
}
if (sex != null) {
updateRecord.setSex(sex);
}
sysUserService.updateById(updateRecord);
//保存redis最新数据
JeeUserDetails currentUser = getCurrentUser();
currentUser.setSysUser(sysUserService.getById(getCurrentUser().getSysUser().getSysUserId()));
ITokenService.refData(currentUser);
return ApiRes.ok();
}
/** 修改密码 */
@ApiOperation("修改个人信息--安全信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "confirmPwd", value = "新密码"),
@ApiImplicitParam(name = "originalPwd", value = "原密码")
})
@RequestMapping(value="modifyPwd", method = RequestMethod.PUT)
@MethodLog(remark = "修改密码")
public ApiRes modifyPwd() throws BizException{<FILL_FUNCTION_BODY>}
// /** 登出 */
// @RequestMapping(value="logout", method = RequestMethod.POST)
// @MethodLog(remark = "登出")
public ApiRes logout() throws BizException{
ITokenService.removeIToken(getCurrentUser().getCacheKey(), getCurrentUser().getSysUser().getSysUserId());
return ApiRes.ok();
}
}
|
//更改密码,验证当前用户信息
String currentUserPwd = Base64.decodeStr(getValStringRequired("originalPwd")); //当前用户登录密码
//验证当前密码是否正确
if(!sysUserAuthService.validateCurrentUserPwd(currentUserPwd)){
throw new BizException("原密码验证失败!");
}
String opUserPwd = Base64.decodeStr(getValStringRequired("confirmPwd"));
// 验证原密码与新密码是否相同
if (opUserPwd.equals(currentUserPwd)) {
throw new BizException("新密码与原密码不能相同!");
}
sysUserAuthService.resetAuthInfo(getCurrentUser().getSysUser().getSysUserId(), null, null, opUserPwd, CS.SYS_TYPE.MGR);
//调用登出接口
return logout();
| 1,328
| 242
| 1,570
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/anon/AuthController.java
|
AuthController
|
validate
|
class AuthController extends CommonCtrl {
@Autowired private AuthService authService;
/** 用户信息认证 获取iToken **/
@ApiOperation("登录认证")
@ApiImplicitParams({
@ApiImplicitParam(name = "ia", value = "用户名 i account, 需要base64处理", required = true),
@ApiImplicitParam(name = "ip", value = "密码 i passport, 需要base64处理", required = true),
@ApiImplicitParam(name = "vc", value = "证码 vercode, 需要base64处理", required = true),
@ApiImplicitParam(name = "vt", value = "验证码token, vercode token , 需要base64处理", required = true)
})
@RequestMapping(value = "/validate", method = RequestMethod.POST)
@MethodLog(remark = "登录认证")
public ApiRes validate() throws BizException {<FILL_FUNCTION_BODY>}
/** 图片验证码 **/
@ApiOperation("图片验证码")
@RequestMapping(value = "/vercode", method = RequestMethod.GET)
public ApiRes vercode() throws BizException {
//定义图形验证码的长和宽 // 4位验证码
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(137, 40, 4, 80);
lineCaptcha.createCode(); //生成code
//redis
String vercodeToken = UUID.fastUUID().toString();
RedisUtil.setString(CS.getCacheKeyImgCode(vercodeToken), lineCaptcha.getCode(), CS.VERCODE_CACHE_TIME ); //图片验证码缓存时间: 1分钟
JSONObject result = new JSONObject();
result.put("imageBase64Data", lineCaptcha.getImageBase64Data());
result.put("vercodeToken", vercodeToken);
result.put("expireTime", CS.VERCODE_CACHE_TIME);
return ApiRes.ok(result);
}
}
|
String account = Base64.decodeStr(getValStringRequired("ia")); //用户名 i account, 已做base64处理
String ipassport = Base64.decodeStr(getValStringRequired("ip")); //密码 i passport, 已做base64处理
String vercode = Base64.decodeStr(getValStringRequired("vc")); //验证码 vercode, 已做base64处理
String vercodeToken = Base64.decodeStr(getValStringRequired("vt")); //验证码token, vercode token , 已做base64处理
String cacheCode = RedisUtil.getString(CS.getCacheKeyImgCode(vercodeToken));
if(StringUtils.isEmpty(cacheCode) || !cacheCode.equalsIgnoreCase(vercode)){
throw new BizException("验证码有误!");
}
// 返回前端 accessToken
String accessToken = authService.auth(account, ipassport);
// 删除图形验证码缓存数据
RedisUtil.del(CS.getCacheKeyImgCode(vercodeToken));
return ApiRes.ok4newJson(CS.ACCESS_TOKEN_NAME, accessToken);
| 529
| 306
| 835
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/common/StaticController.java
|
StaticController
|
imgView
|
class StaticController extends CommonCtrl {
@Autowired private OssYmlConfig ossYmlConfig;
/** 图片预览 **/
@GetMapping("/api/anon/localOssFiles/**/*.*")
public ResponseEntity<?> imgView() {<FILL_FUNCTION_BODY>}
}
|
try {
//查找图片文件
File imgFile = new File(ossYmlConfig.getOss().getFilePublicPath() + File.separator + request.getRequestURI().substring(24));
if(!imgFile.isFile() || !imgFile.exists()) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
//输出文件流(图片格式)
HttpHeaders httpHeaders = new HttpHeaders();
// httpHeaders.setContentType(MediaType.IMAGE_JPEG); //图片格式
InputStream inputStream = new FileInputStream(imgFile);
return new ResponseEntity<>(new InputStreamResource(inputStream), httpHeaders, HttpStatus.OK);
} catch (FileNotFoundException e) {
logger.error("static file error", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
| 85
| 228
| 313
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/config/MainChartController.java
|
MainChartController
|
payCount
|
class MainChartController extends CommonCtrl {
@Autowired private PayOrderService payOrderService;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:18
* @describe: 周交易总金额
*/
@ApiOperation("周交易总金额")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@PreAuthorize("hasAuthority('ENT_C_MAIN_PAY_AMOUNT_WEEK')")
@RequestMapping(value="/payAmountWeek", method = RequestMethod.GET)
public ApiRes payAmountWeek() {
return ApiRes.ok(payOrderService.mainPageWeekCount(null));
}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:18
* @describe: 商户总数量、服务商总数量、总交易金额、总交易笔数
*/
@ApiOperation("商户总数量、服务商总数量、总交易金额、总交易笔数")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@PreAuthorize("hasAuthority('ENT_C_MAIN_NUMBER_COUNT')")
@RequestMapping(value="/numCount", method = RequestMethod.GET)
public ApiRes numCount() {
JSONObject json = payOrderService.mainPageNumCount(null);
//返回数据
return ApiRes.ok(json);
}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:18
* @describe: 交易统计
*/
@ApiOperation("交易统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--开始时间,须和结束时间一起使用,否则默认查最近七天(含今天)"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--结束时间,须和开始时间一起使用,否则默认查最近七天(含今天)")
})
@PreAuthorize("hasAuthority('ENT_C_MAIN_PAY_COUNT')")
@RequestMapping(value="/payCount", method = RequestMethod.GET)
public ApiRes<List<Map>> payCount() {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:18
* @describe: 支付方式统计
*/
@ApiOperation("支付方式统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--开始时间,须和结束时间一起使用,否则默认查最近七天(含今天)"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--结束时间,须和开始时间一起使用,否则默认查最近七天(含今天)")
})
@PreAuthorize("hasAuthority('ENT_C_MAIN_PAY_TYPE_COUNT')")
@RequestMapping(value="/payTypeCount", method = RequestMethod.GET)
public ApiRes<ArrayList> payWayCount() {
JSONObject paramJSON = getReqParamJSON();
// 开始、结束时间
String createdStart = paramJSON.getString("createdStart");
String createdEnd = paramJSON.getString("createdEnd");
ArrayList arrayResult = payOrderService.mainPagePayTypeCount(null, createdStart, createdEnd);
return ApiRes.ok(arrayResult);
}
}
|
// 获取传入参数
JSONObject paramJSON = getReqParamJSON();
String createdStart = paramJSON.getString("createdStart");
String createdEnd = paramJSON.getString("createdEnd");
List<Map> mapList = payOrderService.mainPagePayCount(null, createdStart, createdEnd);
//返回数据
return ApiRes.ok(mapList);
| 1,122
| 96
| 1,218
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/config/SysConfigController.java
|
SysConfigController
|
getConfigs
|
class SysConfigController extends CommonCtrl {
@Autowired private SysConfigService sysConfigService;
@Autowired private IMQSender mqSender;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:19
* @describe: 分组下的配置
*/
@ApiOperation("系统配置--查询分组下的配置")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "groupKey", value = "分组key")
})
@PreAuthorize("hasAuthority('ENT_SYS_CONFIG_INFO')")
@RequestMapping(value="/{groupKey}", method = RequestMethod.GET)
public ApiRes<List<SysConfig>> getConfigs(@PathVariable("groupKey") String groupKey) {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:19
* @describe: 系统配置修改
*/
@ApiOperation("系统配置--修改分组下的配置")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "groupKey", value = "分组key", required = true),
@ApiImplicitParam(name = "mchSiteUrl", value = "商户平台网址(不包含结尾/)"),
@ApiImplicitParam(name = "mgrSiteUrl", value = "运营平台网址(不包含结尾/)"),
@ApiImplicitParam(name = "ossPublicSiteUrl", value = "公共oss访问地址(不包含结尾/)"),
@ApiImplicitParam(name = "paySiteUrl", value = "支付网关地址(不包含结尾/)")
})
@PreAuthorize("hasAuthority('ENT_SYS_CONFIG_EDIT')")
@MethodLog(remark = "系统配置修改")
@RequestMapping(value="/{groupKey}", method = RequestMethod.PUT)
public ApiRes update(@PathVariable("groupKey") String groupKey) {
JSONObject paramJSON = getReqParamJSON();
Map<String, String> updateMap = JSONObject.toJavaObject(paramJSON, Map.class);
int update = sysConfigService.updateByConfigKey(updateMap);
if(update <= 0) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "更新失败");
}
// 异步更新到MQ
SpringBeansUtil.getBean(SysConfigController.class).updateSysConfigMQ(groupKey);
return ApiRes.ok();
}
@Async
public void updateSysConfigMQ(String groupKey){
mqSender.send(ResetAppConfigMQ.build(groupKey));
}
}
|
LambdaQueryWrapper<SysConfig> condition = SysConfig.gw();
condition.orderByAsc(SysConfig::getSortNum);
if(StringUtils.isNotEmpty(groupKey)){
condition.eq(SysConfig::getGroupKey, groupKey);
}
List<SysConfig> configList = sysConfigService.list(condition);
//返回数据
return ApiRes.ok(configList);
| 761
| 114
| 875
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/isv/IsvPayInterfaceConfigController.java
|
IsvPayInterfaceConfigController
|
getByMchNo
|
class IsvPayInterfaceConfigController extends CommonCtrl {
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private IMQSender mqSender;
/**
* @Author: ZhuXiao
* @Description: 查询服务商支付接口配置列表
* @Date: 16:45 2021/4/27
*/
@ApiOperation("查询服务商支付接口配置列表")
@ApiImplicitParams({
@ApiImplicitParam(name = CS.ACCESS_TOKEN_NAME, value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "isvNo", value = "服务商号", required = true)
})
@PreAuthorize("hasAuthority('ENT_ISV_PAY_CONFIG_LIST')")
@GetMapping
public ApiRes<List<PayInterfaceDefine>> list() {
List<PayInterfaceDefine> list = payInterfaceConfigService.selectAllPayIfConfigListByIsvNo(CS.INFO_TYPE_ISV, getValStringRequired("isvNo"));
return ApiRes.ok(list);
}
/**
* @Author: ZhuXiao
* @Description: 根据 服务商号、接口类型 获取商户参数配置
* @Date: 17:03 2021/4/27
*/
@ApiOperation("根据[服务商号]、[接口类型]获取商户参数配置")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "isvNo", value = "服务商号", required = true),
@ApiImplicitParam(name = "ifCode", value = "接口类型代码", required = true)
})
@PreAuthorize("hasAuthority('ENT_ISV_PAY_CONFIG_VIEW')")
@GetMapping("/{isvNo}/{ifCode}")
public ApiRes<PayInterfaceConfig> getByMchNo(@PathVariable(value = "isvNo") String isvNo, @PathVariable(value = "ifCode") String ifCode) {<FILL_FUNCTION_BODY>}
/**
* @Author: ZhuXiao
* @Description: 服务商支付接口参数配置
* @Date: 16:45 2021/4/27
*/
@ApiOperation("服务商支付接口参数配置")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "infoId", value = "服务商号", required = true),
@ApiImplicitParam(name = "ifCode", value = "接口类型代码", required = true),
@ApiImplicitParam(name = "ifParams", value = "接口配置参数,json字符串"),
@ApiImplicitParam(name = "ifRate", value = "支付接口费率", dataType = "BigDecimal"),
@ApiImplicitParam(name = "remark", value = "备注"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_ISV_PAY_CONFIG_ADD')")
@PostMapping
@MethodLog(remark = "更新服务商支付参数")
public ApiRes saveOrUpdate() {
String infoId = getValStringRequired("infoId");
String ifCode = getValStringRequired("ifCode");
PayInterfaceConfig payInterfaceConfig = getObject(PayInterfaceConfig.class);
payInterfaceConfig.setInfoType(CS.INFO_TYPE_ISV);
// 存入真实费率
if (payInterfaceConfig.getIfRate() != null) {
payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().divide(new BigDecimal("100"), 6, BigDecimal.ROUND_HALF_UP));
}
//添加更新者信息
Long userId = getCurrentUser().getSysUser().getSysUserId();
String realName = getCurrentUser().getSysUser().getRealname();
payInterfaceConfig.setUpdatedUid(userId);
payInterfaceConfig.setUpdatedBy(realName);
//根据 服务商号、接口类型 获取商户参数配置
PayInterfaceConfig dbRecoed = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_ISV, infoId, ifCode);
//若配置存在,为saveOrUpdate添加ID,第一次配置添加创建者
if (dbRecoed != null) {
payInterfaceConfig.setId(dbRecoed.getId());
// 合并支付参数
payInterfaceConfig.setIfParams(StringKit.marge(dbRecoed.getIfParams(), payInterfaceConfig.getIfParams()));
}else {
payInterfaceConfig.setCreatedUid(userId);
payInterfaceConfig.setCreatedBy(realName);
}
boolean result = payInterfaceConfigService.saveOrUpdate(payInterfaceConfig);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR, "配置失败");
}
// 推送mq到目前节点进行更新数据
mqSender.send(ResetIsvMchAppInfoConfigMQ.build(ResetIsvMchAppInfoConfigMQ.RESET_TYPE_ISV_INFO, infoId, null, null));
return ApiRes.ok();
}
}
|
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getByInfoIdAndIfCode(CS.INFO_TYPE_ISV, isvNo, ifCode);
if (payInterfaceConfig != null) {
if (payInterfaceConfig.getIfRate() != null) {
payInterfaceConfig.setIfRate(payInterfaceConfig.getIfRate().multiply(new BigDecimal("100")));
}
if (StringUtils.isNotBlank(payInterfaceConfig.getIfParams())) {
IsvParams isvParams = IsvParams.factory(payInterfaceConfig.getIfCode(), payInterfaceConfig.getIfParams());
if (isvParams != null) {
payInterfaceConfig.setIfParams(isvParams.deSenData());
}
}
}
return ApiRes.ok(payInterfaceConfig);
| 1,447
| 209
| 1,656
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/merchant/MchAppController.java
|
MchAppController
|
delete
|
class MchAppController extends CommonCtrl {
@Autowired private MchInfoService mchInfoService;
@Autowired private MchAppService mchAppService;
@Autowired private IMQSender mqSender;
/**
* @Author: ZhuXiao
* @Description: 应用列表
* @Date: 9:59 2021/6/16
*/
@ApiOperation("查询应用列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "mchNo", value = "商户号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "appName", value = "应用名称"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_LIST')")
@GetMapping
public ApiPageRes<MchApp> list() {
MchApp mchApp = getObject(MchApp.class);
IPage<MchApp> pages = mchAppService.selectPage(getIPage(), mchApp);
return ApiPageRes.pages(pages);
}
/**
* @Author: ZhuXiao
* @Description: 新建应用
* @Date: 10:05 2021/6/16
*/
@ApiOperation("新建应用")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appName", value = "应用名称", required = true),
@ApiImplicitParam(name = "appSecret", value = "应用私钥", required = true),
@ApiImplicitParam(name = "mchNo", value = "商户号", required = true),
@ApiImplicitParam(name = "remark", value = "备注"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_ADD')")
@MethodLog(remark = "新建应用")
@PostMapping
public ApiRes add() {
MchApp mchApp = getObject(MchApp.class);
mchApp.setAppId(IdUtil.objectId());
if(mchInfoService.getById(mchApp.getMchNo()) == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
boolean result = mchAppService.save(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_CREATE);
}
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 应用详情
* @Date: 10:13 2021/6/16
*/
@ApiOperation("应用详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true)
})
@PreAuthorize("hasAnyAuthority('ENT_MCH_APP_VIEW', 'ENT_MCH_APP_EDIT')")
@GetMapping("/{appId}")
public ApiRes detail(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.selectById(appId);
if (mchApp == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(mchApp);
}
/**
* @Author: ZhuXiao
* @Description: 更新应用信息
* @Date: 10:11 2021/6/16
*/
@ApiOperation("更新应用信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "appName", value = "应用名称", required = true),
@ApiImplicitParam(name = "appSecret", value = "应用私钥", required = true),
@ApiImplicitParam(name = "mchNo", value = "商户号", required = true),
@ApiImplicitParam(name = "remark", value = "备注"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_EDIT')")
@MethodLog(remark = "更新应用信息")
@PutMapping("/{appId}")
public ApiRes update(@PathVariable("appId") String appId) {
MchApp mchApp = getObject(MchApp.class);
mchApp.setAppId(appId);
boolean result = mchAppService.updateById(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqSender.send(ResetIsvMchAppInfoConfigMQ.build(ResetIsvMchAppInfoConfigMQ.RESET_TYPE_MCH_APP, null, mchApp.getMchNo(), appId));
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 删除应用
* @Date: 10:14 2021/6/16
*/
@ApiOperation("删除应用")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_DEL')")
@MethodLog(remark = "删除应用")
@DeleteMapping("/{appId}")
public ApiRes delete(@PathVariable("appId") String appId) {<FILL_FUNCTION_BODY>}
}
|
MchApp mchApp = mchAppService.getById(appId);
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqSender.send(ResetIsvMchAppInfoConfigMQ.build(ResetIsvMchAppInfoConfigMQ.RESET_TYPE_MCH_APP, null, mchApp.getMchNo(), appId));
return ApiRes.ok();
| 1,828
| 121
| 1,949
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/merchant/MchPayPassageConfigController.java
|
MchPayPassageConfigController
|
list
|
class MchPayPassageConfigController extends CommonCtrl {
@Autowired private MchPayPassageService mchPayPassageService;
@Autowired private PayWayService payWayService;
@Autowired private MchInfoService mchInfoService;
@Autowired private MchAppService mchAppService;
/**
* @Author: ZhuXiao
* @Description: 查询支付方式列表,并添加是否配置支付通道状态
* @Date: 15:31 2021/5/10
*/
@ApiOperation("查询支付方式列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码"),
@ApiImplicitParam(name = "wayName", value = "支付方式名称")
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_LIST')")
@GetMapping
public ApiPageRes<PayWay> list() {<FILL_FUNCTION_BODY>}
/**
* @Author: ZhuXiao
* @Description: 根据appId、支付方式查询可用的支付接口列表
* @Date: 17:55 2021/5/8
* @return
*/
@ApiOperation("根据[应用ID]、[支付方式代码]查询可用的支付接口列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_CONFIG')")
@GetMapping("/availablePayInterface/{appId}/{wayCode}")
public ApiRes availablePayInterface(@PathVariable("appId") String appId, @PathVariable("wayCode") String wayCode) {
MchApp mchApp = mchAppService.getById(appId);
if (mchApp == null || mchApp.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
MchInfo mchInfo = mchInfoService.getById(mchApp.getMchNo());
if (mchInfo == null || mchInfo.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
// 根据支付方式查询可用支付接口列表
List<JSONObject> list = mchPayPassageService.selectAvailablePayInterfaceList(wayCode, appId, CS.INFO_TYPE_MCH_APP, mchInfo.getType());
return ApiRes.ok(list);
}
/**
* @Author: ZhuXiao
* @Description: 应用支付通道配置
* @Date: 17:36 2021/5/8
*/
@ApiOperation("更新商户支付通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "reqParams", value = "商户支付通道配置信息", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_ADD')")
@PostMapping
@MethodLog(remark = "更新商户支付通道")
public ApiRes saveOrUpdate() {
String reqParams = getValStringRequired("reqParams");
try {
List<MchPayPassage> mchPayPassageList = JSONArray.parseArray(reqParams, MchPayPassage.class);
if (CollectionUtils.isEmpty(mchPayPassageList)) {
throw new BizException("操作失败");
}
MchApp mchApp = mchAppService.getById(mchPayPassageList.get(0).getAppId());
if (mchApp == null || mchApp.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
mchPayPassageService.saveOrUpdateBatchSelf(mchPayPassageList, mchApp.getMchNo());
return ApiRes.ok();
}catch (Exception e) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR);
}
}
}
|
String appId = getValStringRequired("appId");
String wayCode = getValString("wayCode");
String wayName = getValString("wayName");
//支付方式集合
LambdaQueryWrapper<PayWay> wrapper = PayWay.gw();
if (StrUtil.isNotBlank(wayCode)) {
wrapper.eq(PayWay::getWayCode, wayCode);
}
if (StrUtil.isNotBlank(wayName)) {
wrapper.like(PayWay::getWayName, wayName);
}
IPage<PayWay> payWayPage = payWayService.page(getIPage(), wrapper);
if (!CollectionUtils.isEmpty(payWayPage.getRecords())) {
// 支付方式代码集合
List<String> wayCodeList = new LinkedList<>();
payWayPage.getRecords().stream().forEach(payWay -> wayCodeList.add(payWay.getWayCode()));
// 应用支付通道集合
List<MchPayPassage> mchPayPassageList = mchPayPassageService.list(MchPayPassage.gw()
.select(MchPayPassage::getWayCode, MchPayPassage::getState)
.eq(MchPayPassage::getAppId, appId)
.in(MchPayPassage::getWayCode, wayCodeList));
for (PayWay payWay : payWayPage.getRecords()) {
payWay.addExt("passageState", CS.NO);
for (MchPayPassage mchPayPassage : mchPayPassageList) {
// 某种支付方式多个通道的情况下,只要有一个通道状态为开启,则该支付方式对应为开启状态
if (payWay.getWayCode().equals(mchPayPassage.getWayCode()) && mchPayPassage.getState() == CS.YES) {
payWay.addExt("passageState", CS.YES);
break;
}
}
}
}
return ApiPageRes.pages(payWayPage);
| 1,327
| 545
| 1,872
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/order/MchNotifyController.java
|
MchNotifyController
|
list
|
class MchNotifyController extends CommonCtrl {
@Autowired private MchNotifyRecordService mchNotifyService;
@Autowired private IMQSender mqSender;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:14
* @describe: 商户通知列表
*/
@ApiOperation("查询商户通知列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "mchNo", value = "商户号"),
@ApiImplicitParam(name = "orderId", value = "订单ID"),
@ApiImplicitParam(name = "mchOrderNo", value = "商户订单号"),
@ApiImplicitParam(name = "isvNo", value = "服务商号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "state", value = "通知状态,1-通知中,2-通知成功,3-通知失败", dataType = "Byte"),
@ApiImplicitParam(name = "orderType", value = "订单类型:1-支付,2-退款", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_NOTIFY_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<MchNotifyRecord> list() {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:14
* @describe: 商户通知信息
*/
@ApiOperation("通知信息详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "notifyId", value = "商户通知记录ID", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_NOTIFY_VIEW')")
@RequestMapping(value="/{notifyId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("notifyId") String notifyId) {
MchNotifyRecord mchNotify = mchNotifyService.getById(notifyId);
if (mchNotify == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(mchNotify);
}
/*
* 功能描述: 商户通知重发操作
* @Author: terrfly
* @Date: 2021/6/21 17:41
*/
@ApiOperation("商户通知重发")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "notifyId", value = "商户通知记录ID", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_NOTIFY_RESEND')")
@RequestMapping(value="resend/{notifyId}", method = RequestMethod.POST)
public ApiRes resend(@PathVariable("notifyId") Long notifyId) {
MchNotifyRecord mchNotify = mchNotifyService.getById(notifyId);
if (mchNotify == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
if (mchNotify.getState() != MchNotifyRecord.STATE_FAIL) {
throw new BizException("请选择失败的通知记录");
}
//更新通知中
mchNotifyService.getBaseMapper().updateIngAndAddNotifyCountLimit(notifyId);
//调起MQ重发
mqSender.send(PayOrderMchNotifyMQ.build(notifyId));
return ApiRes.ok(mchNotify);
}
}
|
MchNotifyRecord mchNotify = getObject(MchNotifyRecord.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<MchNotifyRecord> wrapper = MchNotifyRecord.gw();
if (StringUtils.isNotEmpty(mchNotify.getOrderId())) {
wrapper.eq(MchNotifyRecord::getOrderId, mchNotify.getOrderId());
}
if (StringUtils.isNotEmpty(mchNotify.getMchNo())) {
wrapper.eq(MchNotifyRecord::getMchNo, mchNotify.getMchNo());
}
if (StringUtils.isNotEmpty(mchNotify.getIsvNo())) {
wrapper.eq(MchNotifyRecord::getIsvNo, mchNotify.getIsvNo());
}
if (StringUtils.isNotEmpty(mchNotify.getMchOrderNo())) {
wrapper.eq(MchNotifyRecord::getMchOrderNo, mchNotify.getMchOrderNo());
}
if (mchNotify.getOrderType() != null) {
wrapper.eq(MchNotifyRecord::getOrderType, mchNotify.getOrderType());
}
if (mchNotify.getState() != null) {
wrapper.eq(MchNotifyRecord::getState, mchNotify.getState());
}
if (StringUtils.isNotEmpty(mchNotify.getAppId())) {
wrapper.eq(MchNotifyRecord::getAppId, mchNotify.getAppId());
}
if (paramJSON != null) {
if (StringUtils.isNotEmpty(paramJSON.getString("createdStart"))) {
wrapper.ge(MchNotifyRecord::getCreatedAt, paramJSON.getString("createdStart"));
}
if (StringUtils.isNotEmpty(paramJSON.getString("createdEnd"))) {
wrapper.le(MchNotifyRecord::getCreatedAt, paramJSON.getString("createdEnd"));
}
}
wrapper.orderByDesc(MchNotifyRecord::getCreatedAt);
IPage<MchNotifyRecord> pages = mchNotifyService.page(getIPage(), wrapper);
return ApiPageRes.pages(pages);
| 1,275
| 579
| 1,854
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/order/PayOrderController.java
|
PayOrderController
|
list
|
class PayOrderController extends CommonCtrl {
@Autowired private PayOrderService payOrderService;
@Autowired private PayWayService payWayService;
@Autowired private SysConfigService sysConfigService;
@Autowired private MchAppService mchAppService;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:15
* @describe: 订单信息列表
*/
@ApiOperation("支付订单信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "mchNo", value = "商户号"),
@ApiImplicitParam(name = "unionOrderId", value = "支付/商户/渠道订单号"),
@ApiImplicitParam(name = "isvNo", value = "服务商号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码"),
@ApiImplicitParam(name = "state", value = "支付状态: 0-订单生成, 1-支付中, 2-支付成功, 3-支付失败, 4-已撤销, 5-已退款, 6-订单关闭", dataType = "Byte"),
@ApiImplicitParam(name = "notifyState", value = "向下游回调状态, 0-未发送, 1-已发送"),
@ApiImplicitParam(name = "divisionState", value = "0-未发生分账, 1-等待分账任务处理, 2-分账处理中, 3-分账任务已结束(不体现状态)")
})
@PreAuthorize("hasAuthority('ENT_ORDER_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<PayOrder> list() {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:15
* @describe: 支付订单信息
*/
@ApiOperation("支付订单信息详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "payOrderId", value = "支付订单号", required = true)
})
@PreAuthorize("hasAuthority('ENT_PAY_ORDER_VIEW')")
@RequestMapping(value="/{payOrderId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("payOrderId") String payOrderId) {
PayOrder payOrder = payOrderService.getById(payOrderId);
if (payOrder == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(payOrder);
}
/**
* 发起订单退款
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/6/17 16:38
*/
@ApiOperation("发起订单退款")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "payOrderId", value = "支付订单号", required = true),
@ApiImplicitParam(name = "refundAmount", value = "退款金额", required = true),
@ApiImplicitParam(name = "refundReason", value = "退款原因", required = true)
})
@MethodLog(remark = "发起订单退款")
@PreAuthorize("hasAuthority('ENT_PAY_ORDER_REFUND')")
@PostMapping("/refunds/{payOrderId}")
public ApiRes refund(@PathVariable("payOrderId") String payOrderId) {
Long refundAmount = getRequiredAmountL("refundAmount");
String refundReason = getValStringRequired("refundReason");
PayOrder payOrder = payOrderService.getById(payOrderId);
if (payOrder == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
if(payOrder.getState() != PayOrder.STATE_SUCCESS){
throw new BizException("订单状态不正确");
}
if(payOrder.getRefundAmount() + refundAmount > payOrder.getAmount()){
throw new BizException("退款金额超过订单可退款金额!");
}
RefundOrderCreateRequest request = new RefundOrderCreateRequest();
RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
request.setBizModel(model);
model.setMchNo(payOrder.getMchNo()); // 商户号
model.setAppId(payOrder.getAppId());
model.setPayOrderId(payOrderId);
model.setMchRefundNo(SeqKit.genMhoOrderId());
model.setRefundAmount(refundAmount);
model.setRefundReason(refundReason);
model.setCurrency("CNY");
MchApp mchApp = mchAppService.getById(payOrder.getAppId());
JeepayClient jeepayClient = new JeepayClient(sysConfigService.getDBApplicationConfig().getPaySiteUrl(), mchApp.getAppSecret());
try {
RefundOrderCreateResponse response = jeepayClient.execute(request);
if(response.getCode() != 0){
throw new BizException(response.getMsg());
}
return ApiRes.ok(response.get());
} catch (JeepayException e) {
throw new BizException(e.getMessage());
}
}
}
|
PayOrder payOrder = getObject(PayOrder.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<PayOrder> wrapper = PayOrder.gw();
IPage<PayOrder> pages = payOrderService.listByPage(getIPage(), payOrder, paramJSON, wrapper);
// 得到所有支付方式
Map<String, String> payWayNameMap = new HashMap<>();
List<PayWay> payWayList = payWayService.list();
for (PayWay payWay:payWayList) {
payWayNameMap.put(payWay.getWayCode(), payWay.getWayName());
}
for (PayOrder order:pages.getRecords()) {
// 存入支付方式名称
if (StringUtils.isNotEmpty(payWayNameMap.get(order.getWayCode()))) {
order.addExt("wayName", payWayNameMap.get(order.getWayCode()));
}else {
order.addExt("wayName", order.getWayCode());
}
}
return ApiPageRes.pages(pages);
| 1,751
| 294
| 2,045
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/order/RefundOrderController.java
|
RefundOrderController
|
list
|
class RefundOrderController extends CommonCtrl {
@Autowired private RefundOrderService refundOrderService;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:15
* @describe: 退款订单信息列表
*/
@ApiOperation("退款订单信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "mchNo", value = "商户号"),
@ApiImplicitParam(name = "unionOrderId", value = "支付/退款订单号"),
@ApiImplicitParam(name = "isvNo", value = "服务商号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "state", value = "退款状态:0-订单生成,1-退款中,2-退款成功,3-退款失败,4-退款任务关闭", dataType = "Byte"),
@ApiImplicitParam(name = "mchType", value = "类型: 1-普通商户, 2-特约商户(服务商模式)")
})
@PreAuthorize("hasAuthority('ENT_REFUND_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<RefundOrder> list() {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:15
* @describe: 退款订单信息
*/
@ApiOperation("退款订单信息详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "refundOrderId", value = "退款订单号", required = true)
})
@PreAuthorize("hasAuthority('ENT_REFUND_ORDER_VIEW')")
@RequestMapping(value="/{refundOrderId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("refundOrderId") String refundOrderId) {
RefundOrder refundOrder = refundOrderService.getById(refundOrderId);
if (refundOrder == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(refundOrder);
}
}
|
RefundOrder refundOrder = getObject(RefundOrder.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<RefundOrder> wrapper = RefundOrder.gw();
IPage<RefundOrder> pages = refundOrderService.pageList(getIPage(), wrapper, refundOrder, paramJSON);
return ApiPageRes.pages(pages);
| 865
| 97
| 962
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/order/TransferOrderController.java
|
TransferOrderController
|
list
|
class TransferOrderController extends CommonCtrl {
@Autowired private TransferOrderService transferOrderService;
/** list **/
@ApiOperation("转账订单信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "mchNo", value = "商户号"),
@ApiImplicitParam(name = "unionOrderId", value = "转账/商户/渠道订单号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "state", value = "支付状态: 0-订单生成, 1-转账中, 2-转账成功, 3-转账失败, 4-订单关闭", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_TRANSFER_ORDER_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<TransferOrder> list() {<FILL_FUNCTION_BODY>}
/** detail **/
@ApiOperation("转账订单信息详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "recordId", value = "转账订单号", required = true)
})
@PreAuthorize("hasAuthority('ENT_TRANSFER_ORDER_VIEW')")
@RequestMapping(value="/{recordId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("recordId") String transferId) {
TransferOrder refundOrder = transferOrderService.getById(transferId);
if (refundOrder == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(refundOrder);
}
}
|
TransferOrder transferOrder = getObject(TransferOrder.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<TransferOrder> wrapper = TransferOrder.gw();
IPage<TransferOrder> pages = transferOrderService.pageList(getIPage(), wrapper, transferOrder, paramJSON);
return ApiPageRes.pages(pages);
| 708
| 95
| 803
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/payconfig/PayWayController.java
|
PayWayController
|
update
|
class PayWayController extends CommonCtrl {
@Autowired PayWayService payWayService;
@Autowired MchPayPassageService mchPayPassageService;
@Autowired PayOrderService payOrderService;
/**
* @Author: ZhuXiao
* @Description: list
* @Date: 15:52 2021/4/27
*/
@ApiOperation("支付方式--列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码"),
@ApiImplicitParam(name = "wayName", value = "支付方式名称")
})
@PreAuthorize("hasAnyAuthority('ENT_PC_WAY_LIST', 'ENT_PAY_ORDER_SEARCH_PAY_WAY')")
@GetMapping
public ApiPageRes<PayWay> list() {
PayWay queryObject = getObject(PayWay.class);
LambdaQueryWrapper<PayWay> condition = PayWay.gw();
if(StringUtils.isNotEmpty(queryObject.getWayCode())){
condition.like(PayWay::getWayCode, queryObject.getWayCode());
}
if(StringUtils.isNotEmpty(queryObject.getWayName())){
condition.like(PayWay::getWayName, queryObject.getWayName());
}
condition.orderByAsc(PayWay::getWayCode);
IPage<PayWay> pages = payWayService.page(getIPage(true), condition);
return ApiPageRes.pages(pages);
}
/**
* @Author: ZhuXiao
* @Description: detail
* @Date: 15:52 2021/4/27
*/
@ApiOperation("支付方式--详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码", required = true)
})
@PreAuthorize("hasAnyAuthority('ENT_PC_WAY_VIEW', 'ENT_PC_WAY_EDIT')")
@GetMapping("/{wayCode}")
public ApiRes detail(@PathVariable("wayCode") String wayCode) {
return ApiRes.ok(payWayService.getById(wayCode));
}
/**
* @Author: ZhuXiao
* @Description: add
* @Date: 15:52 2021/4/27
*/
@ApiOperation("支付方式--新增")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码", required = true),
@ApiImplicitParam(name = "wayName", value = "支付方式名称", required = true)
})
@PreAuthorize("hasAuthority('ENT_PC_WAY_ADD')")
@PostMapping
@MethodLog(remark = "新增支付方式")
public ApiRes add() {
PayWay payWay = getObject(PayWay.class);
if (payWayService.count(PayWay.gw().eq(PayWay::getWayCode, payWay.getWayCode())) > 0) {
throw new BizException("支付方式代码已存在");
}
payWay.setWayCode(payWay.getWayCode().toUpperCase());
boolean result = payWayService.save(payWay);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_CREATE);
}
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: update
* @Date: 15:52 2021/4/27
*/
@ApiOperation("支付方式--更新")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码", required = true),
@ApiImplicitParam(name = "wayName", value = "支付方式名称", required = true)
})
@PreAuthorize("hasAuthority('ENT_PC_WAY_EDIT')")
@PutMapping("/{wayCode}")
@MethodLog(remark = "更新支付方式")
public ApiRes update(@PathVariable("wayCode") String wayCode) {<FILL_FUNCTION_BODY>}
/**
* @Author: ZhuXiao
* @Description: delete
* @Date: 15:52 2021/4/27
*/
@ApiOperation("支付方式--删除")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码", required = true)
})
@PreAuthorize("hasAuthority('ENT_PC_WAY_DEL')")
@DeleteMapping("/{wayCode}")
@MethodLog(remark = "删除支付方式")
public ApiRes delete(@PathVariable("wayCode") String wayCode) {
// 校验该支付方式是否有商户已配置通道或者已有订单
if (mchPayPassageService.count(MchPayPassage.gw().eq(MchPayPassage::getWayCode, wayCode)) > 0
|| payOrderService.count(PayOrder.gw().eq(PayOrder::getWayCode, wayCode)) > 0) {
throw new BizException("该支付方式已有商户配置通道或已发生交易,无法删除!");
}
boolean result = payWayService.removeById(wayCode);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_DELETE);
}
return ApiRes.ok();
}
}
|
PayWay payWay = getObject(PayWay.class);
payWay.setWayCode(wayCode);
boolean result = payWayService.updateById(payWay);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
return ApiRes.ok();
| 1,705
| 99
| 1,804
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/sysuser/SysEntController.java
|
SysEntController
|
showTree
|
class SysEntController extends CommonCtrl {
@Autowired SysEntitlementService sysEntitlementService;
/** getOne */
@ApiOperation("查询菜单权限详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "entId", value = "权限ID[ENT_功能模块_子模块_操作], eg: ENT_ROLE_LIST_ADD", required = true),
@ApiImplicitParam(name = "sysType", value = "所属系统: MGR-运营平台, MCH-商户中心", required = true)
})
@PreAuthorize("hasAnyAuthority( 'ENT_UR_ROLE_ENT_LIST' )")
@RequestMapping(value="/bySysType", method = RequestMethod.GET)
public ApiRes bySystem() {
return ApiRes.ok(sysEntitlementService.getOne(SysEntitlement.gw()
.eq(SysEntitlement::getEntId, getValStringRequired("entId"))
.eq(SysEntitlement::getSysType, getValStringRequired("sysType")))
);
}
/** updateById */
@ApiOperation("更新权限资源")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "entId", value = "权限ID[ENT_功能模块_子模块_操作], eg: ENT_ROLE_LIST_ADD", required = true),
@ApiImplicitParam(name = "entName", value = "权限名称", required = true),
@ApiImplicitParam(name = "menuUri", value = "菜单uri/路由地址"),
@ApiImplicitParam(name = "entSort", value = "排序字段, 规则:正序"),
@ApiImplicitParam(name = "quickJump", value = "快速开始菜单 0-否, 1-是"),
@ApiImplicitParam(name = "state", value = "状态 0-停用, 1-启用")
})
@PreAuthorize("hasAuthority( 'ENT_UR_ROLE_ENT_EDIT')")
@MethodLog(remark = "更新资源权限")
@RequestMapping(value="/{entId}", method = RequestMethod.PUT)
public ApiRes updateById(@PathVariable("entId") String entId) {
SysEntitlement queryObject = getObject(SysEntitlement.class);
sysEntitlementService.update(queryObject, SysEntitlement.gw().eq(SysEntitlement::getEntId, entId).eq(SysEntitlement::getSysType, queryObject.getSysType()));
return ApiRes.ok();
}
/** 查询权限集合 */
@ApiOperation("查询权限集合")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "sysType", value = "所属系统: MGR-运营平台, MCH-商户中心", required = true)
})
@PreAuthorize("hasAnyAuthority( 'ENT_UR_ROLE_ENT_LIST', 'ENT_UR_ROLE_DIST' )")
@RequestMapping(value="/showTree", method = RequestMethod.GET)
public ApiRes<List<JSONObject>> showTree() {<FILL_FUNCTION_BODY>}
}
|
//查询全部数据
List<SysEntitlement> list = sysEntitlementService.list(SysEntitlement.gw().eq(SysEntitlement::getSysType, getValStringRequired("sysType")));
//转换为json树状结构
JSONArray jsonArray = (JSONArray) JSONArray.toJSON(list);
List<JSONObject> leftMenuTree = new TreeDataBuilder(jsonArray,
"entId", "pid", "children", "entSort", true)
.buildTreeObject();
return ApiRes.ok(leftMenuTree);
| 919
| 153
| 1,072
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/sysuser/SysLogController.java
|
SysLogController
|
list
|
class SysLogController extends CommonCtrl {
@Autowired SysLogService sysLogService;
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:15
* @describe: 日志记录列表
*/
@ApiOperation("系统日志列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "userId", value = "系统用户ID"),
@ApiImplicitParam(name = "userName", value = "用户姓名"),
@ApiImplicitParam(name = "sysType", value = "所属系统: MGR-运营平台, MCH-商户中心")
})
@PreAuthorize("hasAuthority('ENT_LOG_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<SysLog> list() {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:16
* @describe: 查看日志信息
*/
@ApiOperation("系统日志详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "sysLogId", value = "系统日志ID", required = true)
})
@PreAuthorize("hasAuthority('ENT_SYS_LOG_VIEW')")
@RequestMapping(value="/{sysLogId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("sysLogId") String sysLogId) {
SysLog sysLog = sysLogService.getById(sysLogId);
if (sysLog == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(sysLog);
}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 16:16
* @describe: 删除日志信息
*/
@ApiOperation("删除日志信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "selectedIds", value = "系统日志ID(若干个ID用英文逗号拼接)", required = true)
})
@PreAuthorize("hasAuthority('ENT_SYS_LOG_DEL')")
@MethodLog(remark = "删除日志信息")
@RequestMapping(value="/{selectedIds}", method = RequestMethod.DELETE)
public ApiRes delete(@PathVariable("selectedIds") String selectedIds) {
String[] ids = selectedIds.split(",");
List<Long> idsList = new LinkedList<>();
for (String id : ids) {
idsList.add(Long.valueOf(id));
}
boolean result = sysLogService.removeByIds(idsList);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_DELETE);
}
return ApiRes.ok();
}
}
|
SysLog sysLog = getObject(SysLog.class);
JSONObject paramJSON = getReqParamJSON();
// 查询列表
LambdaQueryWrapper<SysLog> condition = SysLog.gw();
condition.orderByDesc(SysLog::getCreatedAt);
if (sysLog.getUserId() != null) {
condition.eq(SysLog::getUserId, sysLog.getUserId());
}
if (sysLog.getUserName() != null) {
condition.eq(SysLog::getUserName, sysLog.getUserName());
}
if (StringUtils.isNotEmpty(sysLog.getSysType())) {
condition.eq(SysLog::getSysType, sysLog.getSysType());
}
if (paramJSON != null) {
if (StringUtils.isNotEmpty(paramJSON.getString("createdStart"))) {
condition.ge(SysLog::getCreatedAt, paramJSON.getString("createdStart"));
}
if (StringUtils.isNotEmpty(paramJSON.getString("createdEnd"))) {
condition.le(SysLog::getCreatedAt, paramJSON.getString("createdEnd"));
}
}
IPage<SysLog> pages = sysLogService.page(getIPage(), condition);
return ApiPageRes.pages(pages);
| 1,088
| 344
| 1,432
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/sysuser/SysRoleEntRelaController.java
|
SysRoleEntRelaController
|
list
|
class SysRoleEntRelaController extends CommonCtrl {
@Autowired private SysRoleEntRelaService sysRoleEntRelaService;
/** list */
@ApiOperation("关联关系--角色-权限关联信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "roleId", value = "角色ID, ROLE_开头")
})
@PreAuthorize("hasAnyAuthority( 'ENT_UR_ROLE_ADD', 'ENT_UR_ROLE_DIST' )")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<SysRoleEntRela> list() {<FILL_FUNCTION_BODY>}
}
|
SysRoleEntRela queryObject = getObject(SysRoleEntRela.class);
LambdaQueryWrapper<SysRoleEntRela> condition = SysRoleEntRela.gw();
if(queryObject.getRoleId() != null){
condition.eq(SysRoleEntRela::getRoleId, queryObject.getRoleId());
}
IPage<SysRoleEntRela> pages = sysRoleEntRelaService.page(getIPage(true), condition);
return ApiPageRes.pages(pages);
| 287
| 145
| 432
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/sysuser/SysUserRoleRelaController.java
|
SysUserRoleRelaController
|
relas
|
class SysUserRoleRelaController extends CommonCtrl {
@Autowired private SysUserRoleRelaService sysUserRoleRelaService;
@Autowired private SysUserService sysUserService;
@Autowired private AuthService authService;
/** list */
@ApiOperation("关联关系--用户-角色关联信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "userId", value = "用户ID")
})
@PreAuthorize("hasAuthority( 'ENT_UR_USER_UPD_ROLE' )")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<SysUserRoleRela> list() {
SysUserRoleRela queryObject = getObject(SysUserRoleRela.class);
LambdaQueryWrapper<SysUserRoleRela> condition = SysUserRoleRela.gw();
if(queryObject.getUserId() != null){
condition.eq(SysUserRoleRela::getUserId, queryObject.getUserId());
}
IPage<SysUserRoleRela> pages = sysUserRoleRelaService.page(getIPage(true), condition);
return ApiPageRes.pages(pages);
}
/** 重置用户角色关联信息 */
@ApiOperation("更改用户角色信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "sysUserId", value = "用户ID", required = true),
@ApiImplicitParam(name = "roleIdListStr", value = "角色信息,eg:[str1,str2],字符串列表转成json字符串", required = true)
})
@PreAuthorize("hasAuthority( 'ENT_UR_USER_UPD_ROLE' )")
@RequestMapping(value="relas/{sysUserId}", method = RequestMethod.POST)
@MethodLog(remark = "更改用户角色信息")
public ApiRes relas(@PathVariable("sysUserId") Long sysUserId) {<FILL_FUNCTION_BODY>}
}
|
List<String> roleIdList = JSONArray.parseArray(getValStringRequired("roleIdListStr"), String.class);
sysUserService.saveUserRole(sysUserId, roleIdList);
authService.refAuthentication(Arrays.asList(sysUserId));
return ApiRes.ok();
| 663
| 85
| 748
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mgr.config.SystemYmlConfig mainConfig
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/secruity/JeeAuthenticationEntryPoint.java
|
JeeAuthenticationEntryPoint
|
commence
|
class JeeAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
@Override
public void commence(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException authException) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// This is invoked when user tries to access a secured REST resource without supplying any credentials
// We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
//返回json形式的错误信息
// response.setCharacterEncoding("UTF-8");
// response.setContentType("application/json");
// response.getWriter().println("{\"code\":1001, \"msg\":\"Unauthorized\"}");
response.getWriter().flush();
| 64
| 156
| 220
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/secruity/JeeAuthenticationTokenFilter.java
|
JeeAuthenticationTokenFilter
|
commonFilter
|
class JeeAuthenticationTokenFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
JeeUserDetails jeeUserDetails = commonFilter(request);
if(jeeUserDetails == null){
chain.doFilter(request, response);
return;
}
//将信息放置到Spring-security context中
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(jeeUserDetails, null, jeeUserDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authentication);
chain.doFilter(request, response);
}
private JeeUserDetails commonFilter(HttpServletRequest request){<FILL_FUNCTION_BODY>}
}
|
String authToken = request.getHeader(CS.ACCESS_TOKEN_NAME);
if(StringUtils.isEmpty(authToken)){
authToken = request.getParameter(CS.ACCESS_TOKEN_NAME);
}
if(StringUtils.isEmpty(authToken)){
return null; //放行,并交给UsernamePasswordAuthenticationFilter进行验证,返回公共错误信息.
}
JWTPayload jwtPayload = JWTUtils.parseToken(authToken, SpringBeansUtil.getBean(SystemYmlConfig.class).getJwtSecret()); //反解析token信息
//token字符串解析失败
if( jwtPayload == null || StringUtils.isEmpty(jwtPayload.getCacheKey())) {
return null;
}
//根据用户名查找数据库
JeeUserDetails jwtBaseUser = RedisUtil.getObject(jwtPayload.getCacheKey(), JeeUserDetails.class);
if(jwtBaseUser == null){
RedisUtil.del(jwtPayload.getCacheKey());
return null; //数据库查询失败,删除redis
}
//续签时间
RedisUtil.expire(jwtPayload.getCacheKey(), CS.TOKEN_TIME);
return jwtBaseUser;
| 221
| 334
| 555
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/secruity/JeeUserDetailsServiceImpl.java
|
JeeUserDetailsServiceImpl
|
loadUserByUsername
|
class JeeUserDetailsServiceImpl implements UserDetailsService {
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserAuthService sysUserAuthService;
/**
*
* 此函数为: authenticationManager.authenticate(upToken) 内部调用 ;
* 需返回 用户信息载体 / 用户密码 。
* 用户角色+权限的封装集合 (暂时不查询, 在验证通过后再次查询,避免用户名密码输入有误导致查询资源浪费)
*
* **/
@Override
public UserDetails loadUserByUsername(String loginUsernameStr) throws UsernameNotFoundException {<FILL_FUNCTION_BODY>}
}
|
//登录方式, 默认为账号密码登录
Byte identityType = CS.AUTH_TYPE.LOGIN_USER_NAME;
if(RegKit.isMobile(loginUsernameStr)){
identityType = CS.AUTH_TYPE.TELPHONE; //手机号登录
}
//首先根据登录类型 + 用户名得到 信息
SysUserAuth auth = sysUserAuthService.selectByLogin(loginUsernameStr, identityType, CS.SYS_TYPE.MGR);
if(auth == null){ //没有该用户信息
throw JeepayAuthenticationException.build("用户名/密码错误!");
}
//用户ID
Long userId = auth.getUserId();
SysUser sysUser = sysUserService.getById(userId);
if (sysUser == null) {
throw JeepayAuthenticationException.build("用户名/密码错误!");
}
if(CS.PUB_USABLE != sysUser.getState()){ //状态不合法
throw JeepayAuthenticationException.build("用户状态不可登录,请联系管理员!");
}
return new JeeUserDetails(sysUser, auth.getCredential());
| 199
| 308
| 507
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/secruity/WebSecurityConfig.java
|
WebSecurityConfig
|
corsFilter
|
class WebSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired private UserDetailsService userDetailsService;
@Autowired private JeeAuthenticationEntryPoint unauthorizedHandler;
@Autowired private SystemYmlConfig systemYmlConfig;
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
/**
* 使用BCrypt强哈希函数 实现PasswordEncoder
* **/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder
.userDetailsService(this.userDetailsService)
.passwordEncoder(passwordEncoder());
}
/** 允许跨域请求 **/
@Bean
public CorsFilter corsFilter() {<FILL_FUNCTION_BODY>}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
// 由于使用的是JWT,我们这里不需要csrf
.csrf().disable()
.cors().and()
// 认证失败处理方式
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
// 基于token,所以不需要session
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated();
// 添加JWT filter
httpSecurity.addFilterBefore(new JeeAuthenticationTokenFilter(), UsernamePasswordAuthenticationFilter.class);
// 禁用缓存
httpSecurity.headers().cacheControl();
}
@Override
public void configure(WebSecurity web) throws Exception {
//ignore文件 : 无需进入spring security 框架
// 1.允许对于网站静态资源的无授权访问
// 2.对于获取token的rest api要允许匿名访问
web.ignoring().antMatchers(
HttpMethod.GET,
"/",
"/*.html",
"/favicon.ico",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.png",
"/**/*.jpg",
"/**/*.jpeg",
"/**/*.svg",
"/**/*.ico",
"/**/*.webp",
"/*.txt",
"/**/*.xls",
"/**/*.mp4" //支持mp4格式的文件匿名访问
)
.antMatchers(
"/api/anon/**", //匿名访问接口
"/swagger-resources/**","/v2/api-docs/**" // swagger相关
);
}
}
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
if(systemYmlConfig.getAllowCors()){
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); //带上cookie信息
// config.addAllowedOrigin(CorsConfiguration.ALL); //允许跨域的域名, *表示允许任何域名使用
config.addAllowedOriginPattern(CorsConfiguration.ALL); //使用addAllowedOriginPattern 避免出现 When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
config.addAllowedHeader(CorsConfiguration.ALL); //允许任何请求头
config.addAllowedMethod(CorsConfiguration.ALL); //允许任何方法(post、get等)
source.registerCorsConfiguration("/**", config); // CORS 配置对所有接口都有效
}
return new CorsFilter(source);
| 747
| 274
| 1,021
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/service/AuthService.java
|
AuthService
|
auth
|
class AuthService {
@Resource
private AuthenticationManager authenticationManager;
@Autowired private SysUserService sysUserService;
@Autowired private SysRoleService sysRoleService;
@Autowired private SysRoleEntRelaService sysRoleEntRelaService;
@Autowired private SysEntitlementMapper sysEntitlementMapper;
@Autowired private SystemYmlConfig systemYmlConfig;
/**
* 认证
* **/
public String auth(String username, String password){<FILL_FUNCTION_BODY>}
/** 根据用户ID 更新缓存中的权限集合, 使得分配实时生效 **/
public void refAuthentication(List<Long> sysUserIdList){
if(sysUserIdList == null || sysUserIdList.isEmpty()){
return ;
}
Map<Long, SysUser> sysUserMap = new HashMap<>();
// 查询 sysUserId 和 state
sysUserService.list(
SysUser.gw()
.select(SysUser::getSysUserId, SysUser::getState)
.in(SysUser::getSysUserId, sysUserIdList)
).stream().forEach(item -> sysUserMap.put(item.getSysUserId(), item));
for (Long sysUserId : sysUserIdList) {
Collection<String> cacheKeyList = RedisUtil.keys(CS.getCacheKeyToken(sysUserId, "*"));
if(cacheKeyList == null || cacheKeyList.isEmpty()){
continue;
}
for (String cacheKey : cacheKeyList) {
//用户不存在 || 已禁用 需要删除Redis
if(sysUserMap.get(sysUserId) == null || sysUserMap.get(sysUserId).getState() == CS.PUB_DISABLE){
RedisUtil.del(cacheKey);
continue;
}
JeeUserDetails jwtBaseUser = RedisUtil.getObject(cacheKey, JeeUserDetails.class);
if(jwtBaseUser == null){
continue;
}
// 重新放置sysUser对象
jwtBaseUser.setSysUser(sysUserService.getById(sysUserId));
//查询放置权限数据
jwtBaseUser.setAuthorities(getUserAuthority(jwtBaseUser.getSysUser()));
//保存token 失效时间不变
RedisUtil.set(cacheKey, jwtBaseUser);
}
}
}
/** 根据用户ID 删除用户缓存信息 **/
public void delAuthentication(List<Long> sysUserIdList){
if(sysUserIdList == null || sysUserIdList.isEmpty()){
return ;
}
for (Long sysUserId : sysUserIdList) {
Collection<String> cacheKeyList = RedisUtil.keys(CS.getCacheKeyToken(sysUserId, "*"));
if(cacheKeyList == null || cacheKeyList.isEmpty()){
continue;
}
for (String cacheKey : cacheKeyList) {
RedisUtil.del(cacheKey);
}
}
}
public List<SimpleGrantedAuthority> getUserAuthority(SysUser sysUser){
//用户拥有的角色集合 需要以ROLE_ 开头, 用户拥有的权限集合
List<String> roleList = sysRoleService.findListByUser(sysUser.getSysUserId());
List<String> entList = sysRoleEntRelaService.selectEntIdsByUserId(sysUser.getSysUserId(), sysUser.getIsAdmin(), sysUser.getSysType());
List<SimpleGrantedAuthority> grantedAuthorities = new LinkedList<>();
roleList.stream().forEach(role -> grantedAuthorities.add(new SimpleGrantedAuthority(role)));
entList.stream().forEach(ent -> grantedAuthorities.add(new SimpleGrantedAuthority(ent)));
return grantedAuthorities;
}
}
|
//1. 生成spring-security usernamePassword类型对象
UsernamePasswordAuthenticationToken upToken = new UsernamePasswordAuthenticationToken(username, password);
//spring-security 自动认证过程;
// 1. 进入 JeeUserDetailsServiceImpl.loadUserByUsername 获取用户基本信息;
//2. SS根据UserDetails接口验证是否用户可用;
//3. 最后返回loadUserByUsername 封装的对象信息;
Authentication authentication = null;
try {
authentication = authenticationManager.authenticate(upToken);
} catch (JeepayAuthenticationException jex) {
throw jex.getBizException() == null ? new BizException(jex.getMessage()) : jex.getBizException();
} catch (BadCredentialsException e) {
throw new BizException("用户名/密码错误!");
} catch (AuthenticationException e) {
log.error("AuthenticationException:", e);
throw new BizException("认证服务出现异常, 请重试或联系系统管理员!");
}
JeeUserDetails jeeUserDetails = (JeeUserDetails) authentication.getPrincipal();
//验证通过后 再查询用户角色和权限信息集合
SysUser sysUser = jeeUserDetails.getSysUser();
//非超级管理员 && 不包含左侧菜单 进行错误提示
if(sysUser.getIsAdmin() != CS.YES && sysEntitlementMapper.userHasLeftMenu(sysUser.getSysUserId(), CS.SYS_TYPE.MGR) <= 0){
throw new BizException("当前用户未分配任何菜单权限,请联系管理员进行分配后再登录!");
}
// 放置权限集合
jeeUserDetails.setAuthorities(getUserAuthority(sysUser));
//生成token
String cacheKey = CS.getCacheKeyToken(sysUser.getSysUserId(), IdUtil.fastUUID());
//生成iToken 并放置到缓存
ITokenService.processTokenCache(jeeUserDetails, cacheKey); //处理token 缓存信息
//将信息放置到Spring-security context中
UsernamePasswordAuthenticationToken authenticationRest = new UsernamePasswordAuthenticationToken(jeeUserDetails, null, jeeUserDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authenticationRest);
//返回JWTToken
return JWTUtils.generateToken(new JWTPayload(jeeUserDetails), systemYmlConfig.getJwtSecret());
| 1,028
| 647
| 1,675
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/web/ApiResBodyAdvice.java
|
ApiResBodyAdvice
|
supports
|
class ApiResBodyAdvice implements ResponseBodyAdvice {
/** 注入 是否开启 knife4j **/
@Value("${knife4j.enable}")
private boolean knife4jEnable = false;
/** 判断哪些需要拦截 **/
@Override
public boolean supports(MethodParameter returnType, Class converterType) {<FILL_FUNCTION_BODY>}
/** 拦截返回数据处理 */
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//处理扩展字段
return ApiResBodyAdviceKit.beforeBodyWrite(body);
}
}
|
// springfox.documentation.swagger.web.ApiResourceController -- /swagger-resources
// springfox.documentation.swagger2.web.Swagger2ControllerWebMvc -- /v2/api-docs
if(knife4jEnable && returnType.getMethod().getDeclaringClass().getName().startsWith("springfox.documentation.swagger")){
return false;
}
return true;
| 189
| 113
| 302
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/aop/MethodLogAop.java
|
MethodLogAop
|
around
|
class MethodLogAop{
private static final Logger logger = LoggerFactory.getLogger(MethodLogAop.class);
@Autowired private SysLogService sysLogService;
@Autowired private RequestKitBean requestKitBean;
/**
* 异步处理线程池
*/
private final static ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(10);
/**
* 切点
*/
@Pointcut("@annotation(com.jeequan.jeepay.core.aop.MethodLog)")
public void methodCachePointcut() { }
/**
* 切面
* @param point
* @return
* @throws Throwable
*/
@Around("methodCachePointcut()")
public Object around(ProceedingJoinPoint point) throws Throwable {<FILL_FUNCTION_BODY>}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 14:04
* @describe: 记录异常操作请求信息
*/
@AfterThrowing(pointcut = "methodCachePointcut()", throwing="e")
public void doException(JoinPoint joinPoint, Throwable e) throws Exception{
final SysLog sysLog = new SysLog();
// 基础日志信息
setBaseLogInfo(joinPoint, sysLog, JeeUserDetails.getCurrentUserDetails());
sysLog.setOptResInfo(e instanceof BizException ? e.getMessage() : "请求异常");
scheduledThreadPool.execute(() -> sysLogService.save(sysLog));
}
/**
* 获取方法中的中文备注
* @param joinPoint
* @return
* @throws Exception
*/
public static String getAnnotationRemark(JoinPoint joinPoint) throws Exception {
Signature sig = joinPoint.getSignature();
Method m = joinPoint.getTarget().getClass().getMethod(joinPoint.getSignature().getName(), ((MethodSignature) sig).getParameterTypes());
MethodLog methodCache = m.getAnnotation(MethodLog.class);
if (methodCache != null) {
return methodCache.remark();
}
return "";
}
/**
* @author: pangxiaoyu
* @date: 2021/6/7 14:12
* @describe: 日志基本信息 公共方法
*/
private void setBaseLogInfo(JoinPoint joinPoint, SysLog sysLog, JeeUserDetails userDetails) throws Exception {
// 使用point.getArgs()可获取request,仅限于spring MVC参数包含request,改为通过contextHolder获取。
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//请求参数
sysLog.setOptReqParam( requestKitBean.getReqParamJSON().toJSONString() );
//注解备注
sysLog.setMethodRemark(getAnnotationRemark(joinPoint));
//包名 方法名
String methodName = joinPoint.getSignature().getName();
String packageName = joinPoint.getThis().getClass().getName();
if (packageName.indexOf("$$EnhancerByCGLIB$$") > -1 || packageName.indexOf("$$EnhancerBySpringCGLIB$$") > -1) { // 如果是CGLIB动态生成的类
packageName = packageName.substring(0, packageName.indexOf("$$"));
}
sysLog.setMethodName(packageName + "." + methodName);
sysLog.setReqUrl(request.getRequestURL().toString());
sysLog.setUserIp(requestKitBean.getClientIp());
sysLog.setCreatedAt(new Date());
sysLog.setSysType(CS.SYS_TYPE.MCH);
if (userDetails != null) {
sysLog.setUserId(JeeUserDetails.getCurrentUserDetails().getSysUser().getSysUserId());
sysLog.setUserName(JeeUserDetails.getCurrentUserDetails().getSysUser().getRealname());
sysLog.setSysType(JeeUserDetails.getCurrentUserDetails().getSysUser().getSysType());
}
}
}
|
final SysLog sysLog = new SysLog();
//处理切面任务 发生异常将向外抛出 不记录日志
Object result = point.proceed();
try {
// 基础日志信息
setBaseLogInfo(point, sysLog, JeeUserDetails.getCurrentUserDetails());
sysLog.setOptResInfo(JSONObject.toJSON(result).toString());
scheduledThreadPool.execute(new Runnable() {
@Override
public void run() {
sysLogService.save(sysLog);
}
});
} catch (Exception e) {
logger.error("methodLogError", e);
}
return result;
| 1,078
| 176
| 1,254
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/bootstrap/InitRunner.java
|
InitRunner
|
run
|
class InitRunner implements CommandLineRunner {
@Autowired private SystemYmlConfig systemYmlConfig;
@Override
public void run(String... args) throws Exception {<FILL_FUNCTION_BODY>}
}
|
// 配置是否使用缓存模式
SysConfigService.IS_USE_CACHE = systemYmlConfig.getCacheConfig();
//初始化处理fastjson格式
SerializeConfig serializeConfig = SerializeConfig.getGlobalInstance();
serializeConfig.put(Date.class, new SimpleDateFormatSerializer(DatePattern.NORM_DATETIME_PATTERN));
//解决json 序列化时候的 $ref:问题
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
| 59
| 146
| 205
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/bootstrap/JeepayMchApplication.java
|
JeepayMchApplication
|
knife4jDockerBean
|
class JeepayMchApplication {
/** main启动函数 **/
public static void main(String[] args) {
//启动项目
SpringApplication.run(JeepayMchApplication.class, args);
}
/** fastJson 配置信息 **/
@Bean
public HttpMessageConverters fastJsonConfig(){
//新建fast-json转换器
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
// 开启 FastJSON 安全模式!
ParserConfig.getGlobalInstance().setSafeMode(true);
//fast-json 配置信息
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
converter.setFastJsonConfig(config);
//设置响应的 Content-Type
converter.setSupportedMediaTypes(Arrays.asList(new MediaType[]{MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_UTF8}));
return new HttpMessageConverters(converter);
}
/** Mybatis plus 分页插件 **/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
return paginationInterceptor;
}
/**
* 功能描述: API访问地址: http://localhost:9218/doc.html
*
* @Return: springfox.documentation.spring.web.plugins.Docket
* @Author: terrfly
* @Date: 2023/6/13 15:04
*/
@Bean(value = "knife4jDockerBean")
public Docket knife4jDockerBean() {<FILL_FUNCTION_BODY>}
}
|
return new Docket(DocumentationType.SWAGGER_2) //指定使用Swagger2规范
.apiInfo(new ApiInfoBuilder().version("1.0").build()) //描述字段支持Markdown语法
.groupName("商户平台") //分组名称
.select() // 配置: 如何扫描
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 只扫描: ApiOperation 注解文档。 也支持配置包名、 路径等扫描模式。
.build();
| 558
| 143
| 701
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/config/RedisConfig.java
|
RedisConfig
|
sysStringRedisTemplate
|
class RedisConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private Integer port;
@Value("${spring.redis.timeout}")
private Integer timeout;
@Value("${spring.redis.database}")
private Integer defaultDatabase;
@Value("${spring.redis.password}")
private String password;
/** 当前系统的redis缓存操作对象 (主对象) **/
@Primary
@Bean(name = "defaultStringRedisTemplate")
public StringRedisTemplate sysStringRedisTemplate() {<FILL_FUNCTION_BODY>}
}
|
StringRedisTemplate template = new StringRedisTemplate();
LettuceConnectionFactory jedisConnectionFactory = new LettuceConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(port);
jedisConnectionFactory.setTimeout(timeout);
if (!StringUtils.isEmpty(password)) {
jedisConnectionFactory.setPassword(password);
}
if (defaultDatabase != 0) {
jedisConnectionFactory.setDatabase(defaultDatabase);
}
jedisConnectionFactory.afterPropertiesSet();
template.setConnectionFactory(jedisConnectionFactory);
return template;
| 184
| 169
| 353
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/CommonCtrl.java
|
CommonCtrl
|
checkIsAdmin
|
class CommonCtrl extends AbstractCtrl {
@Autowired
protected SystemYmlConfig mainConfig;
@Autowired
private SysConfigService sysConfigService;
/** 获取当前用户ID */
protected JeeUserDetails getCurrentUser(){
return (JeeUserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
/** 获取当前商户ID **/
protected String getCurrentMchNo() {
return getCurrentUser().getSysUser().getBelongInfoId();
}
/**
* 获取当前用户登录IP
* @return
*/
protected String getIp() {
return getClientIp();
}
/**
* 校验当前用户是否为超管
* @return
*/
protected ApiRes checkIsAdmin() {<FILL_FUNCTION_BODY>}
}
|
SysUser sysUser = getCurrentUser().getSysUser();
if (sysUser.getIsAdmin() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_PERMISSION_ERROR);
}else {
return null;
}
| 227
| 75
| 302
|
<methods>public non-sealed void <init>() ,public java.lang.Long getAmountL(java.lang.String) ,public java.lang.String getClientIp() ,public java.lang.Long getRequiredAmountL(java.lang.String) ,public java.lang.String getUserAgent() ,public transient void handleParamAmount(java.lang.String[]) ,public Map<java.lang.String,java.lang.Object> request2payResponseMap(HttpServletRequest, java.lang.String[]) <variables>private static final int DEFAULT_PAGE_INDEX,private static final int DEFAULT_PAGE_SIZE,private static final java.lang.String PAGE_INDEX_PARAM_NAME,private static final java.lang.String PAGE_SIZE_PARAM_NAME,private static final java.lang.String SORT_FIELD_PARAM_NAME,private static final java.lang.String SORT_ORDER_FLAG_PARAM_NAME,protected static final Logger logger,protected HttpServletRequest request,protected com.jeequan.jeepay.core.beans.RequestKitBean requestKitBean,protected HttpServletResponse response
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/CurrentUserController.java
|
CurrentUserController
|
currentUserInfo
|
class CurrentUserController extends CommonCtrl{
@Autowired private SysEntitlementService sysEntitlementService;
@Autowired private SysUserService sysUserService;
@Autowired private SysUserAuthService sysUserAuthService;
@ApiOperation("查询当前登录者的用户信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@RequestMapping(value="/user", method = RequestMethod.GET)
public ApiRes currentUserInfo() {<FILL_FUNCTION_BODY>}
/** 修改个人信息 */
@ApiOperation("修改个人信息--基本信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "avatarUrl", value = "头像地址"),
@ApiImplicitParam(name = "realname", value = "真实姓名"),
@ApiImplicitParam(name = "sex", value = "性别 0-未知, 1-男, 2-女")
})
@MethodLog(remark = "修改个人信息")
@RequestMapping(value="/user", method = RequestMethod.PUT)
public ApiRes modifyCurrentUserInfo() {
//修改头像
String avatarUrl = getValString("avatarUrl");
String realname = getValString("realname");
Byte sex = getValByte("sex");
SysUser updateRecord = new SysUser();
updateRecord.setSysUserId(getCurrentUser().getSysUser().getSysUserId());
if (StringUtils.isNotEmpty(avatarUrl)) {
updateRecord.setAvatarUrl(avatarUrl);
}
if (StringUtils.isNotEmpty(realname)) {
updateRecord.setRealname(realname);
}
if (sex != null) {
updateRecord.setSex(sex);
}
sysUserService.updateById(updateRecord);
//保存redis最新数据
JeeUserDetails currentUser = getCurrentUser();
currentUser.setSysUser(sysUserService.getById(getCurrentUser().getSysUser().getSysUserId()));
ITokenService.refData(currentUser);
return ApiRes.ok();
}
/** modifyPwd */
@ApiOperation("修改个人信息--安全信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "confirmPwd", value = "新密码"),
@ApiImplicitParam(name = "originalPwd", value = "原密码")
})
@MethodLog(remark = "修改密码")
@RequestMapping(value="modifyPwd", method = RequestMethod.PUT)
public ApiRes modifyPwd() throws BizException{
Long opSysUserId = getValLongRequired("recordId"); //操作员ID
//更改密码,验证当前用户信息
String currentUserPwd = Base64.decodeStr(getValStringRequired("originalPwd")); //当前用户登录密码
//验证当前密码是否正确
if(!sysUserAuthService.validateCurrentUserPwd(currentUserPwd)){
throw new BizException("原密码验证失败!");
}
String opUserPwd = Base64.decodeStr(getValStringRequired("confirmPwd"));
// 验证原密码与新密码是否相同
if (opUserPwd.equals(currentUserPwd)) {
throw new BizException("新密码与原密码不能相同!");
}
sysUserAuthService.resetAuthInfo(opSysUserId, null, null, opUserPwd, CS.SYS_TYPE.MCH);
//调用登出接口
return logout();
}
/** 登出 */
@ApiOperation("退出登录")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@MethodLog(remark = "退出")
@RequestMapping(value="logout", method = RequestMethod.POST)
public ApiRes logout() throws BizException{
ITokenService.removeIToken(getCurrentUser().getCacheKey(), getCurrentUser().getSysUser().getSysUserId());
return ApiRes.ok();
}
}
|
///当前用户信息
JeeUserDetails jeeUserDetails = getCurrentUser();
SysUser user = jeeUserDetails.getSysUser();
//1. 当前用户所有权限ID集合
List<String> entIdList = new ArrayList<>();
jeeUserDetails.getAuthorities().stream().forEach(r->entIdList.add(r.getAuthority()));
List<SysEntitlement> allMenuList = new ArrayList<>(); //所有菜单集合
//2. 查询出用户所有菜单集合 (包含左侧显示菜单 和 其他类型菜单 )
if(!entIdList.isEmpty()){
allMenuList = sysEntitlementService.list(SysEntitlement.gw()
.in(SysEntitlement::getEntId, entIdList)
.in(SysEntitlement::getEntType, Arrays.asList(CS.ENT_TYPE.MENU_LEFT, CS.ENT_TYPE.MENU_OTHER))
.eq(SysEntitlement::getSysType, CS.SYS_TYPE.MCH)
.eq(SysEntitlement::getState, CS.PUB_USABLE));
}
//4. 转换为json树状结构
JSONArray jsonArray = (JSONArray) JSON.toJSON(allMenuList);
List<JSONObject> allMenuRouteTree = new TreeDataBuilder(jsonArray,
"entId", "pid", "children", "entSort", true)
.buildTreeObject();
//1. 所有权限ID集合
user.addExt("entIdList", entIdList);
user.addExt("allMenuRouteTree", allMenuRouteTree);
return ApiRes.ok(getCurrentUser().getSysUser());
| 1,172
| 462
| 1,634
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/anon/AuthController.java
|
AuthController
|
validate
|
class AuthController extends CommonCtrl {
@Autowired private AuthService authService;
/** 用户信息认证 获取iToken **/
@ApiOperation("登录认证")
@ApiImplicitParams({
@ApiImplicitParam(name = "ia", value = "用户名 i account, 需要base64处理", required = true),
@ApiImplicitParam(name = "ip", value = "密码 i passport, 需要base64处理", required = true),
@ApiImplicitParam(name = "vc", value = "证码 vercode, 需要base64处理", required = true),
@ApiImplicitParam(name = "vt", value = "验证码token, vercode token , 需要base64处理", required = true)
})
@RequestMapping(value = "/validate", method = RequestMethod.POST)
@MethodLog(remark = "登录认证")
public ApiRes validate() throws BizException {<FILL_FUNCTION_BODY>}
/** 图片验证码 **/
@ApiOperation("图片验证码")
@RequestMapping(value = "/vercode", method = RequestMethod.GET)
public ApiRes vercode() throws BizException {
//定义图形验证码的长和宽 // 4位验证码
LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(137, 40, 4, 80);
lineCaptcha.createCode(); //生成code
//redis
String vercodeToken = UUID.fastUUID().toString();
RedisUtil.setString(CS.getCacheKeyImgCode(vercodeToken), lineCaptcha.getCode(), CS.VERCODE_CACHE_TIME ); //图片验证码缓存时间: 1分钟
JSONObject result = new JSONObject();
result.put("imageBase64Data", lineCaptcha.getImageBase64Data());
result.put("vercodeToken", vercodeToken);
result.put("expireTime", CS.VERCODE_CACHE_TIME);
return ApiRes.ok(result);
}
}
|
String account = Base64.decodeStr(getValStringRequired("ia")); //用户名 i account, 已做base64处理
String ipassport = Base64.decodeStr(getValStringRequired("ip")); //密码 i passport, 已做base64处理
String vercode = Base64.decodeStr(getValStringRequired("vc")); //验证码 vercode, 已做base64处理
String vercodeToken = Base64.decodeStr(getValStringRequired("vt")); //验证码token, vercode token , 已做base64处理
String cacheCode = RedisUtil.getString(CS.getCacheKeyImgCode(vercodeToken));
if(StringUtils.isEmpty(cacheCode) || !cacheCode.equalsIgnoreCase(vercode)){
throw new BizException("验证码有误!");
}
// 返回前端 accessToken
String accessToken = authService.auth(account, ipassport);
// 删除图形验证码缓存数据
RedisUtil.del(CS.getCacheKeyImgCode(vercodeToken));
return ApiRes.ok4newJson(CS.ACCESS_TOKEN_NAME, accessToken);
| 529
| 306
| 835
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/division/PayOrderDivisionRecordController.java
|
PayOrderDivisionRecordController
|
list
|
class PayOrderDivisionRecordController extends CommonCtrl {
@Autowired private PayOrderDivisionRecordService payOrderDivisionRecordService;
@Autowired private IMQSender mqSender;
/** list */
@ApiOperation("分账记录列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "receiverId", value = "账号快照》 分账接收者ID", dataType = "Long"),
@ApiImplicitParam(name = "state", value = "状态: 0-待分账 1-分账成功, 2-分账失败", dataType = "Byte"),
@ApiImplicitParam(name = "receiverGroupId", value = "账号组ID", dataType = "Long"),
@ApiImplicitParam(name = "accNo", value = "账号快照》 分账接收账号"),
@ApiImplicitParam(name = "payOrderId", value = "系统支付订单号")
})
@PreAuthorize("hasAnyAuthority( 'ENT_DIVISION_RECORD_LIST' )")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<PayOrderDivisionRecord> list() {<FILL_FUNCTION_BODY>}
/** detail */
@ApiOperation("分账记录详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "recordId", value = "分账记录ID", required = true, dataType = "Long")
})
@PreAuthorize("hasAuthority( 'ENT_DIVISION_RECORD_VIEW' )")
@RequestMapping(value="/{recordId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("recordId") Long recordId) {
PayOrderDivisionRecord record = payOrderDivisionRecordService
.getOne(PayOrderDivisionRecord.gw()
.eq(PayOrderDivisionRecord::getMchNo, getCurrentMchNo())
.eq(PayOrderDivisionRecord::getRecordId, recordId));
if (record == null) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(record);
}
/** 分账接口重试 */
@ApiOperation("分账接口重试")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "recordId", value = "分账记录ID", required = true, dataType = "Long")
})
@PreAuthorize("hasAuthority( 'ENT_DIVISION_RECORD_RESEND' )")
@RequestMapping(value="/resend/{recordId}", method = RequestMethod.POST)
public ApiRes resend(@PathVariable("recordId") Long recordId) {
PayOrderDivisionRecord record = payOrderDivisionRecordService
.getOne(PayOrderDivisionRecord.gw()
.eq(PayOrderDivisionRecord::getMchNo, getCurrentMchNo())
.eq(PayOrderDivisionRecord::getRecordId, recordId));
if (record == null) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
if(record.getState() != PayOrderDivisionRecord.STATE_FAIL){
throw new BizException("请选择失败的分账记录");
}
// 更新订单状态 & 记录状态
payOrderDivisionRecordService.updateResendState(record.getPayOrderId());
// 重发到MQ
mqSender.send(PayOrderDivisionMQ.build(record.getPayOrderId(), null, null, true));
return ApiRes.ok(record);
}
}
|
PayOrderDivisionRecord queryObject = getObject(PayOrderDivisionRecord.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<PayOrderDivisionRecord> condition = PayOrderDivisionRecord.gw();
condition.eq(PayOrderDivisionRecord::getMchNo, getCurrentMchNo());
if(queryObject.getReceiverId() != null){
condition.eq(PayOrderDivisionRecord::getReceiverId, queryObject.getReceiverId());
}
if(queryObject.getReceiverGroupId() != null){
condition.eq(PayOrderDivisionRecord::getReceiverGroupId, queryObject.getReceiverGroupId());
}
if(StringUtils.isNotEmpty(queryObject.getAppId())){
condition.like(PayOrderDivisionRecord::getAppId, queryObject.getAppId());
}
if(queryObject.getState() != null){
condition.eq(PayOrderDivisionRecord::getState, queryObject.getState());
}
if(StringUtils.isNotEmpty(queryObject.getPayOrderId())){
condition.eq(PayOrderDivisionRecord::getPayOrderId, queryObject.getPayOrderId());
}
if(StringUtils.isNotEmpty(queryObject.getAccNo())){
condition.eq(PayOrderDivisionRecord::getAccNo, queryObject.getAccNo());
}
if (paramJSON != null) {
if (StringUtils.isNotEmpty(paramJSON.getString("createdStart"))) {
condition.ge(PayOrderDivisionRecord::getCreatedAt, paramJSON.getString("createdStart"));
}
if (StringUtils.isNotEmpty(paramJSON.getString("createdEnd"))) {
condition.le(PayOrderDivisionRecord::getCreatedAt, paramJSON.getString("createdEnd"));
}
}
condition.orderByDesc(PayOrderDivisionRecord::getCreatedAt); //时间倒序
IPage<PayOrderDivisionRecord> pages = payOrderDivisionRecordService.page(getIPage(true), condition);
return ApiPageRes.pages(pages);
| 1,253
| 549
| 1,802
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/merchant/MainChartController.java
|
MainChartController
|
userDetail
|
class MainChartController extends CommonCtrl {
@Autowired private PayOrderService payOrderService;
@Autowired private SysUserService sysUserService;
@Autowired private MchInfoService mchInfoService;
/** 周交易总金额 */
@ApiOperation("周交易总金额")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@PreAuthorize("hasAuthority('ENT_MCH_MAIN_PAY_AMOUNT_WEEK')")
@RequestMapping(value="/payAmountWeek", method = RequestMethod.GET)
public ApiRes payAmountWeek() {
return ApiRes.ok(payOrderService.mainPageWeekCount(getCurrentMchNo()));
}
/**
* 商户总数量、服务商总数量、总交易金额、总交易笔数
* @return
*/
@ApiOperation("商户总数量、服务商总数量、总交易金额、总交易笔数")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@PreAuthorize("hasAuthority('ENT_MCH_MAIN_NUMBER_COUNT')")
@RequestMapping(value="/numCount", method = RequestMethod.GET)
public ApiRes numCount() {
return ApiRes.ok(payOrderService.mainPageNumCount(getCurrentMchNo()));
}
/** 交易统计 */
@ApiOperation("交易统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--开始时间,须和结束时间一起使用,否则默认查最近七天(含今天)"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--结束时间,须和开始时间一起使用,否则默认查最近七天(含今天)")
})
@PreAuthorize("hasAuthority('ENT_MCH_MAIN_PAY_COUNT')")
@RequestMapping(value="/payCount", method = RequestMethod.GET)
public ApiRes<List<Map>> payCount() {
// 获取传入参数
JSONObject paramJSON = getReqParamJSON();
String createdStart = paramJSON.getString("createdStart");
String createdEnd = paramJSON.getString("createdEnd");
List<Map> mapList = payOrderService.mainPagePayCount(getCurrentMchNo(), createdStart, createdEnd);
//返回数据
return ApiRes.ok(mapList);
}
/** 支付方式统计 */
@ApiOperation("支付方式统计")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--开始时间,须和结束时间一起使用,否则默认查最近七天(含今天)"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd),时间范围查询--结束时间,须和开始时间一起使用,否则默认查最近七天(含今天)")
})
@PreAuthorize("hasAuthority('ENT_MCH_MAIN_PAY_TYPE_COUNT')")
@RequestMapping(value="/payTypeCount", method = RequestMethod.GET)
public ApiRes<ArrayList> payWayCount() {
JSONObject paramJSON = getReqParamJSON();
// 开始、结束时间
String createdStart = paramJSON.getString("createdStart");
String createdEnd = paramJSON.getString("createdEnd");
ArrayList arrayResult = payOrderService.mainPagePayTypeCount(getCurrentMchNo(), createdStart, createdEnd);
return ApiRes.ok(arrayResult);
}
/** 商户基本信息、用户基本信息 **/
@ApiOperation("商户基本信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header")
})
@PreAuthorize("hasAuthority('ENT_MCH_MAIN_USER_INFO')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiRes userDetail() {<FILL_FUNCTION_BODY>}
}
|
SysUser sysUser = sysUserService.getById(getCurrentUser().getSysUser().getSysUserId());
MchInfo mchInfo = mchInfoService.getById(getCurrentMchNo());
JSONObject json = (JSONObject) JSON.toJSON(mchInfo);
json.put("loginUsername", sysUser.getLoginUsername());
json.put("realname", sysUser.getRealname());
return ApiRes.ok(json);
| 1,220
| 120
| 1,340
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/merchant/MchAppController.java
|
MchAppController
|
add
|
class MchAppController extends CommonCtrl {
@Autowired private MchAppService mchAppService;
@Autowired private IMQSender mqSender;
/**
* @Author: ZhuXiao
* @Description: 应用列表
* @Date: 9:59 2021/6/16
*/
@ApiOperation("查询应用列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "appName", value = "应用名称"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_LIST')")
@GetMapping
public ApiPageRes<MchApp> list() {
MchApp mchApp = getObject(MchApp.class);
mchApp.setMchNo(getCurrentMchNo());
IPage<MchApp> pages = mchAppService.selectPage(getIPage(true), mchApp);
return ApiPageRes.pages(pages);
}
/**
* @Author: ZhuXiao
* @Description: 新建应用
* @Date: 10:05 2021/6/16
*/
@ApiOperation("新建应用")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appName", value = "应用名称", required = true),
@ApiImplicitParam(name = "appSecret", value = "应用私钥", required = true),
@ApiImplicitParam(name = "remark", value = "备注"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_ADD')")
@MethodLog(remark = "新建应用")
@PostMapping
public ApiRes add() {<FILL_FUNCTION_BODY>}
/**
* @Author: ZhuXiao
* @Description: 应用详情
* @Date: 10:13 2021/6/16
*/
@ApiOperation("应用详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true)
})
@PreAuthorize("hasAnyAuthority('ENT_MCH_APP_VIEW', 'ENT_MCH_APP_EDIT')")
@GetMapping("/{appId}")
public ApiRes detail(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.selectById(appId);
if (mchApp == null || !mchApp.getMchNo().equals(getCurrentMchNo())) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(mchApp);
}
/**
* @Author: ZhuXiao
* @Description: 更新应用信息
* @Date: 10:11 2021/6/16
*/
@ApiOperation("更新应用信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "appName", value = "应用名称", required = true),
@ApiImplicitParam(name = "appSecret", value = "应用私钥", required = true),
@ApiImplicitParam(name = "remark", value = "备注"),
@ApiImplicitParam(name = "state", value = "状态: 0-停用, 1-启用", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_EDIT')")
@MethodLog(remark = "更新应用信息")
@PutMapping("/{appId}")
public ApiRes update(@PathVariable("appId") String appId) {
MchApp mchApp = getObject(MchApp.class);
mchApp.setAppId(appId);
MchApp dbRecord = mchAppService.getById(appId);
if (!dbRecord.getMchNo().equals(getCurrentMchNo())) {
throw new BizException("无权操作!");
}
boolean result = mchAppService.updateById(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_UPDATE);
}
// 推送修改应用消息
mqSender.send(ResetIsvMchAppInfoConfigMQ.build(ResetIsvMchAppInfoConfigMQ.RESET_TYPE_MCH_APP, null, mchApp.getMchNo(), appId));
return ApiRes.ok();
}
/**
* @Author: ZhuXiao
* @Description: 删除应用
* @Date: 10:14 2021/6/16
*/
@ApiOperation("删除应用")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_APP_DEL')")
@MethodLog(remark = "删除应用")
@DeleteMapping("/{appId}")
public ApiRes delete(@PathVariable("appId") String appId) {
MchApp mchApp = mchAppService.getById(appId);
if (!mchApp.getMchNo().equals(getCurrentMchNo())) {
throw new BizException("无权操作!");
}
mchAppService.removeByAppId(appId);
// 推送mq到目前节点进行更新数据
mqSender.send(ResetIsvMchAppInfoConfigMQ.build(ResetIsvMchAppInfoConfigMQ.RESET_TYPE_MCH_APP, null, mchApp.getMchNo(), appId));
return ApiRes.ok();
}
}
|
MchApp mchApp = getObject(MchApp.class);
mchApp.setMchNo(getCurrentMchNo());
mchApp.setAppId(IdUtil.objectId());
boolean result = mchAppService.save(mchApp);
if (!result) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_CREATE);
}
return ApiRes.ok();
| 1,841
| 115
| 1,956
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/merchant/MchPayPassageConfigController.java
|
MchPayPassageConfigController
|
availablePayInterface
|
class MchPayPassageConfigController extends CommonCtrl {
@Autowired private MchPayPassageService mchPayPassageService;
@Autowired private PayWayService payWayService;
@Autowired private MchInfoService mchInfoService;
/**
* @Author: ZhuXiao
* @Description: 查询支付方式列表,并添加是否配置支付通道状态
* @Date: 10:58 2021/5/13
*/
@ApiOperation("查询支付方式列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码"),
@ApiImplicitParam(name = "wayName", value = "支付方式名称")
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_LIST')")
@GetMapping
public ApiPageRes<PayWay> list() {
String appId = getValStringRequired("appId");
String wayCode = getValString("wayCode");
String wayName = getValString("wayName");
//支付方式集合
LambdaQueryWrapper<PayWay> wrapper = PayWay.gw();
if (StrUtil.isNotBlank(wayCode)) {
wrapper.eq(PayWay::getWayCode, wayCode);
}
if (StrUtil.isNotBlank(wayName)) {
wrapper.like(PayWay::getWayName, wayName);
}
IPage<PayWay> payWayPage = payWayService.page(getIPage(), wrapper);
if (!CollectionUtils.isEmpty(payWayPage.getRecords())) {
// 支付方式代码集合
List<String> wayCodeList = new LinkedList<>();
payWayPage.getRecords().stream().forEach(payWay -> wayCodeList.add(payWay.getWayCode()));
// 商户支付通道集合
List<MchPayPassage> mchPayPassageList = mchPayPassageService.list(MchPayPassage.gw()
.select(MchPayPassage::getWayCode, MchPayPassage::getState)
.eq(MchPayPassage::getAppId, appId)
.eq(MchPayPassage::getMchNo, getCurrentMchNo())
.in(MchPayPassage::getWayCode, wayCodeList));
for (PayWay payWay : payWayPage.getRecords()) {
payWay.addExt("passageState", CS.NO);
for (MchPayPassage mchPayPassage : mchPayPassageList) {
// 某种支付方式多个通道的情况下,只要有一个通道状态为开启,则该支付方式对应为开启状态
if (payWay.getWayCode().equals(mchPayPassage.getWayCode()) && mchPayPassage.getState() == CS.YES) {
payWay.addExt("passageState", CS.YES);
break;
}
}
}
}
return ApiPageRes.pages(payWayPage);
}
/**
* @Author: ZhuXiao
* @Description: 根据appId、支付方式查询可用的支付接口列表
* @Date: 11:05 2021/5/13
* @return
*/
@ApiOperation("根据[应用ID]、[支付方式代码]查询可用的支付接口列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_CONFIG')")
@GetMapping("/availablePayInterface/{appId}/{wayCode}")
public ApiRes availablePayInterface(@PathVariable("appId") String appId, @PathVariable("wayCode") String wayCode) {<FILL_FUNCTION_BODY>}
/**
* @Author: ZhuXiao
* @Description:
* @Date: 11:05 2021/5/13
*/
@ApiOperation("商户支付通道详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "id", value = "支付通道ID", required = true)
})
@GetMapping("/{id}")
public ApiRes detail(@PathVariable("id") Long id) {
MchPayPassage payPassage = mchPayPassageService.getById(id);
if (payPassage == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
if (!payPassage.getMchNo().equals(getCurrentUser().getSysUser().getBelongInfoId())) {
return ApiRes.fail(ApiCodeEnum.SYS_PERMISSION_ERROR);
}
payPassage.setRate(payPassage.getRate().multiply(new BigDecimal("100")));
return ApiRes.ok(payPassage);
}
/**
* @Author: ZhuXiao
* @Description: 应用支付通道配置
* @Date: 11:05 2021/5/13
*/
@ApiOperation("更新商户支付通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "reqParams", value = "商户支付通道配置信息", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_PASSAGE_ADD')")
@PostMapping
@MethodLog(remark = "更新应用支付通道")
public ApiRes saveOrUpdate() {
String reqParams = getValStringRequired("reqParams");
try {
List<MchPayPassage> mchPayPassageList = JSONArray.parseArray(reqParams, MchPayPassage.class);
mchPayPassageService.saveOrUpdateBatchSelf(mchPayPassageList, getCurrentMchNo());
return ApiRes.ok();
}catch (Exception e) {
return ApiRes.fail(ApiCodeEnum.SYSTEM_ERROR);
}
}
}
|
String mchNo = getCurrentUser().getSysUser().getBelongInfoId();
MchInfo mchInfo = mchInfoService.getById(mchNo);
if (mchInfo == null || mchInfo.getState() != CS.YES) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
// 根据支付方式查询可用支付接口列表
List<JSONObject> list = mchPayPassageService.selectAvailablePayInterfaceList(wayCode, appId, CS.INFO_TYPE_MCH_APP, mchInfo.getType());
return ApiRes.ok(list);
| 1,842
| 176
| 2,018
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/order/RefundOrderController.java
|
RefundOrderController
|
list
|
class RefundOrderController extends CommonCtrl {
@Autowired private RefundOrderService refundOrderService;
/**
* @Author: ZhuXiao
* @Description: 退款订单信息列表
* @Date: 10:44 2021/5/13
*/
@ApiOperation("退款订单信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "unionOrderId", value = "支付/退款订单号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "state", value = "退款状态:0-订单生成,1-退款中,2-退款成功,3-退款失败,4-退款任务关闭", dataType = "Byte"),
@ApiImplicitParam(name = "mchType", value = "类型: 1-普通商户, 2-特约商户(服务商模式)")
})
@PreAuthorize("hasAuthority('ENT_REFUND_LIST')")
@GetMapping
public ApiPageRes<RefundOrder> list() {<FILL_FUNCTION_BODY>}
/**
* @Author: ZhuXiao
* @Description: 退款订单信息
* @Date: 10:44 2021/5/13
*/
@ApiOperation("退款订单信息详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "refundOrderId", value = "退款订单号", required = true)
})
@PreAuthorize("hasAuthority('ENT_REFUND_ORDER_VIEW')")
@GetMapping("/{refundOrderId}")
public ApiRes detail(@PathVariable("refundOrderId") String refundOrderId) {
RefundOrder refundOrder = refundOrderService.getById(refundOrderId);
if (refundOrder == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
if (!refundOrder.getMchNo().equals(getCurrentUser().getSysUser().getBelongInfoId())) {
return ApiRes.fail(ApiCodeEnum.SYS_PERMISSION_ERROR);
}
return ApiRes.ok(refundOrder);
}
}
|
RefundOrder refundOrder = getObject(RefundOrder.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<RefundOrder> wrapper = RefundOrder.gw();
wrapper.eq(RefundOrder::getMchNo, getCurrentMchNo());
IPage<RefundOrder> pages = refundOrderService.pageList(getIPage(), wrapper, refundOrder, paramJSON);
return ApiPageRes.pages(pages);
| 853
| 118
| 971
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/order/TransferOrderController.java
|
TransferOrderController
|
detail
|
class TransferOrderController extends CommonCtrl {
@Autowired private TransferOrderService transferOrderService;
/** list **/
@ApiOperation("转账订单信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "createdStart", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--开始时间,查询范围:大于等于此时间"),
@ApiImplicitParam(name = "createdEnd", value = "日期格式字符串(yyyy-MM-dd HH:mm:ss),时间范围查询--结束时间,查询范围:小于等于此时间"),
@ApiImplicitParam(name = "unionOrderId", value = "转账/商户/渠道订单号"),
@ApiImplicitParam(name = "appId", value = "应用ID"),
@ApiImplicitParam(name = "state", value = "支付状态: 0-订单生成, 1-转账中, 2-转账成功, 3-转账失败, 4-订单关闭", dataType = "Byte")
})
@PreAuthorize("hasAuthority('ENT_TRANSFER_ORDER_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<TransferOrder> list() {
TransferOrder transferOrder = getObject(TransferOrder.class);
JSONObject paramJSON = getReqParamJSON();
LambdaQueryWrapper<TransferOrder> wrapper = TransferOrder.gw();
wrapper.eq(TransferOrder::getMchNo, getCurrentMchNo());
IPage<TransferOrder> pages = transferOrderService.pageList(getIPage(), wrapper, transferOrder, paramJSON);
return ApiPageRes.pages(pages);
}
/** detail **/
@ApiOperation("转账订单信息详情")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "recordId", value = "转账订单号", required = true)
})
@PreAuthorize("hasAuthority('ENT_TRANSFER_ORDER_VIEW')")
@RequestMapping(value="/{recordId}", method = RequestMethod.GET)
public ApiRes detail(@PathVariable("recordId") String transferId) {<FILL_FUNCTION_BODY>}
}
|
TransferOrder refundOrder = transferOrderService.queryMchOrder(getCurrentMchNo(), null, transferId);
if (refundOrder == null) {
return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
return ApiRes.ok(refundOrder);
| 728
| 83
| 811
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/payconfig/PayWayController.java
|
PayWayController
|
list
|
class PayWayController extends CommonCtrl {
@Autowired PayWayService payWayService;
@Autowired MchPayPassageService mchPayPassageService;
@Autowired PayOrderService payOrderService;
/**
* @Author: ZhuXiao
* @Description: list
* @Date: 15:52 2021/4/27
*/
@ApiOperation("支付方式列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "wayCode", value = "支付方式代码"),
@ApiImplicitParam(name = "wayName", value = "支付方式名称")
})
@PreAuthorize("hasAuthority('ENT_PAY_ORDER_SEARCH_PAY_WAY')")
@GetMapping
public ApiPageRes<PayWay> list() {<FILL_FUNCTION_BODY>}
}
|
PayWay queryObject = getObject(PayWay.class);
LambdaQueryWrapper<PayWay> condition = PayWay.gw();
if(StringUtils.isNotEmpty(queryObject.getWayCode())){
condition.like(PayWay::getWayCode, queryObject.getWayCode());
}
if(StringUtils.isNotEmpty(queryObject.getWayName())){
condition.like(PayWay::getWayName, queryObject.getWayName());
}
condition.orderByAsc(PayWay::getWayCode);
IPage<PayWay> pages = payWayService.page(getIPage(true), condition);
return ApiPageRes.pages(pages);
| 336
| 197
| 533
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/sysuser/SysEntController.java
|
SysEntController
|
showTree
|
class SysEntController extends CommonCtrl {
@Autowired SysEntitlementService sysEntitlementService;
/** 查询权限集合 */
@ApiOperation("查询权限集合")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "sysType", value = "所属系统: MGR-运营平台, MCH-商户中心", required = true)
})
@PreAuthorize("hasAnyAuthority( 'ENT_UR_ROLE_ENT_LIST', 'ENT_UR_ROLE_DIST' )")
@RequestMapping(value="/showTree", method = RequestMethod.GET)
public ApiRes<List<JSONObject>> showTree() {<FILL_FUNCTION_BODY>}
}
|
//查询全部数据
List<SysEntitlement> list = sysEntitlementService.list(SysEntitlement.gw().eq(SysEntitlement::getSysType, CS.SYS_TYPE.MCH));
//4. 转换为json树状结构
JSONArray jsonArray = (JSONArray) JSONArray.toJSON(list);
List<JSONObject> leftMenuTree = new TreeDataBuilder(jsonArray,
"entId", "pid", "children", "entSort", true)
.buildTreeObject();
return ApiRes.ok(leftMenuTree);
| 217
| 157
| 374
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/sysuser/SysRoleEntRelaController.java
|
SysRoleEntRelaController
|
relas
|
class SysRoleEntRelaController extends CommonCtrl {
@Autowired private SysRoleEntRelaService sysRoleEntRelaService;
@Autowired private SysUserRoleRelaService sysUserRoleRelaService;
@Autowired private SysRoleService sysRoleService;
@Autowired private AuthService authService;
/** list */
@ApiOperation("关联关系--角色-权限关联信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "roleId", value = "角色ID, ROLE_开头")
})
@PreAuthorize("hasAuthority( 'ENT_UR_ROLE_DIST' )")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<SysRoleEntRela> list() {
SysRoleEntRela queryObject = getObject(SysRoleEntRela.class);
LambdaQueryWrapper<SysRoleEntRela> condition = SysRoleEntRela.gw();
if(queryObject.getRoleId() != null){
condition.eq(SysRoleEntRela::getRoleId, queryObject.getRoleId());
}
IPage<SysRoleEntRela> pages = sysRoleEntRelaService.page(getIPage(true), condition);
return ApiPageRes.pages(pages);
}
/** 重置角色权限关联信息 */
@PreAuthorize("hasAuthority( 'ENT_UR_ROLE_DIST' )")
@RequestMapping(value="relas/{roleId}", method = RequestMethod.POST)
public ApiRes relas(@PathVariable("roleId") String roleId) {<FILL_FUNCTION_BODY>}
}
|
SysRole sysRole = sysRoleService.getOne(SysRole.gw().eq(SysRole::getRoleId, roleId).eq(SysRole::getBelongInfoId, getCurrentMchNo()));
if (sysRole == null) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
List<String> entIdList = JSONArray.parseArray(getValStringRequired("entIdListStr"), String.class);
sysRoleEntRelaService.resetRela(roleId, entIdList);
List<Long> sysUserIdList = new ArrayList<>();
sysUserRoleRelaService.list(SysUserRoleRela.gw().eq(SysUserRoleRela::getRoleId, roleId)).stream().forEach(item -> sysUserIdList.add(item.getUserId()));
//查询到该角色的人员, 将redis更新
authService.refAuthentication(sysUserIdList);
return ApiRes.ok();
| 542
| 266
| 808
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/sysuser/SysUserRoleRelaController.java
|
SysUserRoleRelaController
|
relas
|
class SysUserRoleRelaController extends CommonCtrl {
@Autowired private SysUserRoleRelaService sysUserRoleRelaService;
@Autowired private SysUserService sysUserService;
@Autowired private AuthService authService;
/** list */
@ApiOperation("关联关系--用户-角色关联信息列表")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "pageNumber", value = "分页页码", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "pageSize", value = "分页条数(-1时查全部数据)", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "userId", value = "用户ID")
})
@PreAuthorize("hasAuthority( 'ENT_UR_USER_UPD_ROLE' )")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiPageRes<SysUserRoleRela> list() {
SysUserRoleRela queryObject = getObject(SysUserRoleRela.class);
LambdaQueryWrapper<SysUserRoleRela> condition = SysUserRoleRela.gw();
if(queryObject.getUserId() != null){
condition.eq(SysUserRoleRela::getUserId, queryObject.getUserId());
}
IPage<SysUserRoleRela> pages = sysUserRoleRelaService.page(getIPage(true), condition);
return ApiPageRes.pages( pages);
}
/** 重置用户角色关联信息 */
@ApiOperation("更改用户角色信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "sysUserId", value = "用户ID", required = true),
@ApiImplicitParam(name = "roleIdListStr", value = "角色信息,eg:[str1,str2],字符串列表转成json字符串", required = true)
})
@PreAuthorize("hasAuthority( 'ENT_UR_USER_UPD_ROLE' )")
@RequestMapping(value="relas/{sysUserId}", method = RequestMethod.POST)
public ApiRes relas(@PathVariable("sysUserId") Long sysUserId) {<FILL_FUNCTION_BODY>}
}
|
SysUser dbRecord = sysUserService.getOne(SysUser.gw().eq(SysUser::getSysUserId, sysUserId).eq(SysUser::getBelongInfoId, getCurrentMchNo()));
if (dbRecord == null) {
throw new BizException(ApiCodeEnum.SYS_OPERATION_FAIL_SELETE);
}
List<String> roleIdList = JSONArray.parseArray(getValStringRequired("roleIdListStr"), String.class);
sysUserService.saveUserRole(sysUserId, roleIdList);
authService.refAuthentication(Arrays.asList(sysUserId));
return ApiRes.ok();
| 649
| 180
| 829
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/transfer/ChannelUserIdNotifyController.java
|
ChannelUserIdNotifyController
|
channelUserIdCallback
|
class ChannelUserIdNotifyController extends CommonCtrl {
@ApiOperation("(转账)获取用户ID - 回调函数")
@ApiImplicitParams({
@ApiImplicitParam(name = "extParam", value = "扩展参数"),
@ApiImplicitParam(name = "channelUserId", value = "用户userId"),
@ApiImplicitParam(name = "appId", value = "应用ID")
})
@RequestMapping("")
public String channelUserIdCallback() {<FILL_FUNCTION_BODY>}
}
|
try {
//请求参数
JSONObject params = getReqParamJSON();
String extParam = params.getString("extParam");
String channelUserId = params.getString("channelUserId");
String appId = params.getString("appId");
//推送到前端
WsChannelUserIdServer.sendMsgByAppAndCid(appId, extParam, channelUserId);
} catch (Exception e) {
request.setAttribute("errMsg", e.getMessage());
}
return "channelUser/getChannelUserIdPage";
| 141
| 144
| 285
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/transfer/MchTransferController.java
|
MchTransferController
|
doTransfer
|
class MchTransferController extends CommonCtrl {
@Autowired private MchAppService mchAppService;
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private PayInterfaceDefineService payInterfaceDefineService;
@Autowired private SysConfigService sysConfigService;
/** 查询商户对应应用下支持的支付通道 **/
@ApiOperation("查询商户对应应用下支持的支付通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_TRANSFER_IF_CODE_LIST')")
@GetMapping("/ifCodes/{appId}")
public ApiRes<List> ifCodeList(@PathVariable("appId") String appId) {
List<String> ifCodeList = new ArrayList<>();
payInterfaceConfigService.list(
PayInterfaceConfig.gw().select(PayInterfaceConfig::getIfCode)
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP)
.eq(PayInterfaceConfig::getInfoId, appId)
.eq(PayInterfaceConfig::getState, CS.PUB_USABLE)
).stream().forEach(r -> ifCodeList.add(r.getIfCode()));
if(ifCodeList.isEmpty()){
return ApiRes.ok(ifCodeList);
}
List<PayInterfaceDefine> result = payInterfaceDefineService.list(PayInterfaceDefine.gw().in(PayInterfaceDefine::getIfCode, ifCodeList));
return ApiRes.ok(result);
}
/** 获取渠道侧用户ID **/
@ApiOperation("获取渠道侧用户ID")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "appId", value = "应用ID", required = true),
@ApiImplicitParam(name = "ifCode", value = "接口类型代码", required = true),
@ApiImplicitParam(name = "extParam", value = "扩展参数", required = true)
})
@PreAuthorize("hasAuthority('ENT_MCH_TRANSFER_CHANNEL_USER')")
@GetMapping("/channelUserId")
public ApiRes channelUserId() {
String appId = getValStringRequired("appId");
MchApp mchApp = mchAppService.getById(appId);
if(mchApp == null || mchApp.getState() != CS.PUB_USABLE || !mchApp.getMchNo().equals(getCurrentMchNo())){
throw new BizException("商户应用不存在或不可用");
}
JSONObject param = getReqParamJSON();
param.put("mchNo", getCurrentMchNo());
param.put("appId", appId);
param.put("ifCode", getValStringRequired("ifCode"));
param.put("extParam", getValStringRequired("extParam"));
param.put("reqTime", System.currentTimeMillis() + "");
param.put("version", "1.0");
param.put("signType", "MD5");
DBApplicationConfig dbApplicationConfig = sysConfigService.getDBApplicationConfig();
param.put("redirectUrl", dbApplicationConfig.getMchSiteUrl() + "/api/anon/channelUserIdCallback");
param.put("sign", JeepayKit.getSign(param, mchApp.getAppSecret()));
String url = StringKit.appendUrlQuery(dbApplicationConfig.getPaySiteUrl() + "/api/channelUserId/jump", param);
return ApiRes.ok(url);
}
/** 调起下单接口 **/
@ApiOperation("调起转账接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "iToken", value = "用户身份凭证", required = true, paramType = "header"),
@ApiImplicitParam(name = "mchOrderNo", value = "商户订单号", required = true),
@ApiImplicitParam(name = "entryType", value = "入账方式: WX_CASH-微信零钱; ALIPAY_CASH-支付宝转账; BANK_CARD-银行卡", required = true),
@ApiImplicitParam(name = "ifCode", value = "接口类型代码", required = true),
@ApiImplicitParam(name = "amount", value = "转账金额,单位元", required = true),
@ApiImplicitParam(name = "accountNo", value = "收款账号", required = true),
@ApiImplicitParam(name = "accountName", value = "收款人姓名"),
@ApiImplicitParam(name = "bankName", value = "收款人开户行名称"),
@ApiImplicitParam(name = "clientIp", value = "客户端IP"),
@ApiImplicitParam(name = "transferDesc", value = "转账备注信息"),
@ApiImplicitParam(name = "notifyUrl", value = "通知地址"),
@ApiImplicitParam(name = "channelExtra", value = "特定渠道发起时额外参数"),
@ApiImplicitParam(name = "extParam", value = "扩展参数")
})
@PreAuthorize("hasAuthority('ENT_MCH_PAY_TEST_DO')")
@PostMapping("/doTransfer")
public ApiRes doTransfer() {<FILL_FUNCTION_BODY>}
}
|
handleParamAmount("amount");
TransferOrderCreateReqModel model = getObject(TransferOrderCreateReqModel.class);
MchApp mchApp = mchAppService.getById(model.getAppId());
if(mchApp == null || mchApp.getState() != CS.PUB_USABLE || !mchApp.getMchNo().equals(getCurrentMchNo()) ){
throw new BizException("商户应用不存在或不可用");
}
TransferOrderCreateRequest request = new TransferOrderCreateRequest();
model.setMchNo(this.getCurrentMchNo());
model.setAppId(mchApp.getAppId());
model.setCurrency("CNY");
request.setBizModel(model);
JeepayClient jeepayClient = new JeepayClient(sysConfigService.getDBApplicationConfig().getPaySiteUrl(), mchApp.getAppSecret());
try {
TransferOrderCreateResponse response = jeepayClient.execute(request);
if(response.getCode() != 0){
throw new BizException(response.getMsg());
}
return ApiRes.ok(response.get());
} catch (JeepayException e) {
throw new BizException(e.getMessage());
}
| 1,460
| 328
| 1,788
|
<methods>public non-sealed void <init>() <variables>protected com.jeequan.jeepay.mch.config.SystemYmlConfig mainConfig,private com.jeequan.jeepay.service.impl.SysConfigService sysConfigService
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/mq/CleanMchLoginAuthCacheMQReceiver.java
|
CleanMchLoginAuthCacheMQReceiver
|
receive
|
class CleanMchLoginAuthCacheMQReceiver implements CleanMchLoginAuthCacheMQ.IMQReceiver {
@Override
public void receive(CleanMchLoginAuthCacheMQ.MsgPayload payload) {<FILL_FUNCTION_BODY>}
}
|
log.info("成功接收删除商户用户登录的订阅通知, msg={}", payload);
// 字符串转List<Long>
List<Long> userIdList = payload.getUserIdList();
// 删除redis用户缓存
if(userIdList == null || userIdList.isEmpty()){
log.info("用户ID为空");
return ;
}
for (Long sysUserId : userIdList) {
Collection<String> cacheKeyList = RedisUtil.keys(CS.getCacheKeyToken(sysUserId, "*"));
if(cacheKeyList == null || cacheKeyList.isEmpty()){
continue;
}
for (String cacheKey : cacheKeyList) {
// 删除用户Redis信息
RedisUtil.del(cacheKey);
continue;
}
}
log.info("无权限登录用户信息已清除");
| 67
| 235
| 302
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/secruity/JeeAuthenticationEntryPoint.java
|
JeeAuthenticationEntryPoint
|
commence
|
class JeeAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
@Override
public void commence(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException authException) throws IOException {<FILL_FUNCTION_BODY>}
}
|
// This is invoked when user tries to access a secured REST resource without supplying any credentials
// We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
//返回json形式的错误信息
// response.setCharacterEncoding("UTF-8");
// response.setContentType("application/json");
// response.getWriter().println("{\"code\":1001, \"msg\":\"Unauthorized\"}");
response.getWriter().flush();
| 64
| 156
| 220
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/secruity/JeeAuthenticationTokenFilter.java
|
JeeAuthenticationTokenFilter
|
commonFilter
|
class JeeAuthenticationTokenFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
JeeUserDetails jeeUserDetails = commonFilter(request);
if(jeeUserDetails == null){
chain.doFilter(request, response);
return;
}
//将信息放置到Spring-security context中
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(jeeUserDetails, null, jeeUserDetails.getAuthorities());
authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(authentication);
chain.doFilter(request, response);
}
private JeeUserDetails commonFilter(HttpServletRequest request){<FILL_FUNCTION_BODY>}
}
|
String authToken = request.getHeader(CS.ACCESS_TOKEN_NAME);
if(StringUtils.isEmpty(authToken)){
authToken = request.getParameter(CS.ACCESS_TOKEN_NAME);
}
if(StringUtils.isEmpty(authToken)){
return null; //放行,并交给UsernamePasswordAuthenticationFilter进行验证,返回公共错误信息.
}
JWTPayload jwtPayload = JWTUtils.parseToken(authToken, SpringBeansUtil.getBean(SystemYmlConfig.class).getJwtSecret()); //反解析token信息
//token字符串解析失败
if( jwtPayload == null || StringUtils.isEmpty(jwtPayload.getCacheKey())) {
return null;
}
//根据用户名查找数据库
JeeUserDetails jwtBaseUser = RedisUtil.getObject(jwtPayload.getCacheKey(), JeeUserDetails.class);
if(jwtBaseUser == null){
RedisUtil.del(jwtPayload.getCacheKey());
return null; //数据库查询失败,删除redis
}
//续签时间
RedisUtil.expire(jwtPayload.getCacheKey(), CS.TOKEN_TIME);
return jwtBaseUser;
| 221
| 334
| 555
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/secruity/JeeUserDetailsServiceImpl.java
|
JeeUserDetailsServiceImpl
|
loadUserByUsername
|
class JeeUserDetailsServiceImpl implements UserDetailsService {
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserAuthService sysUserAuthService;
/**
*
* 此函数为: authenticationManager.authenticate(upToken) 内部调用 ;
* 需返回 用户信息载体 / 用户密码 。
* 用户角色+权限的封装集合 (暂时不查询, 在验证通过后再次查询,避免用户名密码输入有误导致查询资源浪费)
*
* **/
@Override
public UserDetails loadUserByUsername(String loginUsernameStr) throws UsernameNotFoundException {<FILL_FUNCTION_BODY>}
}
|
//登录方式, 默认为账号密码登录
Byte identityType = CS.AUTH_TYPE.LOGIN_USER_NAME;
if(RegKit.isMobile(loginUsernameStr)){
identityType = CS.AUTH_TYPE.TELPHONE; //手机号登录
}
//首先根据登录类型 + 用户名得到 信息
SysUserAuth auth = sysUserAuthService.selectByLogin(loginUsernameStr, identityType, CS.SYS_TYPE.MCH);
if(auth == null){ //没有该用户信息
throw JeepayAuthenticationException.build("用户名/密码错误!");
}
//用户ID
Long userId = auth.getUserId();
SysUser sysUser = sysUserService.getById(userId);
if (sysUser == null) {
throw JeepayAuthenticationException.build("用户名/密码错误!");
}
if(CS.PUB_USABLE != sysUser.getState()){ //状态不合法
throw JeepayAuthenticationException.build("用户状态不可登录,请联系管理员!");
}
return new JeeUserDetails(sysUser, auth.getCredential());
| 199
| 308
| 507
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/secruity/WebSecurityConfig.java
|
WebSecurityConfig
|
corsFilter
|
class WebSecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired private UserDetailsService userDetailsService;
@Autowired private JeeAuthenticationEntryPoint unauthorizedHandler;
@Autowired private SystemYmlConfig systemYmlConfig;
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
/**
* 使用BCrypt强哈希函数 实现PasswordEncoder
* **/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder
.userDetailsService(this.userDetailsService)
.passwordEncoder(passwordEncoder());
}
/** 允许跨域请求 **/
@Bean
public CorsFilter corsFilter() {<FILL_FUNCTION_BODY>}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
// 由于使用的是JWT,我们这里不需要csrf
.csrf().disable()
.cors().and()
// 认证失败处理方式
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
// 基于token,所以不需要session
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated();
// 添加JWT filter
httpSecurity.addFilterBefore(new JeeAuthenticationTokenFilter(), UsernamePasswordAuthenticationFilter.class);
// 禁用缓存
httpSecurity.headers().cacheControl();
}
@Override
public void configure(WebSecurity web) throws Exception {
//ignore文件 : 无需进入spring security 框架
// 1.允许对于网站静态资源的无授权访问
// 2.对于获取token的rest api要允许匿名访问
web.ignoring().antMatchers(
HttpMethod.GET,
"/",
"/*.html",
"/favicon.ico",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.png",
"/**/*.jpg",
"/**/*.jpeg",
"/**/*.svg",
"/**/*.ico",
"/**/*.webp",
"/*.txt",
"/**/*.xls",
"/**/*.mp4" //支持mp4格式的文件匿名访问
)
.antMatchers(
"/api/anon/**", //匿名访问接口
"/swagger-resources/**","/v2/api-docs/**" // swagger相关
);
}
}
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
if(systemYmlConfig.getAllowCors()){
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); //带上cookie信息
// config.addAllowedOrigin(CorsConfiguration.ALL); //允许跨域的域名, *表示允许任何域名使用
config.addAllowedOriginPattern(CorsConfiguration.ALL); //使用addAllowedOriginPattern 避免出现 When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
config.addAllowedHeader(CorsConfiguration.ALL); //允许任何请求头
config.addAllowedMethod(CorsConfiguration.ALL); //允许任何方法(post、get等)
source.registerCorsConfiguration("/**", config); // CORS 配置对所有接口都有效
}
return new CorsFilter(source);
| 736
| 274
| 1,010
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/service/AuthService.java
|
AuthService
|
auth
|
class AuthService {
@Resource
private AuthenticationManager authenticationManager;
@Autowired private SysUserService sysUserService;
@Autowired private SysRoleService sysRoleService;
@Autowired private SysRoleEntRelaService sysRoleEntRelaService;
@Autowired private MchInfoService mchInfoService;
@Autowired private SysEntitlementMapper sysEntitlementMapper;
@Autowired private SystemYmlConfig systemYmlConfig;
/**
* 认证
* **/
public String auth(String username, String password){<FILL_FUNCTION_BODY>}
/** 根据用户ID 更新缓存中的权限集合, 使得分配实时生效 **/
public void refAuthentication(List<Long> sysUserIdList){
if(sysUserIdList == null || sysUserIdList.isEmpty()){
return ;
}
Map<Long, SysUser> sysUserMap = new HashMap<>();
// 查询 sysUserId 和 state
sysUserService.list(
SysUser.gw()
.select(SysUser::getSysUserId, SysUser::getState)
.in(SysUser::getSysUserId, sysUserIdList)
).stream().forEach(item -> sysUserMap.put(item.getSysUserId(), item));
for (Long sysUserId : sysUserIdList) {
Collection<String> cacheKeyList = RedisUtil.keys(CS.getCacheKeyToken(sysUserId, "*"));
if(cacheKeyList == null || cacheKeyList.isEmpty()){
continue;
}
for (String cacheKey : cacheKeyList) {
//用户不存在 || 已禁用 需要删除Redis
if(sysUserMap.get(sysUserId) == null || sysUserMap.get(sysUserId).getState() == CS.PUB_DISABLE){
RedisUtil.del(cacheKey);
continue;
}
JeeUserDetails jwtBaseUser = RedisUtil.getObject(cacheKey, JeeUserDetails.class);
if(jwtBaseUser == null){
continue;
}
// 重新放置sysUser对象
jwtBaseUser.setSysUser(sysUserService.getById(sysUserId));
//查询放置权限数据
jwtBaseUser.setAuthorities(getUserAuthority(jwtBaseUser.getSysUser()));
//保存token 失效时间不变
RedisUtil.set(cacheKey, jwtBaseUser);
}
}
}
/** 根据用户ID 删除用户缓存信息 **/
public void delAuthentication(List<Long> sysUserIdList){
if(sysUserIdList == null || sysUserIdList.isEmpty()){
return ;
}
for (Long sysUserId : sysUserIdList) {
Collection<String> cacheKeyList = RedisUtil.keys(CS.getCacheKeyToken(sysUserId, "*"));
if(cacheKeyList == null || cacheKeyList.isEmpty()){
continue;
}
for (String cacheKey : cacheKeyList) {
RedisUtil.del(cacheKey);
}
}
}
public List<SimpleGrantedAuthority> getUserAuthority(SysUser sysUser){
//用户拥有的角色集合 需要以ROLE_ 开头, 用户拥有的权限集合
List<String> roleList = sysRoleService.findListByUser(sysUser.getSysUserId());
List<String> entList = sysRoleEntRelaService.selectEntIdsByUserId(sysUser.getSysUserId(), sysUser.getIsAdmin(), sysUser.getSysType());
List<SimpleGrantedAuthority> grantedAuthorities = new LinkedList<>();
roleList.stream().forEach(role -> grantedAuthorities.add(new SimpleGrantedAuthority(role)));
entList.stream().forEach(ent -> grantedAuthorities.add(new SimpleGrantedAuthority(ent)));
return grantedAuthorities;
}
}
|
//1. 生成spring-security usernamePassword类型对象
UsernamePasswordAuthenticationToken upToken = new UsernamePasswordAuthenticationToken(username, password);
//spring-security 自动认证过程;
// 1. 进入 JeeUserDetailsServiceImpl.loadUserByUsername 获取用户基本信息;
//2. SS根据UserDetails接口验证是否用户可用;
//3. 最后返回loadUserByUsername 封装的对象信息;
Authentication authentication = null;
try {
authentication = authenticationManager.authenticate(upToken);
} catch (JeepayAuthenticationException jex) {
throw jex.getBizException() == null ? new BizException(jex.getMessage()) : jex.getBizException();
} catch (BadCredentialsException e) {
throw new BizException("用户名/密码错误!");
} catch (AuthenticationException e) {
log.error("AuthenticationException:", e);
throw new BizException("认证服务出现异常, 请重试或联系系统管理员!");
}
JeeUserDetails jeeUserDetails = (JeeUserDetails) authentication.getPrincipal();
//验证通过后 再查询用户角色和权限信息集合
SysUser sysUser = jeeUserDetails.getSysUser();
//非超级管理员 && 不包含左侧菜单 进行错误提示
if(sysUser.getIsAdmin() != CS.YES && sysEntitlementMapper.userHasLeftMenu(sysUser.getSysUserId(), CS.SYS_TYPE.MCH) <= 0){
throw new BizException("当前用户未分配任何菜单权限,请联系管理员进行分配后再登录!");
}
// 查询当前用户的商户信息
MchInfo mchInfo = mchInfoService.getById(sysUser.getBelongInfoId());
if (mchInfo != null) {
// 判断当前商户状态是否可用
if (mchInfo.getState() == CS.NO) {
throw new BizException("当前商户状态不可用!");
}
}
// 放置权限集合
jeeUserDetails.setAuthorities(getUserAuthority(sysUser));
//生成token
String cacheKey = CS.getCacheKeyToken(sysUser.getSysUserId(), IdUtil.fastUUID());
//生成iToken 并放置到缓存
ITokenService.processTokenCache(jeeUserDetails, cacheKey); //处理token 缓存信息
//将信息放置到Spring-security context中
UsernamePasswordAuthenticationToken authenticationRest = new UsernamePasswordAuthenticationToken(jeeUserDetails, null, jeeUserDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authenticationRest);
//返回JWTToken
return JWTUtils.generateToken(new JWTPayload(jeeUserDetails), systemYmlConfig.getJwtSecret());
| 1,044
| 747
| 1,791
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/web/ApiResBodyAdvice.java
|
ApiResBodyAdvice
|
supports
|
class ApiResBodyAdvice implements ResponseBodyAdvice {
/** 注入 是否开启 knife4j **/
@Value("${knife4j.enable}")
private boolean knife4jEnable = false;
/** 判断哪些需要拦截 **/
@Override
public boolean supports(MethodParameter returnType, Class converterType) {<FILL_FUNCTION_BODY>}
/** 拦截返回数据处理 */
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//处理扩展字段
return ApiResBodyAdviceKit.beforeBodyWrite(body);
}
}
|
// springfox.documentation.swagger.web.ApiResourceController -- /swagger-resources
// springfox.documentation.swagger2.web.Swagger2ControllerWebMvc -- /v2/api-docs
if(knife4jEnable && returnType.getMethod().getDeclaringClass().getName().startsWith("springfox.documentation.swagger")){
return false;
}
return true;
| 189
| 113
| 302
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/websocket/server/WsChannelUserIdServer.java
|
WsChannelUserIdServer
|
onOpen
|
class WsChannelUserIdServer {
private final static Logger logger = LoggerFactory.getLogger(WsChannelUserIdServer.class);
//当前在线客户端 数量
private static int onlineClientSize = 0;
// appId 与 WsPayOrderServer 存储关系, ConcurrentHashMap保证线程安全
private static Map<String, Set<WsChannelUserIdServer>> wsAppIdMap = new ConcurrentHashMap<>();
//与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
//客户端自定义ID
private String cid = "";
//支付订单号
private String appId = "";
/**
* 连接建立成功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam("appId") String appId, @PathParam("cid") String cid) {<FILL_FUNCTION_BODY>}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
Set wsSet = wsAppIdMap.get(this.appId);
wsSet.remove(this);
if(wsSet.isEmpty()) {
wsAppIdMap.remove(this.appId);
}
subOnlineCount(); //在线数减1
logger.info("cid[{}],appId[{}]连接关闭!当前在线人数为{}", cid, appId, onlineClientSize);
}
/**
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
logger.error("ws发生错误", error);
}
/**
* 实现服务器主动推送
*/
public void sendMessage(String message) throws IOException {
this.session.getBasicRemote().sendText(message);
}
/**
* 根据订单ID,推送消息
* 捕捉所有的异常,避免影响业务。
* @param appId
*/
public static void sendMsgByAppAndCid(String appId, String cid, String msg) {
try {
logger.info("推送ws消息到浏览器, appId={}, cid={}, msg={}", appId, cid, msg);
Set<WsChannelUserIdServer> wsSet = wsAppIdMap.get(appId);
if(wsSet == null || wsSet.isEmpty()){
logger.info("appId[{}] 无ws监听客户端", appId);
return ;
}
for (WsChannelUserIdServer item : wsSet) {
if(!cid.equals(item.cid)){
continue;
}
try {
item.sendMessage(msg);
} catch (Exception e) {
logger.info("推送设备消息时异常,appId={}, cid={}", appId, item.cid, e);
continue;
}
}
} catch (Exception e) {
logger.info("推送消息时异常,appId={}", appId, e);
}
}
public static synchronized int getOnlineClientSize() {
return onlineClientSize;
}
public static synchronized void addOnlineCount() {
onlineClientSize++;
}
public static synchronized void subOnlineCount() {
onlineClientSize--;
}
}
|
try {
//设置当前属性
this.cid = cid;
this.appId = appId;
this.session = session;
Set<WsChannelUserIdServer> wsServerSet = wsAppIdMap.get(appId);
if(wsServerSet == null) {
wsServerSet = new CopyOnWriteArraySet<>();
}
wsServerSet.add(this);
wsAppIdMap.put(appId, wsServerSet);
addOnlineCount(); //在线数加1
logger.info("cid[{}],appId[{}]连接开启监听!当前在线人数为{}", cid, appId, onlineClientSize);
} catch (Exception e) {
logger.error("ws监听异常cid[{}],appId[{}]", cid, appId, e);
}
| 876
| 217
| 1,093
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/websocket/server/WsPayOrderServer.java
|
WsPayOrderServer
|
sendMsgByOrderId
|
class WsPayOrderServer {
private final static Logger logger = LoggerFactory.getLogger(WsPayOrderServer.class);
//当前在线客户端 数量
private static int onlineClientSize = 0;
// payOrderId 与 WsPayOrderServer 存储关系, ConcurrentHashMap保证线程安全
private static Map<String, Set<WsPayOrderServer>> wsOrderIdMap = new ConcurrentHashMap<>();
//与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
//客户端自定义ID
private String cid = "";
//支付订单号
private String payOrderId = "";
/**
* 连接建立成功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam("payOrderId") String payOrderId, @PathParam("cid") String cid) {
try {
//设置当前属性
this.cid = cid;
this.payOrderId = payOrderId;
this.session = session;
Set<WsPayOrderServer> wsServerSet = wsOrderIdMap.get(payOrderId);
if(wsServerSet == null) {
wsServerSet = new CopyOnWriteArraySet<>();
}
wsServerSet.add(this);
wsOrderIdMap.put(payOrderId, wsServerSet);
addOnlineCount(); //在线数加1
logger.info("cid[{}],payOrderId[{}]连接开启监听!当前在线人数为{}", cid, payOrderId, onlineClientSize);
} catch (Exception e) {
logger.error("ws监听异常cid[{}],payOrderId[{}]", cid, payOrderId, e);
}
}
/**
* 连接关闭调用的方法
*/
@OnClose
public void onClose() {
Set wsSet = wsOrderIdMap.get(this.payOrderId);
wsSet.remove(this);
if(wsSet.isEmpty()) {
wsOrderIdMap.remove(this.payOrderId);
}
subOnlineCount(); //在线数减1
logger.info("cid[{}],payOrderId[{}]连接关闭!当前在线人数为{}", cid, payOrderId, onlineClientSize);
}
/**
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
logger.error("ws发生错误", error);
}
/**
* 实现服务器主动推送
*/
public void sendMessage(String message) throws IOException {
this.session.getBasicRemote().sendText(message);
}
/**
* 根据订单ID,推送消息
* 捕捉所有的异常,避免影响业务。
* @param payOrderId
*/
public static void sendMsgByOrderId(String payOrderId, String msg) {<FILL_FUNCTION_BODY>}
public static synchronized int getOnlineClientSize() {
return onlineClientSize;
}
public static synchronized void addOnlineCount() {
onlineClientSize++;
}
public static synchronized void subOnlineCount() {
onlineClientSize--;
}
}
|
try {
logger.info("推送ws消息到浏览器, payOrderId={},msg={}", payOrderId, msg);
Set<WsPayOrderServer> wsSet = wsOrderIdMap.get(payOrderId);
if(wsSet == null || wsSet.isEmpty()){
logger.info("payOrderId[{}] 无ws监听客户端", payOrderId);
return ;
}
for (WsPayOrderServer item : wsSet) {
try {
item.sendMessage(msg);
} catch (Exception e) {
logger.info("推送设备消息时异常,payOrderId={}, cid={}", payOrderId, item.cid, e);
continue;
}
}
} catch (Exception e) {
logger.info("推送消息时异常,payOrderId={}", payOrderId, e);
}
| 847
| 234
| 1,081
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/bootstrap/InitRunner.java
|
InitRunner
|
run
|
class InitRunner implements CommandLineRunner {
@Autowired private SystemYmlConfig systemYmlConfig;
@Override
public void run(String... args) throws Exception {<FILL_FUNCTION_BODY>}
}
|
// 配置是否使用缓存模式
SysConfigService.IS_USE_CACHE = systemYmlConfig.getCacheConfig();
//初始化处理fastjson格式
SerializeConfig serializeConfig = SerializeConfig.getGlobalInstance();
serializeConfig.put(Date.class, new SimpleDateFormatSerializer(DatePattern.NORM_DATETIME_PATTERN));
//解决json 序列化时候的 $ref:问题
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
| 59
| 146
| 205
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/bootstrap/JeepayPayApplication.java
|
JeepayPayApplication
|
paginationInterceptor
|
class JeepayPayApplication {
@Autowired private SystemYmlConfig systemYmlConfig;
/** main启动函数 **/
public static void main(String[] args) {
//启动项目
SpringApplication.run(JeepayPayApplication.class, args);
}
/** fastJson 配置信息 **/
@Bean
public HttpMessageConverters fastJsonConfig(){
//新建fast-json转换器
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
// 开启 FastJSON 安全模式!
ParserConfig.getGlobalInstance().setSafeMode(true);
//fast-json 配置信息
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
converter.setFastJsonConfig(config);
//设置响应的 Content-Type
converter.setSupportedMediaTypes(Arrays.asList(new MediaType[]{MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_UTF8}));
return new HttpMessageConverters(converter);
}
/** Mybatis plus 分页插件 **/
@Bean
public PaginationInterceptor paginationInterceptor() {<FILL_FUNCTION_BODY>}
/** 默认为 失败快速返回模式 **/
@Bean
public Validator validator(){
ValidatorFactory validatorFactory = Validation.byProvider( HibernateValidator.class )
.configure()
.failFast( true )
.buildValidatorFactory();
return validatorFactory.getValidator();
}
/** 允许跨域请求 **/
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
if(systemYmlConfig.getAllowCors()){
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); //带上cookie信息
// config.addAllowedOrigin(CorsConfiguration.ALL); //允许跨域的域名, *表示允许任何域名使用
config.addAllowedOriginPattern(CorsConfiguration.ALL); //使用addAllowedOriginPattern 避免出现 When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
config.addAllowedHeader(CorsConfiguration.ALL); //允许任何请求头
config.addAllowedMethod(CorsConfiguration.ALL); //允许任何方法(post、get等)
source.registerCorsConfiguration("/**", config); // CORS 配置对所有接口都有效
}
return new CorsFilter(source);
}
}
|
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
return paginationInterceptor;
| 716
| 122
| 838
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/AbstractChannelNoticeService.java
|
AbstractChannelNoticeService
|
jsonResp
|
class AbstractChannelNoticeService implements IChannelNoticeService {
@Autowired private RequestKitBean requestKitBean;
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
@Override
public ResponseEntity doNotifyOrderNotExists(HttpServletRequest request) {
return textResp("order not exists");
}
@Override
public ResponseEntity doNotifyOrderStateUpdateFail(HttpServletRequest request) {
return textResp("update status error");
}
/** 文本类型的响应数据 **/
protected ResponseEntity textResp(String text){
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_HTML);
return new ResponseEntity(text, httpHeaders, HttpStatus.OK);
}
/** json类型的响应数据 **/
protected ResponseEntity jsonResp(Object body){<FILL_FUNCTION_BODY>}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected JSONObject getReqParamJSON() {
return requestKitBean.getReqParamJSON();
}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected String getReqParamFromBody() {
return requestKitBean.getReqParamFromBody();
}
/** 获取文件路径 **/
protected String getCertFilePath(String certFilePath) {
return channelCertConfigKitBean.getCertFilePath(certFilePath);
}
/** 获取文件File对象 **/
protected File getCertFile(String certFilePath) {
return channelCertConfigKitBean.getCertFile(certFilePath);
}
}
|
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity(body, httpHeaders, HttpStatus.OK);
| 441
| 50
| 491
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/AbstractChannelRefundNoticeService.java
|
AbstractChannelRefundNoticeService
|
jsonResp
|
class AbstractChannelRefundNoticeService implements IChannelRefundNoticeService {
@Autowired private RequestKitBean requestKitBean;
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
@Override
public ResponseEntity doNotifyOrderNotExists(HttpServletRequest request) {
return textResp("order not exists");
}
@Override
public ResponseEntity doNotifyOrderStateUpdateFail(HttpServletRequest request) {
return textResp("update status error");
}
/** 文本类型的响应数据 **/
protected ResponseEntity textResp(String text){
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_HTML);
return new ResponseEntity(text, httpHeaders, HttpStatus.OK);
}
/** json类型的响应数据 **/
protected ResponseEntity jsonResp(Object body){<FILL_FUNCTION_BODY>}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected JSONObject getReqParamJSON() {
return requestKitBean.getReqParamJSON();
}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected String getReqParamFromBody() {
return requestKitBean.getReqParamFromBody();
}
/** 获取文件路径 **/
protected String getCertFilePath(String certFilePath) {
return channelCertConfigKitBean.getCertFilePath(certFilePath);
}
/** 获取文件File对象 **/
protected File getCertFile(String certFilePath) {
return channelCertConfigKitBean.getCertFile(certFilePath);
}
}
|
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity(body, httpHeaders, HttpStatus.OK);
| 445
| 50
| 495
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/AbstractDivisionRecordChannelNotifyService.java
|
AbstractDivisionRecordChannelNotifyService
|
textResp
|
class AbstractDivisionRecordChannelNotifyService {
@Autowired private RequestKitBean requestKitBean;
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
/** 获取到接口code **/
public abstract String getIfCode();
/** 解析参数: 批次号 和 请求参数
* 异常需要自行捕捉,并返回null , 表示已响应数据。
* **/
public abstract MutablePair<String, Object> parseParams(HttpServletRequest request);
/**
* 返回需要更新的记录 <ID, 结果> 状态 和响应数据
*
* **/
public abstract DivisionChannelNotifyModel doNotify(HttpServletRequest request, Object params,
List<PayOrderDivisionRecord> recordList, MchAppConfigContext mchAppConfigContext);
public ResponseEntity doNotifyOrderNotExists(HttpServletRequest request) {
return textResp("order not exists");
}
public ResponseEntity doNotifyOrderStateUpdateFail(HttpServletRequest request) {
return textResp("update status error");
}
/** 文本类型的响应数据 **/
protected ResponseEntity textResp(String text){<FILL_FUNCTION_BODY>}
/** json类型的响应数据 **/
protected ResponseEntity jsonResp(Object body){
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity(body, httpHeaders, HttpStatus.OK);
}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected JSONObject getReqParamJSON() {
return requestKitBean.getReqParamJSON();
}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected String getReqParamFromBody() {
return requestKitBean.getReqParamFromBody();
}
/** 获取文件路径 **/
protected String getCertFilePath(String certFilePath) {
return channelCertConfigKitBean.getCertFilePath(certFilePath);
}
/** 获取文件File对象 **/
protected File getCertFile(String certFilePath) {
return channelCertConfigKitBean.getCertFile(certFilePath);
}
}
|
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_HTML);
return new ResponseEntity(text, httpHeaders, HttpStatus.OK);
| 605
| 48
| 653
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/AbstractTransferNoticeService.java
|
AbstractTransferNoticeService
|
jsonResp
|
class AbstractTransferNoticeService implements ITransferNoticeService {
@Autowired private RequestKitBean requestKitBean;
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
@Override
public ResponseEntity doNotifyOrderNotExists(HttpServletRequest request) {
return textResp("order not exists");
}
/** 文本类型的响应数据 **/
protected ResponseEntity textResp(String text){
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_HTML);
return new ResponseEntity(text, httpHeaders, HttpStatus.OK);
}
/** json类型的响应数据 **/
protected ResponseEntity jsonResp(Object body){<FILL_FUNCTION_BODY>}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected JSONObject getReqParamJSON() {
return requestKitBean.getReqParamJSON();
}
/**request.getParameter 获取参数 并转换为JSON格式 **/
protected String getReqParamFromBody() {
return requestKitBean.getReqParamFromBody();
}
/** 获取文件路径 **/
protected String getCertFilePath(String certFilePath) {
return channelCertConfigKitBean.getCertFilePath(certFilePath);
}
/** 获取文件File对象 **/
protected File getCertFile(String certFilePath) {
return channelCertConfigKitBean.getCertFile(certFilePath);
}
}
|
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
return new ResponseEntity(body, httpHeaders, HttpStatus.OK);
| 405
| 50
| 455
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayChannelNoticeService.java
|
AlipayChannelNoticeService
|
doNotice
|
class AlipayChannelNoticeService extends AbstractChannelNoticeService {
@Override
public String getIfCode() {
return CS.IF_CODE.ALIPAY;
}
@Override
public MutablePair<String, Object> parseParams(HttpServletRequest request, String urlOrderId, NoticeTypeEnum noticeTypeEnum) {
try {
JSONObject params = getReqParamJSON();
String payOrderId = params.getString("out_trade_no");
return MutablePair.of(payOrderId, params);
} catch (Exception e) {
log.error("error", e);
throw ResponseException.buildText("ERROR");
}
}
@Override
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {<FILL_FUNCTION_BODY>}
}
|
try {
//配置参数获取
Byte useCert = null;
String alipaySignType, alipayPublicCert, alipayPublicKey = null;
if(mchAppConfigContext.isIsvsubMch()){
// 获取支付参数
AlipayIsvParams alipayParams = (AlipayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
useCert = alipayParams.getUseCert();
alipaySignType = alipayParams.getSignType();
alipayPublicCert = alipayParams.getAlipayPublicCert();
alipayPublicKey = alipayParams.getAlipayPublicKey();
}else{
// 获取支付参数
AlipayNormalMchParams alipayParams = (AlipayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
useCert = alipayParams.getUseCert();
alipaySignType = alipayParams.getSignType();
alipayPublicCert = alipayParams.getAlipayPublicCert();
alipayPublicKey = alipayParams.getAlipayPublicKey();
}
// 获取请求参数
JSONObject jsonParams = (JSONObject) params;
boolean verifyResult;
if(useCert != null && useCert == CS.YES){ //证书方式
verifyResult = AlipaySignature.rsaCertCheckV1(jsonParams.toJavaObject(Map.class), getCertFilePath(alipayPublicCert),
AlipayConfig.CHARSET, alipaySignType);
}else{
verifyResult = AlipaySignature.rsaCheckV1(jsonParams.toJavaObject(Map.class), alipayPublicKey, AlipayConfig.CHARSET, alipaySignType);
}
//验签失败
if(!verifyResult){
throw ResponseException.buildText("ERROR");
}
//验签成功后判断上游订单状态
ResponseEntity okResponse = textResp("SUCCESS");
ChannelRetMsg result = new ChannelRetMsg();
result.setChannelOrderId(jsonParams.getString("trade_no")); //渠道订单号
result.setChannelUserId(jsonParams.getString("buyer_id")); //支付用户ID
result.setResponseEntity(okResponse); //响应数据
result.setChannelState(ChannelRetMsg.ChannelState.WAITING); // 默认支付中
if("TRADE_SUCCESS".equals(jsonParams.getString("trade_status"))){
result.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
}else if("TRADE_CLOSED".equals(jsonParams.getString("trade_status"))){
result.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_FAIL);
}
return result;
} catch (Exception e) {
log.error("error", e);
throw ResponseException.buildText("ERROR");
}
| 233
| 806
| 1,039
|
<methods>public non-sealed void <init>() ,public ResponseEntity doNotifyOrderNotExists(HttpServletRequest) ,public ResponseEntity doNotifyOrderStateUpdateFail(HttpServletRequest) <variables>private com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean channelCertConfigKitBean,protected com.jeequan.jeepay.pay.service.ConfigContextQueryService configContextQueryService,private com.jeequan.jeepay.core.beans.RequestKitBean requestKitBean
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayChannelUserService.java
|
AlipayChannelUserService
|
buildUserRedirectUrl
|
class AlipayChannelUserService implements IChannelUserService {
@Autowired private ConfigContextQueryService configContextQueryService;
@Override
public String getIfCode() {
return CS.IF_CODE.ALIPAY;
}
@Override
public String buildUserRedirectUrl(String callbackUrlEncode, MchAppConfigContext mchAppConfigContext) {<FILL_FUNCTION_BODY>}
@Override
public String getChannelUserId(JSONObject reqParams, MchAppConfigContext mchAppConfigContext) {
String authCode = reqParams.getString("auth_code");
//通过code 换取openId
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode(authCode); request.setGrantType("authorization_code");
try {
return configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request).getUserId();
} catch (ChannelException e) {
e.printStackTrace();
return null;
}
}
}
|
String oauthUrl = AlipayConfig.PROD_OAUTH_URL;
String appId = null;
if(mchAppConfigContext.isIsvsubMch()){
AlipayIsvParams isvParams = (AlipayIsvParams) configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
if(isvParams == null) {
throw new BizException("服务商支付宝接口没有配置!");
}
appId = isvParams.getAppId();
if(isvParams.getSandbox() != null && isvParams.getSandbox() == CS.YES){
oauthUrl = AlipayConfig.SANDBOX_OAUTH_URL;
}
}else{
//获取商户配置信息
AlipayNormalMchParams normalMchParams = (AlipayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
if(normalMchParams == null) {
throw new BizException("商户支付宝接口没有配置!");
}
appId = normalMchParams.getAppId();
if(normalMchParams.getSandbox() != null && normalMchParams.getSandbox() == CS.YES){
oauthUrl = AlipayConfig.SANDBOX_OAUTH_URL;
}
}
String alipayUserRedirectUrl = String.format(oauthUrl, appId, callbackUrlEncode);
log.info("alipayUserRedirectUrl={}", alipayUserRedirectUrl);
return alipayUserRedirectUrl;
| 273
| 449
| 722
|
<no_super_class>
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayDivisionRecordChannelNotifyService.java
|
AlipayDivisionRecordChannelNotifyService
|
doNotify
|
class AlipayDivisionRecordChannelNotifyService extends AbstractDivisionRecordChannelNotifyService {
@Override
public String getIfCode() {
return CS.IF_CODE.ALIPAY;
}
@Override
public MutablePair<String, Object> parseParams(HttpServletRequest request) {
try {
JSONObject params = getReqParamJSON();
String batchOrderId = params.getJSONObject("biz_content").getString("out_request_no"); // 分账批次号
return MutablePair.of(batchOrderId, params);
} catch (Exception e) {
log.error("error", e);
throw ResponseException.buildText("ERROR");
}
}
@Override
public DivisionChannelNotifyModel doNotify(HttpServletRequest request, Object params, List<PayOrderDivisionRecord> recordList, MchAppConfigContext mchAppConfigContext) {<FILL_FUNCTION_BODY>}
}
|
// 响应结果
DivisionChannelNotifyModel result = new DivisionChannelNotifyModel();
try {
//配置参数获取
Byte useCert = null;
String alipaySignType, alipayPublicCert, alipayPublicKey = null;
if(mchAppConfigContext.isIsvsubMch()){
// 获取支付参数
AlipayIsvParams alipayParams = (AlipayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
useCert = alipayParams.getUseCert();
alipaySignType = alipayParams.getSignType();
alipayPublicCert = alipayParams.getAlipayPublicCert();
alipayPublicKey = alipayParams.getAlipayPublicKey();
}else{
// 获取支付参数
AlipayNormalMchParams alipayParams = (AlipayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
useCert = alipayParams.getUseCert();
alipaySignType = alipayParams.getSignType();
alipayPublicCert = alipayParams.getAlipayPublicCert();
alipayPublicKey = alipayParams.getAlipayPublicKey();
}
// 获取请求参数
JSONObject jsonParams = (JSONObject) params;
boolean verifyResult;
if(useCert != null && useCert == CS.YES){ //证书方式
verifyResult = AlipaySignature.rsaCertCheckV1(jsonParams.toJavaObject(Map.class), getCertFilePath(alipayPublicCert),
AlipayConfig.CHARSET, alipaySignType);
}else{
verifyResult = AlipaySignature.rsaCheckV1(jsonParams.toJavaObject(Map.class), alipayPublicKey, AlipayConfig.CHARSET, alipaySignType);
}
//验签失败
if(!verifyResult){
throw ResponseException.buildText("ERROR");
}
// 得到所有的 accNo 与 recordId map
Map<String, Long> accnoAndRecordIdSet = new HashMap<>();
for (PayOrderDivisionRecord record : recordList) {
accnoAndRecordIdSet.put(record.getAccNo(), record.getRecordId());
}
Map<Long, ChannelRetMsg> recordResultMap = new HashMap<>();
JSONObject bizContentJSON = jsonParams.getJSONObject("biz_content");
// 循环
JSONArray array = bizContentJSON.getJSONArray("royalty_detail_list");
for (Object o : array) {
JSONObject itemJSON = (JSONObject) o;
// 我方系统的分账接收记录ID
Long recordId = accnoAndRecordIdSet.get(itemJSON.getString("trans_in"));
// 分账类型 && 包含该笔分账账号
if("transfer".equals(itemJSON.getString("operation_type")) && recordId != null){
// 分账成功
if("SUCCESS".equals(itemJSON.getString("state"))){
recordResultMap.put(recordId, ChannelRetMsg.confirmSuccess(bizContentJSON.getString("settle_no")));
}
// 分账失败
if("FAIL".equals(itemJSON.getString("state"))){
recordResultMap.put(recordId, ChannelRetMsg.confirmFail(bizContentJSON.getString("settle_no"), itemJSON.getString("error_code"), itemJSON.getString("error_desc")));
}
}
}
result.setRecordResultMap(recordResultMap);
result.setApiRes(textResp("success"));
return result;
} catch (Exception e) {
log.error("error", e);
throw ResponseException.buildText("ERROR");
}
| 246
| 1,022
| 1,268
|
<methods>public non-sealed void <init>() ,public abstract com.jeequan.jeepay.pay.rqrs.msg.DivisionChannelNotifyModel doNotify(HttpServletRequest, java.lang.Object, List<com.jeequan.jeepay.core.entity.PayOrderDivisionRecord>, com.jeequan.jeepay.pay.model.MchAppConfigContext) ,public ResponseEntity doNotifyOrderNotExists(HttpServletRequest) ,public ResponseEntity doNotifyOrderStateUpdateFail(HttpServletRequest) ,public abstract java.lang.String getIfCode() ,public abstract MutablePair<java.lang.String,java.lang.Object> parseParams(HttpServletRequest) <variables>private com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean channelCertConfigKitBean,protected com.jeequan.jeepay.pay.service.ConfigContextQueryService configContextQueryService,private com.jeequan.jeepay.core.beans.RequestKitBean requestKitBean
|
jeequan_jeepay
|
jeepay/jeepay-payment/src/main/java/com/jeequan/jeepay/pay/channel/alipay/AlipayKit.java
|
AlipayKit
|
putApiIsvInfo
|
class AlipayKit {
/** 放置 isv特殊信息 **/
public static void putApiIsvInfo(MchAppConfigContext mchAppConfigContext, AlipayRequest req, AlipayObject model){<FILL_FUNCTION_BODY>}
public static String appendErrCode(String code, String subCode){
return StringUtils.defaultIfEmpty(subCode, code); //优先: subCode
}
public static String appendErrMsg(String msg, String subMsg){
String result = null;
if(StringUtils.isNotEmpty(msg) && StringUtils.isNotEmpty(subMsg) ){
result = msg + "【" + subMsg + "】";
}else{
result = StringUtils.defaultIfEmpty(subMsg, msg);
}
return CharSequenceUtil.maxLength(result, 253);
}
}
|
//不是特约商户, 无需放置此值
if(!mchAppConfigContext.isIsvsubMch()){
return ;
}
ConfigContextQueryService configContextQueryService = SpringBeansUtil.getBean(ConfigContextQueryService.class);
// 获取支付参数
AlipayIsvParams isvParams = (AlipayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), CS.IF_CODE.ALIPAY);
AlipayIsvsubMchParams isvsubMchParams = (AlipayIsvsubMchParams)configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.ALIPAY);
// 子商户信息
if(req instanceof AlipayTradePayRequest) {
((AlipayTradePayRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeAppPayRequest) {
((AlipayTradeAppPayRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeCreateRequest) {
((AlipayTradeCreateRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradePagePayRequest) {
((AlipayTradePagePayRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradePrecreateRequest) {
((AlipayTradePrecreateRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeWapPayRequest) {
((AlipayTradeWapPayRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeQueryRequest) {
((AlipayTradeQueryRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeRefundRequest) {
((AlipayTradeRefundRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeFastpayRefundQueryRequest) {
((AlipayTradeFastpayRefundQueryRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayFundTransToaccountTransferRequest) {
((AlipayFundTransToaccountTransferRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeRoyaltyRelationBindRequest) {
((AlipayTradeRoyaltyRelationBindRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeOrderSettleRequest) {
((AlipayTradeOrderSettleRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeCloseRequest) {
((AlipayTradeCloseRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
} else if(req instanceof AlipayTradeOrderSettleQueryRequest) {
((AlipayTradeOrderSettleQueryRequest)req).putOtherTextParam("app_auth_token", isvsubMchParams.getAppAuthToken());
}
// 服务商信息
ExtendParams extendParams = new ExtendParams();
extendParams.setSysServiceProviderId(isvParams.getPid());
if(model instanceof AlipayTradePayModel) {
((AlipayTradePayModel)model).setExtendParams(extendParams);
} else if(model instanceof AlipayTradeAppPayModel) {
((AlipayTradeAppPayModel)model).setExtendParams(extendParams);
} else if(model instanceof AlipayTradeCreateModel) {
((AlipayTradeCreateModel)model).setExtendParams(extendParams);
} else if(model instanceof AlipayTradePagePayModel) {
((AlipayTradePagePayModel)model).setExtendParams(extendParams);
} else if(model instanceof AlipayTradePrecreateModel) {
((AlipayTradePrecreateModel)model).setExtendParams(extendParams);
} else if(model instanceof AlipayTradeWapPayModel) {
((AlipayTradeWapPayModel)model).setExtendParams(extendParams);
}
| 223
| 1,297
| 1,520
|
<no_super_class>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.