From 0136ac24970c946f0db0d30a907d70ee32406672 Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Thu, 22 Dec 2022 14:25:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=A0=E5=93=81=E6=A8=A1=E6=9D=BF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EvaluationAssistantController.cs | 50 +++++++++++++++++++ .../EvaluationAssistantBusiness.cs | 39 +++++++++++++++ .../Db/EvaluationAssistant/GiftTemplate.cs | 10 +++- .../Db/EvaluationAssistant/Gifttemplatesku.cs | 44 ---------------- .../AddOrEditGiftTemplateRequest.cs | 10 ++-- .../GiftTemplate/GiftTemplateResponse.cs | 11 ++++ BBWY.Test/JDProductAPITest.cs | 14 ++++++ BBWY.Test/Program.cs | 24 +-------- 8 files changed, 129 insertions(+), 73 deletions(-) create mode 100644 BBWY.Server.API/Controllers/EvaluationAssistantController.cs delete mode 100644 BBWY.Server.Model/Db/EvaluationAssistant/Gifttemplatesku.cs create mode 100644 BBWY.Server.Model/Dto/Response/GiftTemplate/GiftTemplateResponse.cs diff --git a/BBWY.Server.API/Controllers/EvaluationAssistantController.cs b/BBWY.Server.API/Controllers/EvaluationAssistantController.cs new file mode 100644 index 00000000..b944591a --- /dev/null +++ b/BBWY.Server.API/Controllers/EvaluationAssistantController.cs @@ -0,0 +1,50 @@ +using BBWY.Server.Business; +using BBWY.Server.Model.Dto; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; + +namespace BBWY.Server.API.Controllers +{ + + public class EvaluationAssistantController : BaseApiController + { + private EvaluationAssistantBusiness evaluationAssistantBusiness; + + public EvaluationAssistantController(IHttpContextAccessor httpContextAccessor, EvaluationAssistantBusiness evaluationAssistantBusiness) : base(httpContextAccessor) + { + this.evaluationAssistantBusiness = evaluationAssistantBusiness; + } + + /// + /// 新增/编辑赠品模板 + /// + /// + [HttpPost] + public void AddOrEditGiftTemplate([FromBody] AddOrEditGiftTemplateRequest request) + { + evaluationAssistantBusiness.AddOrEditGiftTemplate(request); + } + + /// + /// 获取赠品模板列表 + /// + /// + /// + [HttpGet("{shopId}")] + public IList GetGiftTemplateList([FromRoute] long shopId) + { + return evaluationAssistantBusiness.GetGiftTemplateList(shopId); + } + + /// + /// 删除赠品模板 + /// + /// + [HttpDelete("{giftTemplateId}")] + public void DeleteGiftTemplate([FromRoute] long giftTemplateId) + { + evaluationAssistantBusiness.DeleteGiftTemplate(giftTemplateId); + } + } +} diff --git a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs index 6184b91e..02df5847 100644 --- a/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs +++ b/BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs @@ -1,8 +1,12 @@ using BBWY.Common.Http; using BBWY.Common.Models; using BBWY.Server.Model; +using BBWY.Server.Model.Db; using BBWY.Server.Model.Dto; using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; using Yitter.IdGenerator; namespace BBWY.Server.Business @@ -19,9 +23,44 @@ namespace BBWY.Server.Business this.idGenerator = idGenerator; } + #region 赠品模板 public void AddOrEditGiftTemplate(AddOrEditGiftTemplateRequest request) { + var giftCount = request.GiftSkus.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count(); + if (request.Id == 0) + { + var giftTemplate = new GiftTemplate() + { + Id = idGenerator.NewLong(), + CreateTime = DateTime.Now, + TemplateName = request.TemplateName, + Platform = Enums.Platform.京东, + ShopId = request.ShopId, + TemplateSpu = request.TemplateSpu, + GiftCount = giftCount, + GiftSkus = request.GiftSkus + }; + fsql.Insert(giftTemplate).ExecuteAffrows(); + } + else + { + fsql.Update(request.Id).Set(g => g.TemplateName, request.TemplateName) + .Set(g => g.TemplateSpu, request.TemplateSpu) + .Set(g => g.GiftSkus, request.GiftSkus) + .Set(g => g.GiftCount, giftCount) + .ExecuteAffrows(); + } + } + public IList GetGiftTemplateList(long shopId) + { + return fsql.Select().Where(g => g.ShopId == shopId).ToList(); + } + + public void DeleteGiftTemplate(long giftTemplateId) + { + fsql.Delete(giftTemplateId).ExecuteAffrows(); } + #endregion } } diff --git a/BBWY.Server.Model/Db/EvaluationAssistant/GiftTemplate.cs b/BBWY.Server.Model/Db/EvaluationAssistant/GiftTemplate.cs index f88327ce..5cee63d4 100644 --- a/BBWY.Server.Model/Db/EvaluationAssistant/GiftTemplate.cs +++ b/BBWY.Server.Model/Db/EvaluationAssistant/GiftTemplate.cs @@ -16,14 +16,20 @@ namespace BBWY.Server.Model.Db public int GiftCount { get; set; } [Column(StringLength = 100)] - public string Name { get; set; } + public string TemplateName { get; set; } public Enums.Platform Platform { get; set; } public long ShopId { get; set; } [Column(StringLength = 50)] - public string Spu { get; set; } + public string TemplateSpu { get; set; } + + /// + /// żƷsku + /// + [Column(StringLength = 255)] + public string GiftSkus { get; set; } } diff --git a/BBWY.Server.Model/Db/EvaluationAssistant/Gifttemplatesku.cs b/BBWY.Server.Model/Db/EvaluationAssistant/Gifttemplatesku.cs deleted file mode 100644 index 8467d4fb..00000000 --- a/BBWY.Server.Model/Db/EvaluationAssistant/Gifttemplatesku.cs +++ /dev/null @@ -1,44 +0,0 @@ -using FreeSql.DatabaseModel;using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Newtonsoft.Json; -using FreeSql.DataAnnotations; - -namespace BBWY.Server.Model.Db { - - [JsonObject(MemberSerialization.OptIn), Table(Name = "gifttemplatesku", DisableSyncStructure = true)] - public partial class Gifttemplatesku { - - [JsonProperty, Column(IsPrimary = true)] - public long Id { get; set; } - - [JsonProperty, Column(DbType = "datetime")] - public DateTime? CreateTime { get; set; } - - [JsonProperty] - public long? GiftTemplateId { get; set; } - - [JsonProperty, Column(DbType = "decimal(18,2)")] - public decimal? JdPrice { get; set; } - - [JsonProperty] - public string Logo { get; set; } - - [JsonProperty] - public long? ShopId { get; set; } - - [JsonProperty] - public string Sku { get; set; } - - [JsonProperty, Column(StringLength = 50)] - public string Spu { get; set; } - - [JsonProperty, Column(StringLength = 100)] - public string Title { get; set; } - - } - -} diff --git a/BBWY.Server.Model/Dto/Request/GiftTemplate/AddOrEditGiftTemplateRequest.cs b/BBWY.Server.Model/Dto/Request/GiftTemplate/AddOrEditGiftTemplateRequest.cs index b6a4973d..74052ccb 100644 --- a/BBWY.Server.Model/Dto/Request/GiftTemplate/AddOrEditGiftTemplateRequest.cs +++ b/BBWY.Server.Model/Dto/Request/GiftTemplate/AddOrEditGiftTemplateRequest.cs @@ -10,9 +10,9 @@ namespace BBWY.Server.Model.Dto public long Id { get; set; } /// - /// 赠品模板名称 + /// 模板名称 /// - public string GiftTemplateName { get; set; } + public string TemplateName { get; set; } /// /// 店铺 @@ -22,11 +22,11 @@ namespace BBWY.Server.Model.Dto /// /// 模板SPU /// - public string GiftSpu { get; set; } + public string TemplateSpu { get; set; } /// - /// 选中的赠品Sku + /// 选中的赠品Sku 逗号间隔 /// - public IList GiftSkus { get; set; } + public string GiftSkus { get; set; } } } diff --git a/BBWY.Server.Model/Dto/Response/GiftTemplate/GiftTemplateResponse.cs b/BBWY.Server.Model/Dto/Response/GiftTemplate/GiftTemplateResponse.cs new file mode 100644 index 00000000..d45f0b63 --- /dev/null +++ b/BBWY.Server.Model/Dto/Response/GiftTemplate/GiftTemplateResponse.cs @@ -0,0 +1,11 @@ +using BBWY.Server.Model.Db; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Server.Model.Dto +{ + public class GiftTemplateResponse : GiftTemplate + { + } +} diff --git a/BBWY.Test/JDProductAPITest.cs b/BBWY.Test/JDProductAPITest.cs index 42edf369..0ddcc240 100644 --- a/BBWY.Test/JDProductAPITest.cs +++ b/BBWY.Test/JDProductAPITest.cs @@ -25,6 +25,20 @@ namespace BBWY.Test Console.WriteLine(JsonConvert.SerializeObject(response)); } + public void QueryHot(IJdClient client, string token) + { + var req = new MarketBdpSaleVenderSkuRankQueryRequest(); + + req.opTime = "20221221"; + req.tp = "1"; + req.field = "itemSkuIdList"; + + + var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); + + Console.WriteLine(JsonConvert.SerializeObject(response)); + } + public void QueryTouTu(IJdClient client, string token) { var req = new TransparentImageReadFindByWareIdAndColorIdRequest(); diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index b92b9275..6971c71b 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -40,29 +40,9 @@ namespace BBWY.Test IJdClient client = GetJdClient(appkey, appSecret); var test1 = new JDProductAPITest(); - //Console.WriteLine("-------------获取包含赠品的sku-------------"); - //test1.GetSkus(client,token, "10023500913672"); - - //Console.WriteLine("-------------获取需要进行赠品SKU上架的本款产品的sku-------------"); - - //test1.GetSkus(client, token, "10022515718131"); - - //Console.WriteLine("-------------查询本款产品透图-------------"); - - //test1.QueryTouTu(client,token, "10022515718131"); - - //Console.WriteLine("-------------查询本款产品细节图-------------"); - - //test1.FindImageByColor(client, token, "10022515718131"); - - //var testService = new JDServiceAPITest(); - //testService.GetServiceDetail(client, token); - - //var ddTest = new DingDingAPITest(); - //ddTest.Send(); - - test1.ShangJiaTest(client, token); + test1.QueryHot(client,token); + //test1.ShangJiaTest(client, token); //test1.修改属性别名(client, token); //test1.QueryTouTu(client,token); Console.ReadKey();