|
|
|
@ -1,8 +1,9 @@ |
|
|
|
package com.example.demo.serviceImpl.cash; |
|
|
|
|
|
|
|
import com.example.demo.domain.entity.Admin; |
|
|
|
import com.example.demo.Util.BusinessException; |
|
|
|
import com.example.demo.Util.GoldTistV2; |
|
|
|
import com.example.demo.controller.coin.AuditController; |
|
|
|
import com.example.demo.domain.entity.Market; |
|
|
|
import com.example.demo.domain.entity.User; |
|
|
|
import com.example.demo.domain.entity.UserGoldRecord; |
|
|
|
import com.example.demo.domain.vo.cash.*; |
|
|
|
@ -13,20 +14,18 @@ import com.example.demo.mapper.cash.CashRefundMapper; |
|
|
|
import com.example.demo.mapper.coin.AuditMapper; |
|
|
|
import com.example.demo.mapper.coin.MarketMapper; |
|
|
|
import com.example.demo.mapper.coin.RefundMapper; |
|
|
|
import com.example.demo.service.cash.CashCollectionService; |
|
|
|
import com.example.demo.service.cash.RefundService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static org.apache.commons.lang3.StringUtils.substring; |
|
|
|
|
|
|
|
@ -58,48 +57,97 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
@Override |
|
|
|
public PageInfo<CashRecordDTO> select(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) { |
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
// System.out.println(goldDetail.getMarkets()); |
|
|
|
List<CashRecordDTO> list = cashRefundMapper.select(cashRecordDTO); |
|
|
|
|
|
|
|
if (list.isEmpty()) { |
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
// 批量收集ID |
|
|
|
Set<Integer> relatedIds = new HashSet<>(); |
|
|
|
Set<Integer> marketIds = new HashSet<>(); |
|
|
|
Set<Integer> submitterIds = new HashSet<>(); |
|
|
|
Set<Integer> auditIds = new HashSet<>(); |
|
|
|
|
|
|
|
list.forEach(item -> { |
|
|
|
if (item.getRelatedId() != null) relatedIds.add(item.getRelatedId()); |
|
|
|
if (item.getMarket() != null) marketIds.add(Integer.valueOf(item.getMarket())); |
|
|
|
if (item.getSubmitterId() != null) submitterIds.add(item.getSubmitterId()); |
|
|
|
if (item.getAuditId() != null) auditIds.add(item.getAuditId()); |
|
|
|
}); |
|
|
|
|
|
|
|
// 批量查询 |
|
|
|
Map<Integer, CashCollection> cashCollectionMap = cashCollectionMapper.selectBatchIds(relatedIds) |
|
|
|
.stream().collect(Collectors.toMap(CashCollection::getId, Function.identity())); |
|
|
|
|
|
|
|
Map<Integer, String> marketNameMap = marketMapper.getMarketByIds(marketIds) |
|
|
|
.stream().collect(Collectors.toMap(Market::getId, Market::getName)); |
|
|
|
|
|
|
|
Map<Integer, String> submitterNameMap = auditMapper.getNamesByIds(submitterIds) |
|
|
|
.stream().collect(Collectors.toMap(Admin::getId, Admin::getAdminName)); |
|
|
|
|
|
|
|
Map<Integer, LhlAudit> auditMap = cashRefundMapper.getAuditBatch(auditIds) |
|
|
|
.stream().collect(Collectors.toMap(LhlAudit::getId, Function.identity())); |
|
|
|
|
|
|
|
// 处理数据 |
|
|
|
list.forEach(item -> { |
|
|
|
CashCollection cashCollection = cashCollectionMapper.selectById(item.getRelatedId()); |
|
|
|
String marketName = marketMapper.getMarketById(item.getMarket()); |
|
|
|
String submitter = auditMapper.getName(item.getSubmitterId()); |
|
|
|
LhlAudit lhlAudit = cashRefundMapper.getAudit(item.getAuditId()); |
|
|
|
if(cashCollection.getFreeGold()== null){ |
|
|
|
cashCollection.setFreeGold(0); |
|
|
|
CashCollection cashCollection = cashCollectionMap.get(item.getRelatedId()); |
|
|
|
if (cashCollection != null) { |
|
|
|
processCashCollection(item, cashCollection); |
|
|
|
} |
|
|
|
if(cashCollection.getPermanentGold()== null){ |
|
|
|
cashCollection.setPermanentGold(0); |
|
|
|
|
|
|
|
String marketName = marketNameMap.get(item.getMarket()); |
|
|
|
String submitter = submitterNameMap.get(item.getSubmitterId()); |
|
|
|
LhlAudit lhlAudit = auditMap.get(item.getAuditId()); |
|
|
|
|
|
|
|
item.setMarketName(marketName != null ? marketName : ""); |
|
|
|
item.setSubmitter(submitter != null ? submitter : ""); |
|
|
|
|
|
|
|
if (lhlAudit != null) { |
|
|
|
item.setAreaServise(lhlAudit.getAreaServise()); |
|
|
|
item.setAreaFinance(lhlAudit.getAreaFinance()); |
|
|
|
item.setAreaCharge(lhlAudit.getAreaCharge()); |
|
|
|
item.setHeadFinance(lhlAudit.getHeadFinace()); |
|
|
|
} |
|
|
|
BigDecimal free = new BigDecimal(cashCollection.getFreeGold()) |
|
|
|
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
BigDecimal permanent = new BigDecimal(cashCollection.getPermanentGold()) |
|
|
|
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
item.setGold(permanent); |
|
|
|
item.setFree(free); |
|
|
|
item.setActivity(cashCollection.getActivity()); |
|
|
|
item.setPaymentCurrency(cashCollection.getPaymentCurrency()); |
|
|
|
item.setPaymentAmount(cashCollection.getPaymentAmount()); |
|
|
|
item.setReceivedCurrency(cashCollection.getReceivedCurrency()); |
|
|
|
item.setReceivedAmount(cashCollection.getReceivedAmount()); |
|
|
|
item.setPayType(cashCollection.getPayType()); |
|
|
|
item.setPayTime(cashCollection.getPayTime()); |
|
|
|
item.setPayBankCode(cashCollection.getBankCode()); |
|
|
|
item.setPaySubmitter(cashCollection.getSubmitterName()); |
|
|
|
item.setAudit(cashCollection.getAuditName()); |
|
|
|
item.setReceivedTime(cashCollection.getReceivedTime()); |
|
|
|
item.setPayVoucher(cashCollection.getVoucher()); |
|
|
|
item.setPayRemark(cashCollection.getRemark()); |
|
|
|
item.setMarketName(marketName); |
|
|
|
item.setSubmitter(submitter); |
|
|
|
item.setAreaServise(lhlAudit.getAreaServise()); |
|
|
|
item.setAreaFinance(lhlAudit.getAreaFinance()); |
|
|
|
item.setAreaCharge(lhlAudit.getAreaCharge()); |
|
|
|
item.setHeadFinance(lhlAudit.getHeadFinace()); |
|
|
|
}); |
|
|
|
|
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
private void processCashCollection(CashRecordDTO item, CashCollection cashCollection) { |
|
|
|
// 设置默认值 |
|
|
|
Integer freeGold = cashCollection.getFreeGold() != null ? cashCollection.getFreeGold() : 0; |
|
|
|
Integer permanentGold = cashCollection.getPermanentGold() != null ? cashCollection.getPermanentGold() : 0; |
|
|
|
|
|
|
|
BigDecimal free = new BigDecimal(freeGold).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
BigDecimal permanent = new BigDecimal(permanentGold).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
item.setGold(permanent); |
|
|
|
item.setFree(free); |
|
|
|
item.setActivity(cashCollection.getActivity()); |
|
|
|
item.setPaymentCurrency(cashCollection.getPaymentCurrency()); |
|
|
|
item.setPaymentAmount(cashCollection.getPaymentAmount()); |
|
|
|
item.setReceivedCurrency(cashCollection.getReceivedCurrency()); |
|
|
|
item.setReceivedAmount(cashCollection.getReceivedAmount()); |
|
|
|
item.setPayType(cashCollection.getPayType()); |
|
|
|
item.setPayTime(cashCollection.getPayTime()); |
|
|
|
item.setPayBankCode(cashCollection.getBankCode()); |
|
|
|
item.setPaySubmitter(cashCollection.getSubmitterName()); |
|
|
|
item.setAudit(cashCollection.getAuditName()); |
|
|
|
item.setReceivedTime(cashCollection.getReceivedTime()); |
|
|
|
item.setPayVoucher(cashCollection.getVoucher()); |
|
|
|
item.setPayRemark(cashCollection.getRemark()); |
|
|
|
item.setHandlingCharge(cashCollection.getHandlingCharge()); |
|
|
|
|
|
|
|
// 处理金币金额 |
|
|
|
if (item.getPermanentGold() != null) { |
|
|
|
item.setPermanentGold(item.getPermanentGold().divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
if (item.getFreeGold() != null) { |
|
|
|
item.setFreeGold(item.getFreeGold().divide(new BigDecimal(100), 2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int add(CashRecordRefund cashRecordRefund) throws Exception { |
|
|
|
if(cashRecordRefund.getJwcode()==null){ |
|
|
|
@ -270,44 +318,58 @@ CashRecordDone cashRecordDone1 = new CashRecordDone(); |
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
// System.out.println(goldDetail.getMarkets()); |
|
|
|
List<CashRecordDTO> list = cashRefundMapper.financeSelect(cashRecordDTO); |
|
|
|
System.out.println( list); |
|
|
|
if (list.isEmpty()) { |
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
// 批量收集ID |
|
|
|
Set<Integer> relatedIds = new HashSet<>(); |
|
|
|
Set<Integer> marketIds = new HashSet<>(); |
|
|
|
Set<Integer> submitterIds = new HashSet<>(); |
|
|
|
Set<Integer> auditIds = new HashSet<>(); |
|
|
|
|
|
|
|
list.forEach(item -> { |
|
|
|
CashCollection cashCollection = cashCollectionMapper.selectById(item.getRelatedId()); |
|
|
|
String marketName = marketMapper.getMarketById(item.getMarket()); |
|
|
|
String submitter = auditMapper.getName(item.getSubmitterId()); |
|
|
|
LhlAudit lhlAudit = cashRefundMapper.getAudit(item.getAuditId()); |
|
|
|
if(cashCollection.getFreeGold()== null){ |
|
|
|
cashCollection.setFreeGold(0); |
|
|
|
if (item.getRelatedId() != null) relatedIds.add(item.getRelatedId()); |
|
|
|
if (item.getMarket() != null) marketIds.add(Integer.valueOf(item.getMarket())); |
|
|
|
if (item.getSubmitterId() != null) submitterIds.add(item.getSubmitterId()); |
|
|
|
if (item.getAuditId() != null) auditIds.add(item.getAuditId()); |
|
|
|
}); |
|
|
|
|
|
|
|
// 批量查询 |
|
|
|
Map<Integer, CashCollection> cashCollectionMap = cashCollectionMapper.selectBatchIds(relatedIds) |
|
|
|
.stream().collect(Collectors.toMap(CashCollection::getId, Function.identity())); |
|
|
|
|
|
|
|
Map<Integer, String> marketNameMap = marketMapper.getMarketByIds(marketIds) |
|
|
|
.stream().collect(Collectors.toMap(Market::getId, Market::getName)); |
|
|
|
|
|
|
|
Map<Integer, String> submitterNameMap = auditMapper.getNamesByIds(submitterIds) |
|
|
|
.stream().collect(Collectors.toMap(Admin::getId, Admin::getAdminName)); |
|
|
|
|
|
|
|
Map<Integer, LhlAudit> auditMap = cashRefundMapper.getAuditBatch(auditIds) |
|
|
|
.stream().collect(Collectors.toMap(LhlAudit::getId, Function.identity())); |
|
|
|
|
|
|
|
// 处理数据 |
|
|
|
list.forEach(item -> { |
|
|
|
CashCollection cashCollection = cashCollectionMap.get(item.getRelatedId()); |
|
|
|
if (cashCollection != null) { |
|
|
|
processCashCollection(item, cashCollection); |
|
|
|
} |
|
|
|
if(cashCollection.getPermanentGold()== null){ |
|
|
|
cashCollection.setPermanentGold(0); |
|
|
|
|
|
|
|
String marketName = marketNameMap.get(item.getMarket()); |
|
|
|
String submitter = submitterNameMap.get(item.getSubmitterId()); |
|
|
|
LhlAudit lhlAudit = auditMap.get(item.getAuditId()); |
|
|
|
|
|
|
|
item.setMarketName(marketName != null ? marketName : ""); |
|
|
|
item.setSubmitter(submitter != null ? submitter : ""); |
|
|
|
|
|
|
|
if (lhlAudit != null) { |
|
|
|
item.setAreaServise(lhlAudit.getAreaServise()); |
|
|
|
item.setAreaFinance(lhlAudit.getAreaFinance()); |
|
|
|
item.setAreaCharge(lhlAudit.getAreaCharge()); |
|
|
|
item.setHeadFinance(lhlAudit.getHeadFinace()); |
|
|
|
} |
|
|
|
BigDecimal free = new BigDecimal(cashCollection.getFreeGold()) |
|
|
|
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
BigDecimal permanent = new BigDecimal(cashCollection.getPermanentGold()) |
|
|
|
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
item.setGold(permanent); |
|
|
|
item.setFree(free); |
|
|
|
item.setActivity(cashCollection.getActivity()); |
|
|
|
item.setPaymentCurrency(cashCollection.getPaymentCurrency()); |
|
|
|
item.setPaymentAmount(cashCollection.getPaymentAmount()); |
|
|
|
item.setReceivedCurrency(cashCollection.getReceivedCurrency()); |
|
|
|
item.setReceivedAmount(cashCollection.getReceivedAmount()); |
|
|
|
item.setPayType(cashCollection.getPayType()); |
|
|
|
item.setPayTime(cashCollection.getPayTime()); |
|
|
|
item.setPayBankCode(cashCollection.getBankCode()); |
|
|
|
item.setPaySubmitter(cashCollection.getSubmitterName()); |
|
|
|
item.setAudit(cashCollection.getAuditName()); |
|
|
|
item.setReceivedTime(cashCollection.getReceivedTime()); |
|
|
|
item.setPayVoucher(cashCollection.getVoucher()); |
|
|
|
item.setPayRemark(cashCollection.getRemark()); |
|
|
|
item.setMarketName(marketName); |
|
|
|
item.setSubmitter(submitter); |
|
|
|
item.setAreaServise(lhlAudit.getAreaServise()); |
|
|
|
item.setAreaFinance(lhlAudit.getAreaFinance()); |
|
|
|
item.setAreaCharge(lhlAudit.getAreaCharge()); |
|
|
|
item.setHeadFinance(lhlAudit.getHeadFinace()); |
|
|
|
}); |
|
|
|
|
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
@ -316,38 +378,58 @@ CashRecordDone cashRecordDone1 = new CashRecordDone(); |
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
// System.out.println(goldDetail.getMarkets()); |
|
|
|
List<CashRecordDTO> list = cashRefundMapper.exSelect(cashRecordDTO); |
|
|
|
if (list.isEmpty()) { |
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
// 批量收集ID |
|
|
|
Set<Integer> relatedIds = new HashSet<>(); |
|
|
|
Set<Integer> marketIds = new HashSet<>(); |
|
|
|
Set<Integer> submitterIds = new HashSet<>(); |
|
|
|
Set<Integer> auditIds = new HashSet<>(); |
|
|
|
|
|
|
|
list.forEach(item -> { |
|
|
|
CashCollection cashCollection = cashCollectionMapper.selectById(item.getRelatedId()); |
|
|
|
String marketName |
|
|
|
= marketMapper.getMarketById(item.getMarket()); |
|
|
|
String submitter = auditMapper.getName(item.getSubmitterId()); |
|
|
|
LhlAudit lhlAudit = cashRefundMapper.getAudit(item.getAuditId()); |
|
|
|
BigDecimal free = new BigDecimal(cashCollection.getFreeGold()) |
|
|
|
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
BigDecimal permanent = new BigDecimal(cashCollection.getPermanentGold()) |
|
|
|
.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); |
|
|
|
item.setGold(permanent); |
|
|
|
item.setFree(free); |
|
|
|
item.setActivity(cashCollection.getActivity()); |
|
|
|
item.setPaymentCurrency(cashCollection.getPaymentCurrency()); |
|
|
|
item.setPaymentAmount(cashCollection.getPaymentAmount()); |
|
|
|
item.setReceivedCurrency(cashCollection.getReceivedCurrency()); |
|
|
|
item.setReceivedAmount(cashCollection.getReceivedAmount()); |
|
|
|
item.setPayType(cashCollection.getPayType()); |
|
|
|
item.setPayTime(cashCollection.getPayTime()); |
|
|
|
item.setPayBankCode(cashCollection.getBankCode()); |
|
|
|
item.setPaySubmitter(cashCollection.getSubmitterName()); |
|
|
|
item.setAudit(cashCollection.getAuditName()); |
|
|
|
item.setReceivedTime(cashCollection.getReceivedTime()); |
|
|
|
item.setPayVoucher(cashCollection.getVoucher()); |
|
|
|
item.setPayRemark(cashCollection.getRemark()); |
|
|
|
item.setMarketName(marketName); |
|
|
|
item.setSubmitter(submitter); |
|
|
|
item.setAreaServise(lhlAudit.getAreaServise()); |
|
|
|
item.setAreaFinance(lhlAudit.getAreaFinance()); |
|
|
|
item.setAreaCharge(lhlAudit.getAreaCharge()); |
|
|
|
item.setHeadFinance(lhlAudit.getHeadFinace()); |
|
|
|
if (item.getRelatedId() != null) relatedIds.add(item.getRelatedId()); |
|
|
|
if (item.getMarket() != null) marketIds.add(Integer.valueOf(item.getMarket())); |
|
|
|
if (item.getSubmitterId() != null) submitterIds.add(item.getSubmitterId()); |
|
|
|
if (item.getAuditId() != null) auditIds.add(item.getAuditId()); |
|
|
|
}); |
|
|
|
|
|
|
|
// 批量查询 |
|
|
|
Map<Integer, CashCollection> cashCollectionMap = cashCollectionMapper.selectBatchIds(relatedIds) |
|
|
|
.stream().collect(Collectors.toMap(CashCollection::getId, Function.identity())); |
|
|
|
|
|
|
|
Map<Integer, String> marketNameMap = marketMapper.getMarketByIds(marketIds) |
|
|
|
.stream().collect(Collectors.toMap(Market::getId, Market::getName)); |
|
|
|
|
|
|
|
Map<Integer, String> submitterNameMap = auditMapper.getNamesByIds(submitterIds) |
|
|
|
.stream().collect(Collectors.toMap(Admin::getId, Admin::getAdminName)); |
|
|
|
|
|
|
|
Map<Integer, LhlAudit> auditMap = cashRefundMapper.getAuditBatch(auditIds) |
|
|
|
.stream().collect(Collectors.toMap(LhlAudit::getId, Function.identity())); |
|
|
|
|
|
|
|
// 处理数据 |
|
|
|
list.forEach(item -> { |
|
|
|
CashCollection cashCollection = cashCollectionMap.get(item.getRelatedId()); |
|
|
|
if (cashCollection != null) { |
|
|
|
processCashCollection(item, cashCollection); |
|
|
|
} |
|
|
|
|
|
|
|
String marketName = marketNameMap.get(item.getMarket()); |
|
|
|
String submitter = submitterNameMap.get(item.getSubmitterId()); |
|
|
|
LhlAudit lhlAudit = auditMap.get(item.getAuditId()); |
|
|
|
|
|
|
|
item.setMarketName(marketName != null ? marketName : ""); |
|
|
|
item.setSubmitter(submitter != null ? submitter : ""); |
|
|
|
|
|
|
|
if (lhlAudit != null) { |
|
|
|
item.setAreaServise(lhlAudit.getAreaServise()); |
|
|
|
item.setAreaFinance(lhlAudit.getAreaFinance()); |
|
|
|
item.setAreaCharge(lhlAudit.getAreaCharge()); |
|
|
|
item.setHeadFinance(lhlAudit.getHeadFinace()); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
|