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

View File

@@ -1,6 +1,7 @@
package com.gxwebsoft.glt.entity; package com.gxwebsoft.glt.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -58,6 +59,18 @@ public class GltUserTicketLog implements Serializable {
@Schema(description = "用户ID") @Schema(description = "用户ID")
private Integer userId; 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 = "排序(数字越小越靠前)") @Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber; private Integer sortNumber;

View File

@@ -1,6 +1,7 @@
package com.gxwebsoft.glt.entity; package com.gxwebsoft.glt.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
@@ -31,6 +32,18 @@ public class GltUserTicketRelease implements Serializable {
@Schema(description = "用户ID") @Schema(description = "用户ID")
private Integer userId; 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 = "周期编号") @Schema(description = "周期编号")
private Integer periodNo; private Integer periodNo;

View File

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

View File

@@ -4,8 +4,11 @@
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <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 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> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -66,6 +69,8 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR a.user_id = #{param.keywords}
OR a.order_no = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -4,9 +4,10 @@
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*, u.nickname, u.avatar, u.phone
FROM glt_user_ticket_release a 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"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
</if> </if>
@@ -41,7 +42,8 @@
AND a.create_time &lt;= #{param.createTimeEnd} AND a.create_time &lt;= #{param.createTimeEnd}
</if> </if>
<if test="param.keywords != null"> <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> </if>
</where> </where>

View File

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