TASK: 1.affiliate 新增referral新增、查询、修改以及其他相关的自动结算佣金的功能;2.删除affiliate_income表及相关mapper
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ai.da.mapper.primary.AffiliateIncomeMapper">
|
||||
|
||||
<select id="getPersonalMonthlyIncome" resultType="java.util.Map">
|
||||
SELECT
|
||||
DATE_FORMAT(payment_time, '%m') as yearMonth,
|
||||
SUM(commission) AS totalCommission
|
||||
FROM
|
||||
t_affiliate_income
|
||||
WHERE
|
||||
YEAR(payment_time) = #{year}
|
||||
and affiliate_account_id = #{affiliateAccountId}
|
||||
GROUP BY
|
||||
yearMonth
|
||||
ORDER BY
|
||||
yearMonth
|
||||
</select>
|
||||
|
||||
<select id="getMonthlyAffiliateIncome" resultType="java.util.Map">
|
||||
SELECT
|
||||
DATE_FORMAT(payment_time, '%m') as yearMonth,
|
||||
SUM(amount) AS totalAmount,
|
||||
SUM(commission) AS totalCommission
|
||||
FROM
|
||||
t_affiliate_income
|
||||
WHERE
|
||||
YEAR(payment_time) = #{year}
|
||||
and MONTH(payment_time) = #{month}
|
||||
GROUP BY
|
||||
yearMonth
|
||||
ORDER BY
|
||||
yearMonth
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -38,12 +38,24 @@
|
||||
AND f.id = #{affiliateId}
|
||||
</if>
|
||||
</where>
|
||||
<if test="order != null and order.toUpperCase() == 'DESC'">
|
||||
ORDER BY f.create_time DESC
|
||||
</if>
|
||||
<if test="order == null or order.toUpperCase() != 'DESC'">
|
||||
ORDER BY f.create_time ASC
|
||||
</if>
|
||||
<choose>
|
||||
<when test="sortField != null and sortField != ''">
|
||||
ORDER BY
|
||||
<choose>
|
||||
<when test="sortField == 'id'">f.id</when>
|
||||
<when test="sortField == 'totalEarnings'">f.total_earnings</when>
|
||||
<when test="sortField == 'createTime'">f.create_time</when>
|
||||
<otherwise>f.create_time</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="order != null and order.toUpperCase() == 'DESC'">DESC</when>
|
||||
<otherwise>ASC</otherwise>
|
||||
</choose>
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY f.create_time ASC
|
||||
</otherwise>
|
||||
</choose>
|
||||
LIMIT ${size} OFFSET ${offset}
|
||||
</select>
|
||||
|
||||
|
||||
81
src/main/resources/mapper/primary/ReferralMapper.xml
Normal file
81
src/main/resources/mapper/primary/ReferralMapper.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ai.da.mapper.primary.ReferralMapper">
|
||||
|
||||
<!-- resources/mapper/ReferralMapper.xml -->
|
||||
<select id="selectReferralWithAffiliate" resultType="com.ai.da.model.vo.ReferralPageQueryVO">
|
||||
SELECT
|
||||
r.*,
|
||||
ac.user_name AS affiliateName
|
||||
FROM
|
||||
t_referral r
|
||||
LEFT JOIN
|
||||
t_account ac ON r.affiliate_account_id = ac.id
|
||||
${ew.customSqlSegment} <!-- 动态条件 -->
|
||||
</select>
|
||||
|
||||
<!-- Mapper.xml -->
|
||||
<update id="batchDeleteByIds">
|
||||
UPDATE t_referral
|
||||
SET is_deleted = 1
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- Mapper.xml -->
|
||||
<select id="sumAmount" resultType="java.math.BigDecimal">
|
||||
SELECT SUM(commission)
|
||||
FROM t_referral
|
||||
WHERE affiliate_id = #{affiliateId}
|
||||
<if test="statusList != null and statusList.size() > 0">
|
||||
AND status IN
|
||||
<foreach collection="statusList" item="status" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND create_time <![CDATA[<=]]> #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getPersonalMonthlyIncome" resultType="java.util.Map">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%m') as yearMonth,
|
||||
SUM(commission) AS totalCommission
|
||||
FROM
|
||||
t_referral
|
||||
WHERE
|
||||
YEAR(create_time) = #{year}
|
||||
and affiliate_account_id = #{affiliateAccountId}
|
||||
and is_deleted = 0
|
||||
and status in ("Paid", "Unpaid")
|
||||
GROUP BY
|
||||
yearMonth
|
||||
ORDER BY
|
||||
yearMonth
|
||||
</select>
|
||||
|
||||
<select id="getMonthlyAffiliateIncome" resultType="java.util.Map">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%m') as yearMonth,
|
||||
SUM(amount) AS totalAmount,
|
||||
SUM(CASE WHEN status = 'Paid' THEN commission ELSE 0 END) AS paidCommission,
|
||||
SUM(CASE WHEN status = 'Unpaid' THEN commission ELSE 0 END) AS unpaidCommission
|
||||
FROM
|
||||
t_referral
|
||||
WHERE
|
||||
YEAR(create_time) = #{year}
|
||||
AND MONTH(create_time) = #{month}
|
||||
AND is_deleted = 0
|
||||
AND status IN ('Paid', 'Unpaid')
|
||||
GROUP BY
|
||||
yearMonth
|
||||
ORDER BY
|
||||
yearMonth
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user