wang-hao-jie
2022-06-06 4e837c1e8c6f8a7252fb95776a1530ab737bb684
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
package cn.exrick.xboot.your.mapper;
 
import cn.exrick.xboot.your.vo.Month;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.exrick.xboot.your.entity.OrderLog;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
/**
 * 订单日志表数据处理层
 * @author whj
 */
public interface OrderLogMapper extends BaseMapper<OrderLog> {
 
    @Select("SELECT sum(num) FROM t_order_log where type=0")
    int sumNum();
 
    @Select("select \n" +
            "sum(case month(t.create_time) when '1' then t.num else 0 end) as january,\n" +
            "sum(case month(t.create_time) when '2' then t.num else 0 end) as february,\n" +
            "sum(case month(t.create_time) when '3' then t.num else 0 end) as march,\n" +
            "sum(case month(t.create_time) when '4' then t.num else 0 end) as april,\n" +
            "sum(case month(t.create_time) when '5' then t.num else 0 end) as may,\n" +
            "sum(case month(t.create_time) when '6' then t.num else 0 end) as june,\n" +
            "sum(case month(t.create_time) when '7' then t.num else 0 end) as july,\n" +
            "sum(case month(t.create_time) when '8' then t.num else 0 end) as august,\n" +
            "sum(case month(t.create_time) when '9' then t.num else 0 end) as september,\n" +
            "sum(case month(t.create_time) when '10' then t.num else 0 end) as october,\n" +
            "sum(case month(t.create_time) when '11' then t.num else 0 end) as november,\n" +
            "sum(case month(t.create_time) when '12' then t.num else 0 end) as december\n" +
            "from t_order_log t\n" +
            "where year(t.create_time)=#{year} and type=0")
    Month getSendNum(@Param("year")int year);
}