LifeDiscountCouponMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="shop.alien.mapper.LifeDiscountCouponMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="shop.alien.entity.store.LifeDiscountCoupon">
  6. <id column="id" property="id" />
  7. <result column="store_id" property="storeId" />
  8. <result column="name" property="name" />
  9. <result column="nominal_value" property="nominalValue" />
  10. <result column="expiration_date" property="expirationDate" />
  11. <result column="start_date" property="startDate" />
  12. <result column="end_date" property="endDate" />
  13. <result column="single_qty" property="singleQty" />
  14. <result column="supplementary_instruction" property="supplementaryInstruction" />
  15. <result column="status" property="status" />
  16. <result column="image_path" property="imagePath" />
  17. <result column="get_status" property="getStatus" />
  18. <result column="restricted_quantity" property="restrictedQuantity" />
  19. <result column="minimum_spending_amount" property="minimumSpendingAmount" />
  20. <result column="type" property="type" />
  21. <result column="approval_comments" property="approvalComments" />
  22. <result column="delete_flag" property="deleteFlag" />
  23. <result column="created_time" property="createdTime" />
  24. <result column="updated_time" property="updatedTime" />
  25. <result column="created_user_id" property="createdUserId" />
  26. <result column="updated_user_id" property="updatedUserId" />
  27. </resultMap>
  28. <!-- 关联 life_coupon 查询代金券(仅 type=4):按 storeId、couponStatus、single_qty!=0,返回 dis 表以匹配 BaseResultMap -->
  29. <select id="selectListJoinLifeCoupon" resultMap="BaseResultMap">
  30. SELECT dis.*
  31. FROM life_discount_coupon dis
  32. JOIN life_coupon c ON dis.store_id = c.store_id
  33. WHERE dis.store_id = #{storeId}
  34. AND dis.type = 4
  35. AND dis.coupon_status = #{couponStatus}
  36. AND dis.delete_flag = 0
  37. AND (dis.unlimited_qty = 1 OR (dis.single_qty IS NOT NULL AND dis.single_qty != 0))
  38. </select>
  39. <!-- 单表查询 life_discount_coupon:type 不为 4 时使用 -->
  40. <select id="selectListSingleTable" resultMap="BaseResultMap">
  41. SELECT *
  42. FROM life_discount_coupon
  43. WHERE store_id = #{storeId}
  44. AND coupon_status = #{couponStatus}
  45. AND delete_flag = 0
  46. AND (unlimited_qty = 1 OR (single_qty IS NOT NULL AND single_qty != 0))
  47. <if test="type != null">
  48. AND type = #{type}
  49. </if>
  50. <if test="couponType != null">
  51. AND coupon_type = #{couponType}
  52. </if>
  53. </select>
  54. <select id="selectByIdIncludeDeleted" resultType="shop.alien.entity.store.LifeDiscountCoupon">
  55. SELECT * FROM life_discount_coupon WHERE id = #{id}
  56. </select>
  57. <select id="selectByIdsIncludeDeleted" resultType="shop.alien.entity.store.LifeDiscountCoupon">
  58. SELECT * FROM life_discount_coupon
  59. WHERE id IN
  60. <foreach collection="ids" item="id" open="(" separator="," close=")">
  61. #{id}
  62. </foreach>
  63. </select>
  64. </mapper>