xuekang
2024-05-13 15a0280ae9e7db96fdf0744c722d214d2cb5a0e5
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?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.nuvole.four.mapper.ActivityFeeMapper" >
  <select id="selectList" parameterType="com.nuvole.four.domain.query.ActivityFeeQuery" resultType="com.nuvole.four.domain.ActivityFee">
    select <include refid="Base_Column_List"></include>
    from activity_fee
    <where>
      deleted = 0
      <if test="orgId!=null">
        and org_id =#{orgId}
      </if>
      <if test="orgCode!=null and orgCode!=''">
        and org_code like concat(#{orgCode}, '%')
      </if>
      <if test="name!=null and name!=''">
        and name like concat('%',#{name},'%')
      </if>
      <if test="code!=null and code!=''">
        and code like concat('%',#{code},'%')
      </if>
      <if test="beginTime!=null">
        and begin_time =#{beginTime}
      </if>
      <if test="endTime!=null">
        and end_time =#{endTime}
      </if>
      <if test="expireTime!=null">
        and expire_time =#{expireTime}
      </if>
      <if test="totalFee!=null">
        and total_fee =#{totalFee}
      </if>
      <if test="useFee!=null">
        and use_fee =#{useFee}
      </if>
      <if test="surplusFee!=null">
        and surplus_fee =#{surplusFee}
      </if>
      <if test="onlineAgreeWxRate!=null">
        and online_agree_wx_rate =#{onlineAgreeWxRate}
      </if>
      <if test="onlineAgreeZfbRate!=null">
        and online_agree_zfb_rate =#{onlineAgreeZfbRate}
      </if>
      <if test="onlineAgreeUnionpayRate!=null">
        and online_agree_unionpay_rate =#{onlineAgreeUnionpayRate}
      </if>
      <if test="offlineAgreeWxRate!=null">
        and offline_agree_wx_rate =#{offlineAgreeWxRate}
      </if>
      <if test="offlineAgreeZfbRate!=null">
        and offline_agree_zfb_rate =#{offlineAgreeZfbRate}
      </if>
      <if test="offlineAgreeUnionpayRate!=null">
        and offline_agree_unionpay_rate =#{offlineAgreeUnionpayRate}
      </if>
      <if test="onlineMerWxRate!=null">
        and online_mer_wx_rate =#{onlineMerWxRate}
      </if>
      <if test="onlineMerZfbRate!=null">
        and online_mer_zfb_rate =#{onlineMerZfbRate}
      </if>
      <if test="onlineMerUnionpayRate!=null">
        and online_mer_unionpay_rate =#{onlineMerUnionpayRate}
      </if>
      <if test="offlineMerWxRate!=null">
        and offline_mer_wx_rate =#{offlineMerWxRate}
      </if>
      <if test="offlineMerZfbRate!=null">
        and offline_mer_zfb_rate =#{offlineMerZfbRate}
      </if>
      <if test="offlineMerUnionpayRate!=null">
        and offline_mer_unionpay_rate =#{offlineMerUnionpayRate}
      </if>
      <if test="status!=null">
        and status =#{status}
      </if>
      <if test="deleted!=null">
        and deleted =#{deleted}
      </if>
      <if test="createBy!=null">
        and create_by =#{createBy}
      </if>
      <if test="createTime!=null">
        and create_time =#{createTime}
      </if>
      <if test="updateBy!=null">
        and update_by =#{updateBy}
      </if>
      <if test="updateTime!=null">
        and update_time =#{updateTime}
      </if>
    </where>
  </select>
 
  <select id="selectActivityWithDistribute" parameterType="com.nuvole.four.domain.query.ActivityFeeQuery" resultType="com.nuvole.four.domain.ActivityFee">
    SELECT
      af.id ,
      adr.org_id,
      adr.org_code,
      af.`name`,
      af.code,
      af.begin_time,
      af.end_time,
      af.expire_time,
      af.offline_mer_wx_rate,
      af.offline_mer_zfb_rate,
      af.offline_mer_unionpay_rate,
      af.`status`,
      af.create_time,
      af.create_by
    FROM
      activity_fee af
        JOIN activity_distribute_record adr ON adr.activity_id = af.id
    and af.deleted = 0
    <where>
      <if test="orgId != null">
        and adr.org_id = #{orgId}
      </if>
      <if test="orgCode!=null and orgCode!=''">
        and adr.org_code like concat(#{orgCode}, '%')
      </if>
      <if test="name!=null and name!=''">
        and af.name like concat('%',#{name},'%')
      </if>
      <if test="code!=null and code!=''">
        and af.code like concat('%',#{code},'%')
      </if>
      <if test="beginTime!=null">
        and af.begin_time =#{beginTime}
      </if>
      <if test="endTime!=null">
        and af.end_time =#{endTime}
      </if>
      <if test="expireTime!=null">
        and af.expire_time =#{expireTime}
      </if>
    </where>
    UNION
    SELECT
      af.id,
      '',
      '',
      af.`name`,
      af.CODE,
      af.begin_time,
      af.end_time,
      af.expire_time,
      af.offline_mer_wx_rate,
      af.offline_mer_zfb_rate,
      af.offline_mer_unionpay_rate,
      af.`status`,
      af.create_time,
      af.create_by
    FROM
        activity_fee af
    WHERE
        af.deleted = 0
    AND af.create_by = #{createBy}
 
  </select>
 
    <select id="getActivityFeeDetail" resultType="com.nuvole.four.domain.dto.ActivityDistributeBudgetDto">
      SELECT
        adr.id,
        af.total_fee totalFee,
        af.surplus_fee surplusFee,
        so.id orgId,
        so.NAME orgName,
        so.org_code orgCode,
        so.lv orgLv,
        so.pid pId,
        IFNULL( af.use_fee, 0 ) useFee,
        if( adr.id is null, 0, 1) useOrNot
      FROM
        sys_org so
          LEFT JOIN activity_distribute_record adr ON adr.org_id = so.id AND adr.deleted = 0
          left join activity_fee af on af.id = adr.activity_id and af.deleted = 0
      where so.pid = #{orgId}
      GROUP BY
        so.id
      ORDER BY
        sort_no
    </select>
</mapper>