`id`,`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`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
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 id in
#{idItem}
order by ${sortColumns}
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 `tenant_id`=#{tenantId}
and id=#{id} and `b_user_id` is null
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 id=#{id}
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 id=#{id}
update wx_coupon_order
set `coupon_order_status` = #{couponOrderStatus},
`b_user_id` = null,
`update_date` = #{updateDate},
`verify_type` = null
where `tenant_id`=#{tenantId}
and id=#{id}
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
COUNT(DISTINCT c_user_id) as couponUserCount,
count(*) as couponCount,
(select Count(*)
from wx_coupon_order c
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
AND tenant_id=#{tenantId}
AND c.update_date >= #{startTime}
AND c.update_date <= #{endTime}) as verifyCount,
(select Count(DISTINCT c_user_id)
from wx_coupon_order d
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
AND tenant_id=#{tenantId}
AND d.update_date >= #{startTime}
AND d.update_date <= #{endTime}) as verifyUserCount
from wx_coupon_order
where tenant_id=#{tenantId}
AND create_date >= #{startTime}
AND create_date <= #{endTime}
GROUP BY createTime
SELECT createTime,couponId,couponCount,couponUserCount,verifyCount,verifyUserCount
from view_coupon_data
where view_coupon_data.tenant_id=#{tenantId}
and view_coupon_data.createTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
and view_coupon_data.createTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
and view_coupon_data.couponType = #{couponType}
and view_coupon_data.couponTitle like concat('%', #{couponTitle},'%')
order by view_coupon_data.createTime desc
SELECT xTime, tenant_id, pv, uv, couponCount, userCount, verifyCount, verifyUserCount
FROM view_touch_user
WHERE view_touch_user.tenant_id=#{tenantId}
and view_touch_user.xTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
and view_touch_user.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 wx_coupon_order c
where c.tenant_id = #{tenantId}
and c.coupon_order_status = 1
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 wx_coupon_order c
where c.tenant_id = #{tenantId}
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 wx_coupon_order c left join wx_coupon_action_log cal on cal.tenant_id = c.tenant_id
where cal.coupon_order_id=c.id
and c.tenant_id=#{tenantId}
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 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.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.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.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 wx_coupon_order
where tenant_id=#{tenantId}
AND create_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime
select from wx_coupon_order
where expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price = 0 and coupon_order_status = 0
select from wx_coupon_order
where expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price > 0 and coupon_order_status = 0
co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num,
(case when com.mc=1 then
(select m.name from wx_merchant m, wx_coupon_merchant cm
where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name,
(case when com.mc = 1 then (select m.id from wx_merchant m,
wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id = co.coupon_id
and cm.status = 0) else 0 end) as merchant_id,cu.phone,bu.verify_merchant_name,cal.channel_type
co.id,co.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.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 wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id
inner join (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 on com.tcoid = co.id
inner join wx_c_user cu on cu.id=co.c_user_id
left join (
select bu.id as bu_id,m.name as verify_merchant_name
from wx_merchant_b_user bu inner join wx_merchant m on bu.merchant_id=m.id
where bu.tenant_id = #{tenantId}
) bu on bu.bu_id = co.b_user_id
left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1
left join wx_coupon_action_log cal on co.id = cal.coupon_order_id and co.coupon_id = cal.coupon_id
where 1=1
and co.coupon_type = #{couponType}
and co.coupon_type < 100
and co.tenant_id = #{tenantId}
and co.coupon_order_status = #{couponOrderStatus}
and (case when com.mc=1
then
(select m.name from wx_merchant m, wx_coupon_merchant cm
where m.id = cm.merchant_id
and cm.product_id=co.coupon_id
and cm.status = 0)
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 c.id = #{couponId}
and c.business = #{business}
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 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 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 c.id = co.coupon_id
co.id,co.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.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
bu.name,
cu.phone
co.id,co.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.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 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 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 cu,wx_merchant_b_user bu
where co.coupon_id = c.id
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.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
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 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 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.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,
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,
cal.channel_type as send_channel_type
co.id,co.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,
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.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.verify_type
select
from wx_coupon c,wx_coupon_order co
left join wx_coupon_action_log cal on cal.coupon_order_id = co.id
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.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}
select
from wx_coupon_order co
where co.id = #{id}
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.tenant_id = #{tenantId}
and co.c_user_id = #{cUserId}
and co.coupon_order_status = 0
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.tenant_id = #{tenantId}
and co.c_user_id = #{cUserId}
and co.coupon_order_status = 100
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,
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.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.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.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,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 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.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}