|
|
@@ -26,83 +26,12 @@ |
|
|
</sql> |
|
|
</sql> |
|
|
|
|
|
|
|
|
<sql id="dynamicWhereConditions"> |
|
|
<sql id="dynamicWhereConditions"> |
|
|
where 1 = 1 |
|
|
|
|
|
<if test=" null != id "> |
|
|
|
|
|
and `id` = #{id} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != tenantId and '' != tenantId"> |
|
|
|
|
|
and `tenant_id` = #{tenantId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != cUserId "> |
|
|
|
|
|
and `c_user_id` = #{cUserId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != creditAmount "> |
|
|
|
|
|
and `credit_amount` = #{creditAmount} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != creditNum "> |
|
|
|
|
|
and `credit_num` = #{creditNum} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != creditType "> |
|
|
|
|
|
and `credit_type` = #{creditType} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != receiptUrl "> |
|
|
|
|
|
and `receipt_url` like concat('%', #{receiptUrl},'%') |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != operatorType "> |
|
|
|
|
|
and `operator_type` = #{operatorType} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != operatorId "> |
|
|
|
|
|
and `operator_id` = #{operatorId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != merchantId "> |
|
|
|
|
|
and `merchant_id` = #{merchantId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != couponId "> |
|
|
|
|
|
and `coupon_id` = #{couponId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != businessId "> |
|
|
|
|
|
and `business_id` = #{businessId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != spend "> |
|
|
|
|
|
and `spend` = #{spend} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != changePurpose "> |
|
|
|
|
|
and `change_purpose` = #{changePurpose} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != ticketNumber and ''!=ticketNumber "> |
|
|
|
|
|
and ticket_number like concat('%', #{ticketNumber},'%') |
|
|
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != buserId "> |
|
|
|
|
|
and `buser_id` = #{buserId} |
|
|
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != ids "> |
|
|
|
|
|
and id in |
|
|
|
|
|
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> |
|
|
|
|
|
#{idItem} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != sortColumns"> order by ${sortColumns} </if> |
|
|
|
|
|
</sql> |
|
|
|
|
|
|
|
|
|
|
|
<sql id="customWhereConditions"> |
|
|
|
|
|
where 1 = 1 |
|
|
|
|
|
<if test=" null != name and '' != name"> |
|
|
|
|
|
and basic.nick_name like concat('%', #{name},'%') |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != phone and '' != phone"> |
|
|
|
|
|
and basic.phone like concat('%', #{phone},'%') |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
and credit.create_date >= #{startTime} |
|
|
and credit.create_date >= #{startTime} |
|
|
</if> |
|
|
</if> |
|
|
<if test=" null != endTime"> |
|
|
<if test=" null != endTime"> |
|
|
and credit.create_date < #{endTime} |
|
|
and credit.create_date < #{endTime} |
|
|
</if> |
|
|
</if> |
|
|
<if test=" null != tenantId and '' != tenantId"> |
|
|
|
|
|
and credit.`tenant_id` = #{tenantId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != operatorType "> |
|
|
<if test=" null != operatorType "> |
|
|
and credit.operator_type = #{operatorType} |
|
|
and credit.operator_type = #{operatorType} |
|
|
</if> |
|
|
</if> |
|
|
@@ -118,17 +47,26 @@ |
|
|
<if test=" null != merchantId "> |
|
|
<if test=" null != merchantId "> |
|
|
and credit.merchant_id = #{merchantId} |
|
|
and credit.merchant_id = #{merchantId} |
|
|
</if> |
|
|
</if> |
|
|
<if test=" null != merchantName and ''!=merchantName "> |
|
|
|
|
|
and merchant.name like concat('%', #{merchantName},'%') |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != ticketNumber and ''!=ticketNumber "> |
|
|
<if test=" null != ticketNumber and ''!=ticketNumber "> |
|
|
and credit.ticket_number like concat('%', #{ticketNumber},'%') |
|
|
and credit.ticket_number like concat('%', #{ticketNumber},'%') |
|
|
</if> |
|
|
</if> |
|
|
|
|
|
|
|
|
<if test=" null != buserId "> |
|
|
<if test=" null != buserId "> |
|
|
and credit.buser_id = #{buserId} |
|
|
and credit.buser_id = #{buserId} |
|
|
</if> |
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != merchantIds "> |
|
|
|
|
|
and credit.merchantId in |
|
|
|
|
|
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> |
|
|
|
|
|
#{merchantIdItem} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != cUserIds "> |
|
|
|
|
|
and credit.c_user_id in |
|
|
|
|
|
<foreach collection="cUserIds" index="index" item="cUserIdItem" open="(" separator="," close=")"> |
|
|
|
|
|
#{cUserIdItem} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if> |
|
|
</sql> |
|
|
</sql> |
|
|
|
|
|
|
|
|
<select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> |
|
|
<select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> |
|
|
@@ -136,58 +74,19 @@ |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap"> |
|
|
<select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap"> |
|
|
select <include refid="allColumns" /> from wx_credit_history |
|
|
|
|
|
|
|
|
select <include refid="allColumns" /> |
|
|
|
|
|
from wx_credit_history credit |
|
|
|
|
|
where `tenant_id` = #{tenantId} |
|
|
<include refid="dynamicWhereConditions" /> |
|
|
<include refid="dynamicWhereConditions" /> |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap"> |
|
|
<select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap"> |
|
|
SELECT |
|
|
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.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 |
|
|
credit.operator_type,credit.operator_id,credit.merchant_id,credit.ticket_number,credit.change_purpose |
|
|
FROM wx_credit_history credit |
|
|
FROM wx_credit_history credit |
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
<if test=" null != startTime "> |
|
|
|
|
|
and credit.create_date >= #{startTime} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != endTime"> |
|
|
|
|
|
and credit.create_date < #{endTime} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != operatorType "> |
|
|
|
|
|
and credit.operator_type = #{operatorType} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != operatorId "> |
|
|
|
|
|
and credit.operator_id = #{operatorId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != creditType "> |
|
|
|
|
|
and credit.credit_type = #{creditType} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != cUserId "> |
|
|
|
|
|
and credit.c_user_id = #{cUserId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != merchantId "> |
|
|
|
|
|
and credit.merchant_id = #{merchantId} |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != ticketNumber and ''!=ticketNumber "> |
|
|
|
|
|
and credit.ticket_number like concat('%', #{ticketNumber},'%') |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test=" null != buserId "> |
|
|
|
|
|
and credit.buser_id = #{buserId} |
|
|
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != merchantIds "> |
|
|
|
|
|
and credit.merchantId in |
|
|
|
|
|
<foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> |
|
|
|
|
|
#{merchantIdItem} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if> |
|
|
|
|
|
|
|
|
|
|
|
<if test=" null != cUserIds "> |
|
|
|
|
|
and credit.c_user_id in |
|
|
|
|
|
<foreach collection="cUserIds" index="index" item="cUserIdItem" open="(" separator="," close=")"> |
|
|
|
|
|
#{cUserIdItem} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if> |
|
|
|
|
|
|
|
|
<include refid="dynamicWhereConditions" /> |
|
|
ORDER BY credit.create_date DESC |
|
|
ORDER BY credit.create_date DESC |
|
|
<if test=" null != begin "> |
|
|
<if test=" null != begin "> |
|
|
limit #{begin}, #{limit} |
|
|
limit #{begin}, #{limit} |
|
|
@@ -253,38 +152,28 @@ |
|
|
</if> |
|
|
</if> |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<select id="getTotalCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
|
|
|
resultType="java.lang.Long"> |
|
|
|
|
|
select ifnull(sum(credit.amount),0) amount from ( |
|
|
|
|
|
select basic.credit as amount,credit.c_user_id from wx_credit_history credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id |
|
|
|
|
|
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id |
|
|
|
|
|
<include refid="customWhereConditions"/> |
|
|
|
|
|
group by credit.c_user_id |
|
|
|
|
|
) credit |
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
<select id="getIncrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
<select id="getIncrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
resultType="java.lang.Long"> |
|
|
resultType="java.lang.Long"> |
|
|
select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id |
|
|
|
|
|
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id |
|
|
|
|
|
<include refid="customWhereConditions"/> |
|
|
|
|
|
|
|
|
select ifnull(sum(credit.credit_num),0) amount |
|
|
|
|
|
from wx_credit_history credit |
|
|
|
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
|
|
|
<include refid="dynamicWhereConditions"/> |
|
|
and credit.credit_num>0 |
|
|
and credit.credit_num>0 |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<select id="getDecrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
<select id="getDecrementCreditAmount" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
resultType="java.lang.Long"> |
|
|
resultType="java.lang.Long"> |
|
|
select ABS(ifnull(sum(credit.credit_num),0)) amount from wx_credit_history credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id |
|
|
|
|
|
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id |
|
|
|
|
|
<include refid="customWhereConditions"/> |
|
|
|
|
|
|
|
|
select ABS(ifnull(sum(credit.credit_num),0)) amount |
|
|
|
|
|
from wx_credit_history credit |
|
|
|
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
|
|
|
<include refid="dynamicWhereConditions"/> |
|
|
and credit.credit_num < 0 |
|
|
and credit.credit_num < 0 |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<select id="getAddCreditSummary" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
<select id="getAddCreditSummary" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
resultType="java.lang.Integer"> |
|
|
resultType="java.lang.Integer"> |
|
|
select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit |
|
|
|
|
|
|
|
|
select ifnull(sum(credit.credit_num),0) amount |
|
|
|
|
|
from wx_credit_history credit |
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
and credit.credit_num > 0 and credit.c_user_id = #{cUserId} |
|
|
and credit.credit_num > 0 and credit.c_user_id = #{cUserId} |
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
@@ -298,9 +187,11 @@ |
|
|
|
|
|
|
|
|
<select id="getLesCreditSummary" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
<select id="getLesCreditSummary" parameterType="com.iformall.domain.po.WxCreditHistory" |
|
|
resultType="java.lang.Integer"> |
|
|
resultType="java.lang.Integer"> |
|
|
select ifnull(sum(credit.credit_num),0) amount from wx_credit_history credit |
|
|
|
|
|
|
|
|
select ifnull(sum(credit.credit_num),0) amount |
|
|
|
|
|
from wx_credit_history credit |
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
and credit.credit_num < 0 and credit.c_user_id = #{cUserId} |
|
|
|
|
|
|
|
|
and credit.credit_num < 0 |
|
|
|
|
|
and credit.c_user_id = #{cUserId} |
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
and credit.create_date >= #{startTime} |
|
|
and credit.create_date >= #{startTime} |
|
|
</if> |
|
|
</if> |
|
|
@@ -310,13 +201,10 @@ |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<select id="getPeopleCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Long"> |
|
|
<select id="getPeopleCount" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="java.lang.Long"> |
|
|
select count(1) people from ( |
|
|
|
|
|
select count(*) people from wx_credit_history credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info basic ON basic.id = credit.c_user_id |
|
|
|
|
|
LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id |
|
|
|
|
|
<include refid="customWhereConditions"/> |
|
|
|
|
|
group by credit.c_user_id |
|
|
|
|
|
) credit |
|
|
|
|
|
|
|
|
select count(distinct credit.c_user_id) people |
|
|
|
|
|
from wx_credit_history credit |
|
|
|
|
|
where credit.`tenant_id` = #{tenantId} |
|
|
|
|
|
<include refid="dynamicWhereConditions"/> |
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
<delete id="deleteById" parameterType="java.util.HashMap"> |
|
|
<delete id="deleteById" parameterType="java.util.HashMap"> |
|
|
@@ -345,9 +233,10 @@ |
|
|
) wm |
|
|
) wm |
|
|
left join |
|
|
left join |
|
|
( |
|
|
( |
|
|
select credit.merchant_id,sum(credit.credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id |
|
|
|
|
|
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num > 0 |
|
|
|
|
|
|
|
|
select credit.merchant_id,sum(credit.credit_num) sum_credit_num |
|
|
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
where credit.merchant_id is not null |
|
|
|
|
|
and credit.merchant_id != -1 and credit.credit_num > 0 |
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
and credit.create_date >= #{startTime} |
|
|
and credit.create_date >= #{startTime} |
|
|
</if> |
|
|
</if> |
|
|
@@ -358,9 +247,10 @@ |
|
|
) a on a.merchant_id = wm.id |
|
|
) a on a.merchant_id = wm.id |
|
|
left join |
|
|
left join |
|
|
( |
|
|
( |
|
|
select credit.merchant_id,sum(credit.credit_num) sum_credit_num from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id |
|
|
|
|
|
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num < 0 |
|
|
|
|
|
|
|
|
select credit.merchant_id,sum(credit.credit_num) sum_credit_num |
|
|
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
where credit.merchant_id is not null |
|
|
|
|
|
and credit.merchant_id != -1 and credit.credit_num < 0 |
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
and credit.create_date >= #{startTime} |
|
|
and credit.create_date >= #{startTime} |
|
|
</if> |
|
|
</if> |
|
|
@@ -371,9 +261,10 @@ |
|
|
) b on b.merchant_id = wm.id |
|
|
) b on b.merchant_id = wm.id |
|
|
left join |
|
|
left join |
|
|
( |
|
|
( |
|
|
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id |
|
|
|
|
|
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num > 0 |
|
|
|
|
|
|
|
|
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id |
|
|
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
where credit.merchant_id is not null |
|
|
|
|
|
and credit.merchant_id != -1 and credit.credit_num > 0 |
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
and credit.create_date >= #{startTime} |
|
|
and credit.create_date >= #{startTime} |
|
|
</if> |
|
|
</if> |
|
|
@@ -384,9 +275,10 @@ |
|
|
) c on c.merchant_id = wm.id |
|
|
) c on c.merchant_id = wm.id |
|
|
left join |
|
|
left join |
|
|
( |
|
|
( |
|
|
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
INNER JOIN wx_c_user_basic_info${shardFinalTableSuffix} basic ON basic.id = credit.c_user_id |
|
|
|
|
|
where credit.merchant_id is not null and credit.merchant_id != -1 and credit.credit_num < 0 |
|
|
|
|
|
|
|
|
select credit.merchant_id,count(distinct credit.c_user_id) count_c_user_id |
|
|
|
|
|
from wx_credit_history${shardFinalTableSuffix} credit |
|
|
|
|
|
where credit.merchant_id is not null |
|
|
|
|
|
and credit.merchant_id != -1 and credit.credit_num < 0 |
|
|
<if test=" null != startTime "> |
|
|
<if test=" null != startTime "> |
|
|
and credit.create_date >= #{startTime} |
|
|
and credit.create_date >= #{startTime} |
|
|
</if> |
|
|
</if> |
|
|
|