|
@@ -6,6 +6,7 @@ import com.txz.cif.constants.MyConstants;
|
|
|
import com.txz.cif.core.ServiceException;
|
|
import com.txz.cif.core.ServiceException;
|
|
|
import com.txz.cif.dao.FlowMapper;
|
|
import com.txz.cif.dao.FlowMapper;
|
|
|
import com.txz.cif.dto.Result;
|
|
import com.txz.cif.dto.Result;
|
|
|
|
|
+import com.txz.cif.enums.AccountFreezdTypeEnum;
|
|
|
import com.txz.cif.enums.BizTypeEnum;
|
|
import com.txz.cif.enums.BizTypeEnum;
|
|
|
import com.txz.cif.model.*;
|
|
import com.txz.cif.model.*;
|
|
|
import com.txz.cif.param.*;
|
|
import com.txz.cif.param.*;
|
|
@@ -14,6 +15,7 @@ import com.txz.cif.service.AccountFreezdService;
|
|
|
import com.txz.cif.service.AccountService;
|
|
import com.txz.cif.service.AccountService;
|
|
|
import com.txz.cif.service.FlowService;
|
|
import com.txz.cif.service.FlowService;
|
|
|
import com.txz.cif.core.AbstractService;
|
|
import com.txz.cif.core.AbstractService;
|
|
|
|
|
+import com.txz.cif.web.para.FreezdParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -32,28 +34,28 @@ import java.util.HashMap;
|
|
|
public class FlowServiceImpl extends AbstractService<Flow> implements FlowService {
|
|
public class FlowServiceImpl extends AbstractService<Flow> implements FlowService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private FlowMapper cFlowMapper;
|
|
private FlowMapper cFlowMapper;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private AccountService accountService;
|
|
private AccountService accountService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private AccountFlowService accountFlowService;
|
|
private AccountFlowService accountFlowService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private AccountFreezdService accountFreezdService;
|
|
private AccountFreezdService accountFreezdService;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result freeze(FreezdParam param) {
|
|
public Result freeze(FreezdParam param) {
|
|
|
- try{
|
|
|
|
|
- Account account = accountService.getAccount(param.getUserId(),param.getAccountType());
|
|
|
|
|
- if (account == null){
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ Account account = accountService.getAccount(param.getUserId(), param.getAccountType());
|
|
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
- if (account.getEffectiveBalance().subtract(param.getAmount()).compareTo(BigDecimal.ZERO) < 0){
|
|
|
|
|
|
|
+ if (account.getEffectiveBalance().subtract(param.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
|
|
|
return Result.genFailResult(LocalUtil.get("insufficient.frozen.amount"));
|
|
return Result.genFailResult(LocalUtil.get("insufficient.frozen.amount"));
|
|
|
}
|
|
}
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
.debitAccount(account.getId()).creditAccount(account.getId())
|
|
.debitAccount(account.getId()).creditAccount(account.getId())
|
|
@@ -65,33 +67,33 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().add(param.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance()).freezeAmount(account.getFreezeAmount().add(param.getAmount()))
|
|
|
.flowType(4).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(4).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
AccountFreezd freezd = AccountFreezd.builder().accountId(account.getId()).bizId(flow.getId())
|
|
AccountFreezd freezd = AccountFreezd.builder().accountId(account.getId()).bizId(flow.getId())
|
|
|
- .amount(param.getAmount()).createTime(today).unfreezeAmount(BigDecimal.ZERO)
|
|
|
|
|
|
|
+ .amount(param.getAmount()).createTime(today).unfreezeAmount(BigDecimal.ZERO).type(param.getType())
|
|
|
.updateTime(today).status(1).build();
|
|
.updateTime(today).status(1).build();
|
|
|
accountFreezdService.saveUseGeneratedKeys(freezd);
|
|
accountFreezdService.saveUseGeneratedKeys(freezd);
|
|
|
return Result.genSuccessResult(freezd.getId());
|
|
return Result.genSuccessResult(freezd.getId());
|
|
|
- }catch (Exception e){
|
|
|
|
|
- log.error("冻结异常",e);
|
|
|
|
|
- return Result.genFailResult(LocalUtil.get("freezing.exception"),e);
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("冻结异常", e);
|
|
|
|
|
+ return Result.genFailResult(LocalUtil.get("freezing.exception"), e);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result unFreeze(Long freezdId) {
|
|
public Result unFreeze(Long freezdId) {
|
|
|
AccountFreezd freezd = accountFreezdService.findById(freezdId);
|
|
AccountFreezd freezd = accountFreezdService.findById(freezdId);
|
|
|
- if (freezd == null){
|
|
|
|
|
|
|
+ if (freezd == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("frozen.record.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("frozen.record.not.found"));
|
|
|
}
|
|
}
|
|
|
- if (freezd.getStatus() != 1){
|
|
|
|
|
|
|
+ if (freezd.getStatus() != 1) {
|
|
|
return Result.genFailResult(LocalUtil.get("frozen.status.is.abnormal"));
|
|
return Result.genFailResult(LocalUtil.get("frozen.status.is.abnormal"));
|
|
|
}
|
|
}
|
|
|
Flow oldFlow = findById(freezd.getBizId());
|
|
Flow oldFlow = findById(freezd.getBizId());
|
|
|
- if (oldFlow == null){
|
|
|
|
|
|
|
+ if (oldFlow == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("frozen.record.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("frozen.record.not.found"));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Account account = accountService.findById(freezd.getAccountId());
|
|
Account account = accountService.findById(freezd.getAccountId());
|
|
|
- if (account == null){
|
|
|
|
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("frozen.account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("frozen.account.not.found"));
|
|
|
}
|
|
}
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
@@ -108,49 +110,49 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
accountFreezdService.update(AccountFreezd.builder().id(freezdId).status(3).unfreezeAmount(oldFlow.getAmount()).build());
|
|
accountFreezdService.update(AccountFreezd.builder().id(freezdId).status(3).unfreezeAmount(oldFlow.getAmount()).build());
|
|
|
return Result.genSuccessResult();
|
|
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 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
|
|
@Override
|
|
|
public Result recharge(RechargeParam param) {
|
|
public Result recharge(RechargeParam param) {
|
|
|
- Account account = accountService.getAccount(param.getUserId(),1);
|
|
|
|
|
- if (account == null){
|
|
|
|
|
|
|
+ Account account = accountService.getAccount(param.getUserId(), 1);
|
|
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Account innerCapitalAccount = accountService.findById(MyConstants.INNER_MARKETING);
|
|
Account innerCapitalAccount = accountService.findById(MyConstants.INNER_MARKETING);
|
|
|
- if (innerCapitalAccount == null){
|
|
|
|
|
|
|
+ if (innerCapitalAccount == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
@@ -160,24 +162,24 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.bizId(param.getBizId()).type(1).userId(param.getUserId())
|
|
.bizId(param.getBizId()).type(1).userId(param.getUserId())
|
|
|
.build();
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借 :平台营销账户(负债类)xx元 平台营销账户(负债类)+钱
|
|
|
|
|
|
|
+ // 借 :平台营销账户(负债类)xx元 平台营销账户(负债类)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_MARKETING).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_MARKETING).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(innerCapitalAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(innerCapitalAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
|
|
|
|
+ // 贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if (param.getDiscount().compareTo(BigDecimal.ZERO) > 0){
|
|
|
|
|
- //充值返点
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (param.getDiscount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ // 充值返点
|
|
|
Account innerRebateAccount = accountService.findById(MyConstants.INNER_REBATE);
|
|
Account innerRebateAccount = accountService.findById(MyConstants.INNER_REBATE);
|
|
|
- if (innerCapitalAccount == null){
|
|
|
|
|
|
|
+ if (innerCapitalAccount == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
flow = Flow.builder().amount(param.getDiscount()).bizType(BizTypeEnum.REFUND_RECHARGE.getKey())
|
|
flow = Flow.builder().amount(param.getDiscount()).bizType(BizTypeEnum.REFUND_RECHARGE.getKey())
|
|
@@ -187,53 +189,59 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.bizId(param.getBizId()).type(10)
|
|
.bizId(param.getBizId()).type(10)
|
|
|
.build();
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借 :平台资金银行xx元 内部户1(资产类:借方账户)+钱
|
|
|
|
|
|
|
+ // 借 :平台资金银行xx元 内部户1(资产类:借方账户)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_REBATE).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_REBATE).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerRebateAccount.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(innerRebateAccount.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerRebateAccount.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(innerRebateAccount.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(innerRebateAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(innerRebateAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(1).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
|
|
|
|
+ // 贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(1).type(2).bizType(10).flowId(flow.getId()).build());
|
|
.flowType(1).type(2).bizType(10).flowId(flow.getId()).build());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return Result.genSuccessResult();
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result pay(PayParam param) {
|
|
public Result pay(PayParam param) {
|
|
|
-
|
|
|
|
|
- Account account = accountService.getAccount(param.getUserId(),1);
|
|
|
|
|
- if (account == null){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Account account = accountService.getAccount(param.getUserId(), 1);
|
|
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Account innerIncomeAccount = accountService.findById(MyConstants.INNER_INCOME);
|
|
Account innerIncomeAccount = accountService.findById(MyConstants.INNER_INCOME);
|
|
|
- if (innerIncomeAccount == null){
|
|
|
|
|
|
|
+ if (innerIncomeAccount == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //借:个人账户钱包(贷) -500元
|
|
|
|
|
- //贷:平台主营收入(贷) +500元
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 冻结金额
|
|
|
|
|
+ BigDecimal sumFreezdAmount = accountFreezdService.sumFreezdForRefundByUserId(param.getUserId());
|
|
|
|
|
+ if (account.getBalance().subtract(account.getFreezeAmount()).add(sumFreezdAmount).compareTo(param.getAmount()) == -1) {
|
|
|
|
|
+ return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 借:个人账户钱包(贷) -500元
|
|
|
|
|
+ // 贷:平台主营收入(贷) +500元
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.userId(param.getUserId())
|
|
.userId(param.getUserId())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
- .debitAccount(account.getId()).creditAccount(MyConstants.INNER_INCOME).createUser(param.getUserId()+"")
|
|
|
|
|
|
|
+ .debitAccount(account.getId()).creditAccount(MyConstants.INNER_INCOME).createUser(param.getUserId() + "")
|
|
|
.bizId(param.getBizId()).type(6)
|
|
.bizId(param.getBizId()).type(6)
|
|
|
.build();
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借:个人账户钱包(贷) -500元
|
|
|
|
|
|
|
+ // 借:个人账户钱包(贷) -500元
|
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().subtract(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().subtract(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(6).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(6).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷:平台主营收入(贷) +500元
|
|
|
|
|
|
|
+ // 贷:平台主营收入(贷) +500元
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_INCOME).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_INCOME).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerIncomeAccount.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(innerIncomeAccount.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerIncomeAccount.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(innerIncomeAccount.getBalance().add(flow.getAmount()))
|
|
@@ -241,19 +249,19 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.flowType(6).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(6).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
return Result.genSuccessResult();
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result refund(RefundParam param) {
|
|
public Result refund(RefundParam param) {
|
|
|
-
|
|
|
|
|
- //借:主营支出-退款(借) +100元
|
|
|
|
|
- //贷:个人账户 (贷) +100元
|
|
|
|
|
-
|
|
|
|
|
- Account account = accountService.getAccount(param.getUserId(),1);
|
|
|
|
|
- if (account == null){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 借:主营支出-退款(借) +100元
|
|
|
|
|
+ // 贷:个人账户 (贷) +100元
|
|
|
|
|
+
|
|
|
|
|
+ Account account = accountService.getAccount(param.getUserId(), 1);
|
|
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Account innerRefundAccount = accountService.findById(MyConstants.INNER_REFUND);
|
|
Account innerRefundAccount = accountService.findById(MyConstants.INNER_REFUND);
|
|
|
- if (innerRefundAccount == null){
|
|
|
|
|
|
|
+ if (innerRefundAccount == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
@@ -261,16 +269,27 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.userId(param.getUserId())
|
|
.userId(param.getUserId())
|
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
.bizNo(param.getBizNo()).createTime(today).updateTime(today).transTime(param.getTransTime())
|
|
|
.debitAccount(MyConstants.INNER_REFUND).creditAccount(account.getId())
|
|
.debitAccount(MyConstants.INNER_REFUND).creditAccount(account.getId())
|
|
|
- .bizId(param.getBizId()).type(9).createUser(param.getUserId()+"")
|
|
|
|
|
|
|
+ .bizId(param.getBizId()).type(9).createUser(param.getUserId() + "")
|
|
|
.build();
|
|
.build();
|
|
|
|
|
+ freeze(FreezdParam.builder()
|
|
|
|
|
+ .accountType(account.getType())
|
|
|
|
|
+ .amount(param.getAmount())
|
|
|
|
|
+ .bizType(param.getBizType())
|
|
|
|
|
+ .bizId(param.getBizId())
|
|
|
|
|
+ .bizNo(param.getBizNo())
|
|
|
|
|
+ .transTime(param.getTransTime())
|
|
|
|
|
+ .userId(param.getUserId())
|
|
|
|
|
+ .type(AccountFreezdTypeEnum.REFUND_FREEZE)
|
|
|
|
|
+ .build()
|
|
|
|
|
+ );
|
|
|
saveUseGeneratedKeys(flow);
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借:主营支出-退款(借) +100元
|
|
|
|
|
|
|
+ // 借:主营支出-退款(借) +100元
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_REFUND).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_REFUND).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerRefundAccount.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(innerRefundAccount.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerRefundAccount.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(innerRefundAccount.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(innerRefundAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(innerRefundAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(7).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(7).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷:个人账户(贷) +100元
|
|
|
|
|
|
|
+ // 贷:个人账户(贷) +100元
|
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
@@ -278,19 +297,19 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.flowType(7).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(7).type(2).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
return Result.genSuccessResult();
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result withdraw(WithdrawParam param) {
|
|
public Result withdraw(WithdrawParam param) {
|
|
|
-
|
|
|
|
|
- Account account = accountService.getAccount(param.getUserId(),param.getAccountType());
|
|
|
|
|
- if (account == null){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ Account account = accountService.getAccount(param.getUserId(), param.getAccountType());
|
|
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Account innerCapitalAccount = accountService.findById(MyConstants.INNER_CAPITAL);
|
|
Account innerCapitalAccount = accountService.findById(MyConstants.INNER_CAPITAL);
|
|
|
- if (innerCapitalAccount == null){
|
|
|
|
|
|
|
+ if (innerCapitalAccount == null) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
Flow flow = Flow.builder().amount(param.getAmount()).bizType(param.getBizType())
|
|
|
.userId(param.getUserId())
|
|
.userId(param.getUserId())
|
|
@@ -299,14 +318,14 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.bizId(param.getBizId()).type(3)
|
|
.bizId(param.getBizId()).type(3)
|
|
|
.build();
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
saveUseGeneratedKeys(flow);
|
|
|
-
|
|
|
|
|
- //借 :客户资金账户xx元 客户账号(负债类:贷方账户)-钱
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 借 :客户资金账户xx元 客户账号(负债类:贷方账户)-钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().subtract(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().subtract(flow.getAmount()))
|
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(account.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(3).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(3).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷 :资金应收-渠道款-银行xx元 内部户1(资产类:借方账户)-钱
|
|
|
|
|
|
|
+ // 贷 :资金应收-渠道款-银行xx元 内部户1(资产类:借方账户)-钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_CAPITAL).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_CAPITAL).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(param.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(param.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().subtract(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().subtract(flow.getAmount()))
|
|
@@ -314,31 +333,31 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.flowType(3).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(3).type(1).bizType(param.getBizType()).flowId(flow.getId()).build());
|
|
|
return Result.genSuccessResult();
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result settle(RedEnvelope redEnvelope) {
|
|
public Result settle(RedEnvelope redEnvelope) {
|
|
|
Account account = accountService.getAccount(redEnvelope.getUserId(), 2);
|
|
Account account = accountService.getAccount(redEnvelope.getUserId(), 2);
|
|
|
- if (account == null){
|
|
|
|
|
- throw new ServiceException(LocalUtil.get("income.account.not.found"));
|
|
|
|
|
|
|
+ if (account == null) {
|
|
|
|
|
+ throw new ServiceException(LocalUtil.get("income.account.not.found"));
|
|
|
}
|
|
}
|
|
|
Account innerCapitalAccount = accountService.findById(MyConstants.INNER_RED);
|
|
Account innerCapitalAccount = accountService.findById(MyConstants.INNER_RED);
|
|
|
- if (innerCapitalAccount == null){
|
|
|
|
|
- throw new ServiceException(LocalUtil.get("account.not.found"));
|
|
|
|
|
|
|
+ if (innerCapitalAccount == null) {
|
|
|
|
|
+ throw new ServiceException(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
|
Date today = DateUtil.date();
|
|
Date today = DateUtil.date();
|
|
|
Flow flow = Flow.builder().amount(redEnvelope.getAmount()).bizType(redEnvelope.getBizType())
|
|
Flow flow = Flow.builder().amount(redEnvelope.getAmount()).bizType(redEnvelope.getBizType())
|
|
|
.bizNo(redEnvelope.getOrderNo()).createTime(today).updateTime(today).transTime(redEnvelope.getTransTime())
|
|
.bizNo(redEnvelope.getOrderNo()).createTime(today).updateTime(today).transTime(redEnvelope.getTransTime())
|
|
|
.debitAccount(MyConstants.INNER_RED).creditAccount(account.getId())
|
|
.debitAccount(MyConstants.INNER_RED).creditAccount(account.getId())
|
|
|
- .bizId(redEnvelope.getId()+"").type(1).userId(redEnvelope.getUserId())
|
|
|
|
|
|
|
+ .bizId(redEnvelope.getId() + "").type(1).userId(redEnvelope.getUserId())
|
|
|
.build();
|
|
.build();
|
|
|
saveUseGeneratedKeys(flow);
|
|
saveUseGeneratedKeys(flow);
|
|
|
- //借 :主营业务支出-红包(损益类)xx元 主营业务支出-红包(损益类)+钱
|
|
|
|
|
|
|
+ // 借 :主营业务支出-红包(损益类)xx元 主营业务支出-红包(损益类)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_RED).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(MyConstants.INNER_RED).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(redEnvelope.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(innerCapitalAccount.getAliases()).transTime(redEnvelope.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(innerCapitalAccount.getBalance().add(flow.getAmount()))
|
|
|
.freezeAmount(innerCapitalAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
.freezeAmount(innerCapitalAccount.getFreezeAmount()).userId(flow.getUserId())
|
|
|
.flowType(1).type(2).bizType(redEnvelope.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(1).type(2).bizType(redEnvelope.getBizType()).flowId(flow.getId()).build());
|
|
|
- //贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
|
|
|
|
+ // 贷 :客户资金账户xx元 客户账号(负债类:贷方账户)+钱
|
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
accountService.deal(AccountFlow.builder().accountId(account.getId()).amount(flow.getAmount())
|
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(redEnvelope.getTransTime())
|
|
.bizId(flow.getBizId()).aliases(account.getAliases()).transTime(redEnvelope.getTransTime())
|
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
.bizNo(flow.getBizNo()).balance(account.getBalance().add(flow.getAmount()))
|
|
@@ -346,11 +365,11 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.flowType(1).type(2).bizType(redEnvelope.getBizType()).flowId(flow.getId()).build());
|
|
.flowType(1).type(2).bizType(redEnvelope.getBizType()).flowId(flow.getId()).build());
|
|
|
return Result.genSuccessResult();
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Integer countByUserId(HashMap map) {
|
|
public Integer countByUserId(HashMap map) {
|
|
|
return cFlowMapper.countByUserId(map);
|
|
return cFlowMapper.countByUserId(map);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|