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.
 
 
 
 
 

259 lines
11 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.iformall.mapper.WxOfflineActivityGrantItemMapper">
  6. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOfflineActivityGrantItem">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>
  9. <result property="parentTenantId" column="parent_tenant_id" jdbcType="VARCHAR"/>
  10. <result property="grantId" column="grant_id" jdbcType="BIGINT"/>
  11. <result property="grantAwardsMode" column="grant_awards_mode" jdbcType="SMALLINT"/>
  12. <result property="activityId" column="activity_id" jdbcType="BIGINT"/>
  13. <result property="activityName" column="activity_name" jdbcType="VARCHAR"/>
  14. <result property="activityItemId" column="activity_item_id" jdbcType="BIGINT"/>
  15. <result property="activityItemName" column="activity_item_name" jdbcType="INTEGER"/>
  16. <result property="activityItemType" column="activity_item_type" jdbcType="SMALLINT"/>
  17. <result property="awardItamId" column="award_itam_id" jdbcType="BIGINT"/>
  18. <result property="awardName" column="award_name" jdbcType="VARCHAR"/>
  19. <result property="awardGrade" column="award_grade" jdbcType="INTEGER"/>
  20. <result property="awardMinAmount" column="award_min_amount" jdbcType="DECIMAL"/>
  21. <result property="awardMaxAmount" column="award_max_amount" jdbcType="DECIMAL"/>
  22. <result property="awardsItemRule" column="awards_item_rule" jdbcType="INTEGER"/>
  23. <result property="cashBackRatio" column="cash_back_ratio" jdbcType="DECIMAL"/>
  24. <result property="awardPrice" column="award_price" jdbcType="DECIMAL"/>
  25. <result property="awardCount" column="award_count" jdbcType="INTEGER"/>
  26. <result property="moneyRule" column="money_rule" jdbcType="SMALLINT"/>
  27. <result property="mallShareRate" column="mall_share_rate" jdbcType="DECIMAL"/>
  28. <result property="merchantShareRate" column="merchant_share_rate" jdbcType="DECIMAL"/>
  29. <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
  30. <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
  31. <result property="recordId" column="record_id" jdbcType="BIGINT"/>
  32. <result property="status" column="status" jdbcType="INTEGER"/>
  33. </resultMap>
  34. <sql id="allColumns">
  35. id,tenant_id,parent_tenant_id,
  36. grant_id,grant_awards_mode,activity_id,activity_name,
  37. activity_item_id,activity_item_name,activity_item_type,
  38. award_itam_id,award_name,award_grade,
  39. award_min_amount,award_max_amount,awards_item_rule,cash_back_ratio,
  40. award_price,award_count,money_rule,
  41. mall_share_rate,merchant_share_rate,
  42. create_date,update_date,record_id
  43. </sql>
  44. <sql id="dynamicWhereConditions">
  45. where 1 = 1
  46. <if test=" null != id ">
  47. and `id` = #{id}
  48. </if>
  49. <if test=" null != tenantId and '' != tenantId">
  50. and `tenant_id` = #{tenantId}
  51. </if>
  52. <if test=" null != parentTenantId and '' != parentTenantId">
  53. and `parent_tenant_id` = #{parentTenantId}
  54. </if>
  55. <if test=" null != grantId">
  56. and `grant_id` = #{grantId}
  57. </if>
  58. <if test=" null != grantAwardsMode">
  59. and `grant_awards_mode` = #{grantAwardsMode}
  60. </if>
  61. <if test=" null != activityId">
  62. and `activity_id` = #{activityId}
  63. </if>
  64. <if test=" null != activityItemId">
  65. and `activity_item_id` = #{activityItemId}
  66. </if>
  67. <if test=" null != awardItamId">
  68. and `award_itam_id` = #{awardItamId}
  69. </if>
  70. <if test=" null != status">
  71. and `status` = #{status}
  72. </if>
  73. <if test=" null != ids ">
  74. and id in
  75. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  76. #{idItem}
  77. </foreach>
  78. </if>
  79. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  80. </sql>
  81. <select id="findList" parameterType="com.iformall.domain.po.WxOfflineActivityGrantItem" resultMap="BaseResultMap">
  82. select <include refid="allColumns" /> from wx_offline_activity_grant_item
  83. <include refid="dynamicWhereConditions" />
  84. </select>
  85. <insert id="insertList" parameterType="java.util.List">
  86. insert into wx_offline_activity_grant_item
  87. (id,
  88. grant_id,grant_awards_mode,activity_id,activity_name,
  89. activity_item_id,activity_item_name,activity_item_type,
  90. award_itam_id,award_name,award_grade,
  91. award_min_amount,award_max_amount,awards_item_rule,cash_back_ratio,
  92. award_price,award_count,money_rule,
  93. mall_share_rate,merchant_share_rate,
  94. create_date,update_date,record_id)
  95. values
  96. <foreach collection="grantItemList" item="item" index="index" separator=",">
  97. (#{item.id,jdbcType=BIGINT},
  98. #{item.grantId,jdbcType=BIGINT},#{item.grantAwardsMode,jdbcType=INTEGER},#{item.activityId,jdbcType=BIGINT},#{item.activityName,jdbcType=VARCHAR},
  99. #{item.activityItemId,jdbcType=BIGINT},#{item.activityItemName,jdbcType=VARCHAR},#{item.activityItemType,jdbcType=INTEGER},
  100. #{item.awardItamId,jdbcType=BIGINT},#{item.awardName,jdbcType=VARCHAR},#{item.awardGrade,jdbcType=INTEGER},
  101. #{item.awardMinAmount,jdbcType=DECIMAL},#{item.awardMaxAmount,jdbcType=DECIMAL},#{item.awardsItemRule,jdbcType=INTEGER},#{item.cashBackRatio,jdbcType=DECIMAL},
  102. #{item.awardPrice,jdbcType=DECIMAL},#{item.awardCount,jdbcType=INTEGER},#{item.moneyRule,jdbcType=INTEGER},
  103. #{item.mallShareRate,jdbcType=DECIMAL},#{item.merchantShareRate,jdbcType=DECIMAL},
  104. #{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP},#{item.recordId,jdbcType=BIGINT})
  105. </foreach>
  106. </insert>
  107. <select id="getSumAwardCount" parameterType="com.iformall.domain.po.WxOfflineActivityGrantItem" resultType="Integer">
  108. SELECT IFNULL(sum(award_count),0) FROM wx_offline_activity_grant_item
  109. where 1 = 1
  110. <if test=" null != tenantId and '' != tenantId">
  111. and tenant_id = #{tenantId}
  112. </if>
  113. <if test=" null != parentTenantId and '' != parentTenantId">
  114. and parent_tenant_id = #{parentTenantId}
  115. </if>
  116. <if test=" null != activityId ">
  117. and activity_id = #{activityId}
  118. </if>
  119. <if test=" null != status">
  120. and `status` = #{status}
  121. </if>
  122. </select>
  123. <select id="activityItemStatistics" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
  124. SELECT IFNULL(sum(award_count),0) as 'itemCount',
  125. IFNULL(sum(award_price),0) as 'itemSumMoney'
  126. FROM wx_offline_activity_grant_item
  127. where 1 = 1
  128. <if test=" null != tenantId and '' != tenantId">
  129. and `tenant_id` = #{tenantId}
  130. </if>
  131. <if test=" null != parentTenantId and '' != parentTenantId">
  132. and `parent_tenant_id` = #{parentTenantId}
  133. </if>
  134. <if test=" null != activityId">
  135. and `activity_id` = #{activityId}
  136. </if>
  137. <if test=" null != activityItemId ">
  138. and `activity_item_id` = #{activityItemId}
  139. </if>
  140. <if test=" null != createDateBegin">
  141. and `create_date` &gt;= #{createDateBegin}
  142. </if>
  143. <if test=" null != createDateEnd">
  144. and `create_date` &lt;= #{createDateEnd}
  145. </if>
  146. <if test=" null != status">
  147. and `status` = #{status}
  148. </if>
  149. <if test=" null != awardsItemIdList ">
  150. and award_itam_id in
  151. <foreach collection="awardsItemIdList" index="index" item="idItem" open="(" separator="," close=")">
  152. #{idItem}
  153. </foreach>
  154. </if>
  155. </select>
  156. <select id="activityItemStatisticsChart" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
  157. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,
  158. IFNULL(sum(award_count),0) as 'itemCount',
  159. IFNULL(sum(award_price),0) as 'itemSumMoney'
  160. FROM wx_offline_activity_grant_item
  161. where 1 = 1
  162. <if test=" null != tenantId and '' != tenantId">
  163. and `tenant_id` = #{tenantId}
  164. </if>
  165. <if test=" null != parentTenantId and '' != parentTenantId">
  166. and `parent_tenant_id` = #{parentTenantId}
  167. </if>
  168. <if test=" null != activityId">
  169. and `activity_id` = #{activityId}
  170. </if>
  171. <if test=" null != activityItemId ">
  172. and `activity_item_id` = #{activityItemId}
  173. </if>
  174. <if test=" null != createDateBegin">
  175. and `create_date` &gt;= #{createDateBegin}
  176. </if>
  177. <if test=" null != createDateEnd">
  178. and `create_date` &lt;= #{createDateEnd}
  179. </if>
  180. <if test=" null != status">
  181. and `status` = #{status}
  182. </if>
  183. <if test=" null != awardsItemIdList ">
  184. and award_itam_id in
  185. <foreach collection="awardsItemIdList" index="index" item="idItem" open="(" separator="," close=")">
  186. #{idItem}
  187. </foreach>
  188. </if>
  189. group by xTime
  190. </select>
  191. <select id="awardsItemStatistics" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineGantItemStatistics">
  192. SELECT award_itam_id as 'awardItamId',
  193. IFNULL(sum(award_count),0) as 'awardItamCount',
  194. IFNULL(sum(award_price),0) as 'sumPrice'
  195. FROM wx_offline_activity_grant_item
  196. where 1 = 1
  197. <if test=" null != tenantId and '' != tenantId">
  198. and `tenant_id` = #{tenantId}
  199. </if>
  200. <if test=" null != parentTenantId and '' != parentTenantId">
  201. and `parent_tenant_id` = #{parentTenantId}
  202. </if>
  203. <if test=" null != activityId">
  204. and `activity_id` = #{activityId}
  205. </if>
  206. <if test=" null != activityItemId ">
  207. and `activity_item_id` = #{activityItemId}
  208. </if>
  209. <if test=" null != createDateBegin">
  210. and `create_date` &gt;= #{createDateBegin}
  211. </if>
  212. <if test=" null != createDateEnd">
  213. and `create_date` &lt;= #{createDateEnd}
  214. </if>
  215. <if test=" null != status">
  216. and `status` = #{status}
  217. </if>
  218. group by award_itam_id
  219. </select>
  220. <update id="updateStatusNo" parameterType="com.iformall.domain.po.WxOfflineActivityGrantAward" >
  221. update wx_offline_activity_grant_item set status = 0,update_date = now()
  222. where grant_id in (
  223. select id from wx_offline_activity_grant_award
  224. where `activity_id` = #{activityId} and `cus_phone` = #{cusPhone} and `id` != #{id})
  225. </update>
  226. </mapper>