修复绑定的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s

This commit is contained in:
2026-05-07 18:18:11 +08:00
parent e77bb0d09b
commit 348cb4e670
2 changed files with 3 additions and 2 deletions

View File

@@ -309,10 +309,12 @@ func (s *Service) BindPhone(ctx context.Context, customerID uint, req *dto.BindP
return nil, errors.Wrap(errors.CodeInternalError, err, "查询手机号绑定关系失败") return nil, errors.Wrap(errors.CodeInternalError, err, "查询手机号绑定关系失败")
} }
now := time.Now()
record := &model.PersonalCustomerPhone{ record := &model.PersonalCustomerPhone{
CustomerID: customerID, CustomerID: customerID,
Phone: req.Phone, Phone: req.Phone,
IsPrimary: true, IsPrimary: true,
VerifiedAt: &now,
Status: 1, Status: 1,
} }
if err := s.phoneStore.Create(ctx, record); err != nil { if err := s.phoneStore.Create(ctx, record); err != nil {
@@ -321,7 +323,7 @@ func (s *Service) BindPhone(ctx context.Context, customerID uint, req *dto.BindP
return &dto.BindPhoneResponse{ return &dto.BindPhoneResponse{
Phone: req.Phone, Phone: req.Phone,
BoundAt: record.VerifiedAt.Format("2006-01-02 15:04:05"), BoundAt: now.Format("2006-01-02 15:04:05"),
}, nil }, nil
} }

View File

@@ -21,7 +21,6 @@ func NewPersonalCustomerPhoneStore(db *gorm.DB) *PersonalCustomerPhoneStore {
// Create 创建手机号绑定记录 // Create 创建手机号绑定记录
func (s *PersonalCustomerPhoneStore) Create(ctx context.Context, phone *model.PersonalCustomerPhone) error { func (s *PersonalCustomerPhoneStore) Create(ctx context.Context, phone *model.PersonalCustomerPhone) error {
// VerifiedAt 在验证通过后更新,创建时保持 nil
return s.db.WithContext(ctx).Create(phone).Error return s.db.WithContext(ctx).Create(phone).Error
} }