无关风月
2025-02-28 2f8e70ad2884d2b6b7443dfae0af11ae9cfc8b99
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
<?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.jilongda.manage.mapper.TOrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.jilongda.manage.model.TOrder">
        <id column="id" property="id" />
        <result column="code" property="code" />
        <result column="userId" property="userId" />
        <result column="optometryId" property="optometryId" />
        <result column="storeId" property="storeId" />
        <result column="color" property="color" />
        <result column="series" property="series" />
        <result column="rLens" property="rLens" />
        <result column="lLens" property="lLens" />
        <result column="type" property="type" />
        <result column="refractiveIndex" property="refractiveIndex" />
        <result column="createTime" property="createTime" />
        <result column="updateTime" property="updateTime" />
        <result column="createBy" property="createBy" />
        <result column="updateBy" property="updateBy" />
        <result column="isDelete" property="isDelete" />
        <result column="sysId" property="sysId" />
        <result column="couponId" property="couponId" />
        <result column="itemsId" property="itemsId" />
        <result column="remark" property="remark" />
        <result column="isMail" property="isMail" />
        <result column="mailName" property="mailName" />
        <result column="mailPhone" property="mailPhone" />
        <result column="mailAddress" property="mailAddress" />
        <result column="orderMoney" property="orderMoney" />
        <result column="couponMoney" property="couponMoney" />
        <result column="payMoney" property="payMoney" />
        <result column="isMachining" property="isMachining" />
        <result column="machiningCode" property="machiningCode" />
        <result column="isAccounting" property="isAccounting" />
        <result column="accountingName" property="accountingName" />
        <result column="accountingTime" property="accountingTime" />
        <result column="phone" property="phone" />
        <result column="realName" property="realName" />
        <result column="age" property="age" />
        <result column="gender" property="gender" />
        <result column="payTypeName" property="payTypeName" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, code, userId, optometryId, storeId, color, series, rLens, lLens, `type`, refractiveIndex, createTime, updateTime, createBy,
            updateBy, isDelete, sysId, couponId, itemsId, remark, isMail, mailName, mailPhone, mailAddress, orderMoney, couponMoney, payMoney,
            isMachining, machiningCode, isAccounting, accountingName, accountingTime,phone, realName, age, gender,payTypeName
    </sql>
    <select id="getOrderDetailById" resultType="com.jilongda.manage.vo.TOrderVO">
        select  o.id, o.code, o.userId, o.optometryId, o.storeId, o.color, o.series, o.rLens, o.lLens, o.`type`, o.refractiveIndex, o.createTime, o.updateTime, o.createBy,
                o.updateBy, o.isDelete, o.sysId, o.couponId, o.itemsId, o.remark, o.isMail, o.mailName, o.mailPhone, o.mailAddress, o.orderMoney, o.couponMoney, o.payMoney,
                o.isMachining, o.machiningCode, o.isAccounting, o.accountingName, o.accountingTime,o.phone, o.realName, o.age, o.gender,o.payTypeName,
                su.nick_name AS staffName,s.name AS storeName,tc.name AS couponName
        from t_order o
        left join sec_user su on o.sysId = su.id
        left join t_store s on s.id = o.storeId
        left join t_coupon_receive tcr on tcr.id = o.couponId
        left join t_coupon tc on tc.id = tcr.couponId
        where o.id = #{orderId} and o.isDelete = 0
    </select>
    <select id="pageList" resultType="com.jilongda.manage.model.TOrder">
        select o.id, o.code, o.userId, o.optometryId, o.storeId, o.color, o.series, o.rLens, o.lLens, o.`type`, o.refractiveIndex, o.createTime, o.updateTime, o.createBy,
        o.updateBy, o.isDelete, o.sysId, o.couponId, o.itemsId, o.remark, o.isMail, o.mailName, o.mailPhone, o.mailAddress, o.orderMoney, o.couponMoney, o.payMoney,
        o.isMachining, o.machiningCode, o.isAccounting, o.accountingName, o.accountingTime,o.phone, o.realName, o.age, o.gender,o.payTypeName
        from t_order o
        left join t_order_goods tog on o.id = tog.orderId
        where 1=1
        <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
            and o.createTime between #{query.startTime} and #{query.endTime}
        </if>
        <if test="query.startMoney != null ">
            and o.orderMoney between #{query.startMoney} and #{query.endMoney}
        </if>
        <if test="query.realName != null and query.realName != ''">
            and o.realName like concat('%',#{query.realName},'%')
        </if>
        <if test="query.wxName != null and query.wxName != ''">
            and o.`name` like concat('%',#{query.wxName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and o.phone like concat('%',#{query.phone},'%')
        </if>
        <if test="query.brandFrame != null and query.brandFrame != ''">
            and tog.brandName = #{query.brandFrame}
        </if>
        <if test="query.modelName != null and query.modelName != ''">
            and tog.modelName = #{query.modelName}
        </if>
        <if test="query.color != null and query.color != ''">
            and tog.color = #{query.color}
        </if>
        <if test="query.brandLens != null and query.brandLens != ''">
            and tog.brandName = #{query.brandLens}
        </if>
        <if test="query.series != null and query.series != ''">
            and tog.seriesName = #{query.series}
        </if>
        <if test="query.type != null">
            and tog.type = #{query.type}
        </if>
        <if test="query.refractiveIndex != null  and query.refractiveIndex != ''">
            and tog.refractiveIndex = #{query.refractiveIndex}
        </if>
        <if test="query.storeId != null">
            and o.storeId = #{query.storeId}
        </if>
        <if test="query.sysId != null">
            and o.sysId = #{query.sysId}
        </if>
        <if test="query.userId != null">
            and o.userId = #{query.userId}
        </if>
        <if test="query.userIds != null and query.userIds.size()>0">
            AND o.userId IN
            <foreach collection="query.userIds" close=")" open="(" item="id" separator=",">
                #{id}
            </foreach>
        </if>
        <if test="query.orderIds != null and query.orderIds.size()>0">
            AND o.id IN
            <foreach collection="query.orderIds" close=")" open="(" item="id" separator=",">
                #{id}
            </foreach>
        </if>
        group by o.id
        order by o.createTime desc
    </select>
</mapper>