增加用户和门店查询订单接口
This commit is contained in:
40
src/main/resources/doc/dbInit.sql
Normal file
40
src/main/resources/doc/dbInit.sql
Normal file
@ -0,0 +1,40 @@
|
||||
CREATE TABLE `zc_order_main` (
|
||||
`order_id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单ID(主键)',
|
||||
`order_no` varchar(50) NOT NULL COMMENT '订单编号',
|
||||
`order_status` varchar(20) NOT NULL COMMENT '订单状态:下单未提车、租赁中、已结束-自动、已结束-手动',
|
||||
`operator_id` bigint NOT NULL COMMENT '所属运营商ID',
|
||||
`store_id` bigint NOT NULL COMMENT '所属门店ID',
|
||||
`vehicle_id` bigint DEFAULT NULL COMMENT '车辆ID',
|
||||
`car_model_id` bigint NOT NULL COMMENT '车型ID',
|
||||
`customer_id` bigint NOT NULL COMMENT '客户id',
|
||||
`customer_name` varchar(50) NOT NULL COMMENT '客户姓名',
|
||||
`customer_phone` varchar(20) NOT NULL COMMENT '客户联系电话',
|
||||
`battery_type` varchar(50) DEFAULT '' COMMENT '选择的电池类型(48V标准版/100km,48V超长版/200km等)',
|
||||
`rental_type` varchar(20) NOT NULL COMMENT '租赁类型(时租/日租/按天数/以租代售)',
|
||||
`rental_days` int DEFAULT NULL COMMENT '租赁天数(当类型为"按天数"时使用)',
|
||||
`rental_price` decimal(10,2) NOT NULL COMMENT '租车价格(元)',
|
||||
`deposit_price` decimal(10,2) NOT NULL COMMENT '押金价格(元)',
|
||||
`overdue_fee` decimal(10,2) NOT NULL COMMENT '逾期金额(元)',
|
||||
`overdue_type` varchar(10) DEFAULT '按日计费' COMMENT '逾期计费类型(按日计费/按月计费)',
|
||||
`is_deposit_free` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否开通免押',
|
||||
`is_auto_deduct` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否开通代扣',
|
||||
`first_order_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '首次下单时间',
|
||||
`start_rent_time` datetime DEFAULT NULL COMMENT '开始计费时间',
|
||||
`end_rent_time` datetime DEFAULT NULL COMMENT '预计还车时间',
|
||||
`req_end_rent_time` datetime DEFAULT NULL COMMENT '申请还车时间',
|
||||
`act_end_rent_time` datetime DEFAULT NULL COMMENT '实际还车时间',
|
||||
`overdue_days` int NOT NULL DEFAULT '0' COMMENT '逾期天数',
|
||||
`renewal_times` int NOT NULL DEFAULT '0' COMMENT '续租次数',
|
||||
`charge_times` int NOT NULL DEFAULT '0' COMMENT '充电次数',
|
||||
`rent_car_rule_id` bigint DEFAULT NULL COMMENT '租车套餐id',
|
||||
`rent_battey_rule_id` bigint DEFAULT NULL COMMENT '租电套餐id',
|
||||
`end_order_time` datetime DEFAULT NULL COMMENT '订单结束时间',
|
||||
`del_flag` char(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`order_id`),
|
||||
KEY `idx_order_no` (`order_no`),
|
||||
KEY `idx_customer_id` (`customer_id`),
|
||||
KEY `idx_operator_id` (`operator_id`),
|
||||
KEY `idx_store_id` (`store_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='租车订单信息';
|
||||
@ -2,4 +2,46 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sczx.order.mapper.OrderMainMapper">
|
||||
|
||||
<select id="storeOrderStatistics" resultType="com.sczx.order.dto.StoreOrderStatisticsDTO">
|
||||
SELECT
|
||||
store_id,
|
||||
COUNT(*) as total_orders,
|
||||
SUM(CASE WHEN (status = 'AUTO_END' OR status = 'MANUAL_END') AND DATE_FORMAT(end_order_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m') THEN 1 ELSE 0 END) as monthly_completed_orders,
|
||||
SUM(CASE WHEN (status = 'AUTO_END' OR status = 'MANUAL_END') AND DATE_FORMAT(end_order_time, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m') THEN order_amount ELSE 0 END) as monthly_order_amount,
|
||||
COUNT(CASE WHEN status = 'WAIT_RETURN' THEN 1 END) as pending_pickup_count,
|
||||
COUNT(CASE WHEN status = 'WAIT_RETURN' THEN 1 END) as pending_return_count,
|
||||
COUNT(CASE WHEN status = 'RENT_OVERDUE' THEN 1 END) as overdue_count
|
||||
FROM zc_order_main
|
||||
WHERE store_id = #{storeId}
|
||||
GROUP BY store_id
|
||||
</select>
|
||||
|
||||
<select id="pageQueryOrder" resultType="com.sczx.order.dto.OrderSimpleDTO">
|
||||
|
||||
SELECT
|
||||
o.order_id,
|
||||
o.order_no,
|
||||
o.status,
|
||||
o.first_order_time,
|
||||
o.end_rent_time,
|
||||
o.car_model_id,
|
||||
m.model_name,
|
||||
m.brand_name,
|
||||
m.image
|
||||
from zc_order_main o join zc_car_model m on o.car_model_id = m.id
|
||||
<where>
|
||||
<if test="customerId != null">
|
||||
and o.customer_id = #{customerId}
|
||||
</if>
|
||||
<if test="storeId != null">
|
||||
and o.store_id = #{storeId}
|
||||
</if>
|
||||
<if test="orderStatus != null and orderStatus!= ''">
|
||||
and o.status = #{orderStatus}
|
||||
</if>
|
||||
</where>
|
||||
order by o.update_time desc
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user