| | |
| | | select COALESCE(SUM(commission_price), 0.00) AS total_commission from tb_order where status in (4,5) and share_user_id =#{id} |
| | | </select> |
| | | <select id="getOrderPage" resultType="com.ruoyi.system.pojo.vo.OrderPageVO"> |
| | | select |
| | | c.id, |
| | | o.order_no, |
| | | publish.user_name as publishName, |
| | | publish.phone as publishPhone, |
| | | o.price, |
| | | book.user_name as bookName, |
| | | book.phone as bookPhone, |
| | | c.create_time as createTime, |
| | | o.create_time as bookTime, |
| | | o.finish_time as finishTime, |
| | | -- 状态映射逻辑 |
| | | SELECT |
| | | c.id, |
| | | o.order_no, |
| | | publish.user_name AS publishName, |
| | | publish.phone AS publishPhone, |
| | | o.price, |
| | | book.user_name AS bookName, |
| | | book.phone AS bookPhone, |
| | | c.create_time AS createTime, |
| | | o.create_time AS bookTime, |
| | | o.finish_time AS finishTime, |
| | | -- 状态映射逻辑 |
| | | CASE |
| | | WHEN c.status = -1 THEN -1 |
| | | WHEN c.status = 1 THEN 1 |
| | | WHEN c.status = 2 THEN 7 |
| | | WHEN c.status = 3 THEN 6 |
| | | WHEN c.status = 4 THEN |
| | | CASE |
| | | WHEN o.status = 1 THEN 1 |
| | | WHEN o.status = 2 THEN 2 |
| | | WHEN o.status = 3 THEN 3 |
| | | WHEN o.status IN (4, 5) THEN 4 |
| | | WHEN o.status = 6 THEN 6 |
| | | ELSE c.status |
| | | END |
| | | ELSE c.status |
| | | END AS status |
| | | FROM |
| | | tb_company c |
| | | LEFT JOIN tb_order o ON o.company_id = c.id AND o.status != -1 |
| | | LEFT JOIN (SELECT id, user_name, phone FROM tb_user GROUP BY id) publish ON c.user_id = publish.id |
| | | LEFT JOIN (SELECT id, user_name, phone FROM tb_user GROUP BY id) book ON o.user_id = book.id |
| | | WHERE |
| | | c.is_delete = 0 |
| | | <if test="null != dto.orderNo"> |
| | | AND o.order_no LIKE CONCAT('%', #{dto.orderNo}, '%') |
| | | </if> |
| | | <if test="null != dto.publishName and '' != dto.publishName"> |
| | | AND publish.user_name LIKE CONCAT('%', #{dto.publishName}, '%') |
| | | </if> |
| | | <if test="null != dto.publishPhone and '' != dto.publishPhone"> |
| | | AND publish.phone LIKE CONCAT('%', #{dto.publishPhone}, '%') |
| | | </if> |
| | | <if test="null != dto.bookName and '' != dto.bookName"> |
| | | AND book.user_name LIKE CONCAT('%', #{dto.bookName}, '%') |
| | | </if> |
| | | <if test="null != dto.bookPhone and '' != dto.bookPhone"> |
| | | AND book.phone LIKE CONCAT('%', #{dto.bookPhone}, '%') |
| | | </if> |
| | | <if test="null != dto.createTimeStart and null != dto.createTimeEnd"> |
| | | AND c.create_time BETWEEN #{dto.createTimeStart} AND #{dto.createTimeEnd} |
| | | </if> |
| | | <if test="null != dto.bookTimeStart and null != dto.bookTimeEnd"> |
| | | AND o.create_time BETWEEN #{dto.bookTimeStart} AND #{dto.bookTimeEnd} |
| | | </if> |
| | | <if test="null != dto.finishTimeStart and null != dto.finishTimeEnd"> |
| | | AND o.finish_time BETWEEN #{dto.finishTimeStart} AND #{dto.finishTimeEnd} |
| | | </if> |
| | | <if test="null != dto.status"> |
| | | AND ( |
| | | -- 直接匹配原始状态 |
| | | (c.status IN (1,2,3) AND |
| | | CASE |
| | | WHEN c.status = 1 THEN 1 |
| | | WHEN c.status = 2 THEN 6 |
| | | WHEN c.status = 3 THEN 5 |
| | | WHEN c.status = 4 THEN |
| | | CASE |
| | | WHEN o.status = 2 THEN 2 |
| | | WHEN o.status = 3 THEN 3 |
| | | WHEN o.status IN (4, 5) THEN 4 |
| | | ELSE c.status -- 默认保持原状态(可根据需求调整) |
| | | END |
| | | ELSE c.status -- 其他状态保持不变 |
| | | END AS status |
| | | from |
| | | tb_company c |
| | | left join tb_order o on c.id = o.company_id and o.status != -1 |
| | | left join (select id,user_name,phone from tb_user group by id) publish on c.user_id = publish.id |
| | | left join (select id,user_name,phone from tb_user group by id) book on o.user_id = book.id |
| | | where |
| | | c.is_delete=0 |
| | | |
| | | <if test="null != dto.orderNo"> |
| | | and o.order_no like concat('%',#{dto.orderNo},'%') |
| | | </if> |
| | | <if test="null != dto.publishName and '' != dto.publishName"> |
| | | and publish.user_name like concat('%',#{dto.publishName},'%') |
| | | </if> |
| | | <if test="null != dto.publishPhone and '' != dto.publishPhone"> |
| | | and publish.phone like concat('%',#{dto.publishPhone},'%') |
| | | </if> |
| | | |
| | | <if test="null != dto.bookName and '' != dto.bookName"> |
| | | and book.user_name like concat('%',#{dto.bookName},'%') |
| | | </if> |
| | | <if test="null != dto.bookPhone and '' != dto.bookPhone"> |
| | | and book.phone like concat('%',#{dto.bookPhone},'%') |
| | | </if> |
| | | |
| | | <if test="null != dto.createTimeStart and null != dto.createTimeEnd"> |
| | | and c.create_time between #{dto.createTimeStart} and #{dto.createTimeEnd} |
| | | </if> |
| | | |
| | | <if test="null != dto.bookTimeStart and null != dto.bookTimeEnd"> |
| | | and o.create_time between #{dto.bookTimeStart} and #{dto.bookTimeEnd} |
| | | </if> |
| | | |
| | | <if test="null != dto.finishTimeStart and null != dto.finishTimeEnd"> |
| | | and o.finish_time between #{dto.finishTimeStart} and #{dto.finishTimeEnd} |
| | | </if> |
| | | |
| | | <if test="null != dto.status"> |
| | | AND ( |
| | | <!-- 直接匹配原始状态 --> |
| | | (c.status IN (1,2,3) AND |
| | | CASE |
| | | WHEN c.status = 1 THEN 1 |
| | | WHEN c.status = 2 THEN 6 |
| | | WHEN c.status = 3 THEN 5 |
| | | ELSE c.status |
| | | END = #{dto.status}) |
| | | <!-- 匹配映射后的状态4(c.status=4且o.status=4/5) --> |
| | | OR (c.status = 4 AND o.status IN (4,5) AND 4 = #{dto.status}) |
| | | <!-- 匹配映射后的状态2(c.status=4且o.status=2) --> |
| | | OR (c.status = 4 AND o.status = 2 AND 2 = #{dto.status}) |
| | | <!-- 匹配映射后的状态3(c.status=4且o.status=3) --> |
| | | OR (c.status = 4 AND o.status = 3 AND 3 = #{dto.status}) |
| | | ) |
| | | </if> |
| | | WHEN c.status = 1 THEN 1 |
| | | WHEN c.status = 2 THEN 6 |
| | | WHEN c.status = 3 THEN 5 |
| | | ELSE c.status |
| | | END = #{dto.status}) |
| | | -- 匹配映射后的状态4(c.status=4且o.status=4/5) |
| | | OR (c.status = 4 AND o.status IN (4,5) AND 4 = #{dto.status}) |
| | | -- 匹配映射后的状态2(c.status=4且o.status=2) |
| | | OR (c.status = 4 AND o.status = 2 AND 2 = #{dto.status}) |
| | | -- 匹配映射后的状态3(c.status=4且o.status=3) |
| | | OR (c.status = 4 AND o.status = 3 AND 3 = #{dto.status}) |
| | | ) |
| | | order by c.create_time,o.create_time |
| | | </if> |
| | | </select> |
| | | <select id="getDetailById" resultType="com.ruoyi.system.pojo.vo.OrderDetailVO"> |
| | | |
| | |
| | | -- 状态映射逻辑 |
| | | CASE |
| | | WHEN c.status = 1 THEN 1 |
| | | WHEN c.status = 2 THEN 6 |
| | | WHEN c.status = 3 THEN 5 |
| | | WHEN c.status = 2 THEN 7 |
| | | WHEN c.status = 3 THEN 6 |
| | | WHEN c.status = 4 THEN |
| | | CASE |
| | | WHEN o.status = 2 THEN 2 |
| | |
| | | ELSE c.status -- 其他状态保持不变 |
| | | END AS status, |
| | | o.id as orderId, |
| | | |
| | | c.company_name, |
| | | c.establish_time, |
| | | concat(c.city,c.province,c.area) as place, |
| | |
| | | ( |
| | | CASE |
| | | WHEN c.status = 1 THEN 1 |
| | | WHEN c.status = 2 THEN 6 |
| | | WHEN c.status = 3 THEN 5 |
| | | WHEN c.status = 2 THEN 7 |
| | | WHEN c.status = 3 THEN 6 |
| | | WHEN c.status = 4 THEN |
| | | CASE |
| | | WHEN o.status = 2 THEN 2 |
| | |
| | | FROM tb_order |
| | | WHERE status IN (4, 5, 6) |
| | | AND is_refund = 0 |
| | | <if test="null != dto.orderNo and '' != dto.orderNo"> |
| | | and order_no LIKE CONCAT('%', #{dto.orderNo}, '%') |
| | | </if> |
| | | <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> |
| | | and pay_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} |
| | | </if> |
| | | AND ( #{dto.type} IS NULL OR 1 = #{dto.type} ) |
| | | </select> |
| | | <select id="flowsPage" resultType="com.ruoyi.system.pojo.vo.FinanceFlowsPageVO"> |
| | | SELECT |
| | |
| | | <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> |
| | | and pay_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} |
| | | </if> |
| | | AND ( #{dto.type} IS NULL OR 1 = #{dto.type} ) |
| | | AND ( #{dto.type} IS NULL OR 1 = #{dto.type} ) |
| | | UNION ALL |
| | | SELECT |
| | | order_no, |
| | |
| | | <if test="null != dto.operateTimeStart and null != dto.operateTimeEnd"> |
| | | and refund_time between #{dto.operateTimeStart} and #{dto.operateTimeEnd} |
| | | </if> |
| | | AND ( #{dto.type} IS NULL OR 2 = #{dto.type} ) |
| | | AND ( #{dto.type} IS NULL OR 2 = #{dto.type} ) |
| | | ORDER BY operateTime DESC |
| | | LIMIT #{dto.pageNum}, #{dto.pageSize}; |
| | | LIMIT #{dto.offset}, #{dto.pageSize}; |
| | | </select> |
| | | <select id="countFlowsPage" resultType="java.lang.Long"> |
| | | SELECT COUNT(*) FROM ( |