xiaoyong931011
2022-11-23 d7140004b514b43f9734d050fb65d0c2898cca7f
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
<?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="cc.mrbird.febs.dapp.mapper.IgtOnHookPlanOrderItemDao">
 
    <select id="selectByOrderIdAndMemberIdAndState" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrderItem">
        SELECT
            a.*
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
        and a.member_id = #{memberId}
        and a.state = #{state}
        order by order_num asc
        limit 1
    </select>
 
    <select id="selectTotalProfitByByOrderIdAndMemberIdAndState" resultType="java.math.BigDecimal">
        SELECT
            ifnull(sum(a.profit),0)
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
          and a.member_id = #{memberId}
          and a.is_goal = #{isGoal}
          and a.state = #{state}
    </select>
 
    <select id="selectTotalAmountByByOrderIdAndMemberIdAndState" resultType="java.math.BigDecimal">
        SELECT
            ifnull(sum(a.amount),0)
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
          and a.member_id = #{memberId}
          and a.is_goal = #{isGoal}
          and a.state = #{state}
    </select>
 
    <select id="selectByMemberIdAndBelongNum" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrderItem">
        SELECT
            a.*
        FROM igt_on_hook_plan_order_item a
        where
              a.member_id = #{memberId}
          and a.belong_num = #{recordNum}
            limit 1
    </select>
 
    <select id="selectTotalProfitByMemberIdAndStateAndIsgoal" resultType="java.math.BigDecimal">
        SELECT
            ifnull(sum(a.profit),0)
        FROM igt_on_hook_plan_order a
        where  a.member_id = #{memberId}
          and a.state = #{state}
    </select>
 
    <select id="selectByIgtIdAndMemberId" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrderItem">
        SELECT
            a.*
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
          and a.member_id = #{memberId}
        order by create_time desc
    </select>
 
    <select id="selectTotalAmountByCreateTimeAndOrderId" resultType="java.math.BigDecimal">
        SELECT
            ifnull(sum(a.amount),0)
        FROM igt_on_hook_plan_order_item a
        <where>
            a.order_id = #{orderId}
            and a.create_time &lt; #{endTime}
            <if test="startTime != null">
                and a.create_time > #{startTime}
            </if>
        </where>
    </select>
 
    <select id="selectByIsgoalAndOrderId" resultType="java.lang.Long">
        SELECT
            a.id
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
          and a.is_goal = #{isGoal}
        order by create_time desc
    </select>
 
    <select id="selectByCreateTimeAndIsgoaAndOrderId" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrderItem">
        SELECT
            a.*
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
          and a.is_goal = #{isGoal}
          and a.id &lt; #{id}
        order by a.id desc
        limit 1
    </select>
 
    <select id="selectOneByIgtIdAndMemberId" resultType="cc.mrbird.febs.dapp.entity.IgtOnHookPlanOrderItem">
        SELECT
            a.*
        FROM igt_on_hook_plan_order_item a
        where a.order_id = #{orderId}
          and a.member_id = #{memberId}
        order by a.id desc
            limit 1
    </select>
 
    <select id="selectTotalAmountByIDAndOrderId" resultType="java.math.BigDecimal">
        SELECT
        ifnull(sum(a.amount),0)
        FROM igt_on_hook_plan_order_item a
        <where>
            a.order_id = #{orderId}
            and a.id &lt; #{end}
            <if test="start != null">
                and a.id > #{start}
            </if>
        </where>
    </select>
 
 
</mapper>