!30 fix(优惠券中心):用户查询优惠券逻辑优化,直接通过二维码id进行查询
Merge pull request !30 from Iamasoldier/feature_lsl
This commit is contained in:
+3
-3
@@ -57,14 +57,14 @@ public class OrderDetailController {
|
|||||||
private CtripOrderItemMapper ctripOrderItemMapper;
|
private CtripOrderItemMapper ctripOrderItemMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据手机号和优惠券价格查询可核销的订单明细
|
* 根据二维码ID查询可核销的订单明细
|
||||||
*
|
*
|
||||||
* @param queryDTO 查询条件
|
* @param queryDTO 查询条件(codeId、page、size)
|
||||||
* @return 订单明细分页结果
|
* @return 订单明细分页结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
public Result<PageResult<OrderDetailVO>> queryOrderDetails(@Valid @RequestBody OrderQueryDTO queryDTO) {
|
public Result<PageResult<OrderDetailVO>> queryOrderDetails(@Valid @RequestBody OrderQueryDTO queryDTO) {
|
||||||
log.info("查询可核销订单明细,手机号: {}, 优惠券价格: {}", queryDTO.getUserPhone(), queryDTO.getCouponPrice());
|
log.info("查询可核销订单明细,codeId: {},page: {},size: {}", queryDTO.getCodeId(), queryDTO.getPage(), queryDTO.getSize());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PageResult<OrderDetailVO> result = orderDetailService.queryOrderDetails(queryDTO);
|
PageResult<OrderDetailVO> result = orderDetailService.queryOrderDetails(queryDTO);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.central.coupon.dto;
|
package com.central.coupon.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.math.BigDecimal;
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单查询DTO
|
* 订单查询DTO
|
||||||
@@ -10,27 +11,25 @@ import java.math.BigDecimal;
|
|||||||
public class OrderQueryDTO {
|
public class OrderQueryDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户手机号
|
* 二维码ID(来自订单的codeId)
|
||||||
*/
|
*/
|
||||||
private String userPhone;
|
@NotNull(message = "二维码ID不能为空")
|
||||||
|
private String codeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠券价格(用于筛选匹配的订单)
|
* 是否只查询可核销的订单(内部控制,前端不必传,默认true)
|
||||||
*/
|
|
||||||
private BigDecimal couponPrice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否只查询可核销的订单
|
|
||||||
*/
|
*/
|
||||||
private Boolean onlyConsumable = true;
|
private Boolean onlyConsumable = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页码
|
* 页码
|
||||||
*/
|
*/
|
||||||
|
@Min(value = 1, message = "页码必须大于等于1")
|
||||||
private Integer page = 1;
|
private Integer page = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页大小
|
* 页大小
|
||||||
*/
|
*/
|
||||||
|
@Min(value = 1, message = "页大小必须大于等于1")
|
||||||
private Integer size = 10;
|
private Integer size = 10;
|
||||||
}
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package com.central.coupon.feign;
|
||||||
|
|
||||||
|
import com.central.common.constant.ServiceNameConstants;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.coupon.feign.dto.QrCodeInfo;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
@FeignClient(name = ServiceNameConstants.ORDER_SERVICE, dismiss404 = true)
|
||||||
|
public interface OrderCenterService {
|
||||||
|
@GetMapping("/qrcode/{codeId}")
|
||||||
|
Result<QrCodeInfo> getQrCode(@PathVariable("codeId") String codeId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.central.coupon.feign.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class QrCodeInfo {
|
||||||
|
private String codeId;
|
||||||
|
private String price;
|
||||||
|
}
|
||||||
+2
-2
@@ -11,9 +11,9 @@ import com.central.common.model.PageResult;
|
|||||||
public interface IOrderDetailService {
|
public interface IOrderDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据手机号和价格查询订单明细
|
* 根据二维码ID及分页参数查询订单明细
|
||||||
*
|
*
|
||||||
* @param queryDTO 查询条件
|
* @param queryDTO 查询条件(codeId、page、size)
|
||||||
* @return 订单明细分页结果
|
* @return 订单明细分页结果
|
||||||
*/
|
*/
|
||||||
PageResult<OrderDetailVO> queryOrderDetails(OrderQueryDTO queryDTO);
|
PageResult<OrderDetailVO> queryOrderDetails(OrderQueryDTO queryDTO);
|
||||||
|
|||||||
+69
-25
@@ -1,5 +1,7 @@
|
|||||||
package com.central.coupon.service.impl;
|
package com.central.coupon.service.impl;
|
||||||
|
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
|
import com.central.common.utils.LoginUserUtils;
|
||||||
import com.central.coupon.dto.OrderQueryDTO;
|
import com.central.coupon.dto.OrderQueryDTO;
|
||||||
import com.central.coupon.dto.ConsumeOrderDTO;
|
import com.central.coupon.dto.ConsumeOrderDTO;
|
||||||
import com.central.coupon.vo.OrderDetailVO;
|
import com.central.coupon.vo.OrderDetailVO;
|
||||||
@@ -32,6 +34,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import com.central.coupon.dto.ConsumeItemDTO;
|
import com.central.coupon.dto.ConsumeItemDTO;
|
||||||
|
import com.central.coupon.feign.OrderCenterService;
|
||||||
|
import com.central.coupon.feign.dto.QrCodeInfo;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.common.context.LoginUserContextHolder;
|
||||||
|
import com.central.common.model.LoginAppUser;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单明细服务实现类
|
* 订单明细服务实现类
|
||||||
@@ -58,15 +66,45 @@ public class OrderDetailServiceImpl implements IOrderDetailService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CtripConsumedService ctripConsumedService;
|
private CtripConsumedService ctripConsumedService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderCenterService orderCenterService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrderDetailVO> queryOrderDetails(OrderQueryDTO queryDTO) {
|
public PageResult<OrderDetailVO> queryOrderDetails(OrderQueryDTO queryDTO) {
|
||||||
log.info("查询可核销订单明细,手机号: {}, 优惠券价格: {}", queryDTO.getUserPhone(), queryDTO.getCouponPrice());
|
log.info("查询可核销订单明细,codeId: {},page: {},size: {}", queryDTO.getCodeId(), queryDTO.getPage(), queryDTO.getSize());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 0. 从登录上下文获取用户手机号
|
||||||
|
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||||
|
String userPhone = user != null ? user.getMobile() : null;
|
||||||
|
log.info("当前登录用户手机号: {}", userPhone);
|
||||||
|
|
||||||
|
// 0.1 通过codeId调用订单中心获取二维码信息,得到价格
|
||||||
|
BigDecimal couponPrice = null;
|
||||||
|
if (!StringUtils.isEmpty(queryDTO.getCodeId())) {
|
||||||
|
Result<QrCodeInfo> qrResp = orderCenterService.getQrCode(queryDTO.getCodeId());
|
||||||
|
if (qrResp != null && qrResp.getResp_code() != null && qrResp.getResp_code() == 0 && qrResp.getData() != null) {
|
||||||
|
QrCodeInfo qr = qrResp.getData();
|
||||||
|
if (qr.getPrice() != null) {
|
||||||
|
try {
|
||||||
|
// 二维码价格是分,需要转换为元
|
||||||
|
BigDecimal priceInCents = new BigDecimal(qr.getPrice());
|
||||||
|
couponPrice = priceInCents.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
log.info("二维码价格转换:{}分 = {}元", priceInCents, couponPrice);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("二维码价格解析失败, price={}, codeId={}", qr.getPrice(), queryDTO.getCodeId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("订单中心查询二维码失败,codeId={}, resp={}", queryDTO.getCodeId(), qrResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("根据二维码获得价格(元): {}", couponPrice);
|
||||||
|
|
||||||
// 1. 根据手机号查询订单
|
// 1. 根据手机号查询订单
|
||||||
List<CtripOrder> orders = findOrdersByPhone(queryDTO.getUserPhone());
|
List<CtripOrder> orders = findOrdersByPhone(userPhone);
|
||||||
if (orders == null || orders.isEmpty()) {
|
if (orders == null || orders.isEmpty()) {
|
||||||
log.info("未找到手机号 {} 的订单", queryDTO.getUserPhone());
|
log.info("未找到手机号 {} 的订单", userPhone);
|
||||||
return PageResult.<OrderDetailVO>builder()
|
return PageResult.<OrderDetailVO>builder()
|
||||||
.data(new ArrayList<>())
|
.data(new ArrayList<>())
|
||||||
.count(0L)
|
.count(0L)
|
||||||
@@ -74,13 +112,30 @@ public class OrderDetailServiceImpl implements IOrderDetailService {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 筛选符合条件的订单
|
// 2. 筛选符合条件的订单(使用从二维码获取的价格)
|
||||||
List<CtripOrder> filteredOrders = filterOrders(orders, queryDTO);
|
List<CtripOrder> filteredOrders = filterOrdersByPriceAndConsumable(orders, couponPrice, queryDTO.getOnlyConsumable());
|
||||||
|
|
||||||
// 3. 分页处理
|
// 3. 分页处理 - 添加参数验证和标准化
|
||||||
int startIndex = (queryDTO.getPage() - 1) * queryDTO.getSize();
|
int page = Math.max(1, queryDTO.getPage() != null ? queryDTO.getPage() : 1); // 确保page >= 1
|
||||||
int endIndex = Math.min(startIndex + queryDTO.getSize(), filteredOrders.size());
|
int size = Math.max(1, Math.min(100, queryDTO.getSize() != null ? queryDTO.getSize() : 10)); // 确保size在1-100之间
|
||||||
List<CtripOrder> pagedOrders = filteredOrders.subList(startIndex, endIndex);
|
|
||||||
|
log.info("分页参数标准化:page={}, size={}", page, size);
|
||||||
|
|
||||||
|
int startIndex = (page - 1) * size;
|
||||||
|
int endIndex = Math.min(startIndex + size, filteredOrders.size());
|
||||||
|
|
||||||
|
// 安全检查:确保startIndex不会为负数
|
||||||
|
if (startIndex < 0) {
|
||||||
|
startIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CtripOrder> pagedOrders;
|
||||||
|
if (startIndex >= filteredOrders.size()) {
|
||||||
|
// 如果起始索引超出范围,返回空列表
|
||||||
|
pagedOrders = new ArrayList<>();
|
||||||
|
} else {
|
||||||
|
pagedOrders = filteredOrders.subList(startIndex, endIndex);
|
||||||
|
}
|
||||||
|
|
||||||
// 4. 转换为VO
|
// 4. 转换为VO
|
||||||
List<OrderDetailVO> orderDetails = pagedOrders.stream()
|
List<OrderDetailVO> orderDetails = pagedOrders.stream()
|
||||||
@@ -263,40 +318,29 @@ public class OrderDetailServiceImpl implements IOrderDetailService {
|
|||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private List<CtripOrder> filterOrdersByPriceAndConsumable(List<CtripOrder> orders, BigDecimal couponPrice, Boolean onlyConsumable) {
|
||||||
* 筛选订单
|
|
||||||
*/
|
|
||||||
private List<CtripOrder> filterOrders(List<CtripOrder> orders, OrderQueryDTO queryDTO) {
|
|
||||||
log.info("开始筛选订单,原始订单数量: {}", orders.size());
|
log.info("开始筛选订单,原始订单数量: {}", orders.size());
|
||||||
|
|
||||||
List<CtripOrder> filteredOrders = orders.stream()
|
List<CtripOrder> filteredOrders = orders.stream()
|
||||||
.filter(order -> {
|
.filter(order -> {
|
||||||
log.debug("筛选订单: otaOrderId={}, totalAmount={}", order.getOtaOrderId(), order.getTotalAmount());
|
log.debug("筛选订单: otaOrderId={}, totalAmount={}", order.getOtaOrderId(), order.getTotalAmount());
|
||||||
|
if (couponPrice != null) {
|
||||||
// 按优惠券价格筛选
|
if (order.getTotalAmount() == null || !order.getTotalAmount().equals(couponPrice)) {
|
||||||
if (queryDTO.getCouponPrice() != null) {
|
|
||||||
if (order.getTotalAmount() == null ||
|
|
||||||
!order.getTotalAmount().equals(queryDTO.getCouponPrice())) {
|
|
||||||
log.debug("订单 {} 价格不匹配,期望: {}, 实际: {}",
|
log.debug("订单 {} 价格不匹配,期望: {}, 实际: {}",
|
||||||
order.getOtaOrderId(), queryDTO.getCouponPrice(), order.getTotalAmount());
|
order.getOtaOrderId(), couponPrice, order.getTotalAmount());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log.debug("订单 {} 价格匹配", order.getOtaOrderId());
|
log.debug("订单 {} 价格匹配", order.getOtaOrderId());
|
||||||
}
|
}
|
||||||
|
if (onlyConsumable != null && onlyConsumable) {
|
||||||
// 如果只查询可核销订单,则过滤掉不可核销的订单
|
|
||||||
if (queryDTO.getOnlyConsumable() != null && queryDTO.getOnlyConsumable()) {
|
|
||||||
if (!validateOrderForConsume(order.getOtaOrderId())) {
|
if (!validateOrderForConsume(order.getOtaOrderId())) {
|
||||||
log.debug("订单 {} 不可核销", order.getOtaOrderId());
|
log.debug("订单 {} 不可核销", order.getOtaOrderId());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log.debug("订单 {} 可核销", order.getOtaOrderId());
|
log.debug("订单 {} 可核销", order.getOtaOrderId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
log.info("筛选后订单数量: {}", filteredOrders.size());
|
log.info("筛选后订单数量: {}", filteredOrders.size());
|
||||||
return filteredOrders;
|
return filteredOrders;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ logging:
|
|||||||
ctrip:
|
ctrip:
|
||||||
# AES加密配置
|
# AES加密配置
|
||||||
aes:
|
aes:
|
||||||
key: 087b36ad0dff7942 # 为实际的AES密钥
|
key: 6196f64f4f6e5dca # 为实际的AES密钥
|
||||||
iv: 750e15a31356a99d # 为实际的AES IV
|
iv: 28405d20246ecccd # 为实际的AES IV
|
||||||
# 签名配置(使用账户密钥进行签名计算)
|
# 签名配置(使用账户密钥进行签名计算)
|
||||||
# API配置
|
# API配置
|
||||||
api:
|
api:
|
||||||
@@ -59,10 +59,10 @@ ctrip:
|
|||||||
# 生产环境URL
|
# 生产环境URL
|
||||||
prod-url: https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier
|
prod-url: https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier
|
||||||
# 当前环境(test/prod)
|
# 当前环境(test/prod)
|
||||||
environment: test
|
environment: prod
|
||||||
timeout: 30000 # 请求超时时间(毫秒)
|
timeout: 30000 # 请求超时时间(毫秒)
|
||||||
retry-times: 3 # 重试次数
|
retry-times: 3 # 重试次数
|
||||||
# 账户配置
|
# 账户配置
|
||||||
account:
|
account:
|
||||||
id: c50a8f2a4a59c9e7 # 为实际的账户ID
|
id: e02647943fdfb4c5 # 为实际的账户ID
|
||||||
secret: ce6033ae31124ec5cdab3d2bc79f2622 # 实际的账户密钥
|
secret: 0b4f4dabb50999cb04a773fc96f81499 # 实际的账户密钥
|
||||||
|
|||||||
+5
-12
@@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@@ -29,9 +28,7 @@ public class OrderDetailServiceTest {
|
|||||||
public void testQueryOrderDetails() {
|
public void testQueryOrderDetails() {
|
||||||
// 准备测试数据
|
// 准备测试数据
|
||||||
OrderQueryDTO queryDTO = new OrderQueryDTO();
|
OrderQueryDTO queryDTO = new OrderQueryDTO();
|
||||||
queryDTO.setUserPhone("13800138000");
|
queryDTO.setCodeId("test-code-id");
|
||||||
queryDTO.setCouponPrice(new BigDecimal("100.00"));
|
|
||||||
queryDTO.setOnlyConsumable(true);
|
|
||||||
queryDTO.setPage(1);
|
queryDTO.setPage(1);
|
||||||
queryDTO.setSize(10);
|
queryDTO.setSize(10);
|
||||||
|
|
||||||
@@ -100,12 +97,10 @@ public class OrderDetailServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryOrderDetailsWithEmptyPhone() {
|
public void testQueryOrderDetailsWithEmptyCodeId() {
|
||||||
// 准备测试数据
|
// 准备测试数据
|
||||||
OrderQueryDTO queryDTO = new OrderQueryDTO();
|
OrderQueryDTO queryDTO = new OrderQueryDTO();
|
||||||
queryDTO.setUserPhone(""); // 空手机号
|
queryDTO.setCodeId("");
|
||||||
queryDTO.setCouponPrice(new BigDecimal("100.00"));
|
|
||||||
queryDTO.setOnlyConsumable(true);
|
|
||||||
queryDTO.setPage(1);
|
queryDTO.setPage(1);
|
||||||
queryDTO.setSize(10);
|
queryDTO.setSize(10);
|
||||||
|
|
||||||
@@ -120,12 +115,10 @@ public class OrderDetailServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryOrderDetailsWithNullPhone() {
|
public void testQueryOrderDetailsWithNullCodeId() {
|
||||||
// 准备测试数据
|
// 准备测试数据
|
||||||
OrderQueryDTO queryDTO = new OrderQueryDTO();
|
OrderQueryDTO queryDTO = new OrderQueryDTO();
|
||||||
queryDTO.setUserPhone(null); // null手机号
|
queryDTO.setCodeId(null);
|
||||||
queryDTO.setCouponPrice(new BigDecimal("100.00"));
|
|
||||||
queryDTO.setOnlyConsumable(true);
|
|
||||||
queryDTO.setPage(1);
|
queryDTO.setPage(1);
|
||||||
queryDTO.setSize(10);
|
queryDTO.setSize(10);
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -22,6 +22,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -52,6 +53,7 @@ public interface DashboardMapper {
|
|||||||
"</if>",
|
"</if>",
|
||||||
"AND DATE(o.create_time) = CURDATE()",
|
"AND DATE(o.create_time) = CURDATE()",
|
||||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -75,6 +77,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
"AND o.order_status = 8",
|
"AND o.order_status = 8",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -128,6 +131,7 @@ public interface DashboardMapper {
|
|||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -158,6 +162,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
" AND DATE(o.create_time) = CURDATE()",
|
" AND DATE(o.create_time) = CURDATE()",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -182,6 +187,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
"AND o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9)",
|
"AND o.order_status IN (1, 3, 4, 5, 6, 7, 8, 9)",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -211,6 +217,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
"AND o.order_status = 8",
|
"AND o.order_status = 8",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -244,6 +251,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||||
" AND o.create_time >= #{p.startTime}",
|
" AND o.create_time >= #{p.startTime}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -272,6 +280,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
" AND o.order_status = 3",
|
" AND o.order_status = 3",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||||
" AND o.create_time >= #{p.startTime}",
|
" AND o.create_time >= #{p.startTime}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -300,6 +309,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
" AND o.order_status = 8",
|
" AND o.order_status = 8",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
"<if test='p.startTime != null and p.startTime != \"\"'>",
|
||||||
" AND o.create_time >= #{p.startTime}",
|
" AND o.create_time >= #{p.startTime}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -328,7 +338,7 @@ public interface DashboardMapper {
|
|||||||
" q.code_id as qrcodeId,",
|
" q.code_id as qrcodeId,",
|
||||||
" COUNT(o.id) as orderCount",
|
" COUNT(o.id) as orderCount",
|
||||||
"FROM qrcodes q",
|
"FROM qrcodes q",
|
||||||
"LEFT JOIN orders o ON q.code_id = o.code_id AND o.order_status IN (3, 7)",
|
"LEFT JOIN orders o ON q.code_id = o.code_id AND o.order_status IN (3, 7) AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"WHERE q.is_del = 0",
|
"WHERE q.is_del = 0",
|
||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
@@ -361,6 +371,7 @@ public interface DashboardMapper {
|
|||||||
"</if>",
|
"</if>",
|
||||||
"AND DATE(o.create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
"AND DATE(o.create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)",
|
||||||
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
"AND o.order_status IN (1, 3, 4, 5, 7, 8, 9)",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -384,6 +395,7 @@ public interface DashboardMapper {
|
|||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
"AND o.order_status = 3",
|
"AND o.order_status = 3",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -426,6 +438,7 @@ public interface DashboardMapper {
|
|||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -457,6 +470,7 @@ public interface DashboardMapper {
|
|||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -482,6 +496,7 @@ public interface DashboardMapper {
|
|||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
@@ -507,6 +522,7 @@ public interface DashboardMapper {
|
|||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
"</if>",
|
"</if>",
|
||||||
|
"AND (o.pay_type = 1 OR o.pay_type IS NULL)",
|
||||||
"<if test='p.tourismId != null'>",
|
"<if test='p.tourismId != null'>",
|
||||||
" AND o.tourism_id = #{p.tourismId}",
|
" AND o.tourism_id = #{p.tourismId}",
|
||||||
"</if>",
|
"</if>",
|
||||||
|
|||||||
@@ -31,6 +31,21 @@ const TableList: React.FC = () => {
|
|||||||
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 支付类型选项
|
||||||
|
const PAY_TYPE_OPTIONS = [
|
||||||
|
{ label: '微信支付', value: 1 },
|
||||||
|
{ label: '优惠券支付', value: 2 },
|
||||||
|
];
|
||||||
|
|
||||||
|
// 渲染支付类型标签
|
||||||
|
const renderPayType = (payType: number) => {
|
||||||
|
const payTypeInfo = PAY_TYPE_OPTIONS.find(option => option.value === payType);
|
||||||
|
if (!payTypeInfo) return <Tag color="default">未知</Tag>;
|
||||||
|
|
||||||
|
const color = payType === 1 ? 'green' : 'blue';
|
||||||
|
return <Tag color={color}>{payTypeInfo.label}</Tag>;
|
||||||
|
};
|
||||||
|
|
||||||
// 处理修改操作
|
// 处理修改操作
|
||||||
const handleEdit = useCallback(async (fields: { orderStatus: number }) => {
|
const handleEdit = useCallback(async (fields: { orderStatus: number }) => {
|
||||||
const hide = message.loading('正在更新');
|
const hide = message.loading('正在更新');
|
||||||
@@ -161,6 +176,17 @@ const TableList: React.FC = () => {
|
|||||||
copyable: true,
|
copyable: true,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '支付类型',
|
||||||
|
dataIndex: 'payType',
|
||||||
|
render: (payType) => renderPayType(payType as number),
|
||||||
|
width: 120,
|
||||||
|
filters: PAY_TYPE_OPTIONS.map(option => ({
|
||||||
|
text: option.label,
|
||||||
|
value: option.value,
|
||||||
|
})),
|
||||||
|
filterMultiple: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'orderStatus',
|
dataIndex: 'orderStatus',
|
||||||
@@ -223,6 +249,7 @@ const TableList: React.FC = () => {
|
|||||||
orderNo: values.orderNo?.trim(), // 去除空格
|
orderNo: values.orderNo?.trim(), // 去除空格
|
||||||
orderStatus: values.orderStatus, // 状态
|
orderStatus: values.orderStatus, // 状态
|
||||||
tourismId: values.tourismId, // 景区ID
|
tourismId: values.tourismId, // 景区ID
|
||||||
|
payType: values.payType, // 支付类型
|
||||||
};
|
};
|
||||||
// 过滤掉空值
|
// 过滤掉空值
|
||||||
const validParams = Object.fromEntries(
|
const validParams = Object.fromEntries(
|
||||||
@@ -244,6 +271,13 @@ const TableList: React.FC = () => {
|
|||||||
options={STATUS_OPTIONS}
|
options={STATUS_OPTIONS}
|
||||||
allowClear
|
allowClear
|
||||||
/>
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="payType"
|
||||||
|
label="支付类型"
|
||||||
|
placeholder="请选择支付类型"
|
||||||
|
options={PAY_TYPE_OPTIONS}
|
||||||
|
allowClear
|
||||||
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="tourismId"
|
name="tourismId"
|
||||||
label="景区"
|
label="景区"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ declare namespace ORDERS {
|
|||||||
id: number;
|
id: number;
|
||||||
orderNo: string;
|
orderNo: string;
|
||||||
orderStatus: string;
|
orderStatus: string;
|
||||||
|
payType?: number; // 支付类型(1:微信支付,2:优惠券支付)
|
||||||
createTime?: string;
|
createTime?: string;
|
||||||
tenantId?: string;
|
tenantId?: string;
|
||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user