2026-10-12 16:22:04 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using AdminDomain.BeautifulNumber;
|
|
|
|
|
using AdminDomain.Entity;
|
|
|
|
|
using AdminService.BeautifulNumber;
|
|
|
|
|
using Common;
|
|
|
|
|
using CommonInfrastructure;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using UserDomain.Entity;
|
|
|
|
|
|
|
|
|
|
namespace AdminApi.BeautifulNumber
|
|
|
|
|
{
|
|
|
|
|
[ApiController, Route("adminapi/[controller]")]
|
|
|
|
|
[Authorize]
|
|
|
|
|
|
|
|
|
|
public class BeautifulNumberController : BaseController
|
|
|
|
|
{
|
|
|
|
|
private readonly IBeautifulNumberService _beautifulNumberService;
|
|
|
|
|
|
|
|
|
|
public BeautifulNumberController(IBeautifulNumberService beautifulNumberService)
|
|
|
|
|
{
|
|
|
|
|
_beautifulNumberService = beautifulNumberService;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 获取靓号列表
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpGet("list")]
|
|
|
|
|
public async Task<PageResponse<BeautifulNumberDto>> GetList([FromQuery] BeautifulNumberListParam param)
|
|
|
|
|
{
|
|
|
|
|
param.page = param.page > 0 ? param.page : 1;
|
|
|
|
|
param.size = param.size > 0 ? param.size : 20;
|
|
|
|
|
var result = await _beautifulNumberService.GetList(param);
|
|
|
|
|
var dtos = result.list.Select(MapToDto).ToList();
|
|
|
|
|
return this.ToPageResult(dtos, (int)result.count);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 获取可购买的靓号列表
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpGet("available")]
|
|
|
|
|
public async Task<PageResponse<BeautifulNumberDto>> GetAvailableList([FromQuery] BeautifulNumberListParam param)
|
|
|
|
|
{
|
|
|
|
|
param.page = param.page > 0 ? param.page : 1;
|
|
|
|
|
param.size = param.size > 0 ? param.size : 20;
|
|
|
|
|
param.status = (int)BeautifulNumberStatus.Available;
|
|
|
|
|
var result = await _beautifulNumberService.GetList(param);
|
|
|
|
|
var dtos = result.list.Select(MapToDto).ToList();
|
|
|
|
|
return this.ToPageResult(dtos, (int)result.count);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 查询靓号信息
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpGet("check/{number}")]
|
|
|
|
|
public async Task<BaseResponse<BeautifulNumberDto>> CheckNumber(string number)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.CheckNumber(number);
|
|
|
|
|
return this.ToResult(MapToDto(result));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static BeautifulNumberDto MapToDto(BeautifulNumberConfig entity)
|
|
|
|
|
{
|
|
|
|
|
if (entity == null) return new BeautifulNumberDto();
|
|
|
|
|
return new BeautifulNumberDto
|
|
|
|
|
{
|
|
|
|
|
Id = entity.Id ?? "",
|
|
|
|
|
Number = entity.Number ?? "",
|
|
|
|
|
RuleName = entity.RuleName ?? "",
|
|
|
|
|
Level = entity.Level ?? "",
|
|
|
|
|
Price = entity.Price,
|
|
|
|
|
Status = (int)entity.Status,
|
|
|
|
|
SaleTime = entity.SaleTime,
|
|
|
|
|
BuyerUserId = entity.BuyerUserId ?? "",
|
|
|
|
|
UserId = entity.UserId ?? "",
|
|
|
|
|
Remark = entity.Remark ?? "",
|
|
|
|
|
CreateTime = entity.CreateTime
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 删除靓号
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("delete")]
|
|
|
|
|
public async Task<BaseResponse<string>> Delete([FromBody] DeleteBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.Delete(param.Id);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 设置为普通号
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("set-normal")]
|
|
|
|
|
public async Task<BaseResponse<string>> SetToNormal([FromBody] DeleteBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.SetToNormal(param.Id);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 冻结靓号
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("freeze")]
|
|
|
|
|
public async Task<BaseResponse<string>> Freeze([FromBody] DeleteBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.Freeze(param.Id);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 解冻靓号
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("unfreeze")]
|
|
|
|
|
public async Task<BaseResponse<string>> Unfreeze([FromBody] DeleteBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.Unfreeze(param.Id);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 修改价格
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("update-price")]
|
|
|
|
|
public async Task<BaseResponse<string>> UpdatePrice([FromBody] UpdateBeautifulNumberPriceParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.UpdatePrice(param.Id, param.Price);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 修改靓号(等级和价格)
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("update-number")]
|
|
|
|
|
public async Task<BaseResponse<string>> UpdateNumber([FromBody] UpdateBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.UpdateNumber(param.Id, param.Level, param.Price);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 获取靓号规则列表
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpGet("rules")]
|
|
|
|
|
public async Task<BaseResponse<List<BeautifulNumberRuleDto>>> GetRules()
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.GetRules();
|
|
|
|
|
var dtos = result.Select(MapRuleToDto).ToList();
|
|
|
|
|
return this.ToResult(dtos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static BeautifulNumberRuleDto MapRuleToDto(BeautifulNumberRule entity)
|
|
|
|
|
{
|
|
|
|
|
if (entity == null) return new BeautifulNumberRuleDto();
|
|
|
|
|
return new BeautifulNumberRuleDto
|
|
|
|
|
{
|
|
|
|
|
Id = entity.Id ?? "",
|
|
|
|
|
RuleName = entity.RuleName ?? "",
|
|
|
|
|
Level = entity.Level ?? "",
|
|
|
|
|
Price = entity.Price,
|
|
|
|
|
Sort = entity.Sort,
|
|
|
|
|
IsEnable = entity.IsEnable
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 更新靓号规则
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("update-rules")]
|
|
|
|
|
public async Task<BaseResponse<string>> UpdateRules([FromBody] List<UpdateBeautifulNumberRuleParam> paramList)
|
|
|
|
|
{
|
|
|
|
|
var rules = new List<BeautifulNumberRule>();
|
|
|
|
|
foreach (var param in paramList)
|
|
|
|
|
{
|
|
|
|
|
rules.Add(new BeautifulNumberRule
|
|
|
|
|
{
|
|
|
|
|
Id = param.Id,
|
|
|
|
|
RuleName = param.RuleName,
|
|
|
|
|
Level = param.Level,
|
|
|
|
|
Price = param.Price,
|
|
|
|
|
Sort = param.Sort,
|
|
|
|
|
IsEnable = param.IsEnable
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
var result = await _beautifulNumberService.UpdateRules(rules);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化靓号规则
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("init-rules")]
|
|
|
|
|
public async Task<BaseResponse<string>> InitRules()
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.InitRules();
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 添加规则
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("add-rule")]
|
|
|
|
|
public async Task<BaseResponse<string>> AddRule([FromBody] BeautifulNumberRule rule)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.AddRule(rule);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 更新规则
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("update-rule")]
|
|
|
|
|
public async Task<BaseResponse<string>> UpdateRule([FromBody] BeautifulNumberRule rule)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.UpdateRule(rule);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 删除规则
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("delete-rule")]
|
|
|
|
|
public async Task<BaseResponse<string>> DeleteRule([FromBody] DeleteBeautifulNumberRuleParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.DeleteRule(param.Id);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 赠送靓号给用户
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("give-to-user")]
|
|
|
|
|
public async Task<BaseResponse<string>> GiveToUser([FromBody] GiveBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.GiveToUser(param.Number, param.UserId);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化靓号(已售出不删除)
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("init-numbers")]
|
|
|
|
|
public async Task<BaseResponse<string>> InitNumbers()
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.InitBeautifulNumbers();
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 添加单个靓号
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("add-number")]
|
|
|
|
|
public async Task<BaseResponse<string>> AddNumber([FromBody] AddBeautifulNumberParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.AddNumber(param.Number, param.Level, param.Price);
|
|
|
|
|
if (result.isok)
|
|
|
|
|
return this.ToResult<string>(result.msg);
|
|
|
|
|
else
|
|
|
|
|
return this.ToFailResult<string>(result.msg);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 00:44:00 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 批量添加靓号
|
|
|
|
|
/// </summary>
|
2026-10-12 16:22:04 +08:00
|
|
|
[HttpPost("batch-add-numbers")]
|
|
|
|
|
public async Task<BaseResponse<BatchAddResult>> BatchAddNumbers([FromBody] BatchAddBeautifulNumbersParam param)
|
|
|
|
|
{
|
|
|
|
|
var result = await _beautifulNumberService.BatchAddNumbers(param.Numbers, param.Level, param.Price);
|
|
|
|
|
return this.ToResult(new BatchAddResult { SuccessCount = result.successCount, FailCount = result.failCount, Message = result.msg });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BatchAddResult
|
|
|
|
|
{
|
|
|
|
|
public int SuccessCount { get; set; }
|
|
|
|
|
public int FailCount { get; set; }
|
|
|
|
|
public string Message { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BeautifulNumberDto
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string Number { get; set; }
|
|
|
|
|
public string RuleName { get; set; }
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
public int Status { get; set; }
|
|
|
|
|
public long SaleTime { get; set; }
|
|
|
|
|
public string BuyerUserId { get; set; }
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
public string Remark { get; set; }
|
|
|
|
|
public long CreateTime { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BeautifulNumberRuleDto
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string RuleName { get; set; }
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
public int Sort { get; set; }
|
|
|
|
|
public bool IsEnable { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class BatchAddBeautifulNumbersParam
|
|
|
|
|
{
|
|
|
|
|
public List<string> Numbers { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GiveBeautifulNumberParam
|
|
|
|
|
{
|
|
|
|
|
public string Number { get; set; }
|
|
|
|
|
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AddBeautifulNumberParam
|
|
|
|
|
{
|
|
|
|
|
public string Number { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Sort { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Remark { get; set; }
|
|
|
|
|
}
|
|
|
|
|
public class UpdateBeautifulNumberParam
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public class DeleteBeautifulNumberParam
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UpdateBeautifulNumberPriceParam
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class UpdateBeautifulNumberRuleParam
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string RuleName { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Sort { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool IsEnable { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AddBeautifulNumberRuleParam
|
|
|
|
|
{
|
|
|
|
|
public string RuleName { get; set; }
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
public int Sort { get; set; }
|
|
|
|
|
public bool IsEnable { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UpdateSingleBeautifulNumberRuleParam
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string RuleName { get; set; }
|
|
|
|
|
public string Level { get; set; }
|
|
|
|
|
public long Price { get; set; }
|
|
|
|
|
public int Sort { get; set; }
|
|
|
|
|
public bool IsEnable { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DeleteBeautifulNumberRuleParam
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|