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.
 
 
 
 
 

1038 lines
46 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="sale_price" jdbcType="INTEGER" property="salePrice"/>
  15. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  16. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  17. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  18. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  19. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  20. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  21. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  22. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  23. <result column="price" jdbcType="INTEGER" property="price"/>
  24. <result column="unit" jdbcType="INTEGER" property="unit"/>
  25. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  26. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  27. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  28. <result column="status" jdbcType="INTEGER" property="status"/>
  29. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  30. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  31. <result column="business" jdbcType="INTEGER" property="business"/>
  32. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  33. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  34. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  35. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  36. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  37. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  38. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  39. <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
  40. <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
  41. <result column="is_del" property="isDel"/>
  42. <result column="put_apply_status" property="putApplyStatus"/>
  43. <result column="stock_apply_status" property="stockApplyStatus"/>
  44. <result column="cancle_apply_status" property="cancleApplyStatus"/>
  45. <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
  46. <result column="approval_type" property="approvalType"/>
  47. <result column="password_support" property="passwordSupport"/>
  48. <result column="content_type" property="contentType"/>
  49. <result column="html" property="html"/>
  50. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  51. </resultMap>
  52. <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo">
  53. <id column="id" jdbcType="BIGINT" property="id"/>
  54. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  55. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  56. <result column="type" jdbcType="INTEGER" property="type"/>
  57. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  58. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  59. <result column="title" jdbcType="VARCHAR" property="title"/>
  60. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  61. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  62. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  63. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  64. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  65. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  66. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  67. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  68. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  69. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  70. <result column="price" jdbcType="INTEGER" property="price"/>
  71. <result column="unit" jdbcType="INTEGER" property="unit"/>
  72. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  73. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  74. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  75. <result column="status" jdbcType="INTEGER" property="status"/>
  76. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  77. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  78. <result column="business" jdbcType="INTEGER" property="business"/>
  79. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  80. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  81. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  82. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  83. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  84. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  85. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  86. <result column="sale_count" property="saleCount"/>
  87. <result column="transfer_count" property="transferCount"/>
  88. <result column="sale_amount" property="saleAmount"/>
  89. <result column="sum_payment" property="sumPayment"/>
  90. <result column="press_count" property="pressSendCount"/>
  91. <result column="press_succ_count" property="pressSuccCount"/>
  92. <result column="join_count" property="pressJoinCount"/>
  93. <result column="sum_subsidy" property="sumSubsidy"/>
  94. <result column="payment_rate" property="paymentRate"/>
  95. <result column="change_rate" property="changeRate"/>
  96. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  97. </resultMap>
  98. <sql id="allColumns">
  99. `id`,`tenant_id`,`parent_tenant_id`,`type`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,
  100. `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,
  101. `remark`,`status`,`create_date`,`update_date`,`business`,`sub_business`,`support_transfer`,`subsidy_num`,`subsidy_type`,
  102. `press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund`,`put_apply_status`,`stock_apply_status`,`cancle_apply_status`,
  103. `conditions`,approval_type,content_type,source_type
  104. </sql>
  105. <sql id="statusColumns">
  106. `id`,`remain_inventory`,`status`
  107. </sql>
  108. <sql id="dynamicWhereConditions">
  109. where 1 = 1
  110. <if test=" null != id ">
  111. and `id` = #{id}
  112. </if>
  113. <if test=" null != tenantId and '' != tenantId">
  114. and `tenant_id` = #{tenantId}
  115. </if>
  116. <if test=" null != parentTenantId and '' != parentTenantId">
  117. and `parent_tenant_id` = #{parentTenantId}
  118. </if>
  119. <if test=" null != type ">
  120. and `type` = #{type}
  121. </if>
  122. <if test=" null != coverImg ">
  123. and `cover_img` like concat('%', #{coverImg},'%')
  124. </if>
  125. <if test=" null != title and ''!=title">
  126. and `title` like concat('%', #{title},'%')
  127. </if>
  128. <if test=" null != subTitle ">
  129. and `sub_title` like concat('%', #{subTitle},'%')
  130. </if>
  131. <if test=" null != salePrice ">
  132. and `sale_price` = #{salePrice}
  133. </if>
  134. <if test=" null != usePrice ">
  135. and `use_price` = #{usePrice}
  136. </if>
  137. <if test=" null != useLimitQuantity ">
  138. and `use_limit_quantity` = #{useLimitQuantity}
  139. </if>
  140. <if test=" null != sendType ">
  141. and `send_type` = #{sendType}
  142. </if>
  143. <if test=" null != validType ">
  144. and `valid_type` = #{validType}
  145. </if>
  146. <if test=" null != validStartDate ">
  147. and `valid_start_date` = #{validStartDate}
  148. </if>
  149. <if test=" null != validEndDate ">
  150. and `valid_end_date` = #{validEndDate}
  151. </if>
  152. <if test=" null != validDays ">
  153. and `valid_days` = #{validDays}
  154. </if>
  155. <if test=" null != detail ">
  156. and `detail` like concat('%', #{detail},'%')
  157. </if>
  158. <if test=" null != price ">
  159. and `price` = #{price}
  160. </if>
  161. <if test=" null != unit ">
  162. and `unit` = #{unit}
  163. </if>
  164. <if test=" null != remainInventory ">
  165. and `remain_inventory` = #{remainInventory}
  166. </if>
  167. <if test=" null != inventory ">
  168. and `inventory` = #{inventory}
  169. </if>
  170. <if test=" null != remark ">
  171. and `remark` like concat('%', #{remark},'%')
  172. </if>
  173. <if test=" null != status">
  174. and `status` = #{status}
  175. </if>
  176. <if test=" null != startdate and null!=enddate">
  177. and `create_date` between #{startdate} and #{enddate}
  178. </if>
  179. <if test=" null != updateDate ">
  180. and `update_date` = #{updateDate}
  181. </if>
  182. <if test=" null != business ">
  183. and `business` = #{business}
  184. </if>
  185. <if test=" null != subBusiness ">
  186. and `sub_business` = #{subBusiness}
  187. </if>
  188. <if test=" null != supportTransfer ">
  189. and `support_transfer` = #{supportTransfer}
  190. </if>
  191. <if test=" null != subsidyType ">
  192. and `subsidy_type` = #{subsidyType}
  193. </if>
  194. <if test=" null != subsidyNum ">
  195. and `subsidy_num` = #{subsidyNum}
  196. </if>
  197. <if test=" null != pressLimitNum ">
  198. and `press_limit_num` = #{pressLimitNum}
  199. </if>
  200. <if test=" null != pressLimitHours ">
  201. and `press_limit_hours` = #{pressLimitHours}
  202. </if>
  203. <if test=" null != autoRefund ">
  204. and `auto_refund` = #{autoRefund}
  205. </if>
  206. <if test=" null != creditPrice ">
  207. and `credit_price` = #{creditPrice}
  208. </if>
  209. <if test=" null != creditRefund ">
  210. and `credit_refund` = #{creditRefund}
  211. </if>
  212. <if test=" 1 == filterCanPut ">
  213. and `credit_refund` = #{creditRefund}
  214. </if>
  215. <if test=" null != contentType ">
  216. and `content_type` = #{contentType}
  217. </if>
  218. <if test=" null != putApplyStatus and putApplyStatus == 2">
  219. and `put_apply_status` = #{putApplyStatus}
  220. </if>
  221. <if test=" null != putApplyStatus and putApplyStatus == -1">
  222. and `put_apply_status` != 2
  223. </if>
  224. <if test=" null != stockApplyStatus ">
  225. and `stock_apply_status` = #{stockApplyStatus}
  226. </if>
  227. <if test=" null != cancleApplyStatus ">
  228. and `cancle_apply_status` = #{cancleApplyStatus}
  229. </if>
  230. <if test=" null != sourceType ">
  231. and `source_type` = #{sourceType}
  232. </if>
  233. <if test=" null != ids ">
  234. and id in
  235. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  236. #{idItem}
  237. </foreach>
  238. </if>
  239. <if test=" null != notinTypes ">
  240. and type not in
  241. <foreach collection="notinTypes" index="index" item="typeItem" open="(" separator="," close=")">
  242. #{typeItem}
  243. </foreach>
  244. </if>
  245. <if test=" null != sortColumns">order by ${sortColumns}</if>
  246. </sql>
  247. <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  248. select
  249. <include refid="allColumns"/>
  250. from wx_coupon
  251. <include refid="dynamicWhereConditions"/>
  252. </select>
  253. <update id="updateStockAndValidDate" parameterType="com.iformall.domain.po.WxCoupon">
  254. update wx_coupon
  255. SET
  256. `remain_inventory` = #{remainInventory}, `inventory` = #{inventory},
  257. `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays}
  258. WHERE 1=1
  259. <if test=" null != tenantId and '' != tenantId">
  260. and `tenant_id` = #{tenantId}
  261. </if>
  262. <if test=" null != parentTenantId and '' != parentTenantId">
  263. and `parent_tenant_id` = #{parentTenantId}
  264. </if>
  265. and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory}
  266. </update>
  267. <sql id="dynamicWhereConditionsForCoupon">
  268. where is_del = 0
  269. <if test=" null != targetAd ">
  270. and 0 = (select count(*) from wx_coupon_channel cc
  271. where c.`id` = cc.coupon_id
  272. and cc.status = 0
  273. and cc.target_ad = #{targetAd})
  274. </if>
  275. <if test=" null != id ">
  276. and c.`id` = #{id}
  277. </if>
  278. <if test=" null != tenantId and '' != tenantId">
  279. and c.`tenant_id` = #{tenantId}
  280. </if>
  281. <if test=" null != parentTenantId and '' != parentTenantId">
  282. and c.`parent_tenant_id` = #{parentTenantId}
  283. </if>
  284. <if test=" null == type and null == types">
  285. and c.`type` &lt; 7
  286. </if>
  287. <if test=" null != type ">
  288. and c.`type` = #{type}
  289. </if>
  290. <if test=" null != coverImg ">
  291. and c.`cover_img` like concat('%', #{coverImg},'%')
  292. </if>
  293. <if test=" null != title and ''!=title">
  294. and c.`title` like concat('%', #{title},'%')
  295. </if>
  296. <if test=" null != subTitle ">
  297. and c.`sub_title` like concat('%', #{subTitle},'%')
  298. </if>
  299. <if test=" null != salePrice ">
  300. and c.`sale_price` = #{salePrice}
  301. </if>
  302. <if test=" null != usePrice ">
  303. and c.`use_price` = #{usePrice}
  304. </if>
  305. <if test=" null != useLimitQuantity ">
  306. and c.`use_limit_quantity` = #{useLimitQuantity}
  307. </if>
  308. <if test=" null != sendType ">
  309. and c.`send_type` = #{sendType}
  310. </if>
  311. <if test=" null != validType ">
  312. and c.`valid_type` = #{validType}
  313. </if>
  314. <if test=" null != validStartDate ">
  315. and c.`valid_start_date` = #{validStartDate}
  316. </if>
  317. <if test=" null != validEndDate ">
  318. and c.`valid_end_date` = #{validEndDate}
  319. </if>
  320. <if test=" null != validDays ">
  321. and c.`valid_days` = #{validDays}
  322. </if>
  323. <if test=" null != detail ">
  324. and c.`detail` like concat('%', #{detail},'%')
  325. </if>
  326. <if test=" null != price ">
  327. and c.`price` = #{price}
  328. </if>
  329. <if test=" null != unit ">
  330. and c.`unit` = #{unit}
  331. </if>
  332. <if test=" null != remainInventory ">
  333. and c.`remain_inventory` = #{remainInventory}
  334. </if>
  335. <if test=" null != inventory ">
  336. and c.`inventory` = #{inventory}
  337. </if>
  338. <if test=" null != remark ">
  339. and c.`remark` like concat('%', #{remark},'%')
  340. </if>
  341. <if test=" null != status">
  342. and c.`status` = #{status}
  343. </if>
  344. <if test=" null != startdate and null!=enddate">
  345. and c.`create_date` between #{startdate} and #{enddate}
  346. </if>
  347. <if test=" null != updateDate ">
  348. and c.`update_date` = #{updateDate}
  349. </if>
  350. <if test=" null != business ">
  351. and c.`business` = #{business}
  352. </if>
  353. <if test=" null != subBusiness ">
  354. and `sub_business` = #{subBusiness}
  355. </if>
  356. <if test=" null != supportTransfer ">
  357. and c.`support_transfer` = #{supportTransfer}
  358. </if>
  359. <if test=" null != subsidyType ">
  360. and c.`subsidy_type` = #{subsidyType}
  361. </if>
  362. <if test=" null != subsidyNum ">
  363. and c.`subsidy_num` = #{subsidyNum}
  364. </if>
  365. <if test=" null != pressLimitNum ">
  366. and c.`press_limit_num` = #{pressLimitNum}
  367. </if>
  368. <if test=" null != pressLimitHours ">
  369. and c.`press_limit_hours` = #{pressLimitHours}
  370. </if>
  371. <if test=" null != autoRefund ">
  372. and c.`auto_refund` = #{autoRefund}
  373. </if>
  374. <if test=" null != contentType ">
  375. and c.`content_type` = #{contentType}
  376. </if>
  377. <if test=" null != putApplyStatus and putApplyStatus == 2">
  378. and `put_apply_status` = #{putApplyStatus}
  379. </if>
  380. <if test=" null != putApplyStatus and putApplyStatus == -1">
  381. and `put_apply_status` != 2
  382. </if>
  383. <if test=" null != stockApplyStatus ">
  384. and c.`stock_apply_status` = #{stockApplyStatus}
  385. </if>
  386. <if test=" null != cancleApplyStatus ">
  387. and c.`cancle_apply_status` = #{cancleApplyStatus}
  388. </if>
  389. <if test=" null != sourceType ">
  390. and c.`source_type` = #{sourceType}
  391. </if>
  392. <!--如果配置了审批模板,需要过滤投放审批状态-->
  393. <if test="0 != filterCanPut or null ==filterCanPut ">
  394. <if test=" null != pressModelId and 0l != pressModelId">
  395. and if(type=8,put_apply_status =2 or c.id in (
  396. select coupon_id from wx_coupon_channel
  397. where status=0
  398. <if test=" null != tenantId and '' != tenantId">
  399. and `tenant_id` = #{tenantId}
  400. </if>
  401. <if test=" null != parentTenantId and '' != parentTenantId">
  402. and `parent_tenant_id` = #{parentTenantId}
  403. </if>
  404. ) ,1=1)
  405. </if>
  406. <if test=" null != groupModelId and 0l != groupModelId">
  407. and if(type=9,put_apply_status =2 or c.id in (
  408. select coupon_id from wx_coupon_channel
  409. where status=0
  410. <if test=" null != tenantId and '' != tenantId">
  411. and `tenant_id` = #{tenantId}
  412. </if>
  413. <if test=" null != parentTenantId and '' != parentTenantId">
  414. and `parent_tenant_id` = #{parentTenantId}
  415. </if>
  416. ),1=1)
  417. </if>
  418. <if test=" null != cardModelId and 0l != cardModelId">
  419. and if(type=100,put_apply_status =2 or c.id in (
  420. select coupon_id from wx_coupon_channel
  421. where status=0
  422. <if test=" null != tenantId and '' != tenantId">
  423. and `tenant_id` = #{tenantId}
  424. </if>
  425. <if test=" null != parentTenantId and '' != parentTenantId">
  426. and `parent_tenant_id` = #{parentTenantId}
  427. </if>
  428. ),1=1)
  429. </if>
  430. <if test=" null != couponModelId and 0l != couponModelId">
  431. and if(type !=8 and type !=9 and type!=100,put_apply_status =2 or c.id in (
  432. select coupon_id from wx_coupon_channel
  433. where status=0
  434. <if test=" null != tenantId and '' != tenantId">
  435. and `tenant_id` = #{tenantId}
  436. </if>
  437. <if test=" null != parentTenantId and '' != parentTenantId">
  438. and `parent_tenant_id` = #{parentTenantId}
  439. </if>
  440. ),1=1)
  441. </if>
  442. </if>
  443. <if test=" null != ids ">
  444. and c.id in
  445. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  446. #{idItem}
  447. </foreach>
  448. </if>
  449. <if test=" null != types ">
  450. and c.type in
  451. <foreach collection="types" index="index" item="typesItem" open="(" separator="," close=")">
  452. #{typesItem}
  453. </foreach>
  454. </if>
  455. <if test=" null != sortColumns">order by ${sortColumns}</if>
  456. </sql>
  457. <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  458. select
  459. <include refid="allColumns"/>
  460. from wx_coupon c
  461. <include refid="dynamicWhereConditionsForCoupon"/>
  462. <if test="null != limitStart and null != limitEnd">
  463. limit #{limitStart},#{limitEnd}
  464. </if>
  465. </select>
  466. <select id="findCouponListCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Integer">
  467. select
  468. count(*)
  469. from wx_coupon c
  470. <include refid="dynamicWhereConditionsForCoupon"/>
  471. </select>
  472. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  473. <id column="id" jdbcType="BIGINT" property="id"/>
  474. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  475. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  476. <result column="type" jdbcType="INTEGER" property="type"/>
  477. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  478. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  479. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  480. <result column="title" jdbcType="VARCHAR" property="title"/>
  481. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  482. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  483. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  484. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  485. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  486. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  487. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  488. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  489. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  490. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  491. <result column="price" jdbcType="INTEGER" property="price"/>
  492. <result column="unit" jdbcType="INTEGER" property="unit"/>
  493. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  494. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  495. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  496. <result column="status" jdbcType="INTEGER" property="status"/>
  497. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  498. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  499. <result column="business" jdbcType="INTEGER" property="business"/>
  500. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  501. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  502. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  503. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  504. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  505. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  506. <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
  507. <result column="content_type" jdbcType="INTEGER" property="contentType"/>
  508. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  509. <collection column="{productId=id}" property="merchantVoList"
  510. ofType="com.iformall.domain.vo.WxMerchantVo"
  511. javaType="java.util.List"
  512. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantBaseList">
  513. </collection>
  514. </resultMap>
  515. <resultMap id="WxCouponCVoMapL" type="com.iformall.domain.vo.WxCouponCVo">
  516. <id column="id" jdbcType="BIGINT" property="id"/>
  517. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  518. <result column="type" jdbcType="INTEGER" property="type"/>
  519. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  520. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  521. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  522. <result column="title" jdbcType="VARCHAR" property="title"/>
  523. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  524. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  525. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  526. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  527. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  528. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  529. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  530. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  531. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  532. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  533. <result column="price" jdbcType="INTEGER" property="price"/>
  534. <result column="unit" jdbcType="INTEGER" property="unit"/>
  535. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  536. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  537. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  538. <result column="status" jdbcType="INTEGER" property="status"/>
  539. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  540. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  541. <result column="business" jdbcType="INTEGER" property="business"/>
  542. <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
  543. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  544. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  545. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  546. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  547. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  548. <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
  549. <result column="content_type" jdbcType="INTEGER" property="contentType"/>
  550. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  551. </resultMap>
  552. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  553. select
  554. <include refid="allColumns"/>
  555. from wx_coupon
  556. where id = #{id}
  557. </select>
  558. <select id="findVoStatusDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMapL">
  559. select id, remain_inventory, status
  560. from wx_coupon
  561. where id = #{id}
  562. </select>
  563. <update id="reduceInventory">
  564. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory - #{number} &gt;= 0
  565. </update>
  566. <update id="backInventory">
  567. update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and remain_inventory + #{number} &lt;= inventory
  568. </update>
  569. <update id="offExpiriedCouponByValidDate">
  570. update wx_coupon SET status = 1, update_date = now()
  571. where status = 0 and valid_type = 1 and valid_end_date &lt; now()
  572. </update>
  573. <update id="offExpiriedCouponByMerchantStatus">
  574. update wx_coupon c
  575. SET c.status = 1, c.update_date = now()
  576. where c.status = 0 and
  577. (select count(*) from wx_coupon_merchant cm, wx_merchant m
  578. where m.id = cm.merchant_id
  579. and c.id = cm.product_id
  580. and cm.status = 0
  581. and m.status = 1) = 0
  582. </update>
  583. <select id="findSaleMoneyByDate" parameterType="com.iformall.domain.po.WxCoupon"
  584. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  585. select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
  586. left join wx_coupon c on c.id = ci.coupon_id
  587. where c.type = 100
  588. and ci.create_date between #{startdate} and #{enddate}
  589. group by xtime
  590. </select>
  591. <select id="findPaymentByDate" parameterType="com.iformall.domain.po.WxCoupon"
  592. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  593. select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
  594. left join wx_coupon c on c.id = ci.coupon_id
  595. left join wx_card_spend wcs on wcs.card_id = ci.id
  596. where c.type = 100
  597. and wcs.create_date between #{startdate} and #{enddate}
  598. group by xtime
  599. </select>
  600. <select id="findSaleCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  601. select count(co.id)
  602. from wx_card_info ci
  603. left join wx_coupon c on c.id = ci.coupon_id
  604. left join wx_coupon_order co on co.id = ci.id
  605. where c.type = 100
  606. and co.create_date between #{startdate} and #{enddate}
  607. </select>
  608. <select id="findTranCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  609. select count(distinct wcs.coupon_order_id) from wx_card_info ci
  610. left join wx_coupon c on c.id = ci.coupon_id
  611. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  612. where c.type = 100 and wcs.create_date between #{startdate} and #{enddate}
  613. </select>
  614. <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  615. select sum(round(sc.subsidy/100,2)) from wx_card_info ci
  616. left join wx_coupon c on c.id = ci.coupon_id
  617. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  618. where c.type = 100 and sc.create_date between #{startdate} and #{enddate}
  619. </select>
  620. <select id="findCountData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="statisMap">
  621. select c.*,
  622. IFNULL(round((select sum(wcs.real_payment) from wx_card_info ci
  623. left join wx_coupon wc on wc.id = ci.coupon_id
  624. left join wx_card_spend wcs on wcs.card_id = ci.id
  625. where wc.id = c.id)/(select sum(ci.sale_amount) from wx_card_info ci
  626. left join wx_coupon wc on wc.id = ci.coupon_id
  627. where wc.id = c.id)*100,2),0) payment_rate,
  628. (select count(wco.id) from wx_coupon wc
  629. left join wx_coupon_order wco on wc.id = wco.coupon_id
  630. where wc.id = c.id) as sale_count,
  631. (select count(distinct wcs.coupon_order_id) from wx_card_info ci
  632. left join wx_coupon wc on wc.id = ci.coupon_id
  633. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  634. where wc.id = c.id) as transfer_count,
  635. (select sum(ci.sale_amount) from wx_card_info ci
  636. left join wx_coupon wc on wc.id = ci.coupon_id
  637. where wc.id = c.id) as sale_amount,
  638. (select sum(wcs.real_payment) from wx_card_info ci
  639. left join wx_coupon wc on wc.id = ci.coupon_id
  640. left join wx_card_spend wcs on wcs.card_id = ci.id
  641. where wc.id = c.id) as sum_payment,
  642. (select sum(sc.subsidy) from wx_card_info ci
  643. left join wx_coupon wc on wc.id = ci.coupon_id
  644. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  645. where wc.id = c.id) as sum_subsidy
  646. from wx_coupon c where c.type = 100
  647. <if test="title != null and title !=''">
  648. and c.title like concat('%', #{title},'%')
  649. </if>
  650. <if test="id != null">
  651. and c.id = #{id}
  652. </if>
  653. <if test=" null != sortColumns">order by ${sortColumns}</if>
  654. <if test=" null == sortColumns">order by c.status asc,c.create_date desc</if>
  655. </select>
  656. <select id="findCouponData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="statisMap">
  657. select c.*,
  658. IFNULL(round((select count(wco.id) from wx_coupon wc,wx_coupon_order wco where wco.coupon_id = wc.id and
  659. wco.coupon_order_status = 1 and wc.id = c.id)/(select count(wco.id) from wx_coupon_order wco where wco.coupon_id
  660. = c.id)*100,2),0) payment_rate,
  661. (select count(wco.id) from wx_coupon_order wco where wco.coupon_id = c.id) as sale_count,
  662. (select count(wco.id) from wx_coupon wc,wx_coupon_order wco where wco.coupon_id = wc.id and
  663. wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
  664. (select count(wco.id) from wx_coupon wc,wx_coupon_order wco where wco.coupon_id = wc.id and
  665. wco.coupon_order_status = 3 and wc.id = c.id) as backpay_count,
  666. (select sum(sc.subsidy) from wx_coupon wc
  667. left join wx_coupon_order wo on wo.coupon_id = wc.id
  668. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  669. where wc.id = c.id) as sum_subsidy
  670. from wx_coupon c where c.type not in(8,9,100)
  671. <if test=" 1 == type ">
  672. and c.sale_price > 0
  673. </if>
  674. <if test=" 2 == type ">
  675. and c.sale_price = 0
  676. </if>
  677. <if test="title != null and title != ''">
  678. and c.title like concat('%', #{title},'%')
  679. </if>
  680. <if test="id != null">
  681. and c.id = #{id}
  682. </if>
  683. <if test=" null != sortColumns">order by ${sortColumns}</if>
  684. <if test=" null == sortColumns">order by c.status asc,c.create_date desc</if>
  685. </select>
  686. <select id="findPressData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="statisMap">
  687. select c.id,c.tenant_id, c.`cover_img`,c.`title`,c.`sale_price`,c.`price`,
  688. ifnull(op.press_count,0) as press_count,
  689. ifnull(o.press_succ_count,0) as press_succ_count,
  690. ifnull(op2.join_count,0) as join_count,
  691. ifnull(round(o.press_succ_count/op.press_count*100,2),0) as change_rate,
  692. ifnull(round(cop.xCount/op.press_count*100,2),0) as payment_rate
  693. FROM wx_coupon c
  694. left join (SELECT count(id) as press_count, coupon_id FROM wx_order_press WHERE `first` = 1
  695. <if test=" null != tenantId and '' != tenantId">
  696. and `tenant_id` = #{tenantId}
  697. </if>
  698. <if test=" null != parentTenantId and '' != parentTenantId">
  699. and `parent_tenant_id` = #{parentTenantId}
  700. </if>
  701. group by coupon_id) op on op.coupon_id = c.id
  702. left join (SELECT count(id) as press_succ_count, product_id FROM wx_order WHERE order_status = 1
  703. <if test=" null != tenantId and '' != tenantId">
  704. and `tenant_id` = #{tenantId}
  705. </if>
  706. <if test=" null != parentTenantId and '' != parentTenantId">
  707. and `parent_tenant_id` = #{parentTenantId}
  708. </if>
  709. group by product_id) o on o.product_id = c.id
  710. left join (SELECT count(id) as join_count, coupon_id FROM wx_order_press WHERE 1=1
  711. <if test=" null != tenantId and '' != tenantId">
  712. and `tenant_id` = #{tenantId}
  713. </if>
  714. <if test=" null != parentTenantId and '' != parentTenantId">
  715. and `parent_tenant_id` = #{parentTenantId}
  716. </if>
  717. group by coupon_id) op2 on op2.coupon_id = c.id
  718. left join (SELECT count(id) as xCount, coupon_id FROM wx_coupon_order WHERE coupon_order_status = 1
  719. <if test=" null != tenantId and '' != tenantId">
  720. and `tenant_id` = #{tenantId}
  721. </if>
  722. <if test=" null != parentTenantId and '' != parentTenantId">
  723. and `parent_tenant_id` = #{parentTenantId}
  724. </if>
  725. group by coupon_id) cop on cop.coupon_id = c.id
  726. where c.type = 8
  727. <if test=" null != tenantId and '' != tenantId">
  728. and c.`tenant_id` = #{tenantId}
  729. </if>
  730. <if test=" null != parentTenantId and '' != parentTenantId">
  731. and c.`parent_tenant_id` = #{parentTenantId}
  732. </if>
  733. <if test="id != null">
  734. and c.id = #{id}
  735. </if>
  736. <if test="title != null and title != ''">
  737. and c.title like concat('%', #{title},'%')
  738. </if>
  739. <if test=" null != startdate and null!=enddate">
  740. and c.`create_date` between #{startdate} and #{enddate}
  741. </if>
  742. <if test=" null != sortColumns">order by ${sortColumns}</if>
  743. <if test=" null == sortColumns">order by c.status asc,c.create_date desc</if>
  744. </select>
  745. <select id="findCouponOrderCount" parameterType="com.iformall.domain.po.WxCoupon"
  746. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  747. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c
  748. left join wx_coupon_order wco on c.id = wco.coupon_id
  749. where c.type not in(8,9,100)
  750. and wco.create_date between #{startdate} and #{enddate}
  751. group by xtime
  752. </select>
  753. <select id="findCouponPaymentCount" parameterType="com.iformall.domain.po.WxCoupon"
  754. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  755. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  756. where c.type not in(8,9,100)
  757. and wco.coupon_id = c.id and wco.coupon_order_status = 1
  758. and wco.update_date between #{startdate} and #{enddate}
  759. group by xtime
  760. </select>
  761. <select id="priceCouponSaleCount" parameterType="com.iformall.domain.po.WxCoupon"
  762. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  763. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  764. where c.type not in(8,9,100)
  765. and wco.coupon_id = c.id and wco.coupon_price > 0
  766. and wco.create_date between #{startdate} and #{enddate}
  767. group by xtime
  768. </select>
  769. <select id="priceCouponPaymentCount" parameterType="com.iformall.domain.po.WxCoupon"
  770. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  771. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  772. where c.type not in(8,9,100)
  773. and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
  774. and wco.update_date between #{startdate} and #{enddate}
  775. group by xtime
  776. </select>
  777. <select id="findSumPriceSaleMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  778. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  779. where wco.coupon_id = c.id and wco.coupon_price > 0
  780. and wco.create_date between #{startdate} and #{enddate}
  781. </select>
  782. <select id="findSumPricePayMent" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  783. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  784. where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
  785. and wco.update_date between #{startdate} and #{enddate}
  786. </select>
  787. <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  788. select sum(round(sc.subsidy/100,2)) from wx_coupon c
  789. left join wx_coupon_order wo on wo.coupon_id = c.id
  790. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  791. where c.type not in(8,9,100) and wo.coupon_order_status = 1
  792. and sc.create_date between #{startdate} and #{enddate}
  793. </select>
  794. <!--砍价-->
  795. <select id="pressSendHistory" parameterType="com.iformall.domain.po.WxCoupon"
  796. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  797. select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from wx_coupon wc
  798. left join wx_order wo on wo.product_id = wc.id
  799. left join wx_order_press wop on wop.order_id = wo.id
  800. where wc.type = 8 and wop.first = 1 and
  801. wop.create_date between #{startdate} and #{enddate}
  802. group by xtime
  803. </select>
  804. <select id="pressSuccHistory" parameterType="com.iformall.domain.po.WxCoupon"
  805. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  806. select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount from wx_coupon wc
  807. left join wx_order wo on wo.product_id = wc.id
  808. where wc.type = 8 and wo.order_status = 1
  809. and wo.create_date between #{startdate} and #{enddate}
  810. group by xtime
  811. </select>
  812. <select id="pressPaymentHistory" parameterType="com.iformall.domain.po.WxCoupon"
  813. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  814. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon wc
  815. left join wx_coupon_order wco on wco.coupon_id = wc.id
  816. where wc.type = 8 and wco.coupon_order_status = 1
  817. and wco.create_date between #{startdate} and #{enddate}
  818. group by xtime
  819. </select>
  820. <select id="pressSuccRate" parameterType="com.iformall.domain.po.WxCoupon" resultType="java.lang.String">
  821. select
  822. round(
  823. (select count(wo.id) from wx_coupon wc
  824. left join wx_order wo on wo.product_id = wc.id
  825. where wo.order_status = 1 and wc.type = 8
  826. and wo.create_date between #{startdate} and #{enddate}
  827. <if test=" null != tenantId and '' != tenantId">
  828. and wo.`tenant_id` = #{tenantId}
  829. </if>
  830. <if test=" null != parentTenantId and '' != parentTenantId">
  831. and wo.`parent_tenant_id` = #{parentTenantId}
  832. </if>
  833. )
  834. /
  835. (select count(wop.id) from wx_coupon wc
  836. left join wx_order wo on wo.product_id = wc.id
  837. left join wx_order_press wop on wop.order_id = wo.id
  838. where wop.first = 1 and wc.type = 8
  839. and wop.create_date between #{startdate} and #{enddate}
  840. <if test=" null != tenantId and '' != tenantId">
  841. and wo.`tenant_id` = #{tenantId}
  842. and wop.`tenant_id` = #{tenantId}
  843. </if>
  844. <if test=" null != parentTenantId and '' != parentTenantId">
  845. and wo.`parent_tenant_id` = #{parentTenantId}
  846. and wop.`parent_tenant_id` = #{parentTenantId}
  847. </if>
  848. )
  849. * 100
  850. ,2)
  851. </select>
  852. <select id="sumJoin" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  853. select count(wop.id) from wx_coupon wc
  854. left join wx_order wo on wo.product_id = wc.id
  855. left join wx_order_press wop on wop.order_id = wo.id
  856. where wc.type = 8
  857. and wop.create_date between #{startdate} and #{enddate}
  858. </select>
  859. <select id="priceCouponCancelCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  860. select count(c.id) from wx_coupon c
  861. left join wx_coupon_order wco on c.id = wco.coupon_id
  862. where c.type not in(8,9,100)
  863. and wco.create_date between #{startdate} and #{enddate}
  864. and wco.coupon_order_status = 3
  865. </select>
  866. <select id="findSaleCardCountHistory" parameterType="com.iformall.domain.po.WxCoupon"
  867. resultType="com.iformall.domain.vo.WxCouponStatisVo">
  868. select DATE_FORMAT(co.create_date,'%Y-%m-%d') xtime,count(co.id) xcount
  869. from wx_card_info ci
  870. left join wx_coupon c on c.id = ci.coupon_id
  871. left join wx_coupon_order co on co.id = ci.id
  872. where c.type = 100
  873. and co.create_date between #{startdate} and #{enddate}
  874. group by xtime
  875. </select>
  876. <select id="findCouponByTopic" parameterType="com.iformall.domain.po.WxTopic"
  877. resultType="com.iformall.domain.po.WxCoupon">
  878. select ct.id as id,wc.id as couponId,
  879. wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`sale_price`,wc.`use_price`,wc.`use_limit_quantity`,wc.`send_type`,
  880. wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.`valid_days`,wc.`detail`,wc.`price`,wc.`unit`,wc.`remain_inventory`,wc.`inventory`,
  881. wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`,
  882. wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`,
  883. wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId
  884. from wx_coupon_channel ct
  885. left join wx_coupon wc on wc.id = ct.coupon_id
  886. where ct.`sub_target_id` = #{id} and ct.status = 0
  887. </select>
  888. <select id="findCouponModel" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  889. select
  890. max(case type when 9 then model_id else 0 end) couponModelId,
  891. max(case type when 10 then model_id else 0 end) cardModelId,
  892. max(case type when 11 then model_id else 0 end) groupModelId,
  893. max(case type when 12 then model_id else 0 end) pressModelId
  894. from wx_flow_config
  895. where type in(9,10,11,12)
  896. <if test=" null != tenantId and '' != tenantId">
  897. and `tenant_id` = #{tenantId}
  898. </if>
  899. <if test=" null != parentTenantId and '' != parentTenantId">
  900. and `parent_tenant_id` = #{parentTenantId}
  901. </if>
  902. </select>
  903. </mapper>