`id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund`, `verify_type`,`pay_vendor`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and `coupon_id` = #{couponId}
and `coupon_type` = #{couponType}
and `c_user_id` = #{cUserId}
and `owner_id` = #{ownerId}
and `b_user_id` = #{bUserId}
and `order_id` = #{orderId}
and `expired_time` = #{expiredTime}
and `coupon_order_status` = #{couponOrderStatus}
and `create_date` = #{createDate}
and `update_date` = #{updateDate}
and `coupon_price` = #{couponPrice}
and `auto_refund` = #{autoRefund}
and `pay_vendor` = #{payVendor}
and id in
#{idItem}
order by ${sortColumns}
select from wx_coupon_order where id = #{id} and tenant_id=#{tenantId}
select from wx_coupon_order
update wx_coupon_order
set `coupon_order_status` = #{couponOrderStatus},
`b_user_id` = #{bUserId},
`update_date` = #{updateDate},
`verify_type` = #{verifyType}
where id=#{id} and `b_user_id` is null
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
update wx_coupon_order
set `coupon_order_status` = #{couponOrderStatus},
`b_user_id` = #{bUserId},
`update_date` = #{updateDate},
`verify_type` = #{verifyType}
where id=#{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and `b_user_id` is null
and `b_user_id` = #{bUserId}
update wx_coupon_order
set `coupon_order_status` = #{couponOrderStatus},
`b_user_id` = #{bUserId},
`update_date` = #{updateDate},
`verify_type` = #{verifyType}
where 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and id=#{id}
update wx_coupon_order
set `coupon_order_status` = #{couponOrderStatus},
`b_user_id` = null,
`update_date` = #{updateDate},
`verify_type` = null
where id=#{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
COUNT(DISTINCT c_user_id) as couponUserCount,
count(*) as couponCount,
(select Count(*)
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) c
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
AND c.update_date >= #{startTime}
AND c.update_date <= #{endTime}) as verifyCount,
(select Count(DISTINCT c_user_id)
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) d
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
AND d.update_date >= #{startTime}
AND d.update_date <= #{endTime}) as verifyUserCount
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wx_coupon_order
where 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
AND create_date >= #{startTime}
AND create_date <= #{endTime}
GROUP BY createTime
SELECT createTime,couponId,sum(couponCount) couponCount,sum(couponUserCount) couponUserCount,sum(verifyCount) verifyCount,sum(verifyUserCount) verifyUserCount
from (
SELECT * from view_coupon_data${tenantEntity.shardTableSuffix} WHERE `tenant_id` = #{tenantEntity.tenantId}
) view_coupon_data
where 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and createTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
and view_coupon_data.createTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
and couponType = #{couponType}
and couponTitle like concat('%', #{couponTitle},'%')
GROUP BY createTime,couponId
order by createTime desc
SELECT xTime, sum(pv) pv, sum(uv) uv, sum(couponCount) couponCount, sum(userCount) userCount, sum(verifyCount) verifyCount, sum(verifyUserCount) verifyUserCount
FROM (
SELECT * from view_touch_user${tenantEntity.shardTableSuffix} WHERE `tenant_id` = #{tenantEntity.tenantId}
) view_touch_user
WHERE 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and xTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
and xTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
GROUP BY xTime
order by xTime desc
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) c
where c.coupon_order_status = 1
and c.`tenant_id` = #{tenantId}
and c.`parent_tenant_id` = #{parentTenantId}
and c.update_date BETWEEN #{startTime} and #{endTime}
group by xTime
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) c
where 1=1
and c.`tenant_id` = #{tenantId}
and c.`parent_tenant_id` = #{parentTenantId}
and c.create_date BETWEEN #{startTime} and #{endTime}
group by xTime
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) c left join (
SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
) cal on cal.tenant_id = c.tenant_id
where cal.coupon_order_id=c.id
and c.`tenant_id` = #{tenantId}
and c.`parent_tenant_id` = #{parentTenantId}
and cal.channel_type=#{channelType}
and c.create_date BETWEEN #{startTime} and #{endTime}
group by xTime
SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
where 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and coupon_order_status = #{couponOrderStatus}
and c_user_id = #{cUserId}
and coupon_id = #{couponId}
and coupon_type = #{couponType}
and create_date >= #{startTime}
and create_date <= #{endTime}
select COUNT(*) FROM wx_coupon_order co
inner join wx_coupon c
on c.id = co.coupon_id
and c.business = #{businessId}
and c.sub_business = #{subBusinessId}
where 1=1
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and co.coupon_order_status = #{couponOrderStatus}
and co.c_user_id = #{cUserId}
and co.coupon_id = #{couponId}
and co.coupon_type = #{couponType}
and co.update_date >= #{startTime}
and co.update_date <= #{endTime}
and date_format(co.update_date,'%H:%m') >= '06:00'
and date_format(co.update_date,'%H:%m') < '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4,5)
and ((date_format(co.update_date,'%H:%m') >= '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4))
or
((date_format(co.update_date,'%H:%m') < '06:00')
and date_format(co.update_date,'%w') in (1,2,3,4,5)))
and date_format(co.update_date,'%H:%m') >= '06:00'
and date_format(co.update_date,'%H:%m') < '18:00'
and date_format(co.update_date,'%w') in (0,6)
and ((date_format(co.update_date,'%H:%m') >= '18:00'
and date_format(co.update_date,'%w') in (5,6,0))
or
((date_format(co.update_date,'%H:%m') < '06:00')
and date_format(co.update_date,'%w') in (6,0)))
and co.create_date >= #{startTime}
and co.create_date <= #{endTime}
and date_format(co.create_date,'%H:%m') >= '06:00'
and date_format(co.create_date,'%H:%m') < '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4,5)
and ((date_format(co.create_date,'%H:%m') >= '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4))
or
((date_format(co.create_date,'%H:%m') < '06:00')
and date_format(co.create_date,'%w') in (1,2,3,4,5)))
and date_format(co.create_date,'%H:%m') >= '06:00'
and date_format(co.create_date,'%H:%m') < '18:00'
and date_format(co.create_date,'%w') in (0,6)
and ((date_format(co.create_date,'%H:%m') >= '18:00'
and date_format(co.create_date,'%w') in (5,6,0))
or
((date_format(co.create_date,'%H:%m') < '06:00')
and date_format(co.create_date,'%w') in (6,0)))
select c.business, COUNT(c.business) bu_count
FROM wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id
where 1=1
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and co.coupon_order_status = #{couponOrderStatus}
and co.c_user_id = #{cUserId}
and co.coupon_id = #{couponId}
and co.coupon_type = #{couponType}
and co.update_date >= #{startTime}
and co.update_date <= #{endTime}
and date_format(co.update_date,'%H:%m') >= '06:00'
and date_format(co.update_date,'%H:%m') < '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4,5)
and ((date_format(co.update_date,'%H:%m') >= '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4))
or
((date_format(co.update_date,'%H:%m') < '06:00')
and date_format(co.update_date,'%w') in (1,2,3,4,5)))
and date_format(co.update_date,'%H:%m') >= '06:00'
and date_format(co.update_date,'%H:%m') < '18:00'
and date_format(co.update_date,'%w') in (0,6)
and ((date_format(co.update_date,'%H:%m') >= '18:00'
and date_format(co.update_date,'%w') in (5,6,0))
or
((date_format(co.update_date,'%H:%m') < '06:00')
and date_format(co.update_date,'%w') in (6,0)))
and co.create_date >= #{startTime}
and co.create_date <= #{endTime}
and date_format(co.create_date,'%H:%m') >= '06:00'
and date_format(co.create_date,'%H:%m') < '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4,5)
and ((date_format(co.create_date,'%H:%m') >= '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4))
or
((date_format(co.create_date,'%H:%m') < '06:00')
and date_format(co.create_date,'%w') in (1,2,3,4,5)))
and date_format(co.create_date,'%H:%m') >= '06:00'
and date_format(co.create_date,'%H:%m') < '18:00'
and date_format(co.create_date,'%w') in (0,6)
and ((date_format(co.create_date,'%H:%m') >= '18:00'
and date_format(co.create_date,'%w') in (5,6,0))
or
((date_format(co.create_date,'%H:%m') < '06:00')
and date_format(co.create_date,'%w') in (6,0)))
group by c.business
select c.sub_business, COUNT(c.sub_business) bu_count
FROM wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id and c.business = #{businessId}
where 1=1
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and co.coupon_order_status = #{couponOrderStatus}
and co.c_user_id = #{cUserId}
and co.coupon_id = #{couponId}
and co.coupon_type = #{couponType}
and co.update_date >= #{startTime}
and co.update_date <= #{endTime}
and date_format(co.update_date,'%H:%m') >= '06:00'
and date_format(co.update_date,'%H:%m') < '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4,5)
and ((date_format(co.update_date,'%H:%m') >= '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4))
or
((date_format(co.update_date,'%H:%m') < '06:00')
and date_format(co.update_date,'%w') in (1,2,3,4,5)))
and date_format(co.update_date,'%H:%m') >= '06:00'
and date_format(co.update_date,'%H:%m') < '18:00'
and date_format(co.update_date,'%w') in (0,6)
and ((date_format(co.update_date,'%H:%m') >= '18:00'
and date_format(co.update_date,'%w') in (5,6,0))
or
((date_format(co.update_date,'%H:%m') < '06:00')
and date_format(co.update_date,'%w') in (6,0)))
and co.create_date >= #{startTime}
and co.create_date <= #{endTime}
and date_format(co.create_date,'%H:%m') >= '06:00'
and date_format(co.create_date,'%H:%m') < '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4,5)
and ((date_format(co.create_date,'%H:%m') >= '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4))
or
((date_format(co.create_date,'%H:%m') < '06:00')
and date_format(co.create_date,'%w') in (1,2,3,4,5)))
and date_format(co.create_date,'%H:%m') >= '06:00'
and date_format(co.create_date,'%H:%m') < '18:00'
and date_format(co.create_date,'%w') in (0,6)
and ((date_format(co.create_date,'%H:%m') >= '18:00'
and date_format(co.create_date,'%w') in (5,6,0))
or
((date_format(co.create_date,'%H:%m') < '06:00')
and date_format(co.create_date,'%w') in (6,0)))
group by c.sub_business
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price
from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wx_coupon_order
where 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
AND create_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime
select from wx_coupon_order
where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price = 0 and coupon_order_status in (0, 4)
select from wx_coupon_order
where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price > 0 and coupon_order_status in (0, 4)
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.order_id,
co.create_date,co.update_date,co.coupon_price, co.verify_type, co.pay_vendor,c.title,c.sale_price,c.use_price,c.price,
c.unit,c.auto_refund,c.business,c.subsidy_type,c.source_type,ms.subsidy subsidy_num,
(CASE WHEN couc.mc = 1 THEN m1.name ELSE '[多商户通用]' END) AS merchant_name,
(CASE WHEN couc.mc = 1 THEN m1.id ELSE 0 END) AS merchant_id,
cu.phone,m2.name AS verify_merchant_name,cal.channel_type
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,
co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type, co.pay_vendor,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num,
bu.name, bu.phone as bphone,
cu.phone,
m.name as merchant_name,m.id as merchant_id
select
FROM (
SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
FROM wx_coupon_merchant wcm
WHERE STATUS = 0
and wcm.`tenant_id` = #{tenantId}
and wcm.`parent_tenant_id` = #{parentTenantId}
GROUP BY product_id) couc
RIGHT JOIN (
SELECT co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.coupon_type,
co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.auto_refund,co.verify_type,co.pay_vendor
FROM wx_coupon_order co WHERE 1=1
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
) co
ON co.coupon_id = couc.product_id
LEFT JOIN wx_c_user_basic_info cu ON cu.id=co.c_user_id
LEFT JOIN wx_coupon c ON c.id = co.coupon_id
LEFT JOIN wx_merchant m1 ON m1.id = couc.merchant_id
LEFT JOIN wx_merchant_subsidy ms ON co.id = ms.coupon_order_id AND ms.type = 1
LEFT JOIN wx_merchant_b_user mbu ON mbu.id = co.b_user_id LEFT JOIN wx_merchant m2 ON m2.id = mbu.merchant_id
LEFT JOIN wx_coupon_action_log cal ON cal.coupon_order_id = co.id AND cal.coupon_id = co.coupon_id
where 1=1
and co.coupon_type = #{couponType}
and co.coupon_type < 100
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and co.coupon_order_status = #{couponOrderStatus}
and (case when couc.mc=1
then
m1.name
else'[多商户通用]' end)
like concat('%', #{merchantName},'%')
AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP}
AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP}
and co.id = #{id}
and co.order_id = #{orderId}
and c.id = #{couponId}
and c.business = #{business}
and c.`source_type` = #{sourceType}
and bu.verify_merchant_name = #{verifyMerchantName}
and co.coupon_id in(
select cm.product_id from wx_merchant_shop ms left join wx_merchant m on ms.merchant_id=m.id
left join wx_shop s on ms.shop_id=s.id
left join wx_coupon_merchant cm on ms.merchant_id=cm.merchant_id
where ms.is_del=0 and s.building=#{building}
and ms.`tenant_id` = #{tenantId}
and ms.`parent_tenant_id` = #{parentTenantId}
and s.floor=#{floor}
)
order by ${sortColumns}
order by co.create_date desc,co.id desc
select
from wx_coupon c, wx_coupon_order co
left join wx_c_user_basic_info cu on cu.id = co.c_user_id
left join wx_merchant_b_user bu on co.b_user_id = bu.id
left join wx_merchant m on m.id = bu.merchant_id
left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1
where co.id = #{id} and co.tenant_id = #{tenantId} and cu.final_tenant_id = #{finalTenantId}
and c.id = co.coupon_id
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
bu.name,
cu.phone
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
cu.phone
select
from wx_coupon_order co,wx_coupon c,wx_c_user_basic_info cu,wx_coupon_merchant cm,
(select tco.id as tcoid,
(select count(*) from wx_coupon_merchant tcm
where tcm.product_id = tco.coupon_id
and tcm.status = 0) as mc
from wx_coupon_order tco) com
where com.mc = 1
and com.tcoid = co.id
and cm.merchant_id = #{merchantId}
and co.tenant_id = #{tenantId}
and cm.product_id = c.id
and cm.status = 0
and co.coupon_id = c.id
and cu.id = co.c_user_id
AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
order by co.create_date desc
select
from wx_coupon_order co,wx_coupon c,wx_c_user_basic_info cu,wx_merchant_b_user bu
where co.coupon_id = c.id
and co.tenant_id = #{tenantId}
and cu.id = co.c_user_id
and bu.id = co.b_user_id
and bu.merchant_id = #{merchantId}
AND co.update_date > #{startDate,jdbcType=TIMESTAMP}
AND co.update_date < #{endDate,jdbcType=TIMESTAMP}
AND co.coupon_order_status = '1'
order by co.update_date desc
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor
select
from wx_coupon_order co,wx_coupon_merchant cm,
(select tco.id as tcoid,
(select count(*) from wx_coupon_merchant tcm
where tcm.product_id = tco.coupon_id
and tcm.status = 0)
as mc
from wx_coupon_order tco) com
where com.mc = 1
and co.tenant_id = #{tenantId}
and com.tcoid = co.id
and cm.status = 0
and cm.merchant_id = #{merchantId}
and cm.product_id = co.coupon_id
AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
select
from wx_coupon_order co, wx_merchant_b_user mbu
where mbu.id = co.b_user_id
and co.tenant_id = #{tenantId}
and mbu.merchant_id = #{merchantId}
AND co.update_date > #{startDate,jdbcType=TIMESTAMP}
AND co.update_date < #{endDate,jdbcType=TIMESTAMP}
AND co.coupon_order_status = '1'
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor,
c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,c.valid_end_date,c.auto_refund
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor,
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_type,c.valid_start_date,c.valid_end_date,c.auto_refund
select
from wx_coupon c,wx_coupon_order co
where 1=1
and co.coupon_id = c.id
and co.coupon_type != 5
and co.coupon_type != 51
and co.coupon_type < 100
and co.c_user_id = #{cUserId}
and co.owner_id = #{ownerId}
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
AND (co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
AND co.coupon_order_status = #{couponOrderStatus}
order by ${sortColumns}
select
from wx_coupon_order co, wx_coupon c
where co.coupon_id = c.id
and co.id = #{id} and co.tenant_id = #{tenantId}
select
from wx_coupon_order co
where co.id = #{id} and co.tenant_id = #{tenantId}
select
from wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id
inner join wx_coupon_merchant cm on cm.product_id = co.coupon_id
where co.c_user_id = #{cUserId}
and co.coupon_order_status = 0
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and cm.merchant_id = #{merchantId}
and co.expired_time > now()
and c.type in (1, 2, 6)
union
select
from wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id
inner join wx_coupon_merchant cm on cm.product_id = co.coupon_id
inner join pos_coupon_order_verify pco on pco.coupon_order_id = co.id
where co.c_user_id = #{cUserId}
and co.coupon_order_status = 100
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and cm.merchant_id = #{merchantId}
and co.expired_time > now()
and c.type in (1, 2, 6)
and pco.pos_order_id = #{posOrderId}
co.id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.pay_vendor,
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,
json_extract(car.vendor_params,'$.id') as coupon_free_id
select
from wx_coupon_order co, wx_coupon c, wx_coupon_car car
where co.coupon_id = c.id
and co.coupon_id = car.id
and c.type in (5,51)
and co.c_user_id = #{cUserId}
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and co.id = #{id}
AND ( co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
AND co.coupon_order_status = #{couponOrderStatus}
order by ${sortColumns}
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,
c.cover_img,c.title,c.sub_title,c.detail,c.unit,c.remark,
a.amount,a.remaining_amount,a.support_transfer
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.cover_img,c.title,c.sub_title,c.sale_price,c.price,c.unit,c.detail,c.remark,
a.amount,a.remaining_amount,a.support_transfer
select c.* from (
select id,tenant_id,parent_tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as
coupon_order_status,create_date,update_date,'' cover_img,title,'' sub_title,'' detail,0 unit,
'' remark,amount,remain_amount as remaining_amount,0 support_transfer
from wx_card_transfer_info where 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and from_user = #{ownerId}
and status = #{couponOrderStatus}
and status=8
union
select
from wx_coupon_order co
inner join wx_coupon c on co.coupon_id = c.id
inner join wx_card_info a on co.id=a.id
where 1=1
and co.coupon_type = 100
and co.`tenant_id` = #{tenantId}
and co.`parent_tenant_id` = #{parentTenantId}
and co.c_user_id = #{cUserId}
and co.owner_id = #{ownerId}
and co.coupon_order_status = #{couponOrderStatus}
and co.coupon_order_status in
#{sItem}
) c
order by ${sortColumns}
select
from wx_coupon_order co,wx_coupon c, wx_card_info a
where co.coupon_id = c.id and co.id = a.id
and co.id = #{id} and co.tenant_id = #{tenantId}
update wx_coupon_order set coupon_order_status = 4,update_date = now(), expired_time= #{expireTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5)
select id from wx_coupon_order where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5)