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

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