no message
This commit is contained in:
parent
61e9859181
commit
ad6473f446
|
|
@ -239,6 +239,99 @@ public class OrderMasterController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单转单功能
|
||||||
|
*
|
||||||
|
* @param orderMaster 订单对象,包含id、workerId(新师傅)、originalWorkerId等字段
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/transferOrder")
|
||||||
|
@ResponseBody
|
||||||
|
@Log(title = "订单转单管理", businessType = BusinessType.UPDATE)
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult transferOrder(@RequestBody OrderMaster orderMaster)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// 参数校验
|
||||||
|
if (orderMaster.getId() == null) {
|
||||||
|
return AjaxResult.error("订单ID不能为空");
|
||||||
|
}
|
||||||
|
if (orderMaster.getWorkerId() == null) {
|
||||||
|
return AjaxResult.error("新师傅ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询原订单信息
|
||||||
|
OrderMaster originalOrder = orderMasterService.selectById(orderMaster.getId());
|
||||||
|
if (originalOrder == null) {
|
||||||
|
return AjaxResult.error("订单不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查订单状态是否允许转单
|
||||||
|
if (originalOrder.getOrderStatus() == null || originalOrder.getOrderStatus() > OrderStatus.SERVING.code()) {
|
||||||
|
return AjaxResult.error("订单状态不允许转单,只有待接单、已接单、待上门、进行中状态的订单可以转单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查新师傅是否存在
|
||||||
|
Worker newWorker = workerService.selectById(orderMaster.getWorkerId());
|
||||||
|
if (newWorker == null) {
|
||||||
|
return AjaxResult.error("新师傅不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果原师傅和新师傅相同,则不允许转单
|
||||||
|
if (originalOrder.getWorkerId() != null && originalOrder.getWorkerId().equals(orderMaster.getWorkerId())) {
|
||||||
|
return AjaxResult.error("新师傅不能与原师傅相同");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行转单操作
|
||||||
|
OrderMaster updateOrder = new OrderMaster();
|
||||||
|
updateOrder.setId(orderMaster.getId());
|
||||||
|
|
||||||
|
// 保存原师傅ID到originalWorkerId字段
|
||||||
|
if (originalOrder.getWorkerId() != null) {
|
||||||
|
updateOrder.setOriginalWorkerId(originalOrder.getWorkerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置新师傅ID
|
||||||
|
updateOrder.setWorkerId(orderMaster.getWorkerId());
|
||||||
|
updateOrder.setUpdateBy(getLoginName());
|
||||||
|
|
||||||
|
// 如果有转单备注,添加到原有备注中
|
||||||
|
String newRemark = originalOrder.getRemark() != null ? originalOrder.getRemark() : "";
|
||||||
|
if (StringUtils.isNotEmpty(orderMaster.getRemark())) {
|
||||||
|
newRemark += "【转单记录:" + getLoginName() +
|
||||||
|
"于" + DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()) +
|
||||||
|
"转单给师傅ID:" + orderMaster.getWorkerId() +
|
||||||
|
",备注:" + orderMaster.getRemark() + "】";
|
||||||
|
} else {
|
||||||
|
newRemark += "【转单记录:" + getLoginName() +
|
||||||
|
"于" + DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date()) +
|
||||||
|
"转单给师傅ID:" + orderMaster.getWorkerId() + "】";
|
||||||
|
}
|
||||||
|
updateOrder.setRemark(newRemark);
|
||||||
|
|
||||||
|
int result = orderMasterService.updateOrderMaster(updateOrder);
|
||||||
|
|
||||||
|
if (result > 0) {
|
||||||
|
// 记录转单日志
|
||||||
|
logger.info("订单转单成功:订单ID={}, 原师傅ID={}, 新师傅ID={}, 操作人={}",
|
||||||
|
orderMaster.getId(),
|
||||||
|
originalOrder.getWorkerId(),
|
||||||
|
orderMaster.getWorkerId(),
|
||||||
|
getLoginName());
|
||||||
|
|
||||||
|
String message = String.format("转单成功!订单已从师傅[%s]转给师傅[%s]",
|
||||||
|
originalOrder.getWorkerId() != null ? originalOrder.getWorkerId() : "无",
|
||||||
|
newWorker.getName());
|
||||||
|
return AjaxResult.success(message);
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("转单失败,请重试");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("订单转单失败:{}", e.getMessage(), e);
|
||||||
|
return AjaxResult.error("转单失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改详细订单
|
* 修改详细订单
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -274,4 +274,10 @@ public class OrderMaster extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
@Excel(name = "是否需要开票", cellType = Excel.ColumnType.NUMERIC, readConverterExp = "0=不需要,1=需要")
|
@Excel(name = "是否需要开票", cellType = Excel.ColumnType.NUMERIC, readConverterExp = "0=不需要,1=需要")
|
||||||
private Integer isNeedBill;
|
private Integer isNeedBill;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原师傅id(转单前的师傅)
|
||||||
|
*/
|
||||||
|
@Excel(name = "原师傅id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long originalWorkerId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
<result property="isDeliveryToStore" column="is_delivery_to_store"/>
|
<result property="isDeliveryToStore" column="is_delivery_to_store"/>
|
||||||
<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"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
@ -117,7 +118,8 @@
|
||||||
order_images,
|
order_images,
|
||||||
is_delivery_to_store,
|
is_delivery_to_store,
|
||||||
is_invoiced,
|
is_invoiced,
|
||||||
is_need_bill
|
is_need_bill,
|
||||||
|
original_worker_id
|
||||||
|
|
||||||
FROM order_master
|
FROM order_master
|
||||||
</sql>
|
</sql>
|
||||||
|
|
@ -175,7 +177,8 @@
|
||||||
om.order_images,
|
om.order_images,
|
||||||
om.is_delivery_to_store,
|
om.is_delivery_to_store,
|
||||||
om.is_invoiced,
|
om.is_invoiced,
|
||||||
om.is_need_bill
|
om.is_need_bill,
|
||||||
|
om.original_worker_id
|
||||||
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
|
||||||
|
|
@ -476,6 +479,7 @@
|
||||||
<if test="isDeliveryToStore != null">is_delivery_to_store = #{isDeliveryToStore},</if>
|
<if test="isDeliveryToStore != null">is_delivery_to_store = #{isDeliveryToStore},</if>
|
||||||
<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>
|
||||||
update_time = SYSDATE()
|
update_time = SYSDATE()
|
||||||
</set>
|
</set>
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
|
|
@ -539,6 +543,7 @@
|
||||||
<if test="isDeliveryToStore != null">is_delivery_to_store,</if>
|
<if test="isDeliveryToStore != null">is_delivery_to_store,</if>
|
||||||
<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>
|
||||||
create_time
|
create_time
|
||||||
)VALUES(
|
)VALUES(
|
||||||
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
||||||
|
|
@ -583,6 +588,7 @@
|
||||||
<if test="isDeliveryToStore != null">#{isDeliveryToStore},</if>
|
<if test="isDeliveryToStore != null">#{isDeliveryToStore},</if>
|
||||||
<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>
|
||||||
SYSDATE()
|
SYSDATE()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue