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`,
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`,
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`,
c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,
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`,
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
`id`,`remain_inventory`,`status`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and `make_merchant_id` = #{makeMerchantId}
and `brand` = #{brand}
and `type` = #{type}
and `cover_img` like concat('%', #{coverImg},'%')
and `title` like concat('%', #{title},'%')
and `sub_title` like concat('%', #{subTitle},'%')
and `sale_price` = #{salePrice}
and `use_price` = #{usePrice}
and `use_limit_rule` = #{useLimitRule}
and `use_limit_quantity` = #{useLimitQuantity}
and `send_type` = #{sendType}
and `valid_type` = #{validType}
and `valid_start_date` = #{validStartDate}
and `valid_end_date` = #{validEndDate}
and `valid_days` = #{validDays}
and `detail` like concat('%', #{detail},'%')
and `price` = #{price}
and `unit` = #{unit}
and `remain_inventory` = #{remainInventory}
and `inventory` = #{inventory}
and `remark` like concat('%', #{remark},'%')
and `status` = #{status}
and `create_date` between #{startdate} and #{enddate}
and `update_date` = #{updateDate}
and `business` = #{business}
and `sub_business` = #{subBusiness}
and `support_transfer` = #{supportTransfer}
and `subsidy_type` = #{subsidyType}
and `subsidy_num` = #{subsidyNum}
and `press_limit_num` = #{pressLimitNum}
and `press_limit_hours` = #{pressLimitHours}
and `auto_refund` = #{autoRefund}
and `credit_price` = #{creditPrice}
and `credit_price` <= #{userCredit}
and `credit_refund` = #{creditRefund}
and `credit_refund` = #{creditRefund}
and `content_type` = #{contentType}
and `put_apply_status` = #{putApplyStatus}
and `put_apply_status` != 2
and `stock_apply_status` = #{stockApplyStatus}
and `cancle_apply_status` = #{cancleApplyStatus}
and `source_type` = #{sourceType}
and `merchant_type` = #{merchantType}
and JSON_CONTAINS(gift_list,json_array(#{giftList}))
and id in
#{idItem}
and type not in
#{ntypeItem}
and type in
#{typeItem}
order by ${sortColumns}
select ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
select id,product_type,category_id,product_attrs,sku_attrs
from wx_coupon where id = #{id} and tenant_id = #{tenantId}
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}
select c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where tenant_id = #{tenantId}
and id in
#{idItem}
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,
sub_title,item_group,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date
from wx_coupon c where c.`tenant_id` = #{tenantId}
and id in
#{idItem}
and type in
#{typeItem}
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,
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
from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
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,
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,
c.valid_days,c.detail,c.price,c.tail_price,c.orig_price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
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
from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
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,
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
from wx_coupon c
select id
from wx_coupon c
select id
from wx_coupon where `tenant_id` = #{tenantId}
and ((valid_type=1
and = now() ]]>
and
)
or
or
)
select
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
from wx_coupon c where c.`tenant_id` = #{tenantId}
and id in
#{idItem}
update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId}
select
from wx_coupon c
update wx_coupon
SET
`remain_inventory` = #{remainInventory}, `inventory` = #{inventory},
`valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays}
WHERE 1=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory}
and c.`id` = #{id}
and c.`tenant_id` = #{tenantId}
and c.`parent_tenant_id` = #{parentTenantId}
and c.`type` = #{type}
and c.`cover_img` like concat('%', #{coverImg},'%')
and c.`title` like concat('%', #{title},'%')
and c.`sub_title` like concat('%', #{subTitle},'%')
and c.`sale_price` = #{salePrice}
and c.`use_price` = #{usePrice}
and c.`use_limit_rule` = #{useLimitRule}
and c.`use_limit_quantity` = #{useLimitQuantity}
and c.`send_type` = #{sendType}
and c.`valid_type` = #{validType}
and c.`valid_start_date` = #{validStartDate}
and c.`valid_end_date` = #{validEndDate}
and c.`valid_days` = #{validDays}
and c.`detail` like concat('%', #{detail},'%')
and c.`price` = #{price}
and c.`unit` = #{unit}
and c.`remain_inventory` = #{remainInventory}
and c.`inventory` = #{inventory}
and c.`remark` like concat('%', #{remark},'%')
and c.`status` = #{status}
and c.`create_date` between #{startdate} and #{enddate}
and c.`update_date` = #{updateDate}
and c.`business` = #{business}
and c.`sub_business` = #{subBusiness}
and c.`support_transfer` = #{supportTransfer}
and c.`subsidy_type` = #{subsidyType}
and c.`subsidy_num` = #{subsidyNum}
and c.`press_limit_num` = #{pressLimitNum}
and c.`press_limit_hours` = #{pressLimitHours}
and c.`auto_refund` = #{autoRefund}
and c.`content_type` = #{contentType}
and c.`put_apply_status` = #{putApplyStatus}
and c.`put_apply_status` != 2
and c.`stock_apply_status` = #{stockApplyStatus}
and c.`cancle_apply_status` = #{cancleApplyStatus}
and c.`source_type` = #{sourceType}
and c.`merchant_type` = #{merchantType}
and JSON_CONTAINS(c.gift_list,json_array(#{giftList}))
and 0 = (select count(*) from wx_coupon_channel cc
where c.`id` = cc.coupon_id
and cc.status = 0
and cc.target_ad = #{targetAd})
and c.id in
#{idItem}
and c.type in
#{typesItem}
and c.send_type in
#{typesItem}
select
,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
from wx_coupon c
left join tt_coupon_channel_poi poi on poi.id = c.id
where c.is_del = 0
and poi.`spu_id` = #{spuId}
and poi.`status` = #{poiStatus}
and poi.`last_status` = #{lastStatus}
order by ${sortColumns}
limit #{limitStart},#{limitEnd}
select
count(c.id)
from wx_coupon c
left join tt_coupon_channel_poi poi on poi.id = c.id
where c.is_del = 0
and poi.`spu_id` = #{spuId}
and poi.`status` = #{poiStatus}
and poi.`last_status` = #{lastStatus}
select
from wx_coupon c
where id = #{id} and tenant_id =#{tenantId}
select id, remain_inventory, status
from wx_coupon
where id = #{id} and tenant_id =#{tenantId}
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} >= 0
update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} <= inventory
update wx_coupon SET status = 1, update_date = now()
where status = 0 and tenant_id =#{tenantId} and valid_type = 1 and valid_end_date < now()
update wx_coupon c
SET c.status = 1, c.update_date = now()
where c.status = 0 and c.tenant_id =#{tenantId}
and c.type != 12
and c.id not in
#{idItem}
select cm.product_id from wx_coupon_merchant cm, wx_merchant m
where m.id = cm.merchant_id
and cm.status = 0
and m.status = 1
select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c on c.id = ci.coupon_id
where c.type = 100
and ci.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c on c.id = ci.coupon_id
left join wx_card_spend wcs on wcs.card_id = ci.id
where c.type = 100
and wcs.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select count(co.id)
from wx_card_info ci
left join wx_coupon c on c.id = ci.coupon_id
left join wx_coupon_order co on co.id = ci.id
where c.type = 100
and co.create_date between #{startdate} and #{enddate}
select count(distinct wcs.coupon_order_id) from wx_card_info ci
left join wx_coupon c on c.id = ci.coupon_id
left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
where c.type = 100 and wcs.create_date between #{startdate} and #{enddate}
select sum(round(sc.subsidy/100,2)) from wx_card_info ci
left join wx_coupon c on c.id = ci.coupon_id
left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
where c.type = 100 and sc.create_date between #{startdate} and #{enddate}
select c.*,
IFNULL(round((select sum(wcs.real_payment) from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc on wc.id = ci.coupon_id
left join wx_card_spend wcs on wcs.card_id = ci.id
where wc.id = c.id)/(select sum(ci.sale_amount) from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc on wc.id = ci.coupon_id
where wc.id = c.id)*100,2),0) payment_rate,
(select count(wco.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco on wc.id = wco.coupon_id
where wc.id = c.id) as sale_count,
(select count(distinct wcs.coupon_order_id) from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc on wc.id = ci.coupon_id
left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
where wc.id = c.id) as transfer_count,
(select sum(ci.sale_amount) from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc on wc.id = ci.coupon_id
where wc.id = c.id) as sale_amount,
(select sum(wcs.real_payment) from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc on wc.id = ci.coupon_id
left join wx_card_spend wcs on wcs.card_id = ci.id
where wc.id = c.id) as sum_payment,
(select sum(sc.subsidy) from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc on wc.id = ci.coupon_id
left join (
SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
) sc on sc.coupon_order_id = ci.id
where wc.id = c.id) as sum_subsidy
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c where c.type = 100
and c.title like concat('%', #{wxCoupon.title},'%')
and c.id = #{wxCoupon.id}
order by ${wxCoupon.sortColumns}
order by c.status asc,c.create_date desc
select c.*,
IFNULL(round((select count(wco.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc,(
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco where wco.coupon_id = wc.id and
wco.coupon_order_status = 1 and wc.id = c.id)/(select count(wco.id) from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco where wco.coupon_id
= c.id)*100,2),0) payment_rate,
(select count(wco.id) from (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco where wco.coupon_id = c.id) as sale_count,
(select count(wco.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc,(
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco where wco.coupon_id = wc.id and
wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
(select count(wco.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc,(
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco where wco.coupon_id = wc.id and
wco.coupon_order_status = 3 and wc.id = c.id) as backpay_count,
(select sum(sc.subsidy) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wo on wo.coupon_id = wc.id
left join (
SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
) sc on sc.coupon_order_id = wo.id
where wc.id = c.id) as sum_subsidy
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c where c.type not in(8,9,100)
and c.sale_price > 0
and c.sale_price = 0
and c.title like concat('%', #{wxCoupon.title},'%')
and c.id = #{wxCoupon.id}
order by ${wxCoupon.sortColumns}
order by c.status asc,c.create_date desc
select c.id,c.tenant_id, c.`cover_img`,c.`title`,c.`sale_price`,c.`freight_price`,c.`price`,
ifnull(op.press_count,0) as press_count,
ifnull(o.press_succ_count,0) as press_succ_count,
ifnull(op2.join_count,0) as join_count,
ifnull(round(o.press_succ_count/op.press_count*100,2),0) as change_rate,
ifnull(round(cop.xCount/op.press_count*100,2),0) as payment_rate
FROM (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c
left join (SELECT count(id) as press_count, coupon_id FROM (
SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
) wx_order_press WHERE `first` = 1
and `tenant_id` = #{wxCoupon.tenantId}
and `parent_tenant_id` = #{wxCoupon.parentTenantId}
group by coupon_id) op on op.coupon_id = c.id
left join (SELECT count(id) as press_succ_count, product_id FROM (
SELECT * from wx_order${tenantEntity.shardTableSuffix}
) wx_order WHERE order_status = 1
and `tenant_id` = #{wxCoupon.tenantId}
and `parent_tenant_id` = #{wxCoupon.parentTenantId}
group by product_id) o on o.product_id = c.id
left join (SELECT count(id) as join_count, coupon_id FROM (
SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
) wx_order_press WHERE 1=1
and `tenant_id` = #{wxCoupon.tenantId}
and `parent_tenant_id` = #{wxCoupon.parentTenantId}
group by coupon_id) op2 on op2.coupon_id = c.id
left join (SELECT count(id) as xCount, coupon_id FROM (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wx_coupon_order WHERE coupon_order_status = 1
and `tenant_id` = #{wxCoupon.tenantId}
and `parent_tenant_id` = #{wxCoupon.parentTenantId}
group by coupon_id) cop on cop.coupon_id = c.id
where c.type = 8
and c.`tenant_id` = #{wxCoupon.tenantId}
and c.`parent_tenant_id` = #{wxCoupon.parentTenantId}
and c.id = #{wxCoupon.id}
and c.title like concat('%', #{wxCoupon.title},'%')
and c.`create_date` between #{wxCoupon.startdate} and #{wxCoupon.enddate}
order by ${wxCoupon.sortColumns}
order by c.status asc,c.create_date desc
select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c
left join (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco on c.id = wco.coupon_id
where c.type not in(8,9,100)
and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c,(
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco
where c.type not in(8,9,100)
and wco.coupon_id = c.id and wco.coupon_order_status = 1
and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c,(
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco
where c.type not in(8,9,100)
and wco.coupon_id = c.id and wco.coupon_price > 0
and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c,(
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco
where c.type not in(8,9,100)
and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
where wco.coupon_id = c.id and wco.coupon_price > 0
and wco.create_date between #{startdate} and #{enddate}
select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
and wco.update_date between #{startdate} and #{enddate}
select sum(round(sc.subsidy/100,2)) from wx_coupon c
left join wx_coupon_order wo on wo.coupon_id = c.id
left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
where c.type not in(8,9,100) and wo.coupon_order_status = 1
and sc.create_date between #{startdate} and #{enddate}
select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_order${tenantEntity.shardTableSuffix}
) wo on wo.product_id = wc.id
left join (
SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
) wop on wop.order_id = wo.id
where wc.type = 8 and wop.first = 1 and
wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_order${tenantEntity.shardTableSuffix}
) wo on wo.product_id = wc.id
where wc.type = 8 and wo.order_status = 1
and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) wco on wco.coupon_id = wc.id
where wc.type = 8 and wco.coupon_order_status = 1
and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select
round(
(select count(wo.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_order${tenantEntity.shardTableSuffix}
) wo on wo.product_id = wc.id
where wo.order_status = 1 and wc.type = 8
and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
)
/
(select count(wop.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_order${tenantEntity.shardTableSuffix}
) wo on wo.product_id = wc.id
left join (
SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
) wop on wop.order_id = wo.id
where wop.first = 1 and wc.type = 8
and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
)
* 100
,2)
select count(wop.id) from (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) wc
left join (
SELECT * from wx_order${tenantEntity.shardTableSuffix}
) wo on wo.product_id = wc.id
left join (
SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
) wop on wop.order_id = wo.id
where wc.type = 8
and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
select count(c.id) from wx_coupon c
left join wx_coupon_order wco on c.id = wco.coupon_id
where c.type not in(8,9,100)
and wco.create_date between #{startdate} and #{enddate}
and wco.coupon_order_status = 3
select DATE_FORMAT(co.create_date,'%Y-%m-%d') xtime,count(co.id) xcount
from wx_card_info ci
left join (
SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
) c on c.id = ci.coupon_id
left join (
SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
) co on co.id = ci.id
where c.type = 100
and co.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
group by xtime
select ct.id as id,wc.id as couponId,
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`,
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`,
wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`,
wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`,
wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId
from wx_coupon_channel ct
left join wx_coupon wc on wc.id = ct.coupon_id
where ct.`sub_target_id` = #{id} and ct.status = 0
select
max(case type when 9 then model_id else 0 end) couponModelId,
max(case type when 10 then model_id else 0 end) cardModelId,
max(case type when 11 then model_id else 0 end) groupModelId,
max(case type when 12 then model_id else 0 end) pressModelId
from wx_flow_config
where type in(9,10,11,12)
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id}
select id,remain_inventory,inventory,cover_img,title,sub_title,item_group,sale_price,use_price,price,tail_price,
orig_price,unit,use_limit_rule,use_limit_quantity,send_type,support_transfer,press_limit_num,auto_refund,
conditions,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date,valid_days,credit_price,
content_type,source_type,merchant_type
from wx_coupon where `tenant_id` = #{tenantId}
and `id` = #{id}
and `business` = #{business}
and `sub_business` = #{subBusiness}
and id in
#{idItem}
select c.id
from wx_coupon c
where c.`tenant_id` = #{tenantId} and c.conditions is not null
/*and JSON_EXTRACT(c.conditions, '$.type') = 1*/
and c.`parent_tenant_id` = #{parentTenantId}
select c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`,
c.`title`,c.`sub_title`,c.`sale_price`,c.`freight_price`,c.`send_type`,
c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,
c.`valid_days`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,
c.`auto_refund`,c.`credit_price`,c.`credit_refund`,
c.content_type,c.source_type,c.merchant_type,c.product_type,c.category_id,
poi.coupon_channel_id,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
from wx_coupon c
left join tt_coupon_channel_poi poi on poi.id = c.id
where c.`type` = #{type}
and c.`id` = #{id}
and c.`tenant_id` = #{tenantId}
and c.`parent_tenant_id` = #{parentTenantId}
and c.`title` like concat('%', #{title},'%')
and c.`send_type` = #{sendType}
and c.`status` = #{status}
and c.`create_date` between #{startdate} and #{enddate}
and c.`source_type` = #{sourceType}
and c.`merchant_type` = #{merchantType}
and poi.`coupon_channel_id` = #{couponChannelId}
and poi.`spu_id` = #{spuId}
and poi.`status` = #{poiStatus}
and poi.`last_status` = #{lastStatus}
order by ${sortColumns}
select category_id
from wx_coupon
where id = #{id}
and tenant_id = #{tenantId}
update wx_coupon set make_merchant_id = #{makeMerchantId} where id = #{id} and tenant_id = #{tenantId}