Browse Source

1.对接JD店铺Token推送

2.新增选择采购方案弹窗
qianyi
shanji 3 years ago
parent
commit
b979e2876f
  1. 20
      BBWY.Client/APIServices/PurchaseService.cs
  2. 45
      BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs
  3. 11
      BBWY.Client/ViewModels/ViewModelLocator.cs
  4. 28
      BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml
  5. 15
      BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml.cs
  6. 2
      BBWY.Server.API/Controllers/BaseApiController.cs
  7. 1
      BBWY.Server.API/Controllers/OrderController.cs
  8. 28
      BBWY.Server.API/Controllers/VenderController.cs
  9. 20
      BBWY.Server.Business/Vender/VenderBusiness.cs
  10. 11
      BBWY.Server.Model/Dto/Request/Vender/JDShopToken.cs

20
BBWY.Client/APIServices/PurchaseService.cs

@ -13,8 +13,9 @@ namespace BBWY.Client.APIServices
/// <summary> /// <summary>
/// 获取采购方案 /// 获取采购方案
/// </summary> /// </summary>
/// <param name="productIdList">产品Id</param> /// <param name="productIdList"></param>
/// <param name="purchaserId">采购商Id</param> /// <param name="purchaserId"></param>
/// <param name="shopId"></param>
/// <returns></returns> /// <returns></returns>
public ApiResponse<IList<PurchaseSchemeResponse>> GetPurchaseSchemeList(IList<string> productIdList, string purchaserId, long shopId) public ApiResponse<IList<PurchaseSchemeResponse>> GetPurchaseSchemeList(IList<string> productIdList, string purchaserId, long shopId)
{ {
@ -25,6 +26,21 @@ namespace BBWY.Client.APIServices
HttpMethod.Post); HttpMethod.Post);
} }
/// <summary>
/// 获取采购方案
/// </summary>
/// <param name="skuId"></param>
/// <param name="shopId"></param>
/// <returns></returns>
public ApiResponse<IList<PurchaseSchemeResponse>> GetPurchaseSchemeList(string skuId, long shopId)
{
return SendRequest<IList<PurchaseSchemeResponse>>(globalContext.BBYWApiHost,
"api/PurchaseScheme/GetPurchaseSchemeList",
new { skuId, shopId },
null,
HttpMethod.Post);
}
public ApiResponse<object> EditPurchaseScheme(IList<PurchaseScheme> addPurchaseSchemeList, IList<PurchaseScheme> editPurchaseSchemeList) public ApiResponse<object> EditPurchaseScheme(IList<PurchaseScheme> addPurchaseSchemeList, IList<PurchaseScheme> editPurchaseSchemeList)
{ {
return SendRequest<object>(globalContext.BBYWApiHost, return SendRequest<object>(globalContext.BBYWApiHost,

45
BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs

@ -0,0 +1,45 @@
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Common.Models;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows;
namespace BBWY.Client.ViewModels
{
public class ChoosePurchaseSchemeViewModel : BaseVM, IDenpendency
{
private PurchaseService purchaseService;
private GlobalContext globalContext;
public string SkuId { get; set; }
public IList<PurchaseScheme> PurchaseSchemeList { get; set; }
public ChoosePurchaseSchemeViewModel(PurchaseService purchaseService, GlobalContext globalContext)
{
this.purchaseService = purchaseService;
this.globalContext = globalContext;
PurchaseSchemeList = new ObservableCollection<PurchaseScheme>();
}
protected override void Load()
{
PurchaseSchemeList.Clear();
Task.Factory.StartNew(() => purchaseService.GetPurchaseSchemeList(SkuId, globalContext.User.Shop.ShopId)).ContinueWith(t =>
{
var r = t.Result;
if (!r.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "获取采购方案"));
return;
}
App.Current.Dispatcher.Invoke(() =>
{
foreach (var apiModel in r.Data) PurchaseSchemeList.Add(PurchaseScheme.Convert(apiModel));
});
});
}
}
}

11
BBWY.Client/ViewModels/ViewModelLocator.cs

@ -66,5 +66,16 @@ namespace BBWY.Client.ViewModels
} }
} }
} }
public ChoosePurchaseSchemeViewModel ChoosePurchaseScheme
{
get
{
using (var s = sp.CreateScope())
{
return s.ServiceProvider.GetRequiredService<ChoosePurchaseSchemeViewModel>();
}
}
}
} }
} }

28
BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml

@ -0,0 +1,28 @@
<c:BWindow x:Class="BBWY.Client.Views.Order.ChoosePurchaseScheme"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BBWY.Client.Views.Order"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
mc:Ignorable="d"
Title="ChoosePurchaseScheme" Height="200" Width="800"
Style="{StaticResource bwstyle}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed"
DataContext="{Binding ChoosePurchaseScheme,Source={StaticResource Locator}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
Background="{StaticResource Border.Background}">
<TextBlock Text="选择采购商" Style="{StaticResource middleTextBlock}"/>
</Border>
<DataGrid Grid.Row="1">
</DataGrid>
</Grid>
</c:BWindow>

15
BBWY.Client/Views/Order/ChoosePurchaseScheme.xaml.cs

@ -0,0 +1,15 @@
using BBWY.Controls;
namespace BBWY.Client.Views.Order
{
/// <summary>
/// ChoosePurchaseScheme.xaml 的交互逻辑
/// </summary>
public partial class ChoosePurchaseScheme : BWindow
{
public ChoosePurchaseScheme()
{
InitializeComponent();
}
}
}

2
BBWY.Server.API/Controllers/BaseApiController.cs

@ -7,7 +7,7 @@ namespace BBWY.Server.API.Controllers
[ApiController] [ApiController]
public class BaseApiController : ControllerBase public class BaseApiController : ControllerBase
{ {
private IHttpContextAccessor httpContextAccessor; protected IHttpContextAccessor httpContextAccessor;
public BaseApiController(IHttpContextAccessor httpContextAccessor) public BaseApiController(IHttpContextAccessor httpContextAccessor)
{ {
this.httpContextAccessor = httpContextAccessor; this.httpContextAccessor = httpContextAccessor;

1
BBWY.Server.API/Controllers/OrderController.cs

@ -106,6 +106,7 @@ namespace BBWY.Server.API.Controllers
[HttpPost("{shopId}/{orderId}")] [HttpPost("{shopId}/{orderId}")]
public void SyncOrder([FromRoute] long shopId, [FromRoute] string orderId) public void SyncOrder([FromRoute] long shopId, [FromRoute] string orderId)
{ {
Task.Factory.StartNew(() => orderBusiness.SyncOrder(shopId, orderId), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler); Task.Factory.StartNew(() => orderBusiness.SyncOrder(shopId, orderId), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler);
} }
} }

28
BBWY.Server.API/Controllers/VenderController.cs

@ -2,7 +2,11 @@
using BBWY.Server.Model.Dto; using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NLog;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text;
namespace BBWY.Server.API.Controllers namespace BBWY.Server.API.Controllers
{ {
@ -10,10 +14,14 @@ namespace BBWY.Server.API.Controllers
public class VenderController : BaseApiController public class VenderController : BaseApiController
{ {
private VenderBusiness venderBusiness; private VenderBusiness venderBusiness;
private ILogger logger;
public VenderController(IHttpContextAccessor httpContextAccessor, VenderBusiness venderBusiness) : base(httpContextAccessor) public VenderController(IHttpContextAccessor httpContextAccessor,
VenderBusiness venderBusiness,
ILogger logger) : base(httpContextAccessor)
{ {
this.venderBusiness = venderBusiness; this.venderBusiness = venderBusiness;
this.logger = logger;
} }
/// <summary> /// <summary>
@ -33,9 +41,25 @@ namespace BBWY.Server.API.Controllers
/// <param name="platformRequest"></param> /// <param name="platformRequest"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public IList<LogisticsResponse> GetLogisticsList(PlatformRequest platformRequest) public IList<LogisticsResponse> GetLogisticsList([FromBody] PlatformRequest platformRequest)
{ {
return venderBusiness.GetLogisticsList(platformRequest); return venderBusiness.GetLogisticsList(platformRequest);
} }
/// <summary>
/// 接收JD店铺Token更新
/// </summary>
/// <param name="jDShopToken"></param>
[HttpPost]
public void AcceptJDShopToken([FromBody] JDShopToken jDShopToken)
{
var httpContext = httpContextAccessor.HttpContext;
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("AcceptJDShopToken");
stringBuilder.AppendLine($"ContentType:{httpContext.Request.ContentType}");
stringBuilder.Append($"jDShopToken:{JsonConvert.SerializeObject(jDShopToken)}");
logger.Info(stringBuilder.ToString());
venderBusiness.AcceptJDShopToken(jDShopToken);
}
} }
} }

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

@ -6,6 +6,7 @@ using BBWY.Server.Model.Dto;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http;
namespace BBWY.Server.Business namespace BBWY.Server.Business
{ {
@ -39,5 +40,24 @@ namespace BBWY.Server.Business
throw new BusinessException(response.Msg) { Code = response.Code }; throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data; return response.Data;
} }
public void AcceptJDShopToken(JDShopToken jDShopToken)
{
var venderResponse = GetVenderInfo(new PlatformRequest()
{
AppKey = "120EA9EC65AB017567D78CC1139EEEA5",
AppSecret = "866a9877f5f24b03b537483b4defe75d",
AppToken = jDShopToken.Access_Token,
Platform = Enums.Platform.
});
restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/UpdateShop", new
{
venderResponse.ShopName,
venderResponse.ShopId,
ShopType = venderResponse.ColType,
AppToken = jDShopToken.Access_Token
}, new Dictionary<string, string>() { { "qy", "qy" } }, HttpMethod.Post);
}
} }
} }

11
BBWY.Server.Model/Dto/Request/Vender/JDShopToken.cs

@ -0,0 +1,11 @@
namespace BBWY.Server.Model.Dto
{
public class JDShopToken
{
public string Access_Token { get; set; }
public int Code { get; set; }
public bool IsSuccess { get; set; }
}
}
Loading…
Cancel
Save