关于绑定的问题
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-06-22 12:08:41 +09:00
parent 5f960daf78
commit ba435dd6a6
13 changed files with 1306 additions and 210 deletions

View File

@@ -78,6 +78,14 @@ func (s *PersonalCustomerDeviceStore) UpdateStatus(ctx context.Context, id uint,
Update("status", status).Error
}
// UpdateVirtualNo 更新指定记录的虚拟号(换货迁移专用)
func (s *PersonalCustomerDeviceStore) UpdateVirtualNo(ctx context.Context, id uint, newVirtualNo string) error {
return s.db.WithContext(ctx).
Model(&model.PersonalCustomerDevice{}).
Where("id = ?", id).
Update("virtual_no", newVirtualNo).Error
}
// Delete 软删除绑定记录
func (s *PersonalCustomerDeviceStore) Delete(ctx context.Context, id uint) error {
return s.db.WithContext(ctx).Delete(&model.PersonalCustomerDevice{}, id).Error
@@ -95,6 +103,18 @@ func (s *PersonalCustomerDeviceStore) ExistsByCustomerAndDevice(ctx context.Cont
return count > 0, nil
}
// CountByVirtualNo 统计指定虚拟号的绑定记录数量(不过滤 status
func (s *PersonalCustomerDeviceStore) CountByVirtualNo(ctx context.Context, virtualNo string) (int64, error) {
var count int64
if err := s.db.WithContext(ctx).
Model(&model.PersonalCustomerDevice{}).
Where("virtual_no = ?", virtualNo).
Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}
// CreateOrUpdateLastUsed 创建或更新绑定记录的最后使用时间
// 如果绑定记录存在,更新最后使用时间;如果不存在,创建新记录
func (s *PersonalCustomerDeviceStore) CreateOrUpdateLastUsed(ctx context.Context, customerID uint, deviceNo string) error {

View File

@@ -116,6 +116,25 @@ func (s *PersonalCustomerICCIDStore) ExistsByCustomerAndICCID(ctx context.Contex
return count > 0, nil
}
// CountByICCID 统计指定 ICCID 的绑定记录数量(不过滤 status
func (s *PersonalCustomerICCIDStore) CountByICCID(ctx context.Context, iccid string) (int64, error) {
var column string
switch len(iccid) {
case 19:
column = "iccid_19"
default:
column = "iccid"
}
var count int64
if err := s.db.WithContext(ctx).
Model(&model.PersonalCustomerICCID{}).
Where(column+" = ?", iccid).
Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}
// CreateOrUpdateLastUsed 创建或更新绑定记录的最后使用时间
// 如果绑定记录存在,更新最后使用时间;如果不存在,创建新记录
func (s *PersonalCustomerICCIDStore) CreateOrUpdateLastUsed(ctx context.Context, customerID uint, iccid string) error {