预约单统计功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.vo.BookingOrderStatisticsVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.BkOrder;
|
||||
|
||||
@@ -14,6 +15,11 @@ import java.util.List;
|
||||
*/
|
||||
public interface BkOrderMapper extends BaseMapper<BkOrder> {
|
||||
|
||||
/**
|
||||
* 查询预约单统计信息
|
||||
*/
|
||||
BookingOrderStatisticsVO bookingOrderStatistics(Long shopId, String search, LocalDate start, LocalDate end, String status);
|
||||
|
||||
/**
|
||||
* 查询预约单列表
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.czg.account.entity.BkOrder;
|
||||
import com.czg.account.entity.BkOrderTable;
|
||||
import com.czg.account.service.BkOrderService;
|
||||
import com.czg.account.vo.BkTableVO;
|
||||
import com.czg.account.vo.BookingOrderStatisticsVO;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.service.account.mapper.BkOrderMapper;
|
||||
import com.czg.service.account.mapper.BkOrderTableMapper;
|
||||
@@ -34,6 +35,11 @@ public class BkOrderServiceImpl extends ServiceImpl<BkOrderMapper, BkOrder> impl
|
||||
@Resource
|
||||
private BkOrderTableMapper tableMapper;
|
||||
|
||||
@Override
|
||||
public BookingOrderStatisticsVO bookingOrderStatistics(Long shopId, String search, LocalDate start, LocalDate end, String status) {
|
||||
return mapper.bookingOrderStatistics(shopId, search, start, end, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预约端-预约单:列表
|
||||
*/
|
||||
|
||||
@@ -32,4 +32,39 @@
|
||||
group by o.id
|
||||
order by o.booking_time desc
|
||||
</select>
|
||||
|
||||
<select id="bookingOrderStatistics" resultType="com.czg.account.vo.BookingOrderStatisticsVO">
|
||||
SELECT
|
||||
COUNT(CASE WHEN DATE(create_time) = CURDATE() THEN 1 END) as todayBookingCount,
|
||||
COUNT(CASE WHEN YEAR(create_time) = YEAR(CURDATE()) AND MONTH(create_time) = MONTH(CURDATE()) THEN 1 END) as thisMonthBookingCount,
|
||||
COUNT(CASE WHEN status = '待到店' THEN 1 END) as arrivedCount,
|
||||
COALESCE(
|
||||
ROUND(
|
||||
COUNT(CASE WHEN status = '已到店' THEN 1 END) * 100.0 /
|
||||
NULLIF(COUNT(CASE WHEN status != '已取消' THEN 1 END), 0),
|
||||
2
|
||||
), 0
|
||||
) as arrivalRate
|
||||
FROM bk_order
|
||||
WHERE shop_id = #{shopId}
|
||||
<if test="search != null and search != ''">
|
||||
AND (o.call_username LIKE CONCAT('%', #{search}, '%')
|
||||
OR o.call_phone LIKE CONCAT('%', #{search}, '%')
|
||||
OR o.booking_username LIKE CONCAT('%', #{search}, '%')
|
||||
OR o.booking_phone LIKE CONCAT('%', #{search}, '%'))
|
||||
</if>
|
||||
<if test="start != null and end != null">
|
||||
AND o.booking_time >= CONCAT(#{start}, ' 00:00:00')
|
||||
AND o.booking_time <= CONCAT(#{end}, ' 23:59:59')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
<if test="status == '已超时'">
|
||||
AND o.status = '待到店'
|
||||
AND o.booking_time < DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="status != '已超时'">
|
||||
AND o.status = #{status}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user