增加主单退单原因

This commit is contained in:
cb 2025-08-28 11:33:01 +08:00
parent 9c519ce980
commit d2260ade7b
9 changed files with 152 additions and 33 deletions

View File

@ -1498,6 +1498,10 @@ public class OrderMasterController extends BaseController {
orderStandardDetail.setAfterTimeout(orderDetail.getAfterTimeout()); orderStandardDetail.setAfterTimeout(orderDetail.getAfterTimeout());
orderStandardDetail.setReturnReason(orderDetail.getReturnReason());
orderStandardDetail.setReturnReasonDetail(orderDetail.getReturnReasonDetail());
orderStandardDetail.setReturnImages(orderDetail.getReturnImages());
orderStandardDetails.add(orderStandardDetail); orderStandardDetails.add(orderStandardDetail);
} }
@ -2002,43 +2006,51 @@ public class OrderMasterController extends BaseController {
@PostMapping("/console/cancel") @PostMapping("/console/cancel")
@ResponseBody @ResponseBody
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult consoleCancel(Long id) { public AjaxResult consoleCancel(@RequestBody OrderMaster orderMaster) {
if(id == null){ if(orderMaster.getId() == null){
return AjaxResult.error("订单编码id不能为空!"); return AjaxResult.error("订单编码id不能为空!");
} }
// 判断该主单状态 // 判断该主单状态
OrderMaster orderMaster = orderMasterService.selectById(id); OrderMaster orderMasterInfo = orderMasterService.selectById(orderMaster.getId());
if(!orderMaster.getOrderStatus().equals(OrderStatus.PLAIN.code()) && !orderMaster.getOrderStatus().equals(OrderStatus.RECEIVE.code())){ if(!orderMasterInfo.getOrderStatus().equals(OrderStatus.PLAIN.code()) && !orderMasterInfo.getOrderStatus().equals(OrderStatus.RECEIVE.code())){
return AjaxResult.error("该订单处于无法退单状态!"); return AjaxResult.error("该订单处于无法退单状态!");
} }
// 含有子单 // 含有子单
List<OrderDetail> orderDetails = orderDetailService.selectByOrderMasterId(id); List<OrderDetail> orderDetails = orderDetailService.selectByOrderMasterId(orderMaster.getId());
if(CollectionUtils.isNotEmpty(orderDetails)){ if(CollectionUtils.isNotEmpty(orderDetails)){
return AjaxResult.error("该订单已经派发过子单,无法退单状态!"); return AjaxResult.error("该订单已经派发过子单,无法退单状态!");
} }
try { try {
// 判断是否为服务订单且需要退还服务金额 // 判断是否为服务订单且需要退还服务金额
if (isServiceOrder(orderMaster) && if (isServiceOrder(orderMasterInfo) &&
orderMaster.getGoodsOrderMasterId() != null && orderMasterInfo.getGoodsOrderMasterId() != null &&
orderMaster.getServerGoodsMoney() != null && orderMasterInfo.getServerGoodsMoney() != null &&
orderMaster.getServerGoodsMoney().compareTo(BigDecimal.ZERO) > 0) { orderMasterInfo.getServerGoodsMoney().compareTo(BigDecimal.ZERO) > 0) {
logger.info("检测到服务订单退单,开始退还服务金额:订单[{}],金额[{}],目标商品订单[{}]", logger.info("检测到服务订单退单,开始退还服务金额:订单[{}],金额[{}],目标商品订单[{}]",
orderMaster.getId(), orderMaster.getServerGoodsMoney(), orderMaster.getGoodsOrderMasterId()); orderMasterInfo.getId(), orderMasterInfo.getServerGoodsMoney(), orderMasterInfo.getGoodsOrderMasterId());
// 退还服务金额到商品订单 // 退还服务金额到商品订单
refundServerMoneyToGoodsOrder(orderMaster.getGoodsOrderMasterId(), orderMaster.getServerGoodsMoney()); refundServerMoneyToGoodsOrder(orderMasterInfo.getGoodsOrderMasterId(), orderMasterInfo.getServerGoodsMoney());
// 重置配件主单的服务订单派发状态 // 重置配件主单的服务订单派发状态
OrderMaster goodsOrderUpdate = new OrderMaster(); OrderMaster goodsOrderUpdate = new OrderMaster();
goodsOrderUpdate.setId(orderMaster.getGoodsOrderMasterId()); goodsOrderUpdate.setId(orderMasterInfo.getGoodsOrderMasterId());
goodsOrderUpdate.setHasServiceOrder(0); // 重置为未派发状态 goodsOrderUpdate.setHasServiceOrder(0); // 重置为未派发状态
orderMasterService.updateOrderMaster(goodsOrderUpdate); orderMasterService.updateOrderMaster(goodsOrderUpdate);
} }
// 保存退单信息
OrderMaster returnOrderUpdate = new OrderMaster();
returnOrderUpdate.setId(orderMaster.getId());
returnOrderUpdate.setReturnReason(orderMaster.getReturnReason());
returnOrderUpdate.setReturnReasonDetail(orderMaster.getReturnReasonDetail());
returnOrderUpdate.setReturnImages(orderMaster.getReturnImages());
orderMasterService.updateOrderMaster(returnOrderUpdate);
// 清空id // 清空id
orderMasterService.removeWorker(orderMaster.getId()); orderMasterService.removeWorker(orderMaster.getId());
// 更新状态待接单 // 更新状态待接单
@ -2047,7 +2059,7 @@ public class OrderMasterController extends BaseController {
return AjaxResult.success("退单成功"); return AjaxResult.success("退单成功");
} catch (Exception e) { } catch (Exception e) {
logger.error("退单失败订单ID={}, 错误信息={}", id, e.getMessage(), e); logger.error("退单失败订单ID={}, 错误信息={}", orderMaster.getId(), e.getMessage(), e);
return AjaxResult.error("退单失败:" + e.getMessage()); return AjaxResult.error("退单失败:" + e.getMessage());
} }
} }
@ -2145,6 +2157,9 @@ public class OrderMasterController extends BaseController {
detailRes.setOrderDetailCode(detail.getCode()); detailRes.setOrderDetailCode(detail.getCode());
detailRes.setWorkerName(workerName); detailRes.setWorkerName(workerName);
detailRes.setRemark(workerName + "(" + detail.getCode() + ")"); detailRes.setRemark(workerName + "(" + detail.getCode() + ")");
detailRes.setReturnReason(detail.getReturnReason());
detailRes.setReturnReasonDetail(detail.getReturnReasonDetail());
detailRes.setReturnImages(detail.getReturnImages());
orderStandardDetails.add(detailRes); orderStandardDetails.add(detailRes);
} }

View File

@ -84,4 +84,19 @@ public class OrderStandardDetail {
private BigDecimal addMoney; private BigDecimal addMoney;
/**
* 退单原因
*/
private String returnReason;
/**
* 退单原因详情
*/
private String returnReasonDetail;
/**
* 退单图片
*/
private String returnImages;
} }

View File

@ -30,6 +30,9 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
public Customer selectByCustomerId(Long customerId) { public Customer selectByCustomerId(Long customerId) {
if (customerId == null) {
return null;
}
return customerMapper.selectByCustomerId(customerId); return customerMapper.selectByCustomerId(customerId);
} }

View File

@ -95,6 +95,12 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
@Override @Override
public List<DeptGoodsCategory> appList(DeptGoodsCategory deptGoodsCategory) { public List<DeptGoodsCategory> appList(DeptGoodsCategory deptGoodsCategory) {
Customer customer= customerService.selectByCustomerId(deptGoodsCategory.getCustomerId()); Customer customer= customerService.selectByCustomerId(deptGoodsCategory.getCustomerId());
List<DeptGoodsCategory> goodsCategoryList = new ArrayList<>();
if (customer == null) {
log.warn("未找到客户customerId: {}", deptGoodsCategory.getCustomerId());
// 返回全部类目或默认类目
goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory);
} else {
Long customerId = customer.getCustomerPlace(); Long customerId = customer.getCustomerPlace();
if (customer.getPlaceStatus() == 2) { if (customer.getPlaceStatus() == 2) {
customerId = customer.getCustomerId(); customerId = customer.getCustomerId();
@ -102,9 +108,7 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
CustomerSelection customerSelection = new CustomerSelection(); CustomerSelection customerSelection = new CustomerSelection();
customerSelection.setCustomerId(customerId); customerSelection.setCustomerId(customerId);
List<CustomerSelection> customerSelections = customerSelectionService.selectCustomerSelectionList(customerSelection); List<CustomerSelection> customerSelections = customerSelectionService.selectCustomerSelectionList(customerSelection);
List<DeptGoodsCategory> goodsCategoryList =new ArrayList<>();
log.info("用户id{}获取到的类目列表{}", customerId, customerSelections); log.info("用户id{}获取到的类目列表{}", customerId, customerSelections);
// 第一层
if (deptGoodsCategory.getIsSetting() == 1) { if (deptGoodsCategory.getIsSetting() == 1) {
goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory); goodsCategoryList = deptGoodsCategoryMapper.appList(deptGoodsCategory);
} else { } else {
@ -115,6 +119,7 @@ public class DeptGoodsCategoryServiceImpl implements DeptGoodsCategoryService {
} }
} }
} }
}
log.info("筛选完的类目列表{}",goodsCategoryList); log.info("筛选完的类目列表{}",goodsCategoryList);
// 第二层 // 第二层
this.fillChild(goodsCategoryList); this.fillChild(goodsCategoryList);

View File

@ -230,4 +230,19 @@ public class OrderDetail extends BaseEntity {
*/ */
private Integer delayCount; private Integer delayCount;
/**
* 退单原因
*/
private String returnReason;
/**
* 退单原因详情
*/
private String returnReasonDetail;
/**
* 退单图片
*/
private String returnImages;
} }

View File

@ -303,4 +303,19 @@ public class OrderMaster extends BaseEntity {
*/ */
@Excel(name = "原师傅id", cellType = Excel.ColumnType.NUMERIC) @Excel(name = "原师傅id", cellType = Excel.ColumnType.NUMERIC)
private Long originalWorkerId; private Long originalWorkerId;
/**
* 退单原因
*/
private String returnReason;
/**
* 退单原因详情
*/
private String returnReasonDetail;
/**
* 退单图片
*/
private String returnImages;
} }

View File

@ -37,6 +37,9 @@
<result property="afterTimeout" column="after_timeout"/> <result property="afterTimeout" column="after_timeout"/>
<result property="timeoutFineTimes" column="timeout_fine_times"/> <result property="timeoutFineTimes" column="timeout_fine_times"/>
<result property="delayCount" column="delay_count"/> <result property="delayCount" column="delay_count"/>
<result property="returnReason" column="return_reason"/>
<result property="returnReasonDetail" column="return_reason_detail"/>
<result property="returnImages" column="return_images"/>
</resultMap> </resultMap>
<sql id="selectOrderDetail"> <sql id="selectOrderDetail">
@ -70,7 +73,10 @@
timeout_, timeout_,
timeout_fine_times, timeout_fine_times,
after_timeout, after_timeout,
delay_count delay_count,
return_reason,
return_reason_detail,
return_images
FROM order_detail FROM order_detail
</sql> </sql>
@ -106,7 +112,10 @@
od.timeout_, od.timeout_,
od.timeout_fine_times, od.timeout_fine_times,
od.after_timeout, od.after_timeout,
od.delay_count od.delay_count,
od.return_reason,
od.return_reason_detail,
od.return_images
FROM order_detail od FROM order_detail od
LEFT JOIN order_master om ON om.id = od.order_master_id LEFT JOIN order_master om ON om.id = od.order_master_id
LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id
@ -373,6 +382,9 @@
<if test="ledgerAccountStatus != null">ledger_account_status = #{ledgerAccountStatus},</if> <if test="ledgerAccountStatus != null">ledger_account_status = #{ledgerAccountStatus},</if>
<if test="timeout != null">timeout_ = #{timeout},</if> <if test="timeout != null">timeout_ = #{timeout},</if>
<if test="delayCount != null">delay_count = #{delayCount},</if> <if test="delayCount != null">delay_count = #{delayCount},</if>
<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>
update_time = SYSDATE() update_time = SYSDATE()
</set> </set>
WHERE id = #{id} WHERE id = #{id}
@ -432,6 +444,9 @@
<if test="handoverRemark != null">handover_remark,</if> <if test="handoverRemark != null">handover_remark,</if>
<if test="confirmStartTime != null">confirm_start_time,</if> <if test="confirmStartTime != null">confirm_start_time,</if>
<if test="delayCount != null">delay_count,</if> <if test="delayCount != null">delay_count,</if>
<if test="returnReason != null">return_reason,</if>
<if test="returnReasonDetail != null">return_reason_detail,</if>
<if test="returnImages != null">return_images,</if>
<if test="expectTimeStart != null">expect_time_start,</if> <if test="expectTimeStart != null">expect_time_start,</if>
<if test="expectTimeEnd != null">expect_time_end,</if> <if test="expectTimeEnd != null">expect_time_end,</if>
<if test="workBeginTime != null">work_begin_time,</if> <if test="workBeginTime != null">work_begin_time,</if>
@ -452,6 +467,9 @@
<if test="handoverRemark != null">#{handoverRemark},</if> <if test="handoverRemark != null">#{handoverRemark},</if>
<if test="confirmStartTime != null">#{confirmStartTime},</if> <if test="confirmStartTime != null">#{confirmStartTime},</if>
<if test="delayCount != null">#{delayCount},</if> <if test="delayCount != null">#{delayCount},</if>
<if test="returnReason != null">#{returnReason},</if>
<if test="returnReasonDetail != null">#{returnReasonDetail},</if>
<if test="returnImages != null">#{returnImages},</if>
<if test="expectTimeStart != null">#{expectTimeStart},</if> <if test="expectTimeStart != null">#{expectTimeStart},</if>
<if test="expectTimeEnd != null">#{expectTimeEnd},</if> <if test="expectTimeEnd != null">#{expectTimeEnd},</if>
<if test="workBeginTime != null">#{workBeginTime},</if> <if test="workBeginTime != null">#{workBeginTime},</if>

View File

@ -65,6 +65,9 @@
<result property="isInvoiced" column="is_invoiced"/> <result property="isInvoiced" column="is_invoiced"/>
<result property="isNeedBill" column="is_need_bill"/> <result property="isNeedBill" column="is_need_bill"/>
<result property="originalWorkerId" column="original_worker_id"/> <result property="originalWorkerId" column="original_worker_id"/>
<result property="returnReason" column="return_reason"/>
<result property="returnReasonDetail" column="return_reason_detail"/>
<result property="returnImages" column="return_images"/>
</resultMap> </resultMap>
@ -127,7 +130,10 @@
delivery_images, delivery_images,
is_invoiced, is_invoiced,
is_need_bill, is_need_bill,
original_worker_id original_worker_id,
return_reason,
return_reason_detail,
return_images
FROM order_master FROM order_master
</sql> </sql>
@ -190,7 +196,10 @@
om.delivery_images, om.delivery_images,
om.is_invoiced, om.is_invoiced,
om.is_need_bill, om.is_need_bill,
om.original_worker_id om.original_worker_id,
om.return_reason,
om.return_reason_detail,
om.return_images
FROM order_master om FROM order_master om
LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id LEFT JOIN customer_address ca ON ca.customer_address_id = om.address_id
LEFT JOIN goods g ON g.goods_id = om.goods_id LEFT JOIN goods g ON g.goods_id = om.goods_id
@ -496,6 +505,9 @@
<if test="isInvoiced != null">is_invoiced = #{isInvoiced},</if> <if test="isInvoiced != null">is_invoiced = #{isInvoiced},</if>
<if test="isNeedBill != null">is_need_bill = #{isNeedBill},</if> <if test="isNeedBill != null">is_need_bill = #{isNeedBill},</if>
<if test="originalWorkerId != null">original_worker_id = #{originalWorkerId},</if> <if test="originalWorkerId != null">original_worker_id = #{originalWorkerId},</if>
<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>
update_time = SYSDATE() update_time = SYSDATE()
</set> </set>
WHERE id = #{id} WHERE id = #{id}
@ -564,6 +576,9 @@
<if test="isInvoiced != null">is_invoiced,</if> <if test="isInvoiced != null">is_invoiced,</if>
<if test="isNeedBill != null">is_need_bill,</if> <if test="isNeedBill != null">is_need_bill,</if>
<if test="originalWorkerId != null">original_worker_id,</if> <if test="originalWorkerId != null">original_worker_id,</if>
<if test="returnReason != null">return_reason,</if>
<if test="returnReasonDetail != null">return_reason_detail,</if>
<if test="returnImages != null">return_images,</if>
create_time create_time
)VALUES( )VALUES(
<if test="deptId != null and deptId != 0">#{deptId},</if> <if test="deptId != null and deptId != 0">#{deptId},</if>
@ -613,6 +628,9 @@
<if test="isInvoiced != null">#{isInvoiced},</if> <if test="isInvoiced != null">#{isInvoiced},</if>
<if test="isNeedBill != null">#{isNeedBill},</if> <if test="isNeedBill != null">#{isNeedBill},</if>
<if test="originalWorkerId != null">#{originalWorkerId},</if> <if test="originalWorkerId != null">#{originalWorkerId},</if>
<if test="returnReason != null">#{returnReason},</if>
<if test="returnReasonDetail != null">#{returnReasonDetail},</if>
<if test="returnImages != null">#{returnImages},</if>
SYSDATE() SYSDATE()
) )
</insert> </insert>

View File

@ -83,4 +83,19 @@ public class OrderStandardDetail {
private Integer afterTimeout; private Integer afterTimeout;
/**
* 退单原因
*/
private String returnReason;
/**
* 退单原因详情
*/
private String returnReasonDetail;
/**
* 退单图片
*/
private String returnImages;
} }