38 changed files with 1033 additions and 2 deletions
@ -0,0 +1,37 @@ |
|||
using BBWYB.Server.Business; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using SDKAdapter.OperationPlatform.Models; |
|||
|
|||
namespace BBWYB.Server.API.Controllers |
|||
{ |
|||
public class ProductController : BaseApiController |
|||
{ |
|||
private ProductBusiness productBusiness; |
|||
public ProductController(ProductBusiness productBusiness, IHttpContextAccessor httpContextAccessor) : base(httpContextAccessor) |
|||
{ |
|||
this.productBusiness = productBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// spu列表查询
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public OP_ProductListResponse GetProductList([FromBody] OP_SearchProductRequest request) |
|||
{ |
|||
return productBusiness.GetProductList(request); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// sku列表查询
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public OP_ProductSkuListResponse GetProductSkuList([FromBody] OP_SearchProductSkuRequest request) |
|||
{ |
|||
return productBusiness.GetProductSkuList(request); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
using BBWYB.Common.Log; |
|||
using BBWYB.Common.Models; |
|||
using SDKAdapter.OperationPlatform.Client; |
|||
using SDKAdapter.OperationPlatform.Models; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class ProductBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
private OP_PlatformClientFactory opPlatformClientFactory; |
|||
|
|||
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, OP_PlatformClientFactory opPlatformClientFactory) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
this.opPlatformClientFactory = opPlatformClientFactory; |
|||
} |
|||
|
|||
public OP_ProductListResponse GetProductList(OP_SearchProductRequest request) |
|||
{ |
|||
return opPlatformClientFactory.GetClient(request.Platform).GetProductList(request); |
|||
} |
|||
|
|||
public OP_ProductSkuListResponse GetProductSkuList(OP_SearchProductSkuRequest request) |
|||
{ |
|||
return opPlatformClientFactory.GetClient(request.Platform).GetProductSkuList(request); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
using BBWYB.Common.Http; |
|||
using Newtonsoft.Json; |
|||
using QuanTan.SDK.Extensions; |
|||
using QuanTan.SDK.Model; |
|||
|
|||
namespace QuanTan.SDK.Client |
|||
{ |
|||
public class BaseClient |
|||
{ |
|||
protected RestApiService restApiService; |
|||
|
|||
protected readonly string host = "https://qt.qiyue666.com/"; |
|||
|
|||
public BaseClient(RestApiService restApiService) |
|||
{ |
|||
this.restApiService = restApiService; |
|||
} |
|||
|
|||
public QuanTanResponse<T> SendRequest<T>(string apiPath, object param, string appId, string appSecret) |
|||
{ |
|||
var callTime = DateTime.Now.ToString("yyyyMMddHHmmss"); |
|||
var randomNum = new Random(Guid.NewGuid().GetHashCode()).Next(100000, 999999).ToString(); |
|||
if (param == null) |
|||
param = new object[] { }; |
|||
|
|||
var paramStr = JsonConvert.SerializeObject(param); |
|||
|
|||
var jmStr = JsonConvert.SerializeObject(new QuanTanSignParam() |
|||
{ |
|||
appId = appId, |
|||
appSecret = appSecret, |
|||
callTime = callTime, |
|||
_params = paramStr, |
|||
randomNum = randomNum |
|||
}); |
|||
var md5Str = jmStr.Md5Encrypt(); |
|||
var qtToken = $"{appId}-{callTime}-{md5Str}-{randomNum}"; |
|||
var requestParam = new QuanTanRequestParam() |
|||
{ |
|||
Params = paramStr, |
|||
token = qtToken |
|||
}; |
|||
|
|||
try |
|||
{ |
|||
var restApiResult = restApiService.SendRequest(host, apiPath, requestParam, null, HttpMethod.Post); |
|||
if (restApiResult.StatusCode != System.Net.HttpStatusCode.OK) |
|||
throw new Exception(restApiResult.Content); |
|||
return JsonConvert.DeserializeObject<QuanTanResponse<T>>(restApiResult.Content); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
return new QuanTanResponse<T>() { Status = 0, Message = ex.Message }; |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
using BBWYB.Common.Http; |
|||
using QuanTan.SDK.Model; |
|||
using QuanTan.SDK.Models.Buyer; |
|||
|
|||
namespace QuanTan.SDK.Client |
|||
{ |
|||
public class QuanTan_Buyer_OrderClient : BaseClient |
|||
{ |
|||
public QuanTan_Buyer_OrderClient(RestApiService restApiService) : base(restApiService) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 预览订单
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <param name="appId"></param>
|
|||
/// <param name="appSecret"></param>
|
|||
/// <returns></returns>
|
|||
public QuanTanResponse<QuanTan_Buyer_PreviewOrderResponse> PreviewOrder(QuanTan_Buyer_PreviewOrderRequest request, string appId, string appSecret) |
|||
{ |
|||
return SendRequest<QuanTan_Buyer_PreviewOrderResponse>("api/platform/cart/add", request, appId, appSecret); |
|||
} |
|||
|
|||
public QuanTanResponse<QuanTan_Buyer_CreateOrderResponse> CreateOrder(QuanTan_Buyer_CreateOrderRequest request, string appId, string appSecret) |
|||
{ |
|||
return SendRequest<QuanTan_Buyer_CreateOrderResponse>("api/platform/order/add", request, appId, appSecret); |
|||
} |
|||
|
|||
public QuanTanResponse<QuanTan_Buyer_OrderDetailResponse> GetOrderDetail(QuanTan_Buyer_GetOrderDetailRequest request, string appId, string appSecret) |
|||
{ |
|||
return SendRequest<QuanTan_Buyer_OrderDetailResponse>("api/platform/order/detail", request, appId, appSecret); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
using BBWYB.Common.Http; |
|||
using QuanTan.SDK.Model; |
|||
using QuanTan.SDK.Models.Buyer; |
|||
namespace QuanTan.SDK.Client |
|||
{ |
|||
public class QuanTan_Buyer_ProductClient : BaseClient |
|||
{ |
|||
public QuanTan_Buyer_ProductClient(RestApiService restApiService) : base(restApiService) |
|||
{ |
|||
} |
|||
|
|||
public QuanTanResponse<QuanTan_Buyer_ProductResponse> GetProductInfo(string productId, string appId, string appSecret) |
|||
{ |
|||
return SendRequest<QuanTan_Buyer_ProductResponse>($"api/platform/product/spu/{productId}", null, appId, appSecret); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
using BBWYB.Common.Http; |
|||
using QuanTan.SDK.Model; |
|||
using QuanTan.SDK.Models.Supplier; |
|||
|
|||
namespace QuanTan.SDK.Client.Supplier |
|||
{ |
|||
public class QuanTan_Supplier_ProductClient : BaseClient |
|||
{ |
|||
public QuanTan_Supplier_ProductClient(RestApiService restApiService) : base(restApiService) |
|||
{ |
|||
} |
|||
|
|||
public QuanTanResponse<QuanTan_Supplier_ProductListResponse> GetProductList(QuanTan_Supplier_SearchSpuRequest request, string appId, string appSecret) |
|||
{ |
|||
return SendRequest<QuanTan_Supplier_ProductListResponse>("api/platform/supply/product/spu", request, appId, appSecret); |
|||
} |
|||
|
|||
public QuanTanResponse<QuanTan_Supplier_ProductSkuListResponse> GetProductSkuList(QuanTan_Supplier_SearchSkuRequest request, string appId, string appSecret) |
|||
{ |
|||
return SendRequest<QuanTan_Supplier_ProductSkuListResponse>("api/platform/supply/product/list", request, appId, appSecret); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,85 @@ |
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
|
|||
namespace QuanTan.SDK.Extensions |
|||
{ |
|||
public static class EncryptionExtension |
|||
{ |
|||
|
|||
public static string Md5Encrypt(this string originStr) |
|||
{ |
|||
using (var md5 = MD5.Create()) |
|||
{ |
|||
return string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(originStr)).Select(x => x.ToString("x2"))); |
|||
} |
|||
} |
|||
|
|||
//AES加密 传入,要加密的串和, 解密key
|
|||
public static string AESEncrypt(this string input) |
|||
{ |
|||
var key = "dataplatform2019"; |
|||
var ivStr = "1012132405963708"; |
|||
|
|||
var encryptKey = Encoding.UTF8.GetBytes(key); |
|||
var iv = Encoding.UTF8.GetBytes(ivStr); //偏移量,最小为16
|
|||
using (var aesAlg = Aes.Create()) |
|||
{ |
|||
using (var encryptor = aesAlg.CreateEncryptor(encryptKey, iv)) |
|||
{ |
|||
using (var msEncrypt = new MemoryStream()) |
|||
{ |
|||
using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, |
|||
CryptoStreamMode.Write)) |
|||
|
|||
using (var swEncrypt = new StreamWriter(csEncrypt)) |
|||
{ |
|||
swEncrypt.Write(input); |
|||
} |
|||
var decryptedContent = msEncrypt.ToArray(); |
|||
|
|||
return Convert.ToBase64String(decryptedContent); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static string AESDecrypt(this string cipherText) |
|||
{ |
|||
var fullCipher = Convert.FromBase64String(cipherText); |
|||
|
|||
var ivStr = "1012132405963708"; |
|||
var key = "dataplatform2019"; |
|||
|
|||
var iv = Encoding.UTF8.GetBytes(ivStr); |
|||
var decryptKey = Encoding.UTF8.GetBytes(key); |
|||
|
|||
using (var aesAlg = Aes.Create()) |
|||
{ |
|||
using (var decryptor = aesAlg.CreateDecryptor(decryptKey, iv)) |
|||
{ |
|||
string result; |
|||
using (var msDecrypt = new MemoryStream(fullCipher)) |
|||
{ |
|||
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) |
|||
{ |
|||
using (var srDecrypt = new StreamReader(csDecrypt)) |
|||
{ |
|||
result = srDecrypt.ReadToEnd(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static string Base64Encrypt(this string originStr) |
|||
{ |
|||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(originStr)); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_CreateOrderRequest |
|||
{ |
|||
public string clientOrderId { get; set; } |
|||
|
|||
public string userAccount { get; set; } |
|||
|
|||
public string cartIds { get; set; } |
|||
|
|||
public QuanTanCreateOrderReceipt receipt { get; set; } |
|||
} |
|||
|
|||
public class QuanTanCreateOrderReceipt : QuanTan_Buyer_PreviewOrderReceipt |
|||
{ } |
|||
} |
@ -0,0 +1,9 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_GetOrderDetailRequest |
|||
{ |
|||
public string userAccount { get; set; } |
|||
|
|||
public string orderId { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_PreviewOrderRequest |
|||
{ |
|||
public string clientOrderId { get; set; } |
|||
|
|||
public string userAccount { get; set; } |
|||
|
|||
public IList<QuanTan_Buyer_PreviewOrderProduct> buyInfo { get; set; } |
|||
|
|||
public QuanTan_Buyer_PreviewOrderReceipt receipt { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Buyer_PreviewOrderProduct |
|||
{ |
|||
public string productId { get; set; } |
|||
|
|||
public string productSku { get; set; } |
|||
|
|||
public int quantity { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Buyer_PreviewOrderReceipt |
|||
{ |
|||
public string province { get; set; } |
|||
|
|||
public string city { get; set; } |
|||
|
|||
public string area { get; set; } |
|||
|
|||
public string town { get; set; } |
|||
|
|||
public string address { get; set; } |
|||
|
|||
public string realName { get; set; } |
|||
|
|||
public string phone { get; set; } |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_SendGoodsNotifyRequest |
|||
{ |
|||
public string OrderId { get; set; } |
|||
|
|||
public string WayBillNo { get; set; } |
|||
|
|||
public string ExpressId { get; set; } |
|||
|
|||
public string ExpressName { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_CreateOrderResponse |
|||
{ |
|||
public string OrderId { get; set; } |
|||
|
|||
public string OrderSn { get; set; } |
|||
|
|||
public string GroupOrderId { get; set; } |
|||
|
|||
public string PayStatus { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,98 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_OrderDetailResponse |
|||
{ |
|||
public string OrderId { get; set; } |
|||
|
|||
public string OrderSn { get; set; } |
|||
|
|||
public string ClientOrderId { get; set; } |
|||
|
|||
public string GroupOrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品金额
|
|||
/// </summary>
|
|||
public decimal ProductPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal TotalPostage { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单总金额
|
|||
/// </summary>
|
|||
public decimal TotalPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单状态:-1、已退款;0、待发货;1、待收货;2、待评价;3、已完成;
|
|||
/// </summary>
|
|||
public int Status { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 支付状态:0、待支付 1、已支付
|
|||
/// </summary>
|
|||
public int Paid { get; set; } |
|||
|
|||
public DateTime? PayTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 下单方式:1、普通下单 2、售罄下单
|
|||
/// </summary>
|
|||
public int StockType { get; set; } |
|||
|
|||
public QuanTan_Buyer_OrderDetailReceipt Receipt { get; set; } |
|||
|
|||
public IList<QuanTan_Buyer_OrderDetailProduct> OrderProduct { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Buyer_OrderDetailReceipt : QuanTan_Buyer_PreviewOrderReceipt |
|||
{ |
|||
|
|||
} |
|||
|
|||
public class QuanTan_Buyer_OrderDetailProduct |
|||
{ |
|||
public string OrderProductId { get; set; } |
|||
|
|||
public string ProductId { get; set; } |
|||
|
|||
public string ProductSku { get; set; } |
|||
|
|||
|
|||
public int Quantity { get; set; } |
|||
|
|||
public decimal Price { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品总金额
|
|||
/// </summary>
|
|||
public decimal ProductPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal PostagePrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总金额
|
|||
/// </summary>
|
|||
public decimal TotalPrice { get; set; } |
|||
|
|||
public QuanTan_Buyer_OrderDetailProductSku SkuInfo { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Buyer_OrderDetailProductSku |
|||
{ |
|||
public string ProductId { get; set; } |
|||
|
|||
public string ProductSku { get; set; } |
|||
|
|||
public string Title { get; set; } |
|||
|
|||
public string Image { get; set; } |
|||
|
|||
public decimal Price { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_PreviewOrderResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 货款
|
|||
/// </summary>
|
|||
public decimal ProductPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal PostagePrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 总费用
|
|||
/// </summary>
|
|||
public decimal TotalPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 购物车Id
|
|||
/// </summary>
|
|||
public string CartIds { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_ProductResponse |
|||
{ |
|||
public QuanTan_Buyer_Supplier Supplier { get; set; } |
|||
|
|||
public QuanTan_Buyer_Product Product { get; set; } |
|||
|
|||
public IList<QuanTan_Buyer_ProductSku> ProductSku { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Buyer_Product |
|||
{ |
|||
public string ProductId { get; set; } |
|||
/// <summary>
|
|||
/// 商品名称(完整标题)
|
|||
/// </summary>
|
|||
public string ProductName { get; set; } |
|||
/// <summary>
|
|||
/// 商品简介
|
|||
/// </summary>
|
|||
public string ProductBrief { get; set; } |
|||
public decimal Price { get; set; } |
|||
public string UnitName { get; set; } |
|||
public string Image { get; set; } |
|||
//public string Sliderimage { get; set; }
|
|||
public string VideoLink { get; set; } |
|||
public string Stock { get; set; } |
|||
public string Context { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Buyer_ProductSku |
|||
{ |
|||
public string SkuId { get; set; } |
|||
public string ProductId { get; set; } |
|||
public string Title { get; set; } |
|||
public string Logo { get; set; } |
|||
public decimal Price { get; set; } |
|||
//public decimal RetailPrice { get; set; }
|
|||
public int Stock { get; set; } |
|||
//public decimal Volume { get; set; }
|
|||
//public string weight { get; set; }
|
|||
public string BarCode { get; set; } |
|||
//public string skuArr { get; set; }
|
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
namespace QuanTan.SDK.Models.Buyer |
|||
{ |
|||
public class QuanTan_Buyer_Supplier |
|||
{ |
|||
public string Location { get; set; } |
|||
|
|||
public string VenderId { get; set; } |
|||
|
|||
public string VerdenName { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
using Newtonsoft.Json; |
|||
|
|||
namespace QuanTan.SDK.Model |
|||
{ |
|||
public class QuanTanSignParam |
|||
{ |
|||
public string appId { get; set; } |
|||
public string appSecret { get; set; } |
|||
|
|||
public string callTime { get; set; } |
|||
|
|||
[JsonProperty(PropertyName = "params")] |
|||
public object _params { get; set; } |
|||
|
|||
public string randomNum { get; set; } |
|||
} |
|||
|
|||
public class QuanTanRequestParam |
|||
{ |
|||
[JsonProperty(PropertyName = "params")] |
|||
public object Params { get; set; } |
|||
|
|||
public string token { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
namespace QuanTan.SDK.Model |
|||
{ |
|||
public class QuanTanResponse |
|||
{ |
|||
public int Status { get; set; } |
|||
|
|||
public string Message { get; set; } |
|||
|
|||
public object Data { get; set; } |
|||
} |
|||
|
|||
public class QuanTanResponse<T> : QuanTanResponse |
|||
{ |
|||
public new T Data { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
namespace QuanTan.SDK.Models.Supplier |
|||
{ |
|||
public class QuanTan_Supplier_SearchSkuRequest |
|||
{ |
|||
public string storeId { get; set; } |
|||
|
|||
public string categroyId { get; set; } |
|||
|
|||
public string channel { get; set; } |
|||
|
|||
public string productId { get; set; } |
|||
|
|||
public string productSku { get; set; } |
|||
|
|||
public int page { get; set; } = 1; |
|||
|
|||
public int pageSize { get; set; } = 20; |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
namespace QuanTan.SDK.Models.Supplier |
|||
{ |
|||
public class QuanTan_Supplier_SearchSpuRequest |
|||
{ |
|||
public string storeId { get; set; } |
|||
|
|||
public string productId { get; set; } |
|||
|
|||
public int page { get; set; } = 1; |
|||
|
|||
public int pageSize { get; set; } = 20; |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
namespace QuanTan.SDK.Models.Supplier |
|||
{ |
|||
public class QuanTan_Supplier_Product |
|||
{ |
|||
public string ProductId { get; set; } |
|||
|
|||
public string ProductName { get; set; } |
|||
|
|||
public string Image { get; set; } |
|||
|
|||
public string StoreId { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Supplier_ProductListResponse |
|||
{ |
|||
public int Count { get; set; } |
|||
|
|||
public int Page { get; set; } |
|||
|
|||
public int PageSize { get; set; } |
|||
|
|||
public IList<QuanTan_Supplier_Product> List { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
namespace QuanTan.SDK.Models.Supplier |
|||
{ |
|||
public class QuanTan_Supplier_ProductSku |
|||
{ |
|||
public string ProductId { get; set; } |
|||
|
|||
public string ProductName { get; set; } |
|||
|
|||
public string ProductSku { get; set; } |
|||
|
|||
public string SkuName { get; set; } |
|||
|
|||
public string SkuImage { get; set; } |
|||
|
|||
public decimal SkuPrice { get; set; } |
|||
|
|||
public string CategoryId { get; set; } |
|||
|
|||
public string StoreId { get; set; } |
|||
} |
|||
|
|||
public class QuanTan_Supplier_ProductSkuListResponse |
|||
{ |
|||
public int Count { get; set; } |
|||
|
|||
public int Page { get; set; } |
|||
|
|||
public int PageSize { get; set; } |
|||
|
|||
public IList<QuanTan_Supplier_ProductSku> List { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\BBWYB.Common\BBWYB.Common.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -0,0 +1,17 @@ |
|||
using SDKAdapter.PurchasePlatform.Models; |
|||
|
|||
namespace SDKAdapter |
|||
{ |
|||
public class BasePlatformRequest |
|||
{ |
|||
public AdapterEnums.PlatformType Platform { get; set; } |
|||
|
|||
public string AppKey { get; set; } |
|||
|
|||
public string AppSecret { get; set; } |
|||
|
|||
public string AppToken { get; set; } |
|||
|
|||
public bool SaveResponseLog { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
using BBWYB.Common.Http; |
|||
using SDKAdapter.OperationPlatform.Models; |
|||
using SDKAdapter.PurchasePlatform.Models; |
|||
|
|||
namespace SDKAdapter.OperationPlatform.Client |
|||
{ |
|||
/// <summary>
|
|||
/// 运营平台通用SDK
|
|||
/// </summary>
|
|||
public class OP_PlatformClient |
|||
{ |
|||
protected RestApiService restApiService { get; private set; } |
|||
|
|||
public virtual AdapterEnums.PlatformType Platform { get; } |
|||
|
|||
public OP_PlatformClient(RestApiService restApiService) |
|||
{ |
|||
this.restApiService = restApiService; |
|||
} |
|||
|
|||
public virtual OP_ProductListResponse GetProductList(OP_SearchProductRequest searchProductRequest) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public virtual OP_ProductSkuListResponse GetProductSkuList(OP_SearchProductSkuRequest searchProductSkuRequest) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
using BBWYB.Common.Http; |
|||
using BBWYB.Common.Models; |
|||
using SDKAdapter.PurchasePlatform.Models; |
|||
|
|||
namespace SDKAdapter.OperationPlatform.Client |
|||
{ |
|||
public class OP_PlatformClientFactory |
|||
{ |
|||
private IList<OP_PlatformClient> clients; |
|||
|
|||
public OP_PlatformClientFactory(RestApiService restApiService) |
|||
{ |
|||
clients = new List<OP_PlatformClient>(); |
|||
clients.Add(new OP_JDClient(restApiService)); |
|||
clients.Add(new OP_QuanTanClient(restApiService)); |
|||
} |
|||
|
|||
public OP_PlatformClient GetClient(AdapterEnums.PlatformType platform) |
|||
{ |
|||
var client = clients.FirstOrDefault(c => c.Platform == platform); |
|||
if (client == null) |
|||
throw new Exception("不支持的平台"); |
|||
return client; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
using BBWYB.Common.Http; |
|||
using SDKAdapter.PurchasePlatform.Models; |
|||
|
|||
namespace SDKAdapter.OperationPlatform.Client |
|||
{ |
|||
public class OP_JDClient : OP_PlatformClient |
|||
{ |
|||
public OP_JDClient(RestApiService restApiService) : base(restApiService) |
|||
{ |
|||
} |
|||
|
|||
public override AdapterEnums.PlatformType Platform => AdapterEnums.PlatformType.京东; |
|||
} |
|||
} |
@ -0,0 +1,78 @@ |
|||
using BBWYB.Common.Http; |
|||
using QuanTan.SDK.Client.Supplier; |
|||
using QuanTan.SDK.Models.Supplier; |
|||
using SDKAdapter.OperationPlatform.Models; |
|||
using SDKAdapter.PurchasePlatform.Models; |
|||
|
|||
namespace SDKAdapter.OperationPlatform.Client |
|||
{ |
|||
public class OP_QuanTanClient : OP_PlatformClient |
|||
{ |
|||
private QuanTan_Supplier_ProductClient supplier_ProductClient; |
|||
|
|||
public OP_QuanTanClient(RestApiService restApiService) : base(restApiService) |
|||
{ |
|||
this.supplier_ProductClient = new QuanTan_Supplier_ProductClient(restApiService); |
|||
} |
|||
|
|||
public override AdapterEnums.PlatformType Platform => AdapterEnums.PlatformType.拳探; |
|||
|
|||
public override OP_ProductListResponse GetProductList(OP_SearchProductRequest searchProductRequest) |
|||
{ |
|||
var qtResponse = supplier_ProductClient.GetProductList(new QuanTan_Supplier_SearchSpuRequest() |
|||
{ |
|||
page = searchProductRequest.PageIndex, |
|||
pageSize = searchProductRequest.PageSize, |
|||
productId = searchProductRequest.Spu, |
|||
storeId = searchProductRequest.AppToken |
|||
}, searchProductRequest.AppKey, searchProductRequest.AppSecret); |
|||
|
|||
if (qtResponse.Status != 200) |
|||
throw new Exception(qtResponse.Message); |
|||
|
|||
return new OP_ProductListResponse() |
|||
{ |
|||
Count = qtResponse.Data.Count, |
|||
Items = qtResponse.Data.List.Select(qtp => new OP_ProductResponse() |
|||
{ |
|||
Id = qtp.ProductId, |
|||
BrandName = string.Empty, |
|||
CreateTime = null, |
|||
Logo = qtp.Image, |
|||
ProductItemNum = string.Empty, |
|||
State = 0, |
|||
Title = qtp.ProductName |
|||
}).ToList() |
|||
}; |
|||
} |
|||
|
|||
public override OP_ProductSkuListResponse GetProductSkuList(OP_SearchProductSkuRequest searchProductSkuRequest) |
|||
{ |
|||
var qtResponse = supplier_ProductClient.GetProductSkuList(new QuanTan_Supplier_SearchSkuRequest() |
|||
{ |
|||
page = searchProductSkuRequest.PageIndex, |
|||
pageSize = searchProductSkuRequest.PageSize, |
|||
storeId = searchProductSkuRequest.AppToken, |
|||
productId = searchProductSkuRequest.Spu |
|||
}, searchProductSkuRequest.AppKey, searchProductSkuRequest.AppSecret); |
|||
|
|||
if (qtResponse.Status != 200) |
|||
throw new Exception(qtResponse.Message); |
|||
|
|||
return new OP_ProductSkuListResponse() |
|||
{ |
|||
Count = qtResponse.Data.Count, |
|||
Items = qtResponse.Data.List.Select(qtps => new OP_ProductSkuResponse() |
|||
{ |
|||
CreateTime = null, |
|||
Id = qtps.ProductSku, |
|||
Logo = qtps.SkuImage, |
|||
Price = qtps.SkuPrice, |
|||
ProductId = qtps.ProductId, |
|||
State = 0, |
|||
Title = qtps.SkuName |
|||
}).ToList() |
|||
}; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
namespace SDKAdapter.OperationPlatform.Models |
|||
{ |
|||
public class OP_SearchProductRequest : BasePlatformRequest |
|||
{ |
|||
|
|||
public string Spu { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 货号
|
|||
/// </summary>
|
|||
public string ProductItem { get; set; } |
|||
|
|||
public string ProductName { get; set; } |
|||
|
|||
public int PageIndex { get; set; } |
|||
|
|||
public int PageSize { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
namespace SDKAdapter.OperationPlatform.Models |
|||
{ |
|||
public class OP_SearchProductSkuRequest : BasePlatformRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 当Spu有值时会忽略Sku
|
|||
/// </summary>
|
|||
public string Spu { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 多个Sku逗号间隔
|
|||
/// </summary>
|
|||
public string Sku { get; set; } |
|||
|
|||
public int PageIndex { get; set; } |
|||
|
|||
public int PageSize { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,77 @@ |
|||
namespace SDKAdapter.OperationPlatform.Models |
|||
{ |
|||
public class OP_ProductResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 商品Id
|
|||
/// </summary>
|
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品货号
|
|||
/// </summary>
|
|||
public string ProductItemNum { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品标题
|
|||
/// </summary>
|
|||
public string Title { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品状态
|
|||
/// <para>京东【-1:删除 1:从未上架 2:自主下架 4:系统下架 8:上架 513:从未上架待审 514:自主下架待审 516:系统下架待审 520:上架待审核 1028:系统下架审核失败】</para>
|
|||
/// </summary>
|
|||
public int State { get; set; } |
|||
|
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
public string Logo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品品牌名称
|
|||
/// </summary>
|
|||
public string BrandName { get; set; } |
|||
} |
|||
|
|||
public class OP_ProductListResponse |
|||
{ |
|||
public int Count { get; set; } |
|||
|
|||
public IList<OP_ProductResponse> Items { get; set; } |
|||
} |
|||
|
|||
public class OP_ProductSkuResponse |
|||
{ |
|||
public string Id { get; set; } |
|||
|
|||
public string ProductId { get; set; } |
|||
|
|||
public decimal Price { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Sku标题
|
|||
/// </summary>
|
|||
public string Title { get; set; } |
|||
|
|||
public string Logo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Sku状态
|
|||
/// <para>
|
|||
/// 京东【1:上架 2:下架 4:删除】
|
|||
/// </para>
|
|||
/// </summary>
|
|||
public int State { get; set; } |
|||
|
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
//public JToken Source { get; set; }
|
|||
} |
|||
|
|||
public class OP_ProductSkuListResponse |
|||
{ |
|||
public int Count { get; set; } |
|||
|
|||
public IList<OP_ProductSkuResponse> Items { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
namespace SDKAdapter.PurchasePlatform.Models |
|||
{ |
|||
public class AdapterEnums |
|||
{ |
|||
public enum PlatformType |
|||
{ |
|||
淘宝 = 0, |
|||
京东 = 1, |
|||
阿里巴巴 = 2, |
|||
拼多多 = 3, |
|||
微信 = 4, |
|||
拳探 = 10 |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace SDKAdapter.PurchasePlatform |
|||
{ |
|||
internal class PurchasePlatformSDK |
|||
{ |
|||
} |
|||
} |
Loading…
Reference in new issue