`id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`create_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend`,`change_purpose`,`ticket_number`,`buser_id`
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
and credit.operator_type = #{operatorType}
and credit.operator_id = #{operatorId}
and credit.credit_type = #{creditType}
and credit.c_user_id = #{cUserId}
and credit.merchant_id = #{merchantId}
and credit.ticket_number like concat('%', #{ticketNumber},'%')
and credit.buser_id = #{buserId}
and credit.merchant_id in
#{merchantIdItem}
and credit.c_user_id in
#{cUserIdItem}
select from wx_credit_history where id =#{id} and tenant_id = #{tenantId}
select
from wx_credit_history credit
where `tenant_id` = #{tenantId}
ORDER BY credit.create_date DESC
SELECT
credit.id ,credit.tenant_id ,credit.c_user_id ,credit.credit_amount ,credit.credit_num,credit.create_date,credit.credit_type,credit.receipt_url ,
credit.operator_type,credit.operator_id,credit.merchant_id,credit.ticket_number,credit.change_purpose
FROM wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
ORDER BY credit.create_date DESC
limit #{begin}, #{limit}
select COUNT(0) from wx_credit_history
where 1=1
and `c_user_id` = #{cUserId}
and `credit_type` = #{creditType}
and DATEDIFF(`create_date`,now())=0
select COUNT(0) from wx_credit_history
where 1=1
and `c_user_id` = #{cUserId}
and `credit_type` = #{creditType}
and DATE_FORMAT(`create_date`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m');
select count(0)
from wx_credit_history
where 1=1
and `tenant_id` = #{tenantId}
and `c_user_id` = #{cUserId}
and `credit_type` = #{creditType}
and DATEDIFF(`create_date`,now())=0
SELECT credit_amount FROM wx_credit_history where c_user_id = #{cUserId} ORDER BY create_date desc limit 1
select count(0)
from wx_credit_history
where 1=1
and `tenant_id` = #{tenantId}
and `c_user_id` = #{cUserId}
and `credit_type` = #{creditType}
select ifnull(sum(credit.credit_num),0) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num>0
select ABS(ifnull(sum(credit.credit_num),0)) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num < 0
select ifnull(sum(credit.credit_num),0) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num > 0 and credit.c_user_id = #{cUserId}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
select ifnull(sum(credit.credit_num),0) amount
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num < 0
and credit.c_user_id = #{cUserId}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
select count(distinct credit.c_user_id) people
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
delete from wx_credit_history where id = #{id} and tenant_id = #{tenantId}
{call user_credit_clear(#{cutOffDate},#{finalTableIndex})}
select
from wx_credit_history
where `tenant_id` = #{tenantId}
and `credit_type` = #{creditType}
and create_date >= #{startTime}
and `c_user_id` in
(select user_id from wx_member_card where `final_tenant_id` = #{finalTenantId} )
select credit.merchant_id merchantId,sum(credit.credit_num) sumAddCredit
from wx_credit_history credit
where credit.merchant_id is not null and credit.merchant_id != -1
and credit.credit_num > 0
and `tenant_id` = #{tenantId}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
GROUP BY credit.merchant_id
ORDER BY sumAddCredit desc
select credit.merchant_id merchantId,sum(credit.credit_num) sumLesCredit
from wx_credit_history credit
where credit.credit_num < 0
and `tenant_id` = #{tenantId}
and credit.merchant_id in
#{merchantIdItem}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
GROUP BY credit.merchant_id
select credit.merchant_id merchantId,count(distinct credit.c_user_id) countAddCreditUser
from wx_credit_history credit
where credit.credit_num > 0
and `tenant_id` = #{tenantId}
and credit.merchant_id in
#{merchantIdItem}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
GROUP BY credit.merchant_id
select credit.merchant_id merchantId,count(distinct credit.c_user_id) countLesCreditUser
from wx_credit_history credit
where credit.credit_num < 0
and `tenant_id` = #{tenantId}
and credit.merchant_id in
#{merchantIdItem}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
GROUP BY credit.merchant_id
select credit.c_user_id cUserId,ifnull(sum(credit.credit_num),0) creditNum
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num > 0
and credit.`c_user_id` in
#{uItem}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
GROUP BY credit.`c_user_id`
select credit.c_user_id cUserId,ifnull(sum(credit.credit_num),0) creditNum
from wx_credit_history credit
where credit.`tenant_id` = #{tenantId}
and credit.credit_num < 0
and credit.`c_user_id` in
#{uItem}
and credit.create_date >= #{startTime}
and credit.create_date < #{endTime}
GROUP BY credit.`c_user_id`