Browse Source

Merge remote-tracking branch 'origin/milestone-20251104-现金管理二期' into milestone-20251104-现金管理二期

sunjiabei/feature-20251021102635-银行接口
sunjiabei 1 week ago
parent
commit
36ecee65c8
  1. 96
      src/main/java/com/example/demo/RabbitMQ/CashCollectionAspect.java
  2. 73
      src/main/java/com/example/demo/RabbitMQ/CashCollectionConsumer.java
  3. 96
      src/main/java/com/example/demo/RabbitMQ/CashRefundAspect.java
  4. 72
      src/main/java/com/example/demo/RabbitMQ/CashRefundConsumer.java
  5. 233
      src/main/java/com/example/demo/config/RabbitMQConfig.java
  6. 18
      src/main/java/com/example/demo/config/interfac/Message.java
  7. 2
      src/main/java/com/example/demo/controller/cash/CashRefundController.java
  8. 67
      src/main/java/com/example/demo/controller/cash/MessageController.java
  9. 14
      src/main/java/com/example/demo/domain/DTO/IdRequest.java
  10. 28
      src/main/java/com/example/demo/domain/DTO/MessageDTO.java
  11. 9
      src/main/java/com/example/demo/domain/vo/cash/CashCollection.java
  12. 2
      src/main/java/com/example/demo/domain/vo/cash/CashRecordRefund.java
  13. 36
      src/main/java/com/example/demo/domain/vo/coin/Messages.java
  14. 2
      src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java
  15. 22
      src/main/java/com/example/demo/mapper/cash/MessageMapper.java
  16. 15
      src/main/java/com/example/demo/mapper/coin/OperationLogMapper.java
  17. 21
      src/main/java/com/example/demo/service/cash/MessageService.java
  18. 41
      src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java
  19. 115
      src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java
  20. 39
      src/main/java/com/example/demo/serviceImpl/cash/MessageServiceImpl.java
  21. 30
      src/main/resources/cashMapper/CashCollectionMapper.xml
  22. 37
      src/main/resources/cashMapper/CashRefundMapper.xml
  23. 23
      src/main/resources/cashMapper/MessageMapper.xml
  24. 17
      src/main/resources/mapper/MarketMapper.xml

96
src/main/java/com/example/demo/RabbitMQ/CashCollectionAspect.java

@ -0,0 +1,96 @@
package com.example.demo.RabbitMQ;
import com.example.demo.Util.SecurityUtils;
import com.example.demo.config.RabbitMQConfig;
import com.example.demo.config.interfac.Message;
import com.example.demo.domain.DTO.MessageDTO;
import com.example.demo.mapper.coin.OperationLogMapper;
import com.example.demo.mapper.coin.UserMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @program: GOLD
* @ClassName CashCollectionAspect
* @description:
* @author: huangqizhen
* @create: 202511-14 19:10
* @Version 1.0
**/
@Aspect
@Component
@Slf4j
public class CashCollectionAspect {
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private UserMapper userMapper;
@Autowired
private OperationLogMapper operationLogMapper;
@Around("@annotation(com.example.demo.config.interfac.Message)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
String methodName = signature.getName();
String className = signature.getDeclaringTypeName();
Object[] args = joinPoint.getArgs();
Message logAnnotation = signature.getMethod().getAnnotation(Message.class);
String action = logAnnotation.value();
// 使用 Spring Security 获取真实用户
String username = SecurityUtils.getCurrentUsername();
Integer userId = SecurityUtils.getCurrentUserId();
String name = userMapper.selectUserByJwcode(Integer.valueOf(username)).getName();
// 添加空值检查
if (userId == null) {
log.warn("无法获取当前用户ID,使用默认值 -1");
userId = -1; // 或者使用其他默认值
}
ObjectMapper mapper = new ObjectMapper();
String argsJson = "[]";
try {
argsJson = mapper.writeValueAsString(args);
} catch (Exception e) {
argsJson = "serialize failed";
}
Object result;
try {
result = joinPoint.proceed();
} catch (Exception e) {
log.error("方法执行异常: {}", e.getMessage());
throw e;
}
long duration = System.currentTimeMillis() - startTime;
// 构造日志消息 DTO
MessageDTO messageDTO = new MessageDTO();
messageDTO.setJwcode(Integer.valueOf(username));
messageDTO.setName(name);
messageDTO.setTitle(action);
messageDTO.setDesc(username+"有一条消息需要处理");
// operationLogMapper.insertMessage(messageDTO);
// 发送消息到 RabbitMQ不等待
try {
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", messageDTO);
log.info("📩 日志消息已发送到 RabbitMQ: {}", action);
} catch (Exception e) {
log.error("发送日志消息到 RabbitMQ 失败", e);
}
log.info("✅ AOP 拦截完成: {} 执行 [{}] 耗时 {}ms", username, action, duration);
return result;
}
}

73
src/main/java/com/example/demo/RabbitMQ/CashCollectionConsumer.java

@ -1,9 +1,15 @@
package com.example.demo.RabbitMQ;
import com.example.demo.config.RabbitMQConfig;
import com.example.demo.domain.DTO.MessageDTO;
import com.example.demo.domain.DTO.OperationLogDTO;
import com.example.demo.domain.entity.OperationLog;
import com.example.demo.domain.vo.cash.CashCollectionMessage;
import com.example.demo.domain.vo.coin.Messages;
import com.example.demo.mapper.coin.OperationLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@ -13,64 +19,17 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class CashCollectionConsumer {
@Autowired
private OperationLogMapper operationLogMapper;
/**
* 处理收款订单创建消息
* 当有新的收款订单创建时该方法会被调用
*
* @param message 收款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.COLLECTION_CREATED_QUEUE)
public void handleCollectionCreated(CashCollectionMessage message) {
log.info("收款订单创建通知: 订单号={}, 状态={}, 提交人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getSubmitterId(), message.getMessage());
}
/**
* 处理收款订单审核通过消息
* 当收款订单审核通过时该方法会被调用
*
* @param message 收款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.COLLECTION_AUDITED_QUEUE)
public void handleCollectionAudited(CashCollectionMessage message) {
log.info("收款订单审核通过通知: 订单号={}, 状态={}, 审核人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getAuditId(), message.getMessage());
}
/**
* 处理收款订单审核驳回消息
* 当收款订单被审核驳回时该方法会被调用
*
* @param message 收款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.COLLECTION_REJECTED_QUEUE)
public void handleCollectionRejected(CashCollectionMessage message) {
log.info("收款订单审核驳回通知: 订单号={}, 状态={}, 审核人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getAuditId(), message.getMessage());
}
/**
* 处理收款订单完成消息
* 当收款订单流程全部完成时该方法会被调用
*
* @param message 收款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.COLLECTION_COMPLETED_QUEUE)
public void handleCollectionCompleted(CashCollectionMessage message) {
log.info("收款订单完成通知: 订单号={}, 状态={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getMessage());
}
@RabbitListener(queues = RabbitMQConfig.CASH_COLLECTION_QUEUE)
public void consumeLog(Messages messages) {
try {
operationLogMapper.insertMessage(messages);
/**
* 处理收款订单撤回消息
* 当收款订单被撤回时该方法会被调用
*
* @param message 收款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.COLLECTION_CANCELLED_QUEUE)
public void handleCollectionCancelled(CashCollectionMessage message) {
log.info("收款订单撤回通知: 订单号={}, 状态={}, 提交人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getSubmitterId(), message.getMessage());
} catch (Exception e) {
log.error("持久化日志失败", e);
// 可以重试或记录到文件
}
}
}

96
src/main/java/com/example/demo/RabbitMQ/CashRefundAspect.java

@ -0,0 +1,96 @@
package com.example.demo.RabbitMQ;
import com.example.demo.Util.SecurityUtils;
import com.example.demo.config.RabbitMQConfig;
import com.example.demo.config.interfac.Message;
import com.example.demo.domain.DTO.MessageDTO;
import com.example.demo.mapper.coin.OperationLogMapper;
import com.example.demo.mapper.coin.UserMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @program: GOLD
* @ClassName CashRefundAspect
* @description:
* @author: huangqizhen
* @create: 202511-14 19:10
* @Version 1.0
**/
@Aspect
@Component
@Slf4j
public class CashRefundAspect {
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private UserMapper userMapper;
@Autowired
private OperationLogMapper operationLogMapper;
@Around("@annotation(com.example.demo.config.interfac.Message)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
String methodName = signature.getName();
String className = signature.getDeclaringTypeName();
Object[] args = joinPoint.getArgs();
Message logAnnotation = signature.getMethod().getAnnotation(Message.class);
String action = logAnnotation.value();
// 使用 Spring Security 获取真实用户
String username = SecurityUtils.getCurrentUsername();
Integer userId = SecurityUtils.getCurrentUserId();
String name = userMapper.selectUserByJwcode(Integer.valueOf(username)).getName();
// 添加空值检查
if (userId == null) {
log.warn("无法获取当前用户ID,使用默认值 -1");
userId = -1; // 或者使用其他默认值
}
ObjectMapper mapper = new ObjectMapper();
String argsJson = "[]";
try {
argsJson = mapper.writeValueAsString(args);
} catch (Exception e) {
argsJson = "serialize failed";
}
Object result;
try {
result = joinPoint.proceed();
} catch (Exception e) {
log.error("方法执行异常: {}", e.getMessage());
throw e;
}
long duration = System.currentTimeMillis() - startTime;
// 构造日志消息 DTO
MessageDTO messageDTO = new MessageDTO();
messageDTO.setJwcode(Integer.valueOf(username));
messageDTO.setName(name);
messageDTO.setTitle(action);
messageDTO.setDesc(username+"有一条消息需要处理");
// operationLogMapper.insertMessage(messageDTO);
// 发送消息到 RabbitMQ不等待
try {
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", messageDTO);
log.info("📩 日志消息已发送到 RabbitMQ: {}", action);
} catch (Exception e) {
log.error("发送日志消息到 RabbitMQ 失败", e);
}
log.info("✅ AOP 拦截完成: {} 执行 [{}] 耗时 {}ms", username, action, duration);
return result;
}
}

72
src/main/java/com/example/demo/RabbitMQ/CashRefundConsumer.java

@ -1,9 +1,14 @@
package com.example.demo.RabbitMQ;
import com.example.demo.config.RabbitMQConfig;
import com.example.demo.domain.DTO.OperationLogDTO;
import com.example.demo.domain.entity.OperationLog;
import com.example.demo.domain.vo.cash.CashRefundMessage;
import com.example.demo.domain.vo.coin.Messages;
import com.example.demo.mapper.coin.OperationLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@ -13,64 +18,17 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public class CashRefundConsumer {
@Autowired
private OperationLogMapper operationLogMapper;
/**
* 处理退款订单创建消息
* 当有新的退款订单创建时该方法会被调用
*
* @param message 退款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.REFUND_CREATED_QUEUE)
public void handleRefundCreated(CashRefundMessage message) {
log.info("退款订单创建通知: 订单号={}, 状态={}, 提交人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getSubmitterId(), message.getMessage());
}
/**
* 处理退款订单审核通过消息
* 当退款订单审核通过时该方法会被调用
*
* @param message 退款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.REFUND_REVIEWED_QUEUE)
public void handleRefundReviewed(CashRefundMessage message) {
log.info("退款订单审核通过通知: 订单号={}, 状态={}, 审核人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getAuditId(), message.getMessage());
}
/**
* 处理退款订单审核驳回消息
* 当退款订单被审核驳回时该方法会被调用
*
* @param message 退款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.REFUND_REJECTED_QUEUE)
public void handleRefundRejected(CashRefundMessage message) {
log.info("退款订单审核驳回通知: 订单号={}, 状态={}, 审核人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getAuditId(), message.getMessage());
}
/**
* 处理退款订单执行消息
* 当退款订单被执行时该方法会被调用
*
* @param message 退款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.REFUND_EXECUTED_QUEUE)
public void handleRefundExecuted(CashRefundMessage message) {
log.info("退款订单执行通知: 订单号={}, 状态={}, 执行人={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getExecutorId(), message.getMessage());
}
@RabbitListener(queues = RabbitMQConfig.CASH_REFUND_QUEUE)
public void consumeLog(Messages messages) {
try {
operationLogMapper.insertMessage(messages);
/**
* 处理退款订单完成消息
* 当退款订单流程全部完成时该方法会被调用
*
* @param message 退款订单消息对象
*/
@RabbitListener(queues = RabbitMQConfig.REFUND_COMPLETED_QUEUE)
public void handleRefundCompleted(CashRefundMessage message) {
log.info("退款订单完成通知: 订单号={}, 状态={}, 消息={}",
message.getOrderCode(), message.getStatus(), message.getMessage());
} catch (Exception e) {
log.error("持久化日志失败", e);
// 可以重试或记录到文件
}
}
}

233
src/main/java/com/example/demo/config/RabbitMQConfig.java

@ -11,32 +11,16 @@ import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* RabbitMQ配置类
* 配置消息队列交换机以及它们之间的绑定关系
*/
@Configuration
public class RabbitMQConfig {
public static final String LOG_QUEUE = "operation_log_queue";
public static final String LOG_EXCHANGE = "operation_log_exchange";
// 收款流程相关队列和交换机常量定义
public static final String CASH_COLLECTION_QUEUE = "cash_collection_queue";
public static final String CASH_COLLECTION_EXCHANGE = "cash_collection_exchange";
public static final String COLLECTION_CREATED_QUEUE = "collection_created_queue";
public static final String COLLECTION_AUDITED_QUEUE = "collection_audited_queue";
public static final String COLLECTION_COMPLETED_QUEUE = "collection_completed_queue";
public static final String COLLECTION_CANCELLED_QUEUE = "collection_cancelled_queue";
public static final String COLLECTION_REJECTED_QUEUE = "collection_rejected_queue";
// 退款流程相关队列和交换机常量定义
public static final String CASH_REFUND_QUEUE = "cash_collection_exchange";
public static final String CASH_REFUND_EXCHANGE = "cash_refund_exchange";
public static final String REFUND_CREATED_QUEUE = "refund_created_queue";
public static final String REFUND_REVIEWED_QUEUE = "refund_reviewed_queue";
public static final String REFUND_EXECUTED_QUEUE = "refund_executed_queue";
public static final String REFUND_COMPLETED_QUEUE = "refund_completed_queue";
public static final String REFUND_REJECTED_QUEUE = "refund_rejected_queue";
@Bean
public Queue logQueue() {
return new Queue(LOG_QUEUE, true);
@ -54,223 +38,42 @@ public class RabbitMQConfig {
.with("log.*");
}
/**
* 创建收款流程交换机
* @return TopicExchange对象
*/
@Bean
public TopicExchange cashCollectionExchange() {
return new TopicExchange(CASH_COLLECTION_EXCHANGE);
}
/**
* 创建收款创建队列
* @return Queue对象
*/
// 现金收款队列和绑定按照操作日志的标准
@Bean
public Queue collectionCreatedQueue() {
return new Queue(COLLECTION_CREATED_QUEUE, true);
public Queue cashCollectionQueue() {
return new Queue(CASH_COLLECTION_QUEUE, true);
}
/**
* 创建收款审核队列
* @return Queue对象
*/
@Bean
public Queue collectionAuditedQueue() {
return new Queue(COLLECTION_AUDITED_QUEUE, true);
}
/**
* 创建收款完成队列
* @return Queue对象
*/
@Bean
public Queue collectionCompletedQueue() {
return new Queue(COLLECTION_COMPLETED_QUEUE, true);
public TopicExchange cashCollectionExchange() {
return new TopicExchange(CASH_COLLECTION_EXCHANGE);
}
/**
* 创建收款取消队列
* @return Queue对象
*/
@Bean
public Queue collectionCancelledQueue() {
return new Queue(COLLECTION_CANCELLED_QUEUE, true);
public Binding cashCollectionBinding() {
return BindingBuilder.bind(cashCollectionQueue())
.to(cashCollectionExchange())
.with("cash.collection.*");
}
/**
* 创建收款拒绝队列
* @return Queue对象
*/
// 现金退款队列和绑定按照操作日志的标准
@Bean
public Queue collectionRejectedQueue() {
return new Queue(COLLECTION_REJECTED_QUEUE, true);
public Queue cashRefundQueue() {
return new Queue(CASH_REFUND_QUEUE, true);
}
/**
* 创建退款流程交换机
* @return TopicExchange对象
*/
@Bean
public TopicExchange cashRefundExchange() {
return new TopicExchange(CASH_REFUND_EXCHANGE);
}
/**
* 创建退款创建队列
* @return Queue对象
*/
@Bean
public Queue refundCreatedQueue() {
return new Queue(REFUND_CREATED_QUEUE, true);
}
/**
* 创建退款审核队列
* @return Queue对象
*/
@Bean
public Queue refundReviewedQueue() {
return new Queue(REFUND_REVIEWED_QUEUE, true);
}
/**
* 创建退款执行队列
* @return Queue对象
*/
@Bean
public Queue refundExecutedQueue() {
return new Queue(REFUND_EXECUTED_QUEUE, true);
}
/**
* 创建退款完成队列
* @return Queue对象
*/
@Bean
public Queue refundCompletedQueue() {
return new Queue(REFUND_COMPLETED_QUEUE, true);
}
/**
* 创建退款拒绝队列
* @return Queue对象
*/
@Bean
public Queue refundRejectedQueue() {
return new Queue(REFUND_REJECTED_QUEUE, true);
}
/**
* 绑定收款创建队列到收款交换机
* @return Binding对象
*/
@Bean
public Binding collectionCreatedBinding() {
return BindingBuilder.bind(collectionCreatedQueue())
.to(cashCollectionExchange())
.with("collection.created");
}
/**
* 绑定收款审核队列到收款交换机
* @return Binding对象
*/
@Bean
public Binding collectionAuditedBinding() {
return BindingBuilder.bind(collectionAuditedQueue())
.to(cashCollectionExchange())
.with("collection.audited");
}
/**
* 绑定收款完成队列到收款交换机
* @return Binding对象
*/
@Bean
public Binding collectionCompletedBinding() {
return BindingBuilder.bind(collectionCompletedQueue())
.to(cashCollectionExchange())
.with("collection.completed");
}
/**
* 绑定收款取消队列到收款交换机
* @return Binding对象
*/
@Bean
public Binding collectionCancelledBinding() {
return BindingBuilder.bind(collectionCancelledQueue())
.to(cashCollectionExchange())
.with("collection.cancelled");
}
/**
* 绑定收款拒绝队列到收款交换机
* @return Binding对象
*/
@Bean
public Binding collectionRejectedBinding() {
return BindingBuilder.bind(collectionRejectedQueue())
.to(cashCollectionExchange())
.with("collection.rejected");
}
/**
* 绑定退款创建队列到退款交换机
* @return Binding对象
*/
@Bean
public Binding refundCreatedBinding() {
return BindingBuilder.bind(refundCreatedQueue())
.to(cashRefundExchange())
.with("refund.created");
}
/**
* 绑定退款审核队列到退款交换机
* @return Binding对象
*/
@Bean
public Binding refundReviewedBinding() {
return BindingBuilder.bind(refundReviewedQueue())
.to(cashRefundExchange())
.with("refund.reviewed");
}
/**
* 绑定退款执行队列到退款交换机
* @return Binding对象
*/
@Bean
public Binding refundExecutedBinding() {
return BindingBuilder.bind(refundExecutedQueue())
.to(cashRefundExchange())
.with("refund.executed");
}
/**
* 绑定退款完成队列到退款交换机
* @return Binding对象
*/
@Bean
public Binding refundCompletedBinding() {
return BindingBuilder.bind(refundCompletedQueue())
public Binding cashRefundBinding() {
return BindingBuilder.bind(cashRefundQueue())
.to(cashRefundExchange())
.with("refund.completed");
.with("cash.refund.*");
}
/**
* 绑定退款拒绝队列到退款交换机
* @return Binding对象
*/
@Bean
public Binding refundRejectedBinding() {
return BindingBuilder.bind(refundRejectedQueue())
.to(cashRefundExchange())
.with("refund.rejected");
}
@Bean
public MessageConverter messageConverter() {

18
src/main/java/com/example/demo/config/interfac/Message.java

@ -0,0 +1,18 @@
package com.example.demo.config.interfac;
import java.lang.annotation.*;
/**
* @program: GOLD
* @ClassName Message
* @description:
* @author: huangqizhen
* @create: 202511-14 19:12
* @Version 1.0
**/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Message {
String value() default "";
}

2
src/main/java/com/example/demo/controller/cash/CashRefundController.java

@ -98,6 +98,7 @@ public class CashRefundController {
*/
@PostMapping("/add")
public Result add(@RequestBody CashRecordRefund cashRecordRefund) throws Exception {
cashRecordRefund.setStatus(10);
try {
return Result.success(refundService.add(cashRecordRefund));
} catch (Exception e) {
@ -213,6 +214,7 @@ public class CashRefundController {
*/
@PostMapping("/addOnline")
public Result addOnline(@RequestBody CashRecordRefund cashRecordRefund){
cashRecordRefund.setStatus(20);
try {
return Result.success(refundService.add(cashRecordRefund));
} catch (Exception e) {

67
src/main/java/com/example/demo/controller/cash/MessageController.java

@ -0,0 +1,67 @@
package com.example.demo.controller.cash;
import com.example.demo.Util.JWTUtil;
import com.example.demo.domain.DTO.IdRequest;
import com.example.demo.domain.entity.Admin;
import com.example.demo.domain.vo.coin.Result;
import com.example.demo.service.cash.MessageService;
import com.example.demo.service.coin.MarketService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.Arrays;
import java.util.List;
/**
* @program: GOLD
* @ClassName MessageController
* @description:
* @author: huangqizhen
* @create: 202511-14 22:12
* @Version 1.0
**/
@RestController
@RequestMapping("/getMessage")
@RequiredArgsConstructor
@Slf4j
@CrossOrigin
public class MessageController {
@Autowired
private MessageService messageService;
@Autowired
private MarketService marketService;
@PostMapping
public Result getMessage() throws Exception {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request.getHeader("token");
// 解析 token 获取用户信息
Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class);
List<String> userMarkets = Arrays.asList(StringUtils.split(admin.getMarkets(), ","));
List<String> markets = marketService.getMarketIds(userMarkets);
// 权限校验逻辑
if (markets.contains("9") || markets.contains("9999")) {
markets=null;
}
return Result.success(messageService.getMessage(markets));
}
@PostMapping("/update")
public Result update(@RequestBody IdRequest idRequest) throws Exception {
try {
Integer id = idRequest.getId();
messageService.update(id);
return Result.success();
}
catch (Exception e) {
return Result.error("更新失败");
}
}
}

14
src/main/java/com/example/demo/domain/DTO/IdRequest.java

@ -0,0 +1,14 @@
package com.example.demo.domain.DTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
// 1. 定义一个极简 DTO可复用
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IdRequest {
private Integer id;
}

28
src/main/java/com/example/demo/domain/DTO/MessageDTO.java

@ -0,0 +1,28 @@
package com.example.demo.domain.DTO;
import com.stripe.model.tax.Registration;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @program: GOLD
* @ClassName MessageDTO
* @description:
* @author: huangqizhen
* @create: 202511-14 19:15
* @Version 1.0
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageDTO {
private Integer id;
private Integer jwcode;
private String name;
private String title;
private String desc;
private Integer status;
private Integer type;
private Integer typeId;
}

9
src/main/java/com/example/demo/domain/vo/cash/CashCollection.java

@ -25,7 +25,7 @@ import java.util.List;
@AllArgsConstructor
public class CashCollection implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty("序号")
private Integer id;
//订单信息
private Integer orderType; // 订单类型1-收款2-退款
@ -37,7 +37,7 @@ public class CashCollection implements Serializable {
private String market; // 所属地区
@ExcelProperty("所属地区")
private String marketName; // 所属地区名称
@ExcelProperty("活动")
@ExcelProperty("活动名称")
private String activity; // 活动
@ExcelProperty("金币订单号")
private String orderCode; // 金币订单号
@ -47,6 +47,7 @@ public class CashCollection implements Serializable {
private String goodsName; // 商品名称
@ExcelProperty("商品数量")
private Integer goodNum; // 商品数量
@ExcelProperty("数量单位")
private String numUnit; //数量单位 //
@ExcelProperty("永久金币数量")
private Integer permanentGold; // 永久金币数量
@ -79,13 +80,13 @@ public class CashCollection implements Serializable {
private Integer status; // 订单状态
@ExcelIgnore
private Integer submitterId; // 提交人 id
@ExcelProperty("提交人地区")
@ExcelIgnore
private String submitterMarket; //提交人地区
@ExcelProperty("提交人姓名")
private String submitterName; // 提交人 姓名
@ExcelProperty("转账凭证")
private String voucher; // 转账凭证
@ExcelProperty("备注")
@ExcelIgnore
private String remark; // 备注
@ExcelIgnore
private String receivedRemark; //到账备注

2
src/main/java/com/example/demo/domain/vo/cash/CashRecordRefund.java

@ -23,6 +23,8 @@ public class CashRecordRefund {
*/
private Integer id;
private Integer originalOrderId;
/**
* 精网号
*/

36
src/main/java/com/example/demo/domain/vo/coin/Messages.java

@ -0,0 +1,36 @@
package com.example.demo.domain.vo.coin;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.stripe.model.tax.Registration;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @program: GOLD
* @ClassName Messages
* @description:
* @author: huangqizhen
* @create: 202511-14 18:01
* @Version 1.0
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Messages {
private Integer id;//id
private Integer jwcode;//精网号
private String name;// 姓名
private String title;//标题
private String desc;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private Date czTime; // 创建时间
private Integer status;//状态
private Integer type;
private Integer typeId;
private Integer market;
}

2
src/main/java/com/example/demo/mapper/cash/CashRefundMapper.java

@ -36,4 +36,6 @@ public interface CashRefundMapper {
List<CashRecordDTO> exSelect(CashRecordDTO cashRecordDTO);
List<LhlAudit> getAuditBatch(Set<Integer> auditIds);
//根据id查订单信息
CashRecordDTO selectById(Integer id);
}

22
src/main/java/com/example/demo/mapper/cash/MessageMapper.java

@ -0,0 +1,22 @@
package com.example.demo.mapper.cash;
import com.example.demo.domain.vo.coin.Messages;
import com.example.demo.service.cash.MessageService;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @program: GOLD
* @ClassName MessageMapper
* @description:
* @author: huangqizhen
* @create: 202511-14 22:24
* @Version 1.0
**/
@Mapper
public interface MessageMapper {
List<Messages> getMessage(List<String> markets);
void update(Integer id);
}

15
src/main/java/com/example/demo/mapper/coin/OperationLogMapper.java

@ -1,8 +1,8 @@
package com.example.demo.mapper.coin;// com.example.demo.mapper.OperationLogMapper.java
import com.example.demo.domain.DTO.MessageDTO;
import com.example.demo.domain.entity.OperationLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.example.demo.domain.vo.coin.Messages;
import org.apache.ibatis.annotations.*;
@Mapper
public interface OperationLogMapper {
@ -10,4 +10,13 @@ public interface OperationLogMapper {
@Insert("INSERT INTO operation_log (user_id, username, action, ip, method, args, create_time) " +
"VALUES (#{userId}, #{username}, #{action}, #{ip}, #{method}, #{args}, NOW())")
void insertLog(OperationLog log);
@Insert("INSERT INTO message (jwcode, name, title, `desc`, status,type,type_id,market) "+" VALUES (#{jwcode}, #{name}, #{title}, #{desc},#{status},#{type},#{typeId},#{market})")
void insertMessage(Messages message);
@Options(
useGeneratedKeys = true, // 告诉 MyBatis 使用数据库生成的主键
keyProperty = "id", // 将生成的主键值 set messageDTO.id 字段
keyColumn = "id" // 可选指定数据库列名默认就是 id一般可省略
)
@Select("SELECT * FROM message WHERE id = #{id}")
Messages selectMessageById(@Param("id") Integer id);
}

21
src/main/java/com/example/demo/service/cash/MessageService.java

@ -0,0 +1,21 @@
package com.example.demo.service.cash;
import com.example.demo.domain.vo.coin.Messages;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @program: GOLD
* @ClassName MessageService
* @description:
* @author: huangqizhen
* @create: 202511-14 22:13
* @Version 1.0
**/
@Service
public interface MessageService {
List<Messages> getMessage(List<String> markets);
void update(Integer id) throws Exception;
}

41
src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java

@ -6,6 +6,7 @@ import com.example.demo.domain.entity.*;
import com.example.demo.domain.vo.cash.CashCollection;
import com.example.demo.domain.vo.cash.CashCollectionMessage;
import com.example.demo.domain.vo.coin.GoldUser;
import com.example.demo.domain.vo.coin.Messages;
import com.example.demo.domain.vo.coin.Result;
import com.example.demo.mapper.cash.CashCollectionMapper;
import com.example.demo.mapper.coin.MarketMapper;
@ -127,21 +128,16 @@ public class CashCollectionServiceImpl implements CashCollectionService {
//插入新收款订单
cashCollectionMapper.add(cashRecord);
// 发送收款创建消息
CashCollectionMessage message = new CashCollectionMessage();
message.setId(cashRecord.getId());
message.setOrderCode(cashRecord.getOrderCode());
Messages message = new Messages();
message.setJwcode(cashRecord.getJwcode());
message.setName(cashRecord.getName());
message.setStatus(cashRecord.getStatus());
message.setStatusDescription("线下财务待审核");
message.setMessage("收款订单已创建");
message.setSubmitterId(cashRecord.getSubmitterId());
// 可以通过 submitterId 查询提交人姓名
message.setTimestamp(LocalDateTime.now());
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_COLLECTION_EXCHANGE,
"collection.created",
message
);
message.setDesc(cashRecord.getJwcode()+"用户有条退款订单需审核");
message.setTitle("现金退款--新增退款");
message.setType(1);
message.setTypeId(cashRecord.getId());
message.setMarket(Integer.valueOf(cashRecord.getMarket()));
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_COLLECTION_EXCHANGE, "cash.collection.save", message);
return "添加成功";
}
@ -157,24 +153,7 @@ public class CashCollectionServiceImpl implements CashCollectionService {
}
//修改订单状态
int rows = cashCollectionMapper.updateStatus(orderCode, 5);
if (rows > 0) {
// 发送收款撤回消息
CashCollectionMessage message = new CashCollectionMessage();
message.setId(cashRecord.getId());
message.setOrderCode(cashRecord.getOrderCode());
message.setStatus(5);
message.setStatusDescription("手动撤回待编辑提交");
message.setMessage("收款订单已撤回");
message.setSubmitterId(cashRecord.getSubmitterId());
message.setAuditId(cashRecord.getAuditId());
message.setTimestamp(LocalDateTime.now());
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_COLLECTION_EXCHANGE,
"collection.cancelled",
message
);
}
return rows > 0 ? "撤回成功" : "撤回失败";
}

115
src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java

@ -8,10 +8,12 @@ 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.coin.Messages;
import com.example.demo.domain.vo.coin.Result;
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;
@ -20,6 +22,7 @@ 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.time.LocalDate;
@ -39,7 +42,7 @@ import static org.apache.commons.lang3.StringUtils.substring;
* @Version 1.0
**/
@Service
@Transactional
public class CashRefundServiceImpl implements RefundService {
@Autowired
@ -52,6 +55,8 @@ public class CashRefundServiceImpl implements RefundService {
private MarketMapper marketMapper;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private OperationLogMapper operationLogMapper;
@Override
public PageInfo<CashRecordDTO> select(Integer pageNum, Integer pageSize, CashRecordDTO cashRecordDTO) {
@ -78,7 +83,7 @@ public class CashRefundServiceImpl implements RefundService {
cashRefundMapper.addAudit(cashRecordDonetwo);
cashRecordRefund.setAuditId(cashRecordDonetwo.getId());
cashRecordRefund.setStatus(10);
// cashRecordRefund.setStatus(10);
//生成订单号后半部分
String orderNumber = cashRecordRefund.getOrderCode();
//构建订单信息
@ -93,20 +98,16 @@ public class CashRefundServiceImpl implements RefundService {
else return Result.error("提交失败").getCode();
// 发送退款创建消息
CashRefundMessage message = new CashRefundMessage();
message.setId(cashRecordRefund.getId());
message.setOrderCode(cashRecordRefund.getOrderCode());
message.setStatus(10);
message.setStatusDescription("地区财务待审核");
message.setMessage("退款订单已创建");
message.setSubmitterId(cashRecordRefund.getSubmitterId());
message.setTimestamp(LocalDateTime.now());
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_REFUND_EXCHANGE,
"refund.created",
message
);
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();
}
@ -155,32 +156,21 @@ public class CashRefundServiceImpl implements RefundService {
}
cashRefundMapper.updateAudit(cashRecordDone);
int result = cashRefundMapper.review(cashRecordDone);
CashRecordDTO cashRecordDTO = cashRefundMapper.selectById(cashRecordDone.getId());
if (result > 0) {
// 发送审核消息
CashRefundMessage message = new CashRefundMessage();
message.setId(cashRecordDone.getId());
message.setOrderCode(cashRecordDone.getOrderCode());
message.setStatus(cashRecordDone.getStatus());
message.setStatusDescription(getStatusDescription(cashRecordDone.getStatus()));
message.setMessage("退款订单已审核");
message.setSubmitterId(cashRecordDone.getSubmitterId());
message.setAuditId(cashRecordDone.getAuditId());
// 可以通过 auditId 查询审核人姓名
message.setTimestamp(LocalDateTime.now());
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 (cashRecordDone.getStatus() == 12 || cashRecordDone.getStatus() == 22) {
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_REFUND_EXCHANGE,
"refund.rejected",
message
);
} else {
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_REFUND_EXCHANGE,
"refund.reviewed",
message
);
if (cashRecordDTO.getStatus() != 12 || cashRecordDTO.getStatus() != 22) {
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message);
}
}
@ -209,25 +199,7 @@ public class CashRefundServiceImpl implements RefundService {
throw new RuntimeException("未输入退款金额");
}
int result = cashRefundMapper.executor(cashRecordDone);
if (result > 0) {
// 发送执行消息
CashRefundMessage message = new CashRefundMessage();
message.setId(cashRecordDone.getId());
message.setOrderCode(cashRecordDone.getOrderCode());
message.setStatus(cashRecordDone.getStatus());
message.setStatusDescription(getStatusDescription(cashRecordDone.getStatus()));
message.setMessage("退款订单已执行");
message.setSubmitterId(cashRecordDone.getSubmitterId());
message.setExecutorId(cashRecordDone.getExecutor());
// 可以通过 executorId 查询执行人姓名
message.setTimestamp(LocalDateTime.now());
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_REFUND_EXCHANGE,
"refund.executed",
message
);
}
return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
}
@ -299,23 +271,22 @@ public class CashRefundServiceImpl implements RefundService {
cashRefundMapper.updateAudit(cashRecordDone);
int result = cashRefundMapper.review(cashRecordDone);
CashRecordDTO cashRecordDTO = cashRefundMapper.selectById(cashRecordDone.getId());
if (result > 0) {
// 发送最终审核消息
CashRefundMessage message = new CashRefundMessage();
message.setId(cashRecordDone.getId());
message.setOrderCode(cashRecordDone.getOrderCode());
message.setStatus(cashRecordDone.getStatus());
message.setStatusDescription(getStatusDescription(cashRecordDone.getStatus()));
message.setMessage("退款订单已完成");
message.setSubmitterId(cashRecordDone.getSubmitterId());
message.setAuditId(cashRecordDone.getAuditId());
message.setTimestamp(LocalDateTime.now());
// 发送审核消息
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());
rabbitTemplate.convertAndSend(
RabbitMQConfig.CASH_REFUND_EXCHANGE,
"refund.completed",
message
);
if (cashRecordDTO.getStatus() != 32) {
rabbitTemplate.convertAndSend(RabbitMQConfig.CASH_REFUND_EXCHANGE, "cash.refund.save", message);
}
}
return (result > 0 ? Result.success("提交成功") : Result.error("提交失败")).getCode();
}

39
src/main/java/com/example/demo/serviceImpl/cash/MessageServiceImpl.java

@ -0,0 +1,39 @@
package com.example.demo.serviceImpl.cash;
import com.example.demo.domain.vo.coin.Messages;
import com.example.demo.service.cash.MessageService;
import com.example.demo.mapper.cash.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @program: GOLD
* @ClassName MessageServiceImpl
* @description:
* @author: huangqizhen
* @create: 202511-14 22:23
* @Version 1.0
**/
@Service
@Transactional
public class MessageServiceImpl implements MessageService {
@Autowired
private MessageMapper messageMapper;
@Override
public List<Messages> getMessage(List<String> markets) {
return messageMapper.getMessage(markets) ;
}
@Override
public void update(Integer id) throws Exception {
try {
messageMapper.update(id);
}
catch (Exception e){
throw new Exception("更新失败");
}
}
}

30
src/main/resources/cashMapper/CashCollectionMapper.xml

@ -255,23 +255,25 @@
where cr.id=#{id}
</select>
<select id="selectBatchIds" resultType="com.example.demo.domain.vo.cash.CashCollection">
select cr.id,cr.jwcode,cr.name,cr.market,
cr.order_code,cr.bank_code,cr.goods_name,cr.good_num,cr.num_unit,cr.permanent_gold,cr.free_gold,
cr.payment_currency,cr.payment_amount,cr.received_currency,cr.received_amount,cr.handling_charge,
cr.pay_type,cr.received_market,cr.pay_time,cr.received_time,cr.audit_id,cr.status,cr.submitter_id,
cr.submitter_market,cr.voucher,cr.remark,cr.audit_time,a1.admin_name as submitterName,
a2.admin_name as auditName,ra.activity_name as activity
select
cr.id, cr.jwcode, cr.name, cr.market,
cr.order_code, cr.bank_code, cr.goods_name, cr.good_num, cr.num_unit, cr.permanent_gold, cr.free_gold,
cr.payment_currency, cr.payment_amount, cr.received_currency, cr.received_amount, cr.handling_charge,
cr.pay_type, cr.received_market, cr.pay_time, cr.received_time, cr.audit_id, cr.status, cr.submitter_id,
cr.submitter_market, cr.voucher, cr.remark, cr.audit_time,
a1.admin_name as submitterName,
a2.admin_name as auditName,
ra.activity_name as activity
from cash_record_collection cr
left join admin a1 on cr.submitter_id = a1.id
left join admin a2 on cr.audit_id = a2.id
left join recharge_activity ra on ra.id = cr.activity
<where>
<if test="relatedIds != null and relatedIds.size() > 0">
cr.id IN
<foreach collection="relatedIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
where 1 = 0
<if test="relatedIds != null and relatedIds.size() > 0">
OR cr.id IN
<foreach collection="relatedIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
</mapper>

37
src/main/resources/cashMapper/CashRefundMapper.xml

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.cash.CashRefundMapper">
<insert id="insert">
<insert id="insert" useGeneratedKeys="true"
keyProperty="id"
keyColumn="id">
INSERT INTO cash_record_refund (
jwcode,
name,
@ -49,7 +51,7 @@
#{refundVoucher},
#{refundCurrency},
#{refundAmount},
#{id},
#{originalOrderId},
#{auditId},
#{status}
);
@ -144,6 +146,7 @@
crr.submitter_id,
crr.submitter_market,
crr.executor,
crr.order_code,
crr.refund_channels,
crr.refund_time,
crr.create_time,
@ -224,6 +227,7 @@
crr.name,
crr.market,
crc.goods_name,
crr.order_code,
crc.good_num as goodsNum,
crc.num_unit,
crr.refund_model,
@ -308,6 +312,7 @@
crr.name,
crr.market,
crc.goods_name,
crc.order_code,
crc.good_num as goodsNum,
crc.num_unit,
crr.refund_model,
@ -318,6 +323,7 @@
crr.refund_time,
crr.status,
crr.audit_id,
crr.submitter_id,
crr.related_id,
la.area_servise,
la.area_finance,
@ -379,15 +385,24 @@
</select>
<select id="getAuditBatch" resultType="com.example.demo.domain.vo.cash.LhlAudit">
select * from lhl_audit
<where>
<if test="auditIds != null and auditIds.size() > 0">
id in
<foreach collection="auditIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
SELECT *
FROM lhl_audit
WHERE 1 = 0
<if test="auditIds != null and auditIds.size() > 0">
OR id IN
<foreach collection="auditIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<select id="selectById" resultType="com.example.demo.domain.vo.cash.CashRecordDTO">
select crr.id,
crr.jwcode,
crr.name,
crr.status
from cash_record_refund crr
where crr.id = #{id}
</select>
</mapper>

23
src/main/resources/cashMapper/MessageMapper.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.demo.mapper.cash.MessageMapper">
<update id="update">
update message
set flag=1
where id=#{id}
</update>
<select id="getMessage" resultType="com.example.demo.domain.vo.coin.Messages">
SELECT id, jwcode, name, title, `desc`, status, market,type, type_id,flag
FROM message
<where>
<choose>
<when test="markets != null and markets.size() > 0">
market IN
<foreach item="item" collection="markets" open="(" separator="," close=")">
#{item}
</foreach>
</when>
</choose>
</where>
</select>
</mapper>

17
src/main/resources/mapper/MarketMapper.xml

@ -39,14 +39,13 @@
select name from market where id=#{market}
</select>
<select id="getMarketByIds" resultType="com.example.demo.domain.entity.Market">
select id,name from market
<where>
<if test="marketIds != null and marketIds.size() > 0">
id in
<foreach collection="marketIds" item="marketId" open="(" separator="," close=")">
#{marketId}
</foreach>
</if>
</where>
select id, name from market
where 1 = 0
<if test="marketIds != null and marketIds.size() > 0">
OR id IN
<foreach collection="marketIds" item="marketId" open="(" separator="," close=")">
#{marketId}
</foreach>
</if>
</select>
</mapper>
Loading…
Cancel
Save