Blame view

parking-module-order/src/main/resources/mybatis/mapper/smapper/IncomeStatisticMonthSMapper.xml 10.4 KB
55f68655   王彪总   新项目
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
  <?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.zteits.order.mapper.smapper.IncomeStatisticMonthSMapper" >
    <resultMap id="BaseResultMap" type="com.zteits.order.domain.IncomeStatisticMonth">
      <id column="id" jdbcType="BIGINT" property="id" />
      <result column="static_date" jdbcType="DATE" property="staticDate" />
      <result column="static_date_str" jdbcType="VARCHAR" property="staticDateStr" />
      <result column="org_id" jdbcType="INTEGER" property="orgId" />
      <result column="area_id" jdbcType="VARCHAR" property="areaId" />
      <result column="area_name" jdbcType="VARCHAR" property="areaName" />
      <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
      <result column="pl_name" jdbcType="VARCHAR" property="plName" />
      <result column="pl_type" jdbcType="INTEGER" property="plType" />
      <result column="park_order_num" jdbcType="INTEGER" property="parkOrderNum" />
      <result column="park_short_time_free_num" jdbcType="INTEGER" property="parkShortTimeFreeNum" />
      <result column="park_temp_num" jdbcType="INTEGER" property="parkTempNum" />
      <result column="park_authorization_free_num" jdbcType="INTEGER" property="parkAuthorizationFreeNum" />
      <result column="park_hand_open_num" jdbcType="INTEGER" property="parkHandOpenNum" />
      <result column="park_white_car_num" jdbcType="INTEGER" property="parkWhiteCarNum" />
      <result column="park_total_fee" jdbcType="BIGINT" property="parkTotalFee" />
      <result column="park_act_fee" jdbcType="BIGINT" property="parkActFee" />
      <result column="park_dicount_fee" jdbcType="BIGINT" property="parkDicountFee" />
      <result column="park_arrearage_fee" jdbcType="BIGINT" property="parkArrearageFee" />
      <result column="park_refund_fee" jdbcType="BIGINT" property="parkRefundFee" />
      <result column="park_ali_fee" jdbcType="BIGINT" property="parkAliFee" />
      <result column="park_ali_charge_num" jdbcType="INTEGER" property="parkAliChargeNum" />
      <result column="park_wx_fee" jdbcType="BIGINT" property="parkWxFee" />
      <result column="park_wx_charge_num" jdbcType="INTEGER" property="parkWxChargeNum" />
      <result column="park_cash_fee" jdbcType="BIGINT" property="parkCashFee" />
      <result column="park_cash_charge_num" jdbcType="INTEGER" property="parkCashChargeNum" />
      <result column="park_balance_fee" jdbcType="BIGINT" property="parkBalanceFee" />
      <result column="park_balance_charge_num" jdbcType="INTEGER" property="parkBalanceChargeNum" />
      <result column="card_order_num" jdbcType="INTEGER" property="cardOrderNum" />
      <result column="card_total_fee" jdbcType="BIGINT" property="cardTotalFee" />
      <result column="card_act_fee" jdbcType="BIGINT" property="cardActFee" />
      <result column="card_dicount_fee" jdbcType="BIGINT" property="cardDicountFee" />
      <result column="card_app_num" jdbcType="INTEGER" property="cardAppNum" />
      <result column="card_wx_num" jdbcType="INTEGER" property="cardWxNum" />
      <result column="card_platform_num" jdbcType="INTEGER" property="cardPlatformNum" />
      <result column="card_site_num" jdbcType="INTEGER" property="cardSiteNum" />
      <result column="card_ali_fee" jdbcType="BIGINT" property="cardAliFee" />
      <result column="card_ali_charge_num" jdbcType="INTEGER" property="cardAliChargeNum" />
      <result column="card_wx_fee" jdbcType="BIGINT" property="cardWxFee" />
      <result column="card_wx_charge_num" jdbcType="INTEGER" property="cardWxChargeNum" />
      <result column="card_cash_fee" jdbcType="BIGINT" property="cardCashFee" />
      <result column="card_cash_charge_num" jdbcType="INTEGER" property="cardCashChargeNum" />
      <result column="card_balance_fee" jdbcType="BIGINT" property="cardBalanceFee" />
      <result column="card_balance_charge_num" jdbcType="INTEGER" property="cardBalanceChargeNum" />
      <result column="card_year_card_fee" jdbcType="BIGINT" property="cardYearCardFee" />
      <result column="card_month_card_fee" jdbcType="BIGINT" property="cardMonthCardFee" />
      <result column="card_season_card_fee" jdbcType="BIGINT" property="cardSeasonCardFee" />
      <result column="card_half_year_card_fee" jdbcType="BIGINT" property="cardHalfYearCardFee" />
      <result column="card_day_card_fee" jdbcType="BIGINT" property="cardDayCardFee" />
      <result column="back_order_num" jdbcType="INTEGER" property="backOrderNum" />
      <result column="back_total_fee" jdbcType="BIGINT" property="backTotalFee" />
      <result column="back_act_fee" jdbcType="BIGINT" property="backActFee" />
      <result column="back_dicount_fee" jdbcType="BIGINT" property="backDicountFee" />
      <result column="back_app_num" jdbcType="INTEGER" property="backAppNum" />
      <result column="back_wx_num" jdbcType="INTEGER" property="backWxNum" />
      <result column="back_platform_num" jdbcType="INTEGER" property="backPlatformNum" />
      <result column="back_site_num" jdbcType="INTEGER" property="backSiteNum" />
      <result column="back_ali_fee" jdbcType="BIGINT" property="backAliFee" />
      <result column="back_ali_charge_num" jdbcType="INTEGER" property="backAliChargeNum" />
      <result column="back_wx_fee" jdbcType="BIGINT" property="backWxFee" />
      <result column="back_wx_charge_num" jdbcType="INTEGER" property="backWxChargeNum" />
      <result column="back_cash_fee" jdbcType="BIGINT" property="backCashFee" />
      <result column="back_cash_charge_num" jdbcType="INTEGER" property="backCashChargeNum" />
      <result column="back_balance_fee" jdbcType="BIGINT" property="backBalanceFee" />
      <result column="back_balance_charge_num" jdbcType="INTEGER" property="backBalanceChargeNum" />
      <result column="remark" jdbcType="VARCHAR" property="remark" />
      <result column="data_state" jdbcType="INTEGER" property="dataState" />
      <result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
      <result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
      <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
      <result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId" />
      <result column="modfiy_emp_name" jdbcType="VARCHAR" property="modfiyEmpName" />
      <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
    </resultMap>
  
    <sql id="Base_Column_List" >
      id, static_date, static_date_str, org_id, area_id, area_name, pl_no, pl_name, pl_type,
      park_order_num, park_short_time_free_num, park_temp_num, park_authorization_free_num,
      park_hand_open_num, park_white_car_num, park_total_fee, park_act_fee, park_dicount_fee,
      park_arrearage_fee, park_refund_fee, park_ali_fee, park_ali_charge_num, park_wx_fee,
      park_wx_charge_num, park_cash_fee, park_cash_charge_num, park_balance_fee, park_balance_charge_num,
      card_order_num, card_total_fee, card_act_fee, card_dicount_fee, card_app_num, card_wx_num,
      card_platform_num, card_site_num, card_ali_fee, card_ali_charge_num, card_wx_fee,
      card_wx_charge_num, card_cash_fee, card_cash_charge_num, card_balance_fee, card_balance_charge_num,
      card_year_card_fee, card_month_card_fee, card_season_card_fee, card_half_year_card_fee,
      card_day_card_fee, back_order_num, back_total_fee, back_act_fee, back_dicount_fee,
      back_app_num, back_wx_num, back_platform_num, back_site_num, back_ali_fee, back_ali_charge_num,
      back_wx_fee, back_wx_charge_num, back_cash_fee, back_cash_charge_num, back_balance_fee,
      back_balance_charge_num, remark, data_state, create_emp_id, create_emp_name, create_date,
      modfiy_emp_id, modfiy_emp_name, modfiy_date
    </sql>
  
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
      select 
      <include refid="Base_Column_List" />
      from income_statistic_month
      where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectMonthTotalFeeByPlNos" parameterType="com.zteits.clouds.api.dto.order.income.param.IncomeStatisticReportReq"  resultType="com.zteits.clouds.api.dto.order.income.dto.IncomeStatisticTotalFeeDTO" >
    SELECT
      YEAR(static_date) year,
      MONTH(static_date) num,
      IFNULL(sum(park_act_fee), 0) + IFNULL(SUM(card_act_fee), 0) + IFNULL(SUM(back_act_fee), 0)  totalFee
      FROM
      income_statistic_month
      WHERE
      data_state = 1
      <if test="plNos != null and plNos.size >0">
        AND pl_no IN
        <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
          #{plNo}
        </foreach>
      </if>
      GROUP BY
      `year`,
      num
      ORDER BY year desc,num desc
    </select>
  
    <select id="selectMonthStatisticTrentyPlNos" parameterType="com.zteits.clouds.api.dto.order.income.param.IncomeStatisticReportReq"  resultType="com.zteits.clouds.api.dto.order.income.dto.IncomeStatisticTotalFeeDTO" >
      SELECT
      YEAR(static_date) year,
      MONTH(static_date) num,
      IFNULL(sum(park_act_fee), 0) + IFNULL(SUM(card_act_fee), 0) + IFNULL(SUM(back_act_fee), 0) totalFee
      FROM
      income_statistic_month
      WHERE
      data_state = 1
      <if test="plNos != null and plNos.size >0">
        AND pl_no IN
        <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
          #{plNo}
        </foreach>
      </if>
      <if test="year != null">
        AND YEAR(static_date) &lt;= #{year}
      </if>
      <if test="num != null">
        AND month(static_date) &lt;= #{num}
      </if>
      GROUP BY
      `year`,
      num
      ORDER BY year DESC,num desc
      <if test="trentNum != null">
        limit #{trentNum}
      </if>
    </select>
  
    <select id="selectMonthStatisticFeeRankingByPlNos" parameterType="com.zteits.clouds.api.dto.order.income.param.IncomeStatisticReportReq"  resultType="com.zteits.clouds.api.dto.order.income.dto.IncomeStatisticTotalFeeRankingDTO" >
      SELECT
          pl_no as plNo,
          pl_name as plName,
          IFNULL(SUM(park_order_num),0) orderNum,
          IFNULL(SUM(park_hand_open_num),0) parkHandOpenNum,
          IFNULL(sum(park_total_fee), 0) + IFNULL(SUM(card_total_fee), 0) + IFNULL(SUM(back_total_fee), 0) totalFee,
          IFNULL(sum(park_act_fee), 0) + IFNULL(SUM(card_act_fee), 0) + IFNULL(SUM(back_act_fee), 0) actFee
          FROM
          income_statistic_month
          WHERE
          data_state = 1
      <if test="plNos != null and plNos.size >0">
        AND pl_no IN
        <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
          #{plNo}
        </foreach>
      </if>
      <if test="year != null">
        AND YEAR(static_date) = #{year}
      </if>
      <if test="num != null">
        AND month(static_date) = #{num}
      </if>
      GROUP BY plNo,plName
      ORDER BY actFee desc
    </select>
  </mapper>