2024-08-28 20:54:03 +08:00
<?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= "cn.iocoder.yudao.module.inspection.mapper.AppInspectionPartnerMapper" >
<select id= "selectById" resultType= "cn.iocoder.yudao.module.shop.entity.ShopMallPartners" >
select * from shop_mall_partners where partner_id = #{id}
</select>
2024-10-23 14:27:58 +08:00
<select id= "selectByIdNew" resultType= "cn.iocoder.yudao.module.shop.entity.ShopMallPartners" >
select * from shop_mall_partners
</select>
2024-08-28 20:54:03 +08:00
<select id= "partnerList" parameterType= "cn.iocoder.yudao.module.inspection.query.PartnerListQuery" resultType= "cn.iocoder.yudao.module.inspection.vo.PartnerListVo" >
SELECT
smp.partner_logo,
smp.address,
smp.average_score,
smp.contact_number,
smp.partner_id,
smp.work_time,
smp.partner_name,
smp.sales_num,
2024-10-11 18:53:33 +08:00
ROUND(ST_Distance_Sphere (POINT (#{vo.longitude}, #{vo.latitude}),POINT (smp.longitude, smp.latitude ))) AS distance,
2024-08-28 20:54:03 +08:00
COUNT(sig.id) goodsNum
FROM
shop_mall_partners smp
Inner JOIN shop_inspection_goods sig ON smp.partner_id = sig.partner_id AND sig.is_listing='1'
WHERE
smp.type = 'jc' and smp.is_banned = '0' and smp.partner_logo is not null
2024-10-11 18:53:33 +08:00
<if test= "vo.distance!=null" >
and ROUND(ST_Distance_Sphere (POINT (#{vo.longitude}, #{vo.latitude}),POINT (smp.longitude, smp.latitude ))) <![CDATA[<=]]> #{vo.distance}*1000
2024-08-28 20:54:03 +08:00
</if>
2024-10-11 18:53:33 +08:00
<if test= "vo.categoryId!=null and vo.categoryId!=''" >
and sig.goods_category_id = #{vo.categoryId}
2024-08-28 20:54:03 +08:00
</if>
2024-10-11 18:53:33 +08:00
<if test= "vo.searchValue!=null and vo.searchValue!=''" >
and (smp.partner_name like concat('%',#{vo.searchValue},'%') or sig.title like concat('%',#{vo.searchValue},'%') )
2024-08-28 20:54:03 +08:00
</if>
GROUP BY
smp.partner_id
<choose >
2024-10-11 18:53:33 +08:00
<when test= "vo.orderType!=null and vo.orderType!='' and vo.orderType == 'jl'" >
2024-08-28 20:54:03 +08:00
order by distance asc,smp.order_num
</when>
2024-10-11 18:53:33 +08:00
<when test= "vo.orderType!=null and vo.orderType!='' and vo.orderType == 'hp'" >
2024-08-28 20:54:03 +08:00
order by smp.average_score desc,smp.order_num
</when>
2024-10-11 18:53:33 +08:00
<when test= "vo.orderType!=null and vo.orderType!='' and vo.orderType == 'xl'" >
2024-08-28 20:54:03 +08:00
order by smp.sales_num desc,smp.order_num
</when>
<otherwise >
order by smp.order_num,distance asc
</otherwise>
</choose>
</select>
<select id= "shopDetail" parameterType= "cn.iocoder.yudao.module.inspection.query.PartnerListQuery" resultType= "cn.iocoder.yudao.module.inspection.vo.PartnerListVo" >
SELECT
smp.partner_logo,
smp.address,
smp.average_score,
smp.contact_number,
smp.partner_id,
smp.work_time,
smp.partner_name,
smp.sales_num,
ROUND(ST_Distance_Sphere (POINT (#{longitude}, #{latitude}),POINT (smp.longitude, smp.latitude ))) AS distance,
smp.longitude,
smp.latitude,
smp.province,
smp.city,
smp.area,
smp.shop_images,
ifnull(smp.is_working,'0') isWorking
FROM
shop_mall_partners smp
where partner_id = #{partnerId}
</select>
<update id= "addSalesNum" >
update
shop_mall_partners
set sales_num = sales_num+1
where partner_id = #{partnerId}
</update>
<select id= "workNum" resultType= "cn.iocoder.yudao.module.inspection.vo.StatisticsInfo" >
SELECT
IfNULL(sum(info.`status`='0') ,0) as workingNum
FROM
inspection_info info
INNER JOIN order_info oi ON info.inspection_order_id = oi.id
WHERE oi.partner_id = #{partnerId} and info.create_time like CONCAT(#{timeStr},'%')
</select>
<select id= "srlNum" resultType= "java.lang.Integer" >
SELECT
count(1)
FROM
inspection_info info
INNER JOIN order_info oi ON info.inspection_order_id = oi.id
2024-10-15 10:34:05 +08:00
WHERE info.end_time like CONCAT(#{timeStr},'%')
2024-08-28 20:54:03 +08:00
and info.is_pass ='1' and oi.goods_title like concat('%','双燃料','%')
</select>
<select id= "hgNum" resultType= "java.lang.Integer" >
SELECT
count(1)
FROM
inspection_info info
INNER JOIN order_info oi ON info.inspection_order_id = oi.id
2024-10-15 10:34:05 +08:00
WHERE info.end_time like CONCAT(#{timeStr},'%')
2024-08-28 20:54:03 +08:00
and info.is_pass ='1'
</select>
<select id= "orderNum" resultType= "cn.iocoder.yudao.module.inspection.vo.StatisticsInfo" >
2025-04-10 17:57:04 +08:00
SELECT IfNULL(
sum((oi.is_online = '1' and oi.validation_time is not null and
oi.validation_time like CONCAT(#{timeStr}, '%'))
or
(oi.is_online = '0' and oi.create_time is not null and
oi.create_time like CONCAT(#{timeStr}, '%'))
), 0) as todayOrderNum,
IfNULL(
sum((oi.pay_time like CONCAT(#{timeStr}, '%') and oi.create_time like CONCAT(#{timeStr}, '%'))),
0) as workedNum,
-- 统计当天未完成的订单
IFNULL(
SUM(
(oi.pay_time IS NULL OR oi.validation_time IS NULL) -- 订单未支付或未验证
AND oi.create_time LIKE CONCAT(#{timeStr}, '%') -- 创建时间属于当天
), 0
) AS uncompletedNum
FROM order_info oi
WHERE oi.deleted = 0
2024-08-28 20:54:03 +08:00
</select>
<select id= "allAmount" resultType= "java.lang.Integer" >
SELECT
IfNULL(sum(oi.pay_money+oi.balance),0) as allAmount
FROM
order_info oi
WHERE oi.partner_id = #{partnerId} and validation_time is not null
</select>
<select id= "todayAmount" resultType= "java.lang.Integer" >
SELECT
IfNULL(sum(oi.pay_money+oi.balance),0) as allAmount
FROM
order_info oi
WHERE oi.partner_id = #{partnerId} and validation_time like CONCAT(#{timeStr},'%')
</select>
<select id= "hotGoodsList" resultType= "cn.iocoder.yudao.module.inspection.vo.HotGoodsVo" >
SELECT
goods.title AS goodsName,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then oi.goods_price else 0 end ) AS salesAmount,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then 1 else 0 end ) AS salesNum
FROM
shop_inspection_goods goods
left join order_info oi on oi.goods_id = goods.id and validation_time is not null and validation_time like concat(#{dateStr},'%')
left JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE
goods.partner_id = #{partnerId}
GROUP BY
goods.id
order by salesNum desc
</select>
2024-10-23 14:27:58 +08:00
<select id= "newHotGoodsList" resultType= "cn.iocoder.yudao.module.inspection.vo.HotGoodsVo" >
SELECT
goods.title AS goodsName,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then oi.goods_price else 0 end ) AS salesAmount,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then 1 else 0 end ) AS salesNum
FROM
order_info oi
left join shop_inspection_goods goods on goods.id = oi.goods_id
left JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE validation_time is not null and validation_time like concat(#{dateStr},'%')
GROUP BY
goods.id
order by salesNum desc
</select>
2024-08-28 20:54:03 +08:00
<select id= "manageGoodsList" resultType= "cn.iocoder.yudao.module.inspection.vo.GoodsVo" >
SELECT
sig.id as goodsId,sig.title as goodsTitle,sig.image as goodsImage,sig.price,count(oi.id) as salesNum,sig.listing_status,sig.reject_reason
FROM
shop_inspection_goods sig
LEFT JOIN order_info oi ON sig.id = oi.goods_id and oi.pay_time is not null
where sig.partner_id =#{partnerId}
<if test= "isListing !=null and isListing!=''" >
and sig.is_listing = #{isListing}
</if>
<if test= "goodsTitle !=null and goodsTitle!=''" >
and sig.title like concat('%',#{goodsTitle},'%')
</if>
group by sig.id
order by sig.order_num,sig.create_time desc
</select>
<select id= "orderList" resultType= "cn.iocoder.yudao.module.inspection.vo.OrderAppDetail" >
SELECT
*
FROM
`order_info`
where partner_id =#{partnerId}
and (order_status BETWEEN '1' and '5')
<if test= "title!=null and title!='' " >
and goods_title like concat('%',#{title},'%')
</if>
<if test= "phoneNum!=null and phoneNum!='' " >
and phonenumber like concat('%',#{phoneNum},'%')
</if>
order by validation_time desc
</select>
<select id= "getWorkList" resultType= "cn.iocoder.yudao.module.partner.entity.PartnerWorker" >
SELECT
2024-09-01 21:13:39 +08:00
pw.id,pw.user_id,su.nickname as workName,su.mobile as workPhone, su.avatar
2024-08-28 20:54:03 +08:00
FROM
partner_worker pw
2024-09-01 21:13:39 +08:00
INNER JOIN system_users su ON pw.user_id = su.id
left JOIN system_user_post sup on sup.user_id = su.id
2024-08-28 20:54:03 +08:00
where pw.partner_id = #{partnerId}
<if test= "workName!=null and workName!=''" >
2024-09-01 21:13:39 +08:00
and su.nickname like concat('%',#{workName},'%')
2024-08-28 20:54:03 +08:00
</if>
<if test= "phoneNum!=null and phoneNum!=''" >
2024-09-01 21:13:39 +08:00
and su.mobile like concat('%',#{phoneNum},'%')
2024-08-28 20:54:03 +08:00
</if>
<if test= "postId!=null and postId!=''" >
and sup.post_id = #{postId}
</if>
order by pw.create_time desc
</select>
<select id= "inspectionList" resultType= "cn.iocoder.yudao.module.inspection.entity.InspectionInfo" >
SELECT
info.id,info.worker_name,info.worker_phone,info.worker_avatar,info.`status`,info.is_pass,info.start_time,info.end_time,step.title as lastTitle,
2024-12-20 15:27:01 +08:00
su.nickname buyName,su.mobile as buyPhone,oi.order_no as orderNo,oi.pay_money+oi.balance as realPayMoney,oi.goods_title as goodsName,info.car_num,info.is_retrial,
info.customer_source as customerSource, info.other_phone as otherPhone,oi.sku_id as skuId, oi.sku_name as skuName,oi.goods_price as goodsPrice
2024-08-28 20:54:03 +08:00
from
inspection_info info
2025-02-15 18:01:18 +08:00
LEFT JOIN inspection_step_info step ON info.id = step.inspection_info_id
2025-04-12 14:01:46 +08:00
LEFT JOIN
inspection_work_node iwn ON info.id = iwn.inspection_info_id
2024-09-01 21:13:39 +08:00
INNER JOIN system_users su on su.id = info.user_id
2024-08-28 20:54:03 +08:00
INNER JOIN order_info oi on oi.id = info.inspection_order_id
2025-04-12 14:01:46 +08:00
WHERE info.partner_id = #{partnerId}
<!-- 待复检 -->
<if test= "status == 4" >
-- AND ii.status = '2'
AND iwn.status = '3'
AND info.status != '1'
</if>
<if test= "status != 4" >
AND info.status = #{status}
</if>
2024-08-28 20:54:03 +08:00
<if test= "carNum!=null and carNum!=''" >
and info.car_num like concat('%',#{carNum},'%')
</if>
GROUP BY info.id
order by info.create_time desc
</select>
<select id= "workerInspectionList" resultType= "cn.iocoder.yudao.module.inspection.entity.InspectionInfo" >
SELECT
info.id,info.worker_name,info.worker_phone,info.worker_avatar,info.`status`,info.is_pass,info.start_time,info.end_time,step.title as lastTitle,
2024-09-01 21:13:39 +08:00
su.nickname buyName,su.mobile as buyPhone,oi.order_no as orderNo,oi.pay_money+oi.balance as realPayMoney,oi.goods_title as goodsName,info.car_num,info.is_retrial
2024-08-28 20:54:03 +08:00
from
inspection_info info
LEFT JOIN inspection_step_info step ON info.id = step.inspection_info_id
2024-09-01 21:13:39 +08:00
INNER JOIN system_users su on su.id = info.user_id
2024-08-28 20:54:03 +08:00
INNER JOIN order_info oi on oi.id = info.inspection_order_id
WHERE info.status = #{status} and info.work_id = #{workerId}
<if test= "searchValue!=null and searchValue!=''" >
and (info.car_num like concat('%',#{searchValue},'%') or su.phonenumber like concat('%',#{searchValue},'%'))
</if>
GROUP BY info.id
order by info.create_time desc
</select>
<select id= "validationList" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
SELECT
order_no,goods_title,goods_price,pay_money,balance,reduce_money,validation_time,validation_real_name,real_name,phonenumber
FROM
order_info
WHERE validation_time is not null and partner_id = #{partnerId}
<if test= "searchValue !=null and searchValue!=''" >
and (phonenumber like concat('%',{searchValue},'%') or validation_real_name like concat('%',{searchValue},'%'))
</if>
order by validation_time desc
</select>
<select id= "getPickCarList" resultType= "cn.iocoder.yudao.module.inspection.entity.InspectionPickCar" >
SELECT
pickCar.*
FROM
inspection_pick_car pickCar
inner join inspection_appointment ia on ia.pick_car_id = pickCar.id
where pickCar.partner_id = #{partnerId}
<if test= "phoneNum !=null and phoneNum!=''" >
and pickCar.user_phone like concat('%',#{phoneNum},'%')
</if>
<if test= "pickStatus == '0'.toString()" >
and pickCar.worker_id is null
</if>
<if test= "pickStatus == '1'.toString()" >
and pickCar.worker_id is not null
</if>
order by pickCar.create_time desc
</select>
<select id= "getPickCarListOfWorker" resultType= "cn.iocoder.yudao.module.inspection.entity.InspectionPickCar" >
SELECT
pickCar.*
FROM
inspection_pick_car pickCar
inner join order_info oi on oi.id = pickCar.order_id and oi.order_status = '1'
where pickCar.worker_id = #{workerId}
<if test= "phoneNum !=null and phoneNum!=''" >
and pickCar.user_phone like concat('%',#{phoneNum},'%')
</if>
<if test= "phoneNum !=null and phoneNum!=''" >
and pickCar.user_phone like concat('%',#{phoneNum},'%')
</if>
order by appointment_day desc,appointment_time desc
</select>
<select id= "chartInfoAmount" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
select sum(pay_money) as realPayMoney,goods_title as goodsTitle from
order_info
where validation_time is not null and validation_time between #{startTime} and #{endTime}
and partner_id = #{partnerId}
group by goods_id
order by realPayMoney desc
</select>
2024-10-22 18:11:12 +08:00
<select id= "newChartInfoAmount" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
select sum(pay_money) as realPayMoney,goods_title as goodsTitle from
order_info
where validation_time is not null and validation_time between #{startTime} and #{endTime}
group by goods_id
order by realPayMoney desc
</select>
2024-08-28 20:54:03 +08:00
<select id= "chartInfoNum" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
select count(1) as realPayNum,goods_title as goodsTitle from
order_info
where validation_time is not null and validation_time between #{startTime} and #{endTime}
and partner_id = #{partnerId}
group by goods_id
order by realPayNum desc
</select>
2024-10-22 18:11:12 +08:00
<select id= "newChartInfoNum" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
select count(1) as realPayNum,goods_title as goodsTitle from
order_info
where validation_time is not null and validation_time between #{startTime} and #{endTime}
group by goods_id
order by realPayNum desc
</select>
2024-08-28 20:54:03 +08:00
<select id= "chartInfoRatio" resultType= "java.util.Map" >
SELECT
ROUND((SUM(ins.is_pass='1')/SUM(1))*100,2) as passRatio,oi.goods_title as goodsTitle
FROM
inspection_info ins
inner join order_info oi on oi.id = ins.inspection_order_id
WHERE ins.create_time between #{startTime} and #{endTime}
and ins.partner_id = #{partnerId}
GROUP BY oi.goods_title
order by passRatio desc
</select>
2024-10-22 18:11:12 +08:00
<select id= "newChartInfoRatio" resultType= "java.util.Map" >
SELECT
ROUND((SUM(ins.is_pass='1')/SUM(1))*100,2) as passRatio,oi.goods_title as goodsTitle
FROM
inspection_info ins
inner join order_info oi on oi.id = ins.inspection_order_id
WHERE ins.create_time between #{startTime} and #{endTime}
GROUP BY oi.goods_title
order by passRatio desc
</select>
2024-08-28 20:54:03 +08:00
<select id= "partnerCategoryList" resultType= "cn.iocoder.yudao.module.inspection.entity.ShopInspectionCategory" >
SELECT
cate.*
FROM
shop_inspection_category cate
INNER JOIN inspection_category_template template on template.category_id = cate.id
2024-12-13 18:13:43 +08:00
<if test= "partnerId == null" >
left JOIN shop_inspection_goods goods ON goods.goods_category_id = cate.id and goods.partner_id = #{partnerId}
where goods.id is null
</if>
2024-08-28 20:54:03 +08:00
group by cate.id
ORDER BY cate.order_num
</select>
<select id= "chartLineInspectionAmount" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
SELECT
IFNULL(SUM(oi.pay_money),0)as realPayMoney
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE oi.partner_id = #{partnerId} and ii.create_time like concat(#{dateStr},'%') and ii.`status`='1' and ii.is_pass = '1' and oi.validation_time is not null
</select>
2024-10-22 18:11:12 +08:00
<select id= "newChartLineInspectionAmount" resultType= "cn.iocoder.yudao.module.payment.entity.OrderInfo" >
SELECT
IFNULL(SUM(oi.pay_money),0)as realPayMoney
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE ii.create_time like concat(#{dateStr},'%') and ii.`status`='1' and ii.is_pass = '1' and oi.validation_time is not null
</select>
2024-08-28 20:54:03 +08:00
<select id= "staticsTable1" resultType= "java.util.Map" >
SELECT
ROUND(IFNULL(SUM(oi.goods_price),0)/100) gsAmount,
ROUND(IFNULL(SUM(case when ii.`status`='1' and ii.is_pass = '1' then oi.pay_money else 0 end)/100,0)) ysAmount,
ROUND(IFNULL(SUM(case when ii.`status`='1' and ii.is_pass = '1' and oi.validation_time is not null then oi.pay_money else 0 end)/100,0)) yjsAmount
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE oi.partner_id =#{partnerId}
and (ii.`status`='1' and ii.is_pass = '1' or ii.`status`='0')
and ii.create_time BETWEEN #{startTime} and #{endTime}
</select>
2024-10-22 18:11:12 +08:00
<select id= "newStaticsTable1" resultType= "java.util.Map" >
SELECT
ROUND(IFNULL(SUM(oi.goods_price),0)/100) gsAmount,
ROUND(IFNULL(SUM(case when ii.`status`='1' and ii.is_pass = '1' then oi.pay_money else 0 end)/100,0)) ysAmount,
ROUND(IFNULL(SUM(case when ii.`status`='1' and ii.is_pass = '1' and oi.validation_time is not null then oi.pay_money else 0 end)/100,0)) yjsAmount
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE (ii.`status`='1' and ii.is_pass = '1' or ii.`status`='0')
and ii.create_time BETWEEN #{startTime} and #{endTime}
</select>
2024-08-28 20:54:03 +08:00
<select id= "staticsTable2" resultType= "java.util.Map" >
SELECT
count(1) allNum,
IFNULL(SUM(ii.status='0'),0) jxzNum,
IFNULL(SUM(ii.status='1'),0) ywcNum
FROM
inspection_info ii
2025-04-10 17:57:04 +08:00
WHERE ii.partner_id =#{partnerId} and ii.deleted = 0
2024-08-28 20:54:03 +08:00
and ii.create_time BETWEEN #{startTime} and #{endTime}
</select>
2024-10-22 18:11:12 +08:00
<select id= "newStaticsTable2" resultType= "java.util.Map" >
SELECT
count(1) allNum,
IFNULL(SUM(ii.status='0'),0) jxzNum,
IFNULL(SUM(ii.status='1'),0) ywcNum
FROM
inspection_info ii
WHERE ii.create_time BETWEEN #{startTime} and #{endTime}
</select>
2024-08-28 20:54:03 +08:00
<select id= "staticsTable3" resultType= "java.util.Map" >
SELECT
ii.customer_source customerSource,IFNULL(sdd.remark,'未知类别') remark,count(1) theNum, ROUND(IFNULL(SUM(oi.goods_price),0)/100) theAmount
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
2024-09-03 08:50:49 +08:00
left join system_dict_data sdd on sdd.value = ii.customer_source and sdd.dict_type = concat('customer_source-',#{partnerId})
2024-08-28 20:54:03 +08:00
WHERE oi.partner_id =#{partnerId}
and ii.create_time BETWEEN #{startTime} and #{endTime}
GROUP BY sdd.remark
having count(1)>0
order by theNum desc
</select>
2024-10-22 18:11:12 +08:00
<select id= "newStaticsTable3" resultType= "java.util.Map" >
SELECT
ii.customer_source customerSource,IFNULL(sdd.remark,'未知类别') remark,count(1) theNum, ROUND(IFNULL(SUM(oi.goods_price),0)/100) theAmount
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
2024-10-23 14:27:58 +08:00
left join system_dict_data sdd on sdd.value = ii.customer_source
2024-10-22 18:11:12 +08:00
WHERE ii.create_time BETWEEN #{startTime} and #{endTime}
GROUP BY sdd.remark
having count(1)>0
order by theNum desc
</select>
2024-08-28 20:54:03 +08:00
<select id= "staticsTable3Detail" resultType= "java.util.Map" >
SELECT
ii.customer_source customerSource,oi.goods_title as goodsTitle,IFNULL(sdd.remark,'未知类别') remark,count(1) theNum, ROUND(IFNULL(SUM(oi.goods_price),0)/100) theAmount
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
2024-09-03 08:50:49 +08:00
left join system_dict_data sdd on sdd.value = ii.customer_source and sdd.dict_type = concat('customer_source-',#{partnerId})
2024-08-28 20:54:03 +08:00
WHERE oi.partner_id =#{partnerId}
<if test= "remark !=null and remark !=''" >
<choose >
<when test= "remark == '未知类别'.toString()" >
and sdd.remark is null
</when>
<otherwise >
and sdd.remark = #{remark}
</otherwise>
</choose>
</if>
and ii.create_time BETWEEN #{startTime} and #{endTime}
GROUP BY ii.customer_source,oi.goods_title
having count(1)>0
order by theNum desc
</select>
<select id= "staticsTable4" resultType= "java.util.Map" >
SELECT
count(1) theNum,oi.goods_title goodsTitle
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
WHERE oi.partner_id =#{partnerId}
and ii.create_time BETWEEN #{startTime} and #{endTime}
GROUP BY oi.goods_title
</select>
<select id= "staticsTable5" resultType= "java.util.Map" >
SELECT
2024-09-01 21:13:39 +08:00
ROUND(IFNULL(SUM(oi.goods_price),0)/100) theAmount,su.nickname theName
2024-08-28 20:54:03 +08:00
FROM
order_info oi
INNER JOIN inspection_info ii on oi.id = ii.inspection_order_id
2024-09-03 08:50:49 +08:00
inner join system_users su on su.id = oi.user_id
2024-08-28 20:54:03 +08:00
WHERE oi.partner_id ='19'
and ii.create_time BETWEEN #{startTime} and #{endTime}
and oi.validation_time is null and ii.`status`='1' and ii.is_pass = '1'
2024-09-01 21:13:39 +08:00
GROUP BY su.id
2024-08-28 20:54:03 +08:00
order by theAmount desc
</select>
<select id= "dhjNum" resultType= "java.lang.Long" >
SELECT
IFNULL(SUM(case when oi.sku_name like CONCAT('%','环检','%') then 1 else 0 end ),0) + IFNULL(SUM(case when oi.goods_title like CONCAT('%','双燃料','%') and oi.sku_name like CONCAT('%','环检','%') then 1 else 0 end ),0)
FROM
`inspection_info` ini
INNER JOIN order_info oi on oi.id = ini.inspection_order_id
where ini.is_pass = '1' and ini.partner_id = #{partnerId} and ini.create_time like CONCAT(#{dateStr},'%')
</select>
<select id= "getAppointNum" resultType= "java.lang.Long" >
SELECT
COUNT(1)
FROM
inspection_appointment ia
2024-09-04 22:34:29 +08:00
where ia.deleted = 0 and ia.partner_id = #{partnerId} and appointment_day = #{formDate}
2024-08-28 20:54:03 +08:00
order by create_time desc
</select>
<select id= "getPickNum" resultType= "java.lang.Long" >
SELECT
COUNT(1)
FROM
inspection_pick_car ipc
inner join inspection_appointment ia on ia.pick_car_id = ipc.id
2024-09-04 22:34:29 +08:00
where ipc.deleted = 0 and ia.deleted= 0 and ipc.partner_id = #{partnerId} and ia.appointment_day = #{formDate}
2024-08-28 20:54:03 +08:00
order by ipc.create_time desc
</select>
2024-09-20 01:20:53 +08:00
<select id= "pageWorkList" resultType= "cn.iocoder.yudao.module.partner.entity.PartnerWorker" >
SELECT
pw.id,pw.user_id,su.nickname as workName,su.mobile as workPhone, su.avatar
FROM
partner_worker pw
INNER JOIN system_users su ON pw.user_id = su.id
left JOIN system_user_post sup on sup.user_id = su.id
2024-10-11 00:13:16 +08:00
where pw.deleted = 0
2024-09-20 01:20:53 +08:00
<if test= "workName!=null and workName!=''" >
and su.nickname like concat('%',#{workName},'%')
</if>
<if test= "phoneNum!=null and phoneNum!=''" >
and su.mobile like concat('%',#{phoneNum},'%')
</if>
<if test= "postId!=null and postId!=''" >
and sup.post_id = #{postId}
</if>
order by pw.create_time desc
</select>
2024-12-12 18:49:46 +08:00
<select id= "getOrderByDate" resultType= "cn.iocoder.yudao.module.inspection.vo.OrderTable" >
SELECT t.id,
2025-02-26 18:06:45 +08:00
t.carNum,
t.type,
t.pay,
t.payType,
t.payTime, -- 新增字段
t.createTime,
t.customerSource,
t.carModel,
CASE
WHEN t.status = '已完成' AND t.is_pass = 0 THEN '不合格'
WHEN t.status = '已完成' AND t.is_pass = 1 THEN '合格'
WHEN t.status = '已完成' THEN '未知'
ELSE ''
END AS result,
t.status
FROM (
SELECT ii.id,
ii.car_num AS carNum,
oi.sku_name AS type,
oi.pay_type AS payType,
oi.pay_time AS payTime, -- 新增字段
oi.create_time AS createTime,
ii.customer_source AS customerSource,
ii.car_model AS carModel,
CASE
WHEN oi.pay_type IS NULL THEN '未支付'
ELSE '已支付'
END AS pay,
CASE
WHEN oi.pay_type IS NOT NULL THEN '已完成'
WHEN has_status_0_or_null THEN '检测中'
WHEN (ii.status = 0 OR ii.status = 2) AND has_status_1 THEN '检测中'
WHEN (COALESCE(max_iwn_status, 0) = 2 OR ii.status = 1) THEN '已完成'
WHEN (ii.status = 0 OR ii.status = 2) AND COALESCE(max_iwn_status, 0) = 0 THEN '待检测'
ELSE '未知状态'
END AS status,
ii.is_pass,
COALESCE(max_iwn_status, 0) AS max_iwn_status,
oi.create_time
FROM order_info oi
INNER JOIN inspection_info ii
ON oi.id = ii.inspection_order_id
LEFT JOIN (
SELECT inspection_info_id,
MAX(COALESCE(status, 0)) AS max_iwn_status,
MAX(CASE WHEN COALESCE(status, 0) = 1 THEN 1 ELSE 0 END) AS has_status_1,
MAX(CASE WHEN COALESCE(status, 0) = 0 THEN 1 ELSE 0 END) AS has_status_0_or_null
FROM inspection_work_node
GROUP BY inspection_info_id
) iwn_agg
ON ii.id = iwn_agg.inspection_info_id
<where >
<if test= "query.payType!=null and query.payType!=''" >
AND oi.pay_type = #{query.payType}
</if>
<if test= "query.customerSource!=null and query.customerSource!=''" >
AND ii.customer_source = #{query.customerSource}
</if>
<if test= "query.carModelOrCarYear!=null and query.carModelOrCarYear!=''" >
AND ( ii.car_model LIKE concat('%',#{query.carModelOrCarYear},'%')
OR ii.car_num LIKE concat('%',#{query.carModelOrCarYear},'%') )
</if>
<if test= "query.startTime!=null and query.startTime!=''" >
AND oi.create_time BETWEEN #{query.startTime} AND #{query.endTime}
</if>
<if test= "query.goods!=null and query.goods!=''" >
AND oi.goods_id = #{query.goods}
</if>
<if test= "query.carYear!=null and query.carYear!=''" >
AND (TIMESTAMPDIFF(YEAR, ii.car_register_date, CURDATE()) >= #{query.carYear}
AND TIMESTAMPDIFF(YEAR, ii.car_register_date, CURDATE()) < #{query.carYear} + 1)
</if>
</where>
AND oi.deleted = '0'
) t
2024-12-16 18:04:45 +08:00
<where >
<choose >
2025-02-26 18:06:45 +08:00
<when test= "query.chooseStatus == '2'.toString()" >
2024-12-16 18:04:45 +08:00
t.status = '检测中'
</when>
2025-02-26 18:06:45 +08:00
<when test= "query.chooseStatus == '3'.toString()" >
2024-12-16 18:04:45 +08:00
t.status = '已完成'
</when>
</choose>
</where>
2025-02-26 18:06:45 +08:00
ORDER BY t.create_time DESC;
2024-12-12 18:49:46 +08:00
</select>
2024-12-16 18:04:45 +08:00
<select id= "getTypeCount" resultType= "java.util.Map" >
SELECT t2.type as type, COUNT(*) as count FROM (
SELECT t.id,
t.carNum,
t.type,
t.pay,
t.payType,
CASE
WHEN t.status = '已完成' AND t.is_pass = 0 THEN '不合格'
WHEN t.status = '已完成' AND t.is_pass = 1 THEN '合格'
WHEN t.status = '已完成' THEN '未知'
ELSE ''
END AS result,
t.status
FROM (SELECT ii.id,
ii.car_num AS carNum,
oi.sku_name AS type,
oi.pay_type as payType,
CASE
WHEN oi.pay_type IS NULL THEN '未支付'
ELSE '已支付'
END AS pay,
CASE
WHEN oi.pay_type IS NOT NULL THEN '已完成'
WHEN has_status_0_or_null THEN '检测中'
WHEN (ii.status = 0 OR ii.status = 2) AND has_status_1 THEN '检测中'
WHEN (COALESCE(max_iwn_status, 0) = 2 OR ii.status = 1) THEN '已完成'
WHEN (ii.status = 0 OR ii.status = 2) AND COALESCE(max_iwn_status, 0) = 0 THEN '待检测'
ELSE '未知状态' -- 这是为了处理任何未预期的情况
END AS status,
ii.is_pass,
COALESCE(max_iwn_status, 0) AS max_iwn_status,
oi.create_time
FROM order_info oi
INNER JOIN
inspection_info ii
ON
oi.id = ii.inspection_order_id
LEFT JOIN (SELECT inspection_info_id,
MAX(COALESCE(status, 0)) AS max_iwn_status,
MAX(CASE WHEN COALESCE(status, 0) = 1 THEN 1 ELSE 0 END) AS has_status_1,
MAX(CASE WHEN COALESCE(status, 0) = 0 THEN 1 ELSE 0 END) AS has_status_0_or_null
FROM inspection_work_node
GROUP BY inspection_info_id) iwn_agg
ON
ii.id = iwn_agg.inspection_info_id
WHERE oi.create_time BETWEEN #{startTime} AND #{endTime}
AND oi.deleted = '0') t
<where >
<choose >
<when test= "chooseStatus == '2'.toString()" >
t.status = '检测中'
</when>
<when test= "chooseStatus == '3'.toString()" >
t.status = '已完成'
</when>
</choose>
</where>
) t2
GROUP BY t2.type
</select>
2025-02-15 18:01:18 +08:00
<select id= "queryInspectionSkuList" resultType= "java.util.Map" >
SELECT
sku_name AS skuName,
COUNT(*) AS orderCount
FROM
order_info
<where >
sku_name IN ('年审', '上户', '双燃料', '非定检', '其他检测')
<if test= "startTime != null" >
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
</where>
GROUP BY
sku_name;
</select>
2024-08-28 20:54:03 +08:00
</mapper>