diff --git a/ghy-order/src/main/java/com/ghy/order/domain/AfterServiceRecord.java b/ghy-order/src/main/java/com/ghy/order/domain/AfterServiceRecord.java index 15bb9983..33a1ee32 100644 --- a/ghy-order/src/main/java/com/ghy/order/domain/AfterServiceRecord.java +++ b/ghy-order/src/main/java/com/ghy/order/domain/AfterServiceRecord.java @@ -94,6 +94,10 @@ public class AfterServiceRecord extends BaseEntity @Excel(name = "客户是否同意上门重做方案:0-未处理,1-同意,2-不同意") private Integer customerAgreeRedo; + /** 客户操作时间 */ + @Excel(name = "客户操作时间") + private Date customerOperationTime; + /** 重做/补做完成时间 */ @Excel(name = "重做/补做完成时间") private Date redoCompleteTime; diff --git a/ghy-order/src/main/java/com/ghy/order/mapper/AfterServiceRecordMapper.java b/ghy-order/src/main/java/com/ghy/order/mapper/AfterServiceRecordMapper.java index 84d57dad..bd80b17f 100644 --- a/ghy-order/src/main/java/com/ghy/order/mapper/AfterServiceRecordMapper.java +++ b/ghy-order/src/main/java/com/ghy/order/mapper/AfterServiceRecordMapper.java @@ -91,6 +91,14 @@ public interface AfterServiceRecordMapper { */ List selectWorkerResendTimeoutRecords(); + /** + * 查询退货发货超时的售后记录 + * 查询退货发货时间超过6天且师傅未确认收货的售后记录 + * + * @return 超时的售后记录列表 + */ + List selectReturnShipTimeoutRecords(); + /** * 批量更新售后状态:当客户最终确认为1时,将售后状态设置为1 * diff --git a/ghy-order/src/main/java/com/ghy/order/quartz/AfterServiceTimeoutTask.java b/ghy-order/src/main/java/com/ghy/order/quartz/AfterServiceTimeoutTask.java index e1091d4d..03838877 100644 --- a/ghy-order/src/main/java/com/ghy/order/quartz/AfterServiceTimeoutTask.java +++ b/ghy-order/src/main/java/com/ghy/order/quartz/AfterServiceTimeoutTask.java @@ -1,5 +1,6 @@ package com.ghy.order.quartz; +import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.utils.DateUtils; import com.ghy.order.domain.AfterServiceRecord; import com.ghy.order.service.IAfterServiceRecordService; @@ -189,4 +190,71 @@ public class AfterServiceTimeoutTask { log.info("师傅重发补发超时处理完成,共处理{}条记录", timeoutRecords.size()); } + + /** + * 定时任务:自动处理超时的师傅确认收货 + * 每天凌晨2点执行,查询退货发货时间超过6天且师傅未确认收货的售后记录 + * 自动调用师傅确认收货方法进行退款处理 + */ + @Scheduled(cron = "0 0 2 * * ?") + public void autoConfirmReceiveTask() { + try { + log.info("开始执行自动确认收货定时任务"); + + // 查询退货发货时间超过6天且师傅未确认收货的售后记录 + List timeoutRecords = afterServiceRecordService.selectReturnShipTimeoutRecords(); + + if (timeoutRecords == null || timeoutRecords.isEmpty()) { + log.info("没有找到需要自动确认收货的超时记录"); + return; + } + + log.info("找到{}条需要自动确认收货的超时记录", timeoutRecords.size()); + + int successCount = 0; + int failCount = 0; + + // 循环处理每条超时记录 + for (AfterServiceRecord record : timeoutRecords) { + try { + log.info("开始自动确认收货,售后记录ID:{},退货发货时间:{}", + record.getId(), record.getReturnShipTime()); + + // 创建参数对象 + AfterServiceRecord param = new AfterServiceRecord(); + param.setId(record.getId()); + + // 调用师傅确认收货方法 + AjaxResult result = afterServiceRecordService.workerConfirmReceive(param); + + // if (result.isSuccess()) { + // successCount++; + + // // 标记为自动处理 + // record.setIsAutoProcessed(1); + // record.setAutoProcessTime(new Date()); + // record.setUpdateTime(new Date()); + // afterServiceRecordService.updateAfterServiceRecord(record); + + // log.info("自动确认收货成功,售后记录ID:{}", record.getId()); + // } else { + // failCount++; + // log.error("自动确认收货失败,售后记录ID:{},错误信息:{}", + // record.getId(), result.getMsg()); + // } + + } catch (Exception e) { + failCount++; + log.error("自动确认收货异常,售后记录ID:{},错误:{}", + record.getId(), e.getMessage(), e); + } + } + + log.info("自动确认收货定时任务执行完成,总记录数:{},成功:{},失败:{}", + timeoutRecords.size(), successCount, failCount); + + } catch (Exception e) { + log.error("自动确认收货定时任务执行异常:{}", e.getMessage(), e); + } + } } diff --git a/ghy-order/src/main/java/com/ghy/order/service/IAfterServiceRecordService.java b/ghy-order/src/main/java/com/ghy/order/service/IAfterServiceRecordService.java index 3530222f..2688a2eb 100644 --- a/ghy-order/src/main/java/com/ghy/order/service/IAfterServiceRecordService.java +++ b/ghy-order/src/main/java/com/ghy/order/service/IAfterServiceRecordService.java @@ -129,6 +129,14 @@ public interface IAfterServiceRecordService { */ List selectWorkerResendTimeoutRecords(); + /** + * 查询退货发货时间超过6天且师傅未确认收货的售后记录 + * 用于定时任务自动处理师傅确认收货超时的情况 + * + * @return 超时的售后记录列表 + */ + List selectReturnShipTimeoutRecords(); + /** * 师傅确认收货 * 师傅确认收到货物后,根据同意处理方式决定是否执行退款 diff --git a/ghy-order/src/main/java/com/ghy/order/service/impl/AfterServiceRecordServiceImpl.java b/ghy-order/src/main/java/com/ghy/order/service/impl/AfterServiceRecordServiceImpl.java index 37c4c0ab..e4f4a1b5 100644 --- a/ghy-order/src/main/java/com/ghy/order/service/impl/AfterServiceRecordServiceImpl.java +++ b/ghy-order/src/main/java/com/ghy/order/service/impl/AfterServiceRecordServiceImpl.java @@ -36,6 +36,7 @@ import com.ghy.worker.service.WorkerService; import com.huifu.adapay.core.exception.BaseAdaPayException; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; @@ -585,6 +586,8 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService if (param.getUpdateBy() != null) { afterServiceRecord.setUpdateBy(param.getUpdateBy()); } + // 设置客户操作时间 + afterServiceRecord.setCustomerOperationTime(new Date()); afterServiceRecordMapper.updateAfterServiceRecord(afterServiceRecord); log.info("商品售后-客户同意上门重做方案状态已更新:{}", param.getCustomerAgreeRedo()); return AjaxResult.success("客户同意方案状态已更新"); @@ -748,6 +751,7 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService afterServiceRecord.setRefund(param.getRefund()); } log.info("商品售后-客户同意处理方案"); + // 商品售后特殊处理:客户同意且师傅选择即时退单退款时立即执行退款 if (afterServiceRecord.getWorkerAgreeType() != null && afterServiceRecord.getWorkerAgreeType() == 1) { @@ -1258,6 +1262,8 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService } afterServiceRecord.setUpdateBy(param.getUpdateBy()); + // 设置客户操作时间 + afterServiceRecord.setCustomerOperationTime(new Date()); // 更新数据库 int result = afterServiceRecordMapper.updateAfterServiceRecord(afterServiceRecord); @@ -1590,4 +1596,17 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService } } + /** + * 查询退货发货超时的售后记录 + * 退货发货时间超过6天,师傅未确认收货的记录 + * @return 超时的售后记录列表 + */ + @Override + public List selectReturnShipTimeoutRecords() { + log.debug("查询退货发货超时的售后记录"); + return afterServiceRecordMapper.selectReturnShipTimeoutRecords(); + } + + + } diff --git a/ghy-order/src/main/resources/mapper/order/AfterServiceRecordMapper.xml b/ghy-order/src/main/resources/mapper/order/AfterServiceRecordMapper.xml index 55ffd771..f349750a 100644 --- a/ghy-order/src/main/resources/mapper/order/AfterServiceRecordMapper.xml +++ b/ghy-order/src/main/resources/mapper/order/AfterServiceRecordMapper.xml @@ -26,6 +26,7 @@ + @@ -60,7 +61,7 @@ select id, customer_reason_type, customer_reason, order_detail_id, oper_type, worker_feedback_result, worker_feedback_reason_type, worker_feedback_reason, worker_feedback_images, refund, agreed_refund, platform_refund, original_refund, - customer_final_check, create_by, create_time, update_by, update_time, remark, refund_apply_time, customer_agree_redo, + customer_final_check, create_by, create_time, update_by, update_time, remark, refund_apply_time, customer_agree_redo, customer_operation_time, redo_complete_time, redo_complete_remark, redo_complete_images, is_auto_processed, after_service_category, after_service_type, return_status, return_address, return_contact, return_phone, return_type, return_remark, return_images, return_tracking_number, return_ship_time, merchant_receive_time, worker_resend_plan, worker_resend_time, worker_resend_type, worker_resend_tracking_number, worker_receive_status, worker_agree_type, worker_receive_confirm, worker_resend_remark, worker_resend_images, customer_disagree_images, customer_disagree_reason, after_service_status, platform_handle_reason @@ -113,6 +114,7 @@ platform_refund, customer_final_check, customer_agree_redo, + customer_operation_time, redo_complete_time, redo_complete_remark, redo_complete_images, @@ -161,6 +163,7 @@ #{platformRefund}, #{customerFinalCheck}, #{customerAgreeRedo}, + #{customerOperationTime}, #{redoCompleteTime}, #{redoCompleteRemark}, #{redoCompleteImages}, @@ -215,6 +218,7 @@ platform_refund = #{platformRefund}, customer_final_check = #{customerFinalCheck}, customer_agree_redo = #{customerAgreeRedo}, + customer_operation_time = #{customerOperationTime}, redo_complete_time = #{redoCompleteTime}, redo_complete_remark = #{redoCompleteRemark}, redo_complete_images = #{redoCompleteImages}, @@ -304,4 +308,17 @@ ) + + + +