add f
This commit is contained in:
@@ -2,6 +2,8 @@ package certification
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"tyapi-server/internal/domains/certification/entities"
|
||||
"tyapi-server/internal/domains/certification/repositories"
|
||||
"tyapi-server/internal/shared/database"
|
||||
@@ -90,6 +92,33 @@ func (r *GormEnterpriseInfoSubmitRecordRepository) ExistsByUnifiedSocialCodeExcl
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
// MarkRejectedAndFailedForUser 仅当 id 与 user_id 均匹配且 status=verified 时更新,避免误释放其他用户的 USCC 占用
|
||||
func (r *GormEnterpriseInfoSubmitRecordRepository) MarkRejectedAndFailedForUser(
|
||||
ctx context.Context,
|
||||
recordID, userID, reviewerID, remark string,
|
||||
) (bool, error) {
|
||||
if recordID == "" || userID == "" {
|
||||
return false, nil
|
||||
}
|
||||
now := time.Now()
|
||||
result := r.GetDB(ctx).Model(&entities.EnterpriseInfoSubmitRecord{}).
|
||||
Where("id = ? AND user_id = ? AND status = ?", recordID, userID, "verified").
|
||||
Updates(map[string]interface{}{
|
||||
"status": "failed",
|
||||
"failed_at": now,
|
||||
"failure_reason": remark,
|
||||
"manual_review_status": "rejected",
|
||||
"manual_reviewed_at": now,
|
||||
"manual_reviewer_id": reviewerID,
|
||||
"manual_review_remark": remark,
|
||||
"updated_at": now,
|
||||
})
|
||||
if result.Error != nil {
|
||||
return false, result.Error
|
||||
}
|
||||
return result.RowsAffected > 0, nil
|
||||
}
|
||||
|
||||
func (r *GormEnterpriseInfoSubmitRecordRepository) List(ctx context.Context, filter repositories.ListSubmitRecordsFilter) (*repositories.ListSubmitRecordsResult, error) {
|
||||
base := r.GetDB(ctx).Model(&entities.EnterpriseInfoSubmitRecord{})
|
||||
if filter.CertificationStatus != "" {
|
||||
|
||||
Reference in New Issue
Block a user