|
|
@@ -46,6 +46,7 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
private static final String O_PENDING = StateGuard.O_PENDING;
|
|
|
private static final String O_ACCEPTED = StateGuard.O_ACCEPTED;
|
|
|
private static final String O_CANCELLED = StateGuard.O_CANCELLED;
|
|
|
+ private static final String D_CREATED = "created";
|
|
|
private static final String D_ASSIGNED = "assigned";
|
|
|
private static final String D_ACCEPTED = "accepted";
|
|
|
private static final String D_REASSIGNED = "reassigned";
|
|
|
@@ -110,11 +111,15 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
o.setUpdatedAt(new Date());
|
|
|
// workerId 入参废弃/忽略(终裁)
|
|
|
trainServiceOrderMapper.insert(o);
|
|
|
- log.info("组织建单: orderId={}, orgId={}, operatorId={}", o.getId(), orgId, operatorId);
|
|
|
+ // 建单留痕(同事务):worker_id=NULL 的 created 行实现「谁建的这张单、何时建」全链路可追溯;
|
|
|
+ // uk(order_id, worker_id) 中 NULL 不参与相等性判定,与后续 assign 行不冲突
|
|
|
+ Long dispatchId = insertDispatch(o.getId(), null, SRC_ORG, operatorId, D_CREATED, 0, str(body.get("remark")));
|
|
|
+ log.info("组织建单+留痕: orderId={}, orgId={}, operatorId={}, dispatchId={}", o.getId(), orgId, operatorId, dispatchId);
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
data.put("orderId", o.getId());
|
|
|
data.put("orderNo", o.getOrderNo());
|
|
|
data.put("status", o.getStatus());
|
|
|
+ data.put("dispatchId", dispatchId);
|
|
|
return Result.success(data);
|
|
|
}
|
|
|
|
|
|
@@ -348,7 +353,7 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
|
|
|
// ==================== 内部 ====================
|
|
|
|
|
|
- private void insertDispatch(Long orderId, Long workerId, String source, Long operatorId,
|
|
|
+ private Long insertDispatch(Long orderId, Long workerId, String source, Long operatorId,
|
|
|
String status, Integer fee, String remark) {
|
|
|
TrainOrderDispatch d = new TrainOrderDispatch();
|
|
|
d.setOrderId(orderId);
|
|
|
@@ -362,6 +367,7 @@ public class DispatchServiceImpl implements DispatchService {
|
|
|
d.setCreatedAt(new Date());
|
|
|
d.setUpdatedAt(new Date());
|
|
|
trainOrderDispatchMapper.insert(d);
|
|
|
+ return d.getId();
|
|
|
}
|
|
|
|
|
|
private void cancelDispatch(Long orderId, Long workerId, Long operatorId, String reason) {
|