You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
521 lines
24 KiB
521 lines
24 KiB
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.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 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;
|
|
|
|
@Override
|
|
public PageInfo<CashRecordDTO> select(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) {
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
List<CashRecordDTO> list = cashRefundMapper.select(cashRecordDTO);
|
|
|
|
if (list.isEmpty()) {
|
|
return new PageInfo<>(list);
|
|
}
|
|
System.out.println("135");
|
|
// 批量收集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(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.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());
|
|
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){
|
|
throw new Exception("未输入精网号") ;
|
|
}
|
|
if(cashRecordRefund.getRefundModel()== null){
|
|
throw new Exception("请填充退款类型") ;
|
|
}
|
|
if(cashRecordRefund.getRefundReason()== 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()+"用户有条退款订单需审核");
|
|
message.setTitle("现金退款--新增退款");
|
|
message.setType(1);
|
|
message.setTypeId(cashRecordRefund.getId());
|
|
message.setMarket(Integer.valueOf(cashRecordRefund.getMarket()));
|
|
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message);
|
|
|
|
return Result.success("提交成功").getCode();
|
|
|
|
}
|
|
|
|
@Override
|
|
public int update(CashRecordDone cashRecordDone) 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("请填写退款理由");
|
|
}
|
|
int result = cashRefundMapper.update(cashRecordDone);
|
|
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) throws Exception {
|
|
if(cashRecordDone.getStatus()== 12|| cashRecordDone.getStatus()== 22){
|
|
if(cashRecordDone.getOrderCode()== null){
|
|
throw new RuntimeException("未输入订单号");
|
|
}
|
|
CashRecordDone cashRecordDone1 = new CashRecordDone();
|
|
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()+"用户有条退款订单需审核");
|
|
message.setTitle("现金退款--当地退款审核");
|
|
message.setType(1);
|
|
message.setTypeId(cashRecordDTO.getId());
|
|
message.setMarket(cashRecordDTO.getMarket());
|
|
|
|
if (cashRecordDTO.getStatus() != 12 || cashRecordDTO.getStatus() != 22) {
|
|
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) {
|
|
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.getAuditId());
|
|
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,
|
|
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()+"用户有条退款订单需审核");
|
|
message.setTitle("现金退款--执行人退款提交");
|
|
message.setType(1);
|
|
message.setTypeId(cashRecordDTO.getId());
|
|
message.setMarket(cashRecordDTO.getMarket());
|
|
|
|
if (cashRecordDTO.getStatus() != 32) {
|
|
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message);
|
|
}
|
|
}
|
|
return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
|
|
}
|
|
|
|
@Override
|
|
public PageInfo<CashRecordDTO> financeSelect(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) {
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
// 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<>();
|
|
|
|
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());
|
|
});
|
|
|
|
// 批量查询
|
|
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.getHeadFinance());
|
|
}
|
|
});
|
|
|
|
return new PageInfo<>(list);
|
|
}
|
|
|
|
@Override
|
|
public PageInfo<CashRecordDTO> exSelect(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) {
|
|
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 -> {
|
|
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());
|
|
});
|
|
|
|
// 批量查询
|
|
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.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("提交失败") ;
|
|
}
|
|
}
|