Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

1429 wiersze
69 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.WxCouponMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCoupon">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="type" jdbcType="INTEGER" property="type"/>
  9. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  10. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  11. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  12. <result column="title" jdbcType="VARCHAR" property="title"/>
  13. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  14. <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
  15. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  16. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  17. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  18. <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
  19. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  20. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  21. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  22. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  23. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  24. <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
  25. <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
  26. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  27. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  28. <result column="price" jdbcType="INTEGER" property="price"/>
  29. <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
  30. <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
  31. <result column="unit" jdbcType="INTEGER" property="unit"/>
  32. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  33. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  34. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  35. <result column="status" jdbcType="INTEGER" property="status"/>
  36. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  37. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  38. <result column="business" jdbcType="INTEGER" property="business"/>
  39. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  40. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  41. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  42. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  43. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  44. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  45. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  46. <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
  47. <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
  48. <result column="is_del" property="isDel"/>
  49. <result column="put_apply_status" property="putApplyStatus"/>
  50. <result column="stock_apply_status" property="stockApplyStatus"/>
  51. <result column="cancle_apply_status" property="cancleApplyStatus"/>
  52. <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
  53. <result column="approval_type" property="approvalType"/>
  54. <result column="password_support" property="passwordSupport"/>
  55. <result column="content_type" property="contentType"/>
  56. <result column="html" property="html"/>
  57. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  58. <result column="product_type" jdbcType="INTEGER" property="productType"/>
  59. <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
  60. </resultMap>
  61. <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo">
  62. <id column="id" jdbcType="BIGINT" property="id"/>
  63. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  64. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  65. <result column="type" jdbcType="INTEGER" property="type"/>
  66. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  67. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  68. <result column="title" jdbcType="VARCHAR" property="title"/>
  69. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  70. <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
  71. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  72. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  73. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  74. <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
  75. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  76. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  77. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  78. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  79. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  80. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  81. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  82. <result column="price" jdbcType="INTEGER" property="price"/>
  83. <result column="unit" jdbcType="INTEGER" property="unit"/>
  84. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  85. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  86. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  87. <result column="status" jdbcType="INTEGER" property="status"/>
  88. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  89. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  90. <result column="business" jdbcType="INTEGER" property="business"/>
  91. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  92. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  93. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  94. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  95. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  96. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  97. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  98. <result column="sale_count" property="saleCount"/>
  99. <result column="transfer_count" property="transferCount"/>
  100. <result column="sale_amount" property="saleAmount"/>
  101. <result column="sum_payment" property="sumPayment"/>
  102. <result column="press_count" property="pressSendCount"/>
  103. <result column="press_succ_count" property="pressSuccCount"/>
  104. <result column="join_count" property="pressJoinCount"/>
  105. <result column="sum_subsidy" property="sumSubsidy"/>
  106. <result column="payment_rate" property="paymentRate"/>
  107. <result column="change_rate" property="changeRate"/>
  108. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  109. </resultMap>
  110. <sql id="allColumns">
  111. distinct c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`,
  112. c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`,
  113. c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
  114. c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,
  115. c.`press_limit_num`, c.`press_limit_hours`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`,
  116. c.`conditions`,c.approval_type,c.content_type,c.source_type,c.password_support,c.gift_list,c.product_type,c.category_id
  117. </sql>
  118. <sql id="statusColumns">
  119. `id`,`remain_inventory`,`status`
  120. </sql>
  121. <sql id="dynamicWhereConditions">
  122. where 1 = 1
  123. <if test=" null != id ">
  124. and `id` = #{id}
  125. </if>
  126. <if test=" null != tenantId and '' != tenantId">
  127. and `tenant_id` = #{tenantId}
  128. </if>
  129. <if test=" null != parentTenantId and '' != parentTenantId">
  130. and `parent_tenant_id` = #{parentTenantId}
  131. </if>
  132. <if test=" null != type ">
  133. and `type` = #{type}
  134. </if>
  135. <if test=" null != coverImg ">
  136. and `cover_img` like concat('%', #{coverImg},'%')
  137. </if>
  138. <if test=" null != title and ''!=title">
  139. and `title` like concat('%', #{title},'%')
  140. </if>
  141. <if test=" null != subTitle ">
  142. and `sub_title` like concat('%', #{subTitle},'%')
  143. </if>
  144. <if test=" null != salePrice ">
  145. and `sale_price` = #{salePrice}
  146. </if>
  147. <if test=" null != usePrice ">
  148. and `use_price` = #{usePrice}
  149. </if>
  150. <if test=" null != useLimitRule ">
  151. and `use_limit_rule` = #{useLimitRule}
  152. </if>
  153. <if test=" null != useLimitQuantity ">
  154. and `use_limit_quantity` = #{useLimitQuantity}
  155. </if>
  156. <if test=" null != sendType ">
  157. and `send_type` = #{sendType}
  158. </if>
  159. <if test=" null != validType ">
  160. and `valid_type` = #{validType}
  161. </if>
  162. <if test=" null != validStartDate ">
  163. and `valid_start_date` = #{validStartDate}
  164. </if>
  165. <if test=" null != validEndDate ">
  166. and `valid_end_date` = #{validEndDate}
  167. </if>
  168. <if test=" null != validDays ">
  169. and `valid_days` = #{validDays}
  170. </if>
  171. <if test=" null != detail ">
  172. and `detail` like concat('%', #{detail},'%')
  173. </if>
  174. <if test=" null != price ">
  175. and `price` = #{price}
  176. </if>
  177. <if test=" null != unit ">
  178. and `unit` = #{unit}
  179. </if>
  180. <if test=" null != remainInventory ">
  181. and `remain_inventory` = #{remainInventory}
  182. </if>
  183. <if test=" null != inventory ">
  184. and `inventory` = #{inventory}
  185. </if>
  186. <if test=" null != remark ">
  187. and `remark` like concat('%', #{remark},'%')
  188. </if>
  189. <if test=" null != status">
  190. and `status` = #{status}
  191. </if>
  192. <if test=" null != startdate and null!=enddate">
  193. and `create_date` between #{startdate} and #{enddate}
  194. </if>
  195. <if test=" null != updateDate ">
  196. and `update_date` = #{updateDate}
  197. </if>
  198. <if test=" null != business ">
  199. and `business` = #{business}
  200. </if>
  201. <if test=" null != subBusiness ">
  202. and `sub_business` = #{subBusiness}
  203. </if>
  204. <if test=" null != supportTransfer ">
  205. and `support_transfer` = #{supportTransfer}
  206. </if>
  207. <if test=" null != subsidyType ">
  208. and `subsidy_type` = #{subsidyType}
  209. </if>
  210. <if test=" null != subsidyNum ">
  211. and `subsidy_num` = #{subsidyNum}
  212. </if>
  213. <if test=" null != pressLimitNum ">
  214. and `press_limit_num` = #{pressLimitNum}
  215. </if>
  216. <if test=" null != pressLimitHours ">
  217. and `press_limit_hours` = #{pressLimitHours}
  218. </if>
  219. <if test=" null != autoRefund ">
  220. and `auto_refund` = #{autoRefund}
  221. </if>
  222. <if test=" null != creditPrice ">
  223. and `credit_price` = #{creditPrice}
  224. </if>
  225. <if test=" null != userCredit ">
  226. and `credit_price` &lt;= #{userCredit}
  227. </if>
  228. <if test=" null != creditRefund ">
  229. and `credit_refund` = #{creditRefund}
  230. </if>
  231. <if test=" 1 == filterCanPut ">
  232. and `credit_refund` = #{creditRefund}
  233. </if>
  234. <if test=" null != contentType ">
  235. and `content_type` = #{contentType}
  236. </if>
  237. <if test=" null != putApplyStatus and putApplyStatus == 2">
  238. and `put_apply_status` = #{putApplyStatus}
  239. </if>
  240. <if test=" null != putApplyStatus and putApplyStatus == -1">
  241. and `put_apply_status` != 2
  242. </if>
  243. <if test=" null != stockApplyStatus ">
  244. and `stock_apply_status` = #{stockApplyStatus}
  245. </if>
  246. <if test=" null != cancleApplyStatus ">
  247. and `cancle_apply_status` = #{cancleApplyStatus}
  248. </if>
  249. <if test=" null != sourceType ">
  250. and `source_type` = #{sourceType}
  251. </if>
  252. <if test=" null != giftList">
  253. and JSON_CONTAINS(gift_list,json_array(#{giftList}))
  254. </if>
  255. <if test=" null != ids ">
  256. and id in
  257. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  258. #{idItem}
  259. </foreach>
  260. </if>
  261. <if test=" null != notinTypes ">
  262. and type not in
  263. <foreach collection="notinTypes" index="index" item="ntypeItem" open="(" separator="," close=")">
  264. #{ntypeItem}
  265. </foreach>
  266. </if>
  267. <if test=" null != types ">
  268. and type in
  269. <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")">
  270. #{typeItem}
  271. </foreach>
  272. </if>
  273. <if test=" null != sortColumns">order by ${sortColumns}</if>
  274. </sql>
  275. <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  276. select <include refid="allColumns"/> ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
  277. </select>
  278. <resultMap id="AttrsResultMap" type="com.iformall.domain.po.WxCoupon">
  279. <id column="id" jdbcType="BIGINT" property="id"/>
  280. <result column="product_type" jdbcType="INTEGER" property="productType"/>
  281. <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
  282. <result column="product_attrs" jdbcType="VARCHAR" property="productAttrs"/>
  283. <result column="sku_attrs" jdbcType="VARCHAR" property="skuAttrs"/>
  284. </resultMap>
  285. <select id="getAttrsById" parameterType="java.util.HashMap" resultMap="AttrsResultMap">
  286. select id,product_type,category_id,product_attrs,sku_attrs
  287. from wx_coupon where id = #{id} and tenant_id = #{tenantId}
  288. </select>
  289. <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  290. select c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
  291. </select>
  292. <select id="batchGetPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
  293. select c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where tenant_id = #{tenantId}
  294. and id in
  295. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  296. #{idItem}
  297. </foreach>
  298. </select>
  299. <select id="findTenantSimpleList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  300. select id,title,sale_price,use_price,price,tail_price,orig_price,auto_refund,business,subsidy_type,source_type,type,unit,cover_img,
  301. sub_title,item_group,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date
  302. from wx_coupon c where c.`tenant_id` = #{tenantId}
  303. <if test=" null != ids ">
  304. and id in
  305. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  306. #{idItem}
  307. </foreach>
  308. </if>
  309. <if test=" null != types ">
  310. and type in
  311. <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")">
  312. #{typeItem}
  313. </foreach>
  314. </if>
  315. </select>
  316. <select id="findSimpleDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  317. select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,
  318. c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.content_type,c.gift_list,c.support_transfer,c.subsidy_num
  319. from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
  320. </select>
  321. <select id="findCouponCVoDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  322. select c.id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,
  323. c.use_limit_rule,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
  324. c.valid_days,c.detail,c.price,c.tail_price,c.orig_price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
  325. c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions,c.content_type
  326. from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
  327. </select>
  328. <select id="findSimpleDetailList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  329. select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,
  330. c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.content_type
  331. from wx_coupon c
  332. <include refid="dynamicWhereConditions"/>
  333. </select>
  334. <select id="findIdList" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  335. select id
  336. from wx_coupon c
  337. <include refid="dynamicWhereConditions"/>
  338. </select>
  339. <select id="findSendCouponIds" parameterType="java.util.HashMap" resultType="Long">
  340. select id
  341. from wx_coupon where `tenant_id` = #{tenantId}
  342. and ((valid_type=1
  343. <choose>
  344. <when test="expired == 0">
  345. and <![CDATA[ valid_end_date >= now() ]]>
  346. </when>
  347. <when test="expired == 1">
  348. and <![CDATA[ valid_end_date < now() ]]>
  349. </when>
  350. <otherwise>
  351. </otherwise>
  352. </choose>
  353. )
  354. <choose>
  355. <when test="expired == 0">
  356. or <![CDATA[ valid_type = 2 ]]>
  357. </when>
  358. <when test="expired == 1">
  359. </when>
  360. <otherwise>
  361. or <![CDATA[ valid_type = 2 ]]>
  362. </otherwise>
  363. </choose>
  364. )
  365. </select>
  366. <select id="findSendCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  367. select
  368. c.id,c.remain_inventory, c.use_limit_rule,c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,c.valid_type,c.valid_days
  369. from wx_coupon c where c.`tenant_id` = #{tenantId}
  370. <if test=" null != ids ">
  371. and id in
  372. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  373. #{idItem}
  374. </foreach>
  375. </if>
  376. </select>
  377. <delete id="deleteById" parameterType="java.util.HashMap">
  378. update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId}
  379. </delete>
  380. <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  381. select
  382. <include refid="allColumns"/>
  383. from wx_coupon c
  384. <include refid="dynamicWhereConditions"/>
  385. </select>
  386. <update id="updateStockAndValidDate" parameterType="com.iformall.domain.po.WxCoupon">
  387. update wx_coupon
  388. SET
  389. `remain_inventory` = #{remainInventory}, `inventory` = #{inventory},
  390. `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays}
  391. WHERE 1=1
  392. <if test=" null != tenantId and '' != tenantId">
  393. and `tenant_id` = #{tenantId}
  394. </if>
  395. <if test=" null != parentTenantId and '' != parentTenantId">
  396. and `parent_tenant_id` = #{parentTenantId}
  397. </if>
  398. and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory}
  399. </update>
  400. <sql id="dynamicWhereConditionsForCoupon">
  401. where c.is_del = 0
  402. <if test=" null != targetAd ">
  403. and 0 = (select count(*) from wx_coupon_channel cc
  404. where c.`id` = cc.coupon_id
  405. and cc.status = 0
  406. and cc.target_ad = #{targetAd})
  407. </if>
  408. <if test=" null != id ">
  409. and c.`id` = #{id}
  410. </if>
  411. <if test=" null != tenantId and '' != tenantId">
  412. and c.`tenant_id` = #{tenantId}
  413. </if>
  414. <if test=" null != parentTenantId and '' != parentTenantId">
  415. and c.`parent_tenant_id` = #{parentTenantId}
  416. </if>
  417. <if test=" null == type and null == types">
  418. <!-- and ( c.`type` &lt; 7 or c.`type` = 10 ) -->
  419. and c.`type` in (1,2,3,4,5,6,10,11,12,66)
  420. </if>
  421. <if test=" null != type ">
  422. and c.`type` = #{type}
  423. </if>
  424. <if test=" null != coverImg ">
  425. and c.`cover_img` like concat('%', #{coverImg},'%')
  426. </if>
  427. <if test=" null != title and ''!=title">
  428. and c.`title` like concat('%', #{title},'%')
  429. </if>
  430. <if test=" null != subTitle ">
  431. and c.`sub_title` like concat('%', #{subTitle},'%')
  432. </if>
  433. <if test=" null != salePrice ">
  434. and c.`sale_price` = #{salePrice}
  435. </if>
  436. <if test=" null != usePrice ">
  437. and c.`use_price` = #{usePrice}
  438. </if>
  439. <if test=" null != useLimitRule ">
  440. and c.`use_limit_rule` = #{useLimitRule}
  441. </if>
  442. <if test=" null != useLimitQuantity ">
  443. and c.`use_limit_quantity` = #{useLimitQuantity}
  444. </if>
  445. <if test=" null != sendType ">
  446. and c.`send_type` = #{sendType}
  447. </if>
  448. <if test=" null != validType ">
  449. and c.`valid_type` = #{validType}
  450. </if>
  451. <if test=" null != validStartDate ">
  452. and c.`valid_start_date` = #{validStartDate}
  453. </if>
  454. <if test=" null != validEndDate ">
  455. and c.`valid_end_date` = #{validEndDate}
  456. </if>
  457. <if test=" null != validDays ">
  458. and c.`valid_days` = #{validDays}
  459. </if>
  460. <if test=" null != detail ">
  461. and c.`detail` like concat('%', #{detail},'%')
  462. </if>
  463. <if test=" null != price ">
  464. and c.`price` = #{price}
  465. </if>
  466. <if test=" null != unit ">
  467. and c.`unit` = #{unit}
  468. </if>
  469. <if test=" null != remainInventory ">
  470. and c.`remain_inventory` = #{remainInventory}
  471. </if>
  472. <if test=" null != inventory ">
  473. and c.`inventory` = #{inventory}
  474. </if>
  475. <if test=" null != remark ">
  476. and c.`remark` like concat('%', #{remark},'%')
  477. </if>
  478. <if test=" null != status">
  479. and c.`status` = #{status}
  480. </if>
  481. <if test=" null != startdate and null!=enddate">
  482. and c.`create_date` between #{startdate} and #{enddate}
  483. </if>
  484. <if test=" null != updateDate ">
  485. and c.`update_date` = #{updateDate}
  486. </if>
  487. <if test=" null != business ">
  488. and c.`business` = #{business}
  489. </if>
  490. <if test=" null != subBusiness ">
  491. and c.`sub_business` = #{subBusiness}
  492. </if>
  493. <if test=" null != supportTransfer ">
  494. and c.`support_transfer` = #{supportTransfer}
  495. </if>
  496. <if test=" null != subsidyType ">
  497. and c.`subsidy_type` = #{subsidyType}
  498. </if>
  499. <if test=" null != subsidyNum ">
  500. and c.`subsidy_num` = #{subsidyNum}
  501. </if>
  502. <if test=" null != pressLimitNum ">
  503. and c.`press_limit_num` = #{pressLimitNum}
  504. </if>
  505. <if test=" null != pressLimitHours ">
  506. and c.`press_limit_hours` = #{pressLimitHours}
  507. </if>
  508. <if test=" null != autoRefund ">
  509. and c.`auto_refund` = #{autoRefund}
  510. </if>
  511. <if test=" null != contentType ">
  512. and c.`content_type` = #{contentType}
  513. </if>
  514. <if test=" null != putApplyStatus and putApplyStatus == 2">
  515. and c.`put_apply_status` = #{putApplyStatus}
  516. </if>
  517. <if test=" null != putApplyStatus and putApplyStatus == -1">
  518. and c.`put_apply_status` != 2
  519. </if>
  520. <if test=" null != stockApplyStatus ">
  521. and c.`stock_apply_status` = #{stockApplyStatus}
  522. </if>
  523. <if test=" null != cancleApplyStatus ">
  524. and c.`cancle_apply_status` = #{cancleApplyStatus}
  525. </if>
  526. <if test=" null != sourceType ">
  527. and c.`source_type` = #{sourceType}
  528. </if>
  529. <if test=" null != merchantId ">
  530. and cm.`merchant_id` = #{merchantId}
  531. </if>
  532. <if test=" null != giftList">
  533. and JSON_CONTAINS(c.gift_list,json_array(#{giftList}))
  534. </if>
  535. <if test=" null != ids ">
  536. and c.id in
  537. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  538. #{idItem}
  539. </foreach>
  540. </if>
  541. <if test=" null != types ">
  542. and c.type in
  543. <foreach collection="types" index="index" item="typesItem" open="(" separator="," close=")">
  544. #{typesItem}
  545. </foreach>
  546. </if>
  547. <if test=" null != sendTypes ">
  548. and c.send_type in
  549. <foreach collection="sendTypes" index="index" item="typesItem" open="(" separator="," close=")">
  550. #{typesItem}
  551. </foreach>
  552. </if>
  553. <if test=" null != sortColumns">order by ${sortColumns}</if>
  554. </sql>
  555. <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  556. select
  557. <include refid="allColumns"/>
  558. from wx_coupon c
  559. left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0
  560. <include refid="dynamicWhereConditionsForCoupon"/>
  561. <if test="null != limitStart and null != limitEnd">
  562. limit #{limitStart},#{limitEnd}
  563. </if>
  564. </select>
  565. <select id="findCouponListCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Integer">
  566. select
  567. count(distinct c.id)
  568. from wx_coupon c
  569. left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0
  570. <include refid="dynamicWhereConditionsForCoupon"/>
  571. </select>
  572. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  573. <id column="id" jdbcType="BIGINT" property="id"/>
  574. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  575. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  576. <result column="type" jdbcType="INTEGER" property="type"/>
  577. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  578. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  579. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  580. <result column="title" jdbcType="VARCHAR" property="title"/>
  581. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  582. <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
  583. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  584. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  585. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  586. <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
  587. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  588. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  589. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  590. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  591. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  592. <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
  593. <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
  594. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  595. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  596. <result column="price" jdbcType="INTEGER" property="price"/>
  597. <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
  598. <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
  599. <result column="unit" jdbcType="INTEGER" property="unit"/>
  600. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  601. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  602. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  603. <result column="status" jdbcType="INTEGER" property="status"/>
  604. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  605. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  606. <result column="business" jdbcType="INTEGER" property="business"/>
  607. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  608. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  609. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  610. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  611. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  612. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  613. <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
  614. <result column="content_type" jdbcType="INTEGER" property="contentType"/>
  615. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  616. <result column="gift_list" jdbcType="VARCHAR" property="giftList"></result>
  617. <result column="product_type" jdbcType="INTEGER" property="productType"/>
  618. <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
  619. </resultMap>
  620. <resultMap id="WxCouponCVoMapL" type="com.iformall.domain.vo.WxCouponCVo">
  621. <id column="id" jdbcType="BIGINT" property="id"/>
  622. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  623. <result column="type" jdbcType="INTEGER" property="type"/>
  624. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  625. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  626. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  627. <result column="title" jdbcType="VARCHAR" property="title"/>
  628. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  629. <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
  630. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  631. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  632. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  633. <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
  634. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  635. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  636. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  637. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  638. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  639. <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
  640. <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
  641. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  642. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  643. <result column="price" jdbcType="INTEGER" property="price"/>
  644. <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
  645. <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
  646. <result column="unit" jdbcType="INTEGER" property="unit"/>
  647. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  648. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  649. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  650. <result column="status" jdbcType="INTEGER" property="status"/>
  651. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  652. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  653. <result column="business" jdbcType="INTEGER" property="business"/>
  654. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  655. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  656. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  657. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  658. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  659. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  660. <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
  661. <result column="content_type" jdbcType="INTEGER" property="contentType"/>
  662. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  663. </resultMap>
  664. <select id="findVoDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMap">
  665. select
  666. <include refid="allColumns"/>
  667. from wx_coupon c
  668. where id = #{id} and tenant_id =#{tenantId}
  669. </select>
  670. <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMapL">
  671. select id, remain_inventory, status
  672. from wx_coupon
  673. where id = #{id} and tenant_id =#{tenantId}
  674. </select>
  675. <update id="reduceInventory">
  676. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} &gt;= 0
  677. </update>
  678. <update id="backInventory">
  679. update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} &lt;= inventory
  680. </update>
  681. <update id="offExpiriedCouponByValidDate" parameterType="String">
  682. update wx_coupon SET status = 1, update_date = now()
  683. where status = 0 and tenant_id =#{tenantId} and valid_type = 1 and valid_end_date &lt; now()
  684. </update>
  685. <update id="offExpiriedCouponByMerchantStatus" parameterType="HashMap">
  686. update wx_coupon c
  687. SET c.status = 1, c.update_date = now()
  688. where c.status = 0 and c.tenant_id =#{tenantId}
  689. <!-- type=12 礼包卷没有门店 -->
  690. and c.type != 12
  691. <if test=" null != validIds ">
  692. and c.id not in
  693. <foreach collection="validIds" index="index" item="idItem" open="(" separator="," close=")">
  694. #{idItem}
  695. </foreach>
  696. </if>
  697. </update>
  698. <select id="getValidMerchantProductIds" resultType="Long">
  699. select cm.product_id from wx_coupon_merchant cm, wx_merchant m
  700. where m.id = cm.merchant_id
  701. and cm.status = 0
  702. and m.status = 1
  703. </select>
  704. <select id="findSaleMoneyByDate"
  705. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  706. select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
  707. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  708. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  709. </foreach>) c on c.id = ci.coupon_id
  710. where c.type = 100
  711. and ci.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  712. group by xtime
  713. </select>
  714. <select id="findPaymentByDate"
  715. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  716. select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
  717. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  718. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  719. </foreach>) c on c.id = ci.coupon_id
  720. left join wx_card_spend wcs on wcs.card_id = ci.id
  721. where c.type = 100
  722. and wcs.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  723. group by xtime
  724. </select>
  725. <select id="findSaleCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  726. select count(co.id)
  727. from wx_card_info ci
  728. left join wx_coupon c on c.id = ci.coupon_id
  729. left join wx_coupon_order co on co.id = ci.id
  730. where c.type = 100
  731. and co.create_date between #{startdate} and #{enddate}
  732. </select>
  733. <select id="findTranCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  734. select count(distinct wcs.coupon_order_id) from wx_card_info ci
  735. left join wx_coupon c on c.id = ci.coupon_id
  736. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  737. where c.type = 100 and wcs.create_date between #{startdate} and #{enddate}
  738. </select>
  739. <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  740. select sum(round(sc.subsidy/100,2)) from wx_card_info ci
  741. left join wx_coupon c on c.id = ci.coupon_id
  742. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  743. where c.type = 100 and sc.create_date between #{startdate} and #{enddate}
  744. </select>
  745. <select id="findCountData" resultMap="statisMap">
  746. select c.*,
  747. IFNULL(round((select sum(wcs.real_payment) from wx_card_info ci
  748. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  749. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  750. </foreach>) wc on wc.id = ci.coupon_id
  751. left join wx_card_spend wcs on wcs.card_id = ci.id
  752. where wc.id = c.id)/(select sum(ci.sale_amount) from wx_card_info ci
  753. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  754. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  755. </foreach>) wc on wc.id = ci.coupon_id
  756. where wc.id = c.id)*100,2),0) payment_rate,
  757. (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  758. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  759. </foreach>) wc
  760. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  761. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  762. </foreach>) wco on wc.id = wco.coupon_id
  763. where wc.id = c.id) as sale_count,
  764. (select count(distinct wcs.coupon_order_id) from wx_card_info ci
  765. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  766. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  767. </foreach>) wc on wc.id = ci.coupon_id
  768. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  769. where wc.id = c.id) as transfer_count,
  770. (select sum(ci.sale_amount) from wx_card_info ci
  771. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  772. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  773. </foreach>) wc on wc.id = ci.coupon_id
  774. where wc.id = c.id) as sale_amount,
  775. (select sum(wcs.real_payment) from wx_card_info ci
  776. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  777. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  778. </foreach>) wc on wc.id = ci.coupon_id
  779. left join wx_card_spend wcs on wcs.card_id = ci.id
  780. where wc.id = c.id) as sum_payment,
  781. (select sum(sc.subsidy) from wx_card_info ci
  782. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  783. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  784. </foreach>) wc on wc.id = ci.coupon_id
  785. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  786. SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
  787. </foreach>) sc on sc.coupon_order_id = ci.id
  788. where wc.id = c.id) as sum_subsidy
  789. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  790. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  791. </foreach>) c where c.type = 100
  792. <if test="wxCoupon.title != null and wxCoupon.title !=''">
  793. and c.title like concat('%', #{wxCoupon.title},'%')
  794. </if>
  795. <if test="wxCoupon.id != null">
  796. and c.id = #{wxCoupon.id}
  797. </if>
  798. <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
  799. <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
  800. </select>
  801. <select id="findCouponData" resultMap="statisMap">
  802. select c.*,
  803. IFNULL(round((select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  804. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  805. </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  806. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  807. </foreach>) wco where wco.coupon_id = wc.id and
  808. wco.coupon_order_status = 1 and wc.id = c.id)/(select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  809. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  810. </foreach>) wco where wco.coupon_id
  811. = c.id)*100,2),0) payment_rate,
  812. (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  813. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  814. </foreach>) wco where wco.coupon_id = c.id) as sale_count,
  815. (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  816. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  817. </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  818. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  819. </foreach>) wco where wco.coupon_id = wc.id and
  820. wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
  821. (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  822. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  823. </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  824. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  825. </foreach>) wco where wco.coupon_id = wc.id and
  826. wco.coupon_order_status = 3 and wc.id = c.id) as backpay_count,
  827. (select sum(sc.subsidy) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  828. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  829. </foreach>) wc
  830. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  831. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  832. </foreach>) wo on wo.coupon_id = wc.id
  833. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  834. SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
  835. </foreach>) sc on sc.coupon_order_id = wo.id
  836. where wc.id = c.id) as sum_subsidy
  837. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  838. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  839. </foreach>) c where c.type not in(8,9,100)
  840. <if test=" 1 == wxCoupon.type ">
  841. and c.sale_price > 0
  842. </if>
  843. <if test=" 2 == wxCoupon.type ">
  844. and c.sale_price = 0
  845. </if>
  846. <if test="wxCoupon.title != null and wxCoupon.title != ''">
  847. and c.title like concat('%', #{wxCoupon.title},'%')
  848. </if>
  849. <if test="wxCoupon.id != null">
  850. and c.id = #{wxCoupon.id}
  851. </if>
  852. <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
  853. <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
  854. </select>
  855. <select id="findPressData" resultMap="statisMap">
  856. select c.id,c.tenant_id, c.`cover_img`,c.`title`,c.`sale_price`,c.`freight_price`,c.`price`,
  857. ifnull(op.press_count,0) as press_count,
  858. ifnull(o.press_succ_count,0) as press_succ_count,
  859. ifnull(op2.join_count,0) as join_count,
  860. ifnull(round(o.press_succ_count/op.press_count*100,2),0) as change_rate,
  861. ifnull(round(cop.xCount/op.press_count*100,2),0) as payment_rate
  862. FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  863. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  864. </foreach>) c
  865. left join (SELECT count(id) as press_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  866. SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
  867. </foreach>) wx_order_press WHERE `first` = 1
  868. <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
  869. and `tenant_id` = #{wxCoupon.tenantId}
  870. </if>
  871. <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
  872. and `parent_tenant_id` = #{wxCoupon.parentTenantId}
  873. </if>
  874. group by coupon_id) op on op.coupon_id = c.id
  875. left join (SELECT count(id) as press_succ_count, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  876. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  877. </foreach>) wx_order WHERE order_status = 1
  878. <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
  879. and `tenant_id` = #{wxCoupon.tenantId}
  880. </if>
  881. <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
  882. and `parent_tenant_id` = #{wxCoupon.parentTenantId}
  883. </if>
  884. group by product_id) o on o.product_id = c.id
  885. left join (SELECT count(id) as join_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  886. SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
  887. </foreach>) wx_order_press WHERE 1=1
  888. <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
  889. and `tenant_id` = #{wxCoupon.tenantId}
  890. </if>
  891. <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
  892. and `parent_tenant_id` = #{wxCoupon.parentTenantId}
  893. </if>
  894. group by coupon_id) op2 on op2.coupon_id = c.id
  895. left join (SELECT count(id) as xCount, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  896. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  897. </foreach>) wx_coupon_order WHERE coupon_order_status = 1
  898. <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
  899. and `tenant_id` = #{wxCoupon.tenantId}
  900. </if>
  901. <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
  902. and `parent_tenant_id` = #{wxCoupon.parentTenantId}
  903. </if>
  904. group by coupon_id) cop on cop.coupon_id = c.id
  905. where c.type = 8
  906. <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
  907. and c.`tenant_id` = #{wxCoupon.tenantId}
  908. </if>
  909. <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
  910. and c.`parent_tenant_id` = #{wxCoupon.parentTenantId}
  911. </if>
  912. <if test="wxCoupon.id != null">
  913. and c.id = #{wxCoupon.id}
  914. </if>
  915. <if test="wxCoupon.title != null and wxCoupon.title != ''">
  916. and c.title like concat('%', #{wxCoupon.title},'%')
  917. </if>
  918. <if test=" null != wxCoupon.startdate and null!=wxCoupon.enddate">
  919. and c.`create_date` between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  920. </if>
  921. <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
  922. <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
  923. </select>
  924. <select id="findCouponOrderCount"
  925. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  926. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
  927. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  928. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  929. </foreach>) c
  930. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  931. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  932. </foreach>) wco on c.id = wco.coupon_id
  933. where c.type not in(8,9,100)
  934. and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  935. group by xtime
  936. </select>
  937. <select id="findCouponPaymentCount"
  938. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  939. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
  940. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  941. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  942. </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  943. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  944. </foreach>) wco
  945. where c.type not in(8,9,100)
  946. and wco.coupon_id = c.id and wco.coupon_order_status = 1
  947. and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  948. group by xtime
  949. </select>
  950. <select id="priceCouponSaleCount"
  951. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  952. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
  953. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  954. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  955. </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  956. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  957. </foreach>) wco
  958. where c.type not in(8,9,100)
  959. and wco.coupon_id = c.id and wco.coupon_price > 0
  960. and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  961. group by xtime
  962. </select>
  963. <select id="priceCouponPaymentCount"
  964. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  965. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
  966. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  967. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  968. </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  969. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  970. </foreach>) wco
  971. where c.type not in(8,9,100)
  972. and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
  973. and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  974. group by xtime
  975. </select>
  976. <select id="findSumPriceSaleMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  977. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  978. where wco.coupon_id = c.id and wco.coupon_price > 0
  979. and wco.create_date between #{startdate} and #{enddate}
  980. </select>
  981. <select id="findSumPricePayMent" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  982. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  983. where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
  984. and wco.update_date between #{startdate} and #{enddate}
  985. </select>
  986. <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  987. select sum(round(sc.subsidy/100,2)) from wx_coupon c
  988. left join wx_coupon_order wo on wo.coupon_id = c.id
  989. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  990. where c.type not in(8,9,100) and wo.coupon_order_status = 1
  991. and sc.create_date between #{startdate} and #{enddate}
  992. </select>
  993. <!--砍价-->
  994. <select id="pressSendHistory"
  995. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  996. select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  997. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  998. </foreach>) wc
  999. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1000. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  1001. </foreach>) wo on wo.product_id = wc.id
  1002. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1003. SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
  1004. </foreach>) wop on wop.order_id = wo.id
  1005. where wc.type = 8 and wop.first = 1 and
  1006. wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1007. group by xtime
  1008. </select>
  1009. <select id="pressSuccHistory"
  1010. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  1011. select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount
  1012. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1013. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  1014. </foreach>) wc
  1015. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1016. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  1017. </foreach>) wo on wo.product_id = wc.id
  1018. where wc.type = 8 and wo.order_status = 1
  1019. and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1020. group by xtime
  1021. </select>
  1022. <select id="pressPaymentHistory"
  1023. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  1024. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
  1025. from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1026. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  1027. </foreach>) wc
  1028. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1029. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  1030. </foreach>) wco on wco.coupon_id = wc.id
  1031. where wc.type = 8 and wco.coupon_order_status = 1
  1032. and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1033. group by xtime
  1034. </select>
  1035. <select id="pressSuccRate" resultType="java.lang.String">
  1036. select
  1037. round(
  1038. (select count(wo.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1039. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  1040. </foreach>) wc
  1041. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1042. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  1043. </foreach>) wo on wo.product_id = wc.id
  1044. where wo.order_status = 1 and wc.type = 8
  1045. and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1046. )
  1047. /
  1048. (select count(wop.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1049. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  1050. </foreach>) wc
  1051. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1052. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  1053. </foreach>) wo on wo.product_id = wc.id
  1054. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1055. SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
  1056. </foreach>) wop on wop.order_id = wo.id
  1057. where wop.first = 1 and wc.type = 8
  1058. and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1059. )
  1060. * 100
  1061. ,2)
  1062. </select>
  1063. <select id="sumJoin" resultType="Long">
  1064. select count(wop.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1065. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  1066. </foreach>) wc
  1067. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1068. SELECT * from wx_order${tenantEntity.shardTableSuffix}
  1069. </foreach>) wo on wo.product_id = wc.id
  1070. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1071. SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
  1072. </foreach>) wop on wop.order_id = wo.id
  1073. where wc.type = 8
  1074. and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1075. </select>
  1076. <select id="priceCouponCancelCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  1077. select count(c.id) from wx_coupon c
  1078. left join wx_coupon_order wco on c.id = wco.coupon_id
  1079. where c.type not in(8,9,100)
  1080. and wco.create_date between #{startdate} and #{enddate}
  1081. and wco.coupon_order_status = 3
  1082. </select>
  1083. <select id="findSaleCardCountHistory"
  1084. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  1085. select DATE_FORMAT(co.create_date,'%Y-%m-%d') xtime,count(co.id) xcount
  1086. from wx_card_info ci
  1087. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1088. SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
  1089. </foreach>) c on c.id = ci.coupon_id
  1090. left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
  1091. SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
  1092. </foreach>) co on co.id = ci.id
  1093. where c.type = 100
  1094. and co.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
  1095. group by xtime
  1096. </select>
  1097. <select id="findCouponByTopic" parameterType="com.iformall.domain.po.WxTopic"
  1098. resultType="com.iformall.domain.po.WxCoupon">
  1099. select ct.id as id,wc.id as couponId,
  1100. wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`item_group`,wc.`sale_price`,wc.`freight_price`,wc.`use_price`,wc.`use_limit_rule`,wc.`use_limit_quantity`,wc.`send_type`,
  1101. wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.pick_start_date,wc.pick_end_date,wc.`valid_days`,wc.`detail`,wc.`price`,wc.tail_price,wc.orig_price,wc.`unit`,wc.`remain_inventory`,wc.`inventory`,
  1102. wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`,
  1103. wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`,
  1104. wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId
  1105. from wx_coupon_channel ct
  1106. left join wx_coupon wc on wc.id = ct.coupon_id
  1107. where ct.`sub_target_id` = #{id} and ct.status = 0
  1108. </select>
  1109. <select id="findCouponModel" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  1110. select
  1111. max(case type when 9 then model_id else 0 end) couponModelId,
  1112. max(case type when 10 then model_id else 0 end) cardModelId,
  1113. max(case type when 11 then model_id else 0 end) groupModelId,
  1114. max(case type when 12 then model_id else 0 end) pressModelId
  1115. from wx_flow_config
  1116. where type in(9,10,11,12)
  1117. <if test=" null != tenantId and '' != tenantId">
  1118. and `tenant_id` = #{tenantId}
  1119. </if>
  1120. <if test=" null != parentTenantId and '' != parentTenantId">
  1121. and `parent_tenant_id` = #{parentTenantId}
  1122. </if>
  1123. </select>
  1124. <update id="updateValidEndDate" parameterType="com.iformall.domain.po.WxCoupon">
  1125. update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id}
  1126. </update>
  1127. <select id="newfindCList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  1128. select id,remain_inventory,inventory,cover_img,title,sub_title,item_group,sale_price,use_price,price,tail_price,
  1129. orig_price,unit,use_limit_rule,use_limit_quantity,send_type,support_transfer,press_limit_num,auto_refund,
  1130. conditions,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date,valid_days,credit_price,
  1131. content_type,source_type
  1132. from wx_coupon where `tenant_id` = #{tenantId}
  1133. <if test=" null != id ">
  1134. and `id` = #{id}
  1135. </if>
  1136. <if test=" null != business ">
  1137. and `business` = #{business}
  1138. </if>
  1139. <if test=" null != subBusiness ">
  1140. and `sub_business` = #{subBusiness}
  1141. </if>
  1142. <if test=" null != ids ">
  1143. and id in
  1144. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  1145. #{idItem}
  1146. </foreach>
  1147. </if>
  1148. </select>
  1149. <select id="findIdsListHasConditons" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  1150. select c.id
  1151. from wx_coupon c
  1152. where c.`tenant_id` = #{tenantId} and c.conditions is not null
  1153. /*and JSON_EXTRACT(c.conditions, '$.type') = 1*/
  1154. <if test=" null != parentTenantId and '' != parentTenantId">
  1155. and c.`parent_tenant_id` = #{parentTenantId}
  1156. </if>
  1157. </select>
  1158. <resultMap id="TtCouponVoResultMap" type="com.iformall.domain.vo.TtCouponVo">
  1159. <id column="id" jdbcType="BIGINT" property="id"/>
  1160. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  1161. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  1162. <result column="type" jdbcType="INTEGER" property="type"/>
  1163. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  1164. <result column="title" jdbcType="VARCHAR" property="title"/>
  1165. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  1166. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  1167. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  1168. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  1169. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  1170. <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
  1171. <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
  1172. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  1173. <result column="price" jdbcType="INTEGER" property="price"/>
  1174. <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
  1175. <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
  1176. <result column="unit" jdbcType="INTEGER" property="unit"/>
  1177. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  1178. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  1179. <result column="status" jdbcType="INTEGER" property="status"/>
  1180. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  1181. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  1182. <result column="business" jdbcType="INTEGER" property="business"/>
  1183. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  1184. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  1185. <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
  1186. <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
  1187. <result column="content_type" property="contentType"/>
  1188. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  1189. <result column="product_type" jdbcType="INTEGER" property="productType"/>
  1190. <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
  1191. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  1192. <result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
  1193. <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/>
  1194. <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>
  1195. <result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
  1196. <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>
  1197. </resultMap>
  1198. <select id="ttgoodslist" parameterType="com.iformall.domain.vo.TtCouponVo" resultMap="TtCouponVoResultMap">
  1199. select c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`,
  1200. c.`title`,c.`sub_title`,c.`sale_price`,c.`freight_price`,c.`send_type`,
  1201. c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,
  1202. c.`valid_days`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
  1203. c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,
  1204. c.`auto_refund`,c.`credit_price`,c.`credit_refund`,
  1205. c.content_type,c.source_type,c.product_type,c.category_id,
  1206. poi.coupon_channel_id,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
  1207. from wx_coupon c
  1208. left join tt_coupon_channel_poi poi on poi.id = c.id
  1209. where c.`type` = #{type}
  1210. <if test=" null != id ">
  1211. and c.`id` = #{id}
  1212. </if>
  1213. <if test=" null != tenantId and '' != tenantId">
  1214. and c.`tenant_id` = #{tenantId}
  1215. </if>
  1216. <if test=" null != parentTenantId and '' != parentTenantId">
  1217. and c.`parent_tenant_id` = #{parentTenantId}
  1218. </if>
  1219. <if test=" null != title and ''!=title">
  1220. and c.`title` like concat('%', #{title},'%')
  1221. </if>
  1222. <if test=" null != sendType ">
  1223. and c.`send_type` = #{sendType}
  1224. </if>
  1225. <if test=" null != status">
  1226. and c.`status` = #{status}
  1227. </if>
  1228. <if test=" null != startdate and null!=enddate">
  1229. and c.`create_date` between #{startdate} and #{enddate}
  1230. </if>
  1231. <if test=" null != sourceType ">
  1232. and c.`source_type` = #{sourceType}
  1233. </if>
  1234. <if test=" null != couponChannelId ">
  1235. and poi.`coupon_channel_id` = #{couponChannelId}
  1236. </if>
  1237. <if test=" null != spuId and '' != spuId">
  1238. and poi.`spu_id` = #{spuId}
  1239. </if>
  1240. <if test=" null != poiStatus">
  1241. and poi.`status` = #{poiStatus}
  1242. </if>
  1243. <if test=" null != lastStatus">
  1244. and poi.`last_status` = #{lastStatus}
  1245. </if>
  1246. <if test=" null != sortColumns">order by ${sortColumns}</if>
  1247. </select>
  1248. </mapper>