mitao
2024-07-08 022a7ff7abf82cd2546e18071ade5228b4e2339f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?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.sinata.modular.mall.dao.CommissionSettlementMonthMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.sinata.modular.mall.model.CommissionSettlementMonth">
        <id column="id" property="id"/>
        <result column="userId" property="userId"/>
        <result column="showId" property="showId"/>
        <result column="orderNo" property="orderNo"/>
        <result column="provinceCode" property="provinceCode"/>
        <result column="cityCode" property="cityCode"/>
        <result column="countyCode" property="countyCode"/>
        <result column="salesCommissionGoods" property="salesCommissionGoods"/>
        <result column="salesCommissionGroup" property="salesCommissionGroup"/>
        <result column="manageProfitGoods" property="manageProfitGoods"/>
        <result column="manageProfitGroup" property="manageProfitGroup"/>
        <result column="breedAward" property="breedAward"/>
        <result column="commissionPayable" property="commissionPayable"/>
        <result column="addBeforeTax" property="addBeforeTax"/>
        <result column="subBeforeTax" property="subBeforeTax"/>
        <result column="commissionBeforeTax" property="commissionBeforeTax"/>
        <result column="paymentAmount" property="paymentAmount"/>
        <result column="createTime" property="createTime"/>
        <result column="month" property="month"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userId, showId, orderNo, provinceCode, cityCode, countyCode, salesCommissionGoods, salesCommissionGroup, manageProfitGoods, manageProfitGroup, breedAward, commissionPayable, addBeforeTax, subBeforeTax, commissionBeforeTax, paymentAmount, createTime, month
    </sql>
 
    <sql id="fromTabWhereSql">
        FROM
            `mall_commission_settlement_month` cm
        LEFT JOIN t_city_region province on province.`code` = cm.provinceCode
        LEFT JOIN t_city_region city on city.`code` = cm.cityCode
        LEFT JOIN t_city_region county on county.`code` = cm.countyCode
        LEFT JOIN mem_user mu on mu.id = cm.userId
        <where>
            <if test="month != null and month !=''">
                and cm.month = #{month}
            </if>
            <if test="name != null and name !=''">
                and mu.nick_name like CONCAT("%",#{name},"%")
            </if>
            <if test="showId != null and showId !=''">
                and mu.show_id like CONCAT("%",#{showId},"%")
            </if>
            <if test="area != null and area !=''">
                and (
                province.`name` like CONCAT("%",#{area},"%") or
                city.`name` like CONCAT("%",#{area},"%") or
                county.`name` like CONCAT("%",#{area},"%")
                )
            </if>
            <if test="cityCode != null and cityCode !=''">
                and (
                    cm.cityCode like CONCAT(#{cityCode},"%")
                    OR cm.countyCode like CONCAT(#{cityCode},"%")
                )
            </if>
            <if test="gradeId != null">
                and mu.member_grade_id = #{gradeId}
            </if>
            <if test="beginTime != null and beginTime !=''">
                and cm.month <![CDATA[ >= ]]> #{beginTime}
            </if>
            <if test="endTime != null and endTime !=''">
                and cm.month <![CDATA[ <= ]]> #{endTime}
            </if>
        </where>
    </sql>
 
    <select id="queryList" resultType="com.sinata.modular.mall.model.CommissionSettlementMonth">
        SELECT
            province.`name` provinceCodeName,city.`name` cityCodeName,county.`name` countyCodeName,
            mu.show_id showId, mu.nick_name userName,mu.member_grade_id,
            cm.*
        <include refid="fromTabWhereSql"/>
        <if test="offset != null and size != null">
            limit #{offset}, #{size}
        </if>
    </select>
 
    <select id="queryListCount" resultType="java.lang.Integer">
        SELECT COUNT(*) <include refid="fromTabWhereSql"/>
    </select>
 
    <insert id="addList">
        REPLACE INTO `mall_commission_settlement_month`
            (`userId`, `showId`,`provinceCode`, `cityCode`, `countyCode`, `salesCommissionGoods`,
             `salesCommissionGroup`, `manageProfitGoods`, `manageProfitGroup`, `breedAward`, `commissionPayable`,
             `addBeforeTax`, `subBeforeTax`, `commissionBeforeTax`, `paymentAmount`, `month`) VALUES
        <foreach collection="addMonthList" item="month"
                 separator=",">
            (#{month.userId}, #{month.showId}, #{month.provinceCode}, #{month.cityCode}, #{month.countyCode}, #{month.salesCommissionGoods},
            #{month.salesCommissionGroup}, #{month.manageProfitGoods}, #{month.manageProfitGroup}, #{month.breedAward}, #{month.commissionPayable},
            #{month.addBeforeTax}, #{month.subBeforeTax}, #{month.commissionBeforeTax}, #{month.paymentAmount}, #{month.month})
        </foreach>
 
 
    </insert>
</mapper>