正元同步
This commit is contained in:
1 parent
00d159c8c0
commit
54a46dd9ee
20 files changed
+474
-137
No files matched your search
@@ -112,6 +112,12 @@
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-flow-task-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-thirdparty-api</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<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
|
||||
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
|
||||
|
||||
+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