You've already forked FrameTour-BE
推客
This commit is contained in:
@ -2,10 +2,10 @@
|
||||
<!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 into broker(scenic_id, `name`, phone, status, broker_enable, broker_rate, create_at, update_at) values (#{scenicId}, #{name}, #{phone}, 0, #{brokerEnable}, #{brokerRate}, now(), now())
|
||||
</insert>
|
||||
<update id="update">
|
||||
update broker set `name` = #{name}, promo_code = #{promoCode} where id = #{id}
|
||||
update broker set `name` = #{name}, phone = #{phone}, broker_enable = #{brokerEnable}, broker_rate = #{brokerRate}, update_at = now() where id = #{id}
|
||||
</update>
|
||||
<update id="updateStatus">
|
||||
update broker
|
||||
@ -15,45 +15,56 @@
|
||||
0
|
||||
WHEN 0 THEN
|
||||
1
|
||||
ELSE null
|
||||
ELSE 1
|
||||
END)
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateBrokerEnable">
|
||||
update broker
|
||||
set broker_enable = (CASE
|
||||
broker_enable
|
||||
WHEN 1 THEN
|
||||
0
|
||||
WHEN 0 THEN
|
||||
1
|
||||
ELSE 1
|
||||
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,
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.broker.resp.BrokerRespVO">
|
||||
select b.id, scenic_id, s.name as scenicName, b.`name`, b.phone, b.broker_enable, b.broker_rate, b.status, b.create_at, b.update_at,
|
||||
(select count(1) from statistics s where s.type = 20 and s.morph_id = b.id) as broker_scan_count,
|
||||
(select count(1) from broker_record r where r.broker_id = b.id) as broker_order_count,
|
||||
(select sum(order_price) from broker_record r where r.broker_id = b.id) as broker_order_amount,
|
||||
create_at, update_at
|
||||
from broker
|
||||
from broker b left join scenic s on b.scenic_id = s.id
|
||||
<where>
|
||||
<if test="scenicId!= null">
|
||||
and b.scenic_id = #{scenicId}
|
||||
</if>
|
||||
<if test="name!= null and name!= ''">
|
||||
and `name` like concat('%', #{name}, '%')
|
||||
and b.`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}, '%')
|
||||
and b.`phone` like concat('%', #{phone}, '%')
|
||||
</if>
|
||||
<if test="status!= null">
|
||||
and `status` = #{status}
|
||||
and b.`status` = #{status}
|
||||
</if>
|
||||
<if test="startTime!=null">
|
||||
and d.create_at >= #{startTime}
|
||||
and b.create_at >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime!=null">
|
||||
and d.create_at <= #{endTime}
|
||||
and b.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 id="getById" resultType="com.ycwl.basic.model.pc.broker.resp.BrokerRespVO">
|
||||
select b.id, scenic_id, s.name as scenicName, b.`name`, b.phone, b.broker_enable, b.broker_rate, b.status, b.create_at, b.update_at
|
||||
from broker b left join scenic s on b.scenic_id = s.id
|
||||
where b.id = #{id}
|
||||
</select>
|
||||
</mapper>
|
86
src/main/resources/mapper/BrokerRecordMapper.xml
Normal file
86
src/main/resources/mapper/BrokerRecordMapper.xml
Normal file
@ -0,0 +1,86 @@
|
||||
<?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.BrokerRecordMapper">
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.broker.resp.BrokerRecordRespVO">
|
||||
select id, broker_id, order_id, order_price, broker_rate, broker_price, reason, create_time
|
||||
from broker_record
|
||||
<where>
|
||||
<if test="brokerId != null">
|
||||
and broker_id = #{brokerId}
|
||||
</if>
|
||||
<if test="orderId != null">
|
||||
and order_id = #{orderId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
and create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="com.ycwl.basic.model.pc.broker.resp.BrokerRecordRespVO">
|
||||
select id, broker_id, order_id, order_price, broker_rate, broker_price, reason, create_time
|
||||
from broker_record
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDailySummaryByBrokerId" resultType="com.ycwl.basic.model.pc.broker.resp.DailySummaryRespVO">
|
||||
SELECT date_series.date AS date,
|
||||
COALESCE(COUNT(br.id), 0) AS recordCount,
|
||||
COALESCE(SUM(br.order_price), 0) AS totalOrderPrice
|
||||
FROM (
|
||||
SELECT DATE_ADD(#{startTime}, INTERVAL (units.i + tens.i * 10 + hundreds.i * 100) DAY) AS date
|
||||
FROM (SELECT 0 AS i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) units
|
||||
CROSS JOIN (SELECT 0 AS i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) tens
|
||||
CROSS JOIN (SELECT 0 AS i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) hundreds
|
||||
WHERE DATE_ADD(#{startTime}, INTERVAL (units.i + tens.i * 10) DAY) <= #{endTime}
|
||||
) date_series
|
||||
LEFT JOIN broker_record br ON DATE(br.create_time) = date_series.date AND br.broker_id = #{brokerId}
|
||||
GROUP BY date_series.date
|
||||
ORDER BY date_series.date
|
||||
</select>
|
||||
|
||||
<insert id="add">
|
||||
insert into broker_record(broker_id, order_id, order_price, broker_rate, broker_price, reason, create_time)
|
||||
values (#{brokerId}, #{orderId}, #{orderPrice}, #{brokerRate}, #{brokerPrice}, #{reason}, now())
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete from broker_record
|
||||
where id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteByOrderId">
|
||||
delete from broker_record
|
||||
where order_id = #{orderId}
|
||||
</delete>
|
||||
|
||||
<update id="update">
|
||||
update broker_record
|
||||
<set>
|
||||
<if test="brokerId != null">
|
||||
broker_id = #{brokerId},
|
||||
</if>
|
||||
<if test="orderId != null">
|
||||
order_id = #{orderId},
|
||||
</if>
|
||||
<if test="orderPrice != null">
|
||||
order_price = #{orderPrice},
|
||||
</if>
|
||||
<if test="brokerRate != null">
|
||||
broker_rate = #{brokerRate},
|
||||
</if>
|
||||
<if test="brokerPrice != null">
|
||||
broker_price = #{brokerPrice},
|
||||
</if>
|
||||
<if test="reason != null">
|
||||
reason = #{reason},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
@ -247,4 +247,20 @@
|
||||
and create_at <= #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getBrokerIdListForUser" resultType="java.lang.Long">
|
||||
select morph_id
|
||||
from (
|
||||
select morph_id, max(create_time) as createTime
|
||||
from statistics
|
||||
where type = 20 and member_id = #{memberId}
|
||||
<if test="startTime!= null">
|
||||
and create_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime!= null">
|
||||
and create_time <= #{endTime}
|
||||
</if>
|
||||
group by morph_id
|
||||
) a
|
||||
order by createTime desc
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user