|
|
@@ -4,15 +4,16 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.backstage.basics.domain.vo.PtWorkstationVo;
|
|
|
import org.dromara.backstage.basics.service.IPtParameterService;
|
|
|
import org.dromara.backstage.basics.service.IPtWorkstationService;
|
|
|
import org.dromara.backstage.cardCenter.domain.bo.PtCardBo;
|
|
|
+import org.dromara.backstage.cardCenter.service.IPtCardService;
|
|
|
import org.dromara.backstage.domain.vo.card.InitCardVo;
|
|
|
import org.dromara.backstage.domain.vo.card.PtCardVo;
|
|
|
-import org.dromara.backstage.cardCenter.service.IPtCardService;
|
|
|
import org.dromara.backstage.payment.domain.bo.PtBagBo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtBagVo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
|
|
|
@@ -69,13 +70,13 @@ public class CardBusiness {
|
|
|
PtCardBo addBo = BeanUtil.copyProperties(cardBo, PtCardBo.class);
|
|
|
addBo.setMainCard("Y");
|
|
|
addBo.setStatus(CardStatusEnum.NORMAL.code().toString());
|
|
|
- if(addBo.getCardNo()==null){
|
|
|
+ if (addBo.getCardNo() == null) {
|
|
|
addBo.setCardNo(cardNoBusiness.getCardNo());
|
|
|
}
|
|
|
addBo.setFactoryId(0L);
|
|
|
addBo.setChangeTime(DateUtil.date());
|
|
|
|
|
|
- if(ptCardService.insertByBo(addBo)){
|
|
|
+ if (ptCardService.insertByBo(addBo)) {
|
|
|
//--------- 设置 流水号和主键id set 到 cardBo
|
|
|
cardBo.setCardId(addBo.getCardId());
|
|
|
cardBo.setCardNo(addBo.getCardNo());
|
|
|
@@ -137,7 +138,7 @@ public class CardBusiness {
|
|
|
case REISSUE -> checkUserReIssueCard(uesrCardList, cardBo);
|
|
|
default -> R.ok(new ResultInfo(ResultCodeEnum.SUCCESS));
|
|
|
};
|
|
|
- if(R.isError(result)){
|
|
|
+ if (R.isError(result)) {
|
|
|
return R.fail(result.getData());
|
|
|
}
|
|
|
// 所有逻辑校验通过,入库
|
|
|
@@ -163,18 +164,30 @@ public class CardBusiness {
|
|
|
|
|
|
public R<PtCardVo> writeCardSuccess(PtCardBo cardBo) throws InterruptedException {
|
|
|
PtCardBo queryBo = new PtCardBo();
|
|
|
- if(cardBo.getCardNo()>0) {queryBo.setCardNo(cardBo.getCardNo());}
|
|
|
- if(cardBo.getFactoryId()>0) {queryBo.setFactoryId(cardBo.getFactoryId());}
|
|
|
- if(cardBo.getCardId()>0) {queryBo.setCardId(cardBo.getCardId());}
|
|
|
+ if (cardBo.getCardNo() > 0) {
|
|
|
+ queryBo.setCardNo(cardBo.getCardNo());
|
|
|
+ }
|
|
|
+ if (cardBo.getFactoryId() > 0) {
|
|
|
+ queryBo.setFactoryId(cardBo.getFactoryId());
|
|
|
+ }
|
|
|
+ if (cardBo.getCardId() > 0) {
|
|
|
+ queryBo.setCardId(cardBo.getCardId());
|
|
|
+ }
|
|
|
|
|
|
// 补卡和换卡时需要注销旧卡
|
|
|
if (ObjectUtil.equals(cardBo.getOperateType(), CardOperateEnum.REISSUE)
|
|
|
- || ObjectUtil.equals(cardBo.getOperateType(),CardOperateEnum.CHANGE)) {
|
|
|
+ || ObjectUtil.equals(cardBo.getOperateType(), CardOperateEnum.CHANGE)) {
|
|
|
// 注销旧卡
|
|
|
PtCardBo queryOldBo = new PtCardBo();
|
|
|
- if(cardBo.getOldCardNo()>0) {queryOldBo.setCardNo(cardBo.getOldCardNo());}
|
|
|
- if(cardBo.getOldFactoryId()>0) {queryOldBo.setFactoryId(cardBo.getOldFactoryId());}
|
|
|
- if(cardBo.getOldCardId()>0) {queryOldBo.setCardId(cardBo.getOldCardId());}
|
|
|
+ if (cardBo.getOldCardNo() > 0) {
|
|
|
+ queryOldBo.setCardNo(cardBo.getOldCardNo());
|
|
|
+ }
|
|
|
+ if (cardBo.getOldFactoryId() > 0) {
|
|
|
+ queryOldBo.setFactoryId(cardBo.getOldFactoryId());
|
|
|
+ }
|
|
|
+ if (cardBo.getOldCardId() > 0) {
|
|
|
+ queryOldBo.setCardId(cardBo.getOldCardId());
|
|
|
+ }
|
|
|
queryOldBo.setStatus(CardStatusEnum.CLOSE.code().toString());
|
|
|
queryOldBo.setChangeTime(DateUtil.date());
|
|
|
|
|
|
@@ -187,6 +200,15 @@ public class CardBusiness {
|
|
|
return R.ok(cardVo);
|
|
|
}
|
|
|
|
|
|
+ public R<Void> recycleCard(PtCardBo cardBo) {
|
|
|
+ PtCardVo vo = ptCardService.selectOneByBo(cardBo);
|
|
|
+ if (ObjectUtil.isNotEmpty(vo)) {
|
|
|
+ return ptCardService.recycleCardByBo(cardBo) ? R.ok() : R.fail();
|
|
|
+ } else {
|
|
|
+ return R.fail(MessageFormat.format("[卡片回收]-[没有对应的卡片]-[{0}]", JSONUtil.toJsonStr(cardBo)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private R<ResultInfo> checkParam(PtCardBo cardBo, PtUserAccountVo userAccountVo, PtWorkstationVo workstationVo) {
|
|
|
Long factoryId = cardBo.getFactoryId();
|
|
|
Long userId = cardBo.getUserId();
|
|
|
@@ -272,15 +294,15 @@ public class CardBusiness {
|
|
|
if (CollectionUtil.isNotEmpty(userCardList)) {
|
|
|
// 如人员已有正常的主卡,不能再发主卡
|
|
|
if (userCardList.stream().anyMatch(p -> ObjectUtil.equals(p.getMainCard(), "Y")
|
|
|
- && ObjectUtil.equals(p.getStatus(), CardStatusEnum.NORMAL.code().toString())
|
|
|
- && p.getFactoryId() > 0 && cardBo.getMainCard().equals("Y"))) {
|
|
|
+ && ObjectUtil.equals(p.getStatus(), CardStatusEnum.NORMAL.code().toString())
|
|
|
+ && p.getFactoryId() > 0 && cardBo.getMainCard().equals("Y"))) {
|
|
|
return R.fail(new ResultInfo(ResultCodeEnum.DATA_ALREADY_EXISTED, MessageFormat.format("Id为[{0}]的人员已有正常主卡,无法再发新卡",
|
|
|
- cardBo.getUserId())));
|
|
|
+ cardBo.getUserId())));
|
|
|
}
|
|
|
// 如果人员已发虚拟卡,此时将虚拟卡转为实体卡
|
|
|
userCardList.stream().filter(p -> ObjectUtil.equals(p.getMainCard(), "Y")
|
|
|
- && ObjectUtil.equals(p.getStatus(), CardStatusEnum.NORMAL.code().toString())
|
|
|
- && p.getFactoryId() == 0L).findFirst().ifPresent(k -> {
|
|
|
+ && ObjectUtil.equals(p.getStatus(), CardStatusEnum.NORMAL.code().toString())
|
|
|
+ && p.getFactoryId() == 0L).findFirst().ifPresent(k -> {
|
|
|
cardBo.setCardNo(k.getCardNo());
|
|
|
cardBo.setCardId(k.getCardId());
|
|
|
cardBo.setStatus(k.getStatus());
|
|
|
@@ -309,7 +331,7 @@ public class CardBusiness {
|
|
|
if (ObjectUtil.notEqual(oldCardVo.getStatus(), CardStatusEnum.NORMAL.code().toString())) {
|
|
|
return R.fail(
|
|
|
new ResultInfo(ResultCodeEnum.DATA_NOT_FOUND,
|
|
|
- MessageFormat.format("物理卡号[{0}]和卡流水号[{1}]对应旧卡是正常卡片", oldFactoryId, oldCardNo)));
|
|
|
+ MessageFormat.format("物理卡号[{0}]和卡流水号[{1}]对应旧卡是正常卡片", oldFactoryId, oldCardNo)));
|
|
|
}
|
|
|
// 将原卡的信息复制到新卡 卡类、有效期和是否主卡
|
|
|
userCardList.stream().filter(
|
|
|
@@ -339,15 +361,15 @@ public class CardBusiness {
|
|
|
if (ObjectUtil.notEqual(oldCardVo.getStatus(), CardStatusEnum.LOCK.code().toString())) {
|
|
|
return R.fail(
|
|
|
new ResultInfo(ResultCodeEnum.DATA_NOT_FOUND,
|
|
|
- MessageFormat.format("没有物理卡号[{0}]和卡流水号[{1}]对应的挂失卡片", oldFactoryId, oldCardNo)));
|
|
|
+ MessageFormat.format("没有物理卡号[{0}]和卡流水号[{1}]对应的挂失卡片", oldFactoryId, oldCardNo)));
|
|
|
}
|
|
|
// 如果待补的旧卡是主卡,检查人员是否有正常主卡
|
|
|
if (ObjectUtil.equals(oldCardVo.getMainCard(), "Y")) {
|
|
|
if (userCardList.stream().anyMatch(
|
|
|
p -> ObjectUtil.equals(p.getStatus(), CardStatusEnum.NORMAL.code().toString()) && ObjectUtil.equals(p.getMainCard(), "Y"))) {
|
|
|
return R.fail(new ResultInfo(ResultCodeEnum.DATA_ALREADY_EXISTED,
|
|
|
- MessageFormat.format("物理卡号[{0}]和卡流水号[{1}]的挂失卡片为主卡,但人员已有正常的主卡", oldFactoryId,
|
|
|
- oldCardNo)));
|
|
|
+ MessageFormat.format("物理卡号[{0}]和卡流水号[{1}]的挂失卡片为主卡,但人员已有正常的主卡", oldFactoryId,
|
|
|
+ oldCardNo)));
|
|
|
}
|
|
|
}
|
|
|
return R.ok(new ResultInfo(ResultCodeEnum.SUCCESS));
|
|
|
@@ -360,7 +382,7 @@ public class CardBusiness {
|
|
|
//if (ObjectUtil.isEmpty(oldFactoryId) || oldFactoryId == 0) {
|
|
|
// return R.fail(new ResultInfo(ResultCodeEnum.PARAM_IS_INVALID, "旧卡的物理卡号必须大于0"));
|
|
|
//}
|
|
|
- if(oldCardId>0) {
|
|
|
+ if (oldCardId > 0) {
|
|
|
if (userCardList.stream().noneMatch(p -> ObjectUtil.equals(p.getCardId(), oldCardId))) {
|
|
|
return R.fail(
|
|
|
new ResultInfo(ResultCodeEnum.DATA_NOT_FOUND,
|