feat:宁波银行对接
This commit is contained in:
1 parent
42a218e99c
commit
7847d799f9
11 files changed
+232
-2
No files matched your search
+13
@@ -0,0 +1,13 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.lb;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LbH5LoginDto {
|
||||
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.thirdparty.vo.lb;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LbH5LoginVo {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private String h5Url;
|
||||
|
||||
public boolean isSuccess() {
|
||||
return code == 200;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -115,6 +115,12 @@
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
<!-- 国密 -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15to18</artifactId>
|
||||
<version>1.66</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.thirdparty.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "lb")
|
||||
@Data
|
||||
public class LbConfig {
|
||||
|
||||
/**
|
||||
* 请求基础路径
|
||||
*/
|
||||
private String baseUrl;
|
||||
|
||||
private String appId;
|
||||
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 企业编号
|
||||
*/
|
||||
private String companyNumber;
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.lb;
|
||||
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.thirdparty.dto.lb.LbH5LoginDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdLbApiService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/third-lb")
|
||||
@Tag(description = "third-lb", name = "宁波银行对接")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdLbApiController {
|
||||
|
||||
private final ThirdLbApiService thirdLbApiService;
|
||||
|
||||
@Operation(summary = "美好生活登录", description = "美好生活登录")
|
||||
@PostMapping("/h5-login")
|
||||
public R H5Login(@RequestBody LbH5LoginDto dto) {
|
||||
return R.ok(thirdLbApiService.h5Login(dto));
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.dto.lb.LbH5LoginDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.lb.LbH5LoginVo;
|
||||
|
||||
/**
|
||||
* @author liusiyang_dxm
|
||||
* @since 2025/4/29
|
||||
*/
|
||||
public interface ThirdLbApiService {
|
||||
|
||||
/**
|
||||
* 美好生活登录
|
||||
*/
|
||||
LbH5LoginVo h5Login(LbH5LoginDto dto);
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl.lb;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.thirdparty.config.LbConfig;
|
||||
import com.bsd.pjcloud.thirdparty.dto.lb.LbH5LoginDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdLbApiService;
|
||||
import com.bsd.pjcloud.thirdparty.utils.door.api.DoorApi;
|
||||
import com.bsd.pjcloud.thirdparty.utils.lb.api.LbApi;
|
||||
import com.bsd.pjcloud.thirdparty.vo.ks.KsBaseVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.lb.LbH5LoginVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ThirdLbApiServiceImpl implements ThirdLbApiService {
|
||||
|
||||
private static final String TAG = "宁波银行api";
|
||||
|
||||
private final LbConfig lbConfig;
|
||||
|
||||
@Override
|
||||
public LbH5LoginVo h5Login(LbH5LoginDto dto) {
|
||||
LbH5LoginVo ksBaseVo = new LbH5LoginVo();
|
||||
String phone = dto.getPhone();
|
||||
String signPhone = phone;
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
String signature = apiCountersign(dto.getPhone(), timeMillis);
|
||||
Map<String, String> queryMap = new HashMap<>();
|
||||
queryMap.put("companyNumber", lbConfig.getCompanyNumber());
|
||||
queryMap.put("appId", lbConfig.getAppId());
|
||||
queryMap.put("phone", signPhone);
|
||||
queryMap.put("timestamp", String.valueOf(timeMillis));
|
||||
queryMap.put("signature", signature);
|
||||
// 发送请求
|
||||
DoorApi.Api h5Login = LbApi.H5_LOGIN;
|
||||
try {
|
||||
String res = HttpRequest.post(lbConfig.getBaseUrl() + h5Login.getUrl()).contentType(h5Login.getContentType()).body(JSONUtil.toJsonStr(queryMap)).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) throw new RuntimeException("response响应为空");
|
||||
ksBaseVo = JSONUtil.toBean(res, LbH5LoginVo.class);
|
||||
} catch (Exception e) {
|
||||
String error = String.format("|%s||skuSubmit|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
}
|
||||
return ksBaseVo;
|
||||
}
|
||||
|
||||
|
||||
// 加签
|
||||
public String apiCountersign(String phone, Long timestamp) {
|
||||
String str = String.format("companyNumber=%s&appId=%s&phone=%s×tamp=%s&secret=%s");
|
||||
str = String.format(str, lbConfig.getCompanyNumber(), lbConfig.getAppId(), phone, timestamp, lbConfig.getAppSecret());
|
||||
// 使用 SHA-256 进行哈希计算,并返回十六进制字符串。
|
||||
String sha256 = DigestUtils.sha256Hex(str);
|
||||
return sha256;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.bsd.pjcloud.thirdparty.utils.lb.api;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.constant.door.ThirdDoorApiTypeEnum;
|
||||
import com.bsd.pjcloud.thirdparty.utils.door.api.DoorApi;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
|
||||
|
||||
@UtilityClass
|
||||
public class LbApi {
|
||||
|
||||
// 美好生活登录(直连模式)
|
||||
public static final DoorApi.Api H5_LOGIN = DoorApi.Api.builder().url("/mall/xhr/authLogin/thirdApp").bizType(ThirdDoorApiTypeEnum.REGISTER).method(HttpPost.METHOD_NAME).contentType("application/json").build();
|
||||
|
||||
// 美好生活登录(分行中转模式)
|
||||
public static final DoorApi.Api H5_LOGIN_OPEN = DoorApi.Api.builder().url("/mall/xhr/authLogin/thirdAppOpen").bizType(ThirdDoorApiTypeEnum.REGISTER).method(HttpPost.METHOD_NAME).contentType("application/json").build();
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class Api {
|
||||
private String url;
|
||||
|
||||
private String method;
|
||||
|
||||
private String contentType;
|
||||
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -88,7 +88,11 @@ zy:
|
||||
# callback-base-url: http://h1yzkslmyx.ny.takin.cc
|
||||
# callback-recognition-url: /third/third-ks/callback/recognition
|
||||
# callback-sku-url: /third/third-ks/callback/sku
|
||||
|
||||
lb:
|
||||
base-url: https://elss-sit.nbcb.com.cn
|
||||
app-id: c4b0a38e9ba5419eab9b651dd23db462
|
||||
app-secret: iW9H6BT2AMXg2XnN2Eq+r6ISossJNNh97nyLwrrOrDY=
|
||||
company-number: p6VQYhHZ
|
||||
|
||||
|
||||
sms:
|
||||
|
||||
+16
@@ -35,6 +35,22 @@ public class MchCatgoryController {
|
||||
|
||||
private final MchCatgoryService mchCatgoryService;
|
||||
|
||||
/* ************************************* start 移动端 start ************************************* */
|
||||
|
||||
@Operation(summary = "app下拉查询", description = "app下拉查询")
|
||||
@GetMapping("/app/select")
|
||||
public R appSelect(@ParameterObject Page page, @ParameterObject MchCatgoryEntity mchCatgory) {
|
||||
LambdaQueryWrapper<MchCatgoryEntity> wrapper = new LambdaQueryWrapper<MchCatgoryEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(mchCatgory.getBizType()), MchCatgoryEntity::getBizType, mchCatgory.getBizType())
|
||||
.like(ObjectUtil.isNotEmpty(mchCatgory.getName()), MchCatgoryEntity::getName, mchCatgory.getName())
|
||||
.orderByDesc(MchCatgoryEntity::getSort)
|
||||
.orderByDesc(MchCatgoryEntity::getCreateTime)
|
||||
.orderByDesc(MchCatgoryEntity::getId);
|
||||
return R.ok(mchCatgoryService.list(page, wrapper));
|
||||
}
|
||||
|
||||
/* ************************************* end 移动端 end ************************************* */
|
||||
|
||||
@Operation(summary = "下拉查询(没有权限)", description = "下拉查询(没有权限)")
|
||||
@GetMapping("/select")
|
||||
public R select(@ParameterObject Page page, @ParameterObject MchCatgoryEntity mchCatgory) {
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<if test="dto.parentId != null">
|
||||
and a.parent_id = #{dto.parentId}
|
||||
</if>
|
||||
<if test="dto.parentIsNull != null and dto.parentIsNull == true">
|
||||
<if test="dto.parentIsNull != null and dto.parentIsNull == true and dto.parentId == null ">
|
||||
and a.parent_id = -1
|
||||
</if>
|
||||
<if test="dto.name != null">
|
||||
|
||||
Reference in new issue
Block a user