| | |
| | | <select id="getProcessingCommissionPriceByShareUserId" resultType="java.math.BigDecimal"> |
| | | 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, |
| | | -- 状态映射逻辑 |
| | | 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> |
| | | </select> |
| | | <select id="getDetailById" resultType="com.ruoyi.system.pojo.vo.OrderDetailVO"> |
| | | |
| | | select |
| | | c.id, |
| | | -- 状态映射逻辑 |
| | | 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, |
| | | o.id as orderId, |
| | | c.company_name, |
| | | c.establish_time, |
| | | concat(c.city,c.province,c.area) as place, |
| | | c.registered_capital, |
| | | ct.name as companyCategoryName, |
| | | industry.name as industryName, |
| | | c.taxpayer_type, |
| | | c.tax_credit, |
| | | c.official_seal_num, |
| | | c.paid_in_funds, |
| | | c.oper_name, |
| | | c.scope, |
| | | c.invoice_limit, |
| | | c.social_security, |
| | | c.tendering, |
| | | c.have_trademark, |
| | | c.have_patent, |
| | | c.have_soft_works, |
| | | info.need_rename, |
| | | info.new_district, |
| | | publish.user_name as publishName, |
| | | publish.phone as publishPhone, |
| | | c.create_time as createTime, |
| | | book.user_name as bookName, |
| | | book.phone as bookPhone, |
| | | o.create_time as bookTime, |
| | | o.price as price, |
| | | o.pay_time as payTime, |
| | | o.confirm_time, |
| | | o.seller_finish_time, |
| | | o.finish_time, |
| | | -- 计算预计完成时间 |
| | | CASE |
| | | WHEN |
| | | ( |
| | | 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 |
| | | ) IN (3, 4, 5) |
| | | THEN |
| | | DATE_ADD(o.pay_time, INTERVAL (c.estimated_days+info.add_day) DAY) |
| | | ELSE NULL |
| | | END AS estimateTime |
| | | from tb_company c |
| | | left join tb_company_type ct on c.company_category = ct.id |
| | | left join tb_industry industry on c.company_industry_id = industry.id |
| | | left join tb_order o on c.id= o.company_id and o.status != -1 |
| | | left join tb_buyer_company_info info on o.id = info.order_id |
| | | left join tb_user publish on c.user_id = publish.id |
| | | left join tb_user book on o.user_id = book.id |
| | | where |
| | | c.is_delete=0 |
| | | and |
| | | c.id=#{id} |
| | | |
| | | |
| | | </select> |
| | | </mapper> |