正元同步
This commit is contained in:
1 parent
00d159c8c0
commit
54a46dd9ee
20 files changed
+474
-137
No files matched your search
@@ -8,7 +8,7 @@ CREATE TABLE `third_zy_log`
|
|||||||
(
|
(
|
||||||
`id` bigint NOT NULL COMMENT '主键',
|
`id` bigint NOT NULL COMMENT '主键',
|
||||||
`biz_type` tinytext NOT NULL COMMENT '同步类型',
|
`biz_type` tinytext NOT NULL COMMENT '同步类型',
|
||||||
`biz_id` varchar(2048) NOT NULL COMMENT '同步类型id',
|
`biz_id` varchar(2048) DEFAULT NULL COMMENT '同步类型id',
|
||||||
`api_url` text DEFAULT NULL COMMENT 'api url',
|
`api_url` text DEFAULT NULL COMMENT 'api url',
|
||||||
`org_res` text DEFAULT NULL COMMENT '原始res',
|
`org_res` text DEFAULT NULL COMMENT '原始res',
|
||||||
`encipher_res` text DEFAULT NULL COMMENT '加密res',
|
`encipher_res` text DEFAULT NULL COMMENT '加密res',
|
||||||
@@ -19,7 +19,7 @@ CREATE TABLE `third_zy_log`
|
|||||||
`time_consuming` char(64) DEFAULT NULL COMMENT '同步版本格式化为14位字符串,如果是数字不足14位的,前面补0',
|
`time_consuming` char(64) DEFAULT NULL COMMENT '同步版本格式化为14位字符串,如果是数字不足14位的,前面补0',
|
||||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
`create_by` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT '创建人',
|
`create_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||||
`update_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
|
`update_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
|
||||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除时间',
|
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除时间',
|
||||||
`tenant_id` bigint(20) DEFAULT NULL,
|
`tenant_id` bigint(20) DEFAULT NULL,
|
||||||
|
|||||||
+10
-4
@@ -4,6 +4,10 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
|||||||
import com.bsd.pjcloud.common.core.util.R;
|
import com.bsd.pjcloud.common.core.util.R;
|
||||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideAuthenticationDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideConsumptionDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.stride.ZyStrideCorrectDto;
|
||||||
@@ -19,6 +23,8 @@ import org.springframework.cloud.openfeign.FeignClient;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@FeignClient(contextId = "remoterThirdZyService", value = ServiceNameConstants.THIRDPARTY_SERVICE)
|
@FeignClient(contextId = "remoterThirdZyService", value = ServiceNameConstants.THIRDPARTY_SERVICE)
|
||||||
public interface RemoterThirdZyService {
|
public interface RemoterThirdZyService {
|
||||||
|
|
||||||
@@ -41,28 +47,28 @@ public interface RemoterThirdZyService {
|
|||||||
*/
|
*/
|
||||||
@NoToken
|
@NoToken
|
||||||
@GetMapping("/third-zy-mer/sync-dealer-info")
|
@GetMapping("/third-zy-mer/sync-dealer-info")
|
||||||
R<ZyMerSyncDealerInfoVo> syncDealerInfo(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
|
R<ZyMerSyncDealerInfoVo> syncDealerInfo(@RequestBody List<ZyMerSyncDealerInfoDto> dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记账单位同步
|
* 记账单位同步
|
||||||
*/
|
*/
|
||||||
@NoToken
|
@NoToken
|
||||||
@GetMapping("/third-zy-mer/sync-enterprise-info")
|
@GetMapping("/third-zy-mer/sync-enterprise-info")
|
||||||
R<ZyMerSyncEnterpriseInfoVo> syncEnterpriseInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
|
R<ZyMerSyncEnterpriseInfoVo> syncEnterpriseInfoApi(@RequestBody List<ZyMerSyncEnterpriseInfoDto> dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户信息同步
|
* 账户信息同步
|
||||||
*/
|
*/
|
||||||
@NoToken
|
@NoToken
|
||||||
@GetMapping("/third-zy-mer/sync-account-info")
|
@GetMapping("/third-zy-mer/sync-account-info")
|
||||||
R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
|
R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 身份信息同步
|
* 身份信息同步
|
||||||
*/
|
*/
|
||||||
@NoToken
|
@NoToken
|
||||||
@GetMapping("/third-zy-mer/sync-acc-class-info")
|
@GetMapping("/third-zy-mer/sync-acc-class-info")
|
||||||
R<ZyMerSyncAccClassInfoVo> syncAccClassInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto);
|
R<ZyMerSyncAccClassInfoVo> syncAccClassInfoApi(@RequestBody List<ZyMerSyncAccClassInfoDto> dto);
|
||||||
|
|
||||||
/* ************************************* end 数据同步 end ************************************* */
|
/* ************************************* end 数据同步 end ************************************* */
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ public enum ThirdZyBizEnumType {
|
|||||||
|
|
||||||
// 数据同步
|
// 数据同步
|
||||||
SYNC_DEALER_INFO("10", "商户信息同步"),
|
SYNC_DEALER_INFO("10", "商户信息同步"),
|
||||||
SYNC_ENTERPRISE_INFO("20", "已打印"),
|
SYNC_ENTERPRISE_INFO("20", "记账单位同步"),
|
||||||
SYNC_ACCOUNT_INFO("30", "账户信息同步"),
|
SYNC_ACCOUNT_INFO("30", "账户信息同步"),
|
||||||
SYNC_ACC_CLASS_INFO("40", "身份信息同步"),
|
SYNC_ACC_CLASS_INFO("40", "身份信息同步"),
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ public class ZyMerSyncAccountInfoDto {
|
|||||||
/**
|
/**
|
||||||
* 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
|
* 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
|
||||||
*/
|
*/
|
||||||
private String CardStatus;
|
private Integer CardStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 该卡在所属接入系统中的所属单位编号
|
* 该卡在所属接入系统中的所属单位编号
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ public class ZyMerSyncEnterpriseInfoDto {
|
|||||||
/**
|
/**
|
||||||
* 记账单位是否有效0:禁用 1:有效
|
* 记账单位是否有效0:禁用 1:有效
|
||||||
*/
|
*/
|
||||||
private String IsValid;
|
private Integer IsValid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每次推送版本号,格式化为14位字符串,如果是数字不足14位的,前面补0。
|
* 每次推送版本号,格式化为14位字符串,如果是数字不足14位的,前面补0。
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
|
|||||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||||
entity.setEncipherReq(body);
|
entity.setEncipherReq(body);
|
||||||
String res = HttpRequest.post(url)
|
String res = HttpRequest.post(url)
|
||||||
.body(body)
|
.form(body)
|
||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
if (ObjectUtil.isEmpty(res)) {
|
if (ObjectUtil.isEmpty(res)) {
|
||||||
|
|||||||
+10
-9
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||||
|
import com.bsd.pjcloud.thirdparty.constant.ThirdZyBizEnumType;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||||
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||||
@@ -41,6 +42,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
@Override
|
@Override
|
||||||
public ZyMerSyncDealerInfoVo syncDealerInfoApi(List<ZyMerSyncDealerInfoDto> dto) {
|
public ZyMerSyncDealerInfoVo syncDealerInfoApi(List<ZyMerSyncDealerInfoDto> dto) {
|
||||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||||
|
entity.setBizType(ThirdZyBizEnumType.SYNC_DEALER_INFO.getType());
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
if (ObjectUtil.isEmpty(dto)) {
|
if (ObjectUtil.isEmpty(dto)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -57,13 +59,9 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
encryptionBody.put("dealers", listMap);
|
encryptionBody.put("dealers", listMap);
|
||||||
entity.setApiUrl(url);
|
entity.setApiUrl(url);
|
||||||
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
|
||||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
|
||||||
entity.setEncipherReq(body);
|
entity.setEncipherReq(JSONUtil.toJsonStr(body));
|
||||||
String res = HttpRequest.post(url)
|
String res = HttpRequest.post(url).form(body).execute().body();
|
||||||
.contentType("application/x-www-form-urlencoded")
|
|
||||||
.body(body)
|
|
||||||
.execute()
|
|
||||||
.body();
|
|
||||||
if (ObjectUtil.isEmpty(res)) {
|
if (ObjectUtil.isEmpty(res)) {
|
||||||
throw new RuntimeException("response is empty");
|
throw new RuntimeException("response is empty");
|
||||||
}
|
}
|
||||||
@@ -77,6 +75,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String error = String.format("|%s||syncNativeCardTradeInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
String error = String.format("|%s||syncNativeCardTradeInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||||
log.error(error);
|
log.error(error);
|
||||||
|
entity.setError(error);
|
||||||
} finally {
|
} finally {
|
||||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||||
@@ -91,6 +90,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
@Override
|
@Override
|
||||||
public ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(List<ZyMerSyncEnterpriseInfoDto> dto) {
|
public ZyMerSyncEnterpriseInfoVo syncEnterpriseInfoApi(List<ZyMerSyncEnterpriseInfoDto> dto) {
|
||||||
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
ThirdZyLogEntity entity = new ThirdZyLogEntity();
|
||||||
|
entity.setBizType(ThirdZyBizEnumType.SYNC_ENTERPRISE_INFO.getType());
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ENTERPRISE_INFO;
|
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ENTERPRISE_INFO;
|
||||||
try {
|
try {
|
||||||
@@ -102,6 +102,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
String body = zyApiTool.getEncryptionDto(encryptionBody);
|
||||||
entity.setEncipherReq(body);
|
entity.setEncipherReq(body);
|
||||||
String res = HttpRequest.post(url)
|
String res = HttpRequest.post(url)
|
||||||
|
.contentType("application/x-www-form-urlencoded")
|
||||||
.body(body)
|
.body(body)
|
||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
@@ -161,7 +162,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
String error = String.format("|%s||syncAccountInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
String error = String.format("|%s||syncAccountInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||||
log.error(error);
|
log.error(error);
|
||||||
entity.setError(error);
|
entity.setError(error);
|
||||||
}finally {
|
} finally {
|
||||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||||
thirdZyLogService.save(entity);
|
thirdZyLogService.save(entity);
|
||||||
@@ -203,7 +204,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
|
|||||||
String error = String.format("|%s||syncAccClassInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
String error = String.format("|%s||syncAccClassInfoApi|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||||
log.error(error);
|
log.error(error);
|
||||||
entity.setError(error);
|
entity.setError(error);
|
||||||
}finally {
|
} finally {
|
||||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||||
entity.setTimeConsuming(Long.toString(elapsedTime));
|
entity.setTimeConsuming(Long.toString(elapsedTime));
|
||||||
thirdZyLogService.save(entity);
|
thirdZyLogService.save(entity);
|
||||||
|
|||||||
+13
-2
@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||||
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
|
||||||
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerGetTokenVo;
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerGetTokenVo;
|
||||||
@@ -89,7 +91,16 @@ public class ZyApiTool {
|
|||||||
Map<String, Object> body = new HashMap<>();
|
Map<String, Object> body = new HashMap<>();
|
||||||
body.put("data", params);
|
body.put("data", params);
|
||||||
prePost(body);
|
prePost(body);
|
||||||
return JSONUtil.toJsonStr(body);
|
String jsonString = JSON.toJSONString(body, SerializerFeature.DisableCircularReferenceDetect);
|
||||||
|
log.error(jsonString);
|
||||||
|
return jsonString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getEncryptionMap(Map<String, Object> params) {
|
||||||
|
Map<String, Object> body = new HashMap<>();
|
||||||
|
body.put("data", params);
|
||||||
|
prePost(body);
|
||||||
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> removeEmptyMap(Map<String, Object> params) {
|
public Map<String, Object> removeEmptyMap(Map<String, Object> params) {
|
||||||
@@ -116,7 +127,7 @@ public class ZyApiTool {
|
|||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
entry.setValue(Base64.encode((String) value));
|
entry.setValue(Base64.encode((String) value).replaceAll("\\s+", ""));
|
||||||
} else {
|
} else {
|
||||||
entry.setValue(Base64.encode(value.toString()));
|
entry.setValue(Base64.encode(value.toString()));
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -78,6 +78,10 @@ public class ZyTest {
|
|||||||
@Test
|
@Test
|
||||||
public void merSyncEnterpriseInfo() {
|
public void merSyncEnterpriseInfo() {
|
||||||
ZyMerSyncEnterpriseInfoDto dto = new ZyMerSyncEnterpriseInfoDto();
|
ZyMerSyncEnterpriseInfoDto dto = new ZyMerSyncEnterpriseInfoDto();
|
||||||
|
dto.setEPID("1");
|
||||||
|
dto.setEPName("测试部门");
|
||||||
|
dto.setIsValid(1);
|
||||||
|
dto.setFixId("20190920100101");
|
||||||
ZyMerSyncEnterpriseInfoVo vo = zyMerService.syncEnterpriseInfoApi(List.of(dto));
|
ZyMerSyncEnterpriseInfoVo vo = zyMerService.syncEnterpriseInfoApi(List.of(dto));
|
||||||
System.out.println(vo);
|
System.out.println(vo);
|
||||||
}
|
}
|
||||||
@@ -88,6 +92,9 @@ public class ZyTest {
|
|||||||
@Test
|
@Test
|
||||||
public void merSyncAccountInfoApi() {
|
public void merSyncAccountInfoApi() {
|
||||||
ZyMerSyncAccountInfoDto dto = new ZyMerSyncAccountInfoDto();
|
ZyMerSyncAccountInfoDto dto = new ZyMerSyncAccountInfoDto();
|
||||||
|
dto.setEPID("1");
|
||||||
|
dto.setAccName("测试部门");
|
||||||
|
dto.setEPID("1");
|
||||||
ZyMerSyncAccountInfoVo vo = zyMerService.syncAccountInfoApi(List.of(dto));
|
ZyMerSyncAccountInfoVo vo = zyMerService.syncAccountInfoApi(List.of(dto));
|
||||||
System.out.println(vo);
|
System.out.println(vo);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-6
@@ -24,6 +24,7 @@ import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
|||||||
import com.bsd.pjcloud.common.core.util.R;
|
import com.bsd.pjcloud.common.core.util.R;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -34,11 +35,18 @@ import java.util.List;
|
|||||||
@FeignClient(contextId = "remoteRoleService", value = ServiceNameConstants.UPMS_SERVICE)
|
@FeignClient(contextId = "remoteRoleService", value = ServiceNameConstants.UPMS_SERVICE)
|
||||||
public interface RemoteRoleService {
|
public interface RemoteRoleService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有部门接口
|
* 获取所有部门接口
|
||||||
* @return R 返回结果对象,包含所有部门信息列表
|
*
|
||||||
*/
|
* @return R 返回结果对象,包含所有部门信息列表
|
||||||
@GetMapping("/role/list")
|
*/
|
||||||
R<List<SysRole>> getAllRole();
|
@GetMapping("/role/list")
|
||||||
|
R<List<SysRole>> getAllRole();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@GetMapping("/role/by-codes")
|
||||||
|
R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes);
|
||||||
|
|
||||||
}
|
}
|
||||||
+7
@@ -33,6 +33,7 @@ import com.bsd.pjcloud.common.excel.annotation.RequestExcel;
|
|||||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||||
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
import com.bsd.pjcloud.common.security.annotation.HasPermission;
|
||||||
|
import com.bsd.pjcloud.common.security.annotation.Inner;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@@ -58,6 +59,12 @@ public class SysRoleController {
|
|||||||
|
|
||||||
private final SysRoleService sysRoleService;
|
private final SysRoleService sysRoleService;
|
||||||
|
|
||||||
|
@Inner
|
||||||
|
@PostMapping("/by-codes")
|
||||||
|
public R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes) {
|
||||||
|
return R.ok(sysRoleService.findRolesByCodes(codes));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过ID查询角色信息
|
* 通过ID查询角色信息
|
||||||
* @param id ID
|
* @param id ID
|
||||||
|
|||||||
+7
@@ -53,6 +53,13 @@ public interface SysRoleService extends IService<SysRole> {
|
|||||||
*/
|
*/
|
||||||
List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key);
|
List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据角色标识 查询角色列表
|
||||||
|
* @param codes 角色标识
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysRole> findRolesByCodes(List<String> codes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过角色ID,删除角色
|
* 通过角色ID,删除角色
|
||||||
* @param ids
|
* @param ids
|
||||||
|
|||||||
+2
@@ -1,4 +1,6 @@
|
|||||||
package com.bsd.pjcloud.admin.service;
|
package com.bsd.pjcloud.admin.service;
|
||||||
|
|
||||||
public interface SysThirdZyService {
|
public interface SysThirdZyService {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+119
-104
@@ -22,6 +22,8 @@ package com.bsd.pjcloud.admin.service.impl;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||||
@@ -59,120 +61,133 @@ import java.util.stream.Collectors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||||
|
|
||||||
private SysRoleMenuService roleMenuService;
|
private SysRoleMenuService roleMenuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID,查询角色信息
|
* 通过用户ID,查询角色信息
|
||||||
* @param userId
|
*
|
||||||
* @return
|
* @param userId
|
||||||
*/
|
* @return
|
||||||
@Override
|
*/
|
||||||
public List findRolesByUserId(Long userId) {
|
@Override
|
||||||
return baseMapper.listRolesByUserId(userId);
|
public List findRolesByUserId(Long userId) {
|
||||||
}
|
return baseMapper.listRolesByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色ID 查询角色列表,注意缓存删除
|
* 根据角色ID 查询角色列表,注意缓存删除
|
||||||
* @param roleIdList 角色ID列表
|
*
|
||||||
* @param key 缓存key
|
* @param roleIdList 角色ID列表
|
||||||
* @return
|
* @param key 缓存key
|
||||||
*/
|
* @return
|
||||||
@Override
|
*/
|
||||||
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
|
@Override
|
||||||
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
|
@Cacheable(value = CacheConstants.ROLE_DETAILS, key = "#key", unless = "#result.isEmpty()")
|
||||||
return baseMapper.selectBatchIds(roleIdList);
|
public List<SysRole> findRolesByRoleIds(List<Long> roleIdList, String key) {
|
||||||
}
|
return baseMapper.selectBatchIds(roleIdList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 通过角色ID,删除角色,并清空角色菜单缓存
|
public List<SysRole> findRolesByCodes(List<String> codes) {
|
||||||
* @param ids
|
if (ObjectUtil.isEmpty(codes)) return null;
|
||||||
* @return
|
return baseMapper.selectList(new LambdaQueryWrapper<SysRole>()
|
||||||
*/
|
.in(SysRole::getRoleCode, codes)
|
||||||
@Override
|
);
|
||||||
@Transactional(rollbackFor = Exception.class)
|
}
|
||||||
public Boolean removeRoleByIds(Long[] ids) {
|
|
||||||
roleMenuService
|
|
||||||
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
|
||||||
return this.removeBatchByIds(CollUtil.toList(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据角色菜单列表
|
* 通过角色ID,删除角色,并清空角色菜单缓存
|
||||||
* @param roleVo 角色&菜单列表
|
*
|
||||||
* @return
|
* @param ids
|
||||||
*/
|
* @return
|
||||||
@Override
|
*/
|
||||||
public Boolean updateRoleMenus(RoleMenuVO roleVo) {
|
@Override
|
||||||
return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds());
|
@Transactional(rollbackFor = Exception.class)
|
||||||
}
|
public Boolean removeRoleByIds(Long[] ids) {
|
||||||
|
roleMenuService
|
||||||
|
.remove(Wrappers.<SysRoleMenu>update().lambda().in(SysRoleMenu::getRoleId, CollUtil.toList(ids)));
|
||||||
|
return this.removeBatchByIds(CollUtil.toList(ids));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入角色
|
* 根据角色菜单列表
|
||||||
* @param excelVOList 角色列表
|
*
|
||||||
* @param bindingResult 错误信息列表
|
* @param roleVo 角色&菜单列表
|
||||||
* @return ok fail
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R importRole(List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
|
public Boolean updateRoleMenus(RoleMenuVO roleVo) {
|
||||||
// 通用校验获取失败的数据
|
return roleMenuService.saveRoleMenus(roleVo.getRoleId(), roleVo.getMenuIds());
|
||||||
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
}
|
||||||
|
|
||||||
// 个性化校验逻辑
|
/**
|
||||||
List<SysRole> roleList = this.list();
|
* 导入角色
|
||||||
|
*
|
||||||
|
* @param excelVOList 角色列表
|
||||||
|
* @param bindingResult 错误信息列表
|
||||||
|
* @return ok fail
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public R importRole(List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
|
||||||
|
// 通用校验获取失败的数据
|
||||||
|
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
|
||||||
|
|
||||||
// 执行数据插入操作 组装 RoleDto
|
// 个性化校验逻辑
|
||||||
for (RoleExcelVO excel : excelVOList) {
|
List<SysRole> roleList = this.list();
|
||||||
Set<String> errorMsg = new HashSet<>();
|
|
||||||
// 检验角色名称或者角色编码是否存在
|
|
||||||
boolean existRole = roleList.stream()
|
|
||||||
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
|
||||||
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
|
||||||
|
|
||||||
if (existRole) {
|
// 执行数据插入操作 组装 RoleDto
|
||||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
for (RoleExcelVO excel : excelVOList) {
|
||||||
excel.getRoleCode()));
|
Set<String> errorMsg = new HashSet<>();
|
||||||
}
|
// 检验角色名称或者角色编码是否存在
|
||||||
|
boolean existRole = roleList.stream()
|
||||||
|
.anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName())
|
||||||
|
|| excel.getRoleCode().equals(sysRole.getRoleCode()));
|
||||||
|
|
||||||
// 数据合法情况
|
if (existRole) {
|
||||||
if (CollUtil.isEmpty(errorMsg)) {
|
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
|
||||||
insertExcelRole(excel);
|
excel.getRoleCode()));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// 数据不合法情况
|
|
||||||
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(errorMessageList)) {
|
|
||||||
return R.failed(errorMessageList);
|
|
||||||
}
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// 数据合法情况
|
||||||
* 查询全部的角色
|
if (CollUtil.isEmpty(errorMsg)) {
|
||||||
* @return list
|
insertExcelRole(excel);
|
||||||
*/
|
} else {
|
||||||
@Override
|
// 数据不合法情况
|
||||||
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
||||||
List<SysRole> roleList = this
|
}
|
||||||
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
}
|
||||||
// 转换成execl 对象输出
|
if (CollUtil.isNotEmpty(errorMessageList)) {
|
||||||
return roleList.stream().map(role -> {
|
return R.failed(errorMessageList);
|
||||||
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
}
|
||||||
BeanUtil.copyProperties(role, roleExcelVO);
|
return R.ok();
|
||||||
return roleExcelVO;
|
}
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入excel Role
|
* 查询全部的角色
|
||||||
*/
|
*
|
||||||
private void insertExcelRole(RoleExcelVO excel) {
|
* @return list
|
||||||
SysRole sysRole = new SysRole();
|
*/
|
||||||
sysRole.setRoleName(excel.getRoleName());
|
@Override
|
||||||
sysRole.setRoleDesc(excel.getRoleDesc());
|
public List<RoleExcelVO> listRole(SysRole sysRole, Long[] ids) {
|
||||||
sysRole.setRoleCode(excel.getRoleCode());
|
List<SysRole> roleList = this
|
||||||
this.save(sysRole);
|
.list(Wrappers.lambdaQuery(sysRole).in(ArrayUtil.isNotEmpty(ids), SysRole::getRoleId, ids));
|
||||||
}
|
// 转换成execl 对象输出
|
||||||
|
return roleList.stream().map(role -> {
|
||||||
|
RoleExcelVO roleExcelVO = new RoleExcelVO();
|
||||||
|
BeanUtil.copyProperties(role, roleExcelVO);
|
||||||
|
return roleExcelVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入excel Role
|
||||||
|
*/
|
||||||
|
private void insertExcelRole(RoleExcelVO excel) {
|
||||||
|
SysRole sysRole = new SysRole();
|
||||||
|
sysRole.setRoleName(excel.getRoleName());
|
||||||
|
sysRole.setRoleDesc(excel.getRoleDesc());
|
||||||
|
sysRole.setRoleCode(excel.getRoleCode());
|
||||||
|
this.save(sysRole);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+18
-5
@@ -1,25 +1,38 @@
|
|||||||
package com.bsd.pjcloud.admin.service.impl.third;
|
package com.bsd.pjcloud.admin.service.impl.third;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||||
|
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||||
|
import com.bsd.pjcloud.admin.service.SysRoleService;
|
||||||
import com.bsd.pjcloud.admin.service.SysThirdZyService;
|
import com.bsd.pjcloud.admin.service.SysThirdZyService;
|
||||||
|
import com.bsd.pjcloud.admin.service.SysUserService;
|
||||||
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService;
|
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SysThirdZyServiceImpl implements SysThirdZyService {
|
public class SysThirdZyServiceImpl implements SysThirdZyService {
|
||||||
|
|
||||||
|
private static final String TAG = "用户模块同步到正元信息";
|
||||||
|
|
||||||
private RemoterThirdZyService thirdZyService;
|
private final SysRoleService roleService;
|
||||||
|
private final SysUserService userService;
|
||||||
|
|
||||||
|
private final RemoterThirdZyService thirdZyService;
|
||||||
|
|
||||||
private void syncRole() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void syncUser() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,12 @@
|
|||||||
<groupId>com.bsd</groupId>
|
<groupId>com.bsd</groupId>
|
||||||
<artifactId>pjcloud-flow-task-api</artifactId>
|
<artifactId>pjcloud-flow-task-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bsd</groupId>
|
||||||
|
<artifactId>pjcloud-thirdparty-api</artifactId>
|
||||||
|
<version>5.7.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package com.bsd.pjcloud.wallet.controller.third;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.bsd.pjcloud.common.core.util.R;
|
||||||
|
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||||
|
import com.bsd.pjcloud.wallet.service.MchThirdZyService;
|
||||||
|
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.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/mch-third-zy")
|
||||||
|
@Tag(description = "wallet-active", name = "钱包开卡管理")
|
||||||
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||||
|
@Validated
|
||||||
|
public class MchThirdZyController {
|
||||||
|
|
||||||
|
private final MchThirdZyService mchThirdZyService;
|
||||||
|
|
||||||
|
@GetMapping("/sync-all-mch")
|
||||||
|
@Operation(summary = "同步全部商户")
|
||||||
|
public R<MchManageVo> syncAllMch(@RequestParam Long id) {
|
||||||
|
mchThirdZyService.syncAllMch();
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/sync-all-dept")
|
||||||
|
@Operation(summary = "同步全部商户部门")
|
||||||
|
public R<MchManageVo> syncAllDept() {
|
||||||
|
mchThirdZyService.syncAllDept();
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.bsd.pjcloud.wallet.service;
|
||||||
|
|
||||||
|
public interface MchThirdZyService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步全部商户
|
||||||
|
*/
|
||||||
|
void syncAllMch();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步全部商户部门
|
||||||
|
*/
|
||||||
|
void syncAllDept();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步到正元全部身份信息
|
||||||
|
*/
|
||||||
|
void syncAllUser();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步到正元全部身份信息
|
||||||
|
*/
|
||||||
|
void syncAllRole();
|
||||||
|
|
||||||
|
}
|
||||||
+11
-1
@@ -164,7 +164,17 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MchManageVo> list(MchManageDto dto) {
|
public List<MchManageVo> list(MchManageDto dto) {
|
||||||
return baseMapper.list(dto);
|
List<MchManageVo> list = baseMapper.list(dto);
|
||||||
|
if (ObjectUtil.isEmpty(list)) return null;
|
||||||
|
// 部门
|
||||||
|
List<Long> deptIds = list.stream().map(MchManageVo::getDeptId).distinct().toList();
|
||||||
|
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||||
|
R<Map<Long, SysDept>> deptList = remoteDeptService.getDeptByDeptIds(deptIds);
|
||||||
|
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||||
|
DataUtil.convertDeptList(list, deptList.getData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+176
@@ -0,0 +1,176 @@
|
|||||||
|
package com.bsd.pjcloud.wallet.service.impl.thrid;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||||
|
import com.bsd.pjcloud.admin.api.entity.SysRole;
|
||||||
|
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||||
|
import com.bsd.pjcloud.admin.api.feign.RemoteRoleService;
|
||||||
|
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||||
|
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
|
||||||
|
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdZyService;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccClassInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncAccountInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncDealerInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.zy.mer.ZyMerSyncEnterpriseInfoDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccClassInfoVo;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncAccountInfoVo;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncDealerInfoVo;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.zy.mer.ZyMerSyncEnterpriseInfoVo;
|
||||||
|
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
|
||||||
|
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||||
|
import com.bsd.pjcloud.wallet.api.entity.MchManageEntity;
|
||||||
|
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||||
|
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||||
|
import com.bsd.pjcloud.wallet.service.MchManageService;
|
||||||
|
import com.bsd.pjcloud.wallet.service.MchThirdZyService;
|
||||||
|
import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class MchThirdZyServiceImpl implements MchThirdZyService {
|
||||||
|
|
||||||
|
private static final String TAG = "用户模块同步到正元信息";
|
||||||
|
|
||||||
|
private final RemoterThirdZyService thirdZyService;
|
||||||
|
private final RemoteDeptService remoteDeptService;
|
||||||
|
private final RemoteRoleService remoteRoleService;
|
||||||
|
|
||||||
|
private final MchManageService mchManageService;
|
||||||
|
private final WalletManageService walletManageService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void syncAllMch() {
|
||||||
|
List<MchManageEntity> mchList = mchManageService.list();
|
||||||
|
if (ObjectUtil.isEmpty(mchList)) {
|
||||||
|
log.info("|{}|同步到正元全部商户信息错误mchList为空", TAG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ZyMerSyncDealerInfoDto> syncList = new ArrayList<>();
|
||||||
|
for (MchManageEntity v : mchList) {
|
||||||
|
ZyMerSyncDealerInfoDto entity = new ZyMerSyncDealerInfoDto();
|
||||||
|
entity.setDealerKeyObj(v.getId().toString());
|
||||||
|
entity.setDealerName(v.getName());
|
||||||
|
entity.setIsValid(1);
|
||||||
|
entity.setEPID("");
|
||||||
|
entity.setFixId(getSyncAllMchVersion());
|
||||||
|
syncList.add(entity);
|
||||||
|
}
|
||||||
|
ZyMerSyncDealerInfoVo res = thirdZyService.syncDealerInfo(syncList).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void syncAllDept() {
|
||||||
|
List<SysDept> mchList = remoteDeptService.getAllDept(null).getData();
|
||||||
|
if (ObjectUtil.isEmpty(mchList)) {
|
||||||
|
log.info("|{}|同步到正元全部商户部门信息错误mchList为空", TAG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ZyMerSyncEnterpriseInfoDto> syncList = new ArrayList<>();
|
||||||
|
for (SysDept v : mchList) {
|
||||||
|
ZyMerSyncEnterpriseInfoDto entity = new ZyMerSyncEnterpriseInfoDto();
|
||||||
|
entity.setEPID(v.getDeptId().toString());
|
||||||
|
entity.setEPName(v.getName());
|
||||||
|
entity.setIsValid(1);
|
||||||
|
entity.setFixId(getSyncAllMchVersion());
|
||||||
|
syncList.add(entity);
|
||||||
|
}
|
||||||
|
ZyMerSyncEnterpriseInfoVo res = thirdZyService.syncEnterpriseInfoApi(syncList).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void syncAllUser() {
|
||||||
|
Page page = new Page();
|
||||||
|
page.setCurrent(1);
|
||||||
|
page.setSize(500);
|
||||||
|
boolean isResidue = true;
|
||||||
|
while (isResidue) {
|
||||||
|
isResidue = syncAllUserGroup(page);
|
||||||
|
if (!isResidue) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步到正元全部身份信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void syncAllRole() {
|
||||||
|
// 查询需要同步的身份信息
|
||||||
|
List<SysRole> roleList = remoteRoleService.findRolesByCodes(List.of("GENERAL_USER")).getData();
|
||||||
|
if (ObjectUtil.isEmpty(roleList)) {
|
||||||
|
log.info("|{}|同步到正元全部身份信息错误roleList为空", TAG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<ZyMerSyncAccClassInfoDto> syncList = new ArrayList<>();
|
||||||
|
for (SysRole v : roleList) {
|
||||||
|
ZyMerSyncAccClassInfoDto entity = new ZyMerSyncAccClassInfoDto();
|
||||||
|
entity.setAccClassID(v.getRoleId().toString());
|
||||||
|
entity.setAccClassName(v.getRoleName());
|
||||||
|
entity.setEPID("1");
|
||||||
|
entity.setFixId(getSyncAllRoleVersion());
|
||||||
|
syncList.add(entity);
|
||||||
|
}
|
||||||
|
ZyMerSyncAccClassInfoVo res = thirdZyService.syncAccClassInfoApi(syncList).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean syncAllUserGroup(Page page) {
|
||||||
|
WalletManageDto query = new WalletManageDto();
|
||||||
|
DataScope dataScope = DataScope.of();
|
||||||
|
dataScope.func(DataScopeFuncEnum.ALL);
|
||||||
|
Page<WalletManageVo> userPage = walletManageService.scopePageList(page, query, dataScope);
|
||||||
|
if (ObjectUtil.isEmpty(userPage.getRecords())) return false;
|
||||||
|
List<ZyMerSyncAccountInfoDto> syncList = new ArrayList<>();
|
||||||
|
for (WalletManageVo v : userPage.getRecords()) {
|
||||||
|
ZyMerSyncAccountInfoDto item = new ZyMerSyncAccountInfoDto();
|
||||||
|
item.setAccName(v.getUsername());
|
||||||
|
item.setAccNum(v.getUserId().toString());
|
||||||
|
item.setCardAccNum(v.getId());
|
||||||
|
item.setCardSID(v.getCardNumber());
|
||||||
|
item.setCardStatus(getCardStatus(v.getCardNumber()));
|
||||||
|
item.setEPID("");
|
||||||
|
item.setAccClassID("");
|
||||||
|
item.setPhoneNo(v.getUserMobile());
|
||||||
|
item.setFixId(getSyncAllUserVersion());
|
||||||
|
syncList.add(item);
|
||||||
|
}
|
||||||
|
ZyMerSyncAccountInfoVo res = thirdZyService.syncAccountInfoApi(syncList).getData();
|
||||||
|
|
||||||
|
return userPage.getTotal() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ************************************* start 版本号 start ************************************* */
|
||||||
|
|
||||||
|
private String getSyncAllMchVersion() {
|
||||||
|
return String.format("%014d", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSyncAllDeptVersion() {
|
||||||
|
return String.format("%014d", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSyncAllUserVersion() {
|
||||||
|
return String.format("%014d", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSyncAllRoleVersion() {
|
||||||
|
return String.format("%014d", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************* end 版本号 end ************************************* */
|
||||||
|
|
||||||
|
// 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
|
||||||
|
private Integer getCardStatus(String cardNumber) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user