Compare commits

...

2 Commits

Author SHA1 Message Date
shanji 3f4b74dd71 1 2 years ago
shanji 90b5c1021f 1 2 years ago
  1. 4
      BBWY.Server.API/BBWY.Server.API.csproj
  2. 27
      BBWY.Server.API/Controllers/AfterSaleOrderSyncController.cs
  3. 4
      BBWY.Server.Business/AfterSaleOrder/AfterSaleOrderBusiness.cs
  4. 9
      BBWY.Server.Business/BBWY.Server.Business.csproj
  5. 18
      BBWY.Server.Business/BaseBusiness.cs
  6. 32
      BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs
  7. 2
      BBWY.Server.Business/DingDingBusiness.cs
  8. 55
      BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs
  9. 370
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  10. 85
      BBWY.Server.Business/Extensions/OrderCostExtension.cs
  11. 3
      BBWY.Server.Business/FinancialTerminal/FinancialTerminalBusiness.cs
  12. 172
      BBWY.Server.Business/Order/OrderBusiness.cs
  13. 50
      BBWY.Server.Business/Product/ProductBusiness.cs
  14. 6
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  15. 4
      BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs
  16. 4
      BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
  17. 5
      BBWY.Server.Business/ServiceOrder/ServiceOrderBusiness.cs
  18. 11
      BBWY.Server.Business/SiNan/GOIWarningBusiness.cs
  19. 4
      BBWY.Server.Business/Statistics/JDReportFormStatisticsBusiness.cs
  20. 5
      BBWY.Server.Business/Statistics/StatisticsBusiness.cs
  21. 455
      BBWY.Server.Business/Sync/AfterSaleOrderSyncBusiness.cs
  22. 29
      BBWY.Server.Business/Sync/BaseSyncBusiness.cs
  23. 52
      BBWY.Server.Business/Sync/JD/JDPopularizeReportFormAdGroupLevelSyncBusiness.cs
  24. 56
      BBWY.Server.Business/Sync/JD/JDPopularizeReportFormAdLevelSyncBusiness.cs
  25. 53
      BBWY.Server.Business/Sync/JD/JDPopularizeReportFormCampaignLevelSyncBusiness.cs
  26. 55
      BBWY.Server.Business/Sync/JD/JDPopularizeReportFormOrderLevelSyncBusiness.cs
  27. 73
      BBWY.Server.Business/Sync/JD/JDPopularizeReportFormSkuLevelSyncBusiness.cs
  28. 68
      BBWY.Server.Business/Sync/JD/JDPopularizeSyncBusiness.cs
  29. 127
      BBWY.Server.Business/Sync/JD/JDServiceOrderSyncBusiness.cs
  30. 3
      BBWY.Server.Business/Sync/OrderSkuSaleDetailSyncBusiness.cs
  31. 121
      BBWY.Server.Business/Sync/OrderSyncBusiness.cs
  32. 27
      BBWY.Server.Business/Sync/ProductSyncBusiness.cs
  33. 40
      BBWY.Server.Business/Sync/StoreHouseSyncBusiness.cs
  34. 70
      BBWY.Server.Business/Vender/VenderBusiness.cs
  35. 10
      BBWY.Server.Model/BBWY.Server.Model.csproj
  36. 8
      BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs

4
BBWY.Server.API/BBWY.Server.API.csproj

@ -5,6 +5,10 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Controllers\AfterSaleOrderController.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FreeSql" Version="2.6.100" />
<PackageReference Include="FreeSql.Provider.MySql" Version="2.6.100" />

27
BBWY.Server.API/Controllers/AfterSaleOrderSyncController.cs

@ -1,27 +0,0 @@
using BBWY.Server.Business;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace BBWY.Server.API.Controllers
{
public class AfterSaleOrderSyncController : BaseApiController
{
private AfterSaleOrderSyncBusiness afterSaleOrderSyncBusiness;
public AfterSaleOrderSyncController(IHttpContextAccessor httpContextAccessor,
AfterSaleOrderSyncBusiness afterSaleOrderSyncBusiness) : base(httpContextAccessor)
{
this.afterSaleOrderSyncBusiness = afterSaleOrderSyncBusiness;
}
/// <summary>
/// 全店同步售后订单
/// </summary>
[HttpPost]
public void SyncAllShopAfterOrder()
{
afterSaleOrderSyncBusiness.SyncAllShopAfterOrder();
}
}
}

4
BBWY.Server.Business/AfterSaleOrder/AfterSaleOrderBusiness.cs

@ -3,6 +3,7 @@ using BBWY.Server.Business.Extensions;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Yitter.IdGenerator;
@ -11,9 +12,8 @@ namespace BBWY.Server.Business
{
public class AfterSaleOrderBusiness : BaseBusiness, IDenpendency
{
public AfterSaleOrderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
public AfterSaleOrderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}
private Expression<Func<AfterSaleOrder, OrderSku, OrderConsignee, AfterSaleOrderResponse>> GetExpressionField()

9
BBWY.Server.Business/BBWY.Server.Business.csproj

@ -5,6 +5,11 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="AfterSaleOrder\AfterSaleOrderBusiness.cs" />
<Compile Remove="Sync\AfterSaleOrderSyncBusiness.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FreeSql" Version="2.6.100" />
<PackageReference Include="FreeSql.Provider.MySql" Version="2.6.100" />
@ -22,4 +27,8 @@
<ProjectReference Include="..\QuanTan.SDK\QuanTan.SDK.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="AfterSaleOrder\" />
</ItemGroup>
</Project>

18
BBWY.Server.Business/BaseBusiness.cs

@ -1,4 +1,8 @@
using Yitter.IdGenerator;
using BBWY.Common.Models;
using BBWY.Server.Model;
using System.Collections.Generic;
using System.Linq;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class BaseBusiness
@ -6,12 +10,22 @@ namespace BBWY.Server.Business
protected IFreeSql fsql;
protected NLogManager nLogManager;
protected IIdGenerator idGenerator;
protected IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
public BaseBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator)
public BaseBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList)
{
this.fsql = fsql;
this.nLogManager = nLogManager;
this.idGenerator = idGenerator;
this.platformSDKBusinessList = platformSDKBusinessList;
}
public PlatformSDKBusiness GetPlatformSDKBusiness(Enums.Platform platofrm)
{
var pb = platformSDKBusinessList.FirstOrDefault(p => p.Platform == platofrm);
if (pb == null)
throw new BusinessException($"不支持平台{platofrm}");
return pb;
}
}
}

32
BBWY.Server.Business/BillCorrection/BillCorrectionBusiness.cs

@ -11,9 +11,8 @@ namespace BBWY.Server.Business
{
public class BillCorrectionBusiness : BaseBusiness, IDenpendency
{
public BillCorrectionBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
public BillCorrectionBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}
public IList<BillCorrectionOrderResponse> GetBillCorrectionOrderList(QueryBillCorrectionOrderRequest request)
@ -54,19 +53,19 @@ namespace BBWY.Server.Business
var sdOrderCostList = fsql.Select<OrderCost>(sdOrderIds).ToList();
var afterOrderList = fsql.Select<AfterSaleOrder>()
.Where(aso => orderIds.Contains(aso.OrderId))
.GroupBy(aso => aso.OrderId)
.ToList(g => new
{
OrderId = g.Key,
AfterTotalCost = g.Sum(g.Value.AfterTotalCost)
});
//var afterOrderList = fsql.Select<AfterSaleOrder>()
// .Where(aso => orderIds.Contains(aso.OrderId))
// .GroupBy(aso => aso.OrderId)
// .ToList(g => new
// {
// OrderId = g.Key,
// AfterTotalCost = g.Sum(g.Value.AfterTotalCost)
// });
foreach (var order in orderList)
{
var orderCostDetail = orderCostDetailList.FirstOrDefault(ocd => ocd.OrderId == order.OrderId);
var afterOrder = afterOrderList.FirstOrDefault(aso => aso.OrderId == order.OrderId);
//var afterOrder = afterOrderList.FirstOrDefault(aso => aso.OrderId == order.OrderId);
order.DeliveryExpressFreight = orderCostDetail?.DeliveryExpressFreight ?? 0M;
order.SkuAmount = orderCostDetail?.SkuAmount ?? 0M;
@ -76,7 +75,7 @@ namespace BBWY.Server.Business
order.OutStorageAmount = orderCostDetail?.OutStorageAmount ?? 0M;
order.ConsumableAmount = orderCostDetail?.ConsumableAmount ?? 0M;
order.StorageAmount = orderCostDetail?.StorageAmount ?? 0M;
order.AfterTotalCost = afterOrder?.AfterTotalCost ?? 0M;
//order.AfterTotalCost = afterOrder?.AfterTotalCost ?? 0M;
if (order.StorageType == Model.Enums.StorageType.SD)
{
@ -95,7 +94,7 @@ namespace BBWY.Server.Business
var orderList = fsql.Select<Order>(orderIds).ToList();
var orderCostList = fsql.Select<OrderCost>(orderIds).ToList();
var orderCostDetailList = fsql.Select<OrderCostDetail>().Where(ocd => orderIds.Contains(ocd.OrderId) && ocd.IsEnabled == true).ToList();
var afterOrderList = fsql.Select<AfterSaleOrder>().Where(aso => orderIds.Contains(aso.OrderId)).ToList();
//var afterOrderList = fsql.Select<AfterSaleOrder>().Where(aso => orderIds.Contains(aso.OrderId)).ToList();
IList<IUpdate<OrderCost>> updateOrderCostList = new List<IUpdate<OrderCost>>();
IList<IUpdate<OrderCostDetail>> updateOrderCostDetailList = new List<IUpdate<OrderCostDetail>>();
@ -111,13 +110,14 @@ namespace BBWY.Server.Business
var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == billCorrectionRequest.OrderId).ToList();
if (currentOrderCostDetailList.Count() == 0 && order.StorageType != Model.Enums.StorageType.SD)
continue;
var currentOrderAfterOrderList = afterOrderList.Where(aso => aso.OrderId == billCorrectionRequest.OrderId).ToList();
//var currentOrderAfterOrderList = afterOrderList.Where(aso => aso.OrderId == billCorrectionRequest.OrderId).ToList();
orderCost.DeliveryExpressFreight = billCorrectionRequest.NewDeliveryExpressFreight;
if (order.StorageType != Model.Enums.StorageType.SD)
{
orderCost.CalculationOrderProfitAndCost(order, currentOrderAfterOrderList);
//orderCost.CalculationOrderProfitAndCost(order, currentOrderAfterOrderList);
orderCost.CalculationOrderProfitAndCost(order);
var singleDeliveryExpressFreight = billCorrectionRequest.NewDeliveryExpressFreight / currentOrderCostDetailList.Count();
foreach (var ocd in currentOrderCostDetailList)
{
@ -129,7 +129,7 @@ namespace BBWY.Server.Business
}
else
{
orderCost.CalculationSDOrderProfitAndCost(order, afterOrderList);
orderCost.CalculationSDOrderProfitAndCost(order);
}
var updateOrderCost = fsql.Update<OrderCost>(orderCost.OrderId).Set(oc => oc.DeliveryExpressFreight, orderCost.DeliveryExpressFreight)

2
BBWY.Server.Business/DingDingBusiness.cs

@ -14,7 +14,7 @@ namespace BBWY.Server.Business
{
private RestApiService restApiService;
public DingDingBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, RestApiService restApiService) : base(fsql, nLogManager, idGenerator)
public DingDingBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, RestApiService restApiService, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.restApiService = restApiService;
}

55
BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs

@ -1,15 +1,10 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -22,7 +17,7 @@ namespace BBWY.Server.Business
private IList<Enums.StorageType> validStorageTypeList;
private DingDingBusiness dingDingBusiness;
public JDStockNumWarningBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness, DingDingBusiness dingDingBusiness) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, yunDingBusiness)
public JDStockNumWarningBusiness(NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness) : base(nLogManager, fsql, idGenerator, taskSchedulerManager, platformSDKBusinessList, venderBusiness)
{
validStorageTypeList = new List<Enums.StorageType>() {
Enums.StorageType.,
@ -32,6 +27,16 @@ namespace BBWY.Server.Business
this.dingDingBusiness = dingDingBusiness;
}
//public JDStockNumWarningBusiness( NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, platformSDKBusinessList)
//{
// validStorageTypeList = new List<Enums.StorageType>() {
// Enums.StorageType.云仓,
// Enums.StorageType.京仓,
// Enums.StorageType.本地自发
// };
// this.dingDingBusiness = dingDingBusiness;
//}
public void StartCheckStockNum()
{
var storeHouseList = fsql.Select<Storehouse>().Where(s => s.Platform == Enums.Platform.).ToList();
@ -155,25 +160,35 @@ namespace BBWY.Server.Business
}
Thread.Sleep(1000);
var restApiResult = restApiService.SendRequest(GetPlatformRelayAPIHost(shop.PlatformId), "api/platformsdk/GetStockNumBySku", new SearchProductSkuRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
Platform = shop.PlatformId,
Sku = sku
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (restApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"{sku} {restApiResult.Content}");
var response = JsonConvert.DeserializeObject<ApiResponse<JArray>>(restApiResult.Content);
if (response.Data == null || response.Data.Count() == 0)
var response = GetPlatformSDKBusiness(Enums.Platform.).GetStockNumBySku(
new SearchProductSkuRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
Platform = shop.PlatformId,
Sku = sku
});
//var restApiResult = restApiService.SendRequest(GetPlatformRelayAPIHost(shop.PlatformId), "api/platformsdk/GetStockNumBySku", new SearchProductSkuRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// Platform = shop.PlatformId,
// Sku = sku
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (restApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"{sku} {restApiResult.Content}");
//var response = JsonConvert.DeserializeObject<ApiResponse<JArray>>(restApiResult.Content);
if (response == null || response?.Count() == 0)
{
logContentBuilder.AppendLine("未查询到JD库存数据");
nLogManager.GetLogger(loggerName).Info(logContentBuilder);
continue;
}
var skuStockNumList = response.Data.Select(j => new
var skuStockNumList = response.Select(j => new
{
StockNum = j.Value<int>("stockNum"),
Store = storeHouseList.FirstOrDefault(s => s.Id == j.Value<string>("storeId")),

370
BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs

@ -18,14 +18,11 @@ using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class EvaluationAssistantBusiness : BasePlatformRelayBusiness, IDenpendency
public class EvaluationAssistantBusiness : BaseBusiness, IDenpendency
{
private IFreeSql fsql;
private IIdGenerator idGenerator;
private TaskSchedulerManager taskSchedulerManager;
private VenderBusiness venderBusiness;
private DingDingBusiness dingDingBusiness;
private NLogManager nLogManager;
private List<Enums.OrderState> validOrderStateList;
private List<Enums.PromitionTaskStatus> preTaskStateList;
private ProductBusiness productBusiness;
@ -33,7 +30,15 @@ namespace BBWY.Server.Business
private char[] spliter;
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness, FreeSqlMultiDBManager freeSqlMultiDBManager) : base(restApiService, options, yunDingBusiness)
public EvaluationAssistantBusiness(IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
DingDingBusiness dingDingBusiness,
NLogManager nLogManager,
ProductBusiness productBusiness,
FreeSqlMultiDBManager freeSqlMultiDBManager,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.fsql = fsql;
@ -183,8 +188,7 @@ namespace BBWY.Server.Business
if (request.Id == 0)
{
var relayAPIHost = GetPlatformRelayAPIHost(Enums.Platform.);
var restApiResult_spu = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", new SearchProductRequest()
var spuResponse = productBusiness.GetProductList(new SearchProductRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
@ -193,12 +197,24 @@ namespace BBWY.Server.Business
PageSize = 10,
Platform = Enums.Platform.,
Spu = request.MainProductSpu
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (restApiResult_spu.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(restApiResult_spu.Content) { Code = (int)restApiResult_spu.StatusCode };
var spuResponse = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(restApiResult_spu.Content);
if (!spuResponse.Success)
throw new BusinessException(spuResponse.Msg) { Code = spuResponse.Code };
});
//var relayAPIHost = GetPlatformRelayAPIHost(Enums.Platform.京东);
//var restApiResult_spu = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", new SearchProductRequest()
//{
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// PageIndex = 1,
// PageSize = 10,
// Platform = Enums.Platform.京东,
// Spu = request.MainProductSpu
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (restApiResult_spu.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(restApiResult_spu.Content) { Code = (int)restApiResult_spu.StatusCode };
//var spuResponse = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(restApiResult_spu.Content);
//if (!spuResponse.Success)
// throw new BusinessException(spuResponse.Msg) { Code = spuResponse.Code };
var sort = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == request.ShopId).ToAggregate(p => p.Max(p.Key.Sort));
var promotionTask = new PromotionTask()
@ -219,8 +235,8 @@ namespace BBWY.Server.Business
PromotionId = 0,
Sort = sort + 1,
UpdateSortTime = DateTime.Now,
SpuLogo = spuResponse.Data.Items[0].Logo,
SpuPublishTime = spuResponse.Data.Items[0].CreateTime,
SpuLogo = spuResponse.Items[0].Logo,
SpuPublishTime = spuResponse.Items[0].CreateTime,
TaskCount = request.TaskCount,
CustomMotherSku = request.CustomMotherSku,
OuterId = request.OuterId
@ -523,14 +539,15 @@ namespace BBWY.Server.Business
CheckRepeatSkuInRuningTask(runingTaskList, dbPromotionTask.MainProductSku);
var host = GetPlatformRelayAPIHost(Enums.Platform.);
//var host = GetPlatformRelayAPIHost(Enums.Platform.京东);
var haveGiftTemplateSku = giftTemplateSkuList != null && giftTemplateSkuList.Count() > 0;
string barCode = string.Empty, categoryId = string.Empty;
IList<JToken> multiCateProps = null;
var mainProductSkuInStore = false;
var platformSdkBusiness = GetPlatformSDKBusiness(Enums.Platform.);
if (haveGiftTemplateSku)
{
var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest()
var mainSkuListResponse = productBusiness.GetProductSkuList(new SearchProductSkuRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
@ -538,34 +555,52 @@ namespace BBWY.Server.Business
IsContainSource = true,
Platform = request.Platform,
Spu = dbPromotionTask.MainProductSpu
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}");
var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content);
if (!mainSkuListResponse.Success)
throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}");
});
barCode = mainSkuListResponse.Data[0].Source.Value<string>("barCode");
categoryId = mainSkuListResponse.Data[0].Source.Value<string>("categoryId");
multiCateProps = mainSkuListResponse.Data[0].Source["multiCateProps"] != null ? mainSkuListResponse.Data[0].Source["multiCateProps"].ToList() : null;
//var mainSkuResult = restApiService.SendRequest(host, "api/PlatformSDK/GetProductSkuList", new SearchProductSkuRequest()
//{
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// IsContainSource = true,
// Platform = request.Platform,
// Spu = dbPromotionTask.MainProductSpu
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (mainSkuResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException($"获取主商品sku失败 {mainSkuResult.Content}");
//var mainSkuListResponse = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(mainSkuResult.Content);
//if (!mainSkuListResponse.Success)
// throw new BusinessException($"获取主商品sku失败 {mainSkuListResponse.Msg}");
barCode = mainSkuListResponse[0].Source.Value<string>("barCode");
categoryId = mainSkuListResponse[0].Source.Value<string>("categoryId");
multiCateProps = mainSkuListResponse[0].Source["multiCateProps"] != null ? mainSkuListResponse[0].Source["multiCateProps"].ToList() : null;
var jyStoreIdList = fsql.Select<Storehouse>().Where(s => s.Type == Enums.StockType. || s.Name.Contains("云仓")).ToList(s => s.Id);
foreach (var sku in mainSkuListResponse.Data)
foreach (var sku in mainSkuListResponse)
{
var stockNumApiResult = restApiService.SendRequest(host, "api/platformsdk/GetStockNumBySku", new SearchProductSkuRequest()
var stockNumListResponse = platformSdkBusiness.GetStockNumBySku(new SearchProductSkuRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
Platform = shop.PlatformId,
Sku = sku.Id
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (stockNumApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"{sku} {stockNumApiResult.Content}");
var stockNumListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(stockNumApiResult.Content);
var skuStockNumList = stockNumListResponse.Data.Select(j => new
});
//var stockNumApiResult = restApiService.SendRequest(host, "api/platformsdk/GetStockNumBySku", new SearchProductSkuRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// Platform = shop.PlatformId,
// Sku = sku.Id
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (stockNumApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"{sku} {stockNumApiResult.Content}");
//var stockNumListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(stockNumApiResult.Content);
var skuStockNumList = stockNumListResponse.Select(j => new
{
StockNum = j.Value<int>("stockNum"),
StoreId = j.Value<string>("storeId"),
@ -577,7 +612,7 @@ namespace BBWY.Server.Business
}
}
var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionTask", new StartPromotionTaskRequest2()
var startResponse = platformSdkBusiness.StartJDPromotionTask(new StartPromotionTaskRequest2()
{
Id = dbPromotionTask.Id,
ActivityName = dbPromotionTask.ActivityName,
@ -600,15 +635,16 @@ namespace BBWY.Server.Business
MainProductMultiCateProps = multiCateProps,
MainProductSkuInStore = mainProductSkuInStore,
OuterId = dbPromotionTask.OuterId
});
}, GetYunDingRequestHeader(), HttpMethod.Post);
//var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionTask", , GetYunDingRequestHeader(), HttpMethod.Post);
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(httpApiResult.Content);
var response = JsonConvert.DeserializeObject<ApiResponse<StartPromotionTaskResponse>>(httpApiResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg);
var startResponse = response.Data;
//if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(httpApiResult.Content);
//var response = JsonConvert.DeserializeObject<ApiResponse<StartPromotionTaskResponse>>(httpApiResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg);
//var startResponse = response.Data;
if (dbPromotionTask.GiftTemplateId != null &&
dbPromotionTask.GiftTemplateId != 0 &&
@ -636,22 +672,6 @@ namespace BBWY.Server.Business
private void StartPromotionDelayTask(StartPromotionTaskRequest request, StartPromotionTaskResponse startResponse, PromotionTask promotionTask, ShopResponse shop)
{
var host = GetPlatformRelayAPIHost(Enums.Platform.);
var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionDelayTask", new StartPromotionTaskDelayRequest()
{
Platform = Enums.Platform.,
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
BrandName = startResponse.BrandName,
FullTitle = promotionTask.FullTitle,
JDPromotionId = startResponse.JDPromotionId,
MainProductSpu = promotionTask.MainProductSpu,
HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0,
DeleteGiftSkuList = startResponse.DeleteGiftSkuList
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 150);
var errorBack = new Action<long, string>((id, errorMsg) =>
{
fsql.Update<PromotionTask>(id).Set(pt => pt.Status, Enums.PromitionTaskStatus.)
@ -659,17 +679,59 @@ namespace BBWY.Server.Business
.ExecuteAffrows();
Error(shop, $"评价助手-{shop.ShopName}", $"开始任务-延迟任务-任务Id {request.Id}", new Exception(errorMsg));
});
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
try
{
errorBack(promotionTask.Id, httpApiResult.Content);
return;
GetPlatformSDKBusiness(Enums.Platform.).StartJDPromotionDelayTask(new StartPromotionTaskDelayRequest()
{
Platform = Enums.Platform.,
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
BrandName = startResponse.BrandName,
FullTitle = promotionTask.FullTitle,
JDPromotionId = startResponse.JDPromotionId,
MainProductSpu = promotionTask.MainProductSpu,
HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0,
DeleteGiftSkuList = startResponse.DeleteGiftSkuList
});
}
var response = JsonConvert.DeserializeObject<ApiResponse<object>>(httpApiResult.Content);
if (!response.Success)
catch (Exception ex)
{
errorBack(promotionTask.Id, response.Msg);
errorBack(promotionTask.Id, ex.Message);
return;
}
//var host = GetPlatformRelayAPIHost(Enums.Platform.京东);
//var httpApiResult = restApiService.SendRequest(host, "api/PlatformSDK/StartJDPromotionDelayTask", new StartPromotionTaskDelayRequest()
//{
// Platform = Enums.Platform.京东,
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// BrandName = startResponse.BrandName,
// FullTitle = promotionTask.FullTitle,
// JDPromotionId = startResponse.JDPromotionId,
// MainProductSpu = promotionTask.MainProductSpu,
// HaveGiftTemplate = promotionTask.GiftTemplateId != null && promotionTask.GiftTemplateId != 0,
// DeleteGiftSkuList = startResponse.DeleteGiftSkuList
//}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 150);
//if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
//{
// errorBack(promotionTask.Id, httpApiResult.Content);
// return;
//}
//var response = JsonConvert.DeserializeObject<ApiResponse<object>>(httpApiResult.Content);
//if (!response.Success)
//{
// errorBack(promotionTask.Id, response.Msg);
// return;
//}
}
/// <summary>
@ -681,23 +743,33 @@ namespace BBWY.Server.Business
var dbPromotionTask = fsql.Select<PromotionTask>(request.TaskId).ToOne();
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.)
{
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.),
"api/platformsdk/DeleteJDPromotionTask",
new DeleteJDPromotionTaskRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
PromotionId = dbPromotionTask.PromotionId.Value
},
GetYunDingRequestHeader(),
HttpMethod.Post);
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(httpResult.Content);
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg);
GetPlatformSDKBusiness(Enums.Platform.).DeleteJDPromotionTask(
new DeleteJDPromotionTaskRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
PromotionId = dbPromotionTask.PromotionId.Value
});
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
// "api/platformsdk/DeleteJDPromotionTask",
// new DeleteJDPromotionTaskRequest()
// {
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// Platform = Enums.Platform.京东,
// PromotionId = dbPromotionTask.PromotionId.Value
// },
// GetYunDingRequestHeader(),
// HttpMethod.Post);
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(httpResult.Content);
//var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg);
}
fsql.Transaction(() =>
@ -725,24 +797,34 @@ namespace BBWY.Server.Business
if (!string.IsNullOrEmpty(dbPromotionTask.CustomMotherSku))
motherSkuIdList.AddRange(dbPromotionTask.CustomMotherSku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.),
"api/platformsdk/DeleteJDPromotionTaskSku",
new DeleteJDPromotionTaskSkuRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
PromotionId = dbPromotionTask.PromotionId.Value,
SkuId = string.Join(",", motherSkuIdList)
},
GetYunDingRequestHeader(),
HttpMethod.Post);
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(httpResult.Content);
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg);
GetPlatformSDKBusiness(Enums.Platform.).DeleteJDPromotionTaskSku(new DeleteJDPromotionTaskSkuRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
PromotionId = dbPromotionTask.PromotionId.Value,
SkuId = string.Join(",", motherSkuIdList)
});
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
// "api/platformsdk/DeleteJDPromotionTaskSku",
// new DeleteJDPromotionTaskSkuRequest()
// {
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// Platform = Enums.Platform.京东,
// PromotionId = dbPromotionTask.PromotionId.Value,
// SkuId = string.Join(",", motherSkuIdList)
// },
// GetYunDingRequestHeader(),
// HttpMethod.Post);
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(httpResult.Content);
//var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg);
}
fsql.Transaction(() =>
@ -766,26 +848,37 @@ namespace BBWY.Server.Business
if (dbPromotionTask.Status != Enums.PromitionTaskStatus.)
throw new BusinessException("只能在任务处于进行中时才能停止");
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.),
"api/platformsdk/SuspendJDPromotionTask",
new SuspendDPromotionTaskRequest()
{
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
PromotionId = dbPromotionTask.PromotionId.Value
},
GetYunDingRequestHeader(),
HttpMethod.Post);
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(httpResult.Content);
var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
if (!response.Success)
GetPlatformSDKBusiness(Enums.Platform.).SuspendJDPromotionTask(new SuspendDPromotionTaskRequest()
{
if (!response.Msg.Contains("促销已删除"))
throw new BusinessException(response.Msg);
}
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = Enums.Platform.,
PromotionId = dbPromotionTask.PromotionId.Value
});
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
// "api/platformsdk/SuspendJDPromotionTask",
// new SuspendDPromotionTaskRequest()
// {
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// Platform = Enums.Platform.京东,
// PromotionId = dbPromotionTask.PromotionId.Value
// },
// GetYunDingRequestHeader(),
// HttpMethod.Post);
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(httpResult.Content);
//var response = JsonConvert.DeserializeObject<ApiResponse>(httpResult.Content);
//if (!response.Success)
//{
// if (!response.Msg.Contains("促销已删除"))
// throw new BusinessException(response.Msg);
//}
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.).ExecuteAffrows();
}
@ -979,18 +1072,35 @@ namespace BBWY.Server.Business
{
#region 提前完成任务量,暂停JD活动
{
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.),
"api/platformsdk/SuspendJDPromotionTask",
new SuspendDPromotionTaskRequest()
{
AppKey = shop.AppKey2,
AppSecret = shop.AppSecret2,
AppToken = shop.AppToken2,
Platform = Enums.Platform.,
PromotionId = promotionTask.PromotionId.Value
},
GetYunDingRequestHeader(),
HttpMethod.Post);
try
{
GetPlatformSDKBusiness(Enums.Platform.).SuspendJDPromotionTask(new SuspendDPromotionTaskRequest()
{
AppKey = shop.AppKey2,
AppSecret = shop.AppSecret2,
AppToken = shop.AppToken2,
Platform = Enums.Platform.,
PromotionId = promotionTask.PromotionId.Value
});
}
catch (Exception ex)
{
Error(shop, loggerName, $"监控任务-暂停京东活动-任务Id {promotionTask.Id}", ex);
}
//var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.京东),
// "api/platformsdk/SuspendJDPromotionTask",
// new SuspendDPromotionTaskRequest()
// {
// AppKey = shop.AppKey2,
// AppSecret = shop.AppSecret2,
// AppToken = shop.AppToken2,
// Platform = Enums.Platform.京东,
// PromotionId = promotionTask.PromotionId.Value
// },
// GetYunDingRequestHeader(),
// HttpMethod.Post);
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
//{

85
BBWY.Server.Business/Extensions/OrderCostExtension.cs

@ -8,11 +8,64 @@ namespace BBWY.Server.Business.Extensions
{
public static class OrderCostExtension
{
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, Order order, IList<AfterSaleOrder> afterSaleOrders)
//public static void CalculationOrderProfitAndCost(this OrderCost orderCost, Order order, IList<AfterSaleOrder> afterSaleOrders)
//{
// orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
// orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
// orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
// //退款之后平台扣点
// orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
// orderCost.Profit = order.OrderSellerPrice + order.FreightPrice - orderCost.RefundAmount -
// orderCost.PurchaseAmount -
// orderCost.DeliveryExpressFreight -
// orderCost.PlatformCommissionAmount -
// orderCost.AfterTotalCost +
// orderCost.RefundPurchaseAmount;
//}
//public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal orderSellerPrice,decimal freightPrice, IList<AfterSaleOrder> afterSaleOrders)
//{
// orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
// orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
// orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
// //退款之后平台扣点
// orderCost.PlatformCommissionAmount = (orderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
// orderCost.Profit = orderSellerPrice + freightPrice - orderCost.RefundAmount -
// orderCost.PurchaseAmount -
// orderCost.DeliveryExpressFreight -
// orderCost.PlatformCommissionAmount -
// orderCost.AfterTotalCost +
// orderCost.RefundPurchaseAmount;
//}
//public static void CalculationSDOrderProfitAndCost(this OrderCost orderCost, Order order, IList<AfterSaleOrder> afterSaleOrders)
//{
// orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
// orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
// orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
// //退款之后平台扣点
// orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
// orderCost.Profit = (orderCost.SDCommissionAmount + orderCost.SDOrderAmount + orderCost.DeliveryExpressFreight + orderCost.PlatformCommissionAmount + orderCost.AfterTotalCost) * -1;
//}
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, Order order)
{
orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
//orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
//orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
//orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
orderCost.AfterTotalCost = 0;
orderCost.RefundAmount = 0;
orderCost.RefundPurchaseAmount = 0;
//退款之后平台扣点
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
@ -25,11 +78,15 @@ namespace BBWY.Server.Business.Extensions
orderCost.RefundPurchaseAmount;
}
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal orderSellerPrice,decimal freightPrice, IList<AfterSaleOrder> afterSaleOrders)
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal orderSellerPrice, decimal freightPrice)
{
orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
//orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
//orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
//orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
orderCost.AfterTotalCost = 0;
orderCost.RefundAmount = 0;
orderCost.RefundPurchaseAmount = 0;
//退款之后平台扣点
orderCost.PlatformCommissionAmount = (orderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
@ -44,11 +101,15 @@ namespace BBWY.Server.Business.Extensions
public static void CalculationSDOrderProfitAndCost(this OrderCost orderCost, Order order, IList<AfterSaleOrder> afterSaleOrders)
public static void CalculationSDOrderProfitAndCost(this OrderCost orderCost, Order order)
{
orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
//orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
//orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
//orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
orderCost.AfterTotalCost = 0;
orderCost.RefundAmount = 0;
orderCost.RefundPurchaseAmount = 0;
//退款之后平台扣点
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);

3
BBWY.Server.Business/FinancialTerminal/FinancialTerminalBusiness.cs

@ -10,9 +10,8 @@ namespace BBWY.Server.Business
{
public class FinancialTerminalBusiness : BaseBusiness, IDenpendency
{
public FinancialTerminalBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
public FinancialTerminalBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}
public IList<AuditPayBillResponse> GetAuditPayBillList(QueryAuditPayBillRequest request)

172
BBWY.Server.Business/Order/OrderBusiness.cs

@ -1,5 +1,4 @@
using BBWY.Common.Extensions;
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Business.Extensions;
using BBWY.Server.Model;
@ -9,24 +8,16 @@ using BBWY.Server.Model.Dto;
using FreeSql;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net.Http;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class OrderBusiness : BasePlatformRelayBusiness, IDenpendency
public class OrderBusiness : BaseBusiness, IDenpendency
{
private IFreeSql fsql;
private IIdGenerator idGenerator;
private Lazy<ProductBusiness> productBusinessLazy;
private ProductBusiness productBusiness => productBusinessLazy.Value;
@ -36,12 +27,12 @@ namespace BBWY.Server.Business
private IMemoryCache memoryCache;
private static TimeSpan sdGroupExpirationTimeSpan = TimeSpan.FromMinutes(20);
public OrderBusiness(RestApiService restApiService,
IFreeSql fsql,
public OrderBusiness(IFreeSql fsql,
IIdGenerator idGenerator,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
IServiceProvider serviceProvider,
IMemoryCache memoryCache, YunDingBusiness yunDingBusiness) : base(restApiService, options, yunDingBusiness)
IMemoryCache memoryCache,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.fsql = fsql;
this.idGenerator = idGenerator;
@ -221,9 +212,9 @@ namespace BBWY.Server.Business
#endregion
#region 处理售后信息
var afterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => orderIdList.Contains(aso.OrderId)).ToList<AfterSaleOrderResponse>();
foreach (var order in orderList)
order.AfterSaleOrderList = afterSaleOrderList.Where(aso => aso.OrderId == order.Id).ToList();
//var afterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => orderIdList.Contains(aso.OrderId)).ToList<AfterSaleOrderResponse>();
//foreach (var order in orderList)
// order.AfterSaleOrderList = afterSaleOrderList.Where(aso => aso.OrderId == order.Id).ToList();
#endregion
//#region 翻译仓库Id
@ -356,8 +347,8 @@ namespace BBWY.Server.Business
var orderCostDetailList = fsql.Select<OrderCostDetail>().Where(ocd => ocd.OrderId == orderId && ocd.IsEnabled == true).ToList().Map<IList<OrderCostDetailResponse>>();
var orderDropShippingList = fsql.Select<OrderDropShipping>().Where(ods => ods.OrderId == orderId).ToList().Map<IList<OrderDropShippingResponse>>();
if (order.IsAfterSaleOrder)
orderResponse.AfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == orderId).ToList<AfterSaleOrderResponse>();
//if (order.IsAfterSaleOrder)
// orderResponse.AfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == orderId).ToList<AfterSaleOrderResponse>();
//orderResponse.OrderDropShippingList = orderDropShippingList;
orderResponse.OrderDropShippingList = orderDropShippingList.Where(ods => ods.IsHistory == false).ToList();
@ -408,28 +399,30 @@ namespace BBWY.Server.Business
/// <exception cref="BusinessException"></exception>
public ConsigneeSimpleResponse DecryptConsignee(DecryptConsigneeRequest decryptConsigneeRequest)
{
var relayAPIHost = GetPlatformRelayAPIHost(decryptConsigneeRequest.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/DecryptConsignee", decryptConsigneeRequest, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<ConsigneeSimpleResponse>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
//var relayAPIHost = GetPlatformRelayAPIHost(decryptConsigneeRequest.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/DecryptConsignee", decryptConsigneeRequest, GetYunDingRequestHeader(), HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<ConsigneeSimpleResponse>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
var response = GetPlatformSDKBusiness(decryptConsigneeRequest.Platform).DecryptConsignee(decryptConsigneeRequest);
if (!string.IsNullOrEmpty(decryptConsigneeRequest.PlaintextMobile))
response.Data.Mobile = decryptConsigneeRequest.PlaintextMobile;
response.Mobile = decryptConsigneeRequest.PlaintextMobile;
//将解密后的收货人信息存至数据库
if (decryptConsigneeRequest.SaveDb)
{
fsql.Update<OrderConsignee>(decryptConsigneeRequest.OrderId).Set(oc => oc.ContactName, response.Data.ContactName)
.Set(oc => oc.Address, response.Data.Address)
.SetIf(!string.IsNullOrEmpty(response.Data.Mobile), oc => oc.Mobile, response.Data.Mobile)
.SetIf(!string.IsNullOrEmpty(response.Data.TelePhone), oc => oc.TelePhone, response.Data.TelePhone)
fsql.Update<OrderConsignee>(decryptConsigneeRequest.OrderId).Set(oc => oc.ContactName, response.ContactName)
.Set(oc => oc.Address, response.Address)
.SetIf(!string.IsNullOrEmpty(response.Mobile), oc => oc.Mobile, response.Mobile)
.SetIf(!string.IsNullOrEmpty(response.TelePhone), oc => oc.TelePhone, response.TelePhone)
.Set(oc => oc.IsDecode, true)
.ExecuteAffrows();
}
return response.Data;
return response;
}
/// <summary>
@ -452,7 +445,7 @@ namespace BBWY.Server.Business
orderSkuIds.Contains(po.SkuId)).ToList();
if (purchaserOrders.Count() == 0)
throw new BusinessException("库存为零不能自动计算成本");
var dbAfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == autoCalculationCostRequest.OrderId).ToList();
//var dbAfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == autoCalculationCostRequest.OrderId).ToList();
var orderCost = fsql.Select<OrderCost>(autoCalculationCostRequest.OrderId).ToOne();
var orderCostDetails = fsql.Select<OrderCostDetail>().Where(ocd => ocd.OrderId == autoCalculationCostRequest.OrderId && ocd.IsEnabled == true).ToList();
@ -557,7 +550,7 @@ namespace BBWY.Server.Business
DeliveryExpressFreight = orderDeliveryExpressFreight,
CreateTime = DateTime.Now
};
orderCost.CalculationOrderProfitAndCost(dbOrder, dbAfterSaleOrderList);
orderCost.CalculationOrderProfitAndCost(dbOrder);
insertOrderCost = fsql.Insert(orderCost);
#endregion
}
@ -565,7 +558,7 @@ namespace BBWY.Server.Business
{
orderCost.PurchaseAmount += orderCostPurchaseAmount;
orderCost.DeliveryExpressFreight += orderDeliveryExpressFreight;
orderCost.CalculationOrderProfitAndCost(dbOrder, dbAfterSaleOrderList);
orderCost.CalculationOrderProfitAndCost(dbOrder);
updateOrderCost = fsql.Update<OrderCost>().SetSource(orderCost);
}
@ -611,7 +604,7 @@ namespace BBWY.Server.Business
});
var avgPreferential = dbOrder.PreferentialAmount / orderSkuList.Count();
var dbAfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == manualCalculationCostRequest.OrderId).ToList();
//var dbAfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == manualCalculationCostRequest.OrderId).ToList();
if (manualCalculationCostRequest.IsSetStorageType)
orderUpdate = fsql.Update<Order>(manualCalculationCostRequest.OrderId)
@ -658,7 +651,7 @@ namespace BBWY.Server.Business
// orderCost.PurchaseAmount -
// orderCost.DeliveryExpressFreight -
// orderCost.PlatformCommissionAmount;
orderCost.CalculationOrderProfitAndCost(dbOrder, dbAfterSaleOrderList);
orderCost.CalculationOrderProfitAndCost(dbOrder);
insertOrderCost = fsql.Insert(orderCost);
}
else
@ -670,7 +663,7 @@ namespace BBWY.Server.Business
// orderCost.PurchaseAmount -
// orderCost.DeliveryExpressFreight -
// orderCost.PlatformCommissionAmount;
orderCost.CalculationOrderProfitAndCost(dbOrder, dbAfterSaleOrderList);
orderCost.CalculationOrderProfitAndCost(dbOrder);
orderCost.IsManualEdited = true;
updateOrderCost = fsql.Update<OrderCost>().SetSource(orderCost);
}
@ -701,9 +694,7 @@ namespace BBWY.Server.Business
return;
}
//修改平台订单备注
var relayAPIHost = GetPlatformRelayAPIHost(sdCalculationCostRequest.Platform);
var editApiResult = restApiService.SendRequest(relayAPIHost, "/Api/PlatformSDK/EditVenderRemark", new EditVenderRemarkRequest()
GetPlatformSDKBusiness(sdCalculationCostRequest.Platform).EditVenderRemark(new EditVenderRemarkRequest()
{
AppKey = sdCalculationCostRequest.AppKey,
AppSecret = sdCalculationCostRequest.AppSecret,
@ -712,18 +703,31 @@ namespace BBWY.Server.Business
OrderId = sdCalculationCostRequest.OrderId,
Platform = sdCalculationCostRequest.Platform,
VenderRemark = sdCalculationCostRequest.VenderRemark
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (editApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException($"修改商家备注失败 {editApiResult.Content}") { Code = (int)editApiResult.StatusCode };
var editResponse = JsonConvert.DeserializeObject<ApiResponse>(editApiResult.Content);
if (!editResponse.Success)
throw new BusinessException(editResponse.Msg);
});
//修改平台订单备注
//var relayAPIHost = GetPlatformRelayAPIHost(sdCalculationCostRequest.Platform);
//var editApiResult = restApiService.SendRequest(relayAPIHost, "/Api/PlatformSDK/EditVenderRemark", new EditVenderRemarkRequest()
//{
// AppKey = sdCalculationCostRequest.AppKey,
// AppSecret = sdCalculationCostRequest.AppSecret,
// AppToken = sdCalculationCostRequest.AppToken,
// Flag = sdCalculationCostRequest.Flag,
// OrderId = sdCalculationCostRequest.OrderId,
// Platform = sdCalculationCostRequest.Platform,
// VenderRemark = sdCalculationCostRequest.VenderRemark
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (editApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException($"修改商家备注失败 {editApiResult.Content}") { Code = (int)editApiResult.StatusCode };
//var editResponse = JsonConvert.DeserializeObject<ApiResponse>(editApiResult.Content);
//if (!editResponse.Success)
// throw new BusinessException(editResponse.Msg);
IUpdate<Order> orderUpdate = null;
IUpdate<OrderCost> updateOrderCost = null;
IInsert<OrderCost> insertOrderCost = null;
var dbAfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == sdCalculationCostRequest.OrderId).ToList();
//var dbAfterSaleOrderList = fsql.Select<AfterSaleOrder>().Where(aso => aso.OrderId == sdCalculationCostRequest.OrderId).ToList();
orderUpdate = fsql.Update<Order>(sdCalculationCostRequest.OrderId).Set(o => o.SDType, sdCalculationCostRequest.SDType)
.Set(o => o.Flag, sdCalculationCostRequest.Flag)
@ -755,7 +759,7 @@ namespace BBWY.Server.Business
};
//orderCost.PlatformCommissionAmount = dbOrder.OrderSellerPrice * orderCost.PlatformCommissionRatio;
//orderCost.Profit = (orderCost.SDCommissionAmount + orderCost.DeliveryExpressFreight + orderCost.PlatformCommissionAmount) * -1;
orderCost.CalculationSDOrderProfitAndCost(dbOrder, dbAfterSaleOrderList);
orderCost.CalculationSDOrderProfitAndCost(dbOrder);
insertOrderCost = fsql.Insert(orderCost);
}
else
@ -764,7 +768,7 @@ namespace BBWY.Server.Business
orderCost.SDOrderAmount = sdCalculationCostRequest.SDOrderAmount;
orderCost.DeliveryExpressFreight = sdCalculationCostRequest.DeliveryExpressFreight;
//orderCost.Profit = (orderCost.SDCommissionAmount + orderCost.DeliveryExpressFreight + orderCost.PlatformCommissionAmount) * -1;
orderCost.CalculationSDOrderProfitAndCost(dbOrder, dbAfterSaleOrderList);
orderCost.CalculationSDOrderProfitAndCost(dbOrder);
orderCost.IsManualEdited = true;
updateOrderCost = fsql.Update<OrderCost>().SetSource(orderCost);
}
@ -986,13 +990,15 @@ namespace BBWY.Server.Business
if (dbOrder.OrderState != Enums.OrderState.)
throw new BusinessException($"订单{outStockRequest.OrderId} 只有在待出库时才允许出库");
var relayAPIHost = GetPlatformRelayAPIHost(outStockRequest.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/OutStock", outStockRequest, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<ConsigneeSimpleResponse>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
GetPlatformSDKBusiness(outStockRequest.Platform).OutStock(outStockRequest);
//var relayAPIHost = GetPlatformRelayAPIHost(outStockRequest.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/OutStock", outStockRequest, GetYunDingRequestHeader(), HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<ConsigneeSimpleResponse>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
fsql.Update<Order>(outStockRequest.OrderId).Set(o => o.OrderState, Enums.OrderState.)
.Set(o => o.WaybillNo, outStockRequest.WayBillNo)
@ -1006,16 +1012,18 @@ namespace BBWY.Server.Business
public void EditVenderRemark(EditVenderRemarkRequest editVenderRemarkRequest)
{
//修改平台订单备注
var relayAPIHost = GetPlatformRelayAPIHost(editVenderRemarkRequest.Platform);
//var relayAPIHost = GetPlatformRelayAPIHost(editVenderRemarkRequest.Platform);
if (editVenderRemarkRequest.Platform == Enums.Platform.)
{
var editApiResult = restApiService.SendRequest(relayAPIHost, "/Api/PlatformSDK/EditVenderRemark", editVenderRemarkRequest, GetYunDingRequestHeader(), HttpMethod.Post);
if (editApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException($"修改商家备注失败 {editApiResult.Content}") { Code = (int)editApiResult.StatusCode };
var editResponse = JsonConvert.DeserializeObject<ApiResponse>(editApiResult.Content);
if (!editResponse.Success)
throw new BusinessException(editResponse.Msg);
//var editApiResult = restApiService.SendRequest(relayAPIHost, "/Api/PlatformSDK/EditVenderRemark", editVenderRemarkRequest, GetYunDingRequestHeader(), HttpMethod.Post);
//if (editApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException($"修改商家备注失败 {editApiResult.Content}") { Code = (int)editApiResult.StatusCode };
//var editResponse = JsonConvert.DeserializeObject<ApiResponse>(editApiResult.Content);
//if (!editResponse.Success)
// throw new BusinessException(editResponse.Msg);
GetPlatformSDKBusiness(editVenderRemarkRequest.Platform).EditVenderRemark(editVenderRemarkRequest);
}
else
{
@ -1041,19 +1049,29 @@ namespace BBWY.Server.Business
if (orderResponse == null)
{
var relayAPIHost = GetPlatformRelayAPIHost(request.Platform);
var orderApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetNoPayOrder", new SearchPlatformOrderRequest()
{
OrderId = request.OrderId,
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (orderApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException($"获取未付款订单失败 {orderApiResult.Content}");
var orderJToken = JToken.Parse(orderApiResult.Content);
//var relayAPIHost = GetPlatformRelayAPIHost(request.Platform);
//var orderApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetNoPayOrder", new SearchPlatformOrderRequest()
//{
// OrderId = request.OrderId,
// AppKey = request.AppKey,
// AppSecret = request.AppSecret,
// AppToken = request.AppToken,
// Platform = request.Platform,
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (orderApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException($"获取未付款订单失败 {orderApiResult.Content}");
var orderJToken = GetPlatformSDKBusiness(request.Platform).GetNoPayOrder(
new SearchPlatformOrderRequest()
{
OrderId = request.OrderId,
AppKey = request.AppKey,
AppSecret = request.AppSecret,
AppToken = request.AppToken,
Platform = request.Platform,
});
//var orderJToken = JToken.Parse(orderApiResult.Content);
var orderInfoJToken = orderJToken["Data"]["jingdong_pop_order_notPayOrderById_responce"]["orderDataNotPayInfo"];
if (orderInfoJToken == null || !orderInfoJToken.HasValues)
throw new BusinessException("未查询到待付款订单");

50
BBWY.Server.Business/Product/ProductBusiness.cs

@ -1,44 +1,42 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Common.Models;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net.Http;
using System.Linq;
namespace BBWY.Server.Business
{
public class ProductBusiness : BasePlatformRelayBusiness, IDenpendency
public class ProductBusiness : IDenpendency
{
public ProductBusiness(RestApiService restApiService, IConfiguration configuration, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness) : base(restApiService, options, yunDingBusiness)
private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
public ProductBusiness(IEnumerable<PlatformSDKBusiness> platformSDKBusinessList)
{
this.platformSDKBusinessList = platformSDKBusinessList;
}
public ProductListResponse GetProductList(SearchProductRequest searchProductRequest)
{
var relayAPIHost = GetPlatformRelayAPIHost(searchProductRequest.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", searchProductRequest, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
//var relayAPIHost = GetPlatformRelayAPIHost(searchProductRequest.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductList", searchProductRequest, GetYunDingRequestHeader(), HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<ProductListResponse>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
//return response.Data;
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == searchProductRequest.Platform).GetProductList(searchProductRequest);
}
public IList<ProductSkuResponse> GetProductSkuList(SearchProductSkuRequest searchProductSkuRequest)
{
var relayAPIHost = GetPlatformRelayAPIHost(searchProductSkuRequest.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductSkuList", searchProductSkuRequest, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
//var relayAPIHost = GetPlatformRelayAPIHost(searchProductSkuRequest.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetProductSkuList", searchProductSkuRequest, GetYunDingRequestHeader(), HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<IList<ProductSkuResponse>>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
//return response.Data;
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == searchProductSkuRequest.Platform).GetProductSkuList(searchProductSkuRequest);
}
}
}

6
BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -4,15 +4,12 @@ using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using FreeSql;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using QuanTan.SDK.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -21,7 +18,6 @@ namespace BBWY.Server.Business
{
public class PurchaseOrderBusiness : BaseBusiness, IDenpendency
{
private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
private TaskSchedulerManager taskSchedulerManager;
private OrderBusiness orderBusiness;
private MDSBusiness mdsBusiness;
@ -37,7 +33,7 @@ namespace BBWY.Server.Business
OrderBusiness orderBusiness,
MDSBusiness mdsBusiness,
VenderBusiness venderBusiness,
LogisticsCompanyConverter logisticsCompanyConverter) : base(fsql, nLogManager, idGenerator)
LogisticsCompanyConverter logisticsCompanyConverter) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.platformSDKBusinessList = platformSDKBusinessList;
this.taskSchedulerManager = taskSchedulerManager;

4
BBWY.Server.Business/PurchaseOrderV2/BatchPurchase/BatchPurchaseBusiness.cs

@ -3,7 +3,6 @@ using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using FreeSql;
using Jd.Api.Domain;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@ -17,13 +16,12 @@ namespace BBWY.Server.Business
public class BatchPurchaseBusiness : BaseBusiness, IDenpendency
{
private ProductBusiness productBusiness;
private IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
public BatchPurchaseBusiness(IFreeSql fsql,
NLogManager nLogManager,
IIdGenerator idGenerator,
ProductBusiness productBusiness,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator)
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.productBusiness = productBusiness;
this.platformSDKBusinessList = platformSDKBusinessList;

4
BBWY.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs

@ -11,7 +11,9 @@ namespace BBWY.Server.Business
{
public class PurchaseSchemeBusiness : BaseBusiness, IDenpendency
{
public PurchaseSchemeBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator) { }
public PurchaseSchemeBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}
private void ExtractNewPurchaser<T>(IList<T> purchaserSchemeList, IList<Purchaser> addPurchaserList) where T : InputPurchaseSchemeRequest
{

5
BBWY.Server.Business/ServiceOrder/ServiceOrderBusiness.cs

@ -1,18 +1,15 @@
using BBWY.Common.Models;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using System;
using System.Collections.Generic;
using System.Text;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class ServiceOrderBusiness : BaseBusiness, IDenpendency
{
public ServiceOrderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
public ServiceOrderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}
public ServiceOrderResponse GetList(ClientQueryServiceOrderRequest request)

11
BBWY.Server.Business/SiNan/GOIWarningBusiness.cs

@ -1,6 +1,4 @@
using BBWY.Common.Extensions;
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Business.Statistics;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
@ -8,7 +6,6 @@ using BBWY.Server.Model.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -23,7 +20,7 @@ namespace BBWY.Server.Business.SiNan
private JDReportFormStatisticsBusiness jDReportFormStatisticsBusiness;
private DingDingBusiness dingDingBusiness;
public GOIWarningBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, JDReportFormStatisticsBusiness jDReportFormStatisticsBusiness, DingDingBusiness dingDingBusiness) : base(fsql, nLogManager, idGenerator)
public GOIWarningBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, JDReportFormStatisticsBusiness jDReportFormStatisticsBusiness, DingDingBusiness dingDingBusiness, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.taskSchedulerManager = taskSchedulerManager;
this.venderBusiness = venderBusiness;
@ -509,8 +506,8 @@ namespace BBWY.Server.Business.SiNan
#endregion
if (dingdingSendBuilderList.Count > 0)
{
foreach(var sendBuilder in dingdingSendBuilderList)
{
foreach (var sendBuilder in dingdingSendBuilderList)
dingDingBusiness.SendDingDingBotMessage(shop.SiNanDingDingKey, shop.SiNanDingDingWebHook, sendBuilder.ToString());
}
}

4
BBWY.Server.Business/Statistics/JDReportFormStatisticsBusiness.cs

@ -5,16 +5,14 @@ using BBWY.Server.Model.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yitter.IdGenerator;
namespace BBWY.Server.Business.Statistics
{
public class JDReportFormStatisticsBusiness : BaseBusiness, IDenpendency
{
public JDReportFormStatisticsBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
public JDReportFormStatisticsBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}
public IList<JDMultiLevelGOIResponse> CalculationCampaignLevelGOI(GOIRequest gOIRequest)

5
BBWY.Server.Business/Statistics/StatisticsBusiness.cs

@ -16,7 +16,7 @@ namespace BBWY.Server.Business
private IList<Enums.OrderState> invalidOrderStateList;
private FreeSqlMultiDBManager freeSqlMultiDBManager;
public StatisticsBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager freeSqlMultiDBManager) : base(fsql, nLogManager, idGenerator)
public StatisticsBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager freeSqlMultiDBManager, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
invalidOrderStateList = new List<Enums.OrderState>() { Enums.OrderState., Enums.OrderState. };
this.freeSqlMultiDBManager = freeSqlMultiDBManager;
@ -308,7 +308,8 @@ namespace BBWY.Server.Business
response.WaitOutStoreCount = fsql.Select<Order>().Where(o => o.ShopId == shopId && o.OrderState == Enums.OrderState. && o.StartTime >= dt).Count();
response.AfterSaleOrderUnhandleCount = fsql.Select<AfterSaleOrder>().Where(aso => aso.ShopId == shopId && (aso.ProductHealth == null || aso.ProductResult == null) && aso.CreateTime >= afterDt).Count();
//response.AfterSaleOrderUnhandleCount = fsql.Select<AfterSaleOrder>().Where(aso => aso.ShopId == shopId && (aso.ProductHealth == null || aso.ProductResult == null) && aso.CreateTime >= afterDt).Count();
response.AfterSaleOrderUnhandleCount = 0;
return response;
}

455
BBWY.Server.Business/Sync/AfterSaleOrderSyncBusiness.cs

@ -1,244 +1,233 @@
using BBWY.Common.Extensions;
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using FreeSql;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using BBWY.Common.Models;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class AfterSaleOrderSyncBusiness : BaseSyncBusiness, IDenpendency
{
private IDictionary<Enums.Platform, Action<JArray, ShopResponse>> syncAfterSaleOrderMethodDic;
private IDictionary<int, Enums.ServiceResult> processResultDic;
public AfterSaleOrderSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService,
options,
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
//private IDictionary<Enums.Platform, Action<JArray, ShopResponse>> syncAfterSaleOrderMethodDic;
//private IDictionary<int, Enums.ServiceResult> processResultDic;
//public AfterSaleOrderSyncBusiness(RestApiService restApiService,
// IOptions<GlobalConfig> options,
// NLogManager nLogManager,
// IFreeSql fsql,
// IIdGenerator idGenerator,
// TaskSchedulerManager taskSchedulerManager,
// VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService,
// options,
// nLogManager,
// fsql,
// idGenerator,
// taskSchedulerManager,
// venderBusiness,
// yunDingBusiness)
//{
// syncAfterSaleOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, ShopResponse>>()
// {
// { Enums.Platform.京东, SyncJDAfterOrder }
// };
// processResultDic = new Dictionary<int, Enums.ServiceResult>()
// {
// { 23,Enums.ServiceResult.换新},
// { 40,Enums.ServiceResult.退货},
// { 60,Enums.ServiceResult.原返},
// { 90,Enums.ServiceResult.线下换新},
// { 110,Enums.ServiceResult.商品补发}
// };
//}
//private void SyncJDAfterOrder(JArray afterOrderTokenJArray, ShopResponse shop)
//{
// var shopId = long.Parse(shop.ShopId);
// var validAfterOrderJArray = afterOrderTokenJArray.Where(j => (j.Value<int>("serviceStatus") == 10010 || j.Value<int>("serviceStatus") == 10009) && //完成
// processResultDic.ContainsKey(j.Value<int>("processResult")));
// var orderIds = validAfterOrderJArray.Select(j => j["orderId"].ToString()).Distinct().ToList();
// var orderSkuIds = validAfterOrderJArray.Select(j => j["skuId"].ToString()).Distinct().ToList();
// var updateOrders = fsql.Select<Order>().Where(o => orderIds.Contains(o.Id) && o.IsAfterSaleOrder == false).ToList();
// var dbOrderSkus = fsql.Select<OrderSku>().Where(osku => orderIds.Contains(osku.OrderId) &&
// orderSkuIds.Contains(osku.SkuId) &&
// osku.Price != 0).ToList();
// var updateOrderSkus = dbOrderSkus.Where(osku => osku.IsRefund == false).ToList();
// var afterOrders = fsql.Select<AfterSaleOrder>().Where(aso => orderIds.Contains(aso.OrderId)).ToList();
// List<AfterSaleOrder> insertAfterSaleOrders = new List<AfterSaleOrder>();
// List<IUpdate<AfterSaleOrder>> updateAfterSaleOrders = new List<IUpdate<AfterSaleOrder>>();
// foreach (var afterOrderJToken in validAfterOrderJArray)
// {
// var orderId = afterOrderJToken.Value<string>("orderId");
// var skuId = afterOrderJToken.Value<string>("skuId");
// var serviceId = afterOrderJToken.Value<string>("serviceId");
// var processResult = processResultDic[afterOrderJToken.Value<int>("processResult")];
// var afterOrder = afterOrders.FirstOrDefault(aso => aso.ServiceId == serviceId);
// if (afterOrder == null)
// {
// var dbOrderSku = dbOrderSkus.FirstOrDefault(osku => osku.OrderId == orderId && osku.SkuId == skuId);
// if (dbOrderSku == null)
// continue;
// decimal refundAmount = 0M;
// try
// {
// if (processResult == Enums.ServiceResult.退货)
// refundAmount = SyncJDRefundOrder(shop, orderId, serviceId);
// }
// catch (Exception ex)
// {
// nLogManager.Default().Error(ex, $"SyncAfterOrder-SyncRefound ServiceId:{serviceId} OrderId:{orderId} ShopData:{JsonConvert.SerializeObject(shop)}");
// }
// insertAfterSaleOrders.Add(new AfterSaleOrder()
// {
// Id = idGenerator.NewLong(),
// CreateTime = DateTime.Now,
// OrderId = dbOrderSku.OrderId,
// ProductId = dbOrderSku.ProductId,
// RefundAmount = refundAmount,
// SkuId = skuId,
// ShopId = shopId,
// ServiceResult = processResult,
// ServiceId = serviceId,
// ApplyTime = afterOrderJToken.Value<long>("applyTime").StampToDateTime()
// });
// }
// else
// {
// if (afterOrder.ServiceResult == null ||
// (afterOrder.ServiceResult != processResult &&
// afterOrder.ServiceResult != Enums.ServiceResult.维修 &&
// afterOrder.ServiceResult != Enums.ServiceResult.仅退款 &&
// afterOrder.ServiceResult != Enums.ServiceResult.SD退货))
// {
// var update = fsql.Update<AfterSaleOrder>(afterOrder.Id).Set(aso => aso.ServiceResult, processResult);
// updateAfterSaleOrders.Add(update);
// }
// }
// }
// fsql.Transaction(() =>
// {
// if (updateOrders.Count() > 0)
// foreach (var updateOrder in updateOrders)
// fsql.Update<Order>(updateOrder.Id).Set(o => o.IsAfterSaleOrder, true).ExecuteAffrows();
// if (updateOrderSkus.Count() > 0)
// foreach (var updateOrderSku in updateOrderSkus)
// fsql.Update<OrderSku>(updateOrderSku.Id).Set(osku => osku.IsRefund, true).ExecuteAffrows();
// if (insertAfterSaleOrders.Count() > 0)
// fsql.Insert(insertAfterSaleOrders).ExecuteAffrows();
// if (updateAfterSaleOrders.Count() > 0)
// foreach (var update in updateAfterSaleOrders)
// update.ExecuteAffrows();
// });
//}
//private void SyncAfterOrder(ShopResponse shop, string orderId, DateTime? startTime = null, DateTime? endTime = null, bool isAuto = false)
//{
// try
// {
// //logger.Info($"售后订单同步 {shop.ShopName} isAuto {isAuto}");
// if (!syncAfterSaleOrderMethodDic.ContainsKey(shop.PlatformId))
// throw new Exception("不支持的平台");
// var shopId = long.Parse(shop.ShopId);
// var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
// var afterOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetAfterOrderList", new SyncAfterOrderRequest()
// {
// StartDate = startTime ?? DateTime.Now.Date.AddDays(-3),
// EndDate = endTime ?? DateTime.Now,
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// PageIndex = 1,
// PageSize = 50,
// Platform = shop.PlatformId,
// SaveResponseLog = true,
// OrderId = orderId,
// VenderId = shop.VenderId
// }, GetYunDingRequestHeader(), HttpMethod.Post);
// if (afterOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取退款订单失败 {afterOrderListApiResult.Content}");
// var afterOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(afterOrderListApiResult.Content);
// if (!afterOrderListResponse.Success)
// throw new Exception($"获取退款订单失败 {afterOrderListApiResult.Content}");
// if (afterOrderListResponse.Data == null || afterOrderListResponse.Data.Count == 0)
// return;
// syncAfterSaleOrderMethodDic[shop.PlatformId](afterOrderListResponse.Data, shop);
// }
// catch (Exception ex)
// {
// var shopData = JsonConvert.SerializeObject(shop);
// nLogManager.Default().Error(ex, $"SyncAfterOrder ShopData:{shopData}");
// }
//}
//public void SyncAllShopAfterOrder()
//{
// var shopList = venderBusiness.GetShopList(platform: Enums.Platform.京东);
// //SyncAfterOrder(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), string.Empty, isAuto: true);
// foreach (var shop in shopList)
// {
// Task.Factory.StartNew(() => SyncAfterOrder(shop, string.Empty, isAuto: true),
// System.Threading.CancellationToken.None,
// TaskCreationOptions.LongRunning,
// taskSchedulerManager.SyncAfterOrderTaskScheduler);
// }
//}
///// <summary>
///// 获取退款单
///// </summary>
///// <param name="shop"></param>
///// <param name="orderId"></param>
///// <param name="serviceId"></param>
///// <returns></returns>
///// <exception cref="Exception"></exception>
//private decimal SyncJDRefundOrder(ShopResponse shop, string orderId, string serviceId)
//{
// var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
// var refundOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetRefundList", new SearchRefundPlatformOrderRequest()
// {
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// PageIndex = 1,
// PageSize = 50,
// Platform = shop.PlatformId,
// SaveResponseLog = false,
// OrderId = orderId
// }, GetYunDingRequestHeader(), HttpMethod.Post);
// if (refundOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取退款订单失败 {refundOrderListApiResult.Content}");
// var refundOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(refundOrderListApiResult.Content);
// if (!refundOrderListResponse.Success)
// throw new Exception($"获取退款订单失败 {refundOrderListApiResult.Content}");
// if (refundOrderListResponse.Data == null || refundOrderListResponse.Data.Count == 0)
// return 0M;
// var jtoken = refundOrderListResponse.Data.FirstOrDefault(j => j["sameOrderServiceBill"]["serviceId"].ToString() == serviceId &&
// j.Value<int>("status") == 13 &&
// j.Value<decimal>("refoundAmount") != 0M);
// return jtoken == null ? 0M : jtoken.Value<decimal>("refoundAmount");
//}
public AfterSaleOrderSyncBusiness(NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList, VenderBusiness venderBusiness) : base(nLogManager, fsql, idGenerator, taskSchedulerManager, platformSDKBusinessList, venderBusiness)
{
syncAfterSaleOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, ShopResponse>>()
{
{ Enums.Platform., SyncJDAfterOrder }
};
processResultDic = new Dictionary<int, Enums.ServiceResult>()
{
{ 23,Enums.ServiceResult.},
{ 40,Enums.ServiceResult.退},
{ 60,Enums.ServiceResult.},
{ 90,Enums.ServiceResult.线},
{ 110,Enums.ServiceResult.}
};
}
private void SyncJDAfterOrder(JArray afterOrderTokenJArray, ShopResponse shop)
{
var shopId = long.Parse(shop.ShopId);
var validAfterOrderJArray = afterOrderTokenJArray.Where(j => (j.Value<int>("serviceStatus") == 10010 || j.Value<int>("serviceStatus") == 10009) && //完成
processResultDic.ContainsKey(j.Value<int>("processResult")));
var orderIds = validAfterOrderJArray.Select(j => j["orderId"].ToString()).Distinct().ToList();
var orderSkuIds = validAfterOrderJArray.Select(j => j["skuId"].ToString()).Distinct().ToList();
var updateOrders = fsql.Select<Order>().Where(o => orderIds.Contains(o.Id) && o.IsAfterSaleOrder == false).ToList();
var dbOrderSkus = fsql.Select<OrderSku>().Where(osku => orderIds.Contains(osku.OrderId) &&
orderSkuIds.Contains(osku.SkuId) &&
osku.Price != 0).ToList();
var updateOrderSkus = dbOrderSkus.Where(osku => osku.IsRefund == false).ToList();
var afterOrders = fsql.Select<AfterSaleOrder>().Where(aso => orderIds.Contains(aso.OrderId)).ToList();
List<AfterSaleOrder> insertAfterSaleOrders = new List<AfterSaleOrder>();
List<IUpdate<AfterSaleOrder>> updateAfterSaleOrders = new List<IUpdate<AfterSaleOrder>>();
foreach (var afterOrderJToken in validAfterOrderJArray)
{
var orderId = afterOrderJToken.Value<string>("orderId");
var skuId = afterOrderJToken.Value<string>("skuId");
var serviceId = afterOrderJToken.Value<string>("serviceId");
var processResult = processResultDic[afterOrderJToken.Value<int>("processResult")];
var afterOrder = afterOrders.FirstOrDefault(aso => aso.ServiceId == serviceId);
if (afterOrder == null)
{
var dbOrderSku = dbOrderSkus.FirstOrDefault(osku => osku.OrderId == orderId && osku.SkuId == skuId);
if (dbOrderSku == null)
continue;
decimal refundAmount = 0M;
try
{
if (processResult == Enums.ServiceResult.退)
refundAmount = SyncJDRefundOrder(shop, orderId, serviceId);
}
catch (Exception ex)
{
nLogManager.Default().Error(ex, $"SyncAfterOrder-SyncRefound ServiceId:{serviceId} OrderId:{orderId} ShopData:{JsonConvert.SerializeObject(shop)}");
}
insertAfterSaleOrders.Add(new AfterSaleOrder()
{
Id = idGenerator.NewLong(),
CreateTime = DateTime.Now,
OrderId = dbOrderSku.OrderId,
ProductId = dbOrderSku.ProductId,
RefundAmount = refundAmount,
SkuId = skuId,
ShopId = shopId,
ServiceResult = processResult,
ServiceId = serviceId,
ApplyTime = afterOrderJToken.Value<long>("applyTime").StampToDateTime()
});
}
else
{
if (afterOrder.ServiceResult == null ||
(afterOrder.ServiceResult != processResult &&
afterOrder.ServiceResult != Enums.ServiceResult. &&
afterOrder.ServiceResult != Enums.ServiceResult.退 &&
afterOrder.ServiceResult != Enums.ServiceResult.SD退货))
{
var update = fsql.Update<AfterSaleOrder>(afterOrder.Id).Set(aso => aso.ServiceResult, processResult);
updateAfterSaleOrders.Add(update);
}
}
}
fsql.Transaction(() =>
{
if (updateOrders.Count() > 0)
foreach (var updateOrder in updateOrders)
fsql.Update<Order>(updateOrder.Id).Set(o => o.IsAfterSaleOrder, true).ExecuteAffrows();
if (updateOrderSkus.Count() > 0)
foreach (var updateOrderSku in updateOrderSkus)
fsql.Update<OrderSku>(updateOrderSku.Id).Set(osku => osku.IsRefund, true).ExecuteAffrows();
if (insertAfterSaleOrders.Count() > 0)
fsql.Insert(insertAfterSaleOrders).ExecuteAffrows();
if (updateAfterSaleOrders.Count() > 0)
foreach (var update in updateAfterSaleOrders)
update.ExecuteAffrows();
});
}
private void SyncAfterOrder(ShopResponse shop, string orderId, DateTime? startTime = null, DateTime? endTime = null, bool isAuto = false)
{
try
{
//logger.Info($"售后订单同步 {shop.ShopName} isAuto {isAuto}");
if (!syncAfterSaleOrderMethodDic.ContainsKey(shop.PlatformId))
throw new Exception("不支持的平台");
var shopId = long.Parse(shop.ShopId);
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var afterOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetAfterOrderList", new SyncAfterOrderRequest()
{
StartDate = startTime ?? DateTime.Now.Date.AddDays(-3),
EndDate = endTime ?? DateTime.Now,
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
PageIndex = 1,
PageSize = 50,
Platform = shop.PlatformId,
SaveResponseLog = true,
OrderId = orderId,
VenderId = shop.VenderId
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (afterOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取退款订单失败 {afterOrderListApiResult.Content}");
var afterOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(afterOrderListApiResult.Content);
if (!afterOrderListResponse.Success)
throw new Exception($"获取退款订单失败 {afterOrderListApiResult.Content}");
if (afterOrderListResponse.Data == null || afterOrderListResponse.Data.Count == 0)
return;
syncAfterSaleOrderMethodDic[shop.PlatformId](afterOrderListResponse.Data, shop);
}
catch (Exception ex)
{
var shopData = JsonConvert.SerializeObject(shop);
nLogManager.Default().Error(ex, $"SyncAfterOrder ShopData:{shopData}");
}
}
public void SyncAllShopAfterOrder()
{
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.);
//SyncAfterOrder(shopList.FirstOrDefault(s => s.ShopName == "布莱特玩具专营店"), string.Empty, isAuto: true);
foreach (var shop in shopList)
{
Task.Factory.StartNew(() => SyncAfterOrder(shop, string.Empty, isAuto: true),
System.Threading.CancellationToken.None,
TaskCreationOptions.LongRunning,
taskSchedulerManager.SyncAfterOrderTaskScheduler);
}
}
/// <summary>
/// 获取退款单
/// </summary>
/// <param name="shop"></param>
/// <param name="orderId"></param>
/// <param name="serviceId"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
private decimal SyncJDRefundOrder(ShopResponse shop, string orderId, string serviceId)
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var refundOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetRefundList", new SearchRefundPlatformOrderRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
PageIndex = 1,
PageSize = 50,
Platform = shop.PlatformId,
SaveResponseLog = false,
OrderId = orderId
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (refundOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取退款订单失败 {refundOrderListApiResult.Content}");
var refundOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(refundOrderListApiResult.Content);
if (!refundOrderListResponse.Success)
throw new Exception($"获取退款订单失败 {refundOrderListApiResult.Content}");
if (refundOrderListResponse.Data == null || refundOrderListResponse.Data.Count == 0)
return 0M;
var jtoken = refundOrderListResponse.Data.FirstOrDefault(j => j["sameOrderServiceBill"]["serviceId"].ToString() == serviceId &&
j.Value<int>("status") == 13 &&
j.Value<decimal>("refoundAmount") != 0M);
return jtoken == null ? 0M : jtoken.Value<decimal>("refoundAmount");
}
}
}

29
BBWY.Server.Business/Sync/BaseSyncBusiness.cs

@ -1,34 +1,41 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using Microsoft.Extensions.Options;
using NLog;
using System.Collections.Generic;
using System.Linq;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class BaseSyncBusiness : BasePlatformRelayBusiness, IDenpendency
public class BaseSyncBusiness : IDenpendency
{
protected NLogManager nLogManager;
protected IFreeSql fsql;
protected IIdGenerator idGenerator;
protected TaskSchedulerManager taskSchedulerManager;
protected IEnumerable<PlatformSDKBusiness> platformSDKBusinessList;
protected VenderBusiness venderBusiness;
public BaseSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
public BaseSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService, options, yunDingBusiness)
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
VenderBusiness venderBusiness)
{
this.nLogManager = nLogManager;
this.fsql = fsql;
this.idGenerator = idGenerator;
this.venderBusiness = venderBusiness;
this.taskSchedulerManager = taskSchedulerManager;
this.platformSDKBusinessList = platformSDKBusinessList;
this.venderBusiness = venderBusiness;
}
public PlatformSDKBusiness GetPlatformSDKBusiness(Enums.Platform platofrm)
{
var pb = platformSDKBusinessList.FirstOrDefault(p => p.Platform == platofrm);
if (pb == null)
throw new BusinessException($"不支持平台{platofrm}");
return pb;
}
}
}

52
BBWY.Server.Business/Sync/JD/JDPopularizeReportFormAdGroupLevelSyncBusiness.cs

@ -1,17 +1,12 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -20,20 +15,19 @@ namespace BBWY.Server.Business.Sync
{
public class JDPopularizeReportFormAdGroupLevelSyncBusiness : BaseSyncBusiness, IDenpendency
{
public JDPopularizeReportFormAdGroupLevelSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
public JDPopularizeReportFormAdGroupLevelSyncBusiness(
NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService,
options,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
VenderBusiness venderBusiness) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
}
@ -93,8 +87,7 @@ namespace BBWY.Server.Business.Sync
currentCount = 0;
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByAdGroupLevel", new SyncJDPopularizeReportFormRequest()
var response = GetPlatformSDKBusiness(Enums.Platform.).GetJDSopularizeReportFormByAdGroupLevel(new SyncJDPopularizeReportFormRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
@ -104,19 +97,32 @@ namespace BBWY.Server.Business.Sync
Platform = shop.PlatformId,
PageIndex = pageIndex,
Business = 2
}, GetYunDingRequestHeader(), HttpMethod.Post);
});
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByAdGroupLevel", new SyncJDPopularizeReportFormRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// EndDate = endDate,
// StartDate = startDate,
// Platform = shop.PlatformId,
// PageIndex = pageIndex,
// Business = 2
//}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"单元维度-{shop.ShopName}").Info(httpResult.Content);
nLogManager.GetLogger($"单元维度-{shop.ShopName}").Info(JsonConvert.SerializeObject(response));
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取JD推广报表-单元维度失败 {httpResult.Content}");
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取JD推广报表-单元维度失败 {httpResult.Content}");
var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
if (!presponse.Success)
throw new Exception($"获取JD推广报表-单元维度失败 {presponse.Msg}");
//var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
//if (!presponse.Success)
// throw new Exception($"获取JD推广报表-单元维度失败 {presponse.Msg}");
SyncShopPopularizeReportFormAdGroupLevel(long.Parse(shop.ShopId), presponse.Data);
currentCount = presponse.Data?.Count() ?? 0;
SyncShopPopularizeReportFormAdGroupLevel(long.Parse(shop.ShopId), response);
currentCount = response?.Count() ?? 0;
}
catch (Exception ex)
{

56
BBWY.Server.Business/Sync/JD/JDPopularizeReportFormAdLevelSyncBusiness.cs

@ -1,16 +1,12 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
@ -22,20 +18,18 @@ namespace BBWY.Server.Business.Sync
{
private char[] separator_dx = new char[] { '-' };
public JDPopularizeReportFormAdLevelSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
public JDPopularizeReportFormAdLevelSyncBusiness(
NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService,
options,
VenderBusiness venderBusiness, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
}
@ -95,8 +89,7 @@ namespace BBWY.Server.Business.Sync
currentCount = 0;
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByAdLevel", new SyncJDPopularizeReportFormRequest()
var response = GetPlatformSDKBusiness(Enums.Platform.).GetJDSopularizeReportFormByAdLevel(new SyncJDPopularizeReportFormRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
@ -106,19 +99,32 @@ namespace BBWY.Server.Business.Sync
Platform = shop.PlatformId,
PageIndex = pageIndex,
Business = 2
}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"创意维度-{shop.ShopName}").Info(httpResult.Content);
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取JD推广报表-创意维度失败 {httpResult.Content}");
var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
if (!presponse.Success)
throw new Exception($"获取JD推广报表-创意维度失败 {presponse.Msg}");
});
SyncShopPopularizeReportFormAdLevel(shop.ShopName, long.Parse(shop.ShopId), presponse.Data);
currentCount = presponse.Data?.Count() ?? 0;
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByAdLevel", new SyncJDPopularizeReportFormRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// EndDate = endDate,
// StartDate = startDate,
// Platform = shop.PlatformId,
// PageIndex = pageIndex,
// Business = 2
//}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"创意维度-{shop.ShopName}").Info(JsonConvert.SerializeObject(response));
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取JD推广报表-创意维度失败 {httpResult.Content}");
//var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
//if (!presponse.Success)
// throw new Exception($"获取JD推广报表-创意维度失败 {presponse.Msg}");
SyncShopPopularizeReportFormAdLevel(shop.ShopName, long.Parse(shop.ShopId), response);
currentCount = response?.Count() ?? 0;
}
catch (Exception ex)
{

53
BBWY.Server.Business/Sync/JD/JDPopularizeReportFormCampaignLevelSyncBusiness.cs

@ -1,16 +1,12 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -19,21 +15,18 @@ namespace BBWY.Server.Business.Sync
{
public class JDPopularizeReportFormCampaignLevelSyncBusiness : BaseSyncBusiness, IDenpendency
{
public JDPopularizeReportFormCampaignLevelSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
public JDPopularizeReportFormCampaignLevelSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
VenderBusiness venderBusiness) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
}
@ -102,8 +95,7 @@ namespace BBWY.Server.Business.Sync
currentCount = 0;
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByCampaignLevel", new SyncJDPopularizeReportFormRequest()
var response = GetPlatformSDKBusiness(Enums.Platform.).GetJDSopularizeReportFormByCampaignLevel(new SyncJDPopularizeReportFormRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
@ -113,19 +105,32 @@ namespace BBWY.Server.Business.Sync
Platform = shop.PlatformId,
PageIndex = pageIndex,
Business = businessType
}, GetYunDingRequestHeader(), HttpMethod.Post);
});
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByCampaignLevel", new SyncJDPopularizeReportFormRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// EndDate = endDate,
// StartDate = startDate,
// Platform = shop.PlatformId,
// PageIndex = pageIndex,
// Business = businessType
//}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"计划维度-{shop.ShopName}-{(businessType == 2 ? "" : "")}").Info(httpResult.Content);
nLogManager.GetLogger($"计划维度-{shop.ShopName}-{(businessType == 2 ? "" : "")}").Info(JsonConvert.SerializeObject(response));
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取JD推广报表-计划维度失败 {httpResult.Content}");
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取JD推广报表-计划维度失败 {httpResult.Content}");
var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
if (!presponse.Success)
throw new Exception($"获取JD推广报表-计划维度失败 {presponse.Msg}");
//var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
//if (!presponse.Success)
// throw new Exception($"获取JD推广报表-计划维度失败 {presponse.Msg}");
SyncShopPopularizeReportFormCampaignLevel(long.Parse(shop.ShopId), presponse.Data, businessType);
currentCount = presponse.Data?.Count() ?? 0;
SyncShopPopularizeReportFormCampaignLevel(long.Parse(shop.ShopId), response, businessType);
currentCount = response?.Count() ?? 0;
}
catch (Exception ex)
{

55
BBWY.Server.Business/Sync/JD/JDPopularizeReportFormOrderLevelSyncBusiness.cs

@ -1,16 +1,12 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
@ -20,21 +16,16 @@ namespace BBWY.Server.Business.Sync
{
public class JDPopularizeReportFormOrderLevelSyncBusiness : BaseSyncBusiness, IDenpendency
{
public JDPopularizeReportFormOrderLevelSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
public JDPopularizeReportFormOrderLevelSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
VenderBusiness venderBusiness, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
taskSchedulerManager, platformSDKBusinessList,
venderBusiness)
{
}
@ -105,8 +96,7 @@ namespace BBWY.Server.Business.Sync
currentCount = 0;
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByOrderLevel", new SyncJDPopularizeReportFormRequest()
var response = GetPlatformSDKBusiness(Enums.Platform.).GetJDSopularizeReportFormByOrderLevel(new SyncJDPopularizeReportFormRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
@ -116,23 +106,36 @@ namespace BBWY.Server.Business.Sync
Platform = shop.PlatformId,
PageIndex = pageIndex,
Business = businessType
}, GetYunDingRequestHeader(), HttpMethod.Post);
});
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormByOrderLevel", new SyncJDPopularizeReportFormRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// EndDate = endDate,
// StartDate = startDate,
// Platform = shop.PlatformId,
// PageIndex = pageIndex,
// Business = businessType
//}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"订单维度-{shop.ShopName}-{(businessType == 2 ? "" : "")}").Info(httpResult.Content);
nLogManager.GetLogger($"订单维度-{shop.ShopName}-{(businessType == 2 ? "" : "")}").Info(JsonConvert.SerializeObject(response));
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取JD推广报表-订单维度失败 {httpResult.Content}");
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取JD推广报表-订单维度失败 {httpResult.Content}");
var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
if (!presponse.Success)
throw new Exception($"获取JD推广报表-订单维度失败 {presponse.Msg}");
//var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
//if (!presponse.Success)
// throw new Exception($"获取JD推广报表-订单维度失败 {presponse.Msg}");
if (businessType == 2)
SyncShopPopularizeReportFormOrderLevelByKuaiChe(long.Parse(shop.ShopId), presponse.Data);
SyncShopPopularizeReportFormOrderLevelByKuaiChe(long.Parse(shop.ShopId), response);
else if (businessType == 134217728)
SyncShopPopularizeReportFormOrderLevelByJST(long.Parse(shop.ShopId), presponse.Data);
SyncShopPopularizeReportFormOrderLevelByJST(long.Parse(shop.ShopId), response);
currentCount = presponse.Data?.Count() ?? 0;
currentCount = response?.Count() ?? 0;
}
catch (Exception ex)
{

73
BBWY.Server.Business/Sync/JD/JDPopularizeReportFormSkuLevelSyncBusiness.cs

@ -1,16 +1,12 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -19,21 +15,17 @@ namespace BBWY.Server.Business.Sync
{
public class JDPopularizeReportFormSkuLevelSyncBusiness : BaseSyncBusiness, IDenpendency
{
public JDPopularizeReportFormSkuLevelSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
public JDPopularizeReportFormSkuLevelSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
nLogManager,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
VenderBusiness venderBusiness) : base(nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
}
@ -99,29 +91,42 @@ namespace BBWY.Server.Business.Sync
currentCount = 0;
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormBySkuLevel", new SyncJDPopularizeReportFormRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
EndDate = endDate,
StartDate = startDate,
Platform = shop.PlatformId,
PageIndex = pageIndex,
Business = 134217728
}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"SKU维度-{shop.ShopName}").Info(httpResult.Content);
var response = GetPlatformSDKBusiness(Enums.Platform.).GetJDSopularizeReportFormBySkuLevel(
new SyncJDPopularizeReportFormRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
EndDate = endDate,
StartDate = startDate,
Platform = shop.PlatformId,
PageIndex = pageIndex,
Business = 134217728
});
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取JD推广报表-sku维度失败 {httpResult.Content}");
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDSopularizeReportFormBySkuLevel", new SyncJDPopularizeReportFormRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// EndDate = endDate,
// StartDate = startDate,
// Platform = shop.PlatformId,
// PageIndex = pageIndex,
// Business = 134217728
//}, GetYunDingRequestHeader(), HttpMethod.Post);
nLogManager.GetLogger($"SKU维度-{shop.ShopName}").Info(JsonConvert.SerializeObject(response));
var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
if (!presponse.Success)
throw new Exception($"获取JD推广报表-sku维度失败 {presponse.Msg}");
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取JD推广报表-sku维度失败 {httpResult.Content}");
SyncShopPopularizeReportFormSkuLevel(long.Parse(shop.ShopId), presponse.Data);
currentCount = presponse.Data?.Count() ?? 0;
//var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
//if (!presponse.Success)
// throw new Exception($"获取JD推广报表-sku维度失败 {presponse.Msg}");
SyncShopPopularizeReportFormSkuLevel(long.Parse(shop.ShopId), response);
currentCount = response?.Count() ?? 0;
}
catch (Exception ex)
{

68
BBWY.Server.Business/Sync/JD/JDPopularizeSyncBusiness.cs

@ -1,41 +1,34 @@
using BBWY.Common.Http;
using BBWY.Common.Extensions;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
using BBWY.Common.Extensions;
using BBWY.Server.Model.Db;
using System.Threading;
namespace BBWY.Server.Business.Sync
{
public class JDPopularizeSyncBusiness : BaseSyncBusiness, IDenpendency
{
public JDPopularizeSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
public JDPopularizeSyncBusiness(
NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
}
@ -75,26 +68,37 @@ namespace BBWY.Server.Business.Sync
currentCount = 0;
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDShopSopularizeRecordList", new SyncShopPopularizeRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
EndDate = endDate,
StartDate = startDate,
Platform = shop.PlatformId,
PageIndex = pageIndex
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取JD推广费用失败 {httpResult.Content}");
var response = GetPlatformSDKBusiness(shop.PlatformId).GetJDShopSopularizeRecordList(
new SyncShopPopularizeRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
EndDate = endDate,
StartDate = startDate,
Platform = shop.PlatformId,
PageIndex = pageIndex
});
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var httpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetJDShopSopularizeRecordList", new SyncShopPopularizeRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// EndDate = endDate,
// StartDate = startDate,
// Platform = shop.PlatformId,
// PageIndex = pageIndex
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (httpResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取JD推广费用失败 {httpResult.Content}");
var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
if (!presponse.Success)
throw new Exception($"获取JD推广费用失败 {presponse.Msg}");
//var presponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(httpResult.Content);
//if (!presponse.Success)
// throw new Exception($"获取JD推广费用失败 {presponse.Msg}");
SyncShopPopularizeRecord(long.Parse(shop.ShopId), presponse.Data);
currentCount = presponse.Data?.Count() ?? 0;
SyncShopPopularizeRecord(long.Parse(shop.ShopId), response);
currentCount = response?.Count() ?? 0;
}
catch (Exception ex)
{

127
BBWY.Server.Business/Sync/JD/JDServiceOrderSyncBusiness.cs

@ -1,19 +1,18 @@
using BBWY.Common.Http;
using BBWY.Common.Extensions;
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 FreeSql;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Yitter.IdGenerator;
using System.Linq;
using BBWY.Server.Model.Db;
using FreeSql;
using BBWY.Common.Extensions;
namespace BBWY.Server.Business.Sync
{
@ -25,9 +24,19 @@ namespace BBWY.Server.Business.Sync
private IList<int> kuaiDi100PushStateList_qianshou;
private IList<int> kuaiDi100PushStateList_paijian;
private Dictionary<int, Enums.ServiceResult> processResultDic;
public JDServiceOrderSyncBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, NLogManager nLogManager, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness) : base(restApiService, options, nLogManager, fsql, idGenerator, taskSchedulerManager, venderBusiness, yunDingBusiness)
private RestApiService restApiService;
public JDServiceOrderSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
VenderBusiness venderBusiness,
RestApiService restApiService) : base(nLogManager,
fsql, idGenerator,
taskSchedulerManager,
platformSDKBusinessList,
venderBusiness)
{
/*
yuantong
@ -54,6 +63,7 @@ jingdongkuaiyun 京东快运
huitongkuaidi
*/
kuaiDi100PushStateList_zaitu = new List<int>() { 0, 1001, 1002, 1003 };
kuaiDi100PushStateList_lanshou = new List<int>() { 1, 101, 102, 103 };
kuaiDi100PushStateList_qianshou = new List<int>() { 3, 301, 302, 303, 304 };
@ -92,6 +102,7 @@ huitongkuaidi 百世快递
{ 90,Enums.ServiceResult.线},
{ 110,Enums.ServiceResult.}
};
this.restApiService = restApiService;
}
public void SyncServiceOrder()
@ -117,7 +128,7 @@ huitongkuaidi 百世快递
taskSchedulerManager.SyncServiceOrderTaskScheduler);
}
private void SyncServiceOrder(ShopResponse shop, long shopId, IList<JToken> jtokenList, string relayAPIHost, string appKey, string appSecret, string token)
private void SyncServiceOrder(ShopResponse shop, long shopId, IList<JToken> jtokenList, string appKey, string appSecret, string token)
{
var serviceIdList = jtokenList.Select(j => j.Value<string>("serviceId")).ToList();
var dbServiceOrderList = fsql.Select<ServiceOrder>().Where(s => s.ShopId == shop.ShopId && serviceIdList.Contains(s.ServiceId)).ToList();
@ -168,7 +179,8 @@ huitongkuaidi 百世快递
{
try
{
var serviceOrderDetailResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderDetail", new QueryServiceOrderDetailRequest()
var p = GetPlatformSDKBusiness(Enums.Platform.);
var serviceOrderDetailResponse = p.GetServiceOrderDetail(new QueryServiceOrderDetailRequest()
{
AppKey = appKey,
AppSecret = appSecret,
@ -177,21 +189,32 @@ huitongkuaidi 百世快递
ServiceId = serviceId,
Platform = Enums.Platform.,
VenderId = shop.VenderId
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (serviceOrderDetailResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取服务单详情失败 {serviceOrderDetailResult.Content}");
var serviceOrderDetailResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(serviceOrderDetailResult.Content);
if (!serviceOrderDetailResponse.Success)
throw new Exception($"获取服务单详情失败 {serviceOrderDetailResponse.Msg}");
});
var processResult = serviceOrderDetailResponse.Data.Value<int>("processResult");
//var serviceOrderDetailResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderDetail", new QueryServiceOrderDetailRequest()
//{
// AppKey = appKey,
// AppSecret = appSecret,
// AppToken = token,
// OrderId = serviceOrderId,
// ServiceId = serviceId,
// Platform = Enums.Platform.京东,
// VenderId = shop.VenderId
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (serviceOrderDetailResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取服务单详情失败 {serviceOrderDetailResult.Content}");
//var serviceOrderDetailResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(serviceOrderDetailResult.Content);
//if (!serviceOrderDetailResponse.Success)
// throw new Exception($"获取服务单详情失败 {serviceOrderDetailResponse.Msg}");
var processResult = serviceOrderDetailResponse.Value<int>("processResult");
if (processResultDic.ContainsKey(processResult))
serviceResult = processResultDic[processResult];
//检查退货城市是否为泉州鲤城区
isNeedSubscribeKuaiDi100 = (serviceOrderDetailResponse.Data["afsContactInfo"]?.Value<int>("cityCode") ?? 0) == 1332 &&
(serviceOrderDetailResponse.Data["afsContactInfo"]?.Value<int>("countyCode") ?? 0) == 42930;
isNeedSubscribeKuaiDi100 = (serviceOrderDetailResponse["afsContactInfo"]?.Value<int>("cityCode") ?? 0) == 1332 &&
(serviceOrderDetailResponse["afsContactInfo"]?.Value<int>("countyCode") ?? 0) == 42930;
isTuiHuoCang = isNeedSubscribeKuaiDi100;
}
catch { }
@ -269,7 +292,7 @@ huitongkuaidi 百世快递
try
{
var shopId = long.Parse(shop.ShopId);
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var serviceStatusList = new List<int>() { 10005, 10011, 10010 };
var request = new QueryServiceOrderRequest()
@ -288,24 +311,29 @@ huitongkuaidi 百世快递
};
List<JToken> jtokenList = new List<JToken>();
var p = GetPlatformSDKBusiness(Enums.Platform.);
foreach (var serviceStatus in serviceStatusList)
{
if (string.IsNullOrEmpty(serviceId))
request.ServiceStatus = serviceStatus;
var serviceOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderList", request, GetYunDingRequestHeader(), HttpMethod.Post);
if (serviceOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取服务单失败 {serviceOrderListApiResult.Content}");
var serviceOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(serviceOrderListApiResult.Content);
if (!serviceOrderListResponse.Success)
throw new Exception($"获取服务单失败 {serviceOrderListResponse.Msg}");
if (serviceOrderListResponse.Data != null && serviceOrderListResponse.Data.Count() > 0)
jtokenList.AddRange(serviceOrderListResponse.Data);
var serviceOrderListResponse = p.GetServiceOrderList(request);
//var serviceOrderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderList", request, GetYunDingRequestHeader(), HttpMethod.Post);
//if (serviceOrderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取服务单失败 {serviceOrderListApiResult.Content}");
//var serviceOrderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(serviceOrderListApiResult.Content);
//if (!serviceOrderListResponse.Success)
// throw new Exception($"获取服务单失败 {serviceOrderListResponse.Msg}");
if (serviceOrderListResponse != null && serviceOrderListResponse.Count() > 0)
jtokenList.AddRange(serviceOrderListResponse);
if (!string.IsNullOrEmpty(serviceId))
break;
}
if (jtokenList.Count() > 0)
SyncServiceOrder(shop, shopId, jtokenList, relayAPIHost, request.AppKey, request.AppSecret, request.AppToken);
SyncServiceOrder(shop, shopId, jtokenList, request.AppKey, request.AppSecret, request.AppToken);
}
catch (Exception ex)
{
@ -340,7 +368,7 @@ huitongkuaidi 百世快递
var loggerName = $"订阅快递100-{shop.ShopName}";
try
{
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var serviceOrderList = fsql.Select<ServiceOrder>().Where(s => s.ShopId == shop.ShopId &&
s.IsNeedSubscribeKuaiDi100 == true &&
s.IsSubscribeKuaiDi100 == false)
@ -349,7 +377,7 @@ huitongkuaidi 百世快递
.ToList();
List<IUpdate<ServiceOrder>> updateSerivceOrderList = new List<IUpdate<ServiceOrder>>();
List<ExpressOrder> insertExpressOrderList = new List<ExpressOrder>();
var p = GetPlatformSDKBusiness(shop.PlatformId);
foreach (var serviceOrder in serviceOrderList)
{
bool isUpdateDelivery = false, isUpdateSubscribe = false;
@ -359,7 +387,7 @@ huitongkuaidi 百世快递
try
{
#region 查询服务单运单详情
var serviceOrderDeliveryResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderDeliveryDetail", new QueryServiceOrderDetailRequest()
var serviceOrderDeliveryResponse = p.GetServiceOrderDeliveryDetail(new QueryServiceOrderDetailRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
@ -368,18 +396,29 @@ huitongkuaidi 百世快递
ServiceId = serviceOrder.ServiceId,
Platform = Enums.Platform.,
VenderId = shop.VenderId
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (serviceOrderDeliveryResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取服务单运单详情失败 {serviceOrderDeliveryResult.Content}");
var serviceOrderDeliveryResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(serviceOrderDeliveryResult.Content);
if (!serviceOrderDeliveryResponse.Success)
throw new Exception($"获取服务单运单详情失败 {serviceOrderDeliveryResponse.Msg}");
});
if (serviceOrderDeliveryResponse.Data != null)
//var serviceOrderDeliveryResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceOrderDeliveryDetail", new QueryServiceOrderDetailRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// OrderId = serviceOrder.OrderId,
// ServiceId = serviceOrder.ServiceId,
// Platform = Enums.Platform.京东,
// VenderId = shop.VenderId
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (serviceOrderDeliveryResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取服务单运单详情失败 {serviceOrderDeliveryResult.Content}");
//var serviceOrderDeliveryResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(serviceOrderDeliveryResult.Content);
//if (!serviceOrderDeliveryResponse.Success)
// throw new Exception($"获取服务单运单详情失败 {serviceOrderDeliveryResponse.Msg}");
if (serviceOrderDeliveryResponse != null)
{
serviceOrder.WayBillNo = serviceOrderDeliveryResponse.Data.Value<string>("expressCode");
serviceOrder.ExpressName = serviceOrderDeliveryResponse.Data.Value<string>("expressCompany");
serviceOrder.WayBillNo = serviceOrderDeliveryResponse.Value<string>("expressCode");
serviceOrder.ExpressName = serviceOrderDeliveryResponse.Value<string>("expressCompany");
if (!string.IsNullOrEmpty(serviceOrder.WayBillNo) && serviceOrder.WayBillNo.StartsWith("JD") && string.IsNullOrEmpty(serviceOrder.ExpressName))
{

3
BBWY.Server.Business/Sync/OrderSkuSaleDetailSyncBusiness.cs

@ -3,14 +3,13 @@ using BBWY.Server.Model.Db;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class OrderSkuSaleDetailSyncBusiness : BaseBusiness, IDenpendency
{
public OrderSkuSaleDetailSyncBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
public OrderSkuSaleDetailSyncBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
}

121
BBWY.Server.Business/Sync/OrderSyncBusiness.cs

@ -1,5 +1,4 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Business.Extensions;
using BBWY.Server.Business.PlatformSDK.DataExtension;
using BBWY.Server.Model;
@ -7,16 +6,11 @@ using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using FreeSql;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -25,32 +19,28 @@ namespace BBWY.Server.Business
{
public class OrderSyncBusiness : BaseSyncBusiness, IDenpendency
{
private IDictionary<Enums.Platform, Action<JArray, long, string, string, string, string, decimal>> syncOrderMethodDic;
private IDictionary<Enums.Platform, Action<IList<JToken>, long, string, string, string, decimal>> syncOrderMethodDic;
private IMemoryCache memoryCache;
private IList<string> validOrderState;
public OrderSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
public OrderSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
IMemoryCache memoryCache,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList,
VenderBusiness venderBusiness) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList, venderBusiness)
{
this.memoryCache = memoryCache;
syncOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, long, string, string, string, string, decimal>>()
syncOrderMethodDic = new Dictionary<Enums.Platform, Action<IList<JToken>, long, string, string, string, decimal>>()
{
{ Enums.Platform., SyncJDOrder }
};
@ -58,6 +48,7 @@ namespace BBWY.Server.Business
{
"WAIT_SELLER_STOCK_OUT","WAIT_GOODS_RECEIVE_CONFIRM","FINISHED_L","LOCKED","TRADE_CANCELED","POP_ORDER_PAUSE","PAUSE"
};
this.platformSDKBusinessList = platformSDKBusinessList;
}
/// <summary>
/// 手动同步订单
@ -106,8 +97,9 @@ namespace BBWY.Server.Business
if (!syncOrderMethodDic.ContainsKey(shop.PlatformId))
throw new Exception("不支持的平台");
var shopId = long.Parse(shop.ShopId);
var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
var orderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetOrderList", new SearchPlatformOrderRequest()
var p = GetPlatformSDKBusiness(shop.PlatformId);
var orderList = p.GetOrderList(new SearchPlatformOrderRequest()
{
StartDate = startTime ?? DateTime.Now.AddHours(shop.ShopName.Contains("腾奇") ? -0.5 : -3),
EndDate = endTime ?? DateTime.Now,
@ -121,28 +113,45 @@ namespace BBWY.Server.Business
//SaveResponseLog = true,
OrderId = orderId,
SortTimeType = sortTimeType
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 120);
if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception($"获取订单失败 {orderListApiResult.Content}");
var orderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(orderListApiResult.Content);
if (!orderListResponse.Success)
throw new Exception($"获取订单失败 {orderListApiResult.Content}");
if (orderListResponse.Data == null || orderListResponse.Data.Count == 0)
return;
});
//var relayAPIHost = GetPlatformRelayAPIHost(shop.PlatformId);
//var orderListApiResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetOrderList", new SearchPlatformOrderRequest()
//{
// StartDate = startTime ?? DateTime.Now.AddHours(shop.ShopName.Contains("腾奇") ? -0.5 : -3),
// EndDate = endTime ?? DateTime.Now,
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// PageIndex = 1,
// PageSize = 100,
// Platform = shop.PlatformId,
// JDColType = string.IsNullOrEmpty(shop.ShopType) ? "0" : shop.ShopType,
// //SaveResponseLog = true,
// OrderId = orderId,
// SortTimeType = sortTimeType
//}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 120);
//if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception($"获取订单失败 {orderListApiResult.Content}");
//var orderListResponse = JsonConvert.DeserializeObject<ApiResponse<JArray>>(orderListApiResult.Content);
//if (!orderListResponse.Success)
// throw new Exception($"获取订单失败 {orderListApiResult.Content}");
//if (orderListResponse.Data == null || orderListResponse.Data.Count == 0)
// return;
if (shopId == 10388155)
{
try
{
nLogManager.GetLogger($"订单同步-{shop.ShopName}").Info(orderListApiResult.Content);
nLogManager.GetLogger($"订单同步-{shop.ShopName}").Info(JsonConvert.SerializeObject(orderList));
}
catch { }
}
syncOrderMethodDic[shop.PlatformId](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken, shop.PlatformCommissionRatio ?? 0.05M);
syncOrderMethodDic[shop.PlatformId](orderList, shopId, shop.AppKey, shop.AppSecret, shop.AppToken, shop.PlatformCommissionRatio ?? 0.05M);
}
catch (Exception ex)
{
@ -207,7 +216,7 @@ namespace BBWY.Server.Business
}, System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler);
}
private void SyncJDOrder(JArray orderTokenJArray, long shopId, string relayAPIHost, string appKey, string appSecret, string appToken, decimal platformCommissionRatio)
private void SyncJDOrder(IList<JToken> orderTokenJArray, long shopId, string appKey, string appSecret, string appToken, decimal platformCommissionRatio)
{
var validOrders = orderTokenJArray.Where(o => validOrderState.Contains(o.Value<string>("orderState")));
if (validOrders.Count() == 0)
@ -477,7 +486,7 @@ namespace BBWY.Server.Business
SDCommissionAmount = sDCalculationCostRequest.SDCommissionAmount,
SDOrderAmount = sDCalculationCostRequest.SDOrderAmount
};
orderCost.CalculationSDOrderProfitAndCost(dbOrder, null);
orderCost.CalculationSDOrderProfitAndCost(dbOrder);
insertOrderCostList.Add(orderCost);
}
else if (!fsql.Select<OrderCost>(dbOrder.Id).Any()) //再查询一次数据库,以防同步开始执行后被人为操作扣减库存,造成重复扣减库存
@ -568,9 +577,9 @@ namespace BBWY.Server.Business
CreateTime = DateTime.Now
};
if (dbOrder.OrderTotalPrice != 0)
orderCost.CalculationOrderProfitAndCost(dbOrder, null);
orderCost.CalculationOrderProfitAndCost(dbOrder);
else
orderCost.CalculationOrderProfitAndCost(orderSellerPrice, freightPrice, null);
orderCost.CalculationOrderProfitAndCost(orderSellerPrice, freightPrice);
insertOrderCostList.Add(orderCost);
#endregion
@ -645,20 +654,34 @@ namespace BBWY.Server.Business
for (var i = 0; i < orderSkuRequestCount; i++)
{
var orderSkuIdString = string.Join(",", orderSkuIds.Skip(i * 50).Take(50));
var skuHttpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetSimpleProductSkuList", new SearchProductSkuRequest()
{
AppKey = appKey,
AppSecret = appSecret,
AppToken = appToken,
Platform = Enums.Platform.,
Sku = orderSkuIdString
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (skuHttpResult.StatusCode != System.Net.HttpStatusCode.OK)
continue;
var skuResponse = JsonConvert.DeserializeObject<ApiResponse<IList<SimpleProductSkuResponse>>>(skuHttpResult.Content);
if (!skuResponse.Success)
continue;
foreach (var sku in skuResponse.Data)
var p = GetPlatformSDKBusiness(Enums.Platform.);
var skuList = p.GetSimpleProductSkuList(
new SearchProductSkuRequest()
{
AppKey = appKey,
AppSecret = appSecret,
AppToken = appToken,
Platform = Enums.Platform.,
Sku = orderSkuIdString
});
//var skuHttpResult = restApiService.SendRequest(relayAPIHost, "Api/PlatformSDK/GetSimpleProductSkuList", new SearchProductSkuRequest()
//{
// AppKey = appKey,
// AppSecret = appSecret,
// AppToken = appToken,
// Platform = Enums.Platform.京东,
// Sku = orderSkuIdString
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (skuHttpResult.StatusCode != System.Net.HttpStatusCode.OK)
// continue;
//var skuResponse = JsonConvert.DeserializeObject<ApiResponse<IList<SimpleProductSkuResponse>>>(skuHttpResult.Content);
//if (!skuResponse.Success)
// continue;
foreach (var sku in skuList)
{
var insertSkus = insertOrderSkuList.Where(orderSku => orderSku.SkuId == sku.Id);
foreach (var insertSku in insertSkus) { insertSku.Logo = sku.Logo; }

27
BBWY.Server.Business/Sync/ProductSyncBusiness.cs

@ -1,18 +1,15 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using NLog;
using System.Threading.Tasks;
using Yitter.IdGenerator;
using System.Linq;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using FreeSql;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using FreeSql;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace BBWY.Server.Business.Sync
{
@ -20,22 +17,20 @@ namespace BBWY.Server.Business.Sync
{
private ProductBusiness productBusiness;
public ProductSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
public ProductSyncBusiness(
NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
ProductBusiness productBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
this.productBusiness = productBusiness;
}

40
BBWY.Server.Business/Sync/StoreHouseSyncBusiness.cs

@ -1,15 +1,11 @@
using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
@ -20,21 +16,18 @@ namespace BBWY.Server.Business.Sync
{
private IDictionary<Enums.Platform, Action<JArray, ShopResponse, IList<Storehouse>>> storeHouseSyncMethodDic;
public StoreHouseSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options,
NLogManager nLogManager,
public StoreHouseSyncBusiness(NLogManager nLogManager,
IFreeSql fsql,
IIdGenerator idGenerator,
TaskSchedulerManager taskSchedulerManager,
VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness) : base(restApiService,
options,
IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(
nLogManager,
fsql,
idGenerator,
taskSchedulerManager,
venderBusiness,
yunDingBusiness)
platformSDKBusinessList,
venderBusiness)
{
storeHouseSyncMethodDic = new Dictionary<Enums.Platform, Action<JArray, ShopResponse, IList<Storehouse>>>()
{
@ -51,26 +44,35 @@ namespace BBWY.Server.Business.Sync
{
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.);
var storeHouseList = new List<Storehouse>();
var p = GetPlatformSDKBusiness(Enums.Platform.);
foreach (var shop in shopList)
{
Thread.Sleep(1000);
try
{
var restApiResult = restApiService.SendRequest(GetPlatformRelayAPIHost(shop.PlatformId), "api/PlatformSDK/GetStoreHouseList", new PlatformRequest()
var response = p.GetStoreHouseList(new PlatformRequest()
{
AppKey = shop.AppKey,
AppSecret = shop.AppSecret,
AppToken = shop.AppToken,
Platform = shop.PlatformId,
SaveResponseLog = false
}, GetYunDingRequestHeader(), HttpMethod.Post);
if (restApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new Exception(restApiResult.Content);
var response = JsonConvert.DeserializeObject<ApiResponse<JArray>>(restApiResult.Content);
if (response.Data == null || response.Data.Count() == 0)
});
//var restApiResult = restApiService.SendRequest(GetPlatformRelayAPIHost(shop.PlatformId), "api/PlatformSDK/GetStoreHouseList", new PlatformRequest()
//{
// AppKey = shop.AppKey,
// AppSecret = shop.AppSecret,
// AppToken = shop.AppToken,
// Platform = shop.PlatformId,
// SaveResponseLog = false
//}, GetYunDingRequestHeader(), HttpMethod.Post);
//if (restApiResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new Exception(restApiResult.Content);
//var response = JsonConvert.DeserializeObject<ApiResponse<JArray>>(restApiResult.Content);
if (response == null || response.Count() == 0)
continue;
//ResolveJDStoreHouse(response.Data, shop, storeHouseList);
storeHouseSyncMethodDic[shop.PlatformId](response.Data, shop, storeHouseList);
storeHouseSyncMethodDic[shop.PlatformId](response, shop, storeHouseList);
}
catch (Exception ex)
{

70
BBWY.Server.Business/Vender/VenderBusiness.cs

@ -1,55 +1,51 @@

using BBWY.Common.Http;
using BBWY.Common.Models;
using BBWY.Common.Models;
using BBWY.Server.Model;
using BBWY.Server.Model.Db;
using BBWY.Server.Model.Db.Mds;
using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Yitter.IdGenerator;
namespace BBWY.Server.Business
{
public class VenderBusiness : BasePlatformRelayBusiness, IDenpendency
public class VenderBusiness : BaseBusiness, IDenpendency
{
private FreeSqlMultiDBManager freeSqlMultiDBManager;
private IIdGenerator idGenerator;
public VenderBusiness(FreeSqlMultiDBManager freeSqlMultiDBManager,
RestApiService restApiService,
IOptions<GlobalConfig> options,
IIdGenerator idGenerator, YunDingBusiness yunDingBusiness) : base(restApiService, options, yunDingBusiness)
public VenderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager freeSqlMultiDBManager, IEnumerable<PlatformSDKBusiness> platformSDKBusinessList) : base(fsql, nLogManager, idGenerator, platformSDKBusinessList)
{
this.freeSqlMultiDBManager = freeSqlMultiDBManager;
this.idGenerator = idGenerator;
this.platformSDKBusinessList = platformSDKBusinessList;
}
public VenderResponse GetVenderInfo(PlatformRequest platformRequest)
{
var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetVenderInfo", platformRequest, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<VenderResponse>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
//var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetVenderInfo", platformRequest, GetYunDingRequestHeader(), HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<VenderResponse>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
//return response.Data;
return GetPlatformSDKBusiness(platformRequest.Platform).GetVenderInfo(platformRequest);
}
public IList<LogisticsResponse> GetLogisticsList(PlatformRequest platformRequest)
{
var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetLogisticsList", platformRequest, GetYunDingRequestHeader(), System.Net.Http.HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<IList<LogisticsResponse>>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
//var relayAPIHost = GetPlatformRelayAPIHost(platformRequest.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetLogisticsList", platformRequest, GetYunDingRequestHeader(), System.Net.Http.HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<IList<LogisticsResponse>>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
//return response.Data;
return GetPlatformSDKBusiness(platformRequest.Platform).GetLogisticsList(platformRequest);
}
public string AcceptJDShopToken(JDShopToken jDShopToken)
@ -314,14 +310,16 @@ namespace BBWY.Server.Business
public IList<WaiterResponse> GetServiceGroupList(PlatformRequest request)
{
var relayAPIHost = GetPlatformRelayAPIHost(request.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceGroupList", request, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<IList<WaiterResponse>>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
//var relayAPIHost = GetPlatformRelayAPIHost(request.Platform);
//var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceGroupList", request, GetYunDingRequestHeader(), HttpMethod.Post);
//if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
// throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
//var response = JsonConvert.DeserializeObject<ApiResponse<IList<WaiterResponse>>>(sendResult.Content);
//if (!response.Success)
// throw new BusinessException(response.Msg) { Code = response.Code };
//return response.Data;
return GetPlatformSDKBusiness(request.Platform).GetServiceGroupList(request);
}
}
}

10
BBWY.Server.Model/BBWY.Server.Model.csproj

@ -5,6 +5,16 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Dto\Response\AfterSaleOrder\**" />
<EmbeddedResource Remove="Dto\Response\AfterSaleOrder\**" />
<None Remove="Dto\Response\AfterSaleOrder\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Db\Order\AfterSaleOrder.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="FreeSql" Version="2.6.100" />

8
BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs

@ -195,10 +195,10 @@ namespace BBWY.Server.Model.Dto
/// </summary>
public IList<OrderDropShippingResponse> HistoryOrderDropShippingList { get; set; }
/// <summary>
/// 售后信息
/// </summary>
public IList<AfterSaleOrderResponse> AfterSaleOrderList { get; set; }
///// <summary>
///// 售后信息
///// </summary>
//public IList<AfterSaleOrderResponse> AfterSaleOrderList { get; set; }
}
public class OrderListResponse

Loading…
Cancel
Save