2022-04-25 17:06:55 +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= "com.ghy.order.mapper.OrderMasterMapper" >
<resultMap id= "OrderMasterResult" type= "com.ghy.order.domain.OrderMaster" >
<id property= "id" column= "id" />
2022-05-24 22:26:26 +08:00
<result property= "deptId" column= "dept_id" />
2022-04-25 17:06:55 +08:00
<result property= "code" column= "code" />
<result property= "customerId" column= "customer_id" />
2023-05-10 20:14:07 +08:00
<result property= "addressId" column= "address_id" />
2022-04-25 17:06:55 +08:00
<result property= "orderType" column= "order_type" />
2023-06-01 21:41:59 +08:00
<result property= "orderMode" column= "order_mode" />
2023-10-05 01:24:05 +08:00
<result property= "payMode" column= "pay_mode" />
2024-03-02 20:47:11 +08:00
<result property= "consultMode" column= "consult_mode" />
2024-10-21 14:03:49 +08:00
<result property= "insuranceId" column= "insurance_id" />
2023-10-18 23:23:53 +08:00
<result property= "isCharge" column= "is_charge" />
<result property= "isContact" column= "is_contact" />
2022-04-25 17:06:55 +08:00
<result property= "orderStatus" column= "order_status" />
<result property= "payType" column= "pay_type" />
<result property= "payStatus" column= "pay_status" />
<result property= "workerId" column= "worker_id" />
<result property= "payTime" column= "pay_time" />
<result property= "revTime" column= "rev_time" />
2022-06-20 18:09:34 +08:00
<result property= "expectTimeStart" column= "expect_time_start" />
<result property= "expectTimeEnd" column= "expect_time_end" />
2022-04-25 17:06:55 +08:00
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
2025-09-04 15:27:43 +08:00
<result property= "afterServiceStatus" column= "after_service_status" />
2022-07-04 22:35:02 +08:00
<result property= "goodsId" column= "goods_id" />
2023-11-09 09:59:34 +08:00
<result property= "goodsBrand" column= "goods_brand" />
<result property= "goodsSpecification" column= "goods_specification" />
2023-05-10 20:14:07 +08:00
<result property= "allSelfAssigned" column= "all_self_assigned" />
<result property= "hasDispatchedAll" column= "has_dispatched_all" />
2023-05-09 19:53:44 +08:00
<result property= "timeout" column= "timeout_" />
2023-05-10 20:14:07 +08:00
<result property= "timeoutFineTimes" column= "timeout_fine_times" />
2023-06-04 01:40:36 +08:00
<result property= "isCall" column= "is_call" />
2023-06-05 00:56:03 +08:00
<result property= "serverMoney" column= "server_money" />
2025-06-20 10:09:03 +08:00
<result property= "serverGoodsMoney" column= "server_goods_money" />
2025-04-22 17:58:54 +08:00
<result property= "provinceId" column= "province_id" />
<result property= "cityId" column= "city_id" />
<result property= "countryId" column= "country_id" />
<result property= "streetId" column= "street_id" />
<result property= "address" column= "address" />
<result property= "name" column= "name" />
<result property= "phone" column= "phone" />
2025-04-22 19:51:37 +08:00
<result property= "provinceName" column= "province_name" />
<result property= "cityName" column= "city_name" />
<result property= "countryName" column= "country_name" />
<result property= "streetName" column= "street_name" />
2025-06-14 21:37:33 +08:00
<result property= "withdrawn" column= "withdrawn" />
2025-06-19 18:10:43 +08:00
<result property= "serverGoodsId" column= "server_goods_id" />
2025-08-22 11:35:33 +08:00
<result property= "serviceShopId" column= "service_shop_id" />
2025-06-19 18:10:43 +08:00
<result property= "goodsOrderMasterId" column= "goods_order_master_id" />
<result property= "trackingNumber" column= "tracking_number" />
2025-06-20 11:33:53 +08:00
<result property= "hasServiceOrder" column= "has_service_order" />
2025-07-03 14:55:42 +08:00
<result property= "orderImages" column= "order_images" />
<result property= "isDeliveryToStore" column= "is_delivery_to_store" />
2025-07-09 17:41:24 +08:00
<result property= "deliveryType" column= "delivery_type" />
<result property= "deliveryRemark" column= "delivery_remark" />
<result property= "deliveryImages" column= "delivery_images" />
2025-07-08 09:47:25 +08:00
<result property= "isInvoiced" column= "is_invoiced" />
<result property= "isNeedBill" column= "is_need_bill" />
2025-07-08 10:36:12 +08:00
<result property= "originalWorkerId" column= "original_worker_id" />
2025-08-28 11:33:01 +08:00
<result property= "returnReason" column= "return_reason" />
<result property= "returnReasonDetail" column= "return_reason_detail" />
<result property= "returnImages" column= "return_images" />
2025-08-30 08:54:52 +08:00
<result property= "workerRemark" column= "worker_remark" />
2025-09-11 11:01:42 +08:00
<result property= "shareAccountCountdownEndTime" column= "share_account_countdown_end_time" />
<result property= "shareAccountCountdownDuration" column= "share_account_countdown_duration" />
2025-04-22 19:51:37 +08:00
2022-04-25 17:06:55 +08:00
</resultMap>
<sql id= "selectOrderMaster" >
SELECT id,
2022-05-24 22:26:26 +08:00
dept_id,
2022-04-25 17:06:55 +08:00
code,
customer_id,
2022-06-09 14:35:13 +08:00
address_id,
2022-04-25 17:06:55 +08:00
order_type,
2023-06-01 21:41:59 +08:00
order_mode,
2023-10-05 01:24:05 +08:00
pay_mode,
2024-03-02 20:47:11 +08:00
consult_mode,
2024-10-21 14:03:49 +08:00
insurance_id,
2023-10-18 23:23:53 +08:00
is_charge,
is_contact,
2022-04-25 17:06:55 +08:00
order_status,
pay_type,
pay_status,
worker_id,
pay_time,
rev_time,
2022-06-20 18:09:34 +08:00
expect_time_start,
expect_time_end,
2022-04-25 17:06:55 +08:00
create_by,
create_time,
2023-05-10 20:14:07 +08:00
update_time,
2022-11-04 00:30:37 +08:00
remark,
2023-02-17 21:11:23 +08:00
all_self_assigned,
2023-05-09 19:53:44 +08:00
goods_id,
2023-05-10 20:14:07 +08:00
timeout_,
2023-06-04 01:40:36 +08:00
timeout_fine_times,
2023-06-05 00:56:03 +08:00
is_call,
2023-11-09 09:59:34 +08:00
order_mode,
goods_brand,
2025-04-24 16:08:19 +08:00
goods_specification,
province_id,
city_id ,
country_id,
street_id,
address ,
name ,
province_name,
city_name ,
country_name ,
street_name ,
2025-05-06 15:06:10 +08:00
phone,
2025-06-14 21:37:33 +08:00
has_dispatched_all,
2025-06-19 18:10:43 +08:00
withdrawn,
server_goods_id,
2025-08-22 11:35:33 +08:00
service_shop_id,
2025-06-19 18:10:43 +08:00
goods_order_master_id,
2025-06-20 10:09:03 +08:00
tracking_number,
2025-06-20 11:33:53 +08:00
server_goods_money,
2025-07-03 14:55:42 +08:00
has_service_order,
order_images,
2025-07-08 09:47:25 +08:00
is_delivery_to_store,
2025-07-09 17:41:24 +08:00
delivery_type,
delivery_remark,
delivery_images,
2025-07-08 09:47:25 +08:00
is_invoiced,
2025-07-08 10:36:12 +08:00
is_need_bill,
2025-08-28 11:33:01 +08:00
original_worker_id,
return_reason,
return_reason_detail,
2025-08-30 08:54:52 +08:00
return_images,
2025-09-05 14:45:02 +08:00
worker_remark,
2025-09-11 11:01:42 +08:00
after_service_status,
share_account_countdown_end_time,
share_account_countdown_duration
2022-04-25 17:06:55 +08:00
FROM order_master
</sql>
2022-07-04 22:35:02 +08:00
<sql id= "selectOrderMasterMoreInfo" >
SELECT om.id,
om.dept_id,
om.code,
om.customer_id,
om.address_id,
om.order_type,
2023-06-01 21:41:59 +08:00
om.order_mode,
2023-10-05 01:24:05 +08:00
om.pay_mode,
2023-10-18 23:23:53 +08:00
om.is_charge,
om.is_contact,
2022-07-04 22:35:02 +08:00
om.order_status,
om.pay_type,
om.pay_status,
om.worker_id,
om.pay_time,
om.rev_time,
om.expect_time_start,
om.expect_time_end,
om.create_by,
om.create_time,
2023-05-10 20:14:07 +08:00
om.update_time,
2022-07-04 22:35:02 +08:00
om.remark,
2022-11-04 00:30:37 +08:00
om.all_self_assigned,
2023-05-09 19:53:44 +08:00
om.goods_id,
2023-05-10 20:14:07 +08:00
om.timeout_,
2023-06-04 01:40:36 +08:00
om.timeout_fine_times,
2023-06-05 00:56:03 +08:00
om.is_call,
2023-11-09 09:59:34 +08:00
fm.server_money,
om.goods_brand,
2024-06-05 23:26:10 +08:00
om.goods_specification,
2024-10-21 14:03:49 +08:00
om.consult_mode,
2025-04-30 21:57:34 +08:00
om.insurance_id,
2025-04-30 18:11:14 +08:00
om.province_id,
om.city_id ,
om.country_id,
om.street_id,
om.address ,
om.name ,
om.province_name,
om.city_name ,
om.country_name ,
om.street_name ,
2025-05-06 15:06:10 +08:00
om.phone,
2025-06-14 21:37:33 +08:00
om.has_dispatched_all,
2025-06-19 18:10:43 +08:00
om.withdrawn,
om.server_goods_id,
2025-08-22 11:35:33 +08:00
om.service_shop_id,
2025-06-19 18:10:43 +08:00
om.goods_order_master_id,
2025-06-20 10:09:03 +08:00
om.tracking_number,
2025-06-20 11:33:53 +08:00
om.server_goods_money,
2025-07-03 14:55:42 +08:00
om.has_service_order,
om.order_images,
2025-07-08 09:47:25 +08:00
om.is_delivery_to_store,
2025-07-09 17:41:24 +08:00
om.delivery_type,
om.delivery_remark,
om.delivery_images,
2025-07-08 09:47:25 +08:00
om.is_invoiced,
2025-07-08 10:36:12 +08:00
om.is_need_bill,
2025-08-28 11:33:01 +08:00
om.original_worker_id,
om.return_reason,
om.return_reason_detail,
2025-08-30 08:54:52 +08:00
om.return_images,
2025-09-05 14:45:02 +08:00
om.worker_remark,
2025-09-11 11:01:42 +08:00
om.after_service_status,
om.share_account_countdown_end_time,
om.share_account_countdown_duration
2022-07-04 22:35:02 +08:00
FROM order_master om
LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id
LEFT JOIN goods g ON g.goods_id = om.goods_id
2023-06-01 21:41:59 +08:00
LEFT JOIN financial_master fm ON om.id = fm.order_master_id
2024-02-17 13:50:22 +08:00
left join worker w on om.worker_id = w.worker_id
2022-07-04 22:35:02 +08:00
</sql>
2022-04-25 17:06:55 +08:00
<select id= "selectOrderMasterList" parameterType= "com.ghy.order.domain.OrderMaster" resultMap= "OrderMasterResult" >
2022-11-04 00:30:37 +08:00
<include refid= "selectOrderMasterMoreInfo" > </include>
2022-04-25 17:06:55 +08:00
<where >
2024-02-17 13:50:22 +08:00
<if test= "keywords != null and keywords != ''" >
AND
(
om.code LIKE concat('%', #{keywords}, '%')
or ca.name LIKE concat('%', #{keywords}, '%')
or ca.phone LIKE concat('%', #{keywords}, '%')
2024-06-05 23:26:10 +08:00
or ca.address like concat('%', #{keywords}, '%')
or g.goods_name like concat('%', #{keywords}, '%')
2024-02-17 13:50:22 +08:00
)
</if>
<if test= "workerName != null and workerName != ''" >
AND w.name LIKE concat('%', #{workerName}, '%')
</if>
<if test= "workerPhone != null and workerPhone != ''" >
AND w.phone LIKE concat('%', #{workerPhone}, '%')
</if>
<if test= "province != null and province != ''" >
AND ca.province_id = #{province}
</if>
<if test= "city != null and city != ''" >
AND ca.city_id = #{city}
</if>
<if test= "district != null and district != ''" >
AND ca.country_id = #{district}
</if>
2022-11-04 00:30:37 +08:00
<if test= "isMonitoredOrder" >
2025-09-25 11:38:11 +08:00
AND (om.has_dispatched_all = 0 OR (om.has_dispatched_all = 1 AND om.all_self_assigned = 0)) AND om.order_status in (0,1,2,3,4) and om.worker_id is not null
2022-11-01 23:57:21 +08:00
</if>
2022-11-21 00:57:57 +08:00
<if test= "allSelfAssigned != null" >
AND all_self_assigned = #{allSelfAssigned}
</if>
2022-05-24 22:26:26 +08:00
<if test= "deptId != null and deptId != 0" >
2022-07-04 22:35:02 +08:00
AND om.dept_id = #{deptId}
2022-05-24 22:26:26 +08:00
</if>
2022-04-25 17:06:55 +08:00
<if test= "code != null and code != ''" >
2022-07-04 22:35:02 +08:00
AND om.code LIKE concat('%', #{code}, '%')
2022-04-25 17:06:55 +08:00
</if>
<if test= "customerId != null and customerId != 0" >
2022-07-04 22:35:02 +08:00
AND om.customer_id = #{customerId}
2022-04-25 17:06:55 +08:00
</if>
2022-11-16 01:58:58 +08:00
<if test= "customerIds != null and customerIds.size > 0" >
AND om.customer_id in
<foreach item= "customerId" collection= "customerIds" open= "(" separator= "," close= ")" >
#{customerId}
</foreach>
</if>
2022-05-24 22:26:26 +08:00
<if test= "orderType != null" >
2022-07-04 22:35:02 +08:00
AND om.order_type = #{orderType}
2022-04-25 17:06:55 +08:00
</if>
2022-05-24 22:26:26 +08:00
<if test= "orderStatus != null" >
2022-07-04 22:35:02 +08:00
AND om.order_status = #{orderStatus}
2022-04-25 17:06:55 +08:00
</if>
2022-05-24 22:26:26 +08:00
<if test= "payType != null" >
2022-07-04 22:35:02 +08:00
AND om.pay_type = #{payType}
2022-04-25 17:06:55 +08:00
</if>
2022-05-24 22:26:26 +08:00
<if test= "payStatus != null" >
2022-07-04 22:35:02 +08:00
AND om.pay_status = #{payStatus}
2022-04-25 17:06:55 +08:00
</if>
2022-10-17 00:07:02 +08:00
<if test= "payStatusList != null" >
AND om.pay_status in ( #{payStatusList} )
</if>
2022-06-28 18:05:41 +08:00
<if test= "workerId != null and workerId > 0" >
2022-07-04 22:35:02 +08:00
AND om.worker_id = #{workerId}
2022-04-25 17:06:55 +08:00
</if>
2022-06-28 18:05:41 +08:00
<if test= "workerId == -1" >
2022-07-04 22:35:02 +08:00
AND om.worker_id IS NULL
2023-10-08 22:23:21 +08:00
AND (om.pay_mode = '01' OR (om.pay_mode = '02' and om.pay_status = '1'))
</if>
2024-01-29 17:26:04 +08:00
<if test= "workerId == -2" >
and om.worker_id IS not NULL
</if>
2025-09-29 15:35:25 +08:00
<if test= "originalWorkerId != null and originalWorkerId > 0" >
AND om.original_worker_id = #{originalWorkerId}
</if>
2023-10-08 22:23:21 +08:00
<if test= "payMode != null" >
AND om.pay_mode = #{payMode}
2022-07-04 22:35:02 +08:00
</if>
2023-06-01 23:18:06 +08:00
<if test= "sysPayStatus != null" >
AND fm.pay_status = #{sysPayStatus}
</if>
2022-07-04 22:35:02 +08:00
<if test= "goodsCategoryId != null" >
AND g.dept_goods_category_id = #{goodsCategoryId}
</if>
<if test= "goodsName != null and goodsName != ''" >
AND g.goods_name like concat('%', #{goodsName}, '%')
</if>
<if test= "countryId != null" >
AND ca.country_id = #{countryId}
2022-06-28 18:05:41 +08:00
</if>
2022-07-07 15:32:11 +08:00
<if test= "exceptOrderStatus != null" >
AND om.order_status != #{exceptOrderStatus}
</if>
2022-08-16 23:00:46 +08:00
<if test= "createTimeStart != null" >
AND om.create_time > = #{createTimeStart}
</if>
<if test= "createTimeEnd != null" >
2023-06-26 00:02:43 +08:00
AND om.create_time < = #{createTimeEnd}
2022-08-16 23:00:46 +08:00
</if>
2023-12-26 10:14:37 +08:00
<if test= "updateTimeStart != null" >
AND om.update_time > = #{updateTimeStart}
</if>
<if test= "updateTimeEnd != null" >
AND om.update_time < = #{updateTimeEnd}
</if>
2025-09-04 15:27:43 +08:00
<if test= "afterServiceStatus != null" >
AND om.after_service_status = #{afterServiceStatus}
</if>
2022-10-06 18:29:47 +08:00
<if test= "orderMasterIds != null and orderMasterIds != ''" >
2022-10-06 17:00:10 +08:00
AND om.id in (${orderMasterIds})
2022-09-25 22:46:05 +08:00
</if>
2023-10-24 00:39:12 +08:00
<if test= "orderMasterIdList != null and orderMasterIdList.size > 0" >
AND om.id in
<foreach collection= "orderMasterIdList" item= "id" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</if>
2022-10-06 18:29:47 +08:00
<if test= "orderStatuses != null and orderStatuses != ''" >
AND om.order_status in (${orderStatuses})
</if>
2022-11-18 02:37:06 +08:00
<if test= "hasDispatchedAll != null" >
AND om.has_dispatched_all = #{hasDispatchedAll}
</if>
2022-12-11 21:38:01 +08:00
<if test= "exceptOrderMasterIds != null and exceptOrderMasterIds.size > 0" >
AND om.id not in
<foreach collection= "exceptOrderMasterIds" item= "id" open= "(" separator= "," close= ")" >
#{id}
2022-12-05 22:15:27 +08:00
</foreach>
</if>
2023-05-12 22:24:28 +08:00
<if test= "timeout != null" >
AND om.timeout_ = #{timeout}
</if>
2023-06-04 01:40:36 +08:00
<if test= "isCall != null" >
2023-06-04 01:57:21 +08:00
AND om.is_call = #{isCall}
2023-06-04 01:40:36 +08:00
</if>
2023-06-07 23:24:58 +08:00
<if test= "expectTimeStart != null" >
AND om.expect_time_start > = #{expectTimeStart}
</if>
<if test= "expectTimeEnd != null" >
AND om.expect_time_end < = #{expectTimeEnd}
</if>
2023-10-01 01:37:28 +08:00
<if test= "createBy != null and createBy != ''" >
AND om.create_by = #{createBy}
</if>
2023-10-21 03:04:05 +08:00
<if test= "addressIds != null and addressIds.size > 0" >
AND om.address_id IN
<foreach collection= "addressIds" item= "id" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</if>
2025-09-15 16:51:52 +08:00
<if test= "goodsOrderMasterId != null and goodsOrderMasterId > 0" >
AND om.goods_order_master_id = #{goodsOrderMasterId}
</if>
2022-04-25 17:06:55 +08:00
</where>
2022-07-05 14:09:52 +08:00
order by om.create_time
2022-07-04 22:35:02 +08:00
<trim suffixOverrides= "," >
<choose >
<when test= "params.createTimeSort != null and params.createTimeSort != ''" >
${params.createTimeSort}
</when>
<otherwise >
desc
</otherwise>
</choose>
</trim>
2022-04-25 17:06:55 +08:00
</select>
2022-07-13 11:11:04 +08:00
<select id= "countOrderMasterList" parameterType= "com.ghy.order.domain.OrderMaster" resultType= "Long" >
2023-06-07 23:24:58 +08:00
SELECT COUNT(*)
FROM order_master om
LEFT JOIN financial_master fm ON om.id = fm.order_master_id
2022-07-13 11:11:04 +08:00
<where >
2022-11-04 00:30:37 +08:00
<if test= "isMonitoredOrder" >
2025-09-25 11:38:11 +08:00
AND (om.has_dispatched_all = 0 OR (om.has_dispatched_all = 1 AND om.all_self_assigned = 0)) AND om.order_status in (1,2,3,4)
2022-11-01 23:57:21 +08:00
</if>
2023-08-22 23:01:00 +08:00
<if test= "allSelfAssigned != null" >
AND all_self_assigned = #{allSelfAssigned}
</if>
2022-07-13 11:11:04 +08:00
<if test= "deptId != null and deptId != 0" >
AND om.dept_id = #{deptId}
</if>
<if test= "code != null and code != ''" >
AND om.code LIKE concat('%', #{code}, '%')
</if>
<if test= "customerId != null and customerId != 0" >
AND om.customer_id = #{customerId}
</if>
<if test= "orderType != null" >
AND om.order_type = #{orderType}
</if>
<if test= "orderStatus != null" >
AND om.order_status = #{orderStatus}
</if>
2022-10-31 00:07:07 +08:00
<if test= "orderStatuses != null and orderStatuses != ''" >
AND om.order_status in (${orderStatuses})
</if>
2022-07-13 11:11:04 +08:00
<if test= "payType != null" >
AND om.pay_type = #{payType}
</if>
<if test= "payStatus != null" >
AND om.pay_status = #{payStatus}
</if>
2023-01-07 22:59:07 +08:00
<if test= "payStatusList != null" >
AND om.pay_status in ( #{payStatusList} )
</if>
2022-07-13 11:11:04 +08:00
<if test= "workerId != null and workerId > 0" >
AND om.worker_id = #{workerId}
</if>
<if test= "workerId == -1" >
AND om.worker_id IS NULL
2023-10-08 22:23:21 +08:00
AND (om.pay_mode = '01' OR (om.pay_mode = '02' and om.pay_status = '1'))
</if>
2024-01-29 17:26:04 +08:00
<if test= "workerId == -2" >
AND om.worker_id IS not NULL
</if>
2023-10-08 22:23:21 +08:00
<if test= "payMode != null" >
AND om.pay_mode = #{payMode}
2023-06-07 23:24:58 +08:00
</if>
<if test= "sysPayStatus != null" >
AND fm.pay_status = #{sysPayStatus}
</if>
<if test= "orderMode != null and orderMode != ''" >
AND om.order_mode = #{orderMode}
2022-07-13 11:11:04 +08:00
</if>
<if test= "exceptOrderStatus != null" >
AND om.order_status != #{exceptOrderStatus}
</if>
2022-11-18 02:39:37 +08:00
<if test= "hasDispatchedAll != null" >
2022-11-18 02:41:12 +08:00
AND om.has_dispatched_all = #{hasDispatchedAll}
2022-11-18 02:39:37 +08:00
</if>
2023-01-07 22:59:07 +08:00
<if test= "orderMasterIds != null and orderMasterIds != ''" >
AND om.id in (${orderMasterIds})
</if>
2023-06-04 01:40:36 +08:00
<if test= "isCall != null" >
2023-06-04 01:57:21 +08:00
AND om.is_call = #{isCall}
2023-06-04 01:40:36 +08:00
</if>
2023-06-07 23:24:58 +08:00
<if test= "expectTimeStart != null" >
AND om.expect_time_start > = #{expectTimeStart}
</if>
<if test= "expectTimeEnd != null" >
AND om.expect_time_end < = #{expectTimeEnd}
</if>
2023-10-01 01:37:28 +08:00
<if test= "createBy != null and createBy != ''" >
AND om.create_by = #{createBy}
</if>
2022-07-13 11:11:04 +08:00
</where>
</select>
2022-04-25 17:06:55 +08:00
<select id= "selectById" parameterType= "long" resultMap= "OrderMasterResult" >
<include refid= "selectOrderMaster" />
<where >
<if test= "orderMasterId != null and orderMasterId != 0" >
AND id = #{orderMasterId}
</if>
</where>
</select>
<delete id= "deleteOrderMasterByIds" parameterType= "Long" >
DELETE FROM order_master WHERE id IN
<foreach collection= "array" item= "orderMasterId" open= "(" separator= "," close= ")" >
#{orderMasterId}
</foreach>
</delete>
<update id= "updateOrderMaster" parameterType= "com.ghy.order.domain.OrderMaster" >
UPDATE order_master
<set >
<if test= "code != null and code != ''" > code = #{code},</if>
2022-05-24 22:26:26 +08:00
<if test= "customerId != null and customerId != 0" > customer_id = #{customerId},</if>
<if test= "orderType != null" > order_type = #{orderType},</if>
<if test= "orderStatus != null" > order_status = #{orderStatus},</if>
<if test= "payType != null" > pay_type = #{payType},</if>
<if test= "payStatus != null" > pay_status = #{payStatus},</if>
<if test= "workerId != null and workerId != 0" > worker_id = #{workerId},</if>
2022-09-12 14:48:30 +08:00
<if test= "workerId == -1" >
worker_id = NULL,
</if>
2022-05-24 22:26:26 +08:00
<if test= "payTime != null" > pay_time = #{payTime},</if>
<if test= "revTime != null" > rev_time = #{revTime},</if>
2022-06-20 18:09:34 +08:00
<if test= "expectTimeStart != null" > expect_time_start = #{expectTimeStart},</if>
<if test= "expectTimeEnd != null" > expect_time_end = #{expectTimeEnd},</if>
2022-10-27 00:54:15 +08:00
<if test= "useTimeNotRange" > expect_time_end = null,</if>
2022-04-25 17:06:55 +08:00
<if test= "updateBy != null and updateBy != ''" > update_by = #{updateBy},</if>
2022-11-04 00:30:37 +08:00
<if test= "allSelfAssigned != null" > all_self_assigned = #{allSelfAssigned},</if>
2022-11-18 01:47:54 +08:00
<if test= "resetAllSelfAssigned" > all_self_assigned = null,</if>
<if test= "hasDispatchedAll != null" > has_dispatched_all = #{hasDispatchedAll},</if>
2023-06-04 01:40:36 +08:00
<if test= "isCall != null" > is_call = #{isCall},</if>
2023-10-18 23:23:53 +08:00
<if test= "isCharge != null" > is_charge = #{isCharge},</if>
<if test= "isContact != null" > is_contact = #{isContact},</if>
2023-07-09 16:39:49 +08:00
<if test= "timeout != null" > timeout_ = #{timeout},</if>
2024-12-09 00:37:48 +08:00
<if test= "insuranceId != null" > insurance_id = #{insuranceId},</if>
2025-06-19 18:10:43 +08:00
<if test= "serverGoodsId != null" > server_goods_id = #{serverGoodsId},</if>
2025-08-22 11:35:33 +08:00
<if test= "serviceShopId != null" > service_shop_id = #{serviceShopId},</if>
2025-06-19 18:10:43 +08:00
<if test= "goodsOrderMasterId != null" > goods_order_master_id = #{goodsOrderMasterId},</if>
<if test= "trackingNumber != null" > tracking_number = #{trackingNumber},</if>
2025-06-20 10:09:03 +08:00
<if test= "serverGoodsMoney != null" > server_goods_money = #{serverGoodsMoney},</if>
2025-06-20 11:33:53 +08:00
<if test= "hasServiceOrder != null" > has_service_order = #{hasServiceOrder},</if>
2025-07-03 14:55:42 +08:00
<if test= "orderImages != null" > order_images = #{orderImages},</if>
<if test= "isDeliveryToStore != null" > is_delivery_to_store = #{isDeliveryToStore},</if>
2025-07-09 17:41:24 +08:00
<if test= "deliveryType != null" > delivery_type = #{deliveryType},</if>
<if test= "deliveryRemark != null" > delivery_remark = #{deliveryRemark},</if>
<if test= "deliveryImages != null" > delivery_images = #{deliveryImages},</if>
2025-07-08 09:47:25 +08:00
<if test= "isInvoiced != null" > is_invoiced = #{isInvoiced},</if>
<if test= "isNeedBill != null" > is_need_bill = #{isNeedBill},</if>
2025-07-08 10:36:12 +08:00
<if test= "originalWorkerId != null" > original_worker_id = #{originalWorkerId},</if>
2025-08-28 11:33:01 +08:00
<if test= "returnReason != null" > return_reason = #{returnReason},</if>
<if test= "returnReasonDetail != null" > return_reason_detail = #{returnReasonDetail},</if>
<if test= "returnImages != null" > return_images = #{returnImages},</if>
2025-08-30 08:54:52 +08:00
<if test= "workerRemark != null" > worker_remark = #{workerRemark},</if>
2025-09-06 17:44:40 +08:00
<if test= "afterServiceStatus != null" > after_service_status = #{afterServiceStatus},</if>
2025-09-11 11:01:42 +08:00
<if test= "shareAccountCountdownEndTime != null" > share_account_countdown_end_time = #{shareAccountCountdownEndTime},</if>
<if test= "shareAccountCountdownDuration != null" > share_account_countdown_duration = #{shareAccountCountdownDuration},</if>
2022-04-25 17:06:55 +08:00
update_time = SYSDATE()
</set>
WHERE id = #{id}
</update>
2022-07-20 15:10:01 +08:00
<update id= "updateStatus" >
UPDATE order_master
SET order_status = #{orderStatus},
update_time = SYSDATE()
WHERE id = #{orderMasterId}
</update>
2023-03-29 00:09:09 +08:00
<update id= "updatePayStatus" >
UPDATE order_master
SET pay_status = #{payStatus},
update_time = SYSDATE()
WHERE id = #{orderMasterId}
</update>
2022-04-25 17:06:55 +08:00
<insert id= "insertOrderMaster" parameterType= "com.ghy.order.domain.OrderMaster" useGeneratedKeys= "true" keyProperty= "id" >
INSERT INTO order_master(
2022-05-24 22:26:26 +08:00
<if test= "deptId != null and deptId != 0" > dept_id,</if>
<if test= "code != null and code != ''" > code,</if>
<if test= "customerId != null and customerId != 0" > customer_id,</if>
2022-06-09 14:35:13 +08:00
<if test= "addressId != null and addressId != 0" > address_id,</if>
2022-07-04 22:35:02 +08:00
<if test= "goodsId != null and goodsId != 0" > goods_id,</if>
2022-05-24 22:26:26 +08:00
<if test= "orderType != null" > order_type,</if>
2023-06-01 21:41:59 +08:00
<if test= "orderMode != null" > order_mode,</if>
2023-10-05 01:24:05 +08:00
<if test= "payMode != null" > pay_mode,</if>
2024-03-02 20:47:11 +08:00
<if test= "consultMode != null" > consult_mode,</if>
2024-10-23 17:00:48 +08:00
<if test= "insuranceId != null" > insurance_id,</if>
2022-05-24 22:26:26 +08:00
<if test= "orderStatus != null" > order_status,</if>
<if test= "payType != null" > pay_type,</if>
<if test= "payStatus != null" > pay_status,</if>
<if test= "workerId != null and workerId != 0" > worker_id,</if>
<if test= "payTime != null" > pay_time,</if>
<if test= "revTime != null" > rev_time,</if>
2022-06-30 17:48:25 +08:00
<if test= "remark != null" > remark,</if>
2023-11-09 09:59:34 +08:00
<if test= "goodsBrand != null and goodsBrand != ''" > goods_brand,</if>
<if test= "goodsSpecification != null and goodsSpecification != ''" > goods_specification,</if>
2022-06-20 18:09:34 +08:00
<if test= "expectTimeStart != null" > expect_time_start,</if>
<if test= "expectTimeEnd != null" > expect_time_end,</if>
2022-04-25 17:06:55 +08:00
<if test= "createBy != null and createBy != ''" > create_by,</if>
2025-04-22 17:58:54 +08:00
<if test= "provinceId != null" > province_id,</if>
<if test= "cityId != null" > city_id,</if>
<if test= "countryId != null" > country_id,</if>
<if test= "streetId != null" > street_id,</if>
<if test= "address != null" > address,</if>
<if test= "name != null" > name,</if>
<if test= "phone != null" > phone,</if>
2025-04-22 19:51:37 +08:00
<if test= "provinceName != null" > province_name,</if>
<if test= "cityName != null" > city_name,</if>
<if test= "countryName != null" > country_name,</if>
<if test= "streetName != null" > street_name,</if>
2025-06-19 18:10:43 +08:00
<if test= "serverGoodsId != null" > server_goods_id,</if>
2025-08-22 11:35:33 +08:00
<if test= "serviceShopId != null" > service_shop_id,</if>
2025-06-19 18:10:43 +08:00
<if test= "goodsOrderMasterId != null" > goods_order_master_id,</if>
<if test= "trackingNumber != null and trackingNumber != ''" > tracking_number,</if>
2025-06-20 10:09:03 +08:00
<if test= "serverGoodsMoney != null" > server_goods_money,</if>
2025-06-20 11:33:53 +08:00
<if test= "hasServiceOrder != null" > has_service_order,</if>
2025-07-03 14:55:42 +08:00
<if test= "orderImages != null" > order_images,</if>
<if test= "isDeliveryToStore != null" > is_delivery_to_store,</if>
2025-07-09 17:41:24 +08:00
<if test= "deliveryType != null" > delivery_type,</if>
<if test= "deliveryRemark != null" > delivery_remark,</if>
<if test= "deliveryImages != null" > delivery_images,</if>
2025-07-08 09:47:25 +08:00
<if test= "isInvoiced != null" > is_invoiced,</if>
<if test= "isNeedBill != null" > is_need_bill,</if>
2025-07-08 10:36:12 +08:00
<if test= "originalWorkerId != null" > original_worker_id,</if>
2025-08-28 11:33:01 +08:00
<if test= "returnReason != null" > return_reason,</if>
<if test= "returnReasonDetail != null" > return_reason_detail,</if>
<if test= "returnImages != null" > return_images,</if>
2025-08-30 08:54:52 +08:00
<if test= "workerRemark != null" > worker_remark,</if>
2025-09-11 11:01:42 +08:00
<if test= "shareAccountCountdownEndTime != null" > share_account_countdown_end_time,</if>
<if test= "shareAccountCountdownDuration != null" > share_account_countdown_duration,</if>
2022-04-25 17:06:55 +08:00
create_time
)VALUES(
2022-05-24 22:26:26 +08:00
<if test= "deptId != null and deptId != 0" > #{deptId},</if>
2022-05-12 14:30:06 +08:00
<if test= "code != null" > #{code},</if>
2022-05-24 22:26:26 +08:00
<if test= "customerId != null and customerId != 0" > #{customerId},</if>
2022-06-20 10:07:44 +08:00
<if test= "addressId != null and addressId != 0" > #{addressId},</if>
2022-07-04 22:35:02 +08:00
<if test= "goodsId != null and goodsId != 0" > #{goodsId},</if>
2022-05-24 22:26:26 +08:00
<if test= "orderType != null" > #{orderType},</if>
2023-06-01 21:41:59 +08:00
<if test= "orderMode != null" > #{orderMode},</if>
2023-10-05 01:24:05 +08:00
<if test= "payMode != null" > #{payMode},</if>
2024-03-02 20:47:11 +08:00
<if test= "consultMode != null" > #{consultMode},</if>
2024-10-28 16:45:10 +08:00
<if test= "insuranceId != null" > #{insuranceId},</if>
2022-05-24 22:26:26 +08:00
<if test= "orderStatus != null" > #{orderStatus},</if>
<if test= "payType != null" > #{payType},</if>
<if test= "payStatus != null" > #{payStatus},</if>
<if test= "workerId != null and workerId != 0" > #{workerId},</if>
<if test= "payTime != null" > #{payTime},</if>
<if test= "revTime != null" > #{revTime},</if>
2022-06-30 17:48:25 +08:00
<if test= "remark != null" > #{remark},</if>
2023-11-09 09:59:34 +08:00
<if test= "goodsBrand != null and goodsBrand != ''" > #{goodsBrand},</if>
<if test= "goodsSpecification != null and goodsSpecification != ''" > #{goodsSpecification},</if>
2022-06-20 18:09:34 +08:00
<if test= "expectTimeStart != null" > #{expectTimeStart},</if>
<if test= "expectTimeEnd != null" > #{expectTimeEnd},</if>
2022-04-25 17:06:55 +08:00
<if test= "createBy != null and createBy != ''" > #{createBy},</if>
2025-04-22 17:58:54 +08:00
<if test= "provinceId != null" > #{provinceId},</if>
<if test= "cityId != null" > #{cityId},</if>
<if test= "countryId != null" > #{countryId},</if>
<if test= "streetId != null" > #{streetId},</if>
<if test= "address != null" > #{address},</if>
<if test= "name != null" > #{name},</if>
<if test= "phone != null" > #{phone},</if>
2025-04-22 19:51:37 +08:00
<if test= "provinceName != null" > #{provinceName},</if>
<if test= "cityName != null" > #{cityName},</if>
<if test= "countryName != null" > #{countryName},</if>
<if test= "streetName != null" > #{streetName},</if>
2025-06-19 18:10:43 +08:00
<if test= "serverGoodsId != null" > #{serverGoodsId},</if>
2025-08-22 11:35:33 +08:00
<if test= "serviceShopId != null" > #{serviceShopId},</if>
2025-06-19 18:10:43 +08:00
<if test= "goodsOrderMasterId != null" > #{goodsOrderMasterId},</if>
<if test= "trackingNumber != null and trackingNumber != ''" > #{trackingNumber},</if>
2025-06-20 10:09:03 +08:00
<if test= "serverGoodsMoney != null" > #{serverGoodsMoney},</if>
2025-06-20 11:33:53 +08:00
<if test= "hasServiceOrder != null" > #{hasServiceOrder},</if>
2025-07-03 14:55:42 +08:00
<if test= "orderImages != null" > #{orderImages},</if>
<if test= "isDeliveryToStore != null" > #{isDeliveryToStore},</if>
2025-07-09 17:41:24 +08:00
<if test= "deliveryType != null" > #{deliveryType},</if>
<if test= "deliveryRemark != null" > #{deliveryRemark},</if>
<if test= "deliveryImages != null" > #{deliveryImages},</if>
2025-07-08 09:47:25 +08:00
<if test= "isInvoiced != null" > #{isInvoiced},</if>
<if test= "isNeedBill != null" > #{isNeedBill},</if>
2025-07-08 10:36:12 +08:00
<if test= "originalWorkerId != null" > #{originalWorkerId},</if>
2025-08-28 11:33:01 +08:00
<if test= "returnReason != null" > #{returnReason},</if>
<if test= "returnReasonDetail != null" > #{returnReasonDetail},</if>
<if test= "returnImages != null" > #{returnImages},</if>
2025-08-30 08:54:52 +08:00
<if test= "workerRemark != null" > #{workerRemark},</if>
2025-09-11 11:01:42 +08:00
<if test= "shareAccountCountdownEndTime != null" > #{shareAccountCountdownEndTime},</if>
<if test= "shareAccountCountdownDuration != null" > #{shareAccountCountdownDuration},</if>
2022-04-25 17:06:55 +08:00
SYSDATE()
)
</insert>
<select id= "checkOrderMasterCodeUnique" parameterType= "String" resultMap= "OrderMasterResult" >
<include refid= "selectOrderMaster" />
2022-08-24 23:47:51 +08:00
WHERE `code` = #{orderMasterCode} LIMIT 1
2022-04-25 17:06:55 +08:00
</select>
2022-05-29 17:52:49 +08:00
<select id= "selectByCode" parameterType= "String" resultMap= "OrderMasterResult" >
2022-05-11 20:10:00 +08:00
<include refid= "selectOrderMaster" />
WHERE `code` = #{orderMasterCode}
</select>
2022-08-24 23:47:51 +08:00
<select id= "selectByStatus" resultMap= "OrderMasterResult" >
2022-08-04 19:35:14 +08:00
<include refid= "selectOrderMaster" />
WHERE `order_status` IN
<foreach collection= "list" item= "orderStatus" open= "(" separator= "," close= ")" >
#{orderStatus}
</foreach>
</select>
2022-08-24 23:47:51 +08:00
<select id= "selectUnfinished" resultMap= "OrderMasterResult" >
<include refid= "selectOrderMaster" />
WHERE `order_status` < 5
</select>
2023-02-17 21:11:23 +08:00
<select id= "selectByIds" resultMap= "OrderMasterResult" >
<include refid= "selectOrderMaster" />
<where >
AND id IN
<foreach item= "item" index= "orderMasterId" collection= "orderMasterId" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</where>
</select>
2023-05-09 19:53:44 +08:00
<update id= "updateTimeout" >
UPDATE order_master
SET timeout_ = #{timeout}
2023-05-10 20:14:07 +08:00
<if test= "timeoutFineTimes != null" > ,timeout_fine_times = #{timeoutFineTimes}</if>
2023-05-09 19:53:44 +08:00
WHERE id = #{id}
</update>
2025-03-10 21:07:02 +08:00
<update id= "updateCreateTime" >
UPDATE order_master
SET create_time = SYSDATE()
WHERE id = #{id}
</update>
2023-05-09 19:53:44 +08:00
<update id= "removeWorker" >
UPDATE order_master
2023-12-26 10:14:37 +08:00
SET worker_id = NULL,
update_time = SYSDATE()
2023-05-09 19:53:44 +08:00
WHERE id = #{id}
</update>
2023-06-26 00:02:43 +08:00
<select id= "differentStatusOrderCount" resultType= "com.ghy.order.domain.OrderMasterCount" parameterType= "com.ghy.order.domain.OrderMaster" >
2023-06-07 23:24:58 +08:00
select
2024-01-29 17:26:04 +08:00
count(case when om.order_status = 0 and om.worker_id is not null then 1 else null end) as newOrderNum,
2023-06-07 23:24:58 +08:00
count(case when om.order_status = 1 then 1 else null end) as acceptedOrderNum,
2023-06-26 00:31:20 +08:00
count(case when om.order_status = 1 and om.is_call = '01' then 1 else null end) as notAppointedOrderNum,
count(case when om.order_status = 1 and om.is_call = '02' then 1 else null end) as notArrangedOrderNum,
2023-06-07 23:24:58 +08:00
count(case when om.order_status = 2 then 1 else null end) as waitForDoorOrderNum,
count(case when om.order_status = 3 then 1 else null end) as servingOrderNum,
count(case when om.order_status = 4 then 1 else null end) as confirmingOrderNum,
count(case when om.order_status = 5 then 1 else null end) as finishedOrderNum,
count(case when om.order_status = 6 then 1 else null end) as canceledOrderNum
from order_master om
2023-06-26 00:02:43 +08:00
where 1 = 1
<if test= "timeout != null" >
AND om.timeout_ = #{timeout}
</if>
2023-06-26 00:31:20 +08:00
<if test= "isCall != null" >
AND om.is_call = #{isCall}
</if>
2023-10-01 01:37:28 +08:00
<if test= "createBy != null and createBy != ''" >
AND om.create_by = #{createBy}
</if>
2023-06-07 23:24:58 +08:00
</select>
2024-09-27 12:14:59 +08:00
<select id= "searchByOrderStartTime" parameterType= "com.ghy.order.domain.OrderMaster" resultMap= "OrderMasterResult" >
<include refid= "selectOrderMaster" />
<where >
2024-11-18 13:41:57 +08:00
<if test= "startTime != null" >
and create_time <![CDATA[ >= ]]> #{startTime}
2024-09-27 12:14:59 +08:00
</if>
2024-11-18 13:41:57 +08:00
<if test= "endTime != null" >
and create_time <![CDATA[ <= ]]> #{endTime}
2024-09-27 12:14:59 +08:00
</if>
</where>
</select>
2025-04-22 19:51:37 +08:00
<update id= "updateOrderMasterAddressById" parameterType= "com.ghy.order.domain.OrderMaster" >
UPDATE order_master
<set >
<if test= "name != null" > name = #{name},</if>
<if test= "phone != null" > phone = #{phone},</if>
<if test= "provinceId != null" > province_id = #{provinceId},</if>
<if test= "provinceName != null" > province_name = #{provinceName},</if>
<if test= "cityName != null" > city_name = #{cityName},</if>
<if test= "countryName != null" > country_name = #{countryName},</if>
<if test= "streetName != null" > street_name = #{streetName},</if>
<if test= "cityId != null" > city_id = #{cityId},</if>
<if test= "countryId != null" > country_id = #{countryId},</if>
<if test= "streetId != null" > street_id = #{streetId},</if>
<if test= "address != null" > address = #{address}</if>
</set>
WHERE id = #{id}
</update>
2022-05-12 14:30:06 +08:00
</mapper>