|
|
@@ -75,7 +75,7 @@ public class PaymentsBusiness {
|
|
|
list.add(userAccountVo);
|
|
|
//2.卡片辅助信息
|
|
|
PtCardVo ptCardVo;
|
|
|
- if (bo.getCardId() > 0) {
|
|
|
+ if (bo.getCardId() != null && bo.getCardId() > 0) {
|
|
|
//如果传入了cardId,根据cardId查询卡片信息
|
|
|
ptCardVo = cardService.queryById(bo.getCardId());
|
|
|
} else {
|
|
|
@@ -84,7 +84,7 @@ public class PaymentsBusiness {
|
|
|
}
|
|
|
list.add(ptCardVo);
|
|
|
//3.钱包辅助信息
|
|
|
- PtBagVo ptBagVo = bagService.queryById(bo.getBagId());
|
|
|
+ PtBagVo ptBagVo = bagService.queryByUserBagCode(bo.getUserId(),bo.getBagCode());
|
|
|
list.add(ptBagVo);
|
|
|
//4.设备辅助信息
|
|
|
XfTermVo xfTermVo = termService.queryByNo(bo.getTermNo() == null ? 0 : bo.getTermNo());
|
|
|
@@ -144,11 +144,11 @@ public class PaymentsBusiness {
|
|
|
}
|
|
|
|
|
|
XfCreditAccountBackVo creditAccountBackVo = creditAccountBackService.createOriginalRecord(xfCreditaccountbackBo);
|
|
|
- if(ObjUtil.isEmpty(creditAccountBackVo)){
|
|
|
+ if (ObjUtil.isEmpty(creditAccountBackVo)) {
|
|
|
String message = MessageUtils.message("payments.OriginalRecord.create", JSONUtil.parse(bo));
|
|
|
throw new PaymentsException("资金收支-原始记录", message);
|
|
|
}
|
|
|
- return creditAccountBackVo;
|
|
|
+ return creditAccountBackVo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -159,10 +159,10 @@ public class PaymentsBusiness {
|
|
|
* @param cardVo 资金收支卡片信息
|
|
|
* @param termVo 资金收支消费设备信息
|
|
|
* @param workstationVo 资金收支工作站信息
|
|
|
- * @param originalId 原始收支记录Id(收支备份表主键)
|
|
|
+ * @param originalId 原始收支记录Id(收支备份表主键)
|
|
|
* @return 正式收支记录
|
|
|
*/
|
|
|
- public XfCreditAccountVo keepAccounts(PtBagBo bo, PtUserAccountVo accountVo, PtCardVo cardVo, PtBagVo bagVo, XfTermVo termVo, PtWorkstationVo workstationVo,String originalId){
|
|
|
+ public XfCreditAccountVo keepAccounts(PtBagBo bo, PtUserAccountVo accountVo, PtCardVo cardVo, PtBagVo bagVo, XfTermVo termVo, PtWorkstationVo workstationVo, String originalId) {
|
|
|
//校验要处理的原始收支记录
|
|
|
ValidOriginalRecord(originalId);
|
|
|
XfCreditAccountBo xfCreditaccountbo = new XfCreditAccountBo();
|
|
|
@@ -193,7 +193,7 @@ public class PaymentsBusiness {
|
|
|
xfCreditaccountbo.setCardNo(cardVo.getCardNo());
|
|
|
xfCreditaccountbo.setCardValue(bagVo.getBalance());
|
|
|
xfCreditaccountbo.setCardType(cardVo.getCardType());
|
|
|
- xfCreditaccountbo.setCardCount(bagVo.getRechargeCount()+1);
|
|
|
+ xfCreditaccountbo.setCardCount(bagVo.getRechargeCount() + 1);
|
|
|
xfCreditaccountbo.setCardTypeName(cardVo.getCardTypeName());
|
|
|
xfCreditaccountbo.setMainCard(cardVo.getMainCard());
|
|
|
//设置钱包信息
|
|
|
@@ -205,33 +205,34 @@ public class PaymentsBusiness {
|
|
|
xfCreditaccountbo.setOriginalId(originalId);
|
|
|
|
|
|
XfCreditAccountVo creditAccountVo = creditAccountService.keepAccounts(xfCreditaccountbo);
|
|
|
- if(ObjUtil.isEmpty(creditAccountVo)){
|
|
|
+ if (ObjUtil.isEmpty(creditAccountVo)) {
|
|
|
String message = MessageUtils.message("payments.keepAccounts.create", originalId);
|
|
|
throw new PaymentsException("资金收支-收支入账", message);
|
|
|
}
|
|
|
return creditAccountVo;
|
|
|
}
|
|
|
|
|
|
- public XfUserTotalVo createOrUpdateUserTotal(PtBagBo bo, PtUserAccountVo accountVo, PtCardVo cardVo){
|
|
|
+ public XfUserTotalVo createOrUpdateUserTotal(PtBagBo bo, PtUserAccountVo accountVo, PtCardVo cardVo) {
|
|
|
XfUserTotalBo xfUserTotalBo = new XfUserTotalBo();
|
|
|
xfUserTotalBo.setUserId(accountVo.getUserId());
|
|
|
xfUserTotalBo.setUserNumb(accountVo.getUserNumb());
|
|
|
xfUserTotalBo.setRealName(accountVo.getRealName());
|
|
|
xfUserTotalBo.setDeptName(accountVo.getDeptName());
|
|
|
xfUserTotalBo.setCardNo(cardVo.getCardNo());
|
|
|
- xfUserTotalBo.setDateDay(DateUtil.format(new Date(),"yyyy-MM-dd"));
|
|
|
+ xfUserTotalBo.setDateDay(DateUtil.format(new Date(), "yyyy-MM-dd"));
|
|
|
xfUserTotalBo.setUseType(bo.getUseType().code());
|
|
|
xfUserTotalBo.setCreditMoney(bo.getReceiptMoney());
|
|
|
|
|
|
return userTotalService.createOrUpdateUserTotal(xfUserTotalBo);
|
|
|
}
|
|
|
- public PtBagVo updateBalance(PtBagBo bagBo){
|
|
|
+
|
|
|
+ public PtBagVo updateBalance(PtBagBo bagBo) {
|
|
|
return bagService.updateBalanceByBo(bagBo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通用收支入账处理逻辑
|
|
|
- * 这里主要是处理一次性完成的原始订单生成、收支记账
|
|
|
+ * 这里主要是处理一次性完成的原始订单生成、收支记账
|
|
|
*
|
|
|
* @param bo 资金收支信息
|
|
|
*/
|
|
|
@@ -256,7 +257,7 @@ public class PaymentsBusiness {
|
|
|
|
|
|
/**
|
|
|
* 通用收支入账处理逻辑
|
|
|
- * 这里主要是处理一次性完成的原始订单生成、收支记账和更新个人日统计表功能
|
|
|
+ * 这里主要是处理一次性完成的原始订单生成、收支记账和更新个人日统计表功能
|
|
|
*
|
|
|
* @param bo 资金收支信息
|
|
|
*/
|
|
|
@@ -282,37 +283,39 @@ public class PaymentsBusiness {
|
|
|
log.info("[收支记录生成完成,开始写个人日统计表]-{}", JSONUtil.toJsonStr(bo));
|
|
|
createOrUpdateUserTotal(bo, accountVo, cardVo);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 收支入账前校验收支原始记录
|
|
|
*
|
|
|
* @param originalId 原始记录Id
|
|
|
*/
|
|
|
- private void ValidOriginalRecord(String originalId){
|
|
|
+ private void ValidOriginalRecord(String originalId) {
|
|
|
String message;
|
|
|
XfCreditAccountBackVo xfCreditaccountbackVo = creditAccountBackService.queryById(originalId);
|
|
|
- if(ObjUtil.isEmpty(xfCreditaccountbackVo)){
|
|
|
+ if (ObjUtil.isEmpty(xfCreditaccountbackVo)) {
|
|
|
message = MessageUtils.message("payments.OriginalRecord.get", originalId);
|
|
|
throw new PaymentsException("资金收支-原始记录", message);
|
|
|
}
|
|
|
String accountId = xfCreditaccountbackVo.getCreditId();
|
|
|
- if(StrUtil.isNotEmpty(accountId)){
|
|
|
- message = MessageUtils.message("payments.OriginalRecord.isPost", originalId,accountId);
|
|
|
+ if (StrUtil.isNotEmpty(accountId)) {
|
|
|
+ message = MessageUtils.message("payments.OriginalRecord.isPost", originalId, accountId);
|
|
|
throw new PaymentsException("资金收支-原始记录", message);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 生成资金收支备份表和收支表的32位主键Id
|
|
|
*
|
|
|
- * @param bo 资金收支信息
|
|
|
+ * @param bo 资金收支信息
|
|
|
* @param accountVo 人员账户信息
|
|
|
- * @param bagVo 账户钱包信息
|
|
|
+ * @param bagVo 账户钱包信息
|
|
|
* @return 生成的记录Id
|
|
|
*/
|
|
|
@NotNull
|
|
|
private String getRecordKeyId(PtBagBo bo, PtUserAccountVo accountVo, PtBagVo bagVo) {
|
|
|
BigDecimal a = new BigDecimal(100);
|
|
|
int key3 = 0;
|
|
|
- if(bo.getReceiptMoney().compareTo(BigDecimal.ZERO)>0){
|
|
|
+ if (bo.getReceiptMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
key3 = bo.getReceiptMoney().multiply(a).intValue();
|
|
|
} else {
|
|
|
key3 = bo.getReceiptMoney().negate().multiply(a).intValue();
|