Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

384 linhas
16 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.WxOfflineActivityGrantSettlementMapper">
  6. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOfflineActivityGrantSettlement">
  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="recordId" column="record_id" jdbcType="BIGINT"/>
  11. <result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
  12. <result property="orderMoney" column="order_money" jdbcType="DECIMAL"/>
  13. <result property="merchantId" column="merchant_id" jdbcType="BIGINT"/>
  14. <result property="activityId" column="activity_id" jdbcType="BIGINT"/>
  15. <result property="activityItemId" column="activity_item_id" jdbcType="BIGINT"/>
  16. <result property="awardItamId" column="award_itam_id" jdbcType="BIGINT"/>
  17. <result property="grantId" column="grant_id" jdbcType="BIGINT"/>
  18. <result property="grantItemId" column="grant_item_id" jdbcType="BIGINT"/>
  19. <result property="grantAwardsMode" column="grant_awards_mode" jdbcType="SMALLINT"/>
  20. <result property="grantPrice" column="grant_price" jdbcType="DECIMAL"/>
  21. <result property="mallShareRate" column="mall_share_rate" jdbcType="DECIMAL"/>
  22. <result property="merchantShareRate" column="merchant_share_rate" jdbcType="DECIMAL"/>
  23. <result property="orderRatio" column="order_ratio" jdbcType="DECIMAL"/>
  24. <result property="realGrantPrice" column="real_grant_price" jdbcType="DECIMAL"/>
  25. <result property="realMallSharePrice" column="real_mall_share_price" jdbcType="DECIMAL"/>
  26. <result property="realMerchantSharePrice" column="real_merchant_share_price" jdbcType="DECIMAL"/>
  27. <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
  28. <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
  29. <result property="status" column="status" jdbcType="INTEGER"/>
  30. </resultMap>
  31. <sql id="allColumns">
  32. id,tenant_id,parent_tenant_id,
  33. record_id,order_no,order_money,
  34. merchant_id,activity_id,activity_item_id,
  35. award_itam_id,grant_id,grant_item_id,grant_awards_mode,grant_price,
  36. mall_share_rate,merchant_share_rate,order_ratio,
  37. real_grant_price,real_mall_share_price,real_merchant_share_price,
  38. create_date,update_date
  39. </sql>
  40. <sql id="dynamicWhereConditions">
  41. where 1 = 1
  42. <if test=" null != id ">
  43. and `id` = #{id}
  44. </if>
  45. <if test=" null != tenantId and '' != tenantId">
  46. and `tenant_id` = #{tenantId}
  47. </if>
  48. <if test=" null != parentTenantId and '' != parentTenantId">
  49. and `parent_tenant_id` = #{parentTenantId}
  50. </if>
  51. <if test=" null != recordId ">
  52. and `record_id` = #{recordId}
  53. </if>
  54. <if test=" null != orderNo and orderNo != '' ">
  55. and `order_no` like concat('%', #{orderNo},'%')
  56. </if>
  57. <if test=" null != merchantId ">
  58. and `merchant_id` = #{merchantId}
  59. </if>
  60. <if test=" null != activityId ">
  61. and `activity_id` = #{activityId}
  62. </if>
  63. <if test=" null != activityItemId ">
  64. and `activity_item_id` = #{activityItemId}
  65. </if>
  66. <if test=" null != awardItamId ">
  67. and `award_itam_id` = #{awardItamId}
  68. </if>
  69. <if test=" null != grantId ">
  70. and `grant_id` = #{grantId}
  71. </if>
  72. <if test=" null != grantItemId ">
  73. and `grant_item_id` = #{grantItemId}
  74. </if>
  75. <if test=" null != grantAwardsMode">
  76. and `grant_awards_mode` = #{grantAwardsMode}
  77. </if>
  78. <if test=" null != createDateBegin">
  79. and `create_date` &gt;= #{createDateBegin}
  80. </if>
  81. <if test=" null != createDateEnd">
  82. and `create_date` &lt;= #{createDateEnd}
  83. </if>
  84. <if test=" null != status">
  85. and `status` = #{status}
  86. </if>
  87. <if test=" null != merchantIdList ">
  88. and merchant_id in
  89. <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
  90. #{midItem}
  91. </foreach>
  92. </if>
  93. <if test=" null != ids ">
  94. and id in
  95. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  96. #{idItem}
  97. </foreach>
  98. </if>
  99. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  100. </sql>
  101. <select id="findList" parameterType="com.iformall.domain.po.WxOfflineActivityGrantSettlement" resultMap="BaseResultMap">
  102. select <include refid="allColumns" /> from wx_offline_activity_grant_settlement
  103. <include refid="dynamicWhereConditions" />
  104. </select>
  105. <insert id="insertList" parameterType="java.util.List">
  106. insert into wx_offline_activity_grant_settlement
  107. (id,
  108. record_id,order_no,order_money,
  109. merchant_id,activity_id,activity_item_id,
  110. award_itam_id,grant_id,grant_item_id,grant_awards_mode,grant_price,
  111. mall_share_rate,merchant_share_rate,order_ratio,
  112. real_grant_price,real_mall_share_price,real_merchant_share_price,
  113. create_date,update_date)
  114. values
  115. <foreach collection="settlementList" item="item" index="index" separator=",">
  116. (#{item.id,jdbcType=BIGINT},
  117. #{item.recordId,jdbcType=BIGINT},#{item.orderNo,jdbcType=VARCHAR},#{item.orderMoney,jdbcType=DECIMAL},
  118. #{item.merchantId,jdbcType=BIGINT},#{item.activityId,jdbcType=BIGINT},#{item.activityItemId,jdbcType=BIGINT},
  119. #{item.awardItamId,jdbcType=BIGINT},#{item.grantId,jdbcType=BIGINT},#{item.grantItemId,jdbcType=BIGINT},#{item.grantAwardsMode,jdbcType=INTEGER},#{item.grantPrice,jdbcType=DECIMAL},
  120. #{item.mallShareRate,jdbcType=DECIMAL},#{item.merchantShareRate,jdbcType=DECIMAL},#{item.orderRatio,jdbcType=DECIMAL},
  121. #{item.realGrantPrice,jdbcType=DECIMAL},#{item.realMallSharePrice,jdbcType=DECIMAL},#{item.realMerchantSharePrice,jdbcType=DECIMAL},
  122. #{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP})
  123. </foreach>
  124. </insert>
  125. <select id="settlementStatistics" parameterType="com.iformall.domain.po.WxOfflineActivityGrantSettlement" resultType="com.iformall.domain.vo.OfflineActivitySettlementStatistics">
  126. SELECT IFNULL(sum(real_grant_price),0) as 'sumGrantPrice',
  127. count(DISTINCT record_id) as 'recordCount',
  128. count(DISTINCT merchant_id) as 'merchantCount',
  129. IFNULL(sum(real_mall_share_price),0) as 'sumMallPrice',
  130. IFNULL(sum(real_merchant_share_price),0) as 'sumMerchantPrice'
  131. FROM wx_offline_activity_grant_settlement
  132. where 1 = 1
  133. <if test=" null != tenantId and '' != tenantId">
  134. and `tenant_id` = #{tenantId}
  135. </if>
  136. <if test=" null != parentTenantId and '' != parentTenantId">
  137. and `parent_tenant_id` = #{parentTenantId}
  138. </if>
  139. <if test=" null != activityId">
  140. and `activity_id` = #{activityId}
  141. </if>
  142. <if test=" null != activityItemId ">
  143. and `activity_item_id` = #{activityItemId}
  144. </if>
  145. <if test=" null != createDateBegin">
  146. and `create_date` &gt;= #{createDateBegin}
  147. </if>
  148. <if test=" null != createDateEnd">
  149. and `create_date` &lt;= #{createDateEnd}
  150. </if>
  151. <if test=" null != status">
  152. and `status` = #{status}
  153. </if>
  154. </select>
  155. <select id="getActivitySettlement" parameterType="com.iformall.domain.vo.OfflineActivitySettlement" resultType="com.iformall.domain.vo.OfflineActivitySettlement">
  156. SELECT merchant_id as 'merchantId',
  157. activity_id as 'activityId',
  158. count(record_id) as 'recordCount',
  159. IFNULL(sum(order_money),0) as 'sumOrderMoney',
  160. IFNULL(sum(real_grant_price),0) as 'sumGrantPrice',
  161. IFNULL(sum(real_mall_share_price),0) as 'sumMallPrice',
  162. IFNULL(sum(real_merchant_share_price),0) as 'sumMerchantPrice'
  163. FROM wx_offline_activity_grant_settlement
  164. where `activity_id` = #{activityId}
  165. <if test=" null != id ">
  166. and `id` = #{id}
  167. </if>
  168. <if test=" null != tenantId and '' != tenantId">
  169. and `tenant_id` = #{tenantId}
  170. </if>
  171. <if test=" null != parentTenantId and '' != parentTenantId">
  172. and `parent_tenant_id` = #{parentTenantId}
  173. </if>
  174. <if test=" null != merchantId ">
  175. and `merchant_id` = #{merchantId}
  176. </if>
  177. <if test=" null != status">
  178. and `status` = #{status}
  179. </if>
  180. <if test=" null != merchantIdList ">
  181. and merchant_id in
  182. <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
  183. #{midItem}
  184. </foreach>
  185. </if>
  186. group by merchant_id
  187. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  188. </select>
  189. <select id="activityItemStatistics" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
  190. SELECT count(DISTINCT grant_id) as 'grantCount',
  191. count(DISTINCT record_id) as 'orderCount',
  192. IFNULL(sum(real_grant_price),0) as 'itemSumMoney',
  193. IFNULL(sum(real_mall_share_price),0) as 'mallSumPrice',
  194. IFNULL(sum(real_merchant_share_price),0) as 'merchantSumPrice'
  195. FROM wx_offline_activity_grant_settlement
  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. <if test=" null != awardsItemIdList ">
  219. and award_itam_id in
  220. <foreach collection="awardsItemIdList" index="index" item="idItem" open="(" separator="," close=")">
  221. #{idItem}
  222. </foreach>
  223. </if>
  224. </select>
  225. <select id="activityItemStatisticsChart" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
  226. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,
  227. count(DISTINCT grant_id) as 'grantCount',
  228. count(DISTINCT record_id) as 'orderCount',
  229. IFNULL(sum(real_grant_price),0) as 'itemSumMoney',
  230. IFNULL(sum(real_mall_share_price),0) as 'mallSumPrice',
  231. IFNULL(sum(real_merchant_share_price),0) as 'merchantSumPrice'
  232. FROM wx_offline_activity_grant_settlement
  233. where 1 = 1
  234. <if test=" null != tenantId and '' != tenantId">
  235. and `tenant_id` = #{tenantId}
  236. </if>
  237. <if test=" null != parentTenantId and '' != parentTenantId">
  238. and `parent_tenant_id` = #{parentTenantId}
  239. </if>
  240. <if test=" null != activityId">
  241. and `activity_id` = #{activityId}
  242. </if>
  243. <if test=" null != activityItemId ">
  244. and `activity_item_id` = #{activityItemId}
  245. </if>
  246. <if test=" null != createDateBegin">
  247. and `create_date` &gt;= #{createDateBegin}
  248. </if>
  249. <if test=" null != createDateEnd">
  250. and `create_date` &lt;= #{createDateEnd}
  251. </if>
  252. <if test=" null != status">
  253. and `status` = #{status}
  254. </if>
  255. <if test=" null != awardsItemIdList ">
  256. and award_itam_id in
  257. <foreach collection="awardsItemIdList" index="index" item="idItem" open="(" separator="," close=")">
  258. #{idItem}
  259. </foreach>
  260. </if>
  261. group by xTime
  262. </select>
  263. <update id="updateStatusNo" parameterType="com.iformall.domain.po.WxOfflineActivityGrantAward" >
  264. update wx_offline_activity_grant_settlement set status = 0,update_date = now()
  265. where grant_id in (
  266. select id from wx_offline_activity_grant_award
  267. where `activity_id` = #{activityId} and `cus_phone` = #{cusPhone} and `id` != #{id})
  268. </update>
  269. <!-- <select id="findAwardItemGrantList" parameterType="com.iformall.domain.po.WxOfflineActivityGrantSettlement" resultType="com.iformall.domain.vo.OfflineActivityGrantItemVo">-->
  270. <!-- select gi.grant_id,-->
  271. <!-- gi.activity_id,gi.activity_name,-->
  272. <!-- gi.activity_item_id,gi.activity_item_name,-->
  273. <!-- gi.award_itam_id,gi.award_name,-->
  274. <!-- gi.cash_back_ratio,gi.award_price,gi.award_count,-->
  275. <!-- gi.starting_tax_point,gi.tax_points,gi.tax_points_amount,-->
  276. <!-- gi.mall_share_rate,gi.merchant_share_rate,-->
  277. <!-- gs.record_id,-->
  278. <!-- gs.grant_item_id,-->
  279. <!-- gs.order_no,gs.order_money,-->
  280. <!-- gs.merchant_id,-->
  281. <!-- gs.real_grant_price,-->
  282. <!-- gs.real_mall_share_price,gs.real_merchant_share_price-->
  283. <!-- from wx_offline_activity_grant_item gi-->
  284. <!-- inner join wx_offline_activity_grant_settlement gs on gs.grant_item_id = gi.id and gs.record_id = gi.record_id-->
  285. <!-- where gi.status = 1 and gi.grant_awards_mode = 1 and gi.record_id is not null-->
  286. <!-- <if test=" null != tenantId and '' != tenantId">-->
  287. <!-- and gi.`tenant_id` = #{tenantId}-->
  288. <!-- </if>-->
  289. <!-- <if test=" null != parentTenantId and '' != parentTenantId">-->
  290. <!-- and gi.`parent_tenant_id` = #{parentTenantId}-->
  291. <!-- </if>-->
  292. <!-- <if test=" null != activityItemId ">-->
  293. <!-- and gi.`activity_item_id` = #{activityItemId}-->
  294. <!-- </if>-->
  295. <!-- <if test=" null != awardItamId ">-->
  296. <!-- and gi.`award_itam_id` = #{awardItamId}-->
  297. <!-- </if>-->
  298. <!-- <if test=" null != minMoney">-->
  299. <!-- and gs.`order_money` &gt;= #{minMoney}-->
  300. <!-- </if>-->
  301. <!-- <if test=" null != maxMoney">-->
  302. <!-- and gs.`order_money` &lt; #{maxMoney}-->
  303. <!-- </if>-->
  304. <!-- order by gi.`create_date` desc-->
  305. <!-- </select>-->
  306. <select id="findAwardItemGrantList" resultType="com.iformall.domain.vo.OfflineActivityGrantItemVo">
  307. select gi.grant_id,
  308. gi.activity_id,gi.activity_name,
  309. gi.activity_item_id,gi.activity_item_name,
  310. gi.award_itam_id,gi.award_name,
  311. gi.cash_back_ratio,gi.award_price,gi.award_count,
  312. gi.starting_tax_point,gi.tax_points,gi.tax_points_amount,
  313. gi.mall_share_rate,gi.merchant_share_rate,
  314. gs.record_id,
  315. gs.grant_item_id,
  316. gs.order_no,gs.order_money,
  317. gs.merchant_id,
  318. gs.real_grant_price,
  319. gs.real_mall_share_price,gs.real_merchant_share_price
  320. from wx_offline_activity_grant_settlement gs
  321. left join wx_offline_activity_grant_item gi on gs.grant_item_id = gi.id
  322. where gi.status = 1
  323. and gi.grant_awards_mode = #{grantAwardsMode}
  324. <if test=" null != tenantId and '' != tenantId">
  325. and gi.`tenant_id` = #{tenantId}
  326. </if>
  327. <if test=" null != parentTenantId and '' != parentTenantId">
  328. and gi.`parent_tenant_id` = #{parentTenantId}
  329. </if>
  330. <if test=" null != activityItemId ">
  331. and gi.`activity_item_id` = #{activityItemId}
  332. </if>
  333. <if test=" null != awardItamId ">
  334. and gi.`award_itam_id` = #{awardItamId}
  335. </if>
  336. <if test=" null != minMoney">
  337. and gs.`order_money` &gt;= #{minMoney}
  338. </if>
  339. <if test=" null != maxMoney">
  340. and gs.`order_money` &lt; #{maxMoney}
  341. </if>
  342. order by gi.`create_date` desc
  343. </select>
  344. </mapper>