feat(pickup): 增加第三方单号补录功能并优化列表提号备注展示
- 后端支持补录/修改第三方单号接口 PUT /api/v1/admin/pickups/:id/third-party-order-no,记录流转事件与审计日志 - 前端线下提号主列表在第三方单号列后展示提号备注列 - 前端列表操作列及提号详情页增加补录/修改第三方单号操作入口与弹窗 - 通过 scripts/check.sh 全量门禁校验
This commit is contained in:
@@ -465,6 +465,61 @@ func (r *Repository) UpdateProfit(ctx context.Context, pickupID uint64, req Upda
|
||||
return r.FindByID(ctx, pickupID)
|
||||
}
|
||||
|
||||
// UpdateThirdPartyOrderNo 补录或修改提号单第三方单号。
|
||||
func (r *Repository) UpdateThirdPartyOrderNo(ctx context.Context, pickupID uint64, req UpdateThirdPartyOrderNoRequest, adminID uint64, meta auditlog.Meta) (*PickupDTO, error) {
|
||||
if r == nil || r.db == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
newThirdPartyOrderNo := strings.TrimSpace(req.ThirdPartyOrderNo)
|
||||
if newThirdPartyOrderNo == "" || len([]rune(newThirdPartyOrderNo)) > 128 {
|
||||
return nil, ErrInvalidThirdPartyOrderNo
|
||||
}
|
||||
err := r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
var pickup model.AdminPickup
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).First(&pickup, pickupID).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return ErrPickupNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
if pickup.Status == StatusCancelled {
|
||||
return ErrPickupCancelled
|
||||
}
|
||||
before := pickupState(pickup)
|
||||
|
||||
oldThirdPartyOrderNo := pickup.ThirdPartyOrderNo
|
||||
pickup.ThirdPartyOrderNo = newThirdPartyOrderNo
|
||||
if err := tx.Model(&pickup).Update("third_party_order_no", pickup.ThirdPartyOrderNo).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := appendPickupEvent(tx, pickup, "pickup_third_party_order_no_updated", adminID, "补录/修改第三方单号。", "", map[string]any{
|
||||
"old_third_party_order_no": oldThirdPartyOrderNo,
|
||||
"third_party_order_no": pickup.ThirdPartyOrderNo,
|
||||
}, before); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bid := pickup.ID
|
||||
return auditlog.Append(tx, auditlog.Entry{
|
||||
ActorType: "admin",
|
||||
ActorID: adminID,
|
||||
Action: "pickup_third_party_order_no_update",
|
||||
BizType: "admin_pickup",
|
||||
BizID: &bid,
|
||||
Meta: meta,
|
||||
Detail: map[string]any{
|
||||
"pickup_no": pickup.PickupNo,
|
||||
"old_third_party_order_no": oldThirdPartyOrderNo,
|
||||
"new_third_party_order_no": pickup.ThirdPartyOrderNo,
|
||||
},
|
||||
})
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.FindByID(ctx, pickupID)
|
||||
}
|
||||
|
||||
// CreateFinancialAdjustment 为已完成提号追加财务差额,不改写完成时的原始金额。
|
||||
func (r *Repository) CreateFinancialAdjustment(ctx context.Context, pickupID uint64, req FinancialAdjustmentRequest, adminID uint64, meta auditlog.Meta) (*PickupDTO, error) {
|
||||
if r == nil || r.db == nil {
|
||||
|
||||
Reference in New Issue
Block a user