|
@@ -1,17 +1,11 @@
|
|
|
package com.txz.cif.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import com.txz.cif.constants.MyConstants;
|
|
|
-import com.txz.cif.core.ResultCode;
|
|
|
-import com.txz.cif.core.ServiceException;
|
|
|
import com.txz.cif.dao.FlowMapper;
|
|
|
import com.txz.cif.dto.Result;
|
|
|
import com.txz.cif.model.Account;
|
|
|
import com.txz.cif.model.AccountFlow;
|
|
|
-import com.txz.cif.model.AccountFreezd;
|
|
|
import com.txz.cif.model.Flow;
|
|
|
import com.txz.cif.param.*;
|
|
|
import com.txz.cif.service.AccountFlowService;
|
|
@@ -24,7 +18,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
@@ -46,107 +39,107 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
@Resource
|
|
|
private AccountFreezdService accountFreezdService;
|
|
|
|
|
|
- @Override
|
|
|
- public Result freeze(FreezdParam param) {
|
|
|
- try{
|
|
|
- Account account = accountService.findById(param.getAccountId());
|
|
|
- if (account == null){
|
|
|
- return Result.genFailResult("账号未找到");
|
|
|
- }
|
|
|
- if (account.getEffectiveBalance().subtract(param.getAmount()).compareTo(BigDecimal.ZERO) < 0){
|
|
|
- return Result.genFailResult("冻结金额不足");
|
|
|
- }
|
|
|
- Date today = DateUtil.date();
|
|
|
+// @Override
|
|
|
+// public Result freeze(FreezdParam param) {
|
|
|
+// try{
|
|
|
+// Account account = accountService.findById(param.getAccountId());
|
|
|
+// if (account == null){
|
|
|
+// return Result.genFailResult("账号未找到");
|
|
|
+// }
|
|
|
+// if (account.getEffectiveBalance().subtract(param.getAmount()).compareTo(BigDecimal.ZERO) < 0){
|
|
|
+// return Result.genFailResult("冻结金额不足");
|
|
|
+// }
|
|
|
+// Date today = DateUtil.date();
|
|
|
+//
|
|
|
+// Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
+// .bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
+// .debitAccount(param.getAccountId()).creditAccount(param.getAccountId())
|
|
|
+// .bizId(param.getBizId()).type(4)
|
|
|
+// .build();
|
|
|
+// saveUseGeneratedKeys(flow);
|
|
|
+// accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
+// .bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
+// .bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().add(param.getAmount()))
|
|
|
+// .flowType(4).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
+// AccountFreezd freezd = AccountFreezd.builder().accountId(param.getAccountId()).flowId(flow.getId())
|
|
|
+// .amount(param.getAmount()).createTime(today).unfreezeAmount(BigDecimal.ZERO)
|
|
|
+// .updateTime(today).status(1).build();
|
|
|
+// accountFreezdService.saveUseGeneratedKeys(freezd);
|
|
|
+// return Result.genSuccessResult(freezd.getId());
|
|
|
+// }catch (Exception e){
|
|
|
+// log.error("冻结异常",e);
|
|
|
+// return Result.genFailResult("冻结异常",e);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
- Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
- .bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .debitAccount(param.getAccountId()).creditAccount(param.getAccountId())
|
|
|
- .bizId(param.getBizId()).type(4)
|
|
|
- .build();
|
|
|
- saveUseGeneratedKeys(flow);
|
|
|
- accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
- .bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
- .bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().add(param.getAmount()))
|
|
|
- .flowType(4).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- AccountFreezd freezd = AccountFreezd.builder().accountId(param.getAccountId()).flowId(flow.getId())
|
|
|
- .amount(param.getAmount()).createTime(today).unfreezeAmount(BigDecimal.ZERO)
|
|
|
- .updateTime(today).status(1).build();
|
|
|
- accountFreezdService.saveUseGeneratedKeys(freezd);
|
|
|
- return Result.genSuccessResult(freezd.getId());
|
|
|
- }catch (Exception e){
|
|
|
- log.error("冻结异常",e);
|
|
|
- return Result.genFailResult("冻结异常",e);
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public Result unFreeze(Long freezdId) {
|
|
|
+// AccountFreezd freezd = accountFreezdService.findById(freezdId);
|
|
|
+// if (freezd == null){
|
|
|
+// return Result.genFailResult("冻结记录未找到");
|
|
|
+// }
|
|
|
+// Flow oldFlow = findById(freezd.getFlowId());
|
|
|
+// if (oldFlow == null){
|
|
|
+// return Result.genFailResult("冻结记录未找到");
|
|
|
+// }
|
|
|
+//
|
|
|
+// Account account = accountService.findById(freezd.getAccountId());
|
|
|
+// if (account == null){
|
|
|
+// return Result.genFailResult("冻结账号未找到");
|
|
|
+// }
|
|
|
+// Date today = DateUtil.date();
|
|
|
+// Flow flow = Flow.builder().amount(freezd.getAmount()).bizType(5001)
|
|
|
+// .bizNo(oldFlow.getBizNo()).createTime(today).updateTime(today).transTime(today)
|
|
|
+// .debitAccount(oldFlow.getDebitAccount()).creditAccount(oldFlow.getCreditAccount())
|
|
|
+// .bizId(oldFlow.getBizId()).type(5)
|
|
|
+// .build();
|
|
|
+// saveUseGeneratedKeys(flow);
|
|
|
+// accountService.deal(AccountFlow.builder().accountId(oldFlow.getDebitAccount()).amount(flow.getAmount())
|
|
|
+// .bizId(flow.getBizId()).aliases(account.getAliases()).transTime(today)
|
|
|
+// .bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().subtract(oldFlow.getAmount()))
|
|
|
+// .flowType(5).type(2).bizType(flow.getBizType()).flowId(flow.getId()).build());
|
|
|
+// accountFreezdService.update(AccountFreezd.builder().id(freezdId).status(3).unfreezeAmount(oldFlow.getAmount()).build());
|
|
|
+// return Result.genSuccessResult();
|
|
|
+// }
|
|
|
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public Result trans(TransParam param) {
|
|
|
+// switch (param.getBizType()){
|
|
|
+// case 1001:
|
|
|
+// RechargeParam p1 = BeanUtil.toBean(param,RechargeParam.class);
|
|
|
+// p1.setAccountId(param.getCreditAccount());
|
|
|
+// return recharge(p1);
|
|
|
+// case 2001:
|
|
|
+// FeeParam p2 = BeanUtil.toBean(param,FeeParam.class);
|
|
|
+// p2.setAccountId(param.getDebitAccount());
|
|
|
+// return fee(p2);
|
|
|
+// case 2002:
|
|
|
+// CommissionParam p3 = BeanUtil.toBean(param,CommissionParam.class);
|
|
|
+// p3.setAccountId(param.getCreditAccount());
|
|
|
+// return commission(p3);
|
|
|
+// }
|
|
|
+// return null;
|
|
|
+// }
|
|
|
|
|
|
- @Override
|
|
|
- public Result unFreeze(Long freezdId) {
|
|
|
- AccountFreezd freezd = accountFreezdService.findById(freezdId);
|
|
|
- if (freezd == null){
|
|
|
- return Result.genFailResult("冻结记录未找到");
|
|
|
- }
|
|
|
- Flow oldFlow = findById(freezd.getFlowId());
|
|
|
- if (oldFlow == null){
|
|
|
- return Result.genFailResult("冻结记录未找到");
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public Result unFreezeAndTrans(UnFreezdAndTransParam param) {
|
|
|
+// unFreeze(param.getFreezdId());
|
|
|
+// if (CollUtil.isNotEmpty(param.getTrans())){
|
|
|
+// for (TransParam p: param.getTrans()) {
|
|
|
+// Result r = trans(p);
|
|
|
+// if (r == null || !StrUtil.equals(r.getCode() , "200")){
|
|
|
+// throw new ServiceException(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return Result.genSuccessResult();
|
|
|
+// }
|
|
|
|
|
|
- Account account = accountService.findById(freezd.getAccountId());
|
|
|
- if (account == null){
|
|
|
- return Result.genFailResult("冻结账号未找到");
|
|
|
- }
|
|
|
- Date today = DateUtil.date();
|
|
|
- Flow flow = Flow.builder().amount(freezd.getAmount()).bizType(5001)
|
|
|
- .bizNo(oldFlow.getBizNo()).createTime(today).updateTime(today).transTime(today)
|
|
|
- .debitAccount(oldFlow.getDebitAccount()).creditAccount(oldFlow.getCreditAccount())
|
|
|
- .bizId(oldFlow.getBizId()).type(5)
|
|
|
- .build();
|
|
|
- saveUseGeneratedKeys(flow);
|
|
|
- accountService.deal(AccountFlow.builder().accountId(oldFlow.getDebitAccount()).amount(flow.getAmount())
|
|
|
- .bizId(flow.getBizId()).aliases(account.getAliases()).transTime(today)
|
|
|
- .bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().subtract(oldFlow.getAmount()))
|
|
|
- .flowType(5).type(2).bizType(flow.getBizType()).flowId(flow.getId()).build());
|
|
|
- accountFreezdService.update(AccountFreezd.builder().id(freezdId).status(3).unfreezeAmount(oldFlow.getAmount()).build());
|
|
|
- return Result.genSuccessResult();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result trans(TransParam param) {
|
|
|
- switch (param.getBizType()){
|
|
|
- case 1001:
|
|
|
- RechargeParam p1 = BeanUtil.toBean(param,RechargeParam.class);
|
|
|
- p1.setAccountId(param.getCreditAccount());
|
|
|
- return recharge(p1);
|
|
|
- case 2001:
|
|
|
- FeeParam p2 = BeanUtil.toBean(param,FeeParam.class);
|
|
|
- p2.setAccountId(param.getDebitAccount());
|
|
|
- return fee(p2);
|
|
|
- case 2002:
|
|
|
- CommissionParam p3 = BeanUtil.toBean(param,CommissionParam.class);
|
|
|
- p3.setAccountId(param.getCreditAccount());
|
|
|
- return commission(p3);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result unFreezeAndTrans(UnFreezdAndTransParam param) {
|
|
|
- unFreeze(param.getFreezdId());
|
|
|
- if (CollUtil.isNotEmpty(param.getTrans())){
|
|
|
- for (TransParam p: param.getTrans()) {
|
|
|
- Result r = trans(p);
|
|
|
- if (r == null || !StrUtil.equals(r.getCode() , "200")){
|
|
|
- throw new ServiceException(ResultCode.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.genSuccessResult();
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public Result recharge(RechargeParam param) {
|
|
|
-
|
|
|
- Account account = accountService.findById(param.getAccountId());
|
|
|
+ Account account = accountService.getAccount(param.getUserId(),1);
|
|
|
if (account == null){
|
|
|
return Result.genFailResult("账号未找到");
|
|
|
}
|
|
@@ -157,29 +150,55 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .debitAccount(MyConstants.INNER_CAPITAL).creditAccount(param.getAccountId())
|
|
|
+ .debitAccount(MyConstants.INNER_CAPITAL).creditAccount(account.getId())
|
|
|
.bizId(param.getBizId()).type(1)
|
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借 :资金应收-渠道款-银行xx元 内部户1(资产类:借方账户)+钱
|
|
|
+ //借 :平台资金银行xx元 内部户1(资产类:借方账户)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_CAPITAL).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(innerCapitalAccount.getFreezeAmount())
|
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
//贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
- accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount())
|
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
+
|
|
|
+ //充值返点
|
|
|
+ Account innerRebateAccount = accountService.findById(MyConstants.INNER_REBATE);
|
|
|
+ if (innerCapitalAccount == null){
|
|
|
+ return Result.genFailResult("账号未找到");
|
|
|
+ }
|
|
|
+ flow = Flow.builder().amount(param.getAmount()).bizType(10)
|
|
|
+ .bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
+ .debitAccount(MyConstants.INNER_REBATE).creditAccount(account.getId())
|
|
|
+ .bizId(param.getBizId()).type(1)
|
|
|
+ .build();
|
|
|
+ saveUseGeneratedKeys(flow);
|
|
|
+ //借 :平台资金银行xx元 内部户1(资产类:借方账户)+钱
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_REBATE).amount(flow.getAmount())
|
|
|
+ .bizId(flow.getBizId()).aliases(innerRebateAccount.getAliases()).transTime(param.getTransTime())
|
|
|
+ .bizNo(flow.getBizNo()).balance(innerRebateAccount.getBalance().add(flow.getAmount()))
|
|
|
+ .freezeAmount(innerRebateAccount.getFreezeAmount())
|
|
|
+ .flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
+ //贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
+ .bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
+ .bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
|
+ .freezeAmount(account.getFreezeAmount())
|
|
|
+ .flowType(1).type(2).bizType(10).flowId(flow.getId()).build());
|
|
|
+
|
|
|
+
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result fee(FeeParam param) {
|
|
|
+ public Result pay(PayParam param) {
|
|
|
|
|
|
- Account account = accountService.findById(param.getAccountId());
|
|
|
+ Account account = accountService.getAccount(param.getUserId(),1);
|
|
|
if (account == null){
|
|
|
return Result.genFailResult("账号未找到");
|
|
|
}
|
|
@@ -188,17 +207,17 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
return Result.genFailResult("账号未找到");
|
|
|
}
|
|
|
|
|
|
- //借:医院A账户(贷) -500元
|
|
|
+ //借:个人账户钱包(贷) -500元
|
|
|
//贷:平台主营收入(贷) +500元
|
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .debitAccount(param.getAccountId()).creditAccount(MyConstants.INNER_INCOME)
|
|
|
+ .debitAccount(account.getId()).creditAccount(MyConstants.INNER_INCOME)
|
|
|
.bizId(param.getBizId()).type(6)
|
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借:医院A账户(贷) -500元
|
|
|
- accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
+ //借:个人账户钱包(贷) -500元
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().subtract(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount())
|
|
@@ -213,33 +232,33 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result commission(CommissionParam param) {
|
|
|
- //借:专家提成(借) +100元
|
|
|
- //贷:销售人员账户(贷) +100元
|
|
|
+ public Result refund(RefundParam param) {
|
|
|
+ //借:主营支出-退款(借) +100元
|
|
|
+ //贷:个人账户 (贷) +100元
|
|
|
|
|
|
- Account account = accountService.findById(param.getAccountId());
|
|
|
+ Account account = accountService.getAccount(param.getUserId(),1);
|
|
|
if (account == null){
|
|
|
return Result.genFailResult("账号未找到");
|
|
|
}
|
|
|
- Account innerSpecialistAccount = accountService.findById(MyConstants.INNER_SPECIALIST);
|
|
|
- if (innerSpecialistAccount == null){
|
|
|
+ Account innerRefundAccount = accountService.findById(MyConstants.INNER_REFUND);
|
|
|
+ if (innerRefundAccount == null){
|
|
|
return Result.genFailResult("账号未找到");
|
|
|
}
|
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .debitAccount(MyConstants.INNER_SPECIALIST).creditAccount(param.getAccountId())
|
|
|
+ .debitAccount(MyConstants.INNER_REFUND).creditAccount(account.getId())
|
|
|
.bizId(param.getBizId()).type(6)
|
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借:专家提成(借) +100元
|
|
|
- accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_SPECIALIST).amount(flow.getAmount())
|
|
|
- .bizId(flow.getBizId()).aliases(innerSpecialistAccount.getAliases()).transTime(param.getTransTime())
|
|
|
- .bizNo(flow.getBizNo()).balance(innerSpecialistAccount.getBalance().add(flow.getAmount()))
|
|
|
- .freezeAmount(innerSpecialistAccount.getFreezeAmount())
|
|
|
+ //借:主营支出-退款(借) +100元
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_REFUND).amount(flow.getAmount())
|
|
|
+ .bizId(flow.getBizId()).aliases(innerRefundAccount.getAliases()).transTime(param.getTransTime())
|
|
|
+ .bizNo(flow.getBizNo()).balance(innerRefundAccount.getBalance().add(flow.getAmount()))
|
|
|
+ .freezeAmount(innerRefundAccount.getFreezeAmount())
|
|
|
.flowType(7).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷:销售人员账户(贷) +100元
|
|
|
- accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
+ //贷:个人账户(贷) +100元
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount())
|
|
@@ -250,7 +269,7 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
@Override
|
|
|
public Result withdraw(WithdrawParam param) {
|
|
|
|
|
|
- Account account = accountService.findById(param.getAccountId());
|
|
|
+ Account account = accountService.getAccount(param.getUserId(),param.getAccountType());
|
|
|
if (account == null){
|
|
|
return Result.genFailResult("账号未找到");
|
|
|
}
|
|
@@ -262,13 +281,13 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .creditAccount(MyConstants.INNER_CAPITAL).debitAccount(param.getAccountId())
|
|
|
+ .creditAccount(MyConstants.INNER_CAPITAL).debitAccount(account.getId())
|
|
|
.bizId(param.getBizId()).type(1)
|
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
|
|
|
|
//借 :客户资金账户xx元 客户账号(负债类:贷方账户)-钱
|
|
|
- accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
+ accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().subtract(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount())
|
|
@@ -282,56 +301,5 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Result unFreezeAndFreeze(Long freezdId, FreezdParam param) {
|
|
|
-
|
|
|
- //判断是否足够冻结
|
|
|
- AccountFreezd oldFreezd = accountFreezdService.findById(freezdId);
|
|
|
- if (oldFreezd == null){
|
|
|
- return Result.genFailResult("冻结记录未找到");
|
|
|
- }
|
|
|
- Flow oldFlow = findById(oldFreezd.getFlowId());
|
|
|
- if (oldFlow == null){
|
|
|
- return Result.genFailResult("冻结记录未找到");
|
|
|
- }
|
|
|
-
|
|
|
- Account account = accountService.findById(oldFreezd.getAccountId());
|
|
|
- if (account == null){
|
|
|
- return Result.genFailResult("冻结账号未找到");
|
|
|
- }
|
|
|
-
|
|
|
- if (param.getAmount().compareTo(account.getEffectiveBalance().add(oldFreezd.getAmount())) > 0){
|
|
|
- return Result.genFailResult("冻结金额不足");
|
|
|
- }
|
|
|
-
|
|
|
- Date today = DateUtil.date();
|
|
|
- Flow unflow = Flow.builder().amount(oldFreezd.getAmount()).bizType(5001)
|
|
|
- .bizNo(oldFlow.getBizNo()).createTime(today).updateTime(today).transTime(today)
|
|
|
- .debitAccount(oldFlow.getDebitAccount()).creditAccount(oldFlow.getCreditAccount())
|
|
|
- .bizId(oldFlow.getBizId()).type(5)
|
|
|
- .build();
|
|
|
- saveUseGeneratedKeys(unflow);
|
|
|
- accountService.deal(AccountFlow.builder().accountId(oldFlow.getDebitAccount()).amount(unflow.getAmount())
|
|
|
- .bizId(unflow.getBizId()).aliases(account.getAliases()).transTime(today)
|
|
|
- .bizNo(unflow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().subtract(oldFlow.getAmount()))
|
|
|
- .flowType(5).type(2).bizType(unflow.getBizType()).flowId(unflow.getId()).build());
|
|
|
- accountFreezdService.update(AccountFreezd.builder().id(freezdId).status(3).unfreezeAmount(oldFlow.getAmount()).build());
|
|
|
|
|
|
-
|
|
|
- Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
- .bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .debitAccount(param.getAccountId()).creditAccount(param.getAccountId())
|
|
|
- .bizId(param.getBizId()).type(4)
|
|
|
- .build();
|
|
|
- saveUseGeneratedKeys(flow);
|
|
|
- accountService.deal(AccountFlow.builder().accountId(param.getAccountId()).amount(flow.getAmount())
|
|
|
- .bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
- .bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().add(param.getAmount()))
|
|
|
- .flowType(4).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- AccountFreezd freezd = AccountFreezd.builder().accountId(param.getAccountId()).flowId(flow.getId())
|
|
|
- .amount(param.getAmount()).createTime(today).unfreezeAmount(BigDecimal.ZERO)
|
|
|
- .updateTime(today).status(1).build();
|
|
|
- accountFreezdService.saveUseGeneratedKeys(freezd);
|
|
|
- return Result.genSuccessResult(freezd.getId());
|
|
|
- }
|
|
|
}
|