新增状态筛选条件,同时修复价格未正常写入的情况
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m35s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m35s
This commit is contained in:
@@ -212,8 +212,8 @@ func (s *PackageUsageStore) GetActiveOrDepletedByCarrier(ctx context.Context, ca
|
||||
return &pkg, nil
|
||||
}
|
||||
|
||||
// ListByCarrier 查询载体的所有套餐使用记录(包括所有状态)
|
||||
func (s *PackageUsageStore) ListByCarrier(ctx context.Context, carrierType string, carrierID uint) ([]*model.PackageUsage, error) {
|
||||
// ListByCarrier 查询载体的套餐使用记录(可按状态筛选)
|
||||
func (s *PackageUsageStore) ListByCarrier(ctx context.Context, carrierType string, carrierID uint, status *int) ([]*model.PackageUsage, error) {
|
||||
var usages []*model.PackageUsage
|
||||
query := s.db.WithContext(ctx).Order("priority ASC, created_at DESC")
|
||||
|
||||
@@ -222,6 +222,9 @@ func (s *PackageUsageStore) ListByCarrier(ctx context.Context, carrierType strin
|
||||
} else if carrierType == "device" {
|
||||
query = query.Where("device_id = ?", carrierID)
|
||||
}
|
||||
if status != nil {
|
||||
query = query.Where("status = ?", *status)
|
||||
}
|
||||
|
||||
if err := query.Find(&usages).Error; err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user