| | |
| | | WHERE |
| | | LSCCR.id = #{id} AND LSCCR.delete_flag = 0 |
| | | </select> |
| | | <resultMap id="BaseResultMapByManager" type="cn.lili.modules.lmk.domain.vo.StoreCouponClaimRecordVO"> |
| | | <!-- 会员优惠券表(li_member_coupon)字段映射 --> |
| | | <result column="member_id" property="memberId"/> |
| | | <result column="member_name" property="memberName"/> |
| | | <result column="price" property="price"/> |
| | | <result column="start_time" property="startTime"/> |
| | | <result column="end_time" property="endTime"/> |
| | | <result column="member_coupon_status" property="memberCouponStatus"/> |
| | | <result column="goods_use_limit_num" property="goodsUseLimitNum"/> |
| | | <result column="platform_flag" property="platformFlag"/> |
| | | <result column="get_type" property="getType"/> |
| | | <result column="discount" property="discount"/> |
| | | <result column="coupon_type" property="couponType"/> |
| | | <result column="coupon_id" property="couponId" /> |
| | | <!-- 店铺优惠券领取记录表(lmk_store_coupon_claim_record)字段映射 --> |
| | | <result column="id" property="id"/> |
| | | <result column="store_name" property="storeName"/> |
| | | <result column="store_coupon_id" property="storeCouponId"/> |
| | | <result column="store_id" property="storeId"/> |
| | | <result column="user_id" property="userId"/> |
| | | <result column="coupon_name" property="couponName"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | <select id="getPage" resultMap="BaseResultMapByManager"> |
| | | SELECT |
| | | LSCCR.store_name, |
| | | LSCCR.coupon_id, |
| | | LSCCR.coupon_name, |
| | | LSCCR.store_id, |
| | | LSCCR.user_id, |
| | | LSCCR.id |
| | | lmc.member_id, |
| | | lmc.member_name, |
| | | lmc.price, |
| | | lmc.start_time, |
| | | lmc.end_time, |
| | | lmc.member_coupon_status, |
| | | lmc.goods_use_limit_num, |
| | | lmc.platform_flag, |
| | | lmc.get_type, |
| | | lmc.discount, |
| | | lmc.coupon_type, |
| | | lsccr.id, |
| | | lsccr.store_name, |
| | | lsccr.store_coupon_id, |
| | | lsccr.store_id, |
| | | lsccr.user_id, |
| | | lsccr.coupon_name, |
| | | lsccr.create_time, |
| | | lsccr.coupon_id |
| | | FROM |
| | | lmk_store_coupon_claim_record LSCCR |
| | | lmk_store_coupon_claim_record lsccr |
| | | INNER JOIN |
| | | li_member_coupon lmc ON lmc.coupon_id = lsccr.coupon_id |
| | | WHERE |
| | | LSCCR.delete_flag = 0 |
| | | lmc.delete_flag = 0 |
| | | AND lsccr.delete_flag = 0 |
| | | <!-- 1. 会员名称模糊查询(关联li_member_coupon表) --> |
| | | <if test="query.memberName != null and query.memberName != ''"> |
| | | AND lmc.member_name LIKE CONCAT('%', #{query.memberName}, '%') |
| | | </if> |
| | | <!-- 2. 优惠券名称模糊查询(关联lmk_store_coupon_claim_record表) --> |
| | | <if test="query.couponName != null and query.couponName != ''"> |
| | | AND lsccr.coupon_name LIKE CONCAT('%', #{query.couponName}, '%') |
| | | </if> |
| | | <!-- 3. 优惠券获取方式(精确匹配,关联li_member_coupon表) --> |
| | | <if test="query.getType != null and query.getType != ''"> |
| | | AND lmc.get_type = #{query.getType} |
| | | </if> |
| | | <!-- 4. 会员优惠券状态(精确匹配,关联li_member_coupon表) --> |
| | | <if test="query.memberCouponStatus != null and query.memberCouponStatus != ''"> |
| | | AND lmc.member_coupon_status = #{query.memberCouponStatus} |
| | | </if> |
| | | <!-- 5. 时间范围筛选:用BETWEEN匹配start_time和end_time(需同时传入开始和结束时间) --> |
| | | <if test="query.startTime != null and query.endTime != null"> |
| | | AND lmc.start_time BETWEEN FROM_UNIXTIME(#{query.startTime}/1000) |
| | | AND FROM_UNIXTIME(#{query.endTime}/1000) |
| | | </if> |
| | | <!-- 6. 排序逻辑(根据前端传入的sort字段和order排序方向) --> |
| | | <if test="query.sort != null and query.sort != '' and query.order != null and query.order != ''"> |
| | | ORDER BY |
| | | <choose> |
| | | <!-- li_member_coupon表字段 --> |
| | | <when test="query.sort == 'memberName'">lmc.member_name #{query.order},</when> |
| | | <when test="query.sort == 'price'">lmc.price #{query.order},</when> |
| | | <when test="query.sort == 'startTime'">lmc.start_time #{query.order},</when> |
| | | <when test="query.sort == 'endTime'">lmc.end_time #{query.order},</when> |
| | | <when test="query.sort == 'memberCouponStatus'">lmc.member_coupon_status #{query.order},</when> |
| | | <when test="query.sort == 'getType'">lmc.get_type #{query.order},</when> |
| | | |
| | | <when test="query.sort == 'couponName'">lsccr.coupon_name #{query.order},</when> |
| | | <when test="query.sort == 'storeName'">lsccr.store_name #{query.order},</when> |
| | | <when test="query.sort == 'createTime'">lsccr.create_time #{query.order},</when> |
| | | <!-- 默认排序 --> |
| | | <otherwise>lsccr.create_time DESC,</otherwise> |
| | | </choose> |
| | | lsccr.create_time DESC <!-- 兜底排序,避免语法错误 --> |
| | | </if> |
| | | <!-- 未传排序参数时,默认按领取时间倒序 --> |
| | | <if test="(query.sort == null or query.sort == '') or (query.order == null or query.order == '')"> |
| | | ORDER BY lsccr.create_time DESC |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getExportData" resultMap="BaseResultMapByManager"> |
| | | SELECT |
| | | lmc.member_id, |
| | | lmc.member_name, |
| | | lmc.price, |
| | | lmc.start_time, |
| | | lmc.end_time, |
| | | lmc.member_coupon_status, |
| | | lmc.goods_use_limit_num, |
| | | lmc.platform_flag, |
| | | lmc.get_type, |
| | | lmc.discount, |
| | | lmc.coupon_type, |
| | | lsccr.id, |
| | | lsccr.store_name, |
| | | lsccr.store_coupon_id, |
| | | lsccr.store_id, |
| | | lsccr.user_id, |
| | | lsccr.coupon_name, |
| | | lsccr.create_time, |
| | | lsccr.coupon_id |
| | | FROM |
| | | lmk_store_coupon_claim_record lsccr |
| | | INNER JOIN |
| | | li_member_coupon lmc ON lmc.coupon_id = lsccr.coupon_id |
| | | WHERE |
| | | lmc.delete_flag = 0 |
| | | AND lsccr.delete_flag = 0 |
| | | <!-- 1. 会员名称模糊查询(关联li_member_coupon表) --> |
| | | <if test="query.memberName != null and query.memberName != ''"> |
| | | AND lmc.member_name LIKE CONCAT('%', #{query.memberName}, '%') |
| | | </if> |
| | | <!-- 2. 优惠券名称模糊查询(关联lmk_store_coupon_claim_record表) --> |
| | | <if test="query.couponName != null and query.couponName != ''"> |
| | | AND lsccr.coupon_name LIKE CONCAT('%', #{query.couponName}, '%') |
| | | </if> |
| | | <!-- 3. 优惠券获取方式(精确匹配,关联li_member_coupon表) --> |
| | | <if test="query.getType != null and query.getType != ''"> |
| | | AND lmc.get_type = #{query.getType} |
| | | </if> |
| | | <!-- 4. 会员优惠券状态(精确匹配,关联li_member_coupon表) --> |
| | | <if test="query.memberCouponStatus != null and query.memberCouponStatus != ''"> |
| | | AND lmc.member_coupon_status = #{query.memberCouponStatus} |
| | | </if> |
| | | <!-- 5. 时间范围筛选:用BETWEEN匹配start_time和end_time(需同时传入开始和结束时间) --> |
| | | <if test="query.startTime != null and query.endTime != null"> |
| | | AND lmc.start_time BETWEEN FROM_UNIXTIME(#{query.startTime}/1000) |
| | | AND FROM_UNIXTIME(#{query.endTime}/1000) |
| | | </if> |
| | | <!-- 6. 排序逻辑(根据前端传入的sort字段和order排序方向) --> |
| | | <if test="query.sort != null and query.sort != '' and query.order != null and query.order != ''"> |
| | | ORDER BY |
| | | <choose> |
| | | <!-- li_member_coupon表字段 --> |
| | | <when test="query.sort == 'memberName'">lmc.member_name #{query.order},</when> |
| | | <when test="query.sort == 'price'">lmc.price #{query.order},</when> |
| | | <when test="query.sort == 'startTime'">lmc.start_time #{query.order},</when> |
| | | <when test="query.sort == 'endTime'">lmc.end_time #{query.order},</when> |
| | | <when test="query.sort == 'memberCouponStatus'">lmc.member_coupon_status #{query.order},</when> |
| | | <when test="query.sort == 'getType'">lmc.get_type #{query.order},</when> |
| | | |
| | | <when test="query.sort == 'couponName'">lsccr.coupon_name #{query.order},</when> |
| | | <when test="query.sort == 'storeName'">lsccr.store_name #{query.order},</when> |
| | | <when test="query.sort == 'createTime'">lsccr.create_time #{query.order},</when> |
| | | <!-- 默认排序 --> |
| | | <otherwise>lsccr.create_time DESC,</otherwise> |
| | | </choose> |
| | | lsccr.create_time DESC <!-- 兜底排序,避免语法错误 --> |
| | | </if> |
| | | <!-- 未传排序参数时,默认按领取时间倒序 --> |
| | | <if test="(query.sort == null or query.sort == '') or (query.order == null or query.order == '')"> |
| | | ORDER BY lsccr.create_time DESC |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |