Browse Source

新增GOI接口

GOIAggregation
shanji 2 years ago
parent
commit
c4ea3dc124
  1. 12
      SiNan.API/.config/dotnet-tools.json
  2. 36
      SiNan.API/Controllers/BaseApiController.cs
  3. 27
      SiNan.API/Controllers/GOIController.cs
  4. 7
      SiNan.API/Program.cs
  5. 1
      SiNan.API/appsettings.json
  6. 5
      SiNan.Business/GOIBusiness.cs
  7. 24
      SiNan.Model/Dto/Request/Product/QueryProductGOIRequest.cs
  8. 11
      SiNan.Model/Dto/Request/Product/QueryProductSkuGOIRequest.cs
  9. 13
      SiNan.Model/Dto/Request/Product/SearchProductGOIRequestcs.cs
  10. 12
      SiNan.Model/Dto/Response/GOI/GOIResponse.cs
  11. 7
      SiNan.Model/Dto/Response/GOI/ProductGOIResponse.cs
  12. 54
      SiNan.Model/Dto/Response/GOI/ProductSkuGOIResponse.cs
  13. 9
      SiNan.Model/Dto/Response/ListResponse.cs
  14. 8
      SiNan.Model/Dto/Response/Product/ProductSkuResponse.cs

12
SiNan.API/.config/dotnet-tools.json

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "7.0.12",
"commands": [
"dotnet-ef"
]
}
}
}

36
SiNan.API/Controllers/BaseApiController.cs

@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
namespace SiNan.API.Controllers
{
[Produces("application/json")]
[Route("Api/[Controller]/[Action]")]
[ApiController]
[EnableCors("cors")]
public class BaseApiController : ControllerBase
{
protected IHttpContextAccessor httpContextAccessor;
public BaseApiController(IHttpContextAccessor httpContextAccessor)
{
this.httpContextAccessor = httpContextAccessor;
}
protected string GetUserId()
{
return httpContextAccessor?.HttpContext?.User.Claims.Where(x => x.Type == "userId")?.FirstOrDefault()?.Value;
}
protected string GetToken()
{
httpContextAccessor.HttpContext.Request.Headers.TryGetValue("Authorization", out StringValues token);
return token;
}
protected string GetClientCode()
{
httpContextAccessor.HttpContext.Request.Headers.TryGetValue("ClientCode", out StringValues clientCode);
return clientCode;
}
}
}

27
SiNan.API/Controllers/GOIController.cs

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SiNan.Business;
using SiNan.Model.Dto;
namespace SiNan.API.Controllers
{
public class GOIController : BaseApiController
{
private GOIBusiness goiBusiness;
public GOIController(IHttpContextAccessor httpContextAccessor, GOIBusiness goiBusiness) : base(httpContextAccessor)
{
this.goiBusiness = goiBusiness;
}
/// <summary>
/// 查询产品综合GOI
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public ListResponse<ProductGOIResponse> QueryProductGOI([FromBody]QueryProductGOIRequest request)
{
return goiBusiness.QueryProductGOI(request);
}
}
}

7
SiNan.API/Program.cs

@ -128,6 +128,13 @@ services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(
var app = builder.Build();
app.UseSwagger(c => c.SerializeAsV2 = true)
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "SiNan API");
c.RoutePrefix = string.Empty;
});
app.UseMiddleware<CustomExceptionMiddleWare>();
app.UseRouting();
app.UseCors("cors");

1
SiNan.API/appsettings.json

@ -6,6 +6,7 @@
}
},
"AllowedHosts": "*",
"Secret": "D96BFA5B-F2AF-45BC-9342-5A55C3F9BBB0",
"ConnectionStrings": {
//"DB": "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy;charset=utf8;sslmode=none;"
"BBWYCDB": "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwy_test;charset=utf8;sslmode=none;",

5
SiNan.Business/GOIBusiness.cs

@ -1,5 +1,6 @@
using SiNan.Common.Log;
using SiNan.Common.Models;
using SiNan.Model.Dto;
using Yitter.IdGenerator;
namespace SiNan.Business
@ -12,5 +13,9 @@ namespace SiNan.Business
this.freeSqlMultiDBManager = freeSqlMultiDBManager;
}
public ListResponse<ProductGOIResponse> QueryProductGOI(QueryProductGOIRequest request)
{
return new ListResponse<ProductGOIResponse>();
}
}
}

24
SiNan.Model/Dto/Request/Product/QueryProductGOIRequest.cs

@ -0,0 +1,24 @@
namespace SiNan.Model.Dto
{
public class QueryProductGOIRequest
{
public string Spu { get; set; }
public string Sku { get; set; }
public string SpuTitle { get; set; }
public Enums.Stage? Stage { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int PageIndex { get; set; }
public int PageSize { get; set; }
public long ShopId { get; set; }
}
}

11
SiNan.Model/Dto/Request/Product/QueryProductSkuGOIRequest.cs

@ -0,0 +1,11 @@
namespace SiNan.Model.Dto
{
public class QueryProductSkuGOIRequest
{
public string Spu { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}

13
SiNan.Model/Dto/Request/Product/SearchProductGOIRequestcs.cs

@ -1,13 +0,0 @@
namespace SiNan.Model.Dto.Request.Product
{
public class SearchProductGOIRequestcs
{
public string Spu { get; set; }
public string Sku { get; set; }
public string SpuTitle { get; set; }
public Enums.Stage? Stage { get; set; }
}
}

12
SiNan.Model/Dto/Response/GOI/GOIResponse.cs

@ -1,11 +1,23 @@
namespace SiNan.Model.Dto
{
/// <summary>
/// GOI对象
/// </summary>
public class GOIResponse
{
/// <summary>
/// 花费
/// </summary>
public decimal Cost { get; set; }
/// <summary>
/// 利润
/// </summary>
public decimal Profit { get; set; }
/// <summary>
/// GOI
/// </summary>
public decimal GOI
{
get

7
SiNan.Model/Dto/Response/GOI/ProductGOIResponse.cs

@ -46,5 +46,12 @@
/// 最大亏损
/// </summary>
public decimal MaxDeficit { get; set; }
/// <summary>
/// SKU GOI
/// </summary>
public List<ProductSkuGOIResponse> ProductSkuGOIList { get; set; }
}
}

54
SiNan.Model/Dto/Response/GOI/ProductSkuGOIResponse.cs

@ -1,12 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SiNan.Model.Dto.Response.GOI
namespace SiNan.Model.Dto
{
internal class ProductSkuGOIResponse
public class ProductSkuGOIResponse : ProductSkuResponse
{
/// <summary>
/// 商品维度 昨日GOI
/// </summary>
public GOIResponse ProductGOI_Yestoday { get; set; }
/// <summary>
/// 商品维度 近7天GOI
/// </summary>
public GOIResponse ProductGOI_Recent7Day { get; set; }
/// <summary>
/// 商品维度 近30天GOI
/// </summary>
public GOIResponse ProductGOI_Recent30Day { get; set; }
/// <summary>
/// 推广维度 昨日GOI
/// </summary>
public GOIResponse PromotionGOI_Yestoday { get; set; }
/// <summary>
/// 推广维度 近7天GOI
/// </summary>
public GOIResponse PromotionGOI_Recent7Day { get; set; }
/// <summary>
/// 推广维度 近30天GOI
/// </summary>
public GOIResponse PromotionGOI_Recent30Day { get; set; }
/// <summary>
/// 累计花费
/// </summary>
public decimal TotalCost { get; set; }
/// <summary>
/// 累计亏损
/// </summary>
public decimal TotalDeficit { get; set; }
/// <summary>
/// 最大亏损
/// </summary>
public decimal MaxDeficit { get; set; }
}
}

9
SiNan.Model/Dto/Response/ListResponse.cs

@ -0,0 +1,9 @@
namespace SiNan.Model.Dto
{
public class ListResponse<T> where T : class
{
public List<T> ItemList { get; set; }
public long Count { get; set; }
}
}

8
SiNan.Model/Dto/Response/Product/ProductSkuResponse.cs

@ -0,0 +1,8 @@
using SiNan.Model.Db;
namespace SiNan.Model.Dto
{
public class ProductSkuResponse : ProductSku
{
}
}
Loading…
Cancel
Save