驳回接口
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s

This commit is contained in:
2026-06-25 17:10:24 +09:00
parent c5871b59a1
commit 8cf921f11c
13 changed files with 455 additions and 20 deletions

View File

@@ -94,6 +94,25 @@ func (s *RechargeOrderStore) Update(ctx context.Context, order *model.RechargeOr
return s.db.WithContext(ctx).Save(order).Error
}
// UpdateStatusWithRejection 条件更新订单状态为已驳回并写入驳回原因
// 仅当 status = 0待支付时更新RowsAffected=0 说明订单不存在或状态已变更
func (s *RechargeOrderStore) UpdateStatusWithRejection(ctx context.Context, id uint, rejectionReason string) error {
result := s.db.WithContext(ctx).
Model(&model.RechargeOrder{}).
Where("id = ? AND status = ?", id, model.RechargeOrderStatusPending).
Updates(map[string]interface{}{
"status": model.RechargeOrderStatusRejected,
"rejection_reason": rejectionReason,
})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gorm.ErrRecordNotFound
}
return nil
}
func (s *RechargeOrderStore) ListByCard(ctx context.Context, iotCardID uint, generation int, offset, limit int) ([]*model.RechargeOrder, error) {
var orders []*model.RechargeOrder
query := s.db.WithContext(ctx).