|
|
@@ -40,7 +40,7 @@ public class SettleService {
|
|
|
SettleService settleService;
|
|
|
|
|
|
@Transactional
|
|
|
- public ResultContent settle(String projectOid, String oid, Long endTime, String remark, PaymentType paymentType){
|
|
|
+ public ResultContent settle(String projectOid, String oid, Long endTime, String remark, PaymentType paymentType) {
|
|
|
//获取机构-待结算子账
|
|
|
PayAccount waitSettleAccount = payAccountService.getOrgChildren(projectOid, oid, PaymentChannelType.WaitSettle);
|
|
|
//查询时间内所有待结算账单
|
|
|
@@ -52,7 +52,7 @@ public class SettleService {
|
|
|
// queryModel.setFilter(Map.of("meta.paymentType", paymentType));
|
|
|
queryModel.setFilter(Map.of("meta.paymentType", paymentType, "$or", Arrays.asList(
|
|
|
new Document()
|
|
|
- .append("meta.settleStatus", new Document()
|
|
|
+ .append("meta.settleStatus", new Document()
|
|
|
.append("$exists", false)
|
|
|
),
|
|
|
new Document()
|
|
|
@@ -61,11 +61,11 @@ public class SettleService {
|
|
|
ResultContent<TransactionLogAggregateNotPageRetModel> aggregateResult = transactionLogService.aggregateNotPage(queryModel);
|
|
|
|
|
|
|
|
|
- if (!aggregateResult.getState().equals(ResultState.Success)){
|
|
|
+ if (!aggregateResult.getState().equals(ResultState.Success)) {
|
|
|
log.info("资金结算:查询待结算账单失败");
|
|
|
throw new RuntimeException(aggregateResult.getMsg());
|
|
|
}
|
|
|
- if (aggregateResult.getContent().getList().isEmpty()){
|
|
|
+ if (aggregateResult.getContent().getList().isEmpty()) {
|
|
|
return ResultContent.buildContent(new HashSet<>());
|
|
|
}
|
|
|
List<TransactionLogModel> transactionLogModelList = aggregateResult.getContent().getList();
|
|
|
@@ -82,7 +82,7 @@ public class SettleService {
|
|
|
//收入-支出=可提现金额
|
|
|
long settleAmount = aggregateResult.getContent().getStatistics().getCreditCount() + aggregateResult.getContent().getStatistics().getDebitCount();
|
|
|
|
|
|
- if (settleAmount<=0L){
|
|
|
+ if (settleAmount <= 0L) {
|
|
|
log.info("该账户可结算金额小于或等于0, 账户:{},可提现金额:{}, 时间{}", waitSettleAccount.getLedgerId(), settleAmount, endTime);
|
|
|
throw new RuntimeException("该账户可结算金额小于或等于0");
|
|
|
}
|
|
|
@@ -100,7 +100,7 @@ public class SettleService {
|
|
|
sourceTransaction.setTransactionStatus(TransactionStatus.Success);
|
|
|
sourceTransaction.setAmount(-settleAmount);
|
|
|
sourceTransaction.setRemark(remark);
|
|
|
- sourceTransaction.setMeta(Map.of("orderSize", orderNoSet.size(),"transactionLogList", settleList,"paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "结算"));
|
|
|
+ sourceTransaction.setMeta(Map.of("orderSize", orderNoSet.size(), "transactionLogList", settleList, "paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "结算"));
|
|
|
transferModel.setSource(new TransferTransactionsModel.GeneralLedgerTransaction[]{sourceTransaction});
|
|
|
//构建入账账户
|
|
|
TransferTransactionsModel.GeneralLedgerTransaction destinationTransaction = new TransferTransactionsModel.GeneralLedgerTransaction();
|
|
|
@@ -110,11 +110,11 @@ public class SettleService {
|
|
|
destinationTransaction.setTransactionStatus(TransactionStatus.Success);
|
|
|
destinationTransaction.setAmount(settleAmount);
|
|
|
destinationTransaction.setRemark(remark);
|
|
|
- destinationTransaction.setMeta(Map.of("orderSize", orderNoSet.size(),"transactionLogList", settleList,"paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "结算"));
|
|
|
+ destinationTransaction.setMeta(Map.of("orderSize", orderNoSet.size(), "transactionLogList", settleList, "paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "结算"));
|
|
|
transferModel.setDestinations(new TransferTransactionsModel.GeneralLedgerTransaction[]{destinationTransaction});
|
|
|
ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferModel);
|
|
|
|
|
|
- if (!transfer.getState().equals(ResultState.Success)){
|
|
|
+ if (!transfer.getState().equals(ResultState.Success)) {
|
|
|
log.error("结算划账失败, projectOid: {}, paymentType: {}", projectOid, paymentType);
|
|
|
throw new RuntimeException(transfer.getMsg());
|
|
|
}
|
|
|
@@ -122,7 +122,7 @@ public class SettleService {
|
|
|
updateMetaFieldModel.setIds(settleList);
|
|
|
updateMetaFieldModel.setMetaField(Map.of("settleStatus", SettleStatus.Settle));
|
|
|
ResultContent<Void> updateManyMetaField = transactionLogService.updateManyMetaField(updateMetaFieldModel);
|
|
|
- if (!updateManyMetaField.getState().equals(ResultState.Success)){
|
|
|
+ if (!updateManyMetaField.getState().equals(ResultState.Success)) {
|
|
|
log.error("修改账单meta字段失败, projectOid: {}, paymentType: {}", projectOid, paymentType);
|
|
|
throw new RuntimeException(updateManyMetaField.getMsg());
|
|
|
}
|