|
@@ -59,16 +59,16 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
|
|
|
|
|
@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())
|
|
@@ -94,29 +94,29 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.build();
|
|
.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();
|
|
@@ -133,49 +133,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();
|
|
@@ -185,13 +185,13 @@ 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()))
|
|
@@ -212,33 +212,33 @@ 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"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -266,7 +266,7 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
if (account.getBalance().subtract(account.getFreezeAmount()).compareTo(param.getAmount()) == -1) {
|
|
if (account.getBalance().subtract(account.getFreezeAmount()).compareTo(param.getAmount()) == -1) {
|
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
return Result.genFailResult(LocalUtil.get("account.not.found"));
|
|
|
}
|
|
}
|
|
@@ -287,13 +287,13 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.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()))
|
|
@@ -301,19 +301,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();
|
|
@@ -321,7 +321,7 @@ 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();
|
|
|
|
|
|
|
|
com.txz.operating.result.Result<ConfigDTO> refundFreezeTime = operatingConfigDubboServiceClient.getConfigByCode("refund_freeze_time");
|
|
com.txz.operating.result.Result<ConfigDTO> refundFreezeTime = operatingConfigDubboServiceClient.getConfigByCode("refund_freeze_time");
|
|
@@ -342,13 +342,13 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.build()
|
|
.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()))
|
|
@@ -356,19 +356,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()
|
|
Flow flow = Flow.builder()
|
|
|
.amount(param.getAmount())
|
|
.amount(param.getAmount())
|
|
@@ -384,14 +384,14 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
.type(3)
|
|
.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()))
|
|
@@ -399,31 +399,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()))
|
|
@@ -431,7 +431,7 @@ 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);
|
|
@@ -442,6 +442,10 @@ public class FlowServiceImpl extends AbstractService<Flow> implements FlowServic
|
|
|
AccountFreezd accountFreezd = accountFreezdService.findById(id);
|
|
AccountFreezd accountFreezd = accountFreezdService.findById(id);
|
|
|
// 可用冻结金额
|
|
// 可用冻结金额
|
|
|
BigDecimal canUseAmount = accountFreezd.getAmount().subtract(accountFreezd.getUnfreezeAmount());
|
|
BigDecimal canUseAmount = accountFreezd.getAmount().subtract(accountFreezd.getUnfreezeAmount());
|
|
|
|
|
+ // 解冻账户金额
|
|
|
|
|
+ Account account = accountService.getAccount(accountFreezd.getUserId(), 1);
|
|
|
|
|
+ account.setFreezeAmount(account.getFreezeAmount().subtract(partialThawAmount));
|
|
|
|
|
+ accountService.update(account);
|
|
|
// 可用金额小于等于总金额
|
|
// 可用金额小于等于总金额
|
|
|
if (canUseAmount.compareTo(partialThawAmount) != 1) {
|
|
if (canUseAmount.compareTo(partialThawAmount) != 1) {
|
|
|
accountFreezd.setStatus(3);
|
|
accountFreezd.setStatus(3);
|