忽略dll文件git
This commit is contained in:
@@ -1,54 +1,54 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/agent/[action]")]
|
||||
public class AgentController : HncoreControllerBase
|
||||
{
|
||||
private AgentService m_AgentService;
|
||||
IConfiguration m_Configuration;
|
||||
public AgentController(AgentService _AgentService,IConfiguration configuration)
|
||||
{
|
||||
m_AgentService = _AgentService;
|
||||
m_Configuration = configuration;
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Login([FromBody] AgentLoginRequest request)
|
||||
{
|
||||
return await m_AgentService.Login(request);
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> GetCode([FromQuery] int productId)
|
||||
{
|
||||
var ret = await m_AgentService.GetCode(productId);
|
||||
if (ret.Item1 != null)
|
||||
{
|
||||
var file = $"codes/{Guid.NewGuid().ToString("N")}.jpg";
|
||||
var wwwrootFile = $"wwwroot/{file}";
|
||||
using (FileStream fs = new FileStream(wwwrootFile, FileMode.Create))
|
||||
{
|
||||
await fs.WriteAsync(ret.Item1, 0, ret.Item1.Length);
|
||||
}
|
||||
return Success(new CodeResponse()
|
||||
{
|
||||
Key = ret.Item2,
|
||||
CodeImage = $"{m_Configuration["Service_BaseUrl"]}{file}"
|
||||
});
|
||||
}
|
||||
return Success(new CodeResponse()
|
||||
{
|
||||
Key = "",
|
||||
CodeImage = ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/agent/[action]")]
|
||||
public class AgentController : HncoreControllerBase
|
||||
{
|
||||
private AgentService m_AgentService;
|
||||
IConfiguration m_Configuration;
|
||||
public AgentController(AgentService _AgentService,IConfiguration configuration)
|
||||
{
|
||||
m_AgentService = _AgentService;
|
||||
m_Configuration = configuration;
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Login([FromBody] AgentLoginRequest request)
|
||||
{
|
||||
return await m_AgentService.Login(request);
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> GetCode([FromQuery] int productId)
|
||||
{
|
||||
var ret = await m_AgentService.GetCode(productId);
|
||||
if (ret.Item1 != null)
|
||||
{
|
||||
var file = $"codes/{Guid.NewGuid().ToString("N")}.jpg";
|
||||
var wwwrootFile = $"wwwroot/{file}";
|
||||
using (FileStream fs = new FileStream(wwwrootFile, FileMode.Create))
|
||||
{
|
||||
await fs.WriteAsync(ret.Item1, 0, ret.Item1.Length);
|
||||
}
|
||||
return Success(new CodeResponse()
|
||||
{
|
||||
Key = ret.Item2,
|
||||
CodeImage = $"{m_Configuration["Service_BaseUrl"]}{file}"
|
||||
});
|
||||
}
|
||||
return Success(new CodeResponse()
|
||||
{
|
||||
Key = "",
|
||||
CodeImage = ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/article/[action]")]
|
||||
public class ArticleController : HncoreControllerBase
|
||||
{
|
||||
private ArticleService m_ArticleService;
|
||||
|
||||
public ArticleController(ArticleService _ArticleService)
|
||||
{
|
||||
m_ArticleService = _ArticleService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ArticleEntity request)
|
||||
{
|
||||
request.TenantId = this.Request.GetManageUserInfo().TenantId;
|
||||
await m_ArticleService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ArticleEntity request)
|
||||
{
|
||||
await m_ArticleService.Update(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_ArticleService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_ArticleService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<ArticleEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Title.Contains(request.KeyWord)
|
||||
|| m.SubTitle.Contains(request.KeyWord)
|
||||
|| m.Keyword.Contains(request.KeyWord));
|
||||
}
|
||||
var ret = await m_ArticleService.Page(request.PageIndex, request.PageSize, expr,true);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Audit([FromQuery] int id)
|
||||
{
|
||||
var entity = await m_ArticleService.GetById(id);
|
||||
|
||||
entity.Publish = entity.Publish == 1 ? 0 : 1;
|
||||
|
||||
await m_ArticleService.Update(entity);
|
||||
return Success(entity.Publish);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/article/[action]")]
|
||||
public class ArticleController : HncoreControllerBase
|
||||
{
|
||||
private ArticleService m_ArticleService;
|
||||
|
||||
public ArticleController(ArticleService _ArticleService)
|
||||
{
|
||||
m_ArticleService = _ArticleService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ArticleEntity request)
|
||||
{
|
||||
request.TenantId = this.Request.GetManageUserInfo().TenantId;
|
||||
await m_ArticleService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ArticleEntity request)
|
||||
{
|
||||
await m_ArticleService.Update(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_ArticleService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_ArticleService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<ArticleEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Title.Contains(request.KeyWord)
|
||||
|| m.SubTitle.Contains(request.KeyWord)
|
||||
|| m.Keyword.Contains(request.KeyWord));
|
||||
}
|
||||
var ret = await m_ArticleService.Page(request.PageIndex, request.PageSize, expr,true);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Audit([FromQuery] int id)
|
||||
{
|
||||
var entity = await m_ArticleService.GetById(id);
|
||||
|
||||
entity.Publish = entity.Publish == 1 ? 0 : 1;
|
||||
|
||||
await m_ArticleService.Update(entity);
|
||||
return Success(entity.Publish);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,286 +1,286 @@
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using UserService = Hncore.Pass.Vpn.Service.UserService;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/product/[action]")]
|
||||
public class ProductController : HncoreControllerBase
|
||||
{
|
||||
private ProductService m_ProductService;
|
||||
private UserService m_UserService;
|
||||
private ProductPackageService m_ProductPackageService;
|
||||
private ProductUserPriceService m_ProductUserPriceService;
|
||||
public ProductController(UserService _UserService,ProductService _ProductServic, ProductPackageService _ProductPackageService, ProductUserPriceService m_ProductUserPriceService)
|
||||
{
|
||||
m_ProductService = _ProductServic;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_UserService = _UserService;
|
||||
this.m_ProductUserPriceService = m_ProductUserPriceService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ProductEntity request)
|
||||
{
|
||||
request.TenantId = this.Request.GetManageUserInfo().TenantId;
|
||||
await m_ProductService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ProductEntity request)
|
||||
{
|
||||
var entity = await m_ProductService.GetById(request.Id);
|
||||
entity.Name = request.Name;
|
||||
entity.Profile = request.Profile;
|
||||
entity.Image = request.Image;
|
||||
entity.RefundDayPrice = request.RefundDayPrice;
|
||||
entity.DayLimitPrice = request.DayLimitPrice;
|
||||
await m_ProductService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutConfig([FromBody]ProductEntity request)
|
||||
{
|
||||
var entity = await m_ProductService.GetById(request.Id);
|
||||
entity.Account = request.Account;
|
||||
entity.Pwd = request.Pwd;
|
||||
entity.BaseUrl = request.BaseUrl;
|
||||
entity.Token = "";
|
||||
await m_ProductService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutSoft([FromBody]ProductEntity request)
|
||||
{
|
||||
var entity = await m_ProductService.GetById(request.Id);
|
||||
entity.PcClientDownloadUrl = request.PcClientDownloadUrl;
|
||||
entity.SimulatorDownloadUrl = request.SimulatorDownloadUrl;
|
||||
entity.DroidDownloadUrl = request.DroidDownloadUrl;
|
||||
entity.IosDownloadUrl = request.IosDownloadUrl;
|
||||
await m_ProductService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_ProductService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_ProductService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<ProductEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Name.Contains(request.KeyWord));
|
||||
}
|
||||
var ret = await m_ProductService.PageAsc(request.PageIndex, request.PageSize, expr,true,m=>m.Sort);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpGet,AllowAnonymous]
|
||||
public async Task<ApiResult> OpenPage([FromQuery]PageRequestBase request)
|
||||
{
|
||||
// Expression<Func<ProductEntity, bool>> expr = m => 1 == 1;
|
||||
// if (request.KeyWord.Has())
|
||||
// {
|
||||
// expr = expr.And(m => m.Name.Contains(request.KeyWord));
|
||||
// }
|
||||
// var ret = await m_ProductService.PageAsc(request.PageIndex, request.PageSize, expr, true,m=>m.Sort);
|
||||
// var data = ret.ToApiResult();
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpGet, AllowAnonymous]
|
||||
public async Task<ApiResult> ProductWithPackage()
|
||||
{
|
||||
var respList = await m_ProductService.ProductWithPackage();
|
||||
return Success(respList);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> ProductUserPrice(int userId)
|
||||
{
|
||||
var ret = await this.m_ProductUserPriceService.GetPackageUserPrice(userId);
|
||||
return Success(ret);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetProductLine([FromQuery]int id)
|
||||
{
|
||||
var productEntity = await m_ProductService.GetById(id);
|
||||
if (productEntity == null)
|
||||
{
|
||||
return Error("产品不存在");
|
||||
}
|
||||
productEntity.Status = productEntity.OnLine == 0 ? 1 : 0;
|
||||
await m_ProductService.Update(productEntity);
|
||||
|
||||
return Success(productEntity.Status);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetPackageLine([FromQuery]int id)
|
||||
{
|
||||
var packageEntity = await m_ProductPackageService.GetById(id);
|
||||
if (packageEntity == null)
|
||||
{
|
||||
return Error("套餐不存在");
|
||||
}
|
||||
packageEntity.Status = packageEntity.Status == 0 ? 1 : 0;
|
||||
await m_ProductPackageService.Update(packageEntity);
|
||||
|
||||
return Success(packageEntity.Status);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetUserPriceStatus([FromQuery]int id)
|
||||
{
|
||||
var userPriceEntity = await m_ProductUserPriceService.GetById(id);
|
||||
if (userPriceEntity == null)
|
||||
{
|
||||
return Error("请设置会员价");
|
||||
}
|
||||
var userEntity = await m_UserService.Query(m => m.Id==userPriceEntity.UserId).FirstOrDefaultAsync();
|
||||
userEntity.discount_id = -1;
|
||||
await m_UserService.Update(userEntity);
|
||||
|
||||
userPriceEntity.Status = userPriceEntity.Status == 0 ? 1 : 0;
|
||||
await m_ProductUserPriceService.Update(userPriceEntity);
|
||||
return Success(userPriceEntity.Status);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutPackage([FromBody]ProductPackageEntity request)
|
||||
{
|
||||
var packageEntity = await m_ProductPackageService.GetById(request.Id);
|
||||
if (packageEntity == null)
|
||||
{
|
||||
return Error("套餐不存在");
|
||||
}
|
||||
packageEntity.LinePrice = request.LinePrice;
|
||||
packageEntity.MinPrice = request.MinPrice;
|
||||
packageEntity.Name = request.Name;
|
||||
packageEntity.Price = request.Price;
|
||||
packageEntity.Profile = request.Profile;
|
||||
packageEntity.Title = request.Title;
|
||||
await m_ProductPackageService.Update(packageEntity);
|
||||
return Success(packageEntity);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutUserPrice([FromBody]PutUserPriceRequest request)
|
||||
{
|
||||
var userPriceEntity = await m_ProductUserPriceService.Query(m => m.PackageId == request.PackageId && m.UserId == request.UserId).FirstOrDefaultAsync();
|
||||
var userEntity = await m_UserService.Query(m => m.Id==request.UserId).FirstOrDefaultAsync();
|
||||
userEntity.discount_id = -1;
|
||||
await m_UserService.Update(userEntity);
|
||||
var price = request.UserPrice;
|
||||
var packageEntity =await m_ProductPackageService.GetById(request.PackageId);
|
||||
// var product = await m_ProductService.GetById(packageEntity.ProductId);
|
||||
if (request.UserPrice < packageEntity.MinPrice && packageEntity.MinPrice > 0)
|
||||
{
|
||||
return Error($"不能低于最低限额[{ packageEntity.MinPrice}]");
|
||||
}
|
||||
|
||||
var productEntity = await m_ProductService.GetById(packageEntity.ProductId);
|
||||
|
||||
if (productEntity.DayLimitPrice>0&&request.RefundDayPrice < productEntity.DayLimitPrice)
|
||||
{
|
||||
return Error($"退款单价不能低于[{ productEntity.DayLimitPrice}]");
|
||||
}
|
||||
|
||||
//toto
|
||||
if (userPriceEntity == null)
|
||||
{
|
||||
userPriceEntity =new ProductUserPriceEntity()
|
||||
{
|
||||
PackageId = request.PackageId,
|
||||
ProductId = request.ProductId,
|
||||
UserId = request.UserId,
|
||||
UserPrice = request.UserPrice,
|
||||
Status = 1,
|
||||
DeleteTag = 0,
|
||||
Remark=request.Remark,
|
||||
RefundDayPrice= request.RefundDayPrice
|
||||
};
|
||||
await m_ProductUserPriceService.Add(userPriceEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
userPriceEntity.UserPrice = request.UserPrice;
|
||||
userPriceEntity.RefundDayPrice = request.RefundDayPrice;
|
||||
userPriceEntity.Remark = request.Remark;
|
||||
await m_ProductUserPriceService.Update(userPriceEntity);
|
||||
}
|
||||
return Success(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using UserService = Hncore.Pass.Vpn.Service.UserService;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/product/[action]")]
|
||||
public class ProductController : HncoreControllerBase
|
||||
{
|
||||
private ProductService m_ProductService;
|
||||
private UserService m_UserService;
|
||||
private ProductPackageService m_ProductPackageService;
|
||||
private ProductUserPriceService m_ProductUserPriceService;
|
||||
public ProductController(UserService _UserService,ProductService _ProductServic, ProductPackageService _ProductPackageService, ProductUserPriceService m_ProductUserPriceService)
|
||||
{
|
||||
m_ProductService = _ProductServic;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_UserService = _UserService;
|
||||
this.m_ProductUserPriceService = m_ProductUserPriceService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ProductEntity request)
|
||||
{
|
||||
request.TenantId = this.Request.GetManageUserInfo().TenantId;
|
||||
await m_ProductService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ProductEntity request)
|
||||
{
|
||||
var entity = await m_ProductService.GetById(request.Id);
|
||||
entity.Name = request.Name;
|
||||
entity.Profile = request.Profile;
|
||||
entity.Image = request.Image;
|
||||
entity.RefundDayPrice = request.RefundDayPrice;
|
||||
entity.DayLimitPrice = request.DayLimitPrice;
|
||||
await m_ProductService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutConfig([FromBody]ProductEntity request)
|
||||
{
|
||||
var entity = await m_ProductService.GetById(request.Id);
|
||||
entity.Account = request.Account;
|
||||
entity.Pwd = request.Pwd;
|
||||
entity.BaseUrl = request.BaseUrl;
|
||||
entity.Token = "";
|
||||
await m_ProductService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutSoft([FromBody]ProductEntity request)
|
||||
{
|
||||
var entity = await m_ProductService.GetById(request.Id);
|
||||
entity.PcClientDownloadUrl = request.PcClientDownloadUrl;
|
||||
entity.SimulatorDownloadUrl = request.SimulatorDownloadUrl;
|
||||
entity.DroidDownloadUrl = request.DroidDownloadUrl;
|
||||
entity.IosDownloadUrl = request.IosDownloadUrl;
|
||||
await m_ProductService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_ProductService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_ProductService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<ProductEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Name.Contains(request.KeyWord));
|
||||
}
|
||||
var ret = await m_ProductService.PageAsc(request.PageIndex, request.PageSize, expr,true,m=>m.Sort);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpGet,AllowAnonymous]
|
||||
public async Task<ApiResult> OpenPage([FromQuery]PageRequestBase request)
|
||||
{
|
||||
// Expression<Func<ProductEntity, bool>> expr = m => 1 == 1;
|
||||
// if (request.KeyWord.Has())
|
||||
// {
|
||||
// expr = expr.And(m => m.Name.Contains(request.KeyWord));
|
||||
// }
|
||||
// var ret = await m_ProductService.PageAsc(request.PageIndex, request.PageSize, expr, true,m=>m.Sort);
|
||||
// var data = ret.ToApiResult();
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpGet, AllowAnonymous]
|
||||
public async Task<ApiResult> ProductWithPackage()
|
||||
{
|
||||
var respList = await m_ProductService.ProductWithPackage();
|
||||
return Success(respList);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> ProductUserPrice(int userId)
|
||||
{
|
||||
var ret = await this.m_ProductUserPriceService.GetPackageUserPrice(userId);
|
||||
return Success(ret);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetProductLine([FromQuery]int id)
|
||||
{
|
||||
var productEntity = await m_ProductService.GetById(id);
|
||||
if (productEntity == null)
|
||||
{
|
||||
return Error("产品不存在");
|
||||
}
|
||||
productEntity.Status = productEntity.OnLine == 0 ? 1 : 0;
|
||||
await m_ProductService.Update(productEntity);
|
||||
|
||||
return Success(productEntity.Status);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetPackageLine([FromQuery]int id)
|
||||
{
|
||||
var packageEntity = await m_ProductPackageService.GetById(id);
|
||||
if (packageEntity == null)
|
||||
{
|
||||
return Error("套餐不存在");
|
||||
}
|
||||
packageEntity.Status = packageEntity.Status == 0 ? 1 : 0;
|
||||
await m_ProductPackageService.Update(packageEntity);
|
||||
|
||||
return Success(packageEntity.Status);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetUserPriceStatus([FromQuery]int id)
|
||||
{
|
||||
var userPriceEntity = await m_ProductUserPriceService.GetById(id);
|
||||
if (userPriceEntity == null)
|
||||
{
|
||||
return Error("请设置会员价");
|
||||
}
|
||||
var userEntity = await m_UserService.Query(m => m.Id==userPriceEntity.UserId).FirstOrDefaultAsync();
|
||||
userEntity.discount_id = -1;
|
||||
await m_UserService.Update(userEntity);
|
||||
|
||||
userPriceEntity.Status = userPriceEntity.Status == 0 ? 1 : 0;
|
||||
await m_ProductUserPriceService.Update(userPriceEntity);
|
||||
return Success(userPriceEntity.Status);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutPackage([FromBody]ProductPackageEntity request)
|
||||
{
|
||||
var packageEntity = await m_ProductPackageService.GetById(request.Id);
|
||||
if (packageEntity == null)
|
||||
{
|
||||
return Error("套餐不存在");
|
||||
}
|
||||
packageEntity.LinePrice = request.LinePrice;
|
||||
packageEntity.MinPrice = request.MinPrice;
|
||||
packageEntity.Name = request.Name;
|
||||
packageEntity.Price = request.Price;
|
||||
packageEntity.Profile = request.Profile;
|
||||
packageEntity.Title = request.Title;
|
||||
await m_ProductPackageService.Update(packageEntity);
|
||||
return Success(packageEntity);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutUserPrice([FromBody]PutUserPriceRequest request)
|
||||
{
|
||||
var userPriceEntity = await m_ProductUserPriceService.Query(m => m.PackageId == request.PackageId && m.UserId == request.UserId).FirstOrDefaultAsync();
|
||||
var userEntity = await m_UserService.Query(m => m.Id==request.UserId).FirstOrDefaultAsync();
|
||||
userEntity.discount_id = -1;
|
||||
await m_UserService.Update(userEntity);
|
||||
var price = request.UserPrice;
|
||||
var packageEntity =await m_ProductPackageService.GetById(request.PackageId);
|
||||
// var product = await m_ProductService.GetById(packageEntity.ProductId);
|
||||
if (request.UserPrice < packageEntity.MinPrice && packageEntity.MinPrice > 0)
|
||||
{
|
||||
return Error($"不能低于最低限额[{ packageEntity.MinPrice}]");
|
||||
}
|
||||
|
||||
var productEntity = await m_ProductService.GetById(packageEntity.ProductId);
|
||||
|
||||
if (productEntity.DayLimitPrice>0&&request.RefundDayPrice < productEntity.DayLimitPrice)
|
||||
{
|
||||
return Error($"退款单价不能低于[{ productEntity.DayLimitPrice}]");
|
||||
}
|
||||
|
||||
//toto
|
||||
if (userPriceEntity == null)
|
||||
{
|
||||
userPriceEntity =new ProductUserPriceEntity()
|
||||
{
|
||||
PackageId = request.PackageId,
|
||||
ProductId = request.ProductId,
|
||||
UserId = request.UserId,
|
||||
UserPrice = request.UserPrice,
|
||||
Status = 1,
|
||||
DeleteTag = 0,
|
||||
Remark=request.Remark,
|
||||
RefundDayPrice= request.RefundDayPrice
|
||||
};
|
||||
await m_ProductUserPriceService.Add(userPriceEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
userPriceEntity.UserPrice = request.UserPrice;
|
||||
userPriceEntity.RefundDayPrice = request.RefundDayPrice;
|
||||
userPriceEntity.Remark = request.Remark;
|
||||
await m_ProductUserPriceService.Update(userPriceEntity);
|
||||
}
|
||||
return Success(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,149 +1,149 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/productroute/[action]")]
|
||||
public class ProductRouteController : HncoreControllerBase
|
||||
{
|
||||
private ProductRouteService m_ProductRouteService;
|
||||
|
||||
private ProductService m_ProductService;
|
||||
|
||||
public ProductRouteController(ProductRouteService _ProductRouteService, ProductService _ProductService)
|
||||
{
|
||||
m_ProductRouteService = _ProductRouteService;
|
||||
m_ProductService = _ProductService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ProductRouteEntity request)
|
||||
{
|
||||
var product = await m_ProductService.GetById(request.ProductId);
|
||||
request.ProductName = product?.Name;
|
||||
await m_ProductRouteService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ProductRouteEntity request)
|
||||
{
|
||||
var product = await m_ProductService.GetById(request.ProductId);
|
||||
request.ProductName = product?.Name;
|
||||
await m_ProductRouteService.Update(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_ProductRouteService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_ProductRouteService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]RoutePageRequest request)
|
||||
{
|
||||
Expression<Func<ProductRouteEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Province.Contains(request.KeyWord) || m.Name.Contains(request.KeyWord) || m.City.Contains(request.KeyWord) || m.ServerUrl.Contains(request.KeyWord));
|
||||
}
|
||||
if (request.ProductId.HasValue&& request.ProductId>0)
|
||||
{
|
||||
expr = expr.And(m => m.ProductId==request.ProductId);
|
||||
}
|
||||
var ret = await m_ProductRouteService.PageAsc(request.PageIndex, request.PageSize, expr, true,m=>m.Sort);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, AllowAnonymous]
|
||||
public async Task<ApiResult> Import(IFormFile file)
|
||||
{
|
||||
// var file = this.Request.Form.Files.First();
|
||||
var stream = file.OpenReadStream();// this.Request.Body;
|
||||
//stream.Position = 0;
|
||||
var data = ExcelHelper.ReadFromStream(stream);
|
||||
|
||||
var products = await m_ProductService.GetAll();
|
||||
|
||||
var list = new List<ProductRouteEntity>();
|
||||
|
||||
var dataRows = data.Skip(1);
|
||||
foreach (var row in dataRows)
|
||||
{
|
||||
var model = new ProductRouteEntity();
|
||||
model.ProductName = row[0];
|
||||
model.Province = row[1];
|
||||
model.Name = row[2];
|
||||
model.ServerUrl = row[3];
|
||||
model.Status = row[4];
|
||||
model.LineType = row[5];
|
||||
model.BandWidth = row[6];
|
||||
model.IpRemark = row[7];
|
||||
model.ProductId = products.FirstOrDefault(m => m.Name == model.ProductName)?.Id;
|
||||
}
|
||||
if (list.Count > 1)
|
||||
{
|
||||
await m_ProductRouteService.Adds(list);
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/productroute/[action]")]
|
||||
public class ProductRouteController : HncoreControllerBase
|
||||
{
|
||||
private ProductRouteService m_ProductRouteService;
|
||||
|
||||
private ProductService m_ProductService;
|
||||
|
||||
public ProductRouteController(ProductRouteService _ProductRouteService, ProductService _ProductService)
|
||||
{
|
||||
m_ProductRouteService = _ProductRouteService;
|
||||
m_ProductService = _ProductService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ProductRouteEntity request)
|
||||
{
|
||||
var product = await m_ProductService.GetById(request.ProductId);
|
||||
request.ProductName = product?.Name;
|
||||
await m_ProductRouteService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ProductRouteEntity request)
|
||||
{
|
||||
var product = await m_ProductService.GetById(request.ProductId);
|
||||
request.ProductName = product?.Name;
|
||||
await m_ProductRouteService.Update(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_ProductRouteService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_ProductRouteService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]RoutePageRequest request)
|
||||
{
|
||||
Expression<Func<ProductRouteEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Province.Contains(request.KeyWord) || m.Name.Contains(request.KeyWord) || m.City.Contains(request.KeyWord) || m.ServerUrl.Contains(request.KeyWord));
|
||||
}
|
||||
if (request.ProductId.HasValue&& request.ProductId>0)
|
||||
{
|
||||
expr = expr.And(m => m.ProductId==request.ProductId);
|
||||
}
|
||||
var ret = await m_ProductRouteService.PageAsc(request.PageIndex, request.PageSize, expr, true,m=>m.Sort);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, AllowAnonymous]
|
||||
public async Task<ApiResult> Import(IFormFile file)
|
||||
{
|
||||
// var file = this.Request.Form.Files.First();
|
||||
var stream = file.OpenReadStream();// this.Request.Body;
|
||||
//stream.Position = 0;
|
||||
var data = ExcelHelper.ReadFromStream(stream);
|
||||
|
||||
var products = await m_ProductService.GetAll();
|
||||
|
||||
var list = new List<ProductRouteEntity>();
|
||||
|
||||
var dataRows = data.Skip(1);
|
||||
foreach (var row in dataRows)
|
||||
{
|
||||
var model = new ProductRouteEntity();
|
||||
model.ProductName = row[0];
|
||||
model.Province = row[1];
|
||||
model.Name = row[2];
|
||||
model.ServerUrl = row[3];
|
||||
model.Status = row[4];
|
||||
model.LineType = row[5];
|
||||
model.BandWidth = row[6];
|
||||
model.IpRemark = row[7];
|
||||
model.ProductId = products.FirstOrDefault(m => m.Name == model.ProductName)?.Id;
|
||||
}
|
||||
if (list.Count > 1)
|
||||
{
|
||||
await m_ProductRouteService.Adds(list);
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,189 +1,189 @@
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/scheme/[action]")]
|
||||
public class ProductSchemeController : HncoreControllerBase
|
||||
{
|
||||
private ProductService m_ProductService;
|
||||
private ProductPackageService m_ProductPackageService;
|
||||
private ProductUserPriceService m_ProductUserPriceService;
|
||||
private ProductPriceSchemeService m_PriceSchemeService;
|
||||
private ProductPriceDiscountService m_PriceDiscountService;
|
||||
public ProductSchemeController(ProductService _ProductServic
|
||||
, ProductPackageService _ProductPackageService
|
||||
, ProductUserPriceService _ProductUserPriceService
|
||||
,ProductPriceSchemeService _PriceSchemeService
|
||||
,ProductPriceDiscountService _PriceDiscountService
|
||||
)
|
||||
{
|
||||
m_ProductService = _ProductServic;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_ProductUserPriceService = _ProductUserPriceService;
|
||||
m_PriceSchemeService = _PriceSchemeService;
|
||||
m_PriceDiscountService = _PriceDiscountService;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ProductPriceSchemeEntity request)
|
||||
{
|
||||
await m_PriceSchemeService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ProductPriceSchemeEntity request)
|
||||
{
|
||||
var entity = await m_PriceSchemeService.GetById(request.Id);
|
||||
entity.Name = request.Name;
|
||||
entity.Remark = request.Remark;
|
||||
entity.discount = request.discount;
|
||||
entity.UpdateTime = DateTime.Now;
|
||||
await m_PriceSchemeService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_PriceSchemeService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_PriceSchemeService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<ProductPriceSchemeEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Name.Contains(request.KeyWord));
|
||||
}
|
||||
var ret = await m_PriceSchemeService.Page(request.PageIndex, request.PageSize, expr,true);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> GetProductDiscount(int id)
|
||||
{
|
||||
var ret = await this.m_PriceDiscountService.GetPriceDiscount(id);
|
||||
return Success(ret);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutProductDiscount([FromBody]ProductPriceDiscountEntity request)
|
||||
{
|
||||
var priceDiscountEntity = await m_PriceDiscountService.Query(m => m.PackageId == request.PackageId && m.SchemeId == request.SchemeId).FirstOrDefaultAsync();
|
||||
|
||||
if (priceDiscountEntity == null)
|
||||
{
|
||||
await m_PriceDiscountService.Add(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
priceDiscountEntity.BuyPriceDiscount = request.BuyPriceDiscount;
|
||||
priceDiscountEntity.RefundDayPriceDiscount = request.RefundDayPriceDiscount;
|
||||
await m_PriceDiscountService.Update(priceDiscountEntity);
|
||||
}
|
||||
return Success(1);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetUserDiscount([FromBody] SetUserDiscountRequest request)
|
||||
{
|
||||
var priceDiscountEntitys = await m_PriceDiscountService.Query(m => m.SchemeId == request.SchemeId).ToListAsync();
|
||||
var schemaEntity = await m_PriceSchemeService.GetById(request.SchemeId);
|
||||
var produccts = await m_ProductService.GetAll(true);
|
||||
var packages = await m_ProductPackageService.GetAll(true);
|
||||
|
||||
var userPrices = await m_ProductUserPriceService.GetPackageUserPrice(request.UserId);
|
||||
foreach (var item in priceDiscountEntitys)
|
||||
{
|
||||
var product = produccts.FirstOrDefault(m => m.Id == item.ProductId);
|
||||
var package = packages.FirstOrDefault(m => m.Id == item.PackageId);
|
||||
var userPakcagePrices = userPrices.FirstOrDefault(m => m.Product.Id == item.ProductId)?.PackageUserPrices;
|
||||
var userPrice = userPakcagePrices?.FirstOrDefault(uPrice => uPrice.Package.Id == item.PackageId && uPrice.UserPrice.UserId == request.UserId)?.UserPrice;
|
||||
if (userPrice != null && userPrice.Id > 0)
|
||||
{
|
||||
userPrice.Status = 1;
|
||||
userPrice.UserPrice = item.BuyPriceDiscount / 100m * package.LinePrice;
|
||||
userPrice.RefundDayPrice = item.RefundDayPriceDiscount / 100m * product.RefundDayPrice;
|
||||
userPrice.Remark = schemaEntity.Name;
|
||||
userPrice.UserPrice = Math.Max(userPrice.UserPrice, package.MinPrice);
|
||||
userPrice.RefundDayPrice = Math.Max(userPrice.RefundDayPrice.Value, product.DayLimitPrice.Value);
|
||||
await m_ProductUserPriceService.Update(userPrice);
|
||||
}
|
||||
else
|
||||
{
|
||||
userPrice = new ProductUserPriceEntity()
|
||||
{
|
||||
PackageId = item.PackageId,
|
||||
ProductId = item.ProductId,
|
||||
Status = 1,
|
||||
Remark = schemaEntity.Name,
|
||||
TenantId = 0,
|
||||
UserId = request.UserId,
|
||||
UserPrice = item.BuyPriceDiscount / 100m * package.LinePrice,
|
||||
RefundDayPrice = item.RefundDayPriceDiscount / 100m * product.RefundDayPrice,
|
||||
};
|
||||
userPrice.UserPrice = Math.Max(userPrice.UserPrice, package.MinPrice);
|
||||
userPrice.RefundDayPrice = Math.Max(userPrice.RefundDayPrice.Value, product.DayLimitPrice.Value);
|
||||
await m_ProductUserPriceService.Add(userPrice);
|
||||
}
|
||||
}
|
||||
return Success(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/course/v{version:apiVersion}/scheme/[action]")]
|
||||
public class ProductSchemeController : HncoreControllerBase
|
||||
{
|
||||
private ProductService m_ProductService;
|
||||
private ProductPackageService m_ProductPackageService;
|
||||
private ProductUserPriceService m_ProductUserPriceService;
|
||||
private ProductPriceSchemeService m_PriceSchemeService;
|
||||
private ProductPriceDiscountService m_PriceDiscountService;
|
||||
public ProductSchemeController(ProductService _ProductServic
|
||||
, ProductPackageService _ProductPackageService
|
||||
, ProductUserPriceService _ProductUserPriceService
|
||||
,ProductPriceSchemeService _PriceSchemeService
|
||||
,ProductPriceDiscountService _PriceDiscountService
|
||||
)
|
||||
{
|
||||
m_ProductService = _ProductServic;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_ProductUserPriceService = _ProductUserPriceService;
|
||||
m_PriceSchemeService = _PriceSchemeService;
|
||||
m_PriceDiscountService = _PriceDiscountService;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]ProductPriceSchemeEntity request)
|
||||
{
|
||||
await m_PriceSchemeService.Add(request);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]ProductPriceSchemeEntity request)
|
||||
{
|
||||
var entity = await m_PriceSchemeService.GetById(request.Id);
|
||||
entity.Name = request.Name;
|
||||
entity.Remark = request.Remark;
|
||||
entity.discount = request.discount;
|
||||
entity.UpdateTime = DateTime.Now;
|
||||
await m_PriceSchemeService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
var flag = await m_PriceSchemeService.DeleteById(id);
|
||||
if (flag)
|
||||
return Success();
|
||||
else
|
||||
return Error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery]int id)
|
||||
{
|
||||
var data = await m_PriceSchemeService.GetById(id);
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<ProductPriceSchemeEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Name.Contains(request.KeyWord));
|
||||
}
|
||||
var ret = await m_PriceSchemeService.Page(request.PageIndex, request.PageSize, expr,true);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> GetProductDiscount(int id)
|
||||
{
|
||||
var ret = await this.m_PriceDiscountService.GetPriceDiscount(id);
|
||||
return Success(ret);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> PutProductDiscount([FromBody]ProductPriceDiscountEntity request)
|
||||
{
|
||||
var priceDiscountEntity = await m_PriceDiscountService.Query(m => m.PackageId == request.PackageId && m.SchemeId == request.SchemeId).FirstOrDefaultAsync();
|
||||
|
||||
if (priceDiscountEntity == null)
|
||||
{
|
||||
await m_PriceDiscountService.Add(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
priceDiscountEntity.BuyPriceDiscount = request.BuyPriceDiscount;
|
||||
priceDiscountEntity.RefundDayPriceDiscount = request.RefundDayPriceDiscount;
|
||||
await m_PriceDiscountService.Update(priceDiscountEntity);
|
||||
}
|
||||
return Success(1);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> SetUserDiscount([FromBody] SetUserDiscountRequest request)
|
||||
{
|
||||
var priceDiscountEntitys = await m_PriceDiscountService.Query(m => m.SchemeId == request.SchemeId).ToListAsync();
|
||||
var schemaEntity = await m_PriceSchemeService.GetById(request.SchemeId);
|
||||
var produccts = await m_ProductService.GetAll(true);
|
||||
var packages = await m_ProductPackageService.GetAll(true);
|
||||
|
||||
var userPrices = await m_ProductUserPriceService.GetPackageUserPrice(request.UserId);
|
||||
foreach (var item in priceDiscountEntitys)
|
||||
{
|
||||
var product = produccts.FirstOrDefault(m => m.Id == item.ProductId);
|
||||
var package = packages.FirstOrDefault(m => m.Id == item.PackageId);
|
||||
var userPakcagePrices = userPrices.FirstOrDefault(m => m.Product.Id == item.ProductId)?.PackageUserPrices;
|
||||
var userPrice = userPakcagePrices?.FirstOrDefault(uPrice => uPrice.Package.Id == item.PackageId && uPrice.UserPrice.UserId == request.UserId)?.UserPrice;
|
||||
if (userPrice != null && userPrice.Id > 0)
|
||||
{
|
||||
userPrice.Status = 1;
|
||||
userPrice.UserPrice = item.BuyPriceDiscount / 100m * package.LinePrice;
|
||||
userPrice.RefundDayPrice = item.RefundDayPriceDiscount / 100m * product.RefundDayPrice;
|
||||
userPrice.Remark = schemaEntity.Name;
|
||||
userPrice.UserPrice = Math.Max(userPrice.UserPrice, package.MinPrice);
|
||||
userPrice.RefundDayPrice = Math.Max(userPrice.RefundDayPrice.Value, product.DayLimitPrice.Value);
|
||||
await m_ProductUserPriceService.Update(userPrice);
|
||||
}
|
||||
else
|
||||
{
|
||||
userPrice = new ProductUserPriceEntity()
|
||||
{
|
||||
PackageId = item.PackageId,
|
||||
ProductId = item.ProductId,
|
||||
Status = 1,
|
||||
Remark = schemaEntity.Name,
|
||||
TenantId = 0,
|
||||
UserId = request.UserId,
|
||||
UserPrice = item.BuyPriceDiscount / 100m * package.LinePrice,
|
||||
RefundDayPrice = item.RefundDayPriceDiscount / 100m * product.RefundDayPrice,
|
||||
};
|
||||
userPrice.UserPrice = Math.Max(userPrice.UserPrice, package.MinPrice);
|
||||
userPrice.RefundDayPrice = Math.Max(userPrice.RefundDayPrice.Value, product.DayLimitPrice.Value);
|
||||
await m_ProductUserPriceService.Add(userPrice);
|
||||
}
|
||||
}
|
||||
return Success(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ArticleEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public ArticleCatalog CatalogId { get; set; } = ArticleCatalog.Top;
|
||||
public string SubTitle { get; set; }
|
||||
public string Thumb { get; set; }
|
||||
public string Keyword { get; set; }
|
||||
public string Content { get; set; }
|
||||
public int AccessCount { get; set; }
|
||||
public int Publish { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
public int LinkType { get; set; }
|
||||
public int LinkId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ArticleEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public ArticleCatalog CatalogId { get; set; } = ArticleCatalog.Top;
|
||||
public string SubTitle { get; set; }
|
||||
public string Thumb { get; set; }
|
||||
public string Keyword { get; set; }
|
||||
public string Content { get; set; }
|
||||
public int AccessCount { get; set; }
|
||||
public int Publish { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
public int LinkType { get; set; }
|
||||
public int LinkId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,154 +1,154 @@
|
||||
using Hncore.Infrastructure.EF;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class CourseContext : DbContextBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="options">上下文实体</param>
|
||||
/// <param name="httpContextAccessor">http请求上下文</param>
|
||||
public CourseContext(DbContextOptions<CourseContext> options, IHttpContextAccessor httpContextAccessor) :
|
||||
base(options, httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<ArticleEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("article");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<ProductEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<ProductAccountEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_account");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
entity.Ignore(e => e.RestTime);
|
||||
entity.Ignore(e => e.RestDay);
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<UserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("user");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductPackageEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_package");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductOrderEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_order");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductOrderItemEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_order_items");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductUserPriceEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_user_price");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductPackageUnitEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_package_unit");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductAccountChargeEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_account_recharge");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductRouteEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_route");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<WxAppUserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("wx_app_user");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductPriceSchemeEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_price_scheme");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductPriceDiscountEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_price_discount");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
//代理
|
||||
modelBuilder.Entity<AgentUserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("agent_user");
|
||||
|
||||
entity.HasKey(p => p.id);
|
||||
entity.Property(e => e.id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<AgentScoreEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("agent_score");
|
||||
|
||||
entity.HasKey(p => p.id);
|
||||
entity.Property(e => e.id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<AgentPriceEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("agent_price");
|
||||
|
||||
entity.HasKey(p => p.id);
|
||||
entity.Property(e => e.id).ValueGeneratedOnAdd();
|
||||
});
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.EF;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class CourseContext : DbContextBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="options">上下文实体</param>
|
||||
/// <param name="httpContextAccessor">http请求上下文</param>
|
||||
public CourseContext(DbContextOptions<CourseContext> options, IHttpContextAccessor httpContextAccessor) :
|
||||
base(options, httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<ArticleEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("article");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<ProductEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<ProductAccountEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_account");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
entity.Ignore(e => e.RestTime);
|
||||
entity.Ignore(e => e.RestDay);
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<UserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("user");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductPackageEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_package");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ProductOrderEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_order");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductOrderItemEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_order_items");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductUserPriceEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_user_price");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductPackageUnitEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_package_unit");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductAccountChargeEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_account_recharge");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductRouteEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_route");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<WxAppUserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("wx_app_user");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductPriceSchemeEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_price_scheme");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<ProductPriceDiscountEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("product_price_discount");
|
||||
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
//代理
|
||||
modelBuilder.Entity<AgentUserEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("agent_user");
|
||||
|
||||
entity.HasKey(p => p.id);
|
||||
entity.Property(e => e.id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<AgentScoreEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("agent_score");
|
||||
|
||||
entity.HasKey(p => p.id);
|
||||
entity.Property(e => e.id).ValueGeneratedOnAdd();
|
||||
});
|
||||
modelBuilder.Entity<AgentPriceEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("agent_price");
|
||||
|
||||
entity.HasKey(p => p.id);
|
||||
entity.Property(e => e.id).ValueGeneratedOnAdd();
|
||||
});
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,207 +1,207 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public enum AccountType
|
||||
{
|
||||
[DisplayName("新开")]
|
||||
New = 1,
|
||||
[DisplayName("批量新开")]
|
||||
News = 2,
|
||||
[DisplayName("续费")]
|
||||
AgainBuy = 3,
|
||||
[DisplayName("批量续费")]
|
||||
AgainBuys = 4,
|
||||
|
||||
[DisplayName("原系统认证")]
|
||||
Origin =100,
|
||||
|
||||
[DisplayName("测试账号")]
|
||||
Test = 200,
|
||||
}
|
||||
|
||||
public enum OrderType
|
||||
{
|
||||
[DisplayName("新开")]
|
||||
New = 1,
|
||||
[DisplayName("批量新开")]
|
||||
News = 2,
|
||||
[DisplayName("续费")]
|
||||
AgainBuy = 3,
|
||||
[DisplayName("批量续费")]
|
||||
AgainBuys = 4,
|
||||
[DisplayName("退款")]
|
||||
Refund = 5,
|
||||
}
|
||||
public enum ClientType
|
||||
{
|
||||
WxMp = 1,
|
||||
WxMiniApp = 2,
|
||||
Pc = 3,
|
||||
}
|
||||
|
||||
public enum PayType
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认
|
||||
/// </summary>
|
||||
[Display(Name = "默认")]
|
||||
None = 10,
|
||||
/// <summary>
|
||||
/// 余额
|
||||
/// </summary>
|
||||
[Display(Name = "余额")]
|
||||
Amount = 10,
|
||||
|
||||
/// <summary>
|
||||
/// 微信
|
||||
/// </summary>
|
||||
[Display(Name = "微信")]
|
||||
Wechat = 70,
|
||||
/// <summary>
|
||||
/// 支付宝
|
||||
/// </summary>
|
||||
[Display(Name = "支付宝")]
|
||||
Ali = 100,
|
||||
}
|
||||
|
||||
public enum OrderStatus
|
||||
{
|
||||
[Display(Name = "默认")]
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 待支付
|
||||
/// </summary>
|
||||
[Display(Name = "待付款")]
|
||||
NoPay = 10,
|
||||
/// <summary>
|
||||
/// 已支付
|
||||
/// </summary>
|
||||
[Display(Name = "已付款")]
|
||||
PayOk = 20,
|
||||
/// <summary>
|
||||
/// 申请退款
|
||||
/// </summary>
|
||||
[Display(Name = "申请退款")]
|
||||
RequestRefund = 30,
|
||||
/// <summary>
|
||||
/// 人工退款
|
||||
/// </summary>
|
||||
[Display(Name = "人工退款")]
|
||||
UserRefundOver = 40,
|
||||
/// <summary>
|
||||
/// 自送退款
|
||||
/// </summary>
|
||||
[Display(Name = "自动退款")]
|
||||
AutoRefundOver = 50,
|
||||
/// <summary>
|
||||
/// 订单超时关闭
|
||||
/// </summary>
|
||||
[Display(Name = "超时关闭")]
|
||||
TimeOutClose = 80,
|
||||
|
||||
/// <summary>
|
||||
/// 订单完成
|
||||
/// </summary>
|
||||
[Display(Name = "订单完成")]
|
||||
Complete = 90,
|
||||
|
||||
}
|
||||
|
||||
public enum PackageType
|
||||
{
|
||||
[DisplayName("基本套餐")]
|
||||
Base = 1,
|
||||
[DisplayName("组合套餐")]
|
||||
Group = 2
|
||||
}
|
||||
|
||||
public enum ChargeOperationType
|
||||
{
|
||||
[DisplayName("新开")]
|
||||
New = 1,
|
||||
[DisplayName("批量新开")]
|
||||
News = 2,
|
||||
[DisplayName("续费")]
|
||||
ReNew = 3,
|
||||
[DisplayName("退款")]
|
||||
Refund = 4,
|
||||
}
|
||||
|
||||
public enum ChargeStatus
|
||||
{
|
||||
[DisplayName("成功")]
|
||||
Ok = 1,
|
||||
[DisplayName("失败")]
|
||||
Faild = 2,
|
||||
[DisplayName("关闭")]
|
||||
Close = 3,
|
||||
[DisplayName("超时")]
|
||||
Outtime = 4,
|
||||
}
|
||||
|
||||
public enum AccountChargeStatus
|
||||
{
|
||||
[DisplayName("正常")]
|
||||
Normal = 1,
|
||||
[DisplayName("异常")]
|
||||
Exception = 2,
|
||||
}
|
||||
|
||||
public enum AccountStatus
|
||||
{
|
||||
[DisplayName("正常")]
|
||||
Normal = 1,
|
||||
[DisplayName("退款")]
|
||||
Refund = 2,
|
||||
}
|
||||
|
||||
public enum ArticleCatalog
|
||||
{
|
||||
|
||||
[DisplayName("聚IP头条")]
|
||||
Top = 1,
|
||||
[DisplayName("优惠活动")]
|
||||
Activity = 2,
|
||||
[DisplayName("常见问题")]
|
||||
QA = 3,
|
||||
[DisplayName("新手教程")]
|
||||
Help = 4,
|
||||
}
|
||||
|
||||
public enum PayChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信H5
|
||||
/// </summary>
|
||||
[Display(Name = "微信H5")]
|
||||
WxH5 = 10,
|
||||
/// <summary>
|
||||
/// 微信公众号
|
||||
/// </summary>
|
||||
[Display(Name = "微信公众号")]
|
||||
WxMp = 20,
|
||||
|
||||
/// <summary>
|
||||
/// 微信公众号
|
||||
/// </summary>
|
||||
[Display(Name = "微信Pc")]
|
||||
WxPc = 30,
|
||||
|
||||
/// <summary>
|
||||
/// 支付宝H5
|
||||
/// </summary>
|
||||
[Display(Name = "支付宝H5")]
|
||||
AliH5 = 40,
|
||||
/// <summary>
|
||||
/// 支付宝
|
||||
/// </summary>
|
||||
[Display(Name = "支付宝Pc")]
|
||||
AliPc = 50,
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public enum AccountType
|
||||
{
|
||||
[DisplayName("新开")]
|
||||
New = 1,
|
||||
[DisplayName("批量新开")]
|
||||
News = 2,
|
||||
[DisplayName("续费")]
|
||||
AgainBuy = 3,
|
||||
[DisplayName("批量续费")]
|
||||
AgainBuys = 4,
|
||||
|
||||
[DisplayName("原系统认证")]
|
||||
Origin =100,
|
||||
|
||||
[DisplayName("测试账号")]
|
||||
Test = 200,
|
||||
}
|
||||
|
||||
public enum OrderType
|
||||
{
|
||||
[DisplayName("新开")]
|
||||
New = 1,
|
||||
[DisplayName("批量新开")]
|
||||
News = 2,
|
||||
[DisplayName("续费")]
|
||||
AgainBuy = 3,
|
||||
[DisplayName("批量续费")]
|
||||
AgainBuys = 4,
|
||||
[DisplayName("退款")]
|
||||
Refund = 5,
|
||||
}
|
||||
public enum ClientType
|
||||
{
|
||||
WxMp = 1,
|
||||
WxMiniApp = 2,
|
||||
Pc = 3,
|
||||
}
|
||||
|
||||
public enum PayType
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认
|
||||
/// </summary>
|
||||
[Display(Name = "默认")]
|
||||
None = 10,
|
||||
/// <summary>
|
||||
/// 余额
|
||||
/// </summary>
|
||||
[Display(Name = "余额")]
|
||||
Amount = 10,
|
||||
|
||||
/// <summary>
|
||||
/// 微信
|
||||
/// </summary>
|
||||
[Display(Name = "微信")]
|
||||
Wechat = 70,
|
||||
/// <summary>
|
||||
/// 支付宝
|
||||
/// </summary>
|
||||
[Display(Name = "支付宝")]
|
||||
Ali = 100,
|
||||
}
|
||||
|
||||
public enum OrderStatus
|
||||
{
|
||||
[Display(Name = "默认")]
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 待支付
|
||||
/// </summary>
|
||||
[Display(Name = "待付款")]
|
||||
NoPay = 10,
|
||||
/// <summary>
|
||||
/// 已支付
|
||||
/// </summary>
|
||||
[Display(Name = "已付款")]
|
||||
PayOk = 20,
|
||||
/// <summary>
|
||||
/// 申请退款
|
||||
/// </summary>
|
||||
[Display(Name = "申请退款")]
|
||||
RequestRefund = 30,
|
||||
/// <summary>
|
||||
/// 人工退款
|
||||
/// </summary>
|
||||
[Display(Name = "人工退款")]
|
||||
UserRefundOver = 40,
|
||||
/// <summary>
|
||||
/// 自送退款
|
||||
/// </summary>
|
||||
[Display(Name = "自动退款")]
|
||||
AutoRefundOver = 50,
|
||||
/// <summary>
|
||||
/// 订单超时关闭
|
||||
/// </summary>
|
||||
[Display(Name = "超时关闭")]
|
||||
TimeOutClose = 80,
|
||||
|
||||
/// <summary>
|
||||
/// 订单完成
|
||||
/// </summary>
|
||||
[Display(Name = "订单完成")]
|
||||
Complete = 90,
|
||||
|
||||
}
|
||||
|
||||
public enum PackageType
|
||||
{
|
||||
[DisplayName("基本套餐")]
|
||||
Base = 1,
|
||||
[DisplayName("组合套餐")]
|
||||
Group = 2
|
||||
}
|
||||
|
||||
public enum ChargeOperationType
|
||||
{
|
||||
[DisplayName("新开")]
|
||||
New = 1,
|
||||
[DisplayName("批量新开")]
|
||||
News = 2,
|
||||
[DisplayName("续费")]
|
||||
ReNew = 3,
|
||||
[DisplayName("退款")]
|
||||
Refund = 4,
|
||||
}
|
||||
|
||||
public enum ChargeStatus
|
||||
{
|
||||
[DisplayName("成功")]
|
||||
Ok = 1,
|
||||
[DisplayName("失败")]
|
||||
Faild = 2,
|
||||
[DisplayName("关闭")]
|
||||
Close = 3,
|
||||
[DisplayName("超时")]
|
||||
Outtime = 4,
|
||||
}
|
||||
|
||||
public enum AccountChargeStatus
|
||||
{
|
||||
[DisplayName("正常")]
|
||||
Normal = 1,
|
||||
[DisplayName("异常")]
|
||||
Exception = 2,
|
||||
}
|
||||
|
||||
public enum AccountStatus
|
||||
{
|
||||
[DisplayName("正常")]
|
||||
Normal = 1,
|
||||
[DisplayName("退款")]
|
||||
Refund = 2,
|
||||
}
|
||||
|
||||
public enum ArticleCatalog
|
||||
{
|
||||
|
||||
[DisplayName("聚IP头条")]
|
||||
Top = 1,
|
||||
[DisplayName("优惠活动")]
|
||||
Activity = 2,
|
||||
[DisplayName("常见问题")]
|
||||
QA = 3,
|
||||
[DisplayName("新手教程")]
|
||||
Help = 4,
|
||||
}
|
||||
|
||||
public enum PayChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信H5
|
||||
/// </summary>
|
||||
[Display(Name = "微信H5")]
|
||||
WxH5 = 10,
|
||||
/// <summary>
|
||||
/// 微信公众号
|
||||
/// </summary>
|
||||
[Display(Name = "微信公众号")]
|
||||
WxMp = 20,
|
||||
|
||||
/// <summary>
|
||||
/// 微信公众号
|
||||
/// </summary>
|
||||
[Display(Name = "微信Pc")]
|
||||
WxPc = 30,
|
||||
|
||||
/// <summary>
|
||||
/// 支付宝H5
|
||||
/// </summary>
|
||||
[Display(Name = "支付宝H5")]
|
||||
AliH5 = 40,
|
||||
/// <summary>
|
||||
/// 支付宝
|
||||
/// </summary>
|
||||
[Display(Name = "支付宝Pc")]
|
||||
AliPc = 50,
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductAccountChargeEntity : EntityWithTime<int>
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public int? ProductId { get; set; }
|
||||
public string ProductGroup { get; set; }
|
||||
public int? PackageId { get; set; }
|
||||
public string PackageOriginKey { get; set; }
|
||||
public string Account { get; set; }
|
||||
public int AccountType { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public int ConnectCount { get; set; } = 0;
|
||||
public ChargeStatus Status { get; set; } = 0;
|
||||
public int DayCount { get; set; } = 1;
|
||||
public int TryTimes { get; set; } = 1;
|
||||
public ChargeOperationType OperationType { get; set; } = ChargeOperationType.New;
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductAccountChargeEntity : EntityWithTime<int>
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public int? ProductId { get; set; }
|
||||
public string ProductGroup { get; set; }
|
||||
public int? PackageId { get; set; }
|
||||
public string PackageOriginKey { get; set; }
|
||||
public string Account { get; set; }
|
||||
public int AccountType { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public int ConnectCount { get; set; } = 0;
|
||||
public ChargeStatus Status { get; set; } = 0;
|
||||
public int DayCount { get; set; } = 1;
|
||||
public int TryTimes { get; set; } = 1;
|
||||
public ChargeOperationType OperationType { get; set; } = ChargeOperationType.New;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductAccountEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public int? ProductId { get; set; }
|
||||
public int? PackageId { get; set; }
|
||||
public string UserCode { get; set; }
|
||||
public string UserPhone { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
public int? AccountType { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public int ConnectCount { get; set; } = 0;
|
||||
public AccountStatus Status { get; set; } = AccountStatus.Normal;
|
||||
public AccountChargeStatus? ChargeStatus { get; set; } = AccountChargeStatus.Normal;
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
|
||||
public string RestTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EndTime < DateTime.Now)
|
||||
return "已过期";
|
||||
var bTime = StartTime > DateTime.Now ? StartTime : DateTime.Now;
|
||||
var time = (EndTime - bTime).Value;
|
||||
return time.ToString(@"d\天hh\时mm\分");
|
||||
}
|
||||
}
|
||||
public int RestDay
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EndTime < DateTime.Now)
|
||||
return 0;
|
||||
var bTime = StartTime > DateTime.Now ? StartTime : DateTime.Now;
|
||||
var time = (EndTime - bTime).Value;
|
||||
return time.Days;
|
||||
}
|
||||
}
|
||||
|
||||
public string Raw { get; set; }
|
||||
public int agent_id {get; set;}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductAccountEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public int? ProductId { get; set; }
|
||||
public int? PackageId { get; set; }
|
||||
public string UserCode { get; set; }
|
||||
public string UserPhone { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
public int? AccountType { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public int ConnectCount { get; set; } = 0;
|
||||
public AccountStatus Status { get; set; } = AccountStatus.Normal;
|
||||
public AccountChargeStatus? ChargeStatus { get; set; } = AccountChargeStatus.Normal;
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
|
||||
public string RestTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EndTime < DateTime.Now)
|
||||
return "已过期";
|
||||
var bTime = StartTime > DateTime.Now ? StartTime : DateTime.Now;
|
||||
var time = (EndTime - bTime).Value;
|
||||
return time.ToString(@"d\天hh\时mm\分");
|
||||
}
|
||||
}
|
||||
public int RestDay
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EndTime < DateTime.Now)
|
||||
return 0;
|
||||
var bTime = StartTime > DateTime.Now ? StartTime : DateTime.Now;
|
||||
var time = (EndTime - bTime).Value;
|
||||
return time.Days;
|
||||
}
|
||||
}
|
||||
|
||||
public string Raw { get; set; }
|
||||
public int agent_id {get; set;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Sort { get; set; } = 0;
|
||||
public string Account { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public int? Status { get; set; } = 0;
|
||||
public string LoginUrl { get; set; }
|
||||
public string LoginCodeUrl { get; set; }
|
||||
public string RefrushTokenUrl { get; set; }
|
||||
public string PcClientDownloadUrl { get; set; }
|
||||
public string DroidDownloadUrl { get; set; }
|
||||
public string IosDownloadUrl { get; set; }
|
||||
public string SimulatorDownloadUrl { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Profile { get; set; }
|
||||
public string GroupNO { get; set; }
|
||||
public string Token { get; set; }
|
||||
|
||||
public int? AutoRefund { get; set; } = 0;
|
||||
|
||||
public decimal? RefundDayPrice { get; set; } = 0;
|
||||
public decimal? DayLimitPrice { get; set; } = 0;
|
||||
|
||||
public int OnLine { get; set; } = 1;
|
||||
|
||||
public string L2TPPwd { get; set; } = "";
|
||||
|
||||
public string SSTPPort { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 记录添加(创建)时间
|
||||
/// </summary>
|
||||
public virtual DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 记录最后更新时间
|
||||
/// </summary>
|
||||
public virtual DateTime UpdateTime { get; set; } = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Sort { get; set; } = 0;
|
||||
public string Account { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public int? Status { get; set; } = 0;
|
||||
public string LoginUrl { get; set; }
|
||||
public string LoginCodeUrl { get; set; }
|
||||
public string RefrushTokenUrl { get; set; }
|
||||
public string PcClientDownloadUrl { get; set; }
|
||||
public string DroidDownloadUrl { get; set; }
|
||||
public string IosDownloadUrl { get; set; }
|
||||
public string SimulatorDownloadUrl { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Profile { get; set; }
|
||||
public string GroupNO { get; set; }
|
||||
public string Token { get; set; }
|
||||
|
||||
public int? AutoRefund { get; set; } = 0;
|
||||
|
||||
public decimal? RefundDayPrice { get; set; } = 0;
|
||||
public decimal? DayLimitPrice { get; set; } = 0;
|
||||
|
||||
public int OnLine { get; set; } = 1;
|
||||
|
||||
public string L2TPPwd { get; set; } = "";
|
||||
|
||||
public string SSTPPort { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 记录添加(创建)时间
|
||||
/// </summary>
|
||||
public virtual DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 记录最后更新时间
|
||||
/// </summary>
|
||||
public virtual DateTime UpdateTime { get; set; } = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductOrderEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
public int? CouponId { get; set; } = 0;
|
||||
public decimal? CouponAmount { get; set; }
|
||||
public string OriginKey { get; set; }
|
||||
public string OrderName { get; set; }
|
||||
public string OrderNo { get; set; }
|
||||
public string TradeNo { get; set; }
|
||||
public OrderStatus OrderState { get; set; }
|
||||
public OrderType OrderType { get; set; }
|
||||
public PayType PayType { get; set; }
|
||||
|
||||
public PayChannel PayChannel { get; set; } = PayChannel.WxPc;
|
||||
public int PayState { get; set; }
|
||||
public int ConnectCount { get; set; }
|
||||
public decimal OrderAmount { get; set; }
|
||||
public decimal PaymentAmount { get; set; }
|
||||
public decimal? AccountPayAmount { get; set; } = 0;
|
||||
public decimal? OtherPayAmount { get; set; } = 0;
|
||||
public decimal? DayPrice { get; set; } = 0;
|
||||
public int DayCount { get; set; } = 1;
|
||||
public int ClientType { get; set; }
|
||||
public int ChannelType { get; set; }
|
||||
public string Channel { get; set; }
|
||||
public int AccountCount { get; set; } = 1;
|
||||
public string Remark { get; set; }
|
||||
public string Accounts { get; set; }
|
||||
public string AccountPwd { get; set; }
|
||||
public int RefundCount { get; set; }
|
||||
public decimal RefundAmount { get; set; }
|
||||
|
||||
public string RefundRestTime { get; set; }
|
||||
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
public int? IsAutoRefund { get; set; } = 0;
|
||||
|
||||
public decimal? BackAmount { get; set; } = 0;
|
||||
public string RefundReason { get; set; }
|
||||
public int agent_id {get; set;}
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductOrderEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
public int? CouponId { get; set; } = 0;
|
||||
public decimal? CouponAmount { get; set; }
|
||||
public string OriginKey { get; set; }
|
||||
public string OrderName { get; set; }
|
||||
public string OrderNo { get; set; }
|
||||
public string TradeNo { get; set; }
|
||||
public OrderStatus OrderState { get; set; }
|
||||
public OrderType OrderType { get; set; }
|
||||
public PayType PayType { get; set; }
|
||||
|
||||
public PayChannel PayChannel { get; set; } = PayChannel.WxPc;
|
||||
public int PayState { get; set; }
|
||||
public int ConnectCount { get; set; }
|
||||
public decimal OrderAmount { get; set; }
|
||||
public decimal PaymentAmount { get; set; }
|
||||
public decimal? AccountPayAmount { get; set; } = 0;
|
||||
public decimal? OtherPayAmount { get; set; } = 0;
|
||||
public decimal? DayPrice { get; set; } = 0;
|
||||
public int DayCount { get; set; } = 1;
|
||||
public int ClientType { get; set; }
|
||||
public int ChannelType { get; set; }
|
||||
public string Channel { get; set; }
|
||||
public int AccountCount { get; set; } = 1;
|
||||
public string Remark { get; set; }
|
||||
public string Accounts { get; set; }
|
||||
public string AccountPwd { get; set; }
|
||||
public int RefundCount { get; set; }
|
||||
public decimal RefundAmount { get; set; }
|
||||
|
||||
public string RefundRestTime { get; set; }
|
||||
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
public int? IsAutoRefund { get; set; } = 0;
|
||||
|
||||
public decimal? BackAmount { get; set; } = 0;
|
||||
public string RefundReason { get; set; }
|
||||
public int agent_id {get; set;}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductOrderItemEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string AccountPwd { get; set; }
|
||||
public int ConnectCount { get; set; }
|
||||
public int AccountType { get; set; }
|
||||
public int StartNum { get; set; }
|
||||
public int EndNum { get; set; }
|
||||
public string OrderNo { get; set; }
|
||||
public OrderStatus OrderState { get; set; }
|
||||
public OrderType OrderType { get; set; }
|
||||
public PayType PayType { get; set; }
|
||||
public int PayState { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
public decimal DayPrice { get; set; }
|
||||
public int DayCount { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductOrderItemEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string AccountPwd { get; set; }
|
||||
public int ConnectCount { get; set; }
|
||||
public int AccountType { get; set; }
|
||||
public int StartNum { get; set; }
|
||||
public int EndNum { get; set; }
|
||||
public string OrderNo { get; set; }
|
||||
public OrderStatus OrderState { get; set; }
|
||||
public OrderType OrderType { get; set; }
|
||||
public PayType PayType { get; set; }
|
||||
public int PayState { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
public decimal DayPrice { get; set; }
|
||||
public int DayCount { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPackageEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public PackageType PackageType { get; set; } = PackageType.Base;
|
||||
public string Name { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Status { get; set; } = 0;
|
||||
public string Profile { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal LinePrice { get; set; }
|
||||
public decimal DayPrice { get; set; }
|
||||
public decimal MinPrice { get; set; }
|
||||
public int DayCount { get; set; } = 1;
|
||||
public string OriginKey { get; set; }
|
||||
public string OriginName { get; set; }
|
||||
|
||||
public int? IsTest { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPackageEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public PackageType PackageType { get; set; } = PackageType.Base;
|
||||
public string Name { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Status { get; set; } = 0;
|
||||
public string Profile { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public decimal LinePrice { get; set; }
|
||||
public decimal DayPrice { get; set; }
|
||||
public decimal MinPrice { get; set; }
|
||||
public int DayCount { get; set; } = 1;
|
||||
public string OriginKey { get; set; }
|
||||
public string OriginName { get; set; }
|
||||
|
||||
public int? IsTest { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPackageUnitEntity : Entity<int>
|
||||
{
|
||||
public int PackageId { get; set; }
|
||||
public int BasePackageId { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPackageUnitEntity : Entity<int>
|
||||
{
|
||||
public int PackageId { get; set; }
|
||||
public int BasePackageId { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPriceDiscountEntity : EntityWithDelete<int>
|
||||
{
|
||||
public int SchemeId { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int Status { get; set; } = 0;
|
||||
public int BuyPriceDiscount { get; set; } = 0;
|
||||
public int RefundDayPriceDiscount { get; set; } = 0;
|
||||
public string Remark { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPriceDiscountEntity : EntityWithDelete<int>
|
||||
{
|
||||
public int SchemeId { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int Status { get; set; } = 0;
|
||||
public int BuyPriceDiscount { get; set; } = 0;
|
||||
public int RefundDayPriceDiscount { get; set; } = 0;
|
||||
public string Remark { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPriceSchemeEntity : EntityWithTime<int>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public int discount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductPriceSchemeEntity : EntityWithTime<int>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public int discount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductRouteEntity : EntityWithDelete<int>
|
||||
{
|
||||
public int? ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public string Province { get; set; }
|
||||
public string City { get; set; }
|
||||
public int Sort { get; set; } = 0;
|
||||
public string Name { get; set; }
|
||||
public string ServerUrl { get; set; }
|
||||
public string Status { get; set; }
|
||||
|
||||
public string LineType { get; set; }
|
||||
public string BandWidth { get; set; }
|
||||
public string IpRemark { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public int OnLine { get; set; } = 1;
|
||||
public string KeyWord { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductRouteEntity : EntityWithDelete<int>
|
||||
{
|
||||
public int? ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public string Province { get; set; }
|
||||
public string City { get; set; }
|
||||
public int Sort { get; set; } = 0;
|
||||
public string Name { get; set; }
|
||||
public string ServerUrl { get; set; }
|
||||
public string Status { get; set; }
|
||||
|
||||
public string LineType { get; set; }
|
||||
public string BandWidth { get; set; }
|
||||
public string IpRemark { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public int OnLine { get; set; } = 1;
|
||||
public string KeyWord { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductUserPriceEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int Status { get; set; } = 0;
|
||||
public decimal UserPrice { get; set; }
|
||||
public decimal? RefundDayPrice { get; set; } = 0;
|
||||
public string Remark { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class ProductUserPriceEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int Status { get; set; } = 0;
|
||||
public decimal UserPrice { get; set; }
|
||||
public decimal? RefundDayPrice { get; set; } = 0;
|
||||
public string Remark { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class UserEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// <summary>
|
||||
public int TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管理员登录名[16
|
||||
/// </summary>
|
||||
public string LoginCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录密码[20]
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
public int discount_id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 微信昵称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信头像
|
||||
/// </summary>
|
||||
public string Phone { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 注册来源
|
||||
/// </summary>
|
||||
public string Profile { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int Enabled { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 头像地址[30
|
||||
/// </summary>
|
||||
public string PhotoUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否主管理员权限
|
||||
/// </summary>
|
||||
public DateTime? LastLoginDate { get; set; } = DateTime.Now;
|
||||
public string pay_time { get; set; }
|
||||
|
||||
public int Sex { get; set; }
|
||||
|
||||
//1:管理员添加 2:自己注册 3:来自淘宝
|
||||
public int CreateType { get; set; }
|
||||
|
||||
public int ProductAccountCount { get; set; }
|
||||
|
||||
public int ExpiredProductAccountCount { get; set; }
|
||||
|
||||
public decimal RestAmount { get; set; }
|
||||
|
||||
public decimal ConsumeAmount { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
public string Wx { get; set; }
|
||||
public string QQ { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string TaoBao { get; set; }
|
||||
public string WangWang { get; set; }
|
||||
|
||||
public int? TestCountLimit { get; set; } = 0;
|
||||
public int? UseTestCount { get; set; } = 0;
|
||||
|
||||
public int? ManagerId { get; set; } = 0;
|
||||
public string ManagerName { get; set; }
|
||||
public int is_verify { get; set; }
|
||||
public int agent_id {get; set;}
|
||||
public string apikey {get; set;}
|
||||
public string id_code {get; set;}
|
||||
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class UserEntity : EntityWithTime<int>, ITenant
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// <summary>
|
||||
public int TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管理员登录名[16
|
||||
/// </summary>
|
||||
public string LoginCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录密码[20]
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
public int discount_id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 微信昵称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信头像
|
||||
/// </summary>
|
||||
public string Phone { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 注册来源
|
||||
/// </summary>
|
||||
public string Profile { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int Enabled { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 头像地址[30
|
||||
/// </summary>
|
||||
public string PhotoUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否主管理员权限
|
||||
/// </summary>
|
||||
public DateTime? LastLoginDate { get; set; } = DateTime.Now;
|
||||
public string pay_time { get; set; }
|
||||
|
||||
public int Sex { get; set; }
|
||||
|
||||
//1:管理员添加 2:自己注册 3:来自淘宝
|
||||
public int CreateType { get; set; }
|
||||
|
||||
public int ProductAccountCount { get; set; }
|
||||
|
||||
public int ExpiredProductAccountCount { get; set; }
|
||||
|
||||
public decimal RestAmount { get; set; }
|
||||
|
||||
public decimal ConsumeAmount { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
public string Wx { get; set; }
|
||||
public string QQ { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string TaoBao { get; set; }
|
||||
public string WangWang { get; set; }
|
||||
|
||||
public int? TestCountLimit { get; set; } = 0;
|
||||
public int? UseTestCount { get; set; } = 0;
|
||||
|
||||
public int? ManagerId { get; set; } = 0;
|
||||
public string ManagerName { get; set; }
|
||||
public int is_verify { get; set; }
|
||||
public int agent_id {get; set;}
|
||||
public string apikey {get; set;}
|
||||
public string id_code {get; set;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class WxAppEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
public string OpenAppId { get; set; }
|
||||
public string Appid { get; set; }
|
||||
public int AppType { get; set; }
|
||||
|
||||
public string HeadImg { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string PrincipalName { get; set; }
|
||||
public string Bussinessinfo { get; set; }
|
||||
public string Createtime { get; set; }
|
||||
|
||||
public int AuthorizerState { get; set; }
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
public int ExpiresIn { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class WxAppEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
public string OpenAppId { get; set; }
|
||||
public string Appid { get; set; }
|
||||
public int AppType { get; set; }
|
||||
|
||||
public string HeadImg { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string PrincipalName { get; set; }
|
||||
public string Bussinessinfo { get; set; }
|
||||
public string Createtime { get; set; }
|
||||
|
||||
public int AuthorizerState { get; set; }
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
public int ExpiresIn { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class WxAppUserEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
public string Appid { get; set; }
|
||||
public int AppType { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Unionid { get; set; }
|
||||
public string Openid { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string HeadImgUrl { get; set; }
|
||||
public int Sex { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Country { get; set; }
|
||||
public int IsSubscribe { get; set; }
|
||||
public int InvateUserId { get; set; }
|
||||
public DateTime Createtime { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime UpdateTime{ get; set; } = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Domain
|
||||
{
|
||||
public partial class WxAppUserEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
public string Appid { get; set; }
|
||||
public int AppType { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string Unionid { get; set; }
|
||||
public string Openid { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string HeadImgUrl { get; set; }
|
||||
public int Sex { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Country { get; set; }
|
||||
public int IsSubscribe { get; set; }
|
||||
public int InvateUserId { get; set; }
|
||||
public DateTime Createtime { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime UpdateTime{ get; set; } = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;1998</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.9.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App">
|
||||
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
|
||||
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Extension\" />
|
||||
<Folder Include="Properties\" />
|
||||
<Folder Include="Request\Article\" />
|
||||
<Folder Include="Utils\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Infrastructure\Hncore.Infrastructure\Hncore.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\ServiceClient\PaymentCenterClient\PaymentCenterClient.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\WxApi\WxApi.csproj" />
|
||||
<ProjectReference Include="..\Hncore.Pass.BaseInfo\Hncore.Pass.BaseInfo.csproj" />
|
||||
<ProjectReference Include="..\Hncore.Pass.Sells\Hncore.Pass.Sells.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;1998</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.9.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App">
|
||||
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
|
||||
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Extension\" />
|
||||
<Folder Include="Properties\" />
|
||||
<Folder Include="Request\Article\" />
|
||||
<Folder Include="Utils\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Infrastructure\Hncore.Infrastructure\Hncore.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\ServiceClient\PaymentCenterClient\PaymentCenterClient.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\WxApi\WxApi.csproj" />
|
||||
<ProjectReference Include="..\Hncore.Pass.BaseInfo\Hncore.Pass.BaseInfo.csproj" />
|
||||
<ProjectReference Include="..\Hncore.Pass.Sells\Hncore.Pass.Sells.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 充值失败尝试job
|
||||
/// </summary>
|
||||
public class ChargeTryJob
|
||||
{
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
LogHelper.Trace("开始处理订单");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var agentService = scope.ServiceProvider.GetService<AgentService>();
|
||||
await agentService.FaildTry();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理订单失败", e);
|
||||
break;
|
||||
}
|
||||
await Task.Delay(10 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 充值失败尝试job
|
||||
/// </summary>
|
||||
public class ChargeTryJob
|
||||
{
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
LogHelper.Trace("开始处理订单");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var agentService = scope.ServiceProvider.GetService<AgentService>();
|
||||
await agentService.FaildTry();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理订单失败", e);
|
||||
break;
|
||||
}
|
||||
await Task.Delay(10 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,134 +1,134 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System.Linq;
|
||||
using Hncore.Wx.Open;
|
||||
using Hncore.Infrastructure.SMS;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using System.Collections.Generic;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 过期提醒job
|
||||
/// </summary>
|
||||
public class ExpireTipJob
|
||||
{
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
var doing = false;
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (doing||!(DateTime.Now.Hour == 8 && DateTime.Now.Minute < 5))
|
||||
{
|
||||
break;
|
||||
}
|
||||
doing = true;
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var accountService = scope.ServiceProvider.GetService<ProductAccountService>();
|
||||
var wxUserService = scope.ServiceProvider.GetService<WxAppUserService>();
|
||||
var userService = scope.ServiceProvider.GetService<UserService>();
|
||||
|
||||
var expireAccounts1 = await accountService.GetExpireingAccountsTime(1);
|
||||
var expireAccounts0 = await accountService.GetExpireingAccountsTime(0);
|
||||
var expireAccounts_1 = await accountService.GetExpireingAccountsTime(-1);
|
||||
|
||||
await Tip(expireAccounts1, wxUserService, userService, "还有一天过期");
|
||||
await Tip(expireAccounts0, wxUserService, userService, "今天过期");
|
||||
await Tip(expireAccounts_1, wxUserService, userService, "已经过期一天");
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理过期提醒失败", e);
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
doing = false;
|
||||
}
|
||||
await Task.Delay(6*60 * 1000);
|
||||
}
|
||||
await Task.Delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task Tip(List<ProductAccountEntity> accounts, WxAppUserService wxUserService, UserService userService,string tip="")
|
||||
{
|
||||
var userIds = accounts.Select(m => m.UserId.Value).Distinct().ToList();
|
||||
var wxUsers = await wxUserService.GetWxUsers(userIds);
|
||||
var userInfos = await userService.GetByIds(userIds);
|
||||
|
||||
var tipUsers = new Dictionary<int, bool>();
|
||||
foreach (var account in accounts)
|
||||
{
|
||||
if (tipUsers.ContainsKey(account.UserId.Value)||account.PackageName.IndexOf("测试")!=-1 || account.PackageName.IndexOf("天卡") != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var userInfo = userInfos.FirstOrDefault(m => m.Id == account.UserId);
|
||||
if (wxUsers != null && wxUsers.Count > 0)
|
||||
{
|
||||
var remark = "请及时续费,以免影响您使用。";
|
||||
if(tip=="已经过期一天"){
|
||||
remark = "续费价更优,请登录官网juip.com,联系客服咨询更低价格,现有十几款IP产品,总有一款适合您。";
|
||||
}
|
||||
var title_remark = "请登录juip.com查看具体的到期账号!";
|
||||
if(tip=="今天过期"){
|
||||
title_remark = "您有IP账号将于今天到期,请点击查看详情";
|
||||
} else if(tip=="还有一天过期"){
|
||||
title_remark = "您有IP账号将于明天到期,请点击查看详情";
|
||||
} else {
|
||||
title_remark = "您有IP账号已到期1天,请点击查看详情";
|
||||
}
|
||||
var wxUser = wxUsers.FirstOrDefault(m => m.UserId == account.UserId);
|
||||
if (wxUser != null && wxUser.Openid.Has())
|
||||
{
|
||||
var msg = new TemplateMPModel();
|
||||
msg.first = new TemplateDataItem($"尊敬的用户您好,你的账户{tip}!");
|
||||
msg.Url = "http://www.juip.com/user/myaccounts";
|
||||
msg.template_id = "ltm4OfRDoxgdRG4EC8NMzX-NrkfHUz8aGz33TXSbP44";
|
||||
msg.Items.Add(new TemplateDataItem(title_remark));
|
||||
msg.Items.Add(new TemplateDataItem(userInfo.Phone));
|
||||
msg.Items.Add(new TemplateDataItem("IP账号服务"));
|
||||
msg.Items.Add(new TemplateDataItem(account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss")));
|
||||
msg.remark = new TemplateDataItem(remark);
|
||||
await TemplateApi.SendTemplateMessageAsync(wxUser.Appid, wxUser.Openid, Wx.Open.Enums.ChannelType.MP, msg);
|
||||
}
|
||||
}
|
||||
|
||||
var ret = false;
|
||||
if (userInfo != null && RegexPattern.IsMobile(userInfo.Phone))
|
||||
{
|
||||
if(tip=="今天过期"){
|
||||
ret = AliSmsService.Send("SMS_199202299", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP商城", userInfo.Phone);
|
||||
} else if(tip=="还有一天过期"){
|
||||
ret = AliSmsService.Send("SMS_199222107", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP商城", userInfo.Phone);
|
||||
} else {
|
||||
ret = AliSmsService.Send("SMS_461965526", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP", userInfo.Phone);
|
||||
}
|
||||
// var ret = AliSmsService.Send("SMS_193505090", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP商城", userInfo.Phone);
|
||||
}
|
||||
tipUsers[account.UserId.Value] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System.Linq;
|
||||
using Hncore.Wx.Open;
|
||||
using Hncore.Infrastructure.SMS;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using System.Collections.Generic;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 过期提醒job
|
||||
/// </summary>
|
||||
public class ExpireTipJob
|
||||
{
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
var doing = false;
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (doing||!(DateTime.Now.Hour == 8 && DateTime.Now.Minute < 5))
|
||||
{
|
||||
break;
|
||||
}
|
||||
doing = true;
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var accountService = scope.ServiceProvider.GetService<ProductAccountService>();
|
||||
var wxUserService = scope.ServiceProvider.GetService<WxAppUserService>();
|
||||
var userService = scope.ServiceProvider.GetService<UserService>();
|
||||
|
||||
var expireAccounts1 = await accountService.GetExpireingAccountsTime(1);
|
||||
var expireAccounts0 = await accountService.GetExpireingAccountsTime(0);
|
||||
var expireAccounts_1 = await accountService.GetExpireingAccountsTime(-1);
|
||||
|
||||
await Tip(expireAccounts1, wxUserService, userService, "还有一天过期");
|
||||
await Tip(expireAccounts0, wxUserService, userService, "今天过期");
|
||||
await Tip(expireAccounts_1, wxUserService, userService, "已经过期一天");
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理过期提醒失败", e);
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
doing = false;
|
||||
}
|
||||
await Task.Delay(6*60 * 1000);
|
||||
}
|
||||
await Task.Delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task Tip(List<ProductAccountEntity> accounts, WxAppUserService wxUserService, UserService userService,string tip="")
|
||||
{
|
||||
var userIds = accounts.Select(m => m.UserId.Value).Distinct().ToList();
|
||||
var wxUsers = await wxUserService.GetWxUsers(userIds);
|
||||
var userInfos = await userService.GetByIds(userIds);
|
||||
|
||||
var tipUsers = new Dictionary<int, bool>();
|
||||
foreach (var account in accounts)
|
||||
{
|
||||
if (tipUsers.ContainsKey(account.UserId.Value)||account.PackageName.IndexOf("测试")!=-1 || account.PackageName.IndexOf("天卡") != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var userInfo = userInfos.FirstOrDefault(m => m.Id == account.UserId);
|
||||
if (wxUsers != null && wxUsers.Count > 0)
|
||||
{
|
||||
var remark = "请及时续费,以免影响您使用。";
|
||||
if(tip=="已经过期一天"){
|
||||
remark = "续费价更优,请登录官网juip.com,联系客服咨询更低价格,现有十几款IP产品,总有一款适合您。";
|
||||
}
|
||||
var title_remark = "请登录juip.com查看具体的到期账号!";
|
||||
if(tip=="今天过期"){
|
||||
title_remark = "您有IP账号将于今天到期,请点击查看详情";
|
||||
} else if(tip=="还有一天过期"){
|
||||
title_remark = "您有IP账号将于明天到期,请点击查看详情";
|
||||
} else {
|
||||
title_remark = "您有IP账号已到期1天,请点击查看详情";
|
||||
}
|
||||
var wxUser = wxUsers.FirstOrDefault(m => m.UserId == account.UserId);
|
||||
if (wxUser != null && wxUser.Openid.Has())
|
||||
{
|
||||
var msg = new TemplateMPModel();
|
||||
msg.first = new TemplateDataItem($"尊敬的用户您好,你的账户{tip}!");
|
||||
msg.Url = "http://www.juip.com/user/myaccounts";
|
||||
msg.template_id = "ltm4OfRDoxgdRG4EC8NMzX-NrkfHUz8aGz33TXSbP44";
|
||||
msg.Items.Add(new TemplateDataItem(title_remark));
|
||||
msg.Items.Add(new TemplateDataItem(userInfo.Phone));
|
||||
msg.Items.Add(new TemplateDataItem("IP账号服务"));
|
||||
msg.Items.Add(new TemplateDataItem(account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss")));
|
||||
msg.remark = new TemplateDataItem(remark);
|
||||
await TemplateApi.SendTemplateMessageAsync(wxUser.Appid, wxUser.Openid, Wx.Open.Enums.ChannelType.MP, msg);
|
||||
}
|
||||
}
|
||||
|
||||
var ret = false;
|
||||
if (userInfo != null && RegexPattern.IsMobile(userInfo.Phone))
|
||||
{
|
||||
if(tip=="今天过期"){
|
||||
ret = AliSmsService.Send("SMS_199202299", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP商城", userInfo.Phone);
|
||||
} else if(tip=="还有一天过期"){
|
||||
ret = AliSmsService.Send("SMS_199222107", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP商城", userInfo.Phone);
|
||||
} else {
|
||||
ret = AliSmsService.Send("SMS_461965526", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP", userInfo.Phone);
|
||||
}
|
||||
// var ret = AliSmsService.Send("SMS_193505090", new { date = account.EndTime.Value.ToString("yyyy-MM-dd hh:mm:ss") }, "聚IP商城", userInfo.Phone);
|
||||
}
|
||||
tipUsers[account.UserId.Value] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +1,47 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付成功后开通账号的job
|
||||
/// </summary>
|
||||
public class OrderAccountJob
|
||||
{
|
||||
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true) // 每轮间隔10分钟
|
||||
{
|
||||
LogHelper.Trace("开始处理订单");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var orderService = scope.ServiceProvider.GetService<ProductOrderService>();
|
||||
var orders = await orderService.GetOrders(Domain.OrderStatus.PayOk);
|
||||
|
||||
await orders.ForEachAsync(async m =>
|
||||
{
|
||||
await orderService.ProcessOrderAccount(m);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理订单失败", e);
|
||||
}
|
||||
await Task.Delay(10 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付成功后开通账号的job
|
||||
/// </summary>
|
||||
public class OrderAccountJob
|
||||
{
|
||||
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true) // 每轮间隔10分钟
|
||||
{
|
||||
LogHelper.Trace("开始处理订单");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var orderService = scope.ServiceProvider.GetService<ProductOrderService>();
|
||||
var orders = await orderService.GetOrders(Domain.OrderStatus.PayOk);
|
||||
|
||||
await orders.ForEachAsync(async m =>
|
||||
{
|
||||
await orderService.ProcessOrderAccount(m);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理订单失败", e);
|
||||
}
|
||||
await Task.Delay(10 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using Hncore.Pass.BaseInfo.Request.User;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 超时支付的job
|
||||
/// </summary>
|
||||
public class OrderOutTimePayJob
|
||||
{
|
||||
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true) // 每轮间隔10分钟
|
||||
{
|
||||
LogHelper.Trace("开始处理超时支付");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var orderService = scope.ServiceProvider.GetService<ProductOrderService>();
|
||||
var userService = scope.ServiceProvider.GetService<Hncore.Pass.BaseInfo.Service.UserService>();
|
||||
var orders = await orderService.GetLimitTimeOrders(Domain.OrderStatus.NoPay, 30);
|
||||
orders.ForEach(async order =>
|
||||
{
|
||||
order.OrderState = Domain.OrderStatus.TimeOutClose;
|
||||
await orderService.Update(order);
|
||||
//返还用户余额支付部分
|
||||
if (order.AccountPayAmount > 0)
|
||||
{
|
||||
var amountInfo = new UpdateAmountRequest()
|
||||
{
|
||||
Amount = order.AccountPayAmount.Value,
|
||||
OpAmountType = ScoreType.AccountRefund,
|
||||
UserId = order.UserId,
|
||||
AttchInfo = order.OrderNo,
|
||||
OperateUserName = order.UserName,
|
||||
};
|
||||
await userService.UpdateAmount(amountInfo);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理超时支付失败", e);
|
||||
break;
|
||||
}
|
||||
await Task.Delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using Hncore.Pass.BaseInfo.Request.User;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 超时支付的job
|
||||
/// </summary>
|
||||
public class OrderOutTimePayJob
|
||||
{
|
||||
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true) // 每轮间隔10分钟
|
||||
{
|
||||
LogHelper.Trace("开始处理超时支付");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var orderService = scope.ServiceProvider.GetService<ProductOrderService>();
|
||||
var userService = scope.ServiceProvider.GetService<Hncore.Pass.BaseInfo.Service.UserService>();
|
||||
var orders = await orderService.GetLimitTimeOrders(Domain.OrderStatus.NoPay, 30);
|
||||
orders.ForEach(async order =>
|
||||
{
|
||||
order.OrderState = Domain.OrderStatus.TimeOutClose;
|
||||
await orderService.Update(order);
|
||||
//返还用户余额支付部分
|
||||
if (order.AccountPayAmount > 0)
|
||||
{
|
||||
var amountInfo = new UpdateAmountRequest()
|
||||
{
|
||||
Amount = order.AccountPayAmount.Value,
|
||||
OpAmountType = ScoreType.AccountRefund,
|
||||
UserId = order.UserId,
|
||||
AttchInfo = order.OrderNo,
|
||||
OperateUserName = order.UserName,
|
||||
};
|
||||
await userService.UpdateAmount(amountInfo);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("处理超时支付失败", e);
|
||||
break;
|
||||
}
|
||||
await Task.Delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,42 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 超时支付的job
|
||||
/// </summary>
|
||||
public class RefrushStatusJob
|
||||
{
|
||||
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
LogHelper.Trace("刷新代理服务器状态");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var agentService = scope.ServiceProvider.GetService<AgentService>();
|
||||
await agentService.RefrushAllStatus();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("刷新代理服务器状态失败", e);
|
||||
}
|
||||
await Task.Delay(30 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 超时支付的job
|
||||
/// </summary>
|
||||
public class RefrushStatusJob
|
||||
{
|
||||
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
LogHelper.Trace("刷新代理服务器状态");
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var agentService = scope.ServiceProvider.GetService<AgentService>();
|
||||
await agentService.RefrushAllStatus();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("刷新代理服务器状态失败", e);
|
||||
}
|
||||
await Task.Delay(30 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +1,76 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System.Linq;
|
||||
using Hncore.Wx.Open;
|
||||
using Hncore.Infrastructure.SMS;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using System.Collections.Generic;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除不存在的账号
|
||||
/// </summary>
|
||||
public class RemoveAccountJob
|
||||
{
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
var doing = false;
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (doing||!(DateTime.Now.Hour == 23 && DateTime.Now.Minute < 5))
|
||||
{
|
||||
break;
|
||||
}
|
||||
LogHelper.Trace("开始删除过期账号");
|
||||
doing = true;
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var accountService = scope.ServiceProvider.GetService<ProductAccountService>();
|
||||
var agentService = scope.ServiceProvider.GetService<AgentService>();
|
||||
var removeAccounts = new List<ProductAccountEntity>();
|
||||
var accounts = await accountService.Query(true).ToListAsync();
|
||||
foreach (var item in accounts)
|
||||
{
|
||||
var ret = await agentService.GetOriginAccountInfo(item.ProductId.Value, item.Account, item.Pwd);
|
||||
if (ret.Code != ResultCode.C_SUCCESS && ret.Code != ResultCode.C_NOT_EXISTS_ERROR)
|
||||
{
|
||||
removeAccounts.Add(item);
|
||||
}
|
||||
}
|
||||
await accountService.Deletes(removeAccounts);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("账号删除失败", e);
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
doing = false;
|
||||
}
|
||||
await Task.Delay(6*60 * 1000);
|
||||
}
|
||||
await Task.Delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System.Linq;
|
||||
using Hncore.Wx.Open;
|
||||
using Hncore.Infrastructure.SMS;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using System.Collections.Generic;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Job
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除不存在的账号
|
||||
/// </summary>
|
||||
public class RemoveAccountJob
|
||||
{
|
||||
public static void Start(IServiceProvider serviceProvider)
|
||||
{
|
||||
Task.Run(async () => { await Execute(serviceProvider); });
|
||||
}
|
||||
|
||||
private static async Task Execute(IServiceProvider serviceProvider)
|
||||
{
|
||||
var doing = false;
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (doing||!(DateTime.Now.Hour == 23 && DateTime.Now.Minute < 5))
|
||||
{
|
||||
break;
|
||||
}
|
||||
LogHelper.Trace("开始删除过期账号");
|
||||
doing = true;
|
||||
try
|
||||
{
|
||||
using (var scope = serviceProvider.CreateScope())
|
||||
{
|
||||
var accountService = scope.ServiceProvider.GetService<ProductAccountService>();
|
||||
var agentService = scope.ServiceProvider.GetService<AgentService>();
|
||||
var removeAccounts = new List<ProductAccountEntity>();
|
||||
var accounts = await accountService.Query(true).ToListAsync();
|
||||
foreach (var item in accounts)
|
||||
{
|
||||
var ret = await agentService.GetOriginAccountInfo(item.ProductId.Value, item.Account, item.Pwd);
|
||||
if (ret.Code != ResultCode.C_SUCCESS && ret.Code != ResultCode.C_NOT_EXISTS_ERROR)
|
||||
{
|
||||
removeAccounts.Add(item);
|
||||
}
|
||||
}
|
||||
await accountService.Deletes(removeAccounts);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.Error("账号删除失败", e);
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
doing = false;
|
||||
}
|
||||
await Task.Delay(6*60 * 1000);
|
||||
}
|
||||
await Task.Delay(60 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Map
|
||||
{
|
||||
public class MapConfig
|
||||
{
|
||||
public static void Config()
|
||||
{
|
||||
TinyMapperExtension.Binds<ProductResponse, ProductEntity>();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Map
|
||||
{
|
||||
public class MapConfig
|
||||
{
|
||||
public static void Config()
|
||||
{
|
||||
TinyMapperExtension.Binds<ProductResponse, ProductEntity>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class CatalogUsedModel
|
||||
{
|
||||
public bool Used { get; set; }
|
||||
|
||||
public List<int> CatalogIds { get; set; }
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class CatalogUsedModel
|
||||
{
|
||||
public bool Used { get; set; }
|
||||
|
||||
public List<int> CatalogIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class ManagerSellStatisticModel
|
||||
{
|
||||
public string RealName { get; set; }
|
||||
|
||||
public string Name => this.RealName.NotHas() ? "无" : this.RealName;
|
||||
public long? UserCount { get; set; } = 0;
|
||||
|
||||
public long? NewUserCount { get; set; } = 0;
|
||||
|
||||
public decimal? Amount { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class ManagerSellStatisticModel
|
||||
{
|
||||
public string RealName { get; set; }
|
||||
|
||||
public string Name => this.RealName.NotHas() ? "无" : this.RealName;
|
||||
public long? UserCount { get; set; } = 0;
|
||||
|
||||
public long? NewUserCount { get; set; } = 0;
|
||||
|
||||
public decimal? Amount { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class OrderStatisticModel
|
||||
{
|
||||
public string Channel { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
|
||||
public string PackageName { get; set; }
|
||||
|
||||
public int NewBuyCount { get; set; }
|
||||
public decimal NewBuyAmount { get; set; }
|
||||
|
||||
public int AgainBuyCount { get; set; }
|
||||
public decimal AgainBuyAmount { get; set; }
|
||||
|
||||
public int RefundCount { get; set; }
|
||||
public decimal RefundAmount { get; set; }
|
||||
|
||||
public decimal SellAmount => NewBuyAmount + AgainBuyAmount;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class OrderStatisticModel
|
||||
{
|
||||
public string Channel { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
|
||||
public string PackageName { get; set; }
|
||||
|
||||
public int NewBuyCount { get; set; }
|
||||
public decimal NewBuyAmount { get; set; }
|
||||
|
||||
public int AgainBuyCount { get; set; }
|
||||
public decimal AgainBuyAmount { get; set; }
|
||||
|
||||
public int RefundCount { get; set; }
|
||||
public decimal RefundAmount { get; set; }
|
||||
|
||||
public decimal SellAmount => NewBuyAmount + AgainBuyAmount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class OriginAccountModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string User { get; set; }
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
public string AccountType { get; set; }
|
||||
public string Package { get; set; }
|
||||
public string ConnectCount { get; set; }
|
||||
public string RegistTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public string RestTime { get; set; }
|
||||
public string Amount { get; set; }
|
||||
|
||||
public string IsActive { get; set; }
|
||||
public string Remark { get; set; }
|
||||
|
||||
public DateTime RealEndTime { get; set; }
|
||||
|
||||
public int OnLine { get; set; } = 0;
|
||||
|
||||
public string LoginTime { get; set; }
|
||||
|
||||
public string LoginServer { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class OriginAccountModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string User { get; set; }
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
public string AccountType { get; set; }
|
||||
public string Package { get; set; }
|
||||
public string ConnectCount { get; set; }
|
||||
public string RegistTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public string RestTime { get; set; }
|
||||
public string Amount { get; set; }
|
||||
|
||||
public string IsActive { get; set; }
|
||||
public string Remark { get; set; }
|
||||
|
||||
public DateTime RealEndTime { get; set; }
|
||||
|
||||
public int OnLine { get; set; } = 0;
|
||||
|
||||
public string LoginTime { get; set; }
|
||||
|
||||
public string LoginServer { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class OriginAccountOnlineModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string LoginTime { get; set; }
|
||||
public string OnlineTime { get; set; }
|
||||
|
||||
public string ServerIP { get; set; }
|
||||
public string LoginIP { get; set; }
|
||||
public string UpStream { get; set; }
|
||||
public string DownStream { get; set; }
|
||||
public int OnLine { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class OriginAccountOnlineModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string LoginTime { get; set; }
|
||||
public string OnlineTime { get; set; }
|
||||
|
||||
public string ServerIP { get; set; }
|
||||
public string LoginIP { get; set; }
|
||||
public string UpStream { get; set; }
|
||||
public string DownStream { get; set; }
|
||||
public int OnLine { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class PackageUnitItemModel
|
||||
{
|
||||
public int Count { get; set; }
|
||||
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class PackageUnitItemModel
|
||||
{
|
||||
public int Count { get; set; }
|
||||
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class UserConsumeStatisticsModel
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
||||
public UserEntity UserInfo {get;set;}
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
public string TotalAmount { get; set; }
|
||||
public string DayAmount { get; set; }
|
||||
|
||||
public decimal PrevMonthAmount { get; set; }
|
||||
public decimal MonthAmount { get; set; }
|
||||
|
||||
public decimal AddAmount => MonthAmount - PrevMonthAmount;
|
||||
|
||||
public string YearAmount { get; set; }
|
||||
|
||||
public int TotalAccountCount=> ExpirdAccountCount + UsingAccountCount;
|
||||
|
||||
public int UsingAccountCount { get; set; } = 0;
|
||||
|
||||
public int ExpirdAccountCount { get; set; } = 0;
|
||||
|
||||
public int TestAccountCount { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class UserConsumeStatisticsModel
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
||||
public UserEntity UserInfo {get;set;}
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
public string TotalAmount { get; set; }
|
||||
public string DayAmount { get; set; }
|
||||
|
||||
public decimal PrevMonthAmount { get; set; }
|
||||
public decimal MonthAmount { get; set; }
|
||||
|
||||
public decimal AddAmount => MonthAmount - PrevMonthAmount;
|
||||
|
||||
public string YearAmount { get; set; }
|
||||
|
||||
public int TotalAccountCount=> ExpirdAccountCount + UsingAccountCount;
|
||||
|
||||
public int UsingAccountCount { get; set; } = 0;
|
||||
|
||||
public int ExpirdAccountCount { get; set; } = 0;
|
||||
|
||||
public int TestAccountCount { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class UserDataMode
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Model
|
||||
{
|
||||
public class UserDataMode
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Hncore.Pass.Vpn
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Hncore.Pass.Vpn
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:50978/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:50978/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class AccountPageRequest : PageRequestBase
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
//-1:全部 0 :过期
|
||||
public int ExpirdDay { get; set; }
|
||||
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
public int? PackageId { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
|
||||
public List<int?> AccountTypes { get; set; }
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
public DateTime? ETime { get; set; }
|
||||
public DateTime? BkTime { get; set; }
|
||||
public DateTime? EkTime { get; set; }
|
||||
|
||||
public List<int> ProductIds { get; set; }
|
||||
|
||||
public List<string> PackageNames { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class AccountPageRequest : PageRequestBase
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
//-1:全部 0 :过期
|
||||
public int ExpirdDay { get; set; }
|
||||
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
public int? PackageId { get; set; }
|
||||
public string PackageName { get; set; }
|
||||
|
||||
public List<int?> AccountTypes { get; set; }
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
public DateTime? ETime { get; set; }
|
||||
public DateTime? BkTime { get; set; }
|
||||
public DateTime? EkTime { get; set; }
|
||||
|
||||
public List<int> ProductIds { get; set; }
|
||||
|
||||
public List<string> PackageNames { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class AgentLoginRequest
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
|
||||
public string Key { get; set; }
|
||||
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class AgentLoginRequest
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
|
||||
public string Key { get; set; }
|
||||
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class BindUserRequest
|
||||
{
|
||||
public List<int> AccountIds { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class BindUserRequest
|
||||
{
|
||||
public List<int> AccountIds { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class CouponOrderQueryRequest : PageRequestBase
|
||||
{
|
||||
public int? CouponId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class CouponOrderQueryRequest : PageRequestBase
|
||||
{
|
||||
public int? CouponId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class CreateOrderRequest
|
||||
{
|
||||
public string apikey { get; set; }
|
||||
public OrderType OrderType { get; set; }
|
||||
|
||||
public int PackageId { get; set; }
|
||||
|
||||
//是否使用账户的钱
|
||||
public int UseAccountAmount { get; set; } = 0;
|
||||
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
|
||||
//最小后缀数
|
||||
public int MinPostfix { get; set; }
|
||||
|
||||
//最大后缀数
|
||||
public int MaxPostfix { get; set; }
|
||||
|
||||
//同时在线连接数
|
||||
public int ConnectCount { get; set; }
|
||||
|
||||
//使用的优惠券的Id
|
||||
public int CouponId { get; set; }
|
||||
|
||||
public PayType OPayType { get; set; }
|
||||
|
||||
public PayChannel PayChannel { get; set; }
|
||||
|
||||
public string Channel { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public string phone { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class CreateOrderRequest
|
||||
{
|
||||
public string apikey { get; set; }
|
||||
public OrderType OrderType { get; set; }
|
||||
|
||||
public int PackageId { get; set; }
|
||||
|
||||
//是否使用账户的钱
|
||||
public int UseAccountAmount { get; set; } = 0;
|
||||
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
|
||||
//最小后缀数
|
||||
public int MinPostfix { get; set; }
|
||||
|
||||
//最大后缀数
|
||||
public int MaxPostfix { get; set; }
|
||||
|
||||
//同时在线连接数
|
||||
public int ConnectCount { get; set; }
|
||||
|
||||
//使用的优惠券的Id
|
||||
public int CouponId { get; set; }
|
||||
|
||||
public PayType OPayType { get; set; }
|
||||
|
||||
public PayChannel PayChannel { get; set; }
|
||||
|
||||
public string Channel { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public string phone { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class CreateTestAccountRequest
|
||||
{
|
||||
public string apikey { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int PackageId { get; set; }
|
||||
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class CreateTestAccountRequest
|
||||
{
|
||||
public string apikey { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int PackageId { get; set; }
|
||||
|
||||
public string Account { get; set; }
|
||||
|
||||
public string Pwd { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class OrderQueryRequest: PageRequestBase
|
||||
{
|
||||
public List<int> OrderTypes { get; set; }
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
public int? PackageId { get; set; }
|
||||
public string Channel { get; set; }
|
||||
|
||||
public List<int> ProductIds { get; set; }
|
||||
|
||||
public List<string> PackageNames { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class OrderQueryRequest: PageRequestBase
|
||||
{
|
||||
public List<int> OrderTypes { get; set; }
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
public int? PackageId { get; set; }
|
||||
public string Channel { get; set; }
|
||||
|
||||
public List<int> ProductIds { get; set; }
|
||||
|
||||
public List<string> PackageNames { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class PutPriceDiscountRequest
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int SchemeId { get; set; }
|
||||
public int BuyPriceDiscount { get; set; }
|
||||
public int RefundDayPriceDiscount { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class PutPriceDiscountRequest
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int SchemeId { get; set; }
|
||||
public int BuyPriceDiscount { get; set; }
|
||||
public int RefundDayPriceDiscount { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class PutUserPriceRequest
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public decimal UserPrice { get; set; }
|
||||
public decimal RefundDayPrice { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class PutUserPriceRequest
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
public int PackageId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public decimal UserPrice { get; set; }
|
||||
public decimal RefundDayPrice { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class RefundOrderQueryRequest: PageRequestBase
|
||||
{
|
||||
public List<int> OrderTypes { get; set; }
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
|
||||
public List<int> ProductIds { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class RefundOrderQueryRequest: PageRequestBase
|
||||
{
|
||||
public List<int> OrderTypes { get; set; }
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
|
||||
public List<int> ProductIds { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class RefundProcessRequest
|
||||
{
|
||||
public int Id { get; set;}
|
||||
|
||||
public decimal BackAmount { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class RefundProcessRequest
|
||||
{
|
||||
public int Id { get; set;}
|
||||
|
||||
public decimal BackAmount { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class RoutePageRequest : PageRequestBase
|
||||
{
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class RoutePageRequest : PageRequestBase
|
||||
{
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class SellerOrderQueryRequest : PageRequestBase
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class SellerOrderQueryRequest : PageRequestBase
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
|
||||
public int? ProductId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class SetUserDiscountRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int SchemeId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class SetUserDiscountRequest
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int SchemeId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace HHncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class UpdateAccountPwdRequest
|
||||
{
|
||||
public string apikey { get; set; }
|
||||
public int Id { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public string RePwd { get; set; }
|
||||
}
|
||||
}
|
||||
namespace HHncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class UpdateAccountPwdRequest
|
||||
{
|
||||
public string apikey { get; set; }
|
||||
public int Id { get; set; }
|
||||
public string Account { get; set; }
|
||||
public string Pwd { get; set; }
|
||||
public string RePwd { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class UserConsumeRequest : PageRequestBase
|
||||
{
|
||||
public DateTime? bTime1 { get; set; }
|
||||
public DateTime? eTime1 { get; set; }
|
||||
public DateTime? bTime2 { get; set; }
|
||||
public DateTime? eTime2 { get; set; }
|
||||
|
||||
public string SortLable { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public string Profile { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Request.Product
|
||||
{
|
||||
public class UserConsumeRequest : PageRequestBase
|
||||
{
|
||||
public DateTime? bTime1 { get; set; }
|
||||
public DateTime? eTime1 { get; set; }
|
||||
public DateTime? bTime2 { get; set; }
|
||||
public DateTime? eTime2 { get; set; }
|
||||
|
||||
public string SortLable { get; set; }
|
||||
public int SortOrder { get; set; }
|
||||
public string Profile { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Hncore.Pass.Oss.Request
|
||||
{
|
||||
public class UploadImageBase64Request
|
||||
{
|
||||
public string Base64 { get; set; }
|
||||
}
|
||||
namespace Hncore.Pass.Oss.Request
|
||||
{
|
||||
public class UploadImageBase64Request
|
||||
{
|
||||
public string Base64 { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class CodeResponse
|
||||
{
|
||||
public string CodeImage { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
}
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class CodeResponse
|
||||
{
|
||||
public string CodeImage { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class PackageInfoResponse
|
||||
{
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
|
||||
public ProductUserPriceEntity UserPrice { get; set; }
|
||||
|
||||
public ProductEntity Product { get; set; }
|
||||
|
||||
public int RestTimes { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class PackageInfoResponse
|
||||
{
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
|
||||
public ProductUserPriceEntity UserPrice { get; set; }
|
||||
|
||||
public ProductEntity Product { get; set; }
|
||||
|
||||
public int RestTimes { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class PackageUserPriceResponse
|
||||
{
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
|
||||
public ProductUserPriceEntity UserPrice { get; set; }
|
||||
}
|
||||
|
||||
public class ProductWithPackageUserPriceResponse
|
||||
{
|
||||
public ProductResponse Product { get; set; }
|
||||
public List<PackageUserPriceResponse> PackageUserPrices { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class PackageUserPriceResponse
|
||||
{
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
|
||||
public ProductUserPriceEntity UserPrice { get; set; }
|
||||
}
|
||||
|
||||
public class ProductWithPackageUserPriceResponse
|
||||
{
|
||||
public ProductResponse Product { get; set; }
|
||||
public List<PackageUserPriceResponse> PackageUserPrices { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class ProductResponse
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Sort { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Profile { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
|
||||
public int OnLine { get; set; } = 1;
|
||||
|
||||
public List<string> ContentLine=> this.Profile.Has()?this.Profile.Split('\n').ToList():new List<string>();
|
||||
|
||||
}
|
||||
|
||||
public class ProductWithPackageResponse
|
||||
{
|
||||
public ProductResponse Product { get; set; }
|
||||
public List<ProductPackageEntity> Packages { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class ProductResponse
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Sort { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Profile { get; set; }
|
||||
public int TenantId { get; set; }
|
||||
|
||||
public int OnLine { get; set; } = 1;
|
||||
|
||||
public List<string> ContentLine=> this.Profile.Has()?this.Profile.Split('\n').ToList():new List<string>();
|
||||
|
||||
}
|
||||
|
||||
public class ProductWithPackageResponse
|
||||
{
|
||||
public ProductResponse Product { get; set; }
|
||||
public List<ProductPackageEntity> Packages { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class PackagePriceDiscount
|
||||
{
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
|
||||
public ProductPriceDiscountEntity PriceDiscount { get; set; }
|
||||
}
|
||||
public class ProductWithPriceDiscountResponse
|
||||
{
|
||||
public ProductResponse Product { get; set; }
|
||||
public List<PackagePriceDiscount> PackageDiscounts { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Tree;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Vpn.Response.Product
|
||||
{
|
||||
public class PackagePriceDiscount
|
||||
{
|
||||
public ProductPackageEntity Package { get; set; }
|
||||
|
||||
public ProductPriceDiscountEntity PriceDiscount { get; set; }
|
||||
}
|
||||
public class ProductWithPriceDiscountResponse
|
||||
{
|
||||
public ProductResponse Product { get; set; }
|
||||
public List<PackagePriceDiscount> PackageDiscounts { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,430 +1,430 @@
|
||||
using AngleSharp.Html.Parser;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Serializer;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
//先锋
|
||||
public class AgentClient5Service : AgentClient1Service
|
||||
{
|
||||
string LoginUrl { get; set; } = "main/agentLogin.html";
|
||||
string LoginCodeUrl { get; set; } = "main/imgcode.html";
|
||||
string RefrushTokenUrl { get; set; } = "agent.html";
|
||||
string SingleAddUrl { get; set; } = "agent/memberSingleAdd.html";
|
||||
string SingleReAddUrl { get; set; } = "agent/memberRenew.html";
|
||||
string MuiltAddUrl { get; set; } = "agent/memberMuiltAdd.html";
|
||||
string RefundUrl { get; set; } = "agent/memberRefund/id/{0}.html";
|
||||
string UpdateUrl = "agent/memberUpdate/id/{0}.html";//agent/memberUpdate/id/1155709.html
|
||||
string OnlineUrl { get; set; } = "agent/radiusOnline.html?search=1&username=";
|
||||
string ClientOnlineUrl { get; set; } = "agent/clientOnline.html?search=1&username=";
|
||||
string KIllUrl { get; set; } = "";
|
||||
string KillUrlClient = "/agent/disConnect/sessionid/{0}.html";
|
||||
string KillUrl = "/agent/disConnect/radacctid/{0}.html";
|
||||
string searchAccountUrl = "agent/memberList/type/1.html?search=1&username=";
|
||||
string searchTestAccountUrl = "agent/memberList/type/0.html?search=1&username=";
|
||||
string DeleteUrl { get; set; } = "agent/multiDelMember.html ";
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
public AgentClient5Service(IHttpClientFactory httpClientFactory):base(httpClientFactory)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int payCount = 1)
|
||||
{
|
||||
|
||||
if(packageKey == "free"){
|
||||
return await NewTestAccount(packageKey, account, pwd, 1, accountType, 1);
|
||||
}
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=adduser&user="+account+"&pass="+pwd+"&serverid="+packageKey+"&logincount="+connCount.ToString()+"&phone=17719092232&cardname=万永康&cardno=410325199810129916";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult> NewTestAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int payCount = 1)
|
||||
{
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=addtestuser&user="+account+"&password="+pwd+"&username3=admin01&phone=17719092232&cardname=万永康&cardno=410325199810129916";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
Console.WriteLine("==================================================");
|
||||
Console.WriteLine(jo);
|
||||
Console.WriteLine("==================================================");
|
||||
|
||||
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewReAccount(string packageKey, string account, int connCount, int payCount = 1)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=buy&user="+account+"&serverid="+packageKey+"&logincount="+connCount.ToString()+"&phone=17719092232&cardname=万永康&cardno=410325199810129916";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return new ApiResult(1);
|
||||
}
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> DeleteAccount(string account)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var infoRet = await this.GetAccountInfo(account, true);
|
||||
if (infoRet.Code != ResultCode.C_SUCCESS)
|
||||
return false;
|
||||
var map = new Dictionary<string, string>(){
|
||||
{infoRet.Data.Id,infoRet.Data.Id },
|
||||
};
|
||||
var title = GetOpTitle("DeleteAccount", account);
|
||||
LogHelper.Info(title, account);
|
||||
try
|
||||
{
|
||||
var resp = await client.PostAsForm(this.DeleteUrl, map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("删除成功") != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到账号信息
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<OriginAccountModel>> GetAccountInfo(string account,bool isTest=false)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=getuserinfo&user="+account;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
Console.WriteLine("---------------------------------------------------------------");
|
||||
Console.WriteLine(jo);
|
||||
Console.WriteLine("---------------------------------------------------------------");
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
var trData = new OriginAccountModel
|
||||
{
|
||||
Account = account,
|
||||
Pwd = "",
|
||||
AccountType = "",
|
||||
Package = "",
|
||||
RegistTime = "",
|
||||
EndTime = jo["expiretime"].ToString(),
|
||||
RestTime = "",
|
||||
ConnectCount = jo["logincount"].ToString(),
|
||||
Amount = "",
|
||||
IsActive = "",
|
||||
Remark = "",
|
||||
};
|
||||
return new ApiResult<OriginAccountModel>(trData);
|
||||
}
|
||||
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_INVALID_ERROR, "没有查询到信息");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> UpdateAccountPwd(string account, string pwd)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=setuser&user="+account+"&&new_pwd="+pwd;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> Refund(string account, string packageKey, int days)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("Refund", account);
|
||||
try
|
||||
{
|
||||
var accountInfo = await this.GetAccountInfo(account);
|
||||
if (accountInfo.Code != ResultCode.C_SUCCESS)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
}
|
||||
var url = string.Format(this.RefundUrl, accountInfo.Data.Id);
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("退款成功!") != -1)
|
||||
{
|
||||
return new ApiResult(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(string account)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=get_user_onlinelog&user="+account;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
var retData = new List<OriginAccountOnlineModel>();
|
||||
if (status =="1")
|
||||
{
|
||||
if(jo.ContainsKey("data")){
|
||||
foreach (var tr in jo["data"])
|
||||
{
|
||||
JObject jsondata = (JObject)JsonConvert.DeserializeObject(tr.ToJson());
|
||||
|
||||
var trData = new OriginAccountOnlineModel
|
||||
{
|
||||
Account = account,
|
||||
ServerIP = jsondata["server_ip"].ToString(),
|
||||
LoginTime = "",
|
||||
OnlineTime = jsondata["online_time"].ToString(),
|
||||
LoginIP = jsondata["client_ip"].ToString(),
|
||||
UpStream = "",
|
||||
DownStream = "",
|
||||
Id = "user="+account+"-address="+jsondata["address"].ToString()+"-server_ip="+jsondata["server_ip"].ToString(),
|
||||
|
||||
};
|
||||
|
||||
retData.Add(trData);
|
||||
}
|
||||
}
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(retData);
|
||||
} else {
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(retData);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> KillOut(string id)
|
||||
{
|
||||
var ids = "";
|
||||
if(id.Contains("-")){
|
||||
string[] arrStr = id.Split('-');
|
||||
ids = arrStr[0]+"&"+arrStr[1]+"&"+arrStr[2];
|
||||
}
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=user_online_offline&"+ids;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status =="1")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<bool> KillOutClient(string id)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("KillOutClient", id);
|
||||
var info = "";
|
||||
try
|
||||
{
|
||||
var url = string.Format(this.KillUrlClient, id);
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("已经向客户端发送断开消息") != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message + "-->info:" + info);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> Exist(string account)
|
||||
{
|
||||
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=getuserlenNum&user="+account;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("================test==================================");
|
||||
Console.WriteLine(jo);
|
||||
Console.WriteLine("==================================================");
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using AngleSharp.Html.Parser;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Serializer;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
//先锋
|
||||
public class AgentClient5Service : AgentClient1Service
|
||||
{
|
||||
string LoginUrl { get; set; } = "main/agentLogin.html";
|
||||
string LoginCodeUrl { get; set; } = "main/imgcode.html";
|
||||
string RefrushTokenUrl { get; set; } = "agent.html";
|
||||
string SingleAddUrl { get; set; } = "agent/memberSingleAdd.html";
|
||||
string SingleReAddUrl { get; set; } = "agent/memberRenew.html";
|
||||
string MuiltAddUrl { get; set; } = "agent/memberMuiltAdd.html";
|
||||
string RefundUrl { get; set; } = "agent/memberRefund/id/{0}.html";
|
||||
string UpdateUrl = "agent/memberUpdate/id/{0}.html";//agent/memberUpdate/id/1155709.html
|
||||
string OnlineUrl { get; set; } = "agent/radiusOnline.html?search=1&username=";
|
||||
string ClientOnlineUrl { get; set; } = "agent/clientOnline.html?search=1&username=";
|
||||
string KIllUrl { get; set; } = "";
|
||||
string KillUrlClient = "/agent/disConnect/sessionid/{0}.html";
|
||||
string KillUrl = "/agent/disConnect/radacctid/{0}.html";
|
||||
string searchAccountUrl = "agent/memberList/type/1.html?search=1&username=";
|
||||
string searchTestAccountUrl = "agent/memberList/type/0.html?search=1&username=";
|
||||
string DeleteUrl { get; set; } = "agent/multiDelMember.html ";
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
public AgentClient5Service(IHttpClientFactory httpClientFactory):base(httpClientFactory)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int payCount = 1)
|
||||
{
|
||||
|
||||
if(packageKey == "free"){
|
||||
return await NewTestAccount(packageKey, account, pwd, 1, accountType, 1);
|
||||
}
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=adduser&user="+account+"&pass="+pwd+"&serverid="+packageKey+"&logincount="+connCount.ToString()+"&phone=17719092232&cardname=万永康&cardno=410325199810129916";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult> NewTestAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int payCount = 1)
|
||||
{
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=addtestuser&user="+account+"&password="+pwd+"&username3=admin01&phone=17719092232&cardname=万永康&cardno=410325199810129916";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
Console.WriteLine("==================================================");
|
||||
Console.WriteLine(jo);
|
||||
Console.WriteLine("==================================================");
|
||||
|
||||
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewReAccount(string packageKey, string account, int connCount, int payCount = 1)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=buy&user="+account+"&serverid="+packageKey+"&logincount="+connCount.ToString()+"&phone=17719092232&cardname=万永康&cardno=410325199810129916";
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return new ApiResult(1);
|
||||
}
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> DeleteAccount(string account)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var infoRet = await this.GetAccountInfo(account, true);
|
||||
if (infoRet.Code != ResultCode.C_SUCCESS)
|
||||
return false;
|
||||
var map = new Dictionary<string, string>(){
|
||||
{infoRet.Data.Id,infoRet.Data.Id },
|
||||
};
|
||||
var title = GetOpTitle("DeleteAccount", account);
|
||||
LogHelper.Info(title, account);
|
||||
try
|
||||
{
|
||||
var resp = await client.PostAsForm(this.DeleteUrl, map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("删除成功") != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到账号信息
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<OriginAccountModel>> GetAccountInfo(string account,bool isTest=false)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=getuserinfo&user="+account;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
Console.WriteLine("---------------------------------------------------------------");
|
||||
Console.WriteLine(jo);
|
||||
Console.WriteLine("---------------------------------------------------------------");
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
var trData = new OriginAccountModel
|
||||
{
|
||||
Account = account,
|
||||
Pwd = "",
|
||||
AccountType = "",
|
||||
Package = "",
|
||||
RegistTime = "",
|
||||
EndTime = jo["expiretime"].ToString(),
|
||||
RestTime = "",
|
||||
ConnectCount = jo["logincount"].ToString(),
|
||||
Amount = "",
|
||||
IsActive = "",
|
||||
Remark = "",
|
||||
};
|
||||
return new ApiResult<OriginAccountModel>(trData);
|
||||
}
|
||||
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_INVALID_ERROR, "没有查询到信息");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> UpdateAccountPwd(string account, string pwd)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi/?secretId="+secretId+"&secretKey="+secretKey+"&type=setuser&user="+account+"&&new_pwd="+pwd;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> Refund(string account, string packageKey, int days)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("Refund", account);
|
||||
try
|
||||
{
|
||||
var accountInfo = await this.GetAccountInfo(account);
|
||||
if (accountInfo.Code != ResultCode.C_SUCCESS)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
}
|
||||
var url = string.Format(this.RefundUrl, accountInfo.Data.Id);
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("退款成功!") != -1)
|
||||
{
|
||||
return new ApiResult(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(string account)
|
||||
{
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=get_user_onlinelog&user="+account;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
var retData = new List<OriginAccountOnlineModel>();
|
||||
if (status =="1")
|
||||
{
|
||||
if(jo.ContainsKey("data")){
|
||||
foreach (var tr in jo["data"])
|
||||
{
|
||||
JObject jsondata = (JObject)JsonConvert.DeserializeObject(tr.ToJson());
|
||||
|
||||
var trData = new OriginAccountOnlineModel
|
||||
{
|
||||
Account = account,
|
||||
ServerIP = jsondata["server_ip"].ToString(),
|
||||
LoginTime = "",
|
||||
OnlineTime = jsondata["online_time"].ToString(),
|
||||
LoginIP = jsondata["client_ip"].ToString(),
|
||||
UpStream = "",
|
||||
DownStream = "",
|
||||
Id = "user="+account+"-address="+jsondata["address"].ToString()+"-server_ip="+jsondata["server_ip"].ToString(),
|
||||
|
||||
};
|
||||
|
||||
retData.Add(trData);
|
||||
}
|
||||
}
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(retData);
|
||||
} else {
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(retData);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> KillOut(string id)
|
||||
{
|
||||
var ids = "";
|
||||
if(id.Contains("-")){
|
||||
string[] arrStr = id.Split('-');
|
||||
ids = arrStr[0]+"&"+arrStr[1]+"&"+arrStr[2];
|
||||
}
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=user_online_offline&"+ids;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status =="1")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<bool> KillOutClient(string id)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("KillOutClient", id);
|
||||
var info = "";
|
||||
try
|
||||
{
|
||||
var url = string.Format(this.KillUrlClient, id);
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("已经向客户端发送断开消息") != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message + "-->info:" + info);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override async Task<bool> Exist(string account)
|
||||
{
|
||||
|
||||
|
||||
var secretId = "626B6170693231";
|
||||
var secretKey = "6b3fdfc206841f44c6609bf19c182a6a";
|
||||
|
||||
var url = "http://bkapi.pptp.biz/userapi3/?secretId="+secretId+"&secretKey="+secretKey+"&type=getuserlenNum&user="+account;
|
||||
|
||||
var client = CreateHttpClient();
|
||||
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
|
||||
|
||||
|
||||
Console.WriteLine("================test==================================");
|
||||
Console.WriteLine(jo);
|
||||
Console.WriteLine("==================================================");
|
||||
|
||||
|
||||
if (status =="1")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,246 +1,246 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public abstract class AgentClientBaseService
|
||||
{
|
||||
protected string BaseUrl { get; set; }
|
||||
protected string Token { get; set; }
|
||||
string LoginUrl { get; set; }
|
||||
string LoginCodeUrl { get; set; }
|
||||
string RefrushTokenUrl { get; set; }
|
||||
string SingleAddUrl { get; set; }
|
||||
string SingleReAddUrl { get; set; }
|
||||
string MuiltAddUrl { get; set; }
|
||||
string RefundUrl { get; set; }
|
||||
string OnlineUrl { get; set; }
|
||||
string KIllUrl { get; set; }
|
||||
string UpdateUrl { get; set; }
|
||||
public string ClientName { get; set; }
|
||||
public string Raw { get; set; }
|
||||
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
public AgentClientBaseService(IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public ProductEntity Product { get; set; }
|
||||
|
||||
public void Init(string BaseUrl,string Token)
|
||||
{
|
||||
this.BaseUrl = BaseUrl;
|
||||
this.Token = Token;
|
||||
}
|
||||
|
||||
public virtual string GetOpTitle(string op,string account)
|
||||
{
|
||||
return $"{this.ClientName}_{op}_{account}";
|
||||
}
|
||||
|
||||
protected virtual HttpClient CreateHttpClient(bool autoCooke = true)
|
||||
{
|
||||
var client = m_HttpClientFactory.CreateClient("agentClient");
|
||||
client.BaseAddress = new System.Uri(this.BaseUrl);
|
||||
|
||||
|
||||
|
||||
if (this.Token.Has()&& autoCooke)
|
||||
{
|
||||
AddCookie(client, this.Token);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
public virtual string MD5(string password) {
|
||||
byte[] textBytes = System.Text.Encoding.Default.GetBytes(password);
|
||||
try {
|
||||
System.Security.Cryptography.MD5CryptoServiceProvider cryptHandler;
|
||||
cryptHandler = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||
byte[] hash = cryptHandler.ComputeHash (textBytes);
|
||||
string ret = "";
|
||||
foreach (byte a in hash) {
|
||||
if (a<16)
|
||||
ret += "0" + a.ToString ("x");
|
||||
else
|
||||
ret += a.ToString ("x");
|
||||
}
|
||||
return ret ;
|
||||
}
|
||||
catch {
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected virtual void AddCookie(HttpClient client, string cookie)
|
||||
{
|
||||
client.DefaultRequestHeaders.Remove("Cookie");
|
||||
client.DefaultRequestHeaders.Add("Cookie", cookie);
|
||||
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + cookie);
|
||||
}
|
||||
public string GetCookie(HttpResponseMessage resp, string name)
|
||||
{
|
||||
if (resp.Headers.TryGetValues("Set-Cookie", out IEnumerable<string> cookies))
|
||||
{
|
||||
foreach (var cookie in cookies)
|
||||
{
|
||||
var ret = cookie.Split(";").FirstOrDefault(m => m.IndexOf(name) != -1);
|
||||
if (ret.Has())
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public string GetCookies(HttpResponseMessage resp)
|
||||
{
|
||||
if (resp.Headers.TryGetValues("Set-Cookie", out IEnumerable<string> cookies))
|
||||
{
|
||||
return string.Join(";", cookies);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
protected string GetCookieValue(string cookies, string name)
|
||||
{
|
||||
foreach (var item in cookies.Split(";"))
|
||||
{
|
||||
var token = item.Split("=");
|
||||
if (token.Length == 2 && token[0] == name)
|
||||
{
|
||||
return token[1];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public virtual async Task<int> RefrushStatus()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public virtual async Task<(byte[], string)> GetCode()
|
||||
{
|
||||
return (null, "");
|
||||
}
|
||||
public virtual async Task<ApiResult> Login(AgentLoginRequest request)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
public virtual bool CheckAccount(int productId,List<string> accounts)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> NewAccount(string packageKey, string account,string pwd,int connCount=1,int accountType=1, int payCount = 1)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
public virtual async Task<ApiResult> NewMuiltAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int startNum = 0, int endNum = 1)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> NewReAccount(string packageKey,string account,int connCount, int payCount = 1)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> DeleteAccount(string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到账号信息
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult<OriginAccountModel>> GetAccountInfo(string account, bool isTest = false)
|
||||
{
|
||||
return new ApiResult<OriginAccountModel>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> UpdateAccountPwd(string account,string pwd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> Refund(string account, string packageKey, int days)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(string account)
|
||||
{
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> KillOut(string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> Exist(string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public abstract class AgentClientBaseService
|
||||
{
|
||||
protected string BaseUrl { get; set; }
|
||||
protected string Token { get; set; }
|
||||
string LoginUrl { get; set; }
|
||||
string LoginCodeUrl { get; set; }
|
||||
string RefrushTokenUrl { get; set; }
|
||||
string SingleAddUrl { get; set; }
|
||||
string SingleReAddUrl { get; set; }
|
||||
string MuiltAddUrl { get; set; }
|
||||
string RefundUrl { get; set; }
|
||||
string OnlineUrl { get; set; }
|
||||
string KIllUrl { get; set; }
|
||||
string UpdateUrl { get; set; }
|
||||
public string ClientName { get; set; }
|
||||
public string Raw { get; set; }
|
||||
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
public AgentClientBaseService(IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public ProductEntity Product { get; set; }
|
||||
|
||||
public void Init(string BaseUrl,string Token)
|
||||
{
|
||||
this.BaseUrl = BaseUrl;
|
||||
this.Token = Token;
|
||||
}
|
||||
|
||||
public virtual string GetOpTitle(string op,string account)
|
||||
{
|
||||
return $"{this.ClientName}_{op}_{account}";
|
||||
}
|
||||
|
||||
protected virtual HttpClient CreateHttpClient(bool autoCooke = true)
|
||||
{
|
||||
var client = m_HttpClientFactory.CreateClient("agentClient");
|
||||
client.BaseAddress = new System.Uri(this.BaseUrl);
|
||||
|
||||
|
||||
|
||||
if (this.Token.Has()&& autoCooke)
|
||||
{
|
||||
AddCookie(client, this.Token);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
public virtual string MD5(string password) {
|
||||
byte[] textBytes = System.Text.Encoding.Default.GetBytes(password);
|
||||
try {
|
||||
System.Security.Cryptography.MD5CryptoServiceProvider cryptHandler;
|
||||
cryptHandler = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||
byte[] hash = cryptHandler.ComputeHash (textBytes);
|
||||
string ret = "";
|
||||
foreach (byte a in hash) {
|
||||
if (a<16)
|
||||
ret += "0" + a.ToString ("x");
|
||||
else
|
||||
ret += a.ToString ("x");
|
||||
}
|
||||
return ret ;
|
||||
}
|
||||
catch {
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected virtual void AddCookie(HttpClient client, string cookie)
|
||||
{
|
||||
client.DefaultRequestHeaders.Remove("Cookie");
|
||||
client.DefaultRequestHeaders.Add("Cookie", cookie);
|
||||
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + cookie);
|
||||
}
|
||||
public string GetCookie(HttpResponseMessage resp, string name)
|
||||
{
|
||||
if (resp.Headers.TryGetValues("Set-Cookie", out IEnumerable<string> cookies))
|
||||
{
|
||||
foreach (var cookie in cookies)
|
||||
{
|
||||
var ret = cookie.Split(";").FirstOrDefault(m => m.IndexOf(name) != -1);
|
||||
if (ret.Has())
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public string GetCookies(HttpResponseMessage resp)
|
||||
{
|
||||
if (resp.Headers.TryGetValues("Set-Cookie", out IEnumerable<string> cookies))
|
||||
{
|
||||
return string.Join(";", cookies);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
protected string GetCookieValue(string cookies, string name)
|
||||
{
|
||||
foreach (var item in cookies.Split(";"))
|
||||
{
|
||||
var token = item.Split("=");
|
||||
if (token.Length == 2 && token[0] == name)
|
||||
{
|
||||
return token[1];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public virtual async Task<int> RefrushStatus()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public virtual async Task<(byte[], string)> GetCode()
|
||||
{
|
||||
return (null, "");
|
||||
}
|
||||
public virtual async Task<ApiResult> Login(AgentLoginRequest request)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
public virtual bool CheckAccount(int productId,List<string> accounts)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> NewAccount(string packageKey, string account,string pwd,int connCount=1,int accountType=1, int payCount = 1)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
public virtual async Task<ApiResult> NewMuiltAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int startNum = 0, int endNum = 1)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> NewReAccount(string packageKey,string account,int connCount, int payCount = 1)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> DeleteAccount(string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到账号信息
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult<OriginAccountModel>> GetAccountInfo(string account, bool isTest = false)
|
||||
{
|
||||
return new ApiResult<OriginAccountModel>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> UpdateAccountPwd(string account,string pwd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> Refund(string account, string packageKey, int days)
|
||||
{
|
||||
return new ApiResult();
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(string account)
|
||||
{
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> KillOut(string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> Exist(string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class AgentClientLogHandler : DelegatingHandler
|
||||
{
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Headers.Contains("hl"))
|
||||
{
|
||||
Console.WriteLine(request.RequestUri.ToString());
|
||||
}
|
||||
return base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class AgentClientLogHandler : DelegatingHandler
|
||||
{
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Headers.Contains("hl"))
|
||||
{
|
||||
Console.WriteLine(request.RequestUri.ToString());
|
||||
}
|
||||
return base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,442 +1,442 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class AgentService:IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
protected ProductService m_ProductService;
|
||||
protected ProductPackageService m_ProductPackageService;
|
||||
protected ProductPackageUnitService m_ProductPackageUnitService;
|
||||
protected ProductEntity m_Product;
|
||||
protected ProductAccountChargeService m_AccountChargeService;
|
||||
protected Dictionary<string,AgentClientBaseService> m_MapAgentClient=new Dictionary<string, AgentClientBaseService>();
|
||||
public AgentService(ProductService _ProductService
|
||||
, ProductPackageService _ProductPackageService
|
||||
, ProductPackageUnitService _ProductPackageUnitService
|
||||
, ProductAccountChargeService _AccountChargeService
|
||||
, IHttpClientFactory httpClientFactory
|
||||
, CourseContext _DbContext)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
m_ProductService = _ProductService;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_ProductPackageUnitService = _ProductPackageUnitService;
|
||||
m_AccountChargeService = _AccountChargeService;
|
||||
m_DbContext = _DbContext;
|
||||
}
|
||||
|
||||
protected AgentClientBaseService _AgentClient;
|
||||
private AgentClientBaseService GetAgent(ProductEntity product)
|
||||
{
|
||||
AgentClientBaseService agent=null;
|
||||
if (product.GroupNO == "g1")
|
||||
agent = new AgentClient1Service(m_HttpClientFactory) { ClientName=product.GroupNO};
|
||||
if (product.GroupNO == "g2")
|
||||
agent = new AgentClient2Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g3")
|
||||
agent = new AgentClient3Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g4")
|
||||
agent = new AgentClient4Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g5")
|
||||
agent = new AgentClient5Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g6")
|
||||
agent = new AgentClient6Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g7")
|
||||
agent = new AgentClient7Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g8")
|
||||
agent = new AgentClient8Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g9")
|
||||
agent = new AgentClient9Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g10")
|
||||
agent = new AgentClient10Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g11")
|
||||
agent = new AgentClient11Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g12")
|
||||
agent = new AgentClient12Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g13")
|
||||
agent = new AgentClient13Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g14")
|
||||
agent = new AgentClient14Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g15")
|
||||
agent = new AgentClient15Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g16")
|
||||
agent = new AgentClient16Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g17")
|
||||
agent = new AgentClient17Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g18")
|
||||
agent = new AgentClient18Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g19")
|
||||
agent = new AgentClient19Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
agent.Product = product;
|
||||
return agent;
|
||||
}
|
||||
public async Task RefrushAllStatus()
|
||||
{
|
||||
var products = await m_ProductService.Query(false).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
await products.ForEachAsync(async m =>
|
||||
{
|
||||
// if (m.GroupNO == "g6")
|
||||
await RefrushStatus(m);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task RefrushStatus(ProductEntity product)
|
||||
{
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
int status = await agent.RefrushStatus();
|
||||
if (product.Status != status)
|
||||
{
|
||||
product.UpdateTime = DateTime.Now;
|
||||
product.Status = status;
|
||||
await m_ProductService.Update(product);
|
||||
}
|
||||
if (product.Status == 0)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"{product.Name}:离线");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
public virtual async Task<(byte[], string)> GetCode(int productId)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.GetCode();
|
||||
}
|
||||
public virtual async Task<ApiResult> Login(AgentLoginRequest request)
|
||||
{
|
||||
var product = await m_ProductService.GetById(request.ProductId);
|
||||
product.Token = request.Key;
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
request.Account = product.Account;
|
||||
request.Pwd = product.Pwd;
|
||||
var ret = await agent.Login(request);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
{
|
||||
product.Status = 1;
|
||||
product.Token = ret.Data.ToString();
|
||||
await m_ProductService.Update(product);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public virtual async Task<ApiResult<List<OriginAccountModel>>> GetOriginAccounts(List<ProductAccountEntity> accountList)
|
||||
{
|
||||
var retList = new List<OriginAccountModel>();
|
||||
foreach (var item in accountList)
|
||||
{
|
||||
var product = await m_ProductService.GetById(item.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
var account = item.Account;
|
||||
// if (product.GroupNO == "g7") account = item.Raw;
|
||||
var ret = await agent.GetAccountInfo(account);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
retList.Add(ret.Data as OriginAccountModel);
|
||||
}
|
||||
return new ApiResult<List<OriginAccountModel>>(retList);
|
||||
}
|
||||
|
||||
public virtual async Task<ApiResult<OriginAccountModel>> GetOriginAccountInfo(int productId, string account, string pwd = "")
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(productId, account);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var ret = await agent.GetAccountInfo(account);
|
||||
if (ret.Code != ResultCode.C_SUCCESS && product.Id!=17&& product.Id!=13) return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "账号不存在");
|
||||
if (pwd.Has()&&ret.Data.Pwd != pwd && product.Id!=17&& product.Id!=13)
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "密码不正确");
|
||||
return ret;
|
||||
}
|
||||
|
||||
public virtual async Task<List<OriginAccountModel>> GetOriginAccountInfo(int productId, List<string> accounts)
|
||||
{
|
||||
var list = new List<OriginAccountModel>();
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
foreach (var item in accounts)
|
||||
{
|
||||
var account = item;
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(productId, item);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var ret = await agent.GetAccountInfo(account);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
{
|
||||
list.Add(ret.Data);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> NewAccount(int orderId, int packageId, string account, string pwd, int connCount = 1, int accountType = 1,int payCount = 1)
|
||||
{
|
||||
ApiResult flagResult = new ApiResult(ResultCode.C_SUCCESS);
|
||||
var package = await m_ProductPackageService.GetById(packageId);
|
||||
var product = await m_ProductService.GetById(package.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
|
||||
if (package.PackageType == PackageType.Base)
|
||||
{
|
||||
var ret = await agent.NewAccount(package.OriginKey, account, pwd, connCount, accountType,payCount);
|
||||
//var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordNew(package, orderId, product.GroupNO, account, pwd, accountType, connCount, status);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
var basePackages = await m_ProductPackageService.GetBasePackages(packageId);
|
||||
var firstPackage = basePackages.FirstOrDefault();
|
||||
basePackages.Remove(firstPackage);
|
||||
if (firstPackage.Count > 1)
|
||||
{
|
||||
firstPackage.Count--;
|
||||
basePackages.Insert(0, firstPackage);
|
||||
}
|
||||
var ret = await agent.NewAccount(firstPackage.Package.OriginKey, account, pwd, connCount, accountType,payCount);
|
||||
//var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordNew(firstPackage.Package, orderId, product.GroupNO, account, pwd, accountType, connCount, status);
|
||||
|
||||
if (ret.Code != ResultCode.C_SUCCESS)
|
||||
flagResult = ret;
|
||||
|
||||
foreach (var item in basePackages)
|
||||
{
|
||||
for (var j = 0; j < item.Count; j++)
|
||||
{
|
||||
ret = await agent.NewReAccount(item.Package.OriginKey, account, connCount);
|
||||
// ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordReNew(item.Package, orderId, product.GroupNO, account, connCount, status);
|
||||
if (ret.Code != ResultCode.C_SUCCESS)
|
||||
flagResult = ret;
|
||||
}
|
||||
}
|
||||
return flagResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> ReNewAccount(int orderId, int packageId, string account, int connCount,int payCount = 1)
|
||||
{
|
||||
var package = await m_ProductPackageService.GetById(packageId);
|
||||
var product = await m_ProductService.GetById(package.ProductId);
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(package.ProductId, account);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
ApiResult flagResult = new ApiResult(ResultCode.C_SUCCESS);
|
||||
if (package.PackageType == PackageType.Base)
|
||||
{
|
||||
var ret = await agent.NewReAccount(package.OriginKey, account, connCount,payCount);
|
||||
// var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordReNew(package, orderId, product.GroupNO, account, connCount, status);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
var basePackages = await m_ProductPackageService.GetBasePackages(packageId);
|
||||
foreach (var basePackage in basePackages)
|
||||
{
|
||||
for (var j = 0; j < basePackage.Count; j++)
|
||||
{
|
||||
var ret = await agent.NewReAccount(basePackage.Package.OriginKey, account, connCount,payCount);
|
||||
//var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordReNew(basePackage.Package, orderId, product.GroupNO, account, connCount, status);
|
||||
if (status == ChargeStatus.Faild) flagResult = ret;
|
||||
}
|
||||
}
|
||||
return flagResult;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool DeleteAccount(int productId, string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> UpdateAccountPwd(int productId, string account, string pwd)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(productId, account);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// agent.Raw = accountInfo.Raw;
|
||||
// }
|
||||
return await agent.UpdateAccountPwd(account, pwd);
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> Refund(ProductPackageEntity package, ProductAccountEntity accountInfo)
|
||||
{
|
||||
var product = await m_ProductService.GetById(package.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
var account = accountInfo.Account;
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var flag = await agent.Refund(account, package.OriginKey, accountInfo.RestDay);
|
||||
return flag;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(int productId, string account)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.OnLine(account);
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> KillOut(int productId, string id)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.KillOut(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Exist(int productId, string account)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.Exist(account);
|
||||
}
|
||||
|
||||
public async Task FaildTry()
|
||||
{
|
||||
var records = await m_AccountChargeService.GetFaildRecord();
|
||||
|
||||
foreach (var chargeEntity in records)
|
||||
{
|
||||
if (chargeEntity.Status != ChargeStatus.Faild)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (chargeEntity.TryTimes > 3)
|
||||
{
|
||||
chargeEntity.Status = ChargeStatus.Outtime;
|
||||
chargeEntity.UpdateTime = DateTime.Now;
|
||||
await m_AccountChargeService.Update(chargeEntity);
|
||||
continue;
|
||||
}
|
||||
var product = await m_ProductService.GetById(chargeEntity.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
if (chargeEntity.OperationType == ChargeOperationType.New)
|
||||
{
|
||||
var ret = await agent.NewAccount(chargeEntity.PackageOriginKey, chargeEntity.Account, chargeEntity.Pwd, chargeEntity.ConnectCount, chargeEntity.AccountType);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
|
||||
chargeEntity.Status = status;
|
||||
chargeEntity.TryTimes++;
|
||||
chargeEntity.UpdateTime = DateTime.Now;
|
||||
await m_AccountChargeService.Update(chargeEntity);
|
||||
}else if(chargeEntity.OperationType == ChargeOperationType.ReNew)
|
||||
{
|
||||
var ret = await agent.NewReAccount(chargeEntity.PackageOriginKey, chargeEntity.Account, chargeEntity.ConnectCount);
|
||||
// var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
|
||||
chargeEntity.Status = status;
|
||||
chargeEntity.TryTimes++;
|
||||
chargeEntity.UpdateTime = DateTime.Now;
|
||||
await m_AccountChargeService.Update(chargeEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected async Task<ProductAccountEntity> GetProductAccount(int productId, string account)
|
||||
{
|
||||
return await m_DbContext.Set<ProductAccountEntity>().FirstOrDefaultAsync(m => m.ProductId == productId && m.Account == account);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class AgentService:IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
protected ProductService m_ProductService;
|
||||
protected ProductPackageService m_ProductPackageService;
|
||||
protected ProductPackageUnitService m_ProductPackageUnitService;
|
||||
protected ProductEntity m_Product;
|
||||
protected ProductAccountChargeService m_AccountChargeService;
|
||||
protected Dictionary<string,AgentClientBaseService> m_MapAgentClient=new Dictionary<string, AgentClientBaseService>();
|
||||
public AgentService(ProductService _ProductService
|
||||
, ProductPackageService _ProductPackageService
|
||||
, ProductPackageUnitService _ProductPackageUnitService
|
||||
, ProductAccountChargeService _AccountChargeService
|
||||
, IHttpClientFactory httpClientFactory
|
||||
, CourseContext _DbContext)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
m_ProductService = _ProductService;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
m_ProductPackageUnitService = _ProductPackageUnitService;
|
||||
m_AccountChargeService = _AccountChargeService;
|
||||
m_DbContext = _DbContext;
|
||||
}
|
||||
|
||||
protected AgentClientBaseService _AgentClient;
|
||||
private AgentClientBaseService GetAgent(ProductEntity product)
|
||||
{
|
||||
AgentClientBaseService agent=null;
|
||||
if (product.GroupNO == "g1")
|
||||
agent = new AgentClient1Service(m_HttpClientFactory) { ClientName=product.GroupNO};
|
||||
if (product.GroupNO == "g2")
|
||||
agent = new AgentClient2Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g3")
|
||||
agent = new AgentClient3Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g4")
|
||||
agent = new AgentClient4Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g5")
|
||||
agent = new AgentClient5Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g6")
|
||||
agent = new AgentClient6Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g7")
|
||||
agent = new AgentClient7Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g8")
|
||||
agent = new AgentClient8Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g9")
|
||||
agent = new AgentClient9Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g10")
|
||||
agent = new AgentClient10Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g11")
|
||||
agent = new AgentClient11Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g12")
|
||||
agent = new AgentClient12Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g13")
|
||||
agent = new AgentClient13Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g14")
|
||||
agent = new AgentClient14Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g15")
|
||||
agent = new AgentClient15Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g16")
|
||||
agent = new AgentClient16Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g17")
|
||||
agent = new AgentClient17Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g18")
|
||||
agent = new AgentClient18Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
if (product.GroupNO == "g19")
|
||||
agent = new AgentClient19Service(m_HttpClientFactory) { ClientName = product.GroupNO };
|
||||
agent.Product = product;
|
||||
return agent;
|
||||
}
|
||||
public async Task RefrushAllStatus()
|
||||
{
|
||||
var products = await m_ProductService.Query(false).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
await products.ForEachAsync(async m =>
|
||||
{
|
||||
// if (m.GroupNO == "g6")
|
||||
await RefrushStatus(m);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task RefrushStatus(ProductEntity product)
|
||||
{
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
int status = await agent.RefrushStatus();
|
||||
if (product.Status != status)
|
||||
{
|
||||
product.UpdateTime = DateTime.Now;
|
||||
product.Status = status;
|
||||
await m_ProductService.Update(product);
|
||||
}
|
||||
if (product.Status == 0)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"{product.Name}:离线");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
public virtual async Task<(byte[], string)> GetCode(int productId)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.GetCode();
|
||||
}
|
||||
public virtual async Task<ApiResult> Login(AgentLoginRequest request)
|
||||
{
|
||||
var product = await m_ProductService.GetById(request.ProductId);
|
||||
product.Token = request.Key;
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
request.Account = product.Account;
|
||||
request.Pwd = product.Pwd;
|
||||
var ret = await agent.Login(request);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
{
|
||||
product.Status = 1;
|
||||
product.Token = ret.Data.ToString();
|
||||
await m_ProductService.Update(product);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public virtual async Task<ApiResult<List<OriginAccountModel>>> GetOriginAccounts(List<ProductAccountEntity> accountList)
|
||||
{
|
||||
var retList = new List<OriginAccountModel>();
|
||||
foreach (var item in accountList)
|
||||
{
|
||||
var product = await m_ProductService.GetById(item.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
var account = item.Account;
|
||||
// if (product.GroupNO == "g7") account = item.Raw;
|
||||
var ret = await agent.GetAccountInfo(account);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
retList.Add(ret.Data as OriginAccountModel);
|
||||
}
|
||||
return new ApiResult<List<OriginAccountModel>>(retList);
|
||||
}
|
||||
|
||||
public virtual async Task<ApiResult<OriginAccountModel>> GetOriginAccountInfo(int productId, string account, string pwd = "")
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(productId, account);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var ret = await agent.GetAccountInfo(account);
|
||||
if (ret.Code != ResultCode.C_SUCCESS && product.Id!=17&& product.Id!=13) return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "账号不存在");
|
||||
if (pwd.Has()&&ret.Data.Pwd != pwd && product.Id!=17&& product.Id!=13)
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_NOT_EXISTS_ERROR, "密码不正确");
|
||||
return ret;
|
||||
}
|
||||
|
||||
public virtual async Task<List<OriginAccountModel>> GetOriginAccountInfo(int productId, List<string> accounts)
|
||||
{
|
||||
var list = new List<OriginAccountModel>();
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
foreach (var item in accounts)
|
||||
{
|
||||
var account = item;
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(productId, item);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var ret = await agent.GetAccountInfo(account);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
{
|
||||
list.Add(ret.Data);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> NewAccount(int orderId, int packageId, string account, string pwd, int connCount = 1, int accountType = 1,int payCount = 1)
|
||||
{
|
||||
ApiResult flagResult = new ApiResult(ResultCode.C_SUCCESS);
|
||||
var package = await m_ProductPackageService.GetById(packageId);
|
||||
var product = await m_ProductService.GetById(package.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
|
||||
if (package.PackageType == PackageType.Base)
|
||||
{
|
||||
var ret = await agent.NewAccount(package.OriginKey, account, pwd, connCount, accountType,payCount);
|
||||
//var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordNew(package, orderId, product.GroupNO, account, pwd, accountType, connCount, status);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
var basePackages = await m_ProductPackageService.GetBasePackages(packageId);
|
||||
var firstPackage = basePackages.FirstOrDefault();
|
||||
basePackages.Remove(firstPackage);
|
||||
if (firstPackage.Count > 1)
|
||||
{
|
||||
firstPackage.Count--;
|
||||
basePackages.Insert(0, firstPackage);
|
||||
}
|
||||
var ret = await agent.NewAccount(firstPackage.Package.OriginKey, account, pwd, connCount, accountType,payCount);
|
||||
//var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordNew(firstPackage.Package, orderId, product.GroupNO, account, pwd, accountType, connCount, status);
|
||||
|
||||
if (ret.Code != ResultCode.C_SUCCESS)
|
||||
flagResult = ret;
|
||||
|
||||
foreach (var item in basePackages)
|
||||
{
|
||||
for (var j = 0; j < item.Count; j++)
|
||||
{
|
||||
ret = await agent.NewReAccount(item.Package.OriginKey, account, connCount);
|
||||
// ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordReNew(item.Package, orderId, product.GroupNO, account, connCount, status);
|
||||
if (ret.Code != ResultCode.C_SUCCESS)
|
||||
flagResult = ret;
|
||||
}
|
||||
}
|
||||
return flagResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> ReNewAccount(int orderId, int packageId, string account, int connCount,int payCount = 1)
|
||||
{
|
||||
var package = await m_ProductPackageService.GetById(packageId);
|
||||
var product = await m_ProductService.GetById(package.ProductId);
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(package.ProductId, account);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
ApiResult flagResult = new ApiResult(ResultCode.C_SUCCESS);
|
||||
if (package.PackageType == PackageType.Base)
|
||||
{
|
||||
var ret = await agent.NewReAccount(package.OriginKey, account, connCount,payCount);
|
||||
// var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordReNew(package, orderId, product.GroupNO, account, connCount, status);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
var basePackages = await m_ProductPackageService.GetBasePackages(packageId);
|
||||
foreach (var basePackage in basePackages)
|
||||
{
|
||||
for (var j = 0; j < basePackage.Count; j++)
|
||||
{
|
||||
var ret = await agent.NewReAccount(basePackage.Package.OriginKey, account, connCount,payCount);
|
||||
//var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
await m_AccountChargeService.RecordReNew(basePackage.Package, orderId, product.GroupNO, account, connCount, status);
|
||||
if (status == ChargeStatus.Faild) flagResult = ret;
|
||||
}
|
||||
}
|
||||
return flagResult;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool DeleteAccount(int productId, string account)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> UpdateAccountPwd(int productId, string account, string pwd)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// var accountInfo = await GetProductAccount(productId, account);
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// agent.Raw = accountInfo.Raw;
|
||||
// }
|
||||
return await agent.UpdateAccountPwd(account, pwd);
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult> Refund(ProductPackageEntity package, ProductAccountEntity accountInfo)
|
||||
{
|
||||
var product = await m_ProductService.GetById(package.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
var account = accountInfo.Account;
|
||||
// if (product.GroupNO == "g7")
|
||||
// {
|
||||
// if (accountInfo != null && accountInfo.Raw.Has())
|
||||
// account = accountInfo.Raw;
|
||||
// }
|
||||
var flag = await agent.Refund(account, package.OriginKey, accountInfo.RestDay);
|
||||
return flag;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(int productId, string account)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.OnLine(account);
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<bool> KillOut(int productId, string id)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.KillOut(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Exist(int productId, string account)
|
||||
{
|
||||
var product = await m_ProductService.GetById(productId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
return await agent.Exist(account);
|
||||
}
|
||||
|
||||
public async Task FaildTry()
|
||||
{
|
||||
var records = await m_AccountChargeService.GetFaildRecord();
|
||||
|
||||
foreach (var chargeEntity in records)
|
||||
{
|
||||
if (chargeEntity.Status != ChargeStatus.Faild)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (chargeEntity.TryTimes > 3)
|
||||
{
|
||||
chargeEntity.Status = ChargeStatus.Outtime;
|
||||
chargeEntity.UpdateTime = DateTime.Now;
|
||||
await m_AccountChargeService.Update(chargeEntity);
|
||||
continue;
|
||||
}
|
||||
var product = await m_ProductService.GetById(chargeEntity.ProductId);
|
||||
var agent = GetAgent(product);
|
||||
agent.Init(product.BaseUrl, product.Token);
|
||||
if (chargeEntity.OperationType == ChargeOperationType.New)
|
||||
{
|
||||
var ret = await agent.NewAccount(chargeEntity.PackageOriginKey, chargeEntity.Account, chargeEntity.Pwd, chargeEntity.ConnectCount, chargeEntity.AccountType);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
|
||||
chargeEntity.Status = status;
|
||||
chargeEntity.TryTimes++;
|
||||
chargeEntity.UpdateTime = DateTime.Now;
|
||||
await m_AccountChargeService.Update(chargeEntity);
|
||||
}else if(chargeEntity.OperationType == ChargeOperationType.ReNew)
|
||||
{
|
||||
var ret = await agent.NewReAccount(chargeEntity.PackageOriginKey, chargeEntity.Account, chargeEntity.ConnectCount);
|
||||
// var ret = new ApiResult(ResultCode.C_INVALID_ERROR);
|
||||
var status = ret.Code == ResultCode.C_SUCCESS ? ChargeStatus.Ok : ChargeStatus.Faild;
|
||||
|
||||
chargeEntity.Status = status;
|
||||
chargeEntity.TryTimes++;
|
||||
chargeEntity.UpdateTime = DateTime.Now;
|
||||
await m_AccountChargeService.Update(chargeEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected async Task<ProductAccountEntity> GetProductAccount(int productId, string account)
|
||||
{
|
||||
return await m_DbContext.Set<ProductAccountEntity>().FirstOrDefaultAsync(m => m.ProductId == productId && m.Account == account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ArticleService : ServiceBase<ArticleEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ArticleService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<ArticleEntity>> GetTop(int top, ArticleCatalog catalog)
|
||||
{
|
||||
return await this.Query(m => m.CatalogId == catalog).OrderByDescending(m => m.Id).Take(top).ToListAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ArticleService : ServiceBase<ArticleEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ArticleService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<ArticleEntity>> GetTop(int top, ArticleCatalog catalog)
|
||||
{
|
||||
return await this.Query(m => m.CatalogId == catalog).OrderByDescending(m => m.Id).Take(top).ToListAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +1,96 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductAccountChargeService : ServiceBase<ProductAccountChargeEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductAccountChargeService(CourseContext dbContext
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录新开操作
|
||||
/// </summary>
|
||||
/// <param name="package"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="gid"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <param name="accountType"></param>
|
||||
/// <param name="connCount"></param>
|
||||
/// <param name="chargeStatus"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RecordNew(ProductPackageEntity package, int orderId, string gid, string account, string pwd, int accountType, int connCount, ChargeStatus chargeStatus = ChargeStatus.Ok)
|
||||
{
|
||||
var chargeEntity = new ProductAccountChargeEntity()
|
||||
{
|
||||
Account = account,
|
||||
AccountType = accountType,
|
||||
ConnectCount = connCount,
|
||||
OperationType = ChargeOperationType.New,
|
||||
OrderId = orderId,
|
||||
PackageId = package.Id,
|
||||
PackageOriginKey = package.OriginKey,
|
||||
ProductGroup = gid,
|
||||
ProductId = package.ProductId,
|
||||
Pwd = pwd,
|
||||
Status = chargeStatus,
|
||||
TryTimes = 1,
|
||||
};
|
||||
await this.Add(chargeEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录续费操作
|
||||
/// </summary>
|
||||
/// <param name="package"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="gid"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <param name="accountType"></param>
|
||||
/// <param name="connCount"></param>
|
||||
/// <param name="chargeStatus"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RecordReNew(ProductPackageEntity package, int orderId, string gid, string account, int connCount, ChargeStatus chargeStatus = ChargeStatus.Ok)
|
||||
{
|
||||
var chargeEntity = new ProductAccountChargeEntity()
|
||||
{
|
||||
Account = account,
|
||||
AccountType =0,
|
||||
ConnectCount = connCount,
|
||||
OperationType = ChargeOperationType.ReNew,
|
||||
OrderId = orderId,
|
||||
PackageId = package.Id,
|
||||
PackageOriginKey = package.OriginKey,
|
||||
ProductGroup = gid,
|
||||
ProductId = package.ProductId,
|
||||
Pwd = "",
|
||||
Status = chargeStatus,
|
||||
TryTimes = 1,
|
||||
};
|
||||
await this.Add(chargeEntity);
|
||||
}
|
||||
|
||||
public async Task<List<ProductAccountChargeEntity>> GetFaildRecord(int maxTryTimes = 3, int maxTop = 100)
|
||||
{
|
||||
var query = this.Query(m => m.Status == ChargeStatus.Faild
|
||||
&& m.TryTimes <= maxTryTimes
|
||||
&& (DateTime.Now - m.CreateTime).Minutes <= 10);
|
||||
return await query.OrderBy(m => m.Id)
|
||||
.Take(maxTop)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductAccountChargeService : ServiceBase<ProductAccountChargeEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductAccountChargeService(CourseContext dbContext
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录新开操作
|
||||
/// </summary>
|
||||
/// <param name="package"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="gid"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <param name="accountType"></param>
|
||||
/// <param name="connCount"></param>
|
||||
/// <param name="chargeStatus"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RecordNew(ProductPackageEntity package, int orderId, string gid, string account, string pwd, int accountType, int connCount, ChargeStatus chargeStatus = ChargeStatus.Ok)
|
||||
{
|
||||
var chargeEntity = new ProductAccountChargeEntity()
|
||||
{
|
||||
Account = account,
|
||||
AccountType = accountType,
|
||||
ConnectCount = connCount,
|
||||
OperationType = ChargeOperationType.New,
|
||||
OrderId = orderId,
|
||||
PackageId = package.Id,
|
||||
PackageOriginKey = package.OriginKey,
|
||||
ProductGroup = gid,
|
||||
ProductId = package.ProductId,
|
||||
Pwd = pwd,
|
||||
Status = chargeStatus,
|
||||
TryTimes = 1,
|
||||
};
|
||||
await this.Add(chargeEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录续费操作
|
||||
/// </summary>
|
||||
/// <param name="package"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="gid"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <param name="accountType"></param>
|
||||
/// <param name="connCount"></param>
|
||||
/// <param name="chargeStatus"></param>
|
||||
/// <returns></returns>
|
||||
public async Task RecordReNew(ProductPackageEntity package, int orderId, string gid, string account, int connCount, ChargeStatus chargeStatus = ChargeStatus.Ok)
|
||||
{
|
||||
var chargeEntity = new ProductAccountChargeEntity()
|
||||
{
|
||||
Account = account,
|
||||
AccountType =0,
|
||||
ConnectCount = connCount,
|
||||
OperationType = ChargeOperationType.ReNew,
|
||||
OrderId = orderId,
|
||||
PackageId = package.Id,
|
||||
PackageOriginKey = package.OriginKey,
|
||||
ProductGroup = gid,
|
||||
ProductId = package.ProductId,
|
||||
Pwd = "",
|
||||
Status = chargeStatus,
|
||||
TryTimes = 1,
|
||||
};
|
||||
await this.Add(chargeEntity);
|
||||
}
|
||||
|
||||
public async Task<List<ProductAccountChargeEntity>> GetFaildRecord(int maxTryTimes = 3, int maxTop = 100)
|
||||
{
|
||||
var query = this.Query(m => m.Status == ChargeStatus.Faild
|
||||
&& m.TryTimes <= maxTryTimes
|
||||
&& (DateTime.Now - m.CreateTime).Minutes <= 10);
|
||||
return await query.OrderBy(m => m.Id)
|
||||
.Take(maxTop)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,197 +1,197 @@
|
||||
using HHncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.EF;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductAccountService : ServiceBase<ProductAccountEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
private IConfiguration m_Configuration;
|
||||
public AgentService m_AgentService;
|
||||
private UserService m_UserService;
|
||||
public ProductAccountService(CourseContext dbContext
|
||||
, AgentService _AgentService
|
||||
, UserService _UserService
|
||||
, IConfiguration _Configuration
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
m_AgentService = _AgentService;
|
||||
m_Configuration = _Configuration;
|
||||
m_UserService = _UserService;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckAccountExist(int productId, List<string> accouts)
|
||||
{
|
||||
var flag = this.Exist(m => accouts.Contains(m.Account) && m.DeleteTag == 0);
|
||||
if (flag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
foreach (var item in accouts)
|
||||
{
|
||||
var ret = await m_AgentService.Exist(productId, item);
|
||||
await Task.Delay(50);
|
||||
if (ret == true)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//检查参加活动账号是否已经存在
|
||||
public async Task<bool> CheckMonthAccountExist(string account)
|
||||
{
|
||||
var flag = this.Exist(m => m.Account == account && m.PackageId == 86);
|
||||
if (flag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool CheckUserAccountExist(int product, List<string> accouts, int userId)
|
||||
{
|
||||
return this.Exist(m => accouts.Contains(m.Account) && m.UserId == userId);
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetAccountInfo(string accout, int userId)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m => m.Account == accout && m.UserId == userId && m.DeleteTag == 0);
|
||||
}
|
||||
|
||||
public async Task<List<ProductAccountEntity>> GetAccounts(string accouts,int userId=0)
|
||||
{
|
||||
var alist = accouts.Split(",");
|
||||
return await this.Query(m =>(userId==0||m.UserId== userId)&& alist.Contains(m.Account)&&m.DeleteTag==0).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetAccountInfo(string accout)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m => m.Account == accout);
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetAccountInfo(int packageId,string accout)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m =>m.PackageId== packageId&& m.Account == accout);
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetProductAccountInfo(int productId, string accout)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m => m.ProductId == productId && m.Account == accout && m.DeleteTag == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// day 0:已过期,1天
|
||||
/// </summary>
|
||||
/// <param name="day"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProductAccountEntity>> GetExpireingAccounts_bak(int day)
|
||||
{
|
||||
Expression<Func<ProductAccountEntity, bool>> expr = m => 1 == 1;
|
||||
|
||||
if (day == 0)
|
||||
{
|
||||
expr = expr.And(m => m.EndTime.Value < DateTime.Now);
|
||||
}
|
||||
else
|
||||
{
|
||||
var startTime = DateTime.Now.Begin().AddDays(day);
|
||||
var EndTime = DateTime.Now.End().AddDays(day);
|
||||
expr = expr.And(m => m.EndTime >= startTime && m.EndTime <= EndTime);
|
||||
}
|
||||
return await this.Query(expr,true).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<ProductAccountEntity>> GetExpireingAccounts(int day)
|
||||
{
|
||||
var sql = $"select * from product_account where DATEDIFF(EndTime,now())={day}";
|
||||
return this.m_DbContext.SqlQuery<ProductAccountEntity>(sql);
|
||||
}
|
||||
|
||||
//主要是用来定时执行的
|
||||
public async Task<List<ProductAccountEntity>> GetExpireingAccountsTime(int day)
|
||||
{
|
||||
var sql = $"select * from product_account WHERE DATEDIFF(EndTime,now())={day} AND `PackageName` NOT LIKE '天卡' AND `PackageName` NOT LIKE '测试卡' GROUP BY UserId";
|
||||
// var sql = $"select * from product_account where DATEDIFF(EndTime,now())={day} AND PackageName!='测试卡' AND PackageName!='天卡' GROUP BY UserId";
|
||||
return this.m_DbContext.SqlQuery<ProductAccountEntity>(sql);
|
||||
}
|
||||
|
||||
public async Task<ApiResult> UpdateAccountPwd(UpdateAccountPwdRequest request)
|
||||
{
|
||||
var entity = await this.GetById(request.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "账号不存在");
|
||||
}
|
||||
if (request.Pwd.NotHas())
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "密码不能为空");
|
||||
}
|
||||
var agentRet = await m_AgentService.UpdateAccountPwd(entity.ProductId.Value, entity.Account, request.Pwd);
|
||||
if (!agentRet)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "远程更新失败");
|
||||
}
|
||||
entity.Pwd = request.Pwd;
|
||||
await this.Update(entity);
|
||||
return new ApiResult(1);
|
||||
}
|
||||
|
||||
public async Task<ApiResult> ApiUpdateAccountPwd(UpdateAccountPwdRequest request,int userid)
|
||||
{
|
||||
var entity = await this.Query(m => m.Account == request.Account && m.Pwd == request.Pwd && m.DeleteTag == 0 && m.UserId == userid).FirstOrDefaultAsync();
|
||||
if (entity == null)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "账号不存在");
|
||||
}
|
||||
if (request.Pwd.NotHas()&&request.RePwd.NotHas())
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "密码不能为空");
|
||||
}
|
||||
var agentRet = await m_AgentService.UpdateAccountPwd(entity.ProductId.Value, entity.Account, request.RePwd);
|
||||
if (!agentRet)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "远程更新失败");
|
||||
}
|
||||
entity.Pwd = request.RePwd;
|
||||
await this.Update(entity);
|
||||
return new ApiResult(1);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<ProductAccountEntity>> GetUserTestAccount(int userId)
|
||||
{
|
||||
return await this.Query(m => m.UserId == userId && m.AccountType == (int)AccountType.Test).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> GetRestTestCount(int userId)
|
||||
{
|
||||
var userInfo = await m_UserService.GetById(userId);
|
||||
var restTimes = Convert.ToInt32(m_Configuration["TestCountLimit"]);
|
||||
if (userInfo.TestCountLimit > 0) restTimes = userInfo.TestCountLimit.Value;
|
||||
restTimes = restTimes - userInfo.UseTestCount.Value;
|
||||
restTimes = restTimes < 0 ? 0 : restTimes;
|
||||
return restTimes;
|
||||
}
|
||||
//获取是否实名认证
|
||||
public async Task<int> GetUserStatus(int userId)
|
||||
{
|
||||
var userInfo = await m_UserService.GetById(userId);
|
||||
var flag = userInfo.is_verify;
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
using HHncore.Pass.Vpn.Request.Product;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.EF;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductAccountService : ServiceBase<ProductAccountEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
private IConfiguration m_Configuration;
|
||||
public AgentService m_AgentService;
|
||||
private UserService m_UserService;
|
||||
public ProductAccountService(CourseContext dbContext
|
||||
, AgentService _AgentService
|
||||
, UserService _UserService
|
||||
, IConfiguration _Configuration
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
m_AgentService = _AgentService;
|
||||
m_Configuration = _Configuration;
|
||||
m_UserService = _UserService;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckAccountExist(int productId, List<string> accouts)
|
||||
{
|
||||
var flag = this.Exist(m => accouts.Contains(m.Account) && m.DeleteTag == 0);
|
||||
if (flag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
foreach (var item in accouts)
|
||||
{
|
||||
var ret = await m_AgentService.Exist(productId, item);
|
||||
await Task.Delay(50);
|
||||
if (ret == true)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//检查参加活动账号是否已经存在
|
||||
public async Task<bool> CheckMonthAccountExist(string account)
|
||||
{
|
||||
var flag = this.Exist(m => m.Account == account && m.PackageId == 86);
|
||||
if (flag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public bool CheckUserAccountExist(int product, List<string> accouts, int userId)
|
||||
{
|
||||
return this.Exist(m => accouts.Contains(m.Account) && m.UserId == userId);
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetAccountInfo(string accout, int userId)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m => m.Account == accout && m.UserId == userId && m.DeleteTag == 0);
|
||||
}
|
||||
|
||||
public async Task<List<ProductAccountEntity>> GetAccounts(string accouts,int userId=0)
|
||||
{
|
||||
var alist = accouts.Split(",");
|
||||
return await this.Query(m =>(userId==0||m.UserId== userId)&& alist.Contains(m.Account)&&m.DeleteTag==0).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetAccountInfo(string accout)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m => m.Account == accout);
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetAccountInfo(int packageId,string accout)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m =>m.PackageId== packageId&& m.Account == accout);
|
||||
}
|
||||
|
||||
public async Task<ProductAccountEntity> GetProductAccountInfo(int productId, string accout)
|
||||
{
|
||||
return await this.Query(true).FirstOrDefaultAsync(m => m.ProductId == productId && m.Account == accout && m.DeleteTag == 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// day 0:已过期,1天
|
||||
/// </summary>
|
||||
/// <param name="day"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ProductAccountEntity>> GetExpireingAccounts_bak(int day)
|
||||
{
|
||||
Expression<Func<ProductAccountEntity, bool>> expr = m => 1 == 1;
|
||||
|
||||
if (day == 0)
|
||||
{
|
||||
expr = expr.And(m => m.EndTime.Value < DateTime.Now);
|
||||
}
|
||||
else
|
||||
{
|
||||
var startTime = DateTime.Now.Begin().AddDays(day);
|
||||
var EndTime = DateTime.Now.End().AddDays(day);
|
||||
expr = expr.And(m => m.EndTime >= startTime && m.EndTime <= EndTime);
|
||||
}
|
||||
return await this.Query(expr,true).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<ProductAccountEntity>> GetExpireingAccounts(int day)
|
||||
{
|
||||
var sql = $"select * from product_account where DATEDIFF(EndTime,now())={day}";
|
||||
return this.m_DbContext.SqlQuery<ProductAccountEntity>(sql);
|
||||
}
|
||||
|
||||
//主要是用来定时执行的
|
||||
public async Task<List<ProductAccountEntity>> GetExpireingAccountsTime(int day)
|
||||
{
|
||||
var sql = $"select * from product_account WHERE DATEDIFF(EndTime,now())={day} AND `PackageName` NOT LIKE '天卡' AND `PackageName` NOT LIKE '测试卡' GROUP BY UserId";
|
||||
// var sql = $"select * from product_account where DATEDIFF(EndTime,now())={day} AND PackageName!='测试卡' AND PackageName!='天卡' GROUP BY UserId";
|
||||
return this.m_DbContext.SqlQuery<ProductAccountEntity>(sql);
|
||||
}
|
||||
|
||||
public async Task<ApiResult> UpdateAccountPwd(UpdateAccountPwdRequest request)
|
||||
{
|
||||
var entity = await this.GetById(request.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "账号不存在");
|
||||
}
|
||||
if (request.Pwd.NotHas())
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "密码不能为空");
|
||||
}
|
||||
var agentRet = await m_AgentService.UpdateAccountPwd(entity.ProductId.Value, entity.Account, request.Pwd);
|
||||
if (!agentRet)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "远程更新失败");
|
||||
}
|
||||
entity.Pwd = request.Pwd;
|
||||
await this.Update(entity);
|
||||
return new ApiResult(1);
|
||||
}
|
||||
|
||||
public async Task<ApiResult> ApiUpdateAccountPwd(UpdateAccountPwdRequest request,int userid)
|
||||
{
|
||||
var entity = await this.Query(m => m.Account == request.Account && m.Pwd == request.Pwd && m.DeleteTag == 0 && m.UserId == userid).FirstOrDefaultAsync();
|
||||
if (entity == null)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "账号不存在");
|
||||
}
|
||||
if (request.Pwd.NotHas()&&request.RePwd.NotHas())
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "密码不能为空");
|
||||
}
|
||||
var agentRet = await m_AgentService.UpdateAccountPwd(entity.ProductId.Value, entity.Account, request.RePwd);
|
||||
if (!agentRet)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "远程更新失败");
|
||||
}
|
||||
entity.Pwd = request.RePwd;
|
||||
await this.Update(entity);
|
||||
return new ApiResult(1);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<ProductAccountEntity>> GetUserTestAccount(int userId)
|
||||
{
|
||||
return await this.Query(m => m.UserId == userId && m.AccountType == (int)AccountType.Test).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> GetRestTestCount(int userId)
|
||||
{
|
||||
var userInfo = await m_UserService.GetById(userId);
|
||||
var restTimes = Convert.ToInt32(m_Configuration["TestCountLimit"]);
|
||||
if (userInfo.TestCountLimit > 0) restTimes = userInfo.TestCountLimit.Value;
|
||||
restTimes = restTimes - userInfo.UseTestCount.Value;
|
||||
restTimes = restTimes < 0 ? 0 : restTimes;
|
||||
return restTimes;
|
||||
}
|
||||
//获取是否实名认证
|
||||
public async Task<int> GetUserStatus(int userId)
|
||||
{
|
||||
var userInfo = await m_UserService.GetById(userId);
|
||||
var flag = userInfo.is_verify;
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductOrderItemService : ServiceBase<ProductOrderItemEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductOrderItemService(CourseContext dbContext
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
public async Task<List<ProductOrderItemEntity>> CreateOrderItems(ProductOrderEntity orderEntity,string pwd)
|
||||
{
|
||||
List<ProductOrderItemEntity> items = new List<ProductOrderItemEntity>();
|
||||
var accounts = orderEntity.Accounts.Split(',').ToList();
|
||||
accounts.ForEach(m =>
|
||||
{
|
||||
var item = new ProductOrderItemEntity()
|
||||
{
|
||||
ConnectCount = orderEntity.ConnectCount,
|
||||
DayPrice = orderEntity.DayPrice.Value,
|
||||
DayCount=orderEntity.DayCount,
|
||||
OrderId = orderEntity.Id,
|
||||
OrderNo = orderEntity.OrderNo,
|
||||
OrderState = orderEntity.OrderState,
|
||||
OrderType = orderEntity.OrderType,
|
||||
PackageId = orderEntity.PackageId,
|
||||
PackageName = orderEntity.PackageName,
|
||||
PayState = orderEntity.PayState,
|
||||
PayType = orderEntity.PayType,
|
||||
Account = m,
|
||||
ProductId = orderEntity.ProductId,
|
||||
ProductName = orderEntity.ProductName,
|
||||
TenantId = orderEntity.TenantId,
|
||||
UserId = orderEntity.UserId,
|
||||
UserName = orderEntity.UserName,
|
||||
AccountPwd = pwd
|
||||
};
|
||||
items.Add(item);
|
||||
});
|
||||
await this.Adds(items);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
public async Task<ProductOrderItemEntity> GetLastByAccount(string account)
|
||||
{
|
||||
var orderItem = await this.Query(m => m.Account == account && m.OrderState == OrderStatus.Complete)
|
||||
.OrderByDescending(m => m.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
return orderItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductOrderItemService : ServiceBase<ProductOrderItemEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductOrderItemService(CourseContext dbContext
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
public async Task<List<ProductOrderItemEntity>> CreateOrderItems(ProductOrderEntity orderEntity,string pwd)
|
||||
{
|
||||
List<ProductOrderItemEntity> items = new List<ProductOrderItemEntity>();
|
||||
var accounts = orderEntity.Accounts.Split(',').ToList();
|
||||
accounts.ForEach(m =>
|
||||
{
|
||||
var item = new ProductOrderItemEntity()
|
||||
{
|
||||
ConnectCount = orderEntity.ConnectCount,
|
||||
DayPrice = orderEntity.DayPrice.Value,
|
||||
DayCount=orderEntity.DayCount,
|
||||
OrderId = orderEntity.Id,
|
||||
OrderNo = orderEntity.OrderNo,
|
||||
OrderState = orderEntity.OrderState,
|
||||
OrderType = orderEntity.OrderType,
|
||||
PackageId = orderEntity.PackageId,
|
||||
PackageName = orderEntity.PackageName,
|
||||
PayState = orderEntity.PayState,
|
||||
PayType = orderEntity.PayType,
|
||||
Account = m,
|
||||
ProductId = orderEntity.ProductId,
|
||||
ProductName = orderEntity.ProductName,
|
||||
TenantId = orderEntity.TenantId,
|
||||
UserId = orderEntity.UserId,
|
||||
UserName = orderEntity.UserName,
|
||||
AccountPwd = pwd
|
||||
};
|
||||
items.Add(item);
|
||||
});
|
||||
await this.Adds(items);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
public async Task<ProductOrderItemEntity> GetLastByAccount(string account)
|
||||
{
|
||||
var orderItem = await this.Query(m => m.Account == account && m.OrderState == OrderStatus.Complete)
|
||||
.OrderByDescending(m => m.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
return orderItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,34 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPackageService : ServiceBase<ProductPackageEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
ProductPackageUnitService m_ProductPackageUnitService;
|
||||
public ProductPackageService(CourseContext dbContext
|
||||
, ProductPackageUnitService _ProductPackageUnitService
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
this.m_ProductPackageUnitService = _ProductPackageUnitService;
|
||||
}
|
||||
|
||||
public async Task<List<PackageUnitItemModel>> GetBasePackages(int packageId)
|
||||
{
|
||||
var packageUnits = m_ProductPackageUnitService.Query(m => m.PackageId == packageId);
|
||||
|
||||
var query = from packageUnit in packageUnits
|
||||
join package in this.Query(true) on packageUnit.BasePackageId equals package.Id
|
||||
select new PackageUnitItemModel { Count = packageUnit.Count, Package = package };
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPackageService : ServiceBase<ProductPackageEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
ProductPackageUnitService m_ProductPackageUnitService;
|
||||
public ProductPackageService(CourseContext dbContext
|
||||
, ProductPackageUnitService _ProductPackageUnitService
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
this.m_ProductPackageUnitService = _ProductPackageUnitService;
|
||||
}
|
||||
|
||||
public async Task<List<PackageUnitItemModel>> GetBasePackages(int packageId)
|
||||
{
|
||||
var packageUnits = m_ProductPackageUnitService.Query(m => m.PackageId == packageId);
|
||||
|
||||
var query = from packageUnit in packageUnits
|
||||
join package in this.Query(true) on packageUnit.BasePackageId equals package.Id
|
||||
select new PackageUnitItemModel { Count = packageUnit.Count, Package = package };
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPackageUnitService : ServiceBase<ProductPackageUnitEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductPackageUnitService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPackageUnitService : ServiceBase<ProductPackageUnitEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductPackageUnitService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System.Linq;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPriceDiscountService : ServiceBase<ProductPriceDiscountEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
ProductService m_ProductService;
|
||||
ProductPackageService m_ProductPackageService;
|
||||
public ProductPriceDiscountService(CourseContext dbContext
|
||||
, ProductService _ProductService
|
||||
, ProductPackageService _ProductPackageService
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
m_ProductService = _ProductService;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
}
|
||||
|
||||
public async Task<List<ProductWithPriceDiscountResponse>> GetPriceDiscount(int schemeId)
|
||||
{
|
||||
var products = await m_ProductService.Query(true).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
var packages = m_ProductPackageService.Query(true);
|
||||
var priceDiscount = this.Query(m => m.SchemeId == schemeId);
|
||||
var ret = from pakcage in packages
|
||||
join uDiscount in priceDiscount on pakcage.Id equals uDiscount.PackageId into temp
|
||||
from uDiscount in temp.DefaultIfEmpty()
|
||||
select new PackagePriceDiscount()
|
||||
{
|
||||
Package = pakcage,
|
||||
PriceDiscount = uDiscount ?? new ProductPriceDiscountEntity()
|
||||
};
|
||||
var packgesPrice = await ret.ToListAsync();
|
||||
|
||||
List<ProductWithPriceDiscountResponse> respList = new List<ProductWithPriceDiscountResponse>();
|
||||
products.ForEach(p =>
|
||||
{
|
||||
var resp = new ProductWithPriceDiscountResponse();
|
||||
resp.Product = p.MapTo<ProductResponse>();
|
||||
resp.PackageDiscounts = packgesPrice.Where(m => m.Package.ProductId == p.Id).ToList();
|
||||
respList.Add(resp);
|
||||
});
|
||||
return respList;
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System.Linq;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPriceDiscountService : ServiceBase<ProductPriceDiscountEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
ProductService m_ProductService;
|
||||
ProductPackageService m_ProductPackageService;
|
||||
public ProductPriceDiscountService(CourseContext dbContext
|
||||
, ProductService _ProductService
|
||||
, ProductPackageService _ProductPackageService
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
m_ProductService = _ProductService;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
}
|
||||
|
||||
public async Task<List<ProductWithPriceDiscountResponse>> GetPriceDiscount(int schemeId)
|
||||
{
|
||||
var products = await m_ProductService.Query(true).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
var packages = m_ProductPackageService.Query(true);
|
||||
var priceDiscount = this.Query(m => m.SchemeId == schemeId);
|
||||
var ret = from pakcage in packages
|
||||
join uDiscount in priceDiscount on pakcage.Id equals uDiscount.PackageId into temp
|
||||
from uDiscount in temp.DefaultIfEmpty()
|
||||
select new PackagePriceDiscount()
|
||||
{
|
||||
Package = pakcage,
|
||||
PriceDiscount = uDiscount ?? new ProductPriceDiscountEntity()
|
||||
};
|
||||
var packgesPrice = await ret.ToListAsync();
|
||||
|
||||
List<ProductWithPriceDiscountResponse> respList = new List<ProductWithPriceDiscountResponse>();
|
||||
products.ForEach(p =>
|
||||
{
|
||||
var resp = new ProductWithPriceDiscountResponse();
|
||||
resp.Product = p.MapTo<ProductResponse>();
|
||||
resp.PackageDiscounts = packgesPrice.Where(m => m.Package.ProductId == p.Id).ToList();
|
||||
respList.Add(resp);
|
||||
});
|
||||
return respList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPriceSchemeService : ServiceBase<ProductPriceSchemeEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductPriceSchemeService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductPriceSchemeService : ServiceBase<ProductPriceSchemeEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductPriceSchemeService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductRouteService : ServiceBase<ProductRouteEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductRouteService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductRouteService : ServiceBase<ProductRouteEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public ProductRouteService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductService : ServiceBase<ProductEntity>, IFindService
|
||||
{
|
||||
private static readonly string m_ProductCacheKey = "Product:{0}";
|
||||
CourseContext m_DbContext;
|
||||
ProductPackageService m_ProductPackageService;
|
||||
public ProductService(CourseContext dbContext, ProductPackageService _ProductPackageService, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
}
|
||||
|
||||
|
||||
public async override Task<ProductEntity> GetById(object id)
|
||||
{
|
||||
return await base.GetById(id);
|
||||
string key = string.Format(m_ProductCacheKey, id);
|
||||
|
||||
var cacheData = await RedisHelper.GetAsync<ProductEntity>(key);
|
||||
if (cacheData == null)
|
||||
{
|
||||
cacheData = await base.GetById(id);
|
||||
if (cacheData != null)
|
||||
await RedisHelper.SetAsync(key, cacheData, 60 * 30);
|
||||
}
|
||||
|
||||
return cacheData;
|
||||
}
|
||||
|
||||
|
||||
public async override Task<bool> Update(ProductEntity entity, bool autoSave = true)
|
||||
{
|
||||
string key = string.Format(m_ProductCacheKey, entity.Id);
|
||||
await RedisHelper.SetAsync(key, entity, 60 * 30);
|
||||
return await base.Update(entity, autoSave);
|
||||
}
|
||||
|
||||
public async Task<List<ProductWithPackageResponse>> ProductWithPackage(int online=1)
|
||||
{
|
||||
var products = await this.Query(m => m.Sort != 1000).OrderBy(m=>m.Sort).Where(m=>m.OnLine==online).ToListAsync();
|
||||
var packages = await m_ProductPackageService.Query(true).ToListAsync();
|
||||
|
||||
List<ProductWithPackageResponse> respList = new List<ProductWithPackageResponse>();
|
||||
products.ForEach(p =>
|
||||
{
|
||||
var resp = new ProductWithPackageResponse();
|
||||
resp.Product = p.MapTo<ProductResponse>();
|
||||
resp.Packages = packages.Where(m => m.ProductId == p.Id).ToList();
|
||||
respList.Add(resp);
|
||||
});
|
||||
return respList;
|
||||
}
|
||||
|
||||
public async Task<ProductWithPackageResponse> GetOneProductWithPackage(int productId)
|
||||
{
|
||||
var product = await this.GetById(productId);
|
||||
var packages = await m_ProductPackageService.Query(m => m.ProductId == productId).ToListAsync();
|
||||
|
||||
List<ProductWithPackageResponse> respList = new List<ProductWithPackageResponse>();
|
||||
var resp = new ProductWithPackageResponse();
|
||||
resp.Product = product.MapTo<ProductResponse>();
|
||||
resp.Packages = packages;
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductService : ServiceBase<ProductEntity>, IFindService
|
||||
{
|
||||
private static readonly string m_ProductCacheKey = "Product:{0}";
|
||||
CourseContext m_DbContext;
|
||||
ProductPackageService m_ProductPackageService;
|
||||
public ProductService(CourseContext dbContext, ProductPackageService _ProductPackageService, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
m_ProductPackageService = _ProductPackageService;
|
||||
}
|
||||
|
||||
|
||||
public async override Task<ProductEntity> GetById(object id)
|
||||
{
|
||||
return await base.GetById(id);
|
||||
string key = string.Format(m_ProductCacheKey, id);
|
||||
|
||||
var cacheData = await RedisHelper.GetAsync<ProductEntity>(key);
|
||||
if (cacheData == null)
|
||||
{
|
||||
cacheData = await base.GetById(id);
|
||||
if (cacheData != null)
|
||||
await RedisHelper.SetAsync(key, cacheData, 60 * 30);
|
||||
}
|
||||
|
||||
return cacheData;
|
||||
}
|
||||
|
||||
|
||||
public async override Task<bool> Update(ProductEntity entity, bool autoSave = true)
|
||||
{
|
||||
string key = string.Format(m_ProductCacheKey, entity.Id);
|
||||
await RedisHelper.SetAsync(key, entity, 60 * 30);
|
||||
return await base.Update(entity, autoSave);
|
||||
}
|
||||
|
||||
public async Task<List<ProductWithPackageResponse>> ProductWithPackage(int online=1)
|
||||
{
|
||||
var products = await this.Query(m => m.Sort != 1000).OrderBy(m=>m.Sort).Where(m=>m.OnLine==online).ToListAsync();
|
||||
var packages = await m_ProductPackageService.Query(true).ToListAsync();
|
||||
|
||||
List<ProductWithPackageResponse> respList = new List<ProductWithPackageResponse>();
|
||||
products.ForEach(p =>
|
||||
{
|
||||
var resp = new ProductWithPackageResponse();
|
||||
resp.Product = p.MapTo<ProductResponse>();
|
||||
resp.Packages = packages.Where(m => m.ProductId == p.Id).ToList();
|
||||
respList.Add(resp);
|
||||
});
|
||||
return respList;
|
||||
}
|
||||
|
||||
public async Task<ProductWithPackageResponse> GetOneProductWithPackage(int productId)
|
||||
{
|
||||
var product = await this.GetById(productId);
|
||||
var packages = await m_ProductPackageService.Query(m => m.ProductId == productId).ToListAsync();
|
||||
|
||||
List<ProductWithPackageResponse> respList = new List<ProductWithPackageResponse>();
|
||||
var resp = new ProductWithPackageResponse();
|
||||
resp.Product = product.MapTo<ProductResponse>();
|
||||
resp.Packages = packages;
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductUserPriceService : ServiceBase<ProductUserPriceEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
ProductService m_ProductService;
|
||||
ProductPackageService m_ProductPackageService;
|
||||
public ProductUserPriceService(ProductPackageService m_ProductPackageService
|
||||
, ProductService m_ProductService
|
||||
,CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
this.m_ProductPackageService = m_ProductPackageService;
|
||||
this.m_ProductService = m_ProductService;
|
||||
}
|
||||
|
||||
public async Task<List<ProductWithPackageUserPriceResponse>> GetPackageUserPrice(int userId)
|
||||
{
|
||||
var products = await m_ProductService.Query( m=>m.OnLine == 1).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
var packages = m_ProductPackageService.Query(true);
|
||||
var userPrice = this.Query(m => m.UserId == userId);
|
||||
var ret = from pakcage in packages
|
||||
join uPrice in userPrice on pakcage.Id equals uPrice.PackageId into temp
|
||||
from uPrice in temp.DefaultIfEmpty()
|
||||
select new PackageUserPriceResponse()
|
||||
{
|
||||
Package = pakcage,
|
||||
UserPrice = uPrice ?? new ProductUserPriceEntity() { RefundDayPrice= products.FirstOrDefault(m=>m.Id==pakcage.ProductId).RefundDayPrice, UserPrice=pakcage.Price }
|
||||
};
|
||||
var packgesPrice = await ret.ToListAsync();
|
||||
|
||||
List<ProductWithPackageUserPriceResponse> respList = new List<ProductWithPackageUserPriceResponse>();
|
||||
products.ForEach(p =>
|
||||
{
|
||||
var resp = new ProductWithPackageUserPriceResponse();
|
||||
resp.Product = p.MapTo<ProductResponse>();
|
||||
resp.PackageUserPrices = packgesPrice.Where(m => m.Package.ProductId == p.Id).ToList();
|
||||
respList.Add(resp);
|
||||
});
|
||||
return respList;
|
||||
}
|
||||
|
||||
public async Task<List<ProductUserPriceEntity>> GetProductUserPrice(int product,int userId)
|
||||
{
|
||||
return this.Query(m => m.ProductId == product && m.UserId == userId && m.Status == 1).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<ProductUserPriceEntity>> GetProductUserPrice(int userId)
|
||||
{
|
||||
return this.Query(m => m.UserId == userId && m.Status == 1).ToList();
|
||||
}
|
||||
public async Task<ProductUserPriceEntity> GetPackageUserPrice(int packageId, int userId)
|
||||
{
|
||||
return this.Query(m => m.PackageId == packageId && m.UserId == userId&& m.Status==1).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Response.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class ProductUserPriceService : ServiceBase<ProductUserPriceEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
ProductService m_ProductService;
|
||||
ProductPackageService m_ProductPackageService;
|
||||
public ProductUserPriceService(ProductPackageService m_ProductPackageService
|
||||
, ProductService m_ProductService
|
||||
,CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
this.m_ProductPackageService = m_ProductPackageService;
|
||||
this.m_ProductService = m_ProductService;
|
||||
}
|
||||
|
||||
public async Task<List<ProductWithPackageUserPriceResponse>> GetPackageUserPrice(int userId)
|
||||
{
|
||||
var products = await m_ProductService.Query( m=>m.OnLine == 1).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
var packages = m_ProductPackageService.Query(true);
|
||||
var userPrice = this.Query(m => m.UserId == userId);
|
||||
var ret = from pakcage in packages
|
||||
join uPrice in userPrice on pakcage.Id equals uPrice.PackageId into temp
|
||||
from uPrice in temp.DefaultIfEmpty()
|
||||
select new PackageUserPriceResponse()
|
||||
{
|
||||
Package = pakcage,
|
||||
UserPrice = uPrice ?? new ProductUserPriceEntity() { RefundDayPrice= products.FirstOrDefault(m=>m.Id==pakcage.ProductId).RefundDayPrice, UserPrice=pakcage.Price }
|
||||
};
|
||||
var packgesPrice = await ret.ToListAsync();
|
||||
|
||||
List<ProductWithPackageUserPriceResponse> respList = new List<ProductWithPackageUserPriceResponse>();
|
||||
products.ForEach(p =>
|
||||
{
|
||||
var resp = new ProductWithPackageUserPriceResponse();
|
||||
resp.Product = p.MapTo<ProductResponse>();
|
||||
resp.PackageUserPrices = packgesPrice.Where(m => m.Package.ProductId == p.Id).ToList();
|
||||
respList.Add(resp);
|
||||
});
|
||||
return respList;
|
||||
}
|
||||
|
||||
public async Task<List<ProductUserPriceEntity>> GetProductUserPrice(int product,int userId)
|
||||
{
|
||||
return this.Query(m => m.ProductId == product && m.UserId == userId && m.Status == 1).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<ProductUserPriceEntity>> GetProductUserPrice(int userId)
|
||||
{
|
||||
return this.Query(m => m.UserId == userId && m.Status == 1).ToList();
|
||||
}
|
||||
public async Task<ProductUserPriceEntity> GetPackageUserPrice(int packageId, int userId)
|
||||
{
|
||||
return this.Query(m => m.PackageId == packageId && m.UserId == userId&& m.Status==1).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using System.Collections.Generic;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class UserService : ServiceBase<UserEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public UserService(CourseContext dbContext
|
||||
,IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<UserEntity>> GetByIds(List<int> userids)
|
||||
{
|
||||
return await this.Query(m => userids.Contains(m.Id)).ToListAsync();
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using System;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using System.Collections.Generic;
|
||||
using Hncore.Pass.BaseInfo.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class UserService : ServiceBase<UserEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public UserService(CourseContext dbContext
|
||||
,IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<UserEntity>> GetByIds(List<int> userids)
|
||||
{
|
||||
return await this.Query(m => userids.Contains(m.Id)).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,49 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Wx.Open;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
|
||||
public partial class WxAppService : ServiceBase<WxAppEntity>
|
||||
{
|
||||
public WxAppService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task SaveAppInfo(GetAuthorizerInfoResponse info, int tenantId, int storeId)
|
||||
{
|
||||
var wxAppInfo = await this.Query(true).FirstOrDefaultAsync(m => m.TenantId == tenantId
|
||||
&& m.Appid == info.authorization_info.authorizer_appid
|
||||
&& m.DeleteTag == 0);
|
||||
|
||||
var wxAuthInfoNew = new WxAppEntity()
|
||||
{
|
||||
TenantId = tenantId,
|
||||
StoreId = storeId,
|
||||
Appid = info.authorization_info.authorizer_appid,
|
||||
HeadImg = info.authorizer_info.head_img,
|
||||
NickName = info.authorizer_info.nick_name,
|
||||
PrincipalName = info.authorizer_info.principal_name,
|
||||
UserName = info.authorizer_info.user_name,
|
||||
Bussinessinfo = info.authorizer_info.signature,
|
||||
AuthorizerState = 0,
|
||||
RefreshToken = info.authorization_info.authorizer_refresh_token,
|
||||
ExpiresIn = info.authorization_info.expires_in,
|
||||
};
|
||||
if (wxAppInfo == null)
|
||||
{
|
||||
await this.Add(wxAuthInfoNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxAuthInfoNew.Id = wxAppInfo.Id;
|
||||
await this.Update(wxAuthInfoNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Wx.Open;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
|
||||
public partial class WxAppService : ServiceBase<WxAppEntity>
|
||||
{
|
||||
public WxAppService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task SaveAppInfo(GetAuthorizerInfoResponse info, int tenantId, int storeId)
|
||||
{
|
||||
var wxAppInfo = await this.Query(true).FirstOrDefaultAsync(m => m.TenantId == tenantId
|
||||
&& m.Appid == info.authorization_info.authorizer_appid
|
||||
&& m.DeleteTag == 0);
|
||||
|
||||
var wxAuthInfoNew = new WxAppEntity()
|
||||
{
|
||||
TenantId = tenantId,
|
||||
StoreId = storeId,
|
||||
Appid = info.authorization_info.authorizer_appid,
|
||||
HeadImg = info.authorizer_info.head_img,
|
||||
NickName = info.authorizer_info.nick_name,
|
||||
PrincipalName = info.authorizer_info.principal_name,
|
||||
UserName = info.authorizer_info.user_name,
|
||||
Bussinessinfo = info.authorizer_info.signature,
|
||||
AuthorizerState = 0,
|
||||
RefreshToken = info.authorization_info.authorizer_refresh_token,
|
||||
ExpiresIn = info.authorization_info.expires_in,
|
||||
};
|
||||
if (wxAppInfo == null)
|
||||
{
|
||||
await this.Add(wxAuthInfoNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxAuthInfoNew.Id = wxAppInfo.Id;
|
||||
await this.Update(wxAuthInfoNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,34 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Wx.Open;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class WxAppUserService : ServiceBase<WxAppUserEntity>
|
||||
{
|
||||
WxAppService m_WxAppService;
|
||||
public WxAppUserService(WxAppService _WxAppService, CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_WxAppService = _WxAppService;
|
||||
}
|
||||
public async Task<List<WxAppUserEntity>> GetWxUsers(List<int> UserId)
|
||||
{
|
||||
return await this.Query(m => UserId.Contains(m.UserId)).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<WxAppUserEntity> GetWxUser(string appId, int userId)
|
||||
{
|
||||
return await this.Query(m => m.Appid == appId && m.UserId == userId).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<WxAppUserEntity> GetWxUser(string appId, string openId)
|
||||
{
|
||||
return await this.Query(m => m.Appid == appId && m.Openid == openId).FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Wx.Open;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public partial class WxAppUserService : ServiceBase<WxAppUserEntity>
|
||||
{
|
||||
WxAppService m_WxAppService;
|
||||
public WxAppUserService(WxAppService _WxAppService, CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_WxAppService = _WxAppService;
|
||||
}
|
||||
public async Task<List<WxAppUserEntity>> GetWxUsers(List<int> UserId)
|
||||
{
|
||||
return await this.Query(m => UserId.Contains(m.UserId)).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<WxAppUserEntity> GetWxUser(string appId, int userId)
|
||||
{
|
||||
return await this.Query(m => m.Appid == appId && m.UserId == userId).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<WxAppUserEntity> GetWxUser(string appId, string openId)
|
||||
{
|
||||
return await this.Query(m => m.Appid == appId && m.Openid == openId).FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +1,72 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Job;
|
||||
using Hncore.Pass.Vpn.Map;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
private IServiceProvider _IServiceProvider;
|
||||
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
Configuration = env.UseAppsettings();
|
||||
}
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<CourseContext>(opt => { opt.UseMySql(Configuration["MySql"]); });
|
||||
services.AddTransient<AgentClientLogHandler>();
|
||||
services.AddHttpClient("agentClient", c =>
|
||||
{
|
||||
c.DefaultRequestHeaders.Add("hl", "hl");
|
||||
})
|
||||
.AddHttpMessageHandler<AgentClientLogHandler>()
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler() { UseCookies = false});
|
||||
|
||||
services.AddHttpClient("agentClient1.0", c =>
|
||||
{
|
||||
c.DefaultRequestHeaders.Add("hl", "hl");
|
||||
})
|
||||
.AddHttpMessageHandler<AgentClientLogHandler>()
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler() { UseCookies = false,AllowAutoRedirect=false });
|
||||
|
||||
services.AddServiceClient(Configuration["Service_BaseUrl"]);
|
||||
services.AutoAddService();
|
||||
return _IServiceProvider=services.Init(Configuration, CompatibilityVersion.Version_2_2, new ServiceOption
|
||||
{
|
||||
UseGlobalManageAuthFilter = false
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime
|
||||
, ILoggerFactory loggerFactory)
|
||||
{
|
||||
MapConfig.Config();
|
||||
|
||||
app.Init(loggerFactory, applicationLifetime);
|
||||
//启动后台任务
|
||||
applicationLifetime.ApplicationStarted.Register(() =>
|
||||
{
|
||||
// OrderAccountJob.Start(_IServiceProvider);
|
||||
//RefrushStatusJob.Start(_IServiceProvider);
|
||||
// ChargeTryJob.Start(_IServiceProvider);
|
||||
ExpireTipJob.Start(_IServiceProvider);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Job;
|
||||
using Hncore.Pass.Vpn.Map;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Hncore.Pass.Vpn
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
private IServiceProvider _IServiceProvider;
|
||||
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
Configuration = env.UseAppsettings();
|
||||
}
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<CourseContext>(opt => { opt.UseMySql(Configuration["MySql"]); });
|
||||
services.AddTransient<AgentClientLogHandler>();
|
||||
services.AddHttpClient("agentClient", c =>
|
||||
{
|
||||
c.DefaultRequestHeaders.Add("hl", "hl");
|
||||
})
|
||||
.AddHttpMessageHandler<AgentClientLogHandler>()
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler() { UseCookies = false});
|
||||
|
||||
services.AddHttpClient("agentClient1.0", c =>
|
||||
{
|
||||
c.DefaultRequestHeaders.Add("hl", "hl");
|
||||
})
|
||||
.AddHttpMessageHandler<AgentClientLogHandler>()
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler() { UseCookies = false,AllowAutoRedirect=false });
|
||||
|
||||
services.AddServiceClient(Configuration["Service_BaseUrl"]);
|
||||
services.AutoAddService();
|
||||
return _IServiceProvider=services.Init(Configuration, CompatibilityVersion.Version_2_2, new ServiceOption
|
||||
{
|
||||
UseGlobalManageAuthFilter = false
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime
|
||||
, ILoggerFactory loggerFactory)
|
||||
{
|
||||
MapConfig.Config();
|
||||
|
||||
app.Init(loggerFactory, applicationLifetime);
|
||||
//启动后台任务
|
||||
applicationLifetime.ApplicationStarted.Register(() =>
|
||||
{
|
||||
// OrderAccountJob.Start(_IServiceProvider);
|
||||
//RefrushStatusJob.Start(_IServiceProvider);
|
||||
// ChargeTryJob.Start(_IServiceProvider);
|
||||
ExpireTipJob.Start(_IServiceProvider);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=course;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=10,poolsize=1"
|
||||
}
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=course;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=10,poolsize=1"
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=course;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=10,poolsize=1"
|
||||
}
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=course;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=10,poolsize=1"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user