忽略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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user