后台服务
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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