You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.6 KiB

using BBWYB.Client.APIServices;
using BBWYB.Client.Models;
using BBWYB.Client.ViewModels;
using BBWYB.Client.Views.PackPurchaseTaska;
2 years ago
using BBWYB.Client.Views.WebB;
2 years ago
using CommunityToolkit.Mvvm.ComponentModel;
2 years ago
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
2 years ago
using System.Collections.Generic;
2 years ago
using System.Runtime.InteropServices;
using System.Windows;
2 years ago
namespace BBWYB.Client
{
2 years ago
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
2 years ago
public class GlobalContext : ObservableObject
2 years ago
{
public GlobalContext()
{
2 years ago
BBWYBApiVersion = "10022";
2 years ago
}
private User user;
2 years ago
public User User { get => user; set { SetProperty(ref user, value); } }
2 years ago
public string UserToken { get; set; }
public IList<LogisticsResponse> LogisticsResponseList { get; set; }
/// <summary>
/// JD客户端
/// </summary>
//public IJdClient JdClient { get; set; }
#region APIHost
2 years ago
public string BBWYApiHost { get; set; }
2 years ago
public string MDSApiHost { get; set; }
2 years ago
public string BBWYCApiHost { get; set; }
public string QKApiHost { get; set; }
public string BBWYBApiVersion { get; set; }
#endregion
#region Web
public string GetUserString()
{
return JsonConvert.SerializeObject(User);
}
public string GetBBWYBApiVersion()
{
return BBWYBApiVersion;
}
/// <summary>
/// 对web版提供的修改打包任务方法
/// </summary>
/// <param name="belongSkuId">订单sku归属的来源sku(JD)</param>
/// <param name="orderId">订单Id</param>
/// <param name="skuLogo">sku图片</param>
/// <param name="skuTitle">sku标题</param>
/// <param name="originShopName">订单来源店铺名称</param>
public void OpenUpdatePurchaseTask(string belongSkuId, string orderId, string skuLogo, string skuTitle, string originShopName)
{
var app = App.Current as App;
var sp = app.ServiceProvider;
PackPurchaseTaskService packPurchaseTaskService = null;
using (var s = sp.CreateScope())
{
packPurchaseTaskService = s.ServiceProvider.GetRequiredService<PackPurchaseTaskService>();
}
var orderSku = new OrderSku()
{
OrderId = orderId,
BelongSkuId = belongSkuId,
Title = skuTitle,
Logo = skuLogo,
};
var res = packPurchaseTaskService.GetOrderTask(orderSku.BelongSkuId, orderSku.OrderId);
if (res == null || !res.Success)
{
MessageBox.Show("网络异常!查不到任务");
return;
}
if (res.Data == null)
{
MessageBox.Show("打包任务,不存在或已被删除,请重新发起任务!");
return;
}
UpdatePurchaseTaskWindow packTask = new();
ViewModelLocator view = new();
var updatePackTask = view.UpdatePurchaseTask;
var show = updatePackTask.SearchSku(res.Data, originShopName, orderSku);
if (!show) return;
//updatePackTask.ReflashWindow = () =>
//{
// Task.Factory.StartNew(() => LoadOrder(PageIndex));
//};
packTask.ShowDialog();
2 years ago
WeakReferenceMessenger.Default.Send(new Message_WebB_RefreshPack(null));
//
}
2 years ago
#endregion
}
}