59 lines
2.5 KiB
XML
59 lines
2.5 KiB
XML
<?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.ycwl.basic.mapper.BrokerMapper">
|
|
<insert id="add">
|
|
insert into broker(id, `name`, promo_code) values (#{id}, #{name}, #{promoCode})
|
|
</insert>
|
|
<update id="update">
|
|
update broker set `name` = #{name}, promo_code = #{promoCode} where id = #{id}
|
|
</update>
|
|
<update id="updateStatus">
|
|
update broker
|
|
set status = (CASE
|
|
status
|
|
WHEN 1 THEN
|
|
0
|
|
WHEN 0 THEN
|
|
1
|
|
ELSE null
|
|
END)
|
|
where id = #{id}
|
|
</update>
|
|
<delete id="deleteById">
|
|
delete from broker where id = #{id}
|
|
</delete>
|
|
<select id="list" resultType="com.ycwl.basic.model.pc.broker.entity.BrokerEntity">
|
|
select id, `name`, phone, promo_code, status,
|
|
(select count(1) from `order` where broker_id = broker.id) as broker_order_count,
|
|
(select sum(pay_price) from `order` where broker_id = broker.id) as broker_order_amount,
|
|
(select create_at from `order` where broker_id = broker.id and status = 1 order by create_at desc limit 1) as last_broker_date,
|
|
(select create_at from `order` where broker_id = broker.id and status = 1 order by create_at asc limit 1) as first_broker_date,
|
|
create_at, update_at
|
|
from broker
|
|
<where>
|
|
<if test="name!= null and name!= ''">
|
|
and `name` like concat('%', #{name}, '%')
|
|
</if>
|
|
<if test="phone!= null and phone!= ''">
|
|
and `phone` like concat('%', #{phone}, '%')
|
|
</if>
|
|
<if test="promoCode!= null and promoCode!= ''">
|
|
and promo_code like concat('%', #{promoCode}, '%')
|
|
</if>
|
|
<if test="status!= null">
|
|
and `status` = #{status}
|
|
</if>
|
|
<if test="startTime!=null">
|
|
and d.create_at >= #{startTime}
|
|
</if>
|
|
<if test="endTime!=null">
|
|
and d.create_at <= #{endTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="getById" resultType="com.ycwl.basic.model.pc.broker.entity.BrokerEntity">
|
|
select id, `name`, promo_code, status, create_at, update_at
|
|
from broker
|
|
where id = #{id}
|
|
</select>
|
|
</mapper> |