Browse Source

1

AddValidOverTime
sanji 2 years ago
parent
commit
5635987d19
  1. 6
      BBWY.Server.API/Controllers/TestController.cs
  2. 2
      BBWY.Server.API/Properties/launchSettings.json
  3. 49
      BBWY.Server.Business/TestBusiness.cs

6
BBWY.Server.API/Controllers/TestController.cs

@ -30,5 +30,11 @@ namespace BBWY.Server.API.Controllers
{ {
testBusiness.RepairSkuDetailAndSkuGriooProfit(request); testBusiness.RepairSkuDetailAndSkuGriooProfit(request);
} }
[HttpPost]
public void DeleteJDTask()
{
testBusiness.DeleteJDTask();
}
} }
} }

2
BBWY.Server.API/Properties/launchSettings.json

@ -21,7 +21,7 @@
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "weatherforecast", "launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000", "applicationUrl": "http://localhost:5002",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

49
BBWY.Server.Business/TestBusiness.cs

@ -12,6 +12,9 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using BBWY.Server.Business.Extensions; using BBWY.Server.Business.Extensions;
using Newtonsoft.Json;
using System.Net.Http;
using System.Threading.Tasks;
namespace BBWY.Server.Business namespace BBWY.Server.Business
{ {
@ -21,18 +24,21 @@ namespace BBWY.Server.Business
private VenderBusiness venderBusiness; private VenderBusiness venderBusiness;
private IFreeSql fsql; private IFreeSql fsql;
private OrderSyncBusiness orderSyncBusiness; private OrderSyncBusiness orderSyncBusiness;
private TaskSchedulerManager taskSchedulerManager;
public TestBusiness(RestApiService restApiService, public TestBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options, IOptions<GlobalConfig> options,
FreeSqlMultiDBManager freeSqlMultiDBManager, FreeSqlMultiDBManager freeSqlMultiDBManager,
VenderBusiness venderBusiness, VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness, YunDingBusiness yunDingBusiness,
IFreeSql fsql, IFreeSql fsql,
OrderSyncBusiness orderSyncBusiness) : base(restApiService, options, yunDingBusiness) OrderSyncBusiness orderSyncBusiness,
TaskSchedulerManager taskSchedulerManager) : base(restApiService, options, yunDingBusiness)
{ {
this.freeSqlMultiDBManager = freeSqlMultiDBManager; this.freeSqlMultiDBManager = freeSqlMultiDBManager;
this.venderBusiness = venderBusiness; this.venderBusiness = venderBusiness;
this.fsql = fsql; this.fsql = fsql;
this.orderSyncBusiness = orderSyncBusiness; this.orderSyncBusiness = orderSyncBusiness;
this.taskSchedulerManager = taskSchedulerManager;
} }
public void SyncVenderId() public void SyncVenderId()
@ -164,15 +170,18 @@ namespace BBWY.Server.Business
"瑞源玩具专营店" "瑞源玩具专营店"
}; };
var shopList = venderBusiness.GetShopList(request.ShopId, Enums.Platform.); var shopList = venderBusiness.GetShopList(request.ShopId, Enums.Platform.);
var shopIndex = 0; //var shopIndex = 0;
foreach (var shop in shopList) foreach (var shop in shopList)
{ {
shopIndex++; Task.Factory.StartNew(() =>
Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()}"); {
Console.WriteLine(shop.ShopName);
//shopIndex++;
//Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()}");
var shopId = long.Parse(shop.ShopId); var shopId = long.Parse(shop.ShopId);
if (banedList.Contains(shop.ShopName)) if (banedList.Contains(shop.ShopName))
continue; return;
var orderIdList = fsql.Select<Order>() var orderIdList = fsql.Select<Order>()
.Where(o => o.ShopId == shopId && .Where(o => o.ShopId == shopId &&
o.OrderState != Enums.OrderState. && o.OrderState != Enums.OrderState. &&
@ -195,7 +204,7 @@ namespace BBWY.Server.Business
{ {
var orderId = orderIdList[i]; var orderId = orderIdList[i];
orderSyncBusiness.SyncOrder(shop, orderId); orderSyncBusiness.SyncOrder(shop, orderId);
Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()} {shop.ShopName},orderProgress {i + 1}/{orderIdList.Count()}"); Console.WriteLine($"SyncOrder {shop.ShopName},orderProgress {i + 1}/{orderIdList.Count()}");
} }
// foreach (var orderId in orderIdList) // foreach (var orderId in orderIdList)
// { // {
@ -213,7 +222,7 @@ namespace BBWY.Server.Business
foreach (var order in orderList) foreach (var order in orderList)
{ {
orderIndex++; orderIndex++;
Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()}, orderProgress {orderIndex}/{orderList.Count()}"); Console.WriteLine($"Calculation {shop.ShopName}, orderProgress {orderIndex}/{orderList.Count()}");
var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id).ToList(); var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id).ToList();
@ -257,7 +266,33 @@ namespace BBWY.Server.Business
} }
} }
}, CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler);
}
} }
public void DeleteJDTask()
{
var appKey = "E1AA9247D5583A6D87449CE6AB290185";
var appSecret = "e479558ddd9e40f8929cfc00c6cbbc9c";
var appToken = "578d4074d5c04272af72de7f5fbe0ff2qwnz";
var promotionId = 6106235467;
var httpResult = restApiService.SendRequest(GetPlatformRelayAPIHost(Enums.Platform.),
"api/platformsdk/DeleteJDPromotionTask",
new DeleteJDPromotionTaskRequest()
{
AppKey = appKey,
AppSecret = appSecret,
AppToken = appToken,
Platform = Enums.Platform.,
PromotionId = promotionId
},
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);
} }
} }

Loading…
Cancel
Save