|
|
package com.example.demo.serviceImpl.cash;import com.example.demo.Util.LanguageTranslationUtil;import com.example.demo.Util.SimpleIdGenerator;import com.example.demo.domain.entity.Admin;import com.example.demo.Util.BusinessException;import com.example.demo.Util.GoldTistV2;import com.example.demo.config.RabbitMQConfig;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.*;import com.example.demo.domain.vo.coin.Messages;import com.example.demo.domain.vo.coin.Result;import com.example.demo.exception.SystemException;import com.example.demo.mapper.cash.CashCollectionMapper;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.OperationLogMapper;import com.example.demo.mapper.coin.RefundMapper;import com.example.demo.service.cash.RefundService;import com.github.pagehelper.PageHelper;import com.github.pagehelper.PageInfo;import org.springframework.amqp.rabbit.core.RabbitTemplate;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.web.bind.annotation.RequestHeader;
import java.math.BigDecimal;import java.math.RoundingMode;import java.time.LocalDate;import java.util.*;import java.util.function.Function;import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.substring;
/** * @program: GOLD * @ClassName CashRefundServiceImpl * @description: * @author: huangqizhen * @create: 2025−09-28 15:02 * @Version 1.0 **/@Service
public class CashRefundServiceImpl implements RefundService {
@Autowired private CashRefundMapper cashRefundMapper; @Autowired private RefundMapper refundMapper; @Autowired private AuditMapper auditMapper; @Autowired private MarketMapper marketMapper; @Autowired private RabbitTemplate rabbitTemplate; @Autowired private OperationLogMapper operationLogMapper; @Autowired private CashCollectionMapper cashCollectionMapper; @Autowired private LanguageTranslationUtil languageTranslationUtil;
@Override public PageInfo<CashRecordDTO> select(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) { PageHelper.startPage(pageNum, pageSize); //必须要直接跟mapper
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<>(); Set<Integer> executorIds = new HashSet<>();
list.forEach(item -> { if (item.getRelatedId() != null) relatedIds.add(item.getRelatedId()); if (item.getMarket() != null) marketIds.add(item.getMarket()); if (item.getSubmitterId() != null) submitterIds.add(item.getSubmitterId()); if (item.getAuditId() != null) auditIds.add(item.getAuditId()); if (item.getExecutor() != null) executorIds.add(item.getExecutor()); });
// 批量查询
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())); Map<String, String> executorNameMap = auditMapper.getNamesByJwcodes(executorIds) .stream().collect(Collectors.toMap(Admin::getAccount, Admin::getAdminName));
// 处理数据
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()); String executorName = executorNameMap.get(String.valueOf(item.getExecutor()));
item.setMarketName(marketName != null ? marketName : ""); item.setSubmitter(submitter != null ? submitter : ""); item.setExecutorName(executorName != null ? executorName : "");
if (lhlAudit != null) { item.setAreaServise(lhlAudit.getAreaServise()); item.setAreaFinance(lhlAudit.getAreaFinance()); item.setAreaCharge(lhlAudit.getAreaCharge()); item.setHeadFinance(lhlAudit.getHeadFinance()); } });
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()); if(cashCollection.getPaymentCurrency() != null){ item.setPaymentAmount(cashCollection.getPaymentAmount().divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));} else item.setPaymentAmount(cashCollection.getPaymentAmount()); item.setReceivedCurrency(cashCollection.getReceivedCurrency()); if (cashCollection.getReceivedCurrency() != null){ item.setReceivedAmount(cashCollection.getReceivedAmount().divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));} else 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().divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
// 处理金币金额
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, @RequestHeader(defaultValue = "zh_CN") String lang) throws Exception { if(cashRecordRefund.getJwcode()==null){ throw new Exception("未输入精网号") ; } if(cashRecordRefund.getRefundModel()== null){ throw new Exception("请填充退款类型") ; } if(cashRecordRefund.getRefundReason()== null){ throw new Exception("请填写退款理由") ; } if (cashRecordRefund.getHandlingCharge()== null){ throw new Exception("请先填写手续费") ; } CashRecordDone cashRecordDonetwo = new CashRecordDone(); cashRecordDonetwo.setAreaServise(cashRecordRefund.getAreaServise()); cashRefundMapper.addAudit(cashRecordDonetwo); cashRecordRefund.setAuditId(cashRecordDonetwo.getId());
cashRecordRefund.setStatus(10); //生成订单号后半部分
String orderNumber = cashRecordRefund.getOrderCode(); //构建订单信息
cashRecordRefund.setOrderCode("TK" + orderNumber); //订单号
cashRecordRefund.setMarket(String.valueOf(Integer.valueOf(marketMapper.getMarketId(cashRecordRefund.getMarket())))); cashRefundMapper.insert(cashRecordRefund); CashRecordDone cashRecordDone1 = new CashRecordDone(); cashRecordDone1.setId(cashRecordRefund.getOriginalOrderId()); cashRecordDone1.setStatus(6); if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null) cashRefundMapper.updateStatus(cashRecordDone1); else return Result.error("提交失败").getCode();
// 发送退款创建消息
Messages message = new Messages(); message.setJwcode(cashRecordRefund.getJwcode()); message.setName(cashRecordRefund.getName()); message.setStatus(cashRecordRefund.getStatus()); message.setDesc(cashRecordRefund.getJwcode()+languageTranslationUtil.translate("用户的客服退款申请待审核,前往处理", lang)); message.setTitle(languageTranslationUtil.translate("现金退款--新增退款", lang)); message.setType(0); message.setTypeId(cashRecordRefund.getId()); message.setMarket(Integer.valueOf(cashRecordRefund.getMarket())); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); message.setMarketName(languageTranslationUtil.translate(marketName, lang)); rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message);
return Result.success("提交成功").getCode();
}
@Override public int update(CashRecordDone cashRecordDone, @RequestHeader(defaultValue = "zh_CN") String lang) throws Exception { if (cashRecordDone.getJwcode()== null) { throw new RuntimeException("未输入精网号"); } if (cashRecordDone.getPaymentAmount()== null) { throw new RuntimeException("未输入付款金额"); } if (cashRecordDone.getPaymentCurrency()== null){ throw new RuntimeException("未输入付款币种"); } if (cashRecordDone.getRefundModel()== null) { throw new RuntimeException("请填写退款类型"); } if (cashRecordDone.getRefundReason()== null) { throw new RuntimeException("请填写退款理由"); } if(cashRecordDone.getNewRefundGold()== null){ cashRecordDone.setNewRefundGold(BigDecimal.valueOf(0)); } if(cashRecordDone.getNewRefundFree()== null){ cashRecordDone.setNewRefundFree(BigDecimal.valueOf(0)); } int result = cashRefundMapper.update(cashRecordDone); CashRecordDTO cashRecordDTO = cashRefundMapper.selectById(cashRecordDone.getId()); if (result > 0) { // 发送审核消息
Messages message = new Messages(); message.setJwcode(cashRecordDTO.getJwcode()); message.setName(cashRecordDTO.getName()); message.setStatus(cashRecordDTO.getStatus()); message.setDesc(cashRecordDTO.getJwcode() + languageTranslationUtil.translate("用户的退款申请待审核,前往处理", lang)); message.setTitle(languageTranslationUtil.translate("现金退款--当地退款审核(编辑后提交)", lang)); message.setType(1); message.setTypeId(cashRecordDTO.getId()); message.setMarket(cashRecordDTO.getMarket()); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); message.setMarketName(languageTranslationUtil.translate(marketName, lang)); rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message); } return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode(); }
@Override public int withdraw(CashRecordDone cashRecordDone) { return cashRefundMapper.withdraw(cashRecordDone.getId()); }
@Override public int review(CashRecordDone cashRecordDone, @RequestHeader(defaultValue = "zh_CN") String lang) throws Exception { if(cashRecordDone.getStatus()== 12|| cashRecordDone.getStatus()== 22){ if(cashRecordDone.getOrderCode()== null){ throw new RuntimeException("未输入订单号"); }CashRecordDone cashRecordDone1 = new CashRecordDone(); cashRecordDone1.setId(cashRecordDone.getRelatedId()); cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2)); cashRecordDone1.setStatus(4); if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null){ cashRefundMapper.updateStatus(cashRecordDone1); }} cashRefundMapper.updateAudit(cashRecordDone); int result = cashRefundMapper.review(cashRecordDone); CashRecordDTO cashRecordDTO = cashRefundMapper.selectById(cashRecordDone.getId()); if (result > 0) { // 发送审核消息
Messages message = new Messages(); message.setJwcode(cashRecordDTO.getJwcode()); message.setName(cashRecordDTO.getName()); message.setStatus(cashRecordDTO.getStatus()); message.setDesc(cashRecordDTO.getJwcode()+cashRecordDTO.getStatus()!=12|| cashRecordDTO.getStatus()!=22?languageTranslationUtil.translate("用户的退款申请待审核,前往处理", lang):languageTranslationUtil.translate("用户的现金退款申请已被驳回,前往查看详情", lang)); message.setTitle(languageTranslationUtil.translate("现金退款--当地退款审核", lang)); message.setType(1); message.setTypeId(cashRecordDTO.getId()); message.setMarket(cashRecordDTO.getMarket()); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); message.setMarketName(languageTranslationUtil.translate(marketName, lang));
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message);
}
return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode(); }
@Override public int executor(CashRecordDone cashRecordDone) throws Exception { if(cashRecordDone.getRefundVoucher()== null){ throw new RuntimeException("未输入退款凭证"); } if(cashRecordDone.getRefundTime()== null){ throw new RuntimeException("未输入退款时间"); } if(cashRecordDone.getRefundRemark()== null){ throw new RuntimeException("未输入退款备注"); } if(cashRecordDone.getRefundChannels()== null){ throw new RuntimeException("未输入退款途径"); } if(cashRecordDone.getRefundCurrency()== null){ throw new RuntimeException("未输入退款币种"); } if(cashRecordDone.getRefundAmount()== null){ throw new RuntimeException("未输入退款金额"); } int result = cashRefundMapper.executor(cashRecordDone); return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode(); }
@Override public int updateStatus(CashRecordDone cashRecordDone) { return cashRefundMapper.updateStatus(cashRecordDone); }
@Override public int finalreview(CashRecordDone cashRecordDone, @RequestHeader(defaultValue = "zh_CN") String lang) { if(cashRecordDone.getPermanentGold()== null){ cashRecordDone.setPermanentGold(0); } if(cashRecordDone.getFreeGold()== null){ cashRecordDone.setFreeGold(0); } if(cashRecordDone.getStatus()== 32){ CashRecordDone cashRecordDone1 = new CashRecordDone(); cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2)); cashRecordDone1.setStatus(4); if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null){ cashRefundMapper.updateStatus(cashRecordDone1); }} if (cashRecordDone.getGoodsName() != null &&cashRecordDone.getStatus() ==40 && (cashRecordDone.getGoodsName().equals("金币充值") || cashRecordDone.getGoodsName().contains("金币充值"))) { UserGoldRecord userGoldRecord = new UserGoldRecord(); userGoldRecord.setOrderCode(cashRecordDone.getOrderCode()); userGoldRecord.setType((byte) 2); userGoldRecord.setIsRefund((byte) 1); userGoldRecord.setRefundType("金币退款"); userGoldRecord.setCrefundModel(cashRecordDone.getRefundModel()); userGoldRecord.setJwcode(cashRecordDone.getJwcode()); userGoldRecord.setSumGold(cashRecordDone.getPermanentGold()+cashRecordDone.getFreeGold()); userGoldRecord.setPermanentGold(cashRecordDone.getPermanentGold()); int currentMonth = LocalDate.now().getMonthValue(); if (currentMonth >= 1 && currentMonth <= 6) { // 1-6月:设置12月额度,6月保持默认值
userGoldRecord.setFreeJune(0); userGoldRecord.setFreeDecember(cashRecordDone.getFreeGold()); } else { // 7-12月:设置6月额度,12月保持默认值
userGoldRecord.setFreeJune(cashRecordDone.getFreeGold()); userGoldRecord.setFreeDecember(0); } userGoldRecord.setGoodsName(cashRecordDone.getGoodsName()); userGoldRecord.setPayPlatform("金币系统"); userGoldRecord.setRemark(cashRecordDone.getRemark()); userGoldRecord.setAdminId(cashRecordDone.getAdminId()); userGoldRecord.setAuditStatus(1); userGoldRecord.setTaskGold(0); userGoldRecord.setCreateTime(new Date()); userGoldRecord.setUpdateTime(new Date()); String auditName = auditMapper.getName(cashRecordDone.getAuditId()); refundMapper.add(userGoldRecord); User user = new User(); user.setJwcode(userGoldRecord.getJwcode()); user.setCurrentPermanentGold(BigDecimal.valueOf(-userGoldRecord.getPermanentGold())); //当前永久金币
user.setCurrentFreeJune(BigDecimal.valueOf(-userGoldRecord.getFreeJune())); //当前六月免费金币
user.setCurrentFreeDecember(BigDecimal.valueOf(-userGoldRecord.getFreeDecember())); //当前十二月免费金币
auditMapper.updateUserGold(user); GoldTistV2.addCoinNew(userGoldRecord.getJwcode().toString(), 58, //退款免费+永久金币-充值
(double) (userGoldRecord.getFreeDecember()+userGoldRecord.getFreeJune()+userGoldRecord.getPermanentGold() ) /100, SimpleIdGenerator.generateId(), userGoldRecord.getRemark(),(double) userGoldRecord.getPermanentGold() / 100, auditName, "退款金币充值");}
cashRefundMapper.updateAudit(cashRecordDone); int result = cashRefundMapper.review(cashRecordDone); CashRecordDTO cashRecordDTO = cashRefundMapper.selectById(cashRecordDone.getId()); if (result > 0) { // 发送审核消息
Messages message = new Messages(); message.setJwcode(cashRecordDTO.getJwcode()); message.setName(cashRecordDTO.getName()); message.setStatus(cashRecordDTO.getStatus()); message.setDesc(cashRecordDTO.getJwcode()+cashRecordDTO.getStatus()!=32?languageTranslationUtil.translate("用户的退款申请待审核,前往处理", lang):languageTranslationUtil.translate("用户的现金退款申请已被驳回,前往查看详情", lang)); message.setTitle(languageTranslationUtil.translate("现金退款--执行人退款提交", lang)); message.setType(1); message.setTypeId(cashRecordDTO.getId()); message.setMarket(cashRecordDTO.getMarket()); String marketName = marketMapper.getMarketNameById(String.valueOf(message.getMarket())); message.setMarketName(languageTranslationUtil.translate(marketName, "zh_CN"));
} return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode(); }
@Override public PageInfo<CashRecordDTO> financeSelect(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) { PageHelper.startPage(pageNum, pageSize); //必须要直接跟mapper
// System.out.println(goldDetail.getMarkets());
List<CashRecordDTO> list = cashRefundMapper.financeSelect(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<>(); Set<Integer> executorIds = new HashSet<>();
list.forEach(item -> { if (item.getRelatedId() != null) relatedIds.add(item.getRelatedId()); if (item.getMarket() != null) marketIds.add(item.getMarket()); if (item.getSubmitterId() != null) submitterIds.add(item.getSubmitterId()); if (item.getAuditId() != null) auditIds.add(item.getAuditId()); if (item.getExecutor() != null) executorIds.add(item.getExecutor()); });
// 批量查询
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())); Map<String, String> executorNameMap = auditMapper.getNamesByJwcodes(executorIds) .stream().collect(Collectors.toMap(Admin::getAccount, Admin::getAdminName));
// 处理数据
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()); String executorName = executorNameMap.get(String.valueOf(item.getExecutor()));
item.setMarketName(marketName != null ? marketName : ""); item.setSubmitter(submitter != null ? submitter : ""); item.setExecutorName(executorName != null ? executorName : "");
if (lhlAudit != null) { item.setAreaServise(lhlAudit.getAreaServise()); item.setAreaFinance(lhlAudit.getAreaFinance()); item.setAreaCharge(lhlAudit.getAreaCharge()); item.setHeadFinance(lhlAudit.getHeadFinance()); } });
return new PageInfo<>(list); }
@Override public PageInfo<CashRecordDTO> exSelect(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) { PageHelper.startPage(pageNum, pageSize); //必须要直接跟mapper
// System.out.println(goldDetail.getMarkets());
List<CashRecordDTO> list = cashRefundMapper.exSelect(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<>(); Set<Integer> executorIds = new HashSet<>();
list.forEach(item -> { if (item.getRelatedId() != null) relatedIds.add(item.getRelatedId()); if (item.getMarket() != null) marketIds.add(item.getMarket()); if (item.getSubmitterId() != null) submitterIds.add(item.getSubmitterId()); if (item.getAuditId() != null) auditIds.add(item.getAuditId()); if (item.getExecutor() != null) executorIds.add(item.getExecutor()); });
// 批量查询
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())); Map<String, String> executorNameMap = auditMapper.getNamesByJwcodes(executorIds) .stream().collect(Collectors.toMap(Admin::getAccount, Admin::getAdminName));
// 处理数据
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()); String executorName = executorNameMap.get(String.valueOf(item.getExecutor()));
item.setMarketName(marketName != null ? marketName : ""); item.setSubmitter(submitter != null ? submitter : ""); item.setExecutorName(executorName != null ? executorName : "");
if (lhlAudit != null) { item.setAreaServise(lhlAudit.getAreaServise()); item.setAreaFinance(lhlAudit.getAreaFinance()); item.setAreaCharge(lhlAudit.getAreaCharge()); item.setHeadFinance(lhlAudit.getHeadFinance()); } });
return new PageInfo<>(list); }
@Override public void addOnline(CashRecordRefund cashRecordRefund) { if(cashRecordRefund.getJwcode()==null){ throw new BusinessException("未输入精网号") ; } if(cashRecordRefund.getRefundModel()== null){ throw new BusinessException("请填充退款类型") ; } if(cashRecordRefund.getRefundReason()== null){ throw new BusinessException("请填写退款理由") ; } CashRecordDone cashRecordDonetwo = new CashRecordDone(); cashRecordDonetwo.setAreaServise(cashRecordRefund.getAreaServise()); cashRefundMapper.addAudit(cashRecordDonetwo); cashRecordRefund.setAuditId(cashRecordDonetwo.getId());
cashRecordRefund.setStatus(20); //生成订单号后半部分
String orderNumber = cashRecordRefund.getOrderCode(); //构建订单信息
cashRecordRefund.setOrderCode("TK" + orderNumber); //订单号
cashRecordRefund.setMarket(String.valueOf(Integer.valueOf(marketMapper.getMarketId(cashRecordRefund.getMarket())))); cashRefundMapper.insert(cashRecordRefund); CashRecordDone cashRecordDone1 = new CashRecordDone(); cashRecordDone1.setId(cashRecordRefund.getId()); cashRecordDone1.setStatus(6); if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null) cashRefundMapper.updateStatus(cashRecordDone1); else throw new SystemException("提交失败") ; }
@Override public PageInfo<FundsDTO> funds(Integer pageNum, Integer pageSize, FundsDTO fundsDTO) { // 1. 分页查询主数据
PageHelper.startPage(pageNum, pageSize); if(fundsDTO.getStatuses()==null||fundsDTO.getStatuses().isEmpty()){ List<Integer> list_a = Arrays.asList(4,6); fundsDTO.setStatuses(list_a); } List<FundsDTO> list = cashRefundMapper.selectfunds(fundsDTO);
// 2. 收集 status == 6 的记录 ID(注意:status 是 int)
List<Integer> needQueryIds = new ArrayList<>(); for (FundsDTO dto : list) { if (dto.getStatuses() != null && dto.getStatuses().contains(6)) { needQueryIds.add(dto.getId()); } }
// 3. 批量查询额外信息(关键:必须有返回对象的方法!)
if (!needQueryIds.isEmpty()) { // 👇 请替换为你的实际 Mapper 方法(返回 List<RefundDetailDTO>)
List<FundsDTO> detailList = cashRefundMapper.selectRefundCount(needQueryIds);
// 4. 构建 HashMap: id -> RefundDetailDTO
Map<Integer, FundsDTO> detailMap = new HashMap<>(); for (FundsDTO detail : detailList) { detailMap.put(detail.getRelatedId(), detail); // 假设 detail 有 getId()
}
// 5. 回填到账金额和到账币种
for (FundsDTO dto : list) { if (dto.getStatuses() != null && dto.getStatuses().contains(6)) { FundsDTO detail = detailMap.get(dto.getId()); if (detail != null) { // 将到账金额转为负数(正数 → 负数)
BigDecimal amount = detail.getRefundAmount(); if (amount != null) { dto.setRefundAmount(amount.negate()); // 👈 关键:取负数
} else { dto.setRefundAmount(null); // 或设为 BigDecimal.ZERO,根据业务需求
} // 币种保持不变
dto.setRefundCurrency(detail.getRefundCurrency()); } } } }
return new PageInfo<>(list); }
}
|