OrderBaseInfoMapper.xml
3.93 KB
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
<?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.order.erp.mapper.order.OrderBaseInfoMapper">
<select id="queryProjectNoAndInnerNoDto" resultType="com.order.erp.domain.vo.order.QueryProjectNoAndInnerNoDto">
<if test="flag == true">
SELECT DISTINCT project_no
FROM order_base_info
WHERE enable_flag = 10
AND project_no like concat('%',#{dto.projectNo},'%')
</if>
<if test="flag == false">
SELECT DISTINCT inner_no
FROM order_base_info
WHERE enable_flag = 10
AND inner_no like concat('%',#{dto.innerNo},'%')
</if>
</select>
<select id="salesAmountStatistics" resultType="java.lang.Double">
SELECT SUM(opa.customer_total_price) AS total_price
FROM order_base_info obi
JOIN order_profit_analysis opa ON opa.order_id = obi.id and opa.enable_flag = 10
WHERE obi.enable_flag = 10 <!-- 用于动态添加条件 -->
<!-- 动态添加 customer_code 条件 -->
<if test="customerCodeIn != null and customerCodeIn.size() > 0">
AND customer_code IN
<foreach collection="customerCodeIn" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<!-- 动态添加 create_time 范围条件 -->
<if test="begin != null">
AND obi.create_time >= #{begin}
</if>
<if test="end != null">
AND obi.create_time <![CDATA[ <= ]]> #{end}
</if>
</select>
<select id="salesAmountTarget" resultType="java.lang.Double">
SELECT SUM(relation_value) AS total_value
FROM system_setting
WHERE relation_code = 'salesAmount'
and enable_flag = 10
<!-- 动态添加 setting_name 条件 -->
<if test="customerCodeIn != null and customerCodeIn.size() > 0">
AND setting_value IN
<foreach collection="customerCodeIn" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<resultMap id="mapResult" type="map">
<result property="key" column="k"/>
<result property="value" column="v"/>
</resultMap>
<select id="customerSalesStatus" resultMap="mapResult">
SELECT
obi.customer_code AS k,
SUM(opa.customer_total_price) AS v
FROM
order_base_info obi
JOIN
order_profit_analysis opa ON opa.order_id = obi.id AND opa.enable_flag = 10
WHERE
obi.enable_flag = 10
<if test="customerCodeIn != null and customerCodeIn.size() > 0">
AND obi.customer_code IN
<foreach item="item" index="index" collection="customerCodeIn" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="begin != null">
AND obi.create_time >= #{begin}
</if>
<if test="end != null">
AND obi.create_time <![CDATA[ <= ]]> #{end}
</if>
GROUP BY
obi.customer_code
</select>
<select id="countRecentMonthValueByOrderStatus" resultType="com.order.erp.domain.vo.order.DateYearMonthTimeVO">
SELECT
DATE_FORMAT(obi.create_time, '%Y-%m') AS date,
SUM(opa.customer_total_price) AS totalPrice,
YEAR(obi.create_time) AS yearType
FROM
order_base_info obi
JOIN
order_profit_analysis opa
ON
opa.order_id = obi.id
AND opa.enable_flag = 10
WHERE
obi.enable_flag = 10
AND YEAR(obi.create_time) IN
<foreach item="year" collection="years" open="(" close=")" separator=",">
#{year}
</foreach>
GROUP BY
DATE_FORMAT(obi.create_time, '%Y-%m'),
YEAR(obi.create_time)
ORDER BY
date;
</select>
</mapper>