feat(ticket): 增加套票实体扩展字段和关联查询功能

- 在GltUserTicket实体中增加templateName、payPrice、goodsName、nickname、avatar、phone等扩展字段
- 在GltUserTicketLog实体中增加nickname、avatar、phone等用户信息扩展字段
- 在GltUserTicketRelease实体中增加nickname、avatar、phone等用户信息扩展字段
- 修改GltUserTicketMapper.xml实现用户表、模板表、订单表的LEFT JOIN关联查询
- 修改GltUserTicketLogMapper.xml实现用户表LEFT JOIN关联查询并优化搜索条件
- 修改GltUserTicketReleaseMapper.xml实现用户表LEFT JOIN关联查询并调整搜索逻辑
- 临时注释掉套票发放服务中的时间条件过滤逻辑
- 添加调试日志输出订单数量信息
This commit is contained in:
2026-02-04 02:44:33 +08:00
parent d393de816f
commit 9a79aff47d
7 changed files with 76 additions and 10 deletions

View File

@@ -1,7 +1,10 @@
package com.gxwebsoft.glt.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
@@ -28,9 +31,21 @@ public class GltUserTicket implements Serializable {
@Schema(description = "模板ID")
private Integer templateId;
@Schema(description = "模板名称")
@TableField(exist = false)
private String templateName;
@Schema(description = "商品ID")
private Integer goodsId;
@Schema(description = "购买价格")
@TableField(exist = false)
private BigDecimal payPrice;
@Schema(description = "商品名称")
@TableField(exist = false)
private String goodsName;
@Schema(description = "订单ID")
private Integer orderId;
@@ -58,6 +73,18 @@ public class GltUserTicket implements Serializable {
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "用户昵称")
@TableField(exist = false)
private String nickname;
@Schema(description = "用户头像")
@TableField(exist = false)
private String avatar;
@Schema(description = "用户手机号")
@TableField(exist = false)
private String phone;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;

View File

@@ -1,6 +1,7 @@
package com.gxwebsoft.glt.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -58,6 +59,18 @@ public class GltUserTicketLog implements Serializable {
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "用户昵称")
@TableField(exist = false)
private String nickname;
@Schema(description = "用户头像")
@TableField(exist = false)
private String avatar;
@Schema(description = "用户手机号")
@TableField(exist = false)
private String phone;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;

View File

@@ -1,6 +1,7 @@
package com.gxwebsoft.glt.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -31,6 +32,18 @@ public class GltUserTicketRelease implements Serializable {
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "用户昵称")
@TableField(exist = false)
private String nickname;
@Schema(description = "用户头像")
@TableField(exist = false)
private String avatar;
@Schema(description = "用户手机号")
@TableField(exist = false)
private String phone;
@Schema(description = "周期编号")
private Integer periodNo;

View File

@@ -4,8 +4,9 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
SELECT a.*, u.nickname, u.avatar, u.phone
FROM glt_user_ticket_log a
LEFT JOIN gxwebsoft_core.sys_user u ON a.user_id = u.user_id
<where>
<if test="param.id != null">
AND a.id = #{param.id}
@@ -66,6 +67,9 @@
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR a.user_id = #{param.keywords}
OR a.user_ticket_id = #{param.keywords}
OR a.order_no = #{param.keywords}
)
</if>
</where>

View File

@@ -4,8 +4,11 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
SELECT a.*, u.nickname, u.avatar, u.phone, m.name AS templateName, o.pay_price
FROM glt_user_ticket a
LEFT JOIN gxwebsoft_core.sys_user u ON a.user_id = u.user_id
LEFT JOIN glt_ticket_template m ON a.template_id = m.id
LEFT JOIN shop_order o ON a.order_no = o.order_no
<where>
<if test="param.id != null">
AND a.id = #{param.id}
@@ -66,6 +69,8 @@
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR a.user_id = #{param.keywords}
OR a.order_no = #{param.keywords}
)
</if>
</where>

View File

@@ -4,9 +4,10 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
SELECT a.*, u.nickname, u.avatar, u.phone
FROM glt_user_ticket_release a
<where>
LEFT JOIN gxwebsoft_core.sys_user u ON a.user_id = u.user_id
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
@@ -41,7 +42,8 @@
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
AND (a.user_ticket_id = #{param.keywords}
OR u.user_id = #{param.keywords}
)
</if>
</where>

View File

@@ -59,15 +59,17 @@ public class GltTicketIssueService {
.eq(ShopOrder::getPayStatus, true)
.eq(ShopOrder::getOrderStatus, 0)
// 今日订单(兼容:以 create_time 或 pay_time 任一落在今日即可)
.and(w -> w
.ge(ShopOrder::getCreateTime, todayStart).lt(ShopOrder::getCreateTime, tomorrowStart)
.or()
.ge(ShopOrder::getPayTime, todayStart).lt(ShopOrder::getPayTime, tomorrowStart)
)
// .and(w -> w
// .ge(ShopOrder::getCreateTime, todayStart).lt(ShopOrder::getCreateTime, tomorrowStart)
// .or()
// .ge(ShopOrder::getPayTime, todayStart).lt(ShopOrder::getPayTime, tomorrowStart)
// )
.orderByAsc(ShopOrder::getPayTime)
.orderByAsc(ShopOrder::getOrderId)
);
System.out.println("orders = " + orders.size());
if (orders.isEmpty()) {
log.debug("套票发放扫描:今日无符合条件的订单 tenantId={}, formId={}", tenantId, formId);
return;