feat:正元同步交易数据、用户信息、修改用户钱包状态

This commit is contained in:
dzc committed 2025-03-05 12:02:49 +08:00
1 parent 683bd6a3f8
commit 93d7fddad1
24 files changed
+228 -94

No files matched your search

+18 -18
View File
@@ -37,24 +37,24 @@ CREATE INDEX idx_dept_id ON mch_manage (dept_id);
DROP TABLE IF EXISTS wallet_manage;
CREATE TABLE wallet_manage
(
id bigint NOT NULL COMMENT '主键',
user_id bigint NOT NULL COMMENT '饭卡绑定的用户id',
wallet_type_id bigint NOT NULL COMMENT '饭卡类型id',
dept_id bigint NOT NULL COMMENT '部门id',
card_number varchar(64) COMMENT '饭卡卡号',
balance int DEFAULT 0 NOT NULL COMMENT '余额,单位分',
total_expense int DEFAULT 0 NOT NULL COMMENT '累计支出,单位分',
total_recharge int DEFAULT 0 NOT NULL COMMENT '累计充值,单位分',
freeze_price int DEFAULT 0 NOT NULL COMMENT '冻结金额,单位分',
is_freeze char(1) DEFAULT '0' NOT NULL COMMENT '是否冻结饭卡',
active_bind_time timestamp COMMENT '绑定饭卡时间',
active_bind_status char(10) COMMENT '饭卡绑定状态',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
id bigint NOT NULL COMMENT '主键',
user_id bigint NOT NULL COMMENT '饭卡绑定的用户id',
wallet_type_id bigint NOT NULL COMMENT '饭卡类型id',
dept_id bigint NOT NULL COMMENT '部门id',
card_number varchar(64) COMMENT '饭卡卡号',
balance int DEFAULT 0 NOT NULL COMMENT '余额,单位分',
total_expense int DEFAULT 0 NOT NULL COMMENT '累计支出,单位分',
total_recharge int DEFAULT 0 NOT NULL COMMENT '累计充值,单位分',
freeze_price int DEFAULT 0 NOT NULL COMMENT '冻结金额,单位分',
is_freeze char(1) DEFAULT '0' NOT NULL COMMENT '是否冻结饭卡',
active_bind_time timestamp COMMENT '绑定饭卡时间',
status char(10) COMMENT '饭卡绑定状态',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
@@ -191,14 +191,14 @@
<select id="totalYearMonthDay" resultType="com.bsd.pjcloud.hard.api.vo.order.HardZyCardSyncVo">
SELECT
COUNT(0) AS totalNum,
SUM(a.pay_price) AS totalMoney,
SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN 1 ELSE 0 END) AS totalNumYear,
SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN a.pay_price ELSE 0 END) AS totalMoneyYear,
SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) THEN 1 ELSE 0 END) AS totalNumMonth,
SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) THEN a.pay_price ELSE 0 END) AS totalMoneyMonth,
SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN 1 ELSE 0 END) AS totalNumDay,
SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN a.pay_price ELSE 0 END) AS totalMoneyDay
COALESCE(COUNT(0), 0) AS totalNum,
COALESCE(SUM(a.pay_price), 0) AS totalMoney,
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumYear,
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyYear,
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumMonth,
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyMonth,
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumDay,
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyDay
FROM
hard_order a
<where>
@@ -62,7 +62,7 @@ public interface RemoterThirdZyService {
*/
@NoToken
@PostMapping("/third-zy-mer/sync-account-info")
R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto);
R<ZyMerSyncAccountInfoVo.DataVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto);
/**
* 身份信息同步
@@ -24,7 +24,7 @@ public class ZyForeignSyncNativeCardTradeInfoDto {
/**
* 就餐总人数,从推广公务餐之日起,即总人数
*/
private Long totalNum = 0L;
private Long totalNum;
/**
* 就餐总金额,从推广公务餐之日起,即总金额
@@ -44,7 +44,7 @@ public class ZyForeignSyncNativeCardTradeInfoDto {
/**
* 当月就餐总人数,从当月1日开始
*/
private Long totalNumMonth = 0L;
private Long totalNumMonth;
/**
* 当月就餐总金额,从当月1日开始
@@ -54,7 +54,7 @@ public class ZyForeignSyncNativeCardTradeInfoDto {
/**
* 当日就餐总人数
*/
private Long totalNumDay = 0L;
private Long totalNumDay;
/**
* 当日就餐总金额
@@ -1,6 +1,8 @@
package com.bsd.pjcloud.thirdparty.vo.zy;
import lombok.Data;
import cn.hutool.core.codec.Base64;
@Data
public class ZyBaseEncryptVo {
@@ -14,4 +16,8 @@ public class ZyBaseEncryptVo {
public boolean isSuccess() {
return successCode.equals(code);
}
public String getDecodeBase64Data() {
return Base64.decodeStr(data);
}
}
@@ -10,7 +10,7 @@ import lombok.Data;
public class ZyMerSyncAccountInfoVo extends ZyBaseVo {
@Data
static class DataVo{
public static class DataVo {
/**
* 当前智慧园区通刷服务平台保存的最新同步版本号,返回该版本号,要求第三方一卡通系统同步这个大于这个版本号的数据
*/
@@ -10,10 +10,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequiredArgsConstructor
@@ -28,7 +25,7 @@ public class ThirdZyForeignController {
@Inner
@Operation(summary = "本地一卡通交易数据同步")
@GetMapping("/sync-native-card")
@PostMapping("/sync-native-card")
public R<ZyForeignSyncNativeCardTradeInfoVo> syncNativeCardTradeInfoApi(@RequestBody ZyForeignSyncNativeCardTradeInfoDto dto) {
return R.ok(zyForeignService.syncNativeCardTradeInfoApi(dto));
}
@@ -50,7 +50,7 @@ public class ThirdZyMerController {
@Inner
@Operation(summary = "账户信息同步")
@PostMapping("/sync-account-info")
public R<ZyMerSyncAccountInfoVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto) {
public R<ZyMerSyncAccountInfoVo.DataVo> syncAccountInfoApi(@RequestBody List<ZyMerSyncAccountInfoDto> dto) {
return R.ok(thirdZyMerService.syncAccountInfoApi(dto));
}
@@ -23,7 +23,7 @@ public interface ThirdZyMerService {
/**
* 账户信息同步
*/
ZyMerSyncAccountInfoVo syncAccountInfoApi(List<ZyMerSyncAccountInfoDto> dto);
ZyMerSyncAccountInfoVo.DataVo syncAccountInfoApi(List<ZyMerSyncAccountInfoDto> dto);
/**
* 身份信息同步
@@ -1,11 +1,13 @@
package com.bsd.pjcloud.thirdparty.service.impl.zy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.thirdparty.config.ZyConfig;
import com.bsd.pjcloud.thirdparty.constant.ThirdZyBizEnumType;
import com.bsd.pjcloud.thirdparty.dto.zy.foreign.ZyForeignSyncNativeCardTradeInfoDto;
import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyForeignService;
@@ -47,7 +49,9 @@ public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
*/
@Override
public ZyForeignSyncNativeCardTradeInfoVo syncNativeCardTradeInfoApi(ZyForeignSyncNativeCardTradeInfoDto dto) {
ThirdZyBizEnumType bizTYpe = ThirdZyBizEnumType.SYNC_NATIVE_CARD_INFO;
ThirdZyLogEntity entity = new ThirdZyLogEntity();
entity.setBizType(bizTYpe.getType());
long startTime = System.currentTimeMillis();
String url = zyConfig.getBaseUrl() + ZyApi.Foreign.SYNC_NATIVE_CARD_TRADE_INFO;
try {
@@ -59,12 +63,11 @@ public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
dto.setRegionCode(regionInfo.getRegionCode());
}
url = String.format(url, zyApiTool.getToken());
Map<String, Object> encryptionBody = new HashMap<>();
encryptionBody.put("regionCode", dto);
Map<String, Object> encryptionBody = BeanUtil.beanToMap(dto);
entity.setApiUrl(url);
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
String body = zyApiTool.getEncryptionDto(encryptionBody);
entity.setEncipherReq(body);
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
entity.setEncipherReq(JSONUtil.toJsonStr(body));
String res = HttpRequest.post(url).form(body).execute().body();
if (ObjectUtil.isEmpty(res)) {
throw new RuntimeException("response is empty");
@@ -93,7 +96,9 @@ public class ThirdZyForeignServiceImpl implements ThirdZyForeignService {
*/
@Override
public ZyForeignGetRegionIdByTokenVo.VoData getRegionIdByToken() {
ThirdZyBizEnumType bizTYpe = ThirdZyBizEnumType.GET_REGION_ID_BY_TOKEN;
ThirdZyLogEntity entity = new ThirdZyLogEntity();
entity.setBizType(bizTYpe.getType());
long startTime = System.currentTimeMillis();
String url = zyConfig.getBaseUrl() + ZyApi.Foreign.GET_REGION_ID_BY_TOKEN;
try {
@@ -14,6 +14,7 @@ import com.bsd.pjcloud.thirdparty.entity.zy.ThirdZyLogEntity;
import com.bsd.pjcloud.thirdparty.service.impl.ThirdZyMerService;
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApi;
import com.bsd.pjcloud.thirdparty.utils.zy.api.ZyApiTool;
import com.bsd.pjcloud.thirdparty.vo.zy.ZyBaseEncryptVo;
import com.bsd.pjcloud.thirdparty.vo.zy.mer.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -59,7 +60,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
v.setEPID(deptDdDict.get(v.getEPID()));
v.setDealerKeyObj(mchIdDict.get(v.getDealerKeyObj()));
Map<String, Object> map = zyApiTool.removeEmptyMap(BeanUtil.beanToMap(v));
listMap.add(map);
if (ObjectUtil.isNotEmpty(map)) listMap.add(map);
}
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_DEALER_INFO;
try {
@@ -109,7 +110,7 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
for (ZyMerSyncEnterpriseInfoDto v : dto) {
v.setEPID(idDict.get(v.getEPID()));
Map<String, Object> map = zyApiTool.removeEmptyMap(BeanUtil.beanToMap(v));
listMap.add(map);
if (ObjectUtil.isNotEmpty(map)) listMap.add(map);
}
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ENTERPRISE_INFO;
try {
@@ -147,27 +148,52 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
* 账户信息同步
*/
@Override
public ZyMerSyncAccountInfoVo syncAccountInfoApi(List<ZyMerSyncAccountInfoDto> dto) {
public ZyMerSyncAccountInfoVo.DataVo syncAccountInfoApi(List<ZyMerSyncAccountInfoDto> dto) {
ThirdZyBizEnumType bizType = ThirdZyBizEnumType.SYNC_ACCOUNT_INFO;
ThirdZyLogEntity entity = new ThirdZyLogEntity();
entity.setBizType(bizType.getType());
long startTime = System.currentTimeMillis();
// 转换部门zyId
List<String> deptList = dto.stream().map(ZyMerSyncAccountInfoDto::getEPID).distinct().toList();
Map<String, String> deptIdDict = zyApiTool.generateZyId(ThirdZyBizEnumType.SYNC_ENTERPRISE_INFO, deptList);
// 转换用户zyId
List<String> userList = dto.stream().map(ZyMerSyncAccountInfoDto::getAccNum).distinct().toList();
Map<String, String> userIdDict = zyApiTool.generateZyId(bizType, userList);
// 转换身份编号
List<String> roleList = dto.stream().map(ZyMerSyncAccountInfoDto::getAccClassID).distinct().toList();
Map<String, String> roleIdDict = zyApiTool.generateZyId(bizType, roleList);
for (ZyMerSyncAccountInfoDto v : dto) {
v.setEPID(deptIdDict.get(v.getEPID()));
v.setAccNum(userIdDict.get(v.getAccNum()));
v.setAccClassID(roleIdDict.get(v.getAccClassID()));
}
String url = zyConfig.getBaseUrl() + ZyApi.Mer.SYNC_ACCOUNT_INFO;
try {
OptionalLong maxFixId = dto.stream().map(ZyMerSyncAccountInfoDto::getFixId).mapToLong(Long::valueOf).max();
if (maxFixId.isEmpty()) {
throw new RuntimeException("maxFixId获取错误");
}
url = String.format(url, zyApiTool.getToken());
Map<String, Object> encryptionBody = new HashMap<>();
encryptionBody.put("accounts", dto);
encryptionBody.put("data", Map.of("accounts", dto));
encryptionBody.put("currentMaxFixId", String.valueOf(maxFixId.getAsLong()));
entity.setApiUrl(url);
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody, "data", "currentMaxFixId");
entity.setEncipherReq(JSONUtil.toJsonStr(body));
String res = HttpRequest.post(url).form(body).execute().body();
if (ObjectUtil.isEmpty(res)) {
throw new RuntimeException("response is empty");
}
entity.setEncipherRes(res);
ZyMerSyncAccountInfoVo vo = JSONUtil.toBean(res, ZyMerSyncAccountInfoVo.class);
if (!vo.isSuccess()) {
throw new RuntimeException(String.format("请求错误res|%s|url|%s|body|%s|", res, url, body));
ZyBaseEncryptVo baseEncryptVo = JSONUtil.toBean(res, ZyBaseEncryptVo.class);
if (ObjectUtil.isEmpty(baseEncryptVo)) {
throw new RuntimeException(String.format("解密错误res|%s|url|%s|res|%s|", res, url, baseEncryptVo));
}
if (!baseEncryptVo.isSuccess()) {
throw new RuntimeException(String.format("请求错误res|%s|url|%s|", res, url));
}
ZyMerSyncAccountInfoVo.DataVo vo = JSONUtil.toBean(baseEncryptVo.getDecodeBase64Data(), ZyMerSyncAccountInfoVo.DataVo.class);
entity.setOrgRes(JSONUtil.toJsonStr(vo));
return vo;
} catch (Exception e) {
@@ -200,11 +226,11 @@ public class ThirdZyMerServiceImpl implements ThirdZyMerService {
for (ZyMerSyncAccClassInfoDto v : dto) {
v.setEPID(roleIdDict.get(v.getEPID()));
Map<String, Object> map = zyApiTool.removeEmptyMap(BeanUtil.beanToMap(v));
listMap.add(map);
if (ObjectUtil.isNotEmpty(map)) listMap.add(map);
}
url = String.format(url, zyApiTool.getToken());
Map<String, Object> encryptionBody = new HashMap<>();
encryptionBody.put("accClasses", dto);
encryptionBody.put("accClasses", listMap);
entity.setApiUrl(url);
entity.setOrgReq(JSONUtil.toJsonStr(encryptionBody));
Map<String, Object> body = zyApiTool.getEncryptionMap(encryptionBody);
@@ -34,7 +34,7 @@ public class ZyApi {
// 本地一卡通交易数据同步
public static class Foreign {
// 本地一卡通交易数据同步
public static final String SYNC_NATIVE_CARD_TRADE_INFO = "/api/getToken/syncNativeCardTradeInfo?access_token=%s";
public static final String SYNC_NATIVE_CARD_TRADE_INFO = "/api/syncNativeCardTradeInfo?access_token=%s";
// 获取区域编码
public static final String GET_REGION_ID_BY_TOKEN = "/api/getRegionIdByToken?access_token=%s";
}
@@ -1,6 +1,5 @@
package com.bsd.pjcloud.thirdparty.utils.zy.api;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
@@ -91,15 +90,6 @@ public class ZyApiTool {
return null;
}
public String getEncryptionDto(Map<String, Object> params) {
Map<String, Object> body = new HashMap<>();
body.put("data", params);
prePost(body);
String jsonString = JSON.toJSONString(body, SerializerFeature.DisableCircularReferenceDetect);
log.error(jsonString);
return jsonString;
}
public Map<String, String> generateZyId(ThirdZyBizEnumType type, List<String> selfIds) {
if (!ObjectUtil.isAllNotEmpty(type, selfIds)) return null;
List<ThirdZyIdDictEntity> bySelfIdList = thirdZyIdDictMapper.getBySelfIds(type, selfIds);
@@ -145,6 +135,16 @@ public class ZyApiTool {
return result;
}
public Map<String, Object> getEncryptionMap(Map<String, Object> params, String... str) {
Map<String, Object> body = new LinkedHashMap<>();
if (ObjectUtil.isEmpty(str)) return body;
for (String v : str) {
body.put(v, params.getOrDefault(v, null));
}
prePost(body);
return body;
}
public Map<String, Object> getEncryptionMap(Map<String, Object> params) {
Map<String, Object> body = new HashMap<>();
body.put("data", params);
@@ -153,6 +153,7 @@ public class ZyApiTool {
}
public Map<String, Object> removeEmptyMap(Map<String, Object> params) {
if (ObjectUtil.isEmpty(params)) return null;
for (Map.Entry<String, Object> entry : params.entrySet()) {
Object value = entry.getValue();
if (value == null) {
@@ -0,0 +1,38 @@
package com.bsd.pjcloud.wallet.api.constant;
import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
@Getter
@AllArgsConstructor
public enum WalleCardStatusEnum {
NONE_ACTIVE("0", "未激活"),
ACTIVE("1", "激活"),
REPORT("2", "挂失"),
FREEZE("3", "冻结"),
LOCK("4", "锁卡"),
CANCEL("5", "销卡"),
;
private final String code;
private final String desc;
public static WalleCardStatusEnum valueOfByType(String code) {
return Arrays.stream(WalleCardStatusEnum.values())
.filter(v -> ObjectUtil.equal(v.getCode(), code))
.findFirst().get();
}
public static WalleCardStatusEnum descOf(String description) {
return Arrays.stream(WalleCardStatusEnum.values())
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
.findFirst().get();
}
}
@@ -24,4 +24,14 @@ public class WalletActiveDto extends WalletActiveEntity {
private Long walletTypeId;
private List<Long> userIds;
/**
* 是否绑定用户
*/
private Boolean isBindUser;
/**
* 是否硬件激活
*/
private Boolean isMchActive;
}
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.wallet.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.bsd.pjcloud.wallet.api.constant.WalleCardStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
@@ -81,6 +82,7 @@ public class WalletManageEntity extends Model<WalletManageEntity> {
private Integer freezePrice;
/**
* @deprecated 已废弃
* 是否冻结饭卡
*/
@Schema(description = "是否冻结饭卡")
@@ -93,10 +95,11 @@ public class WalletManageEntity extends Model<WalletManageEntity> {
private LocalDateTime activeBindTime;
/**
* 饭卡绑定状态 1已经绑定 0未绑定
* 饭卡绑定状态
* @see WalleCardStatusEnum
*/
@Schema(description = "饭卡绑定状态")
private String activeBindStatus;
private String status;
/**
* 创建人
@@ -55,7 +55,7 @@ public class WalletDataUtil {
v.setWalletFreezePrice(vo.getFreezePrice());
v.setWalletIsFreeze(vo.getIsFreeze());
v.setWalletActiveBindTime(vo.getActiveBindTime());
v.setWalletActiveBindStatus(vo.getActiveBindStatus());
v.setWalletActiveBindStatus(vo.getStatus());
return v;
}
}
@@ -47,4 +47,5 @@ public class WalletManageVo extends WalletManageEntity implements BaseUserInterf
* 最后充值时间
*/
private LocalDateTime lastTopUpTime;
}
@@ -0,0 +1,27 @@
package com.bsd.pjcloud.wallet.api.vo.base;
public interface BaseWalletActiveInterface {
/**
* 卡号
*/
String getCardNumber();
void setCardNumber(String cardNumber);
/**
* 饭卡激活唯一id
*/
Long getWalletActiveId();
void setWalletActiveId(Long walletActiveId);
/**
* 是否在硬件上激活
*/
String getIsActiveHardware();
void setIsActiveHardware(String isActiveHardware);
}
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.wallet.mapper;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
@@ -33,6 +34,22 @@ public interface WalletActiveMapper extends PjcloudBaseMapper<WalletActiveEntity
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletActiveEntity::getDeptId, dto.getDeptId())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletActiveEntity::getUserId, dto.getUserIds())
.orderByDesc(WalletActiveEntity::getCardSort);
if (ObjectUtil.isNotEmpty(dto.getIsBindUser())) {
if (dto.getIsBindUser()) {
wrapper.isNotNull(WalletActiveEntity::getUserId);
wrapper.isNotNull(WalletActiveEntity::getWalletId);
} else {
wrapper.isNull(WalletActiveEntity::getUserId);
wrapper.isNull(WalletActiveEntity::getWalletId);
}
}
if (ObjectUtil.isNotEmpty(dto.getIsMchActive())) {
if (dto.getIsMchActive()) {
wrapper.eq(WalletActiveEntity::getIsActiveHardware, YesNoEnum.YES.getCode());
} else {
wrapper.eq(WalletActiveEntity::getIsActiveHardware, YesNoEnum.NO.getCode());
}
}
Page list = selectPageByScope(page, wrapper, DataScope.of());
list.setRecords(BeanUtils.toBean(list.getRecords(), WalletActiveVo.class));
return list;
@@ -5,7 +5,6 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysDept;
@@ -16,7 +15,7 @@ import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.wallet.api.constant.WalleCardStatusEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveBindCardDto;
@@ -139,7 +138,7 @@ public class WalletActiveServiceImpl extends ServiceImpl<WalletActiveMapper, Wal
WalletActiveEntity walletActiveObj = WalletActiveEntity.builder().id(walletActive.getId()).userId(dto.getUserId()).walletId(selfWallet.getId()).walletTypeId(selfWallet.getWalletTypeId()).build();
baseMapper.updateById(walletActiveObj);
// 更新用户钱包
WalletManageEntity walletObj = WalletManageEntity.builder().id(selfWallet.getId()).cardNumber(walletActive.getCardNumber()).activeBindStatus(YesNoEnum.YES.getCode()).activeBindTime(LocalDateTime.now()).build();
WalletManageEntity walletObj = WalletManageEntity.builder().id(selfWallet.getId()).cardNumber(walletActive.getCardNumber()).status(WalleCardStatusEnum.ACTIVE.getCode()).activeBindTime(LocalDateTime.now()).build();
walletManageService.updateById(walletObj);
return baseMapper.selectById(walletActiveObj.getId());
}
@@ -208,7 +207,7 @@ public class WalletActiveServiceImpl extends ServiceImpl<WalletActiveMapper, Wal
LambdaUpdateWrapper<WalletManageEntity> walletUpdateWrapper = new LambdaUpdateWrapper<WalletManageEntity>()
.eq(WalletManageEntity::getId, walletActive.getWalletId())
.set(WalletManageEntity::getCardNumber, null)
.set(WalletManageEntity::getActiveBindStatus, YesNoEnum.NO.getCode())
.set(WalletManageEntity::getStatus, WalleCardStatusEnum.NONE_ACTIVE.getCode())
.set(WalletManageEntity::getActiveBindTime, null);
walletManageService.update(walletUpdateWrapper);
return true;
@@ -24,6 +24,7 @@ import com.bsd.pjcloud.flow.task.constant.NodeStatusEnum;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.flow.task.dto.TaskParamDto;
import com.bsd.pjcloud.wallet.api.constant.WalleCardStatusEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletFreezeDto;
import com.bsd.pjcloud.wallet.api.entity.*;
import com.bsd.pjcloud.wallet.api.vo.WalletFreezeVo;
@@ -160,7 +161,7 @@ public class WalletFreezeServiceImpl extends ServiceImpl<WalletFreezeMapper, Wal
baseMapper.updateById(WalletFreezeEntity.builder().id(detail.getId()).freeStatus(YesNoEnum.YES.getCode()).processStatus(processStatus).processTime(LocalDateTime.now()).build());
if (isConsent) {
// 更改钱包状态
WalletManageEntity walletUpdateObj = WalletManageEntity.builder().id(detail.getWalletId()).isFreeze(YesNoEnum.YES.getCode()).build();
WalletManageEntity walletUpdateObj = WalletManageEntity.builder().id(detail.getWalletId()).isFreeze(YesNoEnum.YES.getCode()).status(WalleCardStatusEnum.FREEZE.getCode()).build();
walletManageService.updateById(walletUpdateObj);
}
} catch (Exception e) {
@@ -4,10 +4,8 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
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;
@@ -23,10 +21,10 @@ 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.constant.WalleCardStatusEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
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.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
@@ -160,7 +158,7 @@ public class MchThirdZyServiceImpl implements MchThirdZyService {
public void syncAllUser(Long userId) {
Page page = new Page();
page.setCurrent(1);
page.setSize(100);
page.setSize(10);
// 查询身份信息
List<SysRole> roleList = remoteRoleService.findRolesByCodes(List.of(DEFAULT_USER_ROLE_CODE)).getData();
if (ObjectUtil.isEmpty(roleList)) {
@@ -181,6 +179,7 @@ public class MchThirdZyServiceImpl implements MchThirdZyService {
while (true) {
boolean isNotEmpty = syncAllUserGroup(page, userId, defaultUserRole.get().getRoleId(), walletType.getId());
if (!isNotEmpty) break;
page.setCurrent(page.getCurrent() + 1);
}
}
@@ -199,7 +198,7 @@ public class MchThirdZyServiceImpl implements MchThirdZyService {
// 查询用户
UserInfo user = remoteUserService.getByUserId(v.getUserId()).getData();
if (ObjectUtil.isEmpty(user)) {
log.error("|{}|syncAllUserGroup用户不存在为空WalletManageVo|{}|", TAG, JSONUtil.toJsonStr(v));
log.error("|{}|syncAllUserGroup用户不存在WalletManageVo为空|{}|", TAG, JSONUtil.toJsonStr(v));
continue;
}
MchManageVo mch = mchManageService.getFirstMchByDeptId(user.getSysUser().getDeptId());
@@ -219,20 +218,20 @@ public class MchThirdZyServiceImpl implements MchThirdZyService {
item.setAccNum(v.getUserId().toString());
item.setCardAccNum(v.getId());
item.setCardSID(v.getCardNumber());
item.setCardStatus(getCardStatus(v.getUserId(), v.getCardNumber()));
item.setCardStatus(getCardStatus(v.getStatus()));
item.setEPID(mch.getDeptId().toString());
item.setAccClassID(roleId.toString());
item.setPhoneNo(v.getUserMobile());
item.setFixId(syncAllMchVersion);
syncList.add(item);
}
// try {
// ZyMerSyncAccountInfoVo res = thirdZyService.syncAccountInfoApi(syncList).getData();
// if (ObjectUtil.isEmpty(res)) return false;
// } catch (Exception e) {
// log.error("|{}syncAllUserGroup 调用第三方接口错误|", TAG);
// return false;
// }
try {
ZyMerSyncAccountInfoVo.DataVo res = thirdZyService.syncAccountInfoApi(syncList).getData();
if (ObjectUtil.isEmpty(res)) return false;
} catch (Exception e) {
log.error("|{}syncAllUserGroup 调用第三方接口错误|", TAG);
return false;
}
return userPage.getTotal() > 0;
}
@@ -245,18 +244,22 @@ public class MchThirdZyServiceImpl implements MchThirdZyService {
// 卡片状态,0销卡;1有效;2挂失;3冻结;4预销卡;5锁卡,默认1
private Integer getCardStatus(Long userId, String cardNumber) {
if (!ObjectUtil.isAllNotEmpty(userId, cardNumber)) {
throw new RuntimeException();
}
private Integer getCardStatus(String cardStatus) {
// 没有就默认锁卡
if (ObjectUtil.isEmpty(cardStatus)) return 5;
try {
// 创建并绑定钱包
walletManageService.createWallet(userId);
return 1;
WalleCardStatusEnum walleCardStatusEnum = WalleCardStatusEnum.valueOfByType(cardStatus);
return switch (walleCardStatusEnum) {
case NONE_ACTIVE, LOCK -> 5;
case ACTIVE -> 1;
case REPORT -> 2;
case FREEZE -> 3;
case CANCEL -> 0;
};
} catch (Exception e) {
String msg = String.format("|{}|getCardStatus意外的错误", TAG);
String msg = String.format("|{}|cardStatus解析错误", TAG);
log.error(msg, e);
throw new RuntimeException(msg, e);
return 5;
}
}
@@ -13,7 +13,7 @@
<result property="freezePrice" column="freeze_price"/>
<result property="isFreeze" column="is_freeze"/>
<result property="activeBindTime" column="active_bind_time"/>
<result property="activeBindStatus" column="active_bind_status"/>
<result property="status" column="active_bind_status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>