|
|
|
@ -1,15 +1,16 @@ |
|
|
|
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.CashRecordDTO; |
|
|
|
import com.example.demo.domain.vo.cash.CashRecordDone; |
|
|
|
import com.example.demo.domain.vo.cash.CashRecordRefund; |
|
|
|
import com.example.demo.domain.vo.cash.CashRefundMessage; |
|
|
|
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; |
|
|
|
@ -18,31 +19,29 @@ 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 jakarta.servlet.http.HttpServletRequest; |
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
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; |
|
|
|
|
|
|
|
/** |
|
|
|
* @program: GOLD |
|
|
|
* @ClassName CashRefundServiceImpl |
|
|
|
* @description: 处理退款相关业务逻辑 |
|
|
|
* @description: |
|
|
|
* @author: huangqizhen |
|
|
|
* @create: 2025−09-28 15:02 |
|
|
|
* @Version 1.0 |
|
|
|
**/ |
|
|
|
@Service |
|
|
|
@Transactional |
|
|
|
|
|
|
|
public class CashRefundServiceImpl implements RefundService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -57,33 +56,136 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
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); |
|
|
|
// 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<>(); |
|
|
|
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) throws Exception { |
|
|
|
if (cashRecordRefund.getJwcode() == null) { |
|
|
|
throw new Exception("未输入精网号"); |
|
|
|
if(cashRecordRefund.getJwcode()==null){ |
|
|
|
throw new Exception("未输入精网号") ; |
|
|
|
} |
|
|
|
if(cashRecordRefund.getRefundModel()== null){ |
|
|
|
throw new Exception("请填充退款类型") ; |
|
|
|
} |
|
|
|
if (cashRecordRefund.getRefundModel() == null) { |
|
|
|
throw new Exception("请填充退款类型"); |
|
|
|
if(cashRecordRefund.getRefundReason()== 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); |
|
|
|
cashRecordRefund.setStatus(10); |
|
|
|
//生成订单号后半部分 |
|
|
|
String orderNumber = cashRecordRefund.getOrderCode(); |
|
|
|
//构建订单信息 |
|
|
|
@ -91,9 +193,9 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
cashRecordRefund.setMarket(String.valueOf(Integer.valueOf(marketMapper.getMarketId(cashRecordRefund.getMarket())))); |
|
|
|
cashRefundMapper.insert(cashRecordRefund); |
|
|
|
CashRecordDone cashRecordDone1 = new CashRecordDone(); |
|
|
|
cashRecordDone1.setId(cashRecordRefund.getId()); |
|
|
|
cashRecordDone1.setId(cashRecordRefund.getOriginalOrderId()); |
|
|
|
cashRecordDone1.setStatus(6); |
|
|
|
if (cashRecordDone1.getId() != null || cashRecordDone1.getOrderCode() != null) |
|
|
|
if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null) |
|
|
|
cashRefundMapper.updateStatus(cashRecordDone1); |
|
|
|
else return Result.error("提交失败").getCode(); |
|
|
|
|
|
|
|
@ -110,50 +212,48 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
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) { |
|
|
|
if (cashRecordDone.getJwcode()== null) { |
|
|
|
throw new RuntimeException("未输入精网号"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getPaymentAmount() == null) { |
|
|
|
if (cashRecordDone.getPaymentAmount()== null) { |
|
|
|
throw new RuntimeException("未输入付款金额"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getPaymentCurrency() == null) { |
|
|
|
if (cashRecordDone.getPaymentCurrency()== null){ |
|
|
|
throw new RuntimeException("未输入付款币种"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundModel() == null) { |
|
|
|
if (cashRecordDone.getRefundModel()== null) { |
|
|
|
throw new RuntimeException("请填写退款类型"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundReason() == null) { |
|
|
|
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) { |
|
|
|
if(cashRecordDone.getStatus()== 12|| cashRecordDone.getStatus()== 22){ |
|
|
|
if(cashRecordDone.getOrderCode()== null){ |
|
|
|
throw new RuntimeException("未输入订单号"); |
|
|
|
} |
|
|
|
CashRecordDone cashRecordDone1 = new CashRecordDone(); |
|
|
|
CashRecordDone cashRecordDone1 = new CashRecordDone(); |
|
|
|
cashRecordDone1.setId(cashRecordDone.getRelatedId()); |
|
|
|
cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2)); |
|
|
|
cashRecordDone1.setStatus(4); |
|
|
|
if (cashRecordDone1.getId() != null || cashRecordDone1.getOrderCode() != null) { |
|
|
|
if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null){ |
|
|
|
cashRefundMapper.updateStatus(cashRecordDone1); |
|
|
|
} |
|
|
|
} |
|
|
|
}} |
|
|
|
cashRefundMapper.updateAudit(cashRecordDone); |
|
|
|
int result = cashRefundMapper.review(cashRecordDone); |
|
|
|
CashRecordDTO cashRecordDTO = cashRefundMapper.selectById(cashRecordDone.getId()); |
|
|
|
@ -164,7 +264,7 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
message.setName(cashRecordDTO.getName()); |
|
|
|
message.setStatus(cashRecordDTO.getStatus()); |
|
|
|
message.setDesc(cashRecordDTO.getJwcode()+"用户有条退款订单需审核"); |
|
|
|
message.setTitle("现金退款--新增退款"); |
|
|
|
message.setTitle("现金退款--当地退款审核"); |
|
|
|
message.setType(1); |
|
|
|
message.setTypeId(cashRecordDTO.getId()); |
|
|
|
message.setMarket(cashRecordDTO.getMarket()); |
|
|
|
@ -177,56 +277,51 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode(); |
|
|
|
} |
|
|
|
|
|
|
|
// 执行退款操作 |
|
|
|
@Override |
|
|
|
public int executor(CashRecordDone cashRecordDone) throws Exception { |
|
|
|
if (cashRecordDone.getRefundVoucher() == null) { |
|
|
|
if(cashRecordDone.getRefundVoucher()== null){ |
|
|
|
throw new RuntimeException("未输入退款凭证"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundTime() == null) { |
|
|
|
if(cashRecordDone.getRefundTime()== null){ |
|
|
|
throw new RuntimeException("未输入退款时间"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundRemark() == null) { |
|
|
|
if(cashRecordDone.getRefundRemark()== null){ |
|
|
|
throw new RuntimeException("未输入退款备注"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundChannels() == null) { |
|
|
|
if(cashRecordDone.getRefundChannels()== null){ |
|
|
|
throw new RuntimeException("未输入退款途径"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundCurrency() == null) { |
|
|
|
if(cashRecordDone.getRefundCurrency()== null){ |
|
|
|
throw new RuntimeException("未输入退款币种"); |
|
|
|
} |
|
|
|
if (cashRecordDone.getRefundAmount() == null) { |
|
|
|
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) { |
|
|
|
if(cashRecordDone.getPermanentGold()== null){ |
|
|
|
cashRecordDone.setPermanentGold(0); |
|
|
|
} |
|
|
|
if (cashRecordDone.getFreeGold() == null) { |
|
|
|
if(cashRecordDone.getFreeGold()== null){ |
|
|
|
cashRecordDone.setFreeGold(0); |
|
|
|
} |
|
|
|
if (cashRecordDone.getStatus() == 32) { |
|
|
|
if(cashRecordDone.getStatus()== 32){ |
|
|
|
CashRecordDone cashRecordDone1 = new CashRecordDone(); |
|
|
|
cashRecordDone1.setOrderCode(cashRecordDone.getOrderCode().substring(2)); |
|
|
|
cashRecordDone1.setStatus(4); |
|
|
|
if (cashRecordDone1.getId() != null || cashRecordDone1.getOrderCode() != null) { |
|
|
|
if (cashRecordDone1.getId()!=null||cashRecordDone1.getOrderCode()!= null){ |
|
|
|
cashRefundMapper.updateStatus(cashRecordDone1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (cashRecordDone.getGoodsName() != null && cashRecordDone.getStatus() == 40 && |
|
|
|
}} |
|
|
|
if (cashRecordDone.getGoodsName() != null &&cashRecordDone.getStatus() ==40 && |
|
|
|
(cashRecordDone.getGoodsName().equals("金币充值") || |
|
|
|
cashRecordDone.getGoodsName().contains("金币充值"))) { |
|
|
|
UserGoldRecord userGoldRecord = new UserGoldRecord(); |
|
|
|
@ -236,7 +331,7 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
userGoldRecord.setRefundType("金币退款"); |
|
|
|
userGoldRecord.setCrefundModel(cashRecordDone.getRefundModel()); |
|
|
|
userGoldRecord.setJwcode(cashRecordDone.getJwcode()); |
|
|
|
userGoldRecord.setSumGold(cashRecordDone.getPermanentGold() + cashRecordDone.getFreeGold()); |
|
|
|
userGoldRecord.setSumGold(cashRecordDone.getPermanentGold()+cashRecordDone.getFreeGold()); |
|
|
|
userGoldRecord.setPermanentGold(cashRecordDone.getPermanentGold()); |
|
|
|
int currentMonth = LocalDate.now().getMonthValue(); |
|
|
|
if (currentMonth >= 1 && currentMonth <= 6) { |
|
|
|
@ -265,9 +360,8 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
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, "退款金币充值"); |
|
|
|
} |
|
|
|
(double) (userGoldRecord.getFreeDecember()+userGoldRecord.getFreeJune()+userGoldRecord.getPermanentGold() ) /100, |
|
|
|
userGoldRecord.getRemark(),(double) userGoldRecord.getPermanentGold() / 100, auditName, "退款金币充值");} |
|
|
|
|
|
|
|
cashRefundMapper.updateAudit(cashRecordDone); |
|
|
|
int result = cashRefundMapper.review(cashRecordDone); |
|
|
|
@ -279,7 +373,7 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
message.setName(cashRecordDTO.getName()); |
|
|
|
message.setStatus(cashRecordDTO.getStatus()); |
|
|
|
message.setDesc(cashRecordDTO.getJwcode()+"用户有条退款订单需审核"); |
|
|
|
message.setTitle("现金退款--新增退款"); |
|
|
|
message.setTitle("现金退款--执行人退款提交"); |
|
|
|
message.setType(1); |
|
|
|
message.setTypeId(cashRecordDTO.getId()); |
|
|
|
message.setMarket(cashRecordDTO.getMarket()); |
|
|
|
@ -291,51 +385,169 @@ public class CashRefundServiceImpl implements RefundService { |
|
|
|
return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode(); |
|
|
|
} |
|
|
|
|
|
|
|
// 辅助方法:根据状态码获取状态描述 |
|
|
|
private String getStatusDescription(Integer status) { |
|
|
|
switch (status) { |
|
|
|
case 10: |
|
|
|
return "地区财务待审核"; |
|
|
|
case 11: |
|
|
|
return "地区财务手动撤回待编辑提交"; |
|
|
|
case 12: |
|
|
|
return "地区财务驳回"; |
|
|
|
case 20: |
|
|
|
return "地区负责人待审核"; |
|
|
|
case 22: |
|
|
|
return "地区负责人驳回"; |
|
|
|
case 30: |
|
|
|
return "总部财务待审核"; |
|
|
|
case 32: |
|
|
|
return "总部财务驳回"; |
|
|
|
case 40: |
|
|
|
return "执行人待处理"; |
|
|
|
case 41: |
|
|
|
return "执行人已处理,退款结束"; |
|
|
|
default: |
|
|
|
return "未知状态"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 财务查询退款订单列表 |
|
|
|
@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<>(); |
|
|
|
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); |
|
|
|
// 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("提交失败") ; |
|
|
|
} |
|
|
|
} |