售后超时,恢复财务金额
This commit is contained in:
parent
e7bb47f023
commit
c733349a9e
|
|
@ -1356,6 +1356,10 @@ public class OrderController extends BaseController {
|
|||
// 查询子单
|
||||
OrderDetail orderDetailReq = new OrderDetail();
|
||||
BeanUtils.copyProperties(orderListRequest, orderDetailReq);
|
||||
// 当查询超时订单时,需要同时考虑订单服务超时和售后超时
|
||||
if (orderListRequest.getTimeout() != null && orderListRequest.getTimeout() == 1) {
|
||||
orderDetailReq.setIncludeAfterTimeout(true);
|
||||
}
|
||||
// 拿到所有正常筛选出来的子单
|
||||
List<OrderListResponse> detailList = this.getDetailList(orderDetailReq);
|
||||
orderListResponses.addAll(detailList);
|
||||
|
|
|
|||
|
|
@ -805,6 +805,7 @@ public class OrderDetailController extends BaseController {
|
|||
AfterServiceRecord afterServiceRecord=new AfterServiceRecord();
|
||||
afterServiceRecord.setOrderDetailId(detail.getId());
|
||||
List<AfterServiceRecord> afterServiceRecordList=afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecord);
|
||||
orderListResponse.setShowAfterServiceRecord(1);
|
||||
orderListResponse.setIsNeedBill(orderMaster.getIsNeedBill());
|
||||
orderListResponse.setIsMonitoredOrder(orderMaster.getIsMonitoredOrder());
|
||||
orderListResponse.setOrderImages(orderMaster.getOrderImages());
|
||||
|
|
|
|||
|
|
@ -192,6 +192,11 @@ public class OrderDetail extends BaseEntity {
|
|||
* */
|
||||
private Integer afterTimeout;
|
||||
|
||||
/**
|
||||
* 查询时是否包含售后超时条件
|
||||
*/
|
||||
private Boolean includeAfterTimeout;
|
||||
|
||||
/**
|
||||
* 超时扣款次数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -117,9 +117,23 @@ public class AfterServiceTimeoutTask {
|
|||
// 倒计时3:师傅拒绝或同意后客户36小时不操作自动取消售后
|
||||
record.setCustomerFinalCheck(null);
|
||||
record.setAfterServiceStatus(2); // 设置为已取消状态
|
||||
// 售后单取消完成,不需要退款,不设置refundApplyTime
|
||||
record.setIsAutoProcessed(1); // 自动处理
|
||||
|
||||
// // 检查是否需要恢复财务金额
|
||||
// if (record.getOriginalRefund() != null && record.getOriginalRefund().compareTo(java.math.BigDecimal.ZERO) > 0) {
|
||||
// log.info("售后取消,开始恢复财务金额,记录ID:{},原退款金额:{}",
|
||||
// record.getId(), record.getOriginalRefund());
|
||||
|
||||
// // 调用财务恢复逻辑
|
||||
// try {
|
||||
// afterServiceRecordService.restoreFinancialAmount(record);
|
||||
// log.info("售后取消财务金额恢复成功,记录ID:{}", record.getId());
|
||||
// } catch (Exception e) {
|
||||
// log.error("售后取消财务金额恢复失败,记录ID:{},错误:{}",
|
||||
// record.getId(), e.getMessage(), e);
|
||||
// }
|
||||
// }
|
||||
|
||||
log.info("师傅拒绝/同意后客户超时自动取消,售后单取消完成,售后记录ID:{}", record.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,4 +137,11 @@ public interface IAfterServiceRecordService {
|
|||
* @return 操作结果
|
||||
*/
|
||||
AjaxResult workerConfirmReceive(AfterServiceRecord afterServiceRecord);
|
||||
|
||||
/**
|
||||
* 恢复财务金额
|
||||
* 当售后取消时,将之前扣减的金额恢复到原财务账单
|
||||
* @param afterServiceRecord 售后记录
|
||||
*/
|
||||
void restoreFinancialAmount(AfterServiceRecord afterServiceRecord);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,15 @@ import com.ghy.order.domain.AfterServiceRecord;
|
|||
import com.ghy.order.domain.OrderDetail;
|
||||
import com.ghy.order.domain.OrderMaster;
|
||||
import com.ghy.order.mapper.AfterServiceRecordMapper;
|
||||
import com.ghy.order.mapper.OrderDetailMapper;
|
||||
import com.ghy.order.service.IAfterServiceImgsService;
|
||||
import com.ghy.order.service.IAfterServiceRecordService;
|
||||
import com.ghy.order.service.OrderDetailService;
|
||||
import com.ghy.order.service.OrderMasterService;
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.domain.FinancialMaster;
|
||||
import com.ghy.payment.mapper.FinancialDetailMapper;
|
||||
import com.ghy.payment.mapper.FinancialMasterMapper;
|
||||
import com.ghy.payment.service.AdapayService;
|
||||
import com.ghy.payment.service.FinancialDetailService;
|
||||
import com.ghy.payment.service.FinancialMasterService;
|
||||
|
|
@ -72,6 +75,12 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService
|
|||
private WorkerService workerService;
|
||||
@Autowired
|
||||
private CustomerAddressService customerAddressService;
|
||||
@Resource
|
||||
private OrderDetailMapper orderDetailMapper;
|
||||
@Resource
|
||||
private FinancialDetailMapper financialDetailMapper;
|
||||
@Resource
|
||||
private FinancialMasterMapper financialMasterMapper;
|
||||
|
||||
|
||||
|
||||
|
|
@ -86,6 +95,81 @@ public class AfterServiceRecordServiceImpl implements IAfterServiceRecordService
|
|||
return afterServiceRecordMapper.selectAfterServiceRecordById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复财务金额
|
||||
* 当售后取消时,将之前扣减的金额恢复到原财务账单
|
||||
* @param afterServiceRecord 售后记录
|
||||
*/
|
||||
public void restoreFinancialAmount(AfterServiceRecord afterServiceRecord) {
|
||||
try {
|
||||
log.info("开始恢复财务金额,售后记录ID:{},原退款金额:{}",
|
||||
afterServiceRecord.getId(), afterServiceRecord.getOriginalRefund());
|
||||
|
||||
// 检查是否有需要恢复的金额
|
||||
if (afterServiceRecord.getOriginalRefund() == null ||
|
||||
afterServiceRecord.getOriginalRefund().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
log.info("无需恢复财务金额,售后记录ID:{}", afterServiceRecord.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// 查询订单详情
|
||||
OrderDetail orderDetail = orderDetailService.selectById(afterServiceRecord.getOrderDetailId());
|
||||
if (orderDetail == null) {
|
||||
log.error("订单详情不存在,无法恢复财务金额,订单详情ID:{}", afterServiceRecord.getOrderDetailId());
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal restoreAmount = afterServiceRecord.getOriginalRefund();
|
||||
|
||||
// 判断是大师傅子单还是小师傅子单
|
||||
if (orderDetail.getOrderMasterId() != null && orderDetail.getOrderMasterId() > 0) {
|
||||
// 小师傅子单,恢复子财务单
|
||||
FinancialDetail financialDetail = financialDetailMapper.selectByOrderDetailId(orderDetail.getId());
|
||||
|
||||
if (financialDetail != null) {
|
||||
// 恢复支付金额和服务金额
|
||||
BigDecimal newPayAmount = financialDetail.getPayMoney().add(restoreAmount);
|
||||
|
||||
financialDetail.setPayMoney(newPayAmount);
|
||||
financialDetail.setUpdateTime(new Date());
|
||||
|
||||
financialDetailMapper.updateFinancialDetail(financialDetail);
|
||||
|
||||
log.info("小师傅子单财务金额恢复成功,订单详情ID:{},恢复金额:{},新支付金额:{}",
|
||||
orderDetail.getId(), restoreAmount, newPayAmount);
|
||||
} else {
|
||||
log.error("子财务单不存在,无法恢复财务金额,订单详情ID:{}", orderDetail.getId());
|
||||
}
|
||||
} else {
|
||||
// 大师傅子单,恢复主财务单
|
||||
FinancialMaster financialMaster = financialMasterMapper.selectByOrderMasterId(orderDetail.getOrderMasterId());
|
||||
if (financialMaster != null) {
|
||||
// 恢复支付金额和服务金额
|
||||
BigDecimal newPayAmount = financialMaster.getPayMoney().add(restoreAmount);
|
||||
BigDecimal newServiceAmount = financialMaster.getServerMoney().add(restoreAmount);
|
||||
|
||||
financialMaster.setPayMoney(newPayAmount);
|
||||
financialMaster.setServerMoney(newServiceAmount);
|
||||
financialMaster.setUpdateTime(new Date());
|
||||
|
||||
financialMasterMapper.updateFinancialMaster(financialMaster);
|
||||
|
||||
log.info("大师傅子单财务金额恢复成功,主订单ID:{},恢复金额:{},新支付金额:{},新服务金额:{}",
|
||||
orderDetail.getOrderMasterId(), restoreAmount, newPayAmount, newServiceAmount);
|
||||
} else {
|
||||
log.error("主财务单不存在,无法恢复财务金额,主订单ID:{}", orderDetail.getOrderMasterId());
|
||||
}
|
||||
}
|
||||
|
||||
log.info("财务金额恢复完成,售后记录ID:{},恢复金额:{}",
|
||||
afterServiceRecord.getId(), restoreAmount);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("恢复财务金额异常,售后记录ID:{},错误:{}",
|
||||
afterServiceRecord.getId(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询售后记录列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -264,7 +264,6 @@
|
|||
AND customer_final_check IS NULL
|
||||
AND (is_auto_processed IS NULL OR is_auto_processed = 0)
|
||||
AND create_time <= DATE_SUB(NOW(), INTERVAL 24 HOUR)
|
||||
AND create_time > DATE_SUB(NOW(), INTERVAL 24*60+5 MINUTE)
|
||||
</select>
|
||||
|
||||
<!-- 查询客户确认超时的售后记录 -->
|
||||
|
|
@ -277,13 +276,11 @@
|
|||
AND (
|
||||
-- 倒计时2:师傅重做完成后客户36小时不操作
|
||||
(worker_feedback_result = 3
|
||||
AND redo_complete_time <= DATE_SUB(NOW(), INTERVAL 36 HOUR)
|
||||
AND redo_complete_time > DATE_SUB(NOW(), INTERVAL 36*60+5 MINUTE))
|
||||
AND redo_complete_time <= DATE_SUB(NOW(), INTERVAL 36 HOUR))
|
||||
OR
|
||||
-- 倒计时3:师傅拒绝或同意后客户36小时不操作
|
||||
(worker_feedback_result IN (0, 1)
|
||||
AND update_time <= DATE_SUB(NOW(), INTERVAL 36 HOUR)
|
||||
AND update_time > DATE_SUB(NOW(), INTERVAL 36*60+5 MINUTE))
|
||||
AND update_time <= DATE_SUB(NOW(), INTERVAL 36 HOUR))
|
||||
)
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,14 @@
|
|||
<!-- AND od.work_finish_time is not null-->
|
||||
<!-- </if>-->
|
||||
<if test="timeout != null">
|
||||
<choose>
|
||||
<when test="includeAfterTimeout != null and includeAfterTimeout == true">
|
||||
AND (od.timeout_ = #{timeout} OR od.after_timeout = #{timeout})
|
||||
</when>
|
||||
<otherwise>
|
||||
AND od.timeout_ = #{timeout}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- <if test="isCall != null">-->
|
||||
<!-- AND om.is_call = #{isCall}-->
|
||||
|
|
@ -335,7 +342,14 @@
|
|||
</foreach>
|
||||
</if>
|
||||
<if test="timeout != null">
|
||||
<choose>
|
||||
<when test="includeAfterTimeout != null and includeAfterTimeout == true">
|
||||
AND (od.timeout_ = #{timeout} OR od.after_timeout = #{timeout})
|
||||
</when>
|
||||
<otherwise>
|
||||
AND od.timeout_ = #{timeout}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="masterIds != null and masterIds.size() > 0">
|
||||
AND od.order_master_id in
|
||||
|
|
|
|||
Loading…
Reference in New Issue