You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

229 lines
9.7 KiB

  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="com.iformall.mapper.WxCardInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCardInfo">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="sub_tenant_id" jdbcType="VARCHAR" property="subTenantId" />
  8. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  9. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  10. <result column="amount" jdbcType="INTEGER" property="amount" />
  11. <result column="sale_amount" jdbcType="INTEGER" property="saleAmount" />
  12. <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" />
  13. <result column="service_fee_amount" jdbcType="INTEGER" property="serviceFeeAmount" />
  14. <result column="share_fee_amount" jdbcType="INTEGER" property="shareFeeAmount" />
  15. <result column="remaining_share_fee_amount" jdbcType="INTEGER" property="remainingShareFeeAmount" />
  16. <result column="rate_amount" jdbcType="INTEGER" property="rateAmount" />
  17. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  18. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  19. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  20. </resultMap>
  21. <sql id="allColumns">
  22. `id`,`tenant_id`,`sub_tenant_id`,`coupon_id`,`transaction_id`,
  23. `amount`,`sale_amount`,`remaining_amount`,`service_fee_amount`,
  24. `share_fee_amount`,`remaining_share_fee_amount`, `rate_amount`,
  25. `create_date`,`update_date`,`support_transfer`
  26. </sql>
  27. <sql id="dynamicWhereConditions">
  28. where 1 = 1
  29. <if test=" null != id ">
  30. and `id` = #{id}
  31. </if>
  32. <if test=" null != tenantId ">
  33. and `tenant_id` = #{tenantId}
  34. </if>
  35. <if test=" null != subTenantId ">
  36. and `sub_tenant_id` = #{subTenantId}
  37. </if>
  38. <if test=" null != couponId ">
  39. and `coupon_id` = #{couponId}
  40. </if>
  41. <if test=" null != transactionId ">
  42. and `transaction_id` = #{transactionId}
  43. </if>
  44. <if test=" null != amount ">
  45. and `amount` = #{amount}
  46. </if>
  47. <if test=" null != saleAmount ">
  48. and `sale_amount` = #{saleAmount}
  49. </if>
  50. <if test=" null != remainingAmount ">
  51. and `remaining_amount` = #{remainingAmount}
  52. </if>
  53. <if test=" null != serviceFeeAmount ">
  54. and `service_fee_amount` = #{serviceFeeAmount}
  55. </if>
  56. <if test=" null != shareFeeAmount ">
  57. and `share_fee_amount` = #{shareFeeAmount}
  58. </if>
  59. <if test=" null != remainingShareFeeAmount ">
  60. and `remaining_share_fee_amount` = #{remainingShareFeeAmount}
  61. </if>
  62. <if test=" null != rateAmount ">
  63. and `rate_amount` = #{rateAmount}
  64. </if>
  65. <if test=" null != createDate ">
  66. and `create_date` = #{createDate}
  67. </if>
  68. <if test=" null != updateDate ">
  69. and `update_date` = #{updateDate}
  70. </if>
  71. <if test=" null != startdate and null!=enddate">
  72. and `create_date` between #{startdate} and #{enddate}
  73. </if>
  74. <if test=" null != ids ">
  75. and id in
  76. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  77. #{idItem}
  78. </foreach>
  79. </if>
  80. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  81. </sql>
  82. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxCardVo">
  83. <id column="id" jdbcType="BIGINT" property="id" />
  84. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  85. <result column="sub_tenant_id" jdbcType="VARCHAR" property="subTenantId" />
  86. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  87. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  88. <result column="amount" jdbcType="INTEGER" property="amount" />
  89. <result column="sale_amount" jdbcType="INTEGER" property="saleAmount" />
  90. <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" />
  91. <result column="service_fee_amount" jdbcType="INTEGER" property="serviceFeeAmount" />
  92. <result column="share_fee_amount" jdbcType="INTEGER" property="shareFeeAmount" />
  93. <result column="remaining_share_fee_amount" jdbcType="INTEGER" property="remainingShareFeeAmount" />
  94. <result column="rate_amount" jdbcType="INTEGER" property="rateAmount" />
  95. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  96. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  97. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  98. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture" />
  99. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture" />
  100. <result column="title" jdbcType="VARCHAR" property="title" />
  101. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  102. <result column="detail" jdbcType="VARCHAR" property="detail" />
  103. <result column="unit" jdbcType="INTEGER" property="unit" />
  104. <result column="remark" jdbcType="VARCHAR" property="remark" />
  105. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  106. <result column="price" jdbcType="INTEGER" property="price"/>
  107. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  108. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  109. <result column="c_user_id" jdbcType="BIGINT" property="cuserId" />
  110. <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
  111. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  112. <result column="status" jdbcType="INTEGER" property="status"/>
  113. <result column="c_nick_name" jdbcType="VARCHAR" property="cnickName"/>
  114. <result column="o_nick_name" jdbcType="VARCHAR" property="onickName"/>
  115. <result column="ou_phone" jdbcType="VARCHAR" property="ouPhone"/>
  116. </resultMap>
  117. <sql id="allVoColumns">
  118. ci.`id`,ci.`tenant_id`,ci.`sub_tenant_id`,ci.`coupon_id`,ci.`transaction_id`,
  119. ci.`amount`,ci.`sale_amount`,ci.`remaining_amount`,ci.`service_fee_amount`,
  120. ci.`share_fee_amount`,ci.`remaining_share_fee_amount`, ci.`rate_amount`,
  121. ci.`create_date`,ci.`update_date`,
  122. c.`cover_img`, c.`cover_picture`,c.`detail_picture`,c.`title`, c.`sub_title`, c.`detail`, c.`unit`, c.`remark`, c.`sale_price`, c.`price`, c.`subsidy_type`, c.`subsidy_num`,
  123. co.`c_user_id`, co.`owner_id`, co.`expired_time`, co.`coupon_order_status` as status,
  124. cu.`nick_name` as c_nick_name, ou.`nick_name` as o_nick_name, ou.`phone` as ou_phone
  125. </sql>
  126. <sql id="dynamicVoWhereConditions">
  127. where 1 = 1
  128. <if test=" null != id ">
  129. and ci.`id` = #{id}
  130. </if>
  131. <if test=" null != tenantId ">
  132. and ci.`tenant_id` = #{tenantId}
  133. </if>
  134. <if test=" null != subTenantId ">
  135. and ci.`sub_tenant_id` = #{subTenantId}
  136. </if>
  137. <if test=" null != couponId ">
  138. and ci.`coupon_id` = #{couponId}
  139. </if>
  140. <if test=" null != transactionId ">
  141. and ci.`transaction_id` = #{transactionId}
  142. </if>
  143. <if test=" null != amount ">
  144. and ci.`amount` = #{amount}
  145. </if>
  146. <if test=" null != saleAmount ">
  147. and ci.`sale_amount` = #{saleAmount}
  148. </if>
  149. <if test=" null != remainingAmount ">
  150. and ci.`remaining_amount` = #{remainingAmount}
  151. </if>
  152. <if test=" null != serviceFeeAmount ">
  153. and ci.`service_fee_amount` = #{serviceFeeAmount}
  154. </if>
  155. <if test=" null != shareFeeAmount ">
  156. and ci.`share_fee_amount` = #{shareFeeAmount}
  157. </if>
  158. <if test=" null != remainingShareFeeAmount ">
  159. and ci.`remaining_share_fee_amount` = #{remainingShareFeeAmount}
  160. </if>
  161. <if test=" null != rateAmount ">
  162. and ci.`rate_amount` = #{rateAmount}
  163. </if>
  164. <if test=" null != createDate ">
  165. and ci.`create_date` = #{createDate}
  166. </if>
  167. <if test=" null != updateDate ">
  168. and ci.`update_date` = #{updateDate}
  169. </if>
  170. <if test=" null != status ">
  171. and co.`coupon_order_status` = #{status}
  172. </if>
  173. <if test=" null != ouPhone and '' != ouPhone">
  174. and ou.`phone` = #{ouPhone}
  175. </if>
  176. <if test=" null != startdate and null!=enddate">
  177. and ci.`create_date` between #{startdate} and #{enddate}
  178. </if>
  179. <if test=" null != onickName and ''!=onickName">
  180. and ou.`nick_name` like concat('%',#{onickName},'%')
  181. </if>
  182. <if test=" null != statusS ">
  183. and co.`coupon_order_status` in
  184. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  185. #{sItem}
  186. </foreach>
  187. </if>
  188. <if test=" null != ids ">
  189. and ci.id in
  190. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  191. #{idItem}
  192. </foreach>
  193. </if>
  194. order by ci.id desc
  195. </sql>
  196. <select id="findVoList" parameterType="com.iformall.domain.vo.WxCardVo" resultMap="VoBaseResultMap">
  197. select <include refid="allVoColumns" />
  198. <!--from (select ci.`id`, ci.`tenant_id`, ci.`coupon_id`, ci.`transaction_id`, ci.`amount`, ci.`sale_amount`, ci.`remaining_amount`, ci.`service_fee_amount`, ci.`share_fee_amount`, ci.`remaining_share_fee_amount`, ci.`rate_amount`, ci.`create_date`, ci.`update_date` from wx_card_info ci where ci.`tenant_id` = #{tenantId}) ci-->
  199. from wx_card_info ci
  200. left join wx_coupon c on c.id = ci.coupon_id
  201. left join wx_coupon_order co on co.id = ci.id
  202. left join wx_c_user cu on cu.id = co.c_user_id
  203. left join wx_c_user ou on ou.id = co.owner_id
  204. <include refid="dynamicVoWhereConditions" />
  205. </select>
  206. <update id="updateTransferStatusByCouponId" parameterType="Long">
  207. update wx_card_info set support_transfer=0,update_date=now() where support_transfer=1 and coupon_id=#{couponId}
  208. </update>
  209. <select id="findList" parameterType="com.iformall.domain.po.WxCardInfo" resultMap="BaseResultMap">
  210. select <include refid="allColumns" />
  211. from wx_card_info
  212. <include refid="dynamicWhereConditions" />
  213. </select>
  214. </mapper>