shanji 1 year ago
parent
commit
1a0c693bba
  1. 6
      BBWYB.Client/APIServices/MdsApiService.cs
  2. 4
      BBWYB.Client/App.xaml
  3. 11
      BBWYB.Client/App.xaml.cs
  4. 1
      BBWYB.Client/BBWYB.Client.csproj
  5. 358
      BBWYB.Client/GlobalContext.cs
  6. 927
      BBWYB.Client/Helpers/1688/Collect1688Helper.cs
  7. 28
      BBWYB.Client/Helpers/1688/Md5Helper.cs
  8. 32
      BBWYB.Client/Helpers/CustomWebView2.cs
  9. 17
      BBWYB.Client/Models/1688/AddressModel.cs
  10. 109
      BBWYB.Client/Models/1688/OrderParameter.cs
  11. 22
      BBWYB.Client/Models/1688/OrderProduct.cs
  12. 25
      BBWYB.Client/Models/1688/PrewOrderResponse.cs
  13. 15
      BBWYB.Client/Models/1688/ProductModel.cs
  14. 23
      BBWYB.Client/Models/1688/_1688CookieModel.cs
  15. 2
      BBWYB.Client/Models/APIModel/Request/PackPurchaseTask/CerRequest.cs
  16. 10
      BBWYB.Client/Models/Enums.cs
  17. 4
      BBWYB.Client/Models/PackPurchaseTask/CertificateModel.cs
  18. 13
      BBWYB.Client/Models/PackPurchaseTask/PurchaseSku.cs
  19. 5
      BBWYB.Client/Models/Shop/PurchaseAccount.cs
  20. 160
      BBWYB.Client/ViewModels/PackPurchaseTask/UpdatePurchaseTaskViewModel.cs
  21. 58
      BBWYB.Client/ViewModels/WebVM.cs
  22. 12
      BBWYB.Client/Views/1688/Login1688Window.xaml
  23. 214
      BBWYB.Client/Views/1688/Login1688Window.xaml.cs
  24. 13
      BBWYB.Client/Views/1688/NewLogin1688Window.xaml
  25. 184
      BBWYB.Client/Views/1688/NewLogin1688Window.xaml.cs
  26. 109
      BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml
  27. 16
      BBWYB.Client/Views/Web.xaml.cs
  28. 4
      BBWYB.Client/WebView2Manager.cs
  29. 4
      BBWYB.Client/appsettings.json
  30. 1
      BBWYB.Server.API/BBWYB.Server.API.csproj
  31. 15
      BBWYB.Server.API/Controllers/PurchaseOrderController.cs
  32. 1
      BBWYB.Server.Business/BBWYB.Server.Business.csproj
  33. 604
      BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  34. 2
      BBWYB.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs
  35. 4
      BBWYB.Server.Business/PurchaseScheme/PurchaseSchemeBusiness.cs
  36. 2
      BBWYB.Server.Business/SkuOptimization/OptimizationBusiness.cs
  37. 1
      BBWYB.Server.Business/Vender/VenderBusiness.cs
  38. 939
      BBWYB.Server.Business/_1688Helper/Collect1688Helper.cs
  39. 28
      BBWYB.Server.Business/_1688Helper/Md5Helper.cs
  40. 7
      BBWYB.Server.Model/Db/MDS/Purchaseaccount.cs
  41. 9
      BBWYB.Server.Model/Dto/Request/PurchaseOrder/CreateOrderRequest.cs
  42. 2
      BBWYB.Server.Model/Dto/Request/PurchaseOrder/PreviewOrderRequest.cs
  43. 2
      BBWYB.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs
  44. 17
      BBWYB.Server.Model/Dto/_1688/AddressModel.cs
  45. 111
      BBWYB.Server.Model/Dto/_1688/OrderParameter.cs
  46. 22
      BBWYB.Server.Model/Dto/_1688/OrderProduct.cs
  47. 26
      BBWYB.Server.Model/Dto/_1688/PrewOrderResponse.cs
  48. 15
      BBWYB.Server.Model/Dto/_1688/ProductModel.cs
  49. 21
      BBWYB.Server.Model/Dto/_1688/_1688CookieModel.cs
  50. 10
      BBWYB.Server.Model/Enums.cs

6
BBWYB.Client/APIServices/MdsApiService.cs

@ -80,7 +80,8 @@ namespace BBWYB.Client.APIServices
PlatformCommissionRatio = jShop.Value<decimal?>("PlatformCommissionRatio") ?? 0.05M,
ShopName = jShop.Value<string>("ShopName"),
VenderType = jShop.Value<string>("ShopType"),
TeamId = jShop.Value<string>("TeamId")
TeamId = jShop.Value<string>("TeamId"),
};
d.ShopList.Add(shop);
@ -95,7 +96,8 @@ namespace BBWYB.Client.APIServices
AppSecret = jPurchaseAccount.Value<string>("AppSecret"),
AppToken = jPurchaseAccount.Value<string>("AppToken"),
ShopId = shop.ShopId,
PurchasePlatformId = (Platform)jPurchaseAccount.Value<int>("AppPlatformId")
PurchasePlatformId = (Platform)jPurchaseAccount.Value<int>("AppPlatformId"),
Password = jPurchaseAccount.Value<string>("Password"),
});
}
}

4
BBWYB.Client/App.xaml

@ -4,9 +4,9 @@
xmlns:local="clr-namespace:BBWYB.Client"
xmlns:vm="clr-namespace:BBWYB.Client.ViewModels"
xmlns:ctr="clr-namespace:BBWYB.Client.Converters"
StartupUri="/Views/Web.xaml"
StartupUri="/Views/Web.xaml"
ShutdownMode="OnExplicitShutdown">
<!--StartupUri="/Views/MainWindow.xaml"-->
<!--StartupUri="/Views/Web.xaml"-->
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

11
BBWYB.Client/App.xaml.cs

@ -30,12 +30,17 @@ namespace BBWYB.Client
var gl = new GlobalContext();
string userToken = string.Empty;
#if DEBUG
//齐越山鸡
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNzI2MzAwNjY0fQ.hPSbgJEuTt0MLy_7YkSJX4rRG3drJAfso-5IS8ZlOkY";
//议价2组
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNzYwOTcxNjg4OTY0NTI2MDgwIiwiZXhwIjoxNzQyNjMwODk0fQ.Vtq2MU1Qd9Oo192udkA01ZAwiQgQxj2m-pkayGZ1d3I";
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNzYwOTcxNjg4OTY0NTI2MDgwIiwiZXhwIjoxNzQyNjMwODk0fQ.Vtq2MU1Qd9Oo192udkA01ZAwiQgQxj2m-pkayGZ1d3I";
//齐越艾伦
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNjg2MTk4MzQzMjcwNjY2MjQwIiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNDU4NzAxNzE4MjI0MTEzNjY0LDE2MjAzNDIwMTQ3MDY5Nzg4MTYiLCJleHAiOjE3NDQxNzg3NjR9.lPHkPwG7inb_08T8aFDnPlSv7EKkWx7Jzp9R56DsAO4";
//拳探店铺 陈默
//userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNjI0OTUxNjgzNTc2NTAwMjI0IiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNjIwMzQyMDE0NzA2OTc4ODE2LDE2MjAzNDM4Mjc0NzI1ODQ3MDQsMTYyMDM0NDAzMzczNTg3MjUxMiwxNjIwMzQ0MDkyODI5NDIxNTY4LDE2MjAzNDQxNDA4NTAwMDgwNjQiLCJleHAiOjE3MjA3NjQzMjV9.Q8fiKXCHgvzbm7NDEre-MeoSju_AmC6Ae6eDY22rUAw";
@ -85,6 +90,10 @@ namespace BBWYB.Client
serviceCollection.AddTransient<BindingPurchaseProductViewModel>();
serviceCollection.AddMapper(new MappingProfile());
ServiceProvider = serviceCollection.BuildServiceProvider();
gl.Login1688("齐越供应链1号", "jiayou123", true);
base.OnStartup(e);
}

1
BBWYB.Client/BBWYB.Client.csproj

@ -40,6 +40,7 @@
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1829-prerelease" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="WebView2.DevTools.Dom" Version="4.0.1" />
</ItemGroup>
<ItemGroup>

358
BBWYB.Client/GlobalContext.cs

@ -1,14 +1,21 @@
using BBWYB.Client.APIServices;
using BBWYB.Client.Helpers;
using BBWYB.Client.Models;
using BBWYB.Client.Models._1688;
using BBWYB.Client.Views;
using BBWYB.Client.Views._1688;
using BBWYB.Client.Views.PackPurchaseTaska;
using BBWYB.Common.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace BBWYB.Client
@ -20,9 +27,11 @@ namespace BBWYB.Client
{
public GlobalContext()
{
BBWYBApiVersion = "10041";
BBWYBApiVersion = "10043";
}
public List<_1688CookieModel> _1688CookieList { get; set; } = new List<_1688CookieModel>();
private User user;
public User User { get => user; set { SetProperty(ref user, value); } }
@ -44,6 +53,7 @@ namespace BBWYB.Client
public string QKApiHost { get; set; }
public string BBWYBApiVersion { get; set; }
public Window CurryWindow { get; set; }
#endregion
#region Web
@ -120,6 +130,352 @@ namespace BBWYB.Client
packTask.Show();
//
}
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="IsNeedLogin">是否必须登陆</param>
/// <returns></returns>
public async Task<string> Login1688_(string userName, string password, bool IsNeedLogin)
{
return await Task.Factory.StartNew<string>(() =>
{
if (!IsNeedLogin)
{
if (_1688CookieList.Any(c => c.UserName == userName))
{
return _1688CookieList.FirstOrDefault(c => c.UserName == userName).Cookie;
}
}
string cookie = string.Empty;
try
{
//检查是否跨线程
if (!App.Current.Dispatcher.CheckAccess())
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
var loginWindow = new Login1688Window(userName, password);
loginWindow.ShowDialog();
var newCookie = loginWindow.downCookies;
if (!string.IsNullOrEmpty(newCookie))
//更新或者添加
if (_1688CookieList.Any(c => c.UserName == userName))
{
var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
oldCookie.Cookie = newCookie;
}
else
{
_1688CookieList.Add(new _1688CookieModel() { UserName = userName, Cookie = newCookie });
}
cookie = loginWindow.downCookies;
}));
}
}
catch (Exception ex)
{
}
return cookie;
});
}
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="IsNeedLogin">是否必须登陆</param>
/// <returns></returns>
public async Task<string> Login1688123(string userName, string password, bool IsNeedLogin)
{
return await Task.Factory.StartNew<string>(() =>
{
if (!IsNeedLogin)
{
if (_1688CookieList.Any(c => c.UserName == userName))
{
return _1688CookieList.FirstOrDefault(c => c.UserName == userName).Cookie;
}
}
string cookie = string.Empty;
try
{
//检查是否跨线程
if (!App.Current.Dispatcher.CheckAccess())
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
var loginWindow = new NewLogin1688Window(userName, password);
loginWindow.ShowDialog();
var newCookie = loginWindow.downCookies;
//更新或者添加
if (_1688CookieList.Any(c => c.UserName == userName))
{
var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
oldCookie.Cookie = newCookie;
}
else
{
_1688CookieList.Add(new _1688CookieModel() { UserName = userName, Cookie = newCookie });
}
cookie = loginWindow.downCookies;
}));
}
//else
//{
// var loginWindow = new NewLogin1688Window(userName, password);
// loginWindow.ShowDialog();
// var newCookie = loginWindow.downCookies;
// //更新或者添加
// if (_1688CookieList.Any(c => c.UserName == userName))
// {
// var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
// oldCookie.Cookie = newCookie;
// }
// else
// {
// _1688CookieList.Add(new _1688CookieModel() { UserName = userName, Cookie = newCookie });
// }
// cookie = loginWindow.downCookies;
//}
}
catch (Exception ex)
{
}
return cookie;
});
}
/// <summary>
/// 客户端登陆 不获取cookie
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="IsNeedLogin">是否必须登陆</param>
/// <returns></returns>
public string Login1688(string userName, string password, bool IsNeedLogin)
{
if (!IsNeedLogin)
{
if (_1688CookieList.Any(c => c.UserName == userName&&!c.IsExpire))
{
return JsonConvert.SerializeObject(_1688CookieList.FirstOrDefault(c => c.UserName == userName));
}
}
Task.Factory.StartNew(() =>
{
try
{
//检查是否跨线程
if (!App.Current.Dispatcher.CheckAccess())
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
var loginWindow = new NewLogin1688Window(userName, password);
loginWindow.ShowDialog();
var newCookie = loginWindow.downCookies;
if (!string.IsNullOrEmpty(newCookie))
//更新或者添加
if (_1688CookieList.Any(c => c.UserName == userName))
{
var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
oldCookie.Cookie = newCookie;
}
else
{
_1688CookieList.Add(new _1688CookieModel() { UserName = userName, Cookie = newCookie, Password = password, LoginTime = DateTime.Now });
}
//SaveLocalFile?.Invoke(_1688LogunPath, JsonConvert.SerializeObject(_1688CookieList));
}));
}
//else
//{
// var loginWindow = new NewLogin1688Window(userName, password);
// loginWindow.ShowDialog();
// var newCookie = loginWindow.downCookies;
// //更新或者添加
// if (_1688CookieList.Any(c => c.UserName == userName))
// {
// var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
// oldCookie.Cookie = newCookie;
// }
// else
// {
// _1688CookieList.Add(new _1688CookieModel() { UserName = userName, Cookie = newCookie });
// }
// cookie = loginWindow.downCookies;
//}
}
catch (Exception ex)
{
}
});
return null;
}
//public Action<string ,string> SaveLocalFile { get; set; }
//public const string _1688LogunPath = "1688LoginCookies";
public void SetCookieExpire(string userName)
{
if (_1688CookieList.Any(c => c.UserName == userName))
{
var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
oldCookie.IsExpire = true;
//SaveLocalFile?.Invoke(_1688LogunPath, JsonConvert.SerializeObject(_1688CookieList));
}
}
/*
public string CreatePurchaseOrderByWeb(string orderProductListJson, string adress, int _orderModel, string remark, string userName, string password)
{
OrderModel orderModel = (OrderModel)_orderModel;
List<OrderProduct> models = JsonConvert.DeserializeObject<List<OrderProduct>>(orderProductListJson);
List<OrderProduct> distinModels = new List<OrderProduct>();
//合并相同的sku商品 叠加数量
foreach (var item in models)
{
//判断是否存在
if (distinModels.Any(m => m.SkuId == item.SkuId && m.SpectId == item.SpectId && m.ProductId == item.ProductId))
{
var oldModel = distinModels.FirstOrDefault(m => m.SkuId == item.SkuId);
oldModel.Quantity += item.Quantity;
}
else
{
distinModels.Add(item);
}
}
models = distinModels;
string cookie = "";
if (_1688CookieList.Any(c => c.UserName == userName))
{
var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
cookie = oldCookie.Cookie;
}
else
{
Login1688(userName, password, true);
return JsonConvert.SerializeObject(new ApiResponse<string>
{
Code = 1000,
Msg = "登录失效,请重新登陆后下单",
});
}
Collect1688Helper collect1688Helper = new Collect1688Helper(cookie);
var prewOrder = collect1688Helper.PrewOrder(models, adress, orderModel);
if (prewOrder == null)
{
Login1688(userName, password, true);
return JsonConvert.SerializeObject(new ApiResponse<string>
{
Code = 1000,
Msg = "登录失效,正在重新登陆,登录后点击下单!",
});
}
return JsonConvert.SerializeObject(collect1688Helper.CommitOrder(prewOrder, remark));
}
public async Task<string> CreatePurchaseOrderByWeb_olf(string orderProductListJson, string adress, int _orderModel, string remark, string userName, string password)
{
OrderModel orderModel = (OrderModel)_orderModel;
List<OrderProduct> models = JsonConvert.DeserializeObject<List<OrderProduct>>(orderProductListJson);
string cookie = "";
if (_1688CookieList.Any(c => c.UserName == userName))
{
var oldCookie = _1688CookieList.FirstOrDefault(c => c.UserName == userName);
cookie = oldCookie.Cookie;
}
else
{
Login1688(userName, password, true);
return JsonConvert.SerializeObject(new ApiResponse<string>
{
Code = 1000,
Msg = "登录失效,请重新登陆后下单",
});
}
return await Task.Factory.StartNew<string>(() =>
{
Collect1688Helper collect1688Helper = new Collect1688Helper(cookie);
var prewOrder = collect1688Helper.PrewOrder(models, adress, orderModel);
if (prewOrder == null)
{
return JsonConvert.SerializeObject(new ApiResponse<string>
{
Code = 1000,
Msg = "预览订单失败,登录失效",
});
}
return JsonConvert.SerializeObject(collect1688Helper.CommitOrder(prewOrder, remark));
});
}
*/
#endregion
}
}

927
BBWYB.Client/Helpers/1688/Collect1688Helper.cs

File diff suppressed because one or more lines are too long

28
BBWYB.Client/Helpers/1688/Md5Helper.cs

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Helpers
{
public class Md5Helper
{
//32位小写
public static string Md5_32(string str)
{
string cl = str;
string pwd = "";
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();//实例化一个md5对像
// 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
byte[] s = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(cl));
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
for (int i = 0; i < s.Length; i++)
{
//将得到的字符串使用16进制类型格式
pwd = pwd + s[i].ToString("X");
}
return pwd.ToLower();
}
}
}

32
BBWYB.Client/Helpers/CustomWebView2.cs

@ -0,0 +1,32 @@
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.Core.DevToolsProtocolExtension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Helpers
{
public class CustomWebView2 : Microsoft.Web.WebView2.Wpf.WebView2, IDisposable
{
public CustomWebView2(string folderName = "WebView2UserData")
{
//允许跨域
var op = new CoreWebView2EnvironmentOptions("--disable-web-security")
{
// AreBrowserExtensionsEnabled = true
};
var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: System.IO. Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), folderName)).Result;
EnsureCoreWebView2Async(wb2Setting);
}
public void DisposeWeb()
{
base.Dispose();
GC.Collect();
}
}
}

17
BBWYB.Client/Models/1688/AddressModel.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Models
{
public class AddressModel
{
public string AddressDetail { get; internal set; }
public string DivisionZip { get; internal set; }
public string MobileNO { get; internal set; }
public string PersonalName { get; internal set; }
public string AddressCode { get; internal set; }
}
}

109
BBWYB.Client/Models/1688/OrderParameter.cs

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Models
{
public class OrderParameter
{
public string Csrf_token { get; set; }
public string OrderUrl { get; set; }
public string Lvid { get; set; }
public List<OrderGroupParameter> OrderGroupParameterList { get; set; }
public string Address { get; set; }
public string TownCode { get; set; }
public string IpvId { get; set; }
}
public class OrderGroupParameter
{
/// <summary>
/// 优惠券id
/// </summary>
public string PromotionId { get; set; }
/// <summary>
/// 1使用优惠券 0不使用优惠券
/// </summary>
public int ChooseFreeFreight { get; set; }
public decimal SumCarriage { get; set; }
public decimal DiscountFee { get; set; }
public decimal TotalProductAmount { get; set; }
public decimal ActualPay { get; set; }
public int PayFee { get; set; }
public int ActualPayFee { get; set; }
public string Group { get; set; }
public string StepName { get; set; }
public string OrderOutId { get; set; }
public string MemberId { get; set; }
//sellerUserId
public string SellerUserId { get; set; }
////transportType
//public string TransportType { get; set; }
////tplCode
//public string TplCode { get; set; }
//belong
public string Belong { get; set; }
public List<OrderProductParameter> OrderProductParameterList { get; set; }
}
public class OrderProductParameter
{
public decimal DiscountFee { get; set; }
public decimal SumCarriage { get; set; }
public string ProductId { get; set; }
public string SkuId { get; set; }
public string SpectId { get; set; }
public string CargoKey { get; set; }
public decimal UnitPrice { get; set; }
public decimal ProductAmount { get; set; }
public int Quantity { get; set; }
public string FreightId { get; internal set; }
//outId
public string OutId { get; set; }
public string? OfferPriceRangeJson { get; internal set; }
/// <summary>
/// 优惠券
/// </summary>
public string Couple { get; set; }
/// <summary>
/// 1使用优惠券 0不使用优惠券
/// </summary>
public int ChooseFreeFreight { get; set; }
}
}

22
BBWYB.Client/Models/1688/OrderProduct.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Models
{
public class OrderProduct
{
public string ProductId { get; set; }
public string SkuId { get; set; }
public string SpectId { get; set; }
//数量
public int Quantity { get; set; }
}
}

25
BBWYB.Client/Models/1688/PrewOrderResponse.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Models
{
public class PrewOrderResponse
{
public OrderParameter orderParameter { get; set; }
public OrderModel OrderModel { get; set; }
public AddressModel AddressModel { get; set; }
public decimal TotalProductAmount { get; set; }
public decimal SumCarriage { get; set; }
//总订单金额
public decimal ActualPay { get; set; }
}
}

15
BBWYB.Client/Models/1688/ProductModel.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Models
{
public class ProductModel
{
public int MixNumber { get; set; }
public string IpvId { get; set; }
}
}

23
BBWYB.Client/Models/1688/_1688CookieModel.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Client.Models._1688
{
public class _1688CookieModel
{
public string Cookie { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public DateTime LoginTime { get; set; }
//是否过期
public bool IsExpire { get; set; }
}
}

2
BBWYB.Client/Models/APIModel/Request/PackPurchaseTask/CerRequest.cs

@ -70,7 +70,7 @@ namespace BBWYB.Client.Models.APIModel
/// </summary>
public string ApplyAge { get; set; }
public int GoodsNumber { get; set; }
public long GoodsNumber { get; set; }
public string ProduceDate { get; set; }

10
BBWYB.Client/Models/Enums.cs

@ -340,4 +340,14 @@
=0,=1
}
/// <summary>
/// 下单类型(批发(general)=0,代发(fenxiao=1)
/// </summary>
public enum OrderModel
{
general = 0,//批发
fenxiao = 1//代发
}
}

4
BBWYB.Client/Models/PackPurchaseTask/CertificateModel.cs

@ -146,11 +146,11 @@ namespace BBWYB.Client.Models.PackPurchaseTask
private int goodsNumber = 1;
private long goodsNumber = 1;
/// <summary>
/// 配件序号
/// </summary>
public int GoodsNumber { get => goodsNumber; set { SetProperty(ref goodsNumber, value); } }
public long GoodsNumber { get => goodsNumber; set { SetProperty(ref goodsNumber, value); } }
private string produceDate;
/// <summary>

13
BBWYB.Client/Models/PackPurchaseTask/PurchaseSku.cs

@ -48,21 +48,14 @@ namespace BBWYB.Client.Models.PackPurchaseTask
/// <summary>
/// 合格证配置信息
/// </summary>
public CertificateModel CerDTO { get ; set ; }
public CertificateModel CerDTO { get; set; }
private bool isSetCertificate;
/// <summary>
/// 设置显示(合格证)
/// </summary>
public bool IsSetCertificate
{
get => isSetCertificate; set
{
SetProperty(ref isSetCertificate, value);
//IsNeedCertificateModel = IsSetCertificate ? Need.不需要 : Need.需要;
}
}
public bool IsSetCertificate{get => isSetCertificate; set{SetProperty(ref isSetCertificate, value);}}
}
}

5
BBWYB.Client/Models/Shop/PurchaseAccount.cs

@ -20,6 +20,11 @@ namespace BBWYB.Client.Models
public string AppSecret { get => appSecret; set { SetProperty(ref appSecret, value); } }
public string AppToken { get => appToken; set { SetProperty(ref appToken, value); } }
/// <summary>
/// 密码
/// </summary>
public string Password { get; set; }
public object Clone()
{
return this.MemberwiseClone();

160
BBWYB.Client/ViewModels/PackPurchaseTask/UpdatePurchaseTaskViewModel.cs

@ -472,17 +472,101 @@ namespace BBWYB.Client.ViewModels
Brand = productApiResponse.Data.Items[0].BrandName;
}
IsNeedBarCode = Need.;
IsSetBarCode = true;
IsSetCertificate = true;
var productSku = packPurchaseTaskService.GetConfigPack(SkuId, "", OrderId);
if (productSku == null || !productSku.Success || productSku.Data == null)
if (productSku == null)
{
MessageBox.Show(productSku.Msg);
MessageBox.Show("网络异常!");
return false;
}
PurchaseSkuList = new ObservableCollection<Models.PackPurchaseTask.PurchaseSku>();
SkuPurchaseSchemeId = null;
if (productSku.Success && productSku.Data != null && !string.IsNullOrEmpty(productSku.Data.SkuPurchaseSchemeId))
{
SkuPurchaseSchemeId = productSku.Data.SkuPurchaseSchemeId;
BarCodeModel = productSku.Data.BarCode;
foreach (var item in productSku.Data.PurchaseSkus)
{
var list = purchaseService.GetPurchaseSkuBasicInfo(item.PurchaseProductId);
if (list == null || !list.Success || list.Data == null) continue;
var skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId);
if (skuItem == null)
{
MessageBox.Show($"{item.PurchaseProductId}采购商品列表不存在skuid:{item.PurchaseSkuId},sku商品可能被下架了.");
//return false;
}
App.Current.Dispatcher.Invoke(new Action(() =>
{
PurchaseSkuList.Add(new Models.PackPurchaseTask.PurchaseSku
{
Logo = skuItem?.Logo,
Title = skuItem?.Title,
IsNeedCer = item.IsNeedCer,
PurchaseSkuId = item.PurchaseSkuId,
CerDTO = item.CerDTO,
IsSetCertificate = item.CerDTO == null ? true : false,
});
}));
}
if (productSku.Data.PackConfig != null)
{
var config = productSku.Data.PackConfig;
SkuTitle = config.SkuGoodsTitle;
BrandName = config.BrandName;
GoodsNumber = config.GoodsNumber;
PackType = (PackType)config.PackType;
BasicPack = (BasicPack)config.BasicPack;
Availability = (TaskState)config.Availability;
//MarkMessage = config.MarkMessage;
CertificatePosition = config.CertificatePosition == null ? CertificatePosition. : (CertificatePosition)config.CertificatePosition.Value;
// Increment1 = config.Increment1;
IsNeedBarCode = config.NeedBar ? Need. : Need.;
IsNeedCertificateModel = config.NeedCer ? Need. : Need.;
IsSetBarCode = !config.NeedBar;
IsSetCertificate = !config.NeedCer;
string[] increateDatas = config.Increment1?.Split(',');
bool isSelected = false;
IncreateList = new ObservableCollection<IncreateModel>();
foreach (var item in increates)
{
isSelected = false;
if (increateDatas != null && increateDatas.Count() > 0 && increateDatas.Contains(item))
{
isSelected = true;
}
App.Current.Dispatcher.Invoke(() =>
{
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = isSelected
});
});
}
}
}
else
{
PurchaseSkuList.Add(new Models.PackPurchaseTask.PurchaseSku
{
CerDTO = new CertificateModel { }
});
}
SkuPurchaseSchemeId = productSku.Data.SkuPurchaseSchemeId;
BarCodeModel = productSku.Data.BarCode;
if (BarCodeModel == null)
{
BarCodeModel = new BarCodeModel();
@ -495,75 +579,7 @@ namespace BBWYB.Client.ViewModels
BarCodeModel.ProductNo = ProductNo;
BarCodeModel.SkuId = SkuId;
BarCodeModel.SkuName = SkuName;
PurchaseSkuList = new ObservableCollection<Models.PackPurchaseTask.PurchaseSku>();
foreach (var item in productSku.Data.PurchaseSkus)
{
var list = purchaseService.GetPurchaseSkuBasicInfo(item.PurchaseProductId);
if (list == null) continue;
var skuItem = list.Data.ItemList.FirstOrDefault(f => f.PurchaseSkuId == item.PurchaseSkuId);
if (skuItem == null)
{
MessageBox.Show($"{item.PurchaseProductId}采购商品列表不存在skuid:{item.PurchaseSkuId},sku商品可能被下架了.");
//return false;
}
App.Current.Dispatcher.Invoke(new Action(() =>
{
PurchaseSkuList.Add(new Models.PackPurchaseTask.PurchaseSku
{
Logo = skuItem?.Logo,
Title = skuItem?.Title,
IsNeedCer = item.IsNeedCer,
PurchaseSkuId = item.PurchaseSkuId,
CerDTO = item.CerDTO,
IsSetCertificate = item.CerDTO == null ? true : false,
});
}));
}
IsNeedBarCode = Need.;
IsSetBarCode = true;
IsSetCertificate = true;
if (productSku.Data.PackConfig != null)
{
var config = productSku.Data.PackConfig;
SkuTitle = config.SkuGoodsTitle;
BrandName = config.BrandName;
GoodsNumber = config.GoodsNumber;
PackType = (PackType)config.PackType;
BasicPack = (BasicPack)config.BasicPack;
Availability = (TaskState)config.Availability;
//MarkMessage = config.MarkMessage;
CertificatePosition = config.CertificatePosition == null ? CertificatePosition. : (CertificatePosition)config.CertificatePosition.Value;
// Increment1 = config.Increment1;
IsNeedBarCode = config.NeedBar ? Need. : Need.;
IsNeedCertificateModel = config.NeedCer ? Need. : Need.;
IsSetBarCode = !config.NeedBar;
IsSetCertificate = !config.NeedCer;
string[] increateDatas = config.Increment1?.Split(',');
bool isSelected = false;
IncreateList = new ObservableCollection<IncreateModel>();
foreach (var item in increates)
{
isSelected = false;
if (increateDatas != null && increateDatas.Count() > 0 && increateDatas.Contains(item))
{
isSelected = true;
}
App.Current.Dispatcher.Invoke(() =>
{
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = isSelected
});
});
}
}
return true;

58
BBWYB.Client/ViewModels/WebVM.cs

@ -51,29 +51,43 @@ namespace BBWYB.Client.ViewModels
IList<Department> departmentList = null;
var response = mdsApiService.GetShopDetailList();
if (!response.Success)
throw new Exception(response.Msg);
departmentList = response.Data.Where(d => d.Name.Contains("供应链")).ToList();
var res = shopService.GetDepartmentList();
if (!res.Success)
throw new Exception(res.Msg);
var allDepartmentList = res.Data.Map<IList<Department>>();
var shopList = new List<Shop>();
foreach (var d in allDepartmentList)
shopList.AddRange(d.ShopList);
GlobalContext.User.ShopList = shopList;
//if (managerDepartment.Contains(GlobalContext.User.TeamName) ||
// managerDepartment.Any(m => GlobalContext.User.SonDepartmentNames.Contains(m)))
//{
// var res = shopService.GetDepartmentList();
// if (!res.Success)
// throw new Exception(res.Msg);
// var allDepartmentList = res.Data.Map<IList<Department>>();
if (managerDepartment.Contains(GlobalContext.User.TeamName) ||
managerDepartment.Any(m => GlobalContext.User.SonDepartmentNames.Contains(m)))
{
var res = shopService.GetDepartmentList();
if (!res.Success)
throw new Exception(res.Msg);
var allDepartmentList = res.Data.Map<IList<Department>>();
var shopList = new List<Shop>();
foreach (var d in allDepartmentList)
shopList.AddRange(d.ShopList);
GlobalContext.User.ShopList = shopList;
departmentList = allDepartmentList.Where(d => d.Name.Contains("供应链")).ToList();
}
else
{
var response = mdsApiService.GetShopDetailList();
if (!response.Success)
throw new Exception(response.Msg);
departmentList = response.Data.Where(d => d.Name.Contains("供应链")).ToList();
}
// var shopList = new List<Shop>();
// foreach (var d in allDepartmentList)
// shopList.AddRange(d.ShopList);
// GlobalContext.User.ShopList = shopList;
// departmentList = allDepartmentList.Where(d => d.Name.Contains("供应链")).ToList();
//}
//else
//{
// var response = mdsApiService.GetShopDetailList();
// if (!response.Success)
// throw new Exception(response.Msg);
// departmentList = response.Data.Where(d => d.Name.Contains("供应链")).ToList();
//}
if (departmentList.Count == 0)
throw new Exception("缺少有效的部门数据");

12
BBWYB.Client/Views/1688/Login1688Window.xaml

@ -0,0 +1,12 @@
<Window x:Class="BBWYB.Client.Views._1688.Login1688Window"
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:BBWYB.Client.Views._1688"
mc:Ignorable="d"
Title="登录1688窗口" Height="450" Width="800">
<Grid Name="gd">
</Grid>
</Window>

214
BBWYB.Client/Views/1688/Login1688Window.xaml.cs

@ -0,0 +1,214 @@
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Web.WebView2.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WebView2.DevTools.Dom;
namespace BBWYB.Client.Views._1688
{
/// <summary>
/// Login1688Window.xaml 的交互逻辑
/// </summary>
public partial class Login1688Window : System.Windows.Window
{
private WebView2Manager w2m;
private bool isNavigated;
private GlobalContext globalContext;
public static Login1688Window ShowUrlSearchWindow(string userName, string password)
{
Login1688Window window = null;
bool? result = null;
if (!App.Current.Dispatcher.CheckAccess())
{
try
{
App.Current.Dispatcher.Invoke(() => {
window = new Login1688Window(userName, password);
window.ShowDialog();
});
}
catch (Exception ex)
{
}
}
else
{
window = new Login1688Window(userName, password);
window.ShowDialog();
// 在 UI 线程上执行操作
}
return window;
}
public Login1688Window(string userName, string password)
{
InitializeComponent();
this.Width = SystemParameters.WorkArea.Size.Width * 0.8;
this.Height = SystemParameters.WorkArea.Size.Height * 0.7;
var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope())
{
w2m =new WebView2Manager();
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
UserName = userName;
Password = password;
initWebView();
}
public string UserName { get; set; }
public string Password { get; set; }
private void initWebView()
{
var url = "https://login.taobao.com/?redirect_url=https%3A%2F%2Flogin.1688.com%2Fmember%2Fjump.htm%3Ftarget%3Dhttps%253A%252F%252Flogin.1688.com%252Fmember%252FmarketSigninJump.htm%253FDone%253Dhttps%25253A%25252F%25252Fwww.1688.com%25252F&style=tao_custom&from=1688web";
w2m.Init("bbwyb_web_1688");
w2m.wb2.SetValue(Grid.RowProperty, 1);
w2m.wb2.Margin = new Thickness(1, 0, 1, 0);
//grid.Children.Clear();
gd.Children.Add(w2m.wb2);
w2m.wb2.NavigationCompleted += Wb2_NavigationCompleted;
w2m.CoreWebView2InitializationCompleted += (s) =>
{
w2m.wb2.CoreWebView2.Navigate(url);
};
}
private void Wb2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
{
if (sender != null && sender is Microsoft.Web.WebView2.Wpf.WebView2)
{
var wv2 = sender as Microsoft.Web.WebView2.Wpf.WebView2;
if (wv2.CoreWebView2.Source.StartsWith("https://login.taobao.com/"))
{
App.Current.Dispatcher.Invoke(async () =>
{
await ExecuteJavaScript($"document.getElementById('fm-login-id').value='{UserName}'",1);
Thread.Sleep(100);
await ExecuteJavaScript($"document.getElementById('fm-login-password').value='{Password}'",1);
Thread.Sleep(100);
await ExecuteJavaScript("document.querySelector('.fm-button.fm-submit.password-login').click();", 1);
});
}
if (wv2.CoreWebView2.Source == ("https://www.1688.com/"))//手机端登录 保存账号密码
{
App.Current.Dispatcher.Invoke(async () =>
{
await GetCookies("https://www.1688.com/");
w2m.Close();
GC.Collect();
this.Close();
});
}
}
}
/// <summary>
/// 执行js函数
/// </summary>
/// <param name="js"></param>
/// <param name="type">0 有返回值 1无返回值 </param>
/// <returns></returns>
public async Task<(bool istrue, string res)> ExecuteJavaScript(string js, int type = 0)
{
try
{
string script = $"()=>{{ return {js}}}";
if (type != 0)
script = $"()=>{{ {js}}}";
string result = "";
await Application.Current.Dispatcher.Invoke(async () =>
{
await w2m.wb2?.EnsureCoreWebView2Async();
await using var devToolsContext = await w2m.wb2?.CoreWebView2?.CreateDevToolsContextAsync().WaitAsync((TimeSpan.FromSeconds(5)));//
result = await devToolsContext.EvaluateFunctionAsync<string>(script).WaitAsync(TimeSpan.FromSeconds(5));
});
return new(true, result);
}
catch (Exception ex)
{
// 处理可能的异常
Console.WriteLine(ex.Message);
return new(false, ex.Message);
}
}
public string downCookies { get; set; } = "";
static object obj { get; set; } = new object();
public Dictionary<string, string> dicCookies { get; set; } = new Dictionary<string, string>();
/// <summary>
/// 获取cookie
/// </summary>
public async Task GetCookies(string url)
{
if (w2m.wb2.CoreWebView2 != null)
{
var cookieManager = w2m.wb2.CoreWebView2.CookieManager;
List<CoreWebView2Cookie> cookies = await cookieManager.GetCookiesAsync(url);
foreach (CoreWebView2Cookie cookie in cookies)
{
if (dicCookies.Keys.Contains(cookie.Name))
{
dicCookies[cookie.Name] = cookie.Value;
continue;
}
dicCookies.Add(cookie.Name, cookie.Value);
}
//存本地下次打开植入
foreach (var item in dicCookies.Keys)
{
downCookies += $"{item}={dicCookies[item]}; ";
}
}
}
}
}

13
BBWYB.Client/Views/1688/NewLogin1688Window.xaml

@ -0,0 +1,13 @@
<Window x:Class="BBWYB.Client.Views._1688.NewLogin1688Window"
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:BBWYB.Client.Views._1688"
xmlns:c="clr-namespace:SJ.Controls;assembly=SJ.Controls"
mc:Ignorable="d"
Title="NewLogin1688Window" Height="800" Width="1000">
<Grid x:Name="gd">
</Grid>
</Window>

184
BBWYB.Client/Views/1688/NewLogin1688Window.xaml.cs

@ -0,0 +1,184 @@
using BBWYB.Client.Helpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Web.WebView2.Core;
using SJ.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace BBWYB.Client.Views._1688
{
/// <summary>
/// NewLogin1688Window.xaml 的交互逻辑
/// </summary>
public partial class NewLogin1688Window : Window
{
CustomWebView2 webView2;
CoreWebView2 web;
public NewLogin1688Window(string userName, string password)
{
InitializeComponent();
webView2 = new CustomWebView2("bbwyb_web_1688");
webView2.CoreWebView2InitializationCompleted += WebView2_CoreWebView2InitializationCompleted;
this.Width = SystemParameters.WorkArea.Size.Width * 0.8;
this.Height = SystemParameters.WorkArea.Size.Height * 0.7;
var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope())
{
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
UserName = userName;
Password = password;
gd.Children.Add(webView2);
}
GlobalContext globalContext;
public string UserName { get; set; }
public string Password { get; set; }
private void WebView2_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
// webView2.CoreWebView2.DocumentTitleChanged += CoreWebView2_DocumentTitleChanged;
web = webView2.CoreWebView2;
var url = "https://login.taobao.com/?redirect_url=https%3A%2F%2Flogin.1688.com%2Fmember%2Fjump.htm%3Ftarget%3Dhttps%253A%252F%252Flogin.1688.com%252Fmember%252FmarketSigninJump.htm%253FDone%253Dhttps%25253A%25252F%25252Fwww.1688.com%25252F&style=tao_custom&from=1688web";
webView2.CoreWebView2.Navigate(url);
//注册winning脚本c#互操作
// webView2.CoreWebView2.AddHostObjectToScript("hyCoreModel", globalContext);
//注册全局变量winning
// webView2.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("let hyCoreModel= window.chrome.webview.hostObjects.hyCoreModel;");
// web.AddWebResourceRequestedFilter("nacollector://home/img/*", CoreWebView2WebResourceContext.All);
//web.NavigationCompleted += Web_NavigationCompleted;
webView2.NavigationCompleted += Web_NavigationCompleted;
}
string lastUrl = "";
private void Web_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
if (sender != null && sender is Microsoft.Web.WebView2.Wpf.WebView2)
{
var wv2 = sender as Microsoft.Web.WebView2.Wpf.WebView2;
var url = wv2.CoreWebView2.Source;
if (url.StartsWith("https://login.taobao.com/") && lastUrl != url)
{
lastUrl = url;
App.Current.Dispatcher.Invoke(() =>
{
DoJavaScript($"document.getElementById('fm-login-id').value='{UserName}'",0);
DoJavaScript($"document.getElementById('fm-login-password').value='{Password}'",0);
DoJavaScript("document.querySelector('.fm-button.fm-submit.password-login').click();",0);
});
}
if (url.StartsWith("https://www.1688.com/") && lastUrl != url)//手机端登录 保存账号密码
{
lastUrl = wv2.CoreWebView2.Source;
App.Current.Dispatcher.Invoke(async () =>
{
await GetCookies("https://www.1688.com/");
webView2.DisposeWeb();
this.Close();
});
}
}
}
public string downCookies { get; set; } = "";
static object obj { get; set; } = new object();
public Dictionary<string, string> dicCookies { get; set; } = new Dictionary<string, string>();
/// <summary>
/// 获取cookie
/// </summary>
public async Task GetCookies(string url)
{
if (webView2.CoreWebView2 != null)
{
var cookieManager = webView2.CoreWebView2.CookieManager;
List<CoreWebView2Cookie> cookies = await cookieManager.GetCookiesAsync(url);
foreach (CoreWebView2Cookie cookie in cookies)
{
if (dicCookies.Keys.Contains(cookie.Name))
{
dicCookies[cookie.Name] = cookie.Value;
continue;
}
dicCookies.Add(cookie.Name, cookie.Value);
}
//存本地下次打开植入
foreach (var item in dicCookies.Keys)
{
downCookies += $"{item}={dicCookies[item]}; ";
}
}
}
/// <summary>
/// 执行js
/// </summary>
public (bool isOk, object result) DoJavaScript(string js, double timeSleep =5)
{
try
{
string result = null;
string script = $"(()=>{{{js}}})()";
Application.Current.Dispatcher.Invoke(async () =>
{
result = await web.ExecuteScriptAsync(script);
}).Wait(TimeSpan.FromSeconds(timeSleep));
if (int.TryParse(result, out var val))
{
return (true, val);
}
return (true, result);
}
catch (Exception ex)
{
return (false, null);
}
}
}
}

109
BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml

@ -126,15 +126,16 @@
</StackPanel>
</StackPanel>
<Grid Grid.Column="1">
<ListBox x:Name="listbox_order" HorizontalAlignment="Left"
Height="150" Width="900" Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
<ListBox x:Name="listbox_order" HorizontalAlignment="Left"
Height="150" Width="900" Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="0"
Foreground="{StaticResource Text.Color}">
Foreground="{StaticResource Text.Color}"
Visibility="{Binding SkuPurchaseSchemeId,Converter={StaticResource objConverter},ConverterParameter=#null:Collapsed:Visible}"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" />
@ -236,6 +237,104 @@
</DockPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="listbox_noSchemeId" HorizontalAlignment="Left"
Height="150" Width="900" Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
ItemsSource="{Binding PurchaseSkuList,Mode=TwoWay}"
BorderBrush="{StaticResource Border.Brush}"
BorderThickness="0"
Foreground="{StaticResource Text.Color}"
Visibility="{Binding SkuPurchaseSchemeId,Converter={StaticResource objConverter},ConverterParameter=#null:Visible:Collapsed}"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid
MinHeight="100">
<StackPanel Orientation="Horizontal" Height="150">
<c:BAsyncImage UrlSource="{Binding Logo}" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1"
Height="150" Width="150" Stretch="Fill"
VerticalAlignment="Top" Margin="20 0 0 0"
Cursor="Hand">
</c:BAsyncImage>
<DockPanel VerticalAlignment="Top" Width="190" Height="150">
<TextBlock Margin="10 10 0 0" DockPanel.Dock="Top" TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip>
<ToolTip Style="{StaticResource OrderCouponToolipStyle}">
<TextBlock Text="{Binding PurchaseSkuId}"/>
</ToolTip>
</TextBlock.ToolTip>
<Run Text="配件商品ID:"/>
<Run Text="{Binding PurchaseSkuId}"/>
</TextBlock >
<TextBlock Margin="10 10 0 10" DockPanel.Dock="Top" TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip>
<ToolTip Style="{StaticResource OrderCouponToolipStyle}">
<TextBlock Text="{Binding Title}"/>
</ToolTip>
</TextBlock.ToolTip>
<Run Text="SKU名称:"/>
<Run Text="{Binding Title}"/>
</TextBlock >
<StackPanel Margin="10 0 0 0" Height="25" VerticalAlignment="Bottom" DockPanel.Dock="Bottom" Orientation="Horizontal">
<TextBlock Text="合格证:" VerticalAlignment="Center"/>
<StackPanel Orientation="Horizontal"
Visibility="{Binding IsNeedCer, Converter={StaticResource objConverter}, ConverterParameter=true:Visible:Collapsed }">
<!--Content="{Binding CerDTO,Converter={StaticResource objConverter},ConverterParameter=#null:待设置:待确认}"-->
<c:BButton Content="待确认" Style="{StaticResource LinkButton}" Width="35" Height="15"
Command="{Binding DataContext. SetCertificateCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
CommandParameter="{Binding }"
Visibility="{Binding IsSetCertificate, Converter={StaticResource objConverter}, ConverterParameter=true:Visible:Collapsed }"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
Visibility="{Binding IsSetCertificate, Converter={StaticResource objConverter}, ConverterParameter=false:Visible:Collapsed }">
<c:BButton Content="查看" Style="{StaticResource LinkButton}" Width="35" Height="15"
CommandParameter="{Binding PurchaseSkuId}"
Command="{Binding DataContext. LookCerCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
<c:BButton Content="修改" Style="{StaticResource LinkButton}" Width="35" Height="15" CommandParameter="{Binding }"
Command="{Binding DataContext.SetCertificateCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
/>
</StackPanel >
</StackPanel>
<StackPanel Orientation="Horizontal"
Visibility="{Binding IsNeedCer, Converter={StaticResource objConverter}, ConverterParameter=true:Collapsed:Visible }">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
<!--Visibility="{Binding IsSetCertificate, Converter={StaticResource objConverter}, ConverterParameter=false:Visible:Collapsed }"-->
<TextBlock Text="无需合格证" Height="15" Margin="5 0 0 0"
/>
<c:BButton Content="修改" Style="{StaticResource LinkButton}" Width="35" Height="15" CommandParameter="{Binding }"
Command="{Binding DataContext.SetCertificateCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
/>
</StackPanel >
</StackPanel>
</StackPanel>
</DockPanel>
</StackPanel>
</Grid>

16
BBWYB.Client/Views/Web.xaml.cs

@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.Messaging.Messages;
using Microsoft.Extensions.DependencyInjection;
using SJ.Controls;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@ -24,16 +25,24 @@ namespace BBWYB.Client.Views
var sp = (App.Current as App).ServiceProvider;
using (var s = sp.CreateScope())
{
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>();
w2m = new WebView2Manager();
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>();
}
WeakReferenceMessenger.Default.Register<Message_WebB_LoginCompleted>(this, (o, x) =>
{
this.Dispatcher.BeginInvoke(initWebView);
});
}
//public void InitCookieList()
//{
//}
private void Web_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
@ -44,9 +53,9 @@ namespace BBWYB.Client.Views
{
#if DEBUG
var url = "http://qtbbwy.qiyue666.com";
//var registerName = "webContext";
var registerName = "webContext";
//var url = "http://192.168.1.2:8080";
var registerName = "webTestContext";
//var registerName = "webTestContext";//webTestContext
//var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");
#else
var url = "http://qtbbwy.qiyue666.com";
@ -55,6 +64,7 @@ namespace BBWYB.Client.Views
//var url = "http://qtbbwy.qiyue666.com";
w2m.CoreWebView2InitializationCompleted = (e) =>
{
globalContext.CurryWindow = this;
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext);
isNavigated = true;
w2m.wb2.CoreWebView2.Navigate(url);

4
BBWYB.Client/WebView2Manager.cs

@ -8,7 +8,7 @@ namespace BBWYB.Client
{
public class WebView2Manager : IDenpendency
{
public WebView2 wb2 { get; private set; }
public Microsoft.Web.WebView2.Wpf.WebView2 wb2 { get; private set; }
//public WebView2Manager()
//{
// Init();
@ -17,7 +17,7 @@ namespace BBWYB.Client
{
if (wb2 == null)
{
wb2 = new WebView2();
wb2 = new Microsoft.Web.WebView2.Wpf.WebView2();
var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: io.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), folderName)).Result;
wb2.EnsureCoreWebView2Async(wb2Setting);
wb2.CoreWebView2InitializationCompleted += Wb2_CoreWebView2InitializationCompleted;

4
BBWYB.Client/appsettings.json

@ -1,6 +1,6 @@
{
//"BBWYApiHost": "http://localhost:5000",
"BBWYApiHost": "http://bbwyb.qiyue666.com",
"BBWYApiHost": "http://localhost:5000",
//"BBWYApiHost": "http://bbwyb.qiyue666.com",
"MDSApiHost": "http://mdsapi.qiyue666.com",
"BBWYCApiHost": "http://bbwytest.qiyue666.com",
"QKApiHost": "http://localhost:8080"

1
BBWYB.Server.API/BBWYB.Server.API.csproj

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="FreeSql" Version="3.2.690" />
<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.690" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.60" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.14" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.14" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

15
BBWYB.Server.API/Controllers/PurchaseOrderController.cs

@ -38,6 +38,17 @@ namespace BBWYB.Server.API.Controllers
{
purchaseOrderBusiness.CreatePurchaseOrder(request);
}
/// <summary>
/// 网页创建采购单
/// </summary>
/// <param name="request"></param>
[HttpPost]
public void WebCreatePurchaseOrder([FromBody] WebCreateOrderRequest request)
{
purchaseOrderBusiness.WebCreatePurchaseOrder(request);
}
/// <summary>
/// 获取关联采购单列表
@ -185,5 +196,9 @@ namespace BBWYB.Server.API.Controllers
message = "成功"
});
}
}
}

1
BBWYB.Server.Business/BBWYB.Server.Business.csproj

@ -20,6 +20,7 @@
<ItemGroup>
<PackageReference Include="FreeSql" Version="3.2.690" />
<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.690" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.60" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.2-mauipre.1.22102.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />

604
BBWYB.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -1,6 +1,7 @@
using BBWYB.Common.Http;
using BBWYB.Common.Log;
using BBWYB.Common.Models;
using BBWYB.Server.Business._1688Helper;
using BBWYB.Server.Business.Extensions;
using BBWYB.Server.Business.JD;
using BBWYB.Server.Model;
@ -22,6 +23,7 @@ using SDKAdapter.PurchasePlatform.Models;
using System.Text;
using System.Text.RegularExpressions;
using Yitter.IdGenerator;
using static SDKAdapter.AdapterEnums;
namespace BBWYB.Server.Business
{
@ -3377,5 +3379,607 @@ namespace BBWYB.Server.Business
}
return list;
}
public void WebCreatePurchaseOrder(WebCreateOrderRequest request)
{
nLogManager.Default().Info($"CreatePurchaseOrder\r\n{JsonConvert.SerializeObject(request)}");
var dbOrder = fsql.Select<Order>(request.OrderId).ToOne();
if (dbOrder == null)
throw new BusinessException("订单不存在");
if (cantPurchaseOrderStateList.Contains(dbOrder.OrderState.Value))
throw new BusinessException($"当前订单状态:{dbOrder.OrderState},不允许采购");
if (request.Consignee == null ||
string.IsNullOrEmpty(request.Consignee.Address) ||
string.IsNullOrEmpty(request.Consignee.Mobile) ||
string.IsNullOrEmpty(request.Consignee.ContactName))
throw new BusinessException("缺少收货人信息");
if (request.PurchaseAccountList == null || request.PurchaseAccountList.Count() == 0)
throw new BusinessException("缺少采购账号");
if (request.CargoParamGroupList == null || request.CargoParamGroupList.Count() == 0)
throw new BusinessException("缺少下单商品参数");
if (request.CargoParamGroupList.Any(g => string.IsNullOrEmpty(g.PurchaserId)))
throw new BusinessException("缺少采购商Id");
if (request.CargoParamGroupList.GroupBy(c => c.PurchaserId).Any(g => g.Count() > 1))
throw new BusinessException("提交采购商包含重复");
//if (string.IsNullOrEmpty(request.WaitPayOrderId))
// throw new BusinessException("缺少待支付订单号");
#region 验证同一个批次中,一个订单sku不能同时拥有多个采购方案
IDictionary<string, long> schemeValidationDictionary = new Dictionary<string, long>();
foreach (var purchaseGroup in request.CargoParamGroupList)
{
foreach (var cargo in purchaseGroup.CargoParamList)
{
if (!schemeValidationDictionary.ContainsKey(cargo.BelongSkuId))
schemeValidationDictionary.TryAdd(cargo.BelongSkuId, cargo.SchemeId);
if (schemeValidationDictionary.TryGetValue(cargo.BelongSkuId, out long schemeId))
{
if (cargo.SchemeId != schemeId)
{
throw new BusinessException($"订单sku{cargo.BelongSkuId}只允许使用一个采购方案进行下单");
}
}
}
}
schemeValidationDictionary.Clear();
#endregion
string cookies = request.LoginCookies;
var isRepurchase = fsql.Select<OrderCost>(dbOrder.Id).Any();
var orderSkus = fsql.Select<OrderSku>().Where(osku => osku.OrderId == request.OrderId).ToList();
var orderPurchaseInfoList = fsql.Select<OrderPurchaseInfo>().Where(opi => opi.OrderId == request.OrderId && opi.IsEnabled == true).ToList();
var orderCostDetailList = fsql.Select<OrderCostDetail>().Where(ocd => ocd.OrderId == request.OrderId && ocd.IsEnabled == true).ToList();
var orderSkuCostList = fsql.Select<OrderSkuCost>().Where(osc => osc.OrderId == request.OrderId).ToList();
foreach (var cargoParamGroup in request.CargoParamGroupList)
{
var purchaseOrder = orderPurchaseInfoList.FirstOrDefault(opi => opi.PurchaserId == cargoParamGroup.PurchaserId);
if (purchaseOrder != null)
{
foreach (var cargoParam in cargoParamGroup.CargoParamList)
{
if (purchaseOrder.BelongSkuIds.Contains(cargoParam.BelongSkuId))
{
//throw new BusinessException($"订单sku[{cargoParam.BelongSkuId}]已经存在同一个商家[{cargoParamGroup.PurchaserId}][{cargoParamGroup.PurchaserName}]的另一笔采购单中[{purchaseOrder.PurchaseOrderId}],请不要为同一笔订单sku进行同商家采购");
throw new BusinessException($"提示:请勿为同一个订单中的sku重复向同一个商家下采购单\r\n重复信息:\r\n- 订单sku:{cargoParam.BelongSkuId}\r\n- 商家:{cargoParamGroup.PurchaserName}");
}
}
}
}
var extJArray = JsonConvert.DeserializeObject<JArray>(request.Extensions);
List<OrderCostDetail> insertOrderCostDetails = new List<OrderCostDetail>();
List<OrderPurchaseInfo> insertOrderPurchaseInfos = new List<OrderPurchaseInfo>();
List<OrderPurchaseSkuInfo> insertOrderPurchaseSkuInfos = new List<OrderPurchaseSkuInfo>();
List<IUpdate<PurchaseScheme>> updatePurchaseSchemeList = new List<IUpdate<PurchaseScheme>>();
//List<IUpdate<PurchaseSchemeProductSku>> updatePssList = new List<IUpdate<PurchaseSchemeProductSku>>();
List<OrderPurchaseRelationInfo> insertOrderPurchaseRelationInfoList = new List<OrderPurchaseRelationInfo>();
List<string> updatePurchaseTimeLimitTaskOrderSkuList = new List<string>();
List<IUpdate<Purchaser>> updatePurchaserList = new List<IUpdate<Purchaser>>();
List<SkuHistoryPurchaserRelation> insertSkuHistoryPurchaserRelationList = new List<SkuHistoryPurchaserRelation>();
List<SkuOptimizationHistory> insertSkuOptimizationHistoryList = new List<SkuOptimizationHistory>();
//List<long> updateSkuOptimizationPurhcasementByIdList = new List<long>();
List<QiKuPackTaskSkuPurchaseSchemeIdRequest> notifyQikuPackSchemeParamList = null;
if (dbOrder.IntoStoreType == Enums.IntoStoreType.)
notifyQikuPackSchemeParamList = new List<QiKuPackTaskSkuPurchaseSchemeIdRequest>();
IInsert<OrderCost> insertOrderCost = null;
IUpdate<OrderCost> updateOrderCost = null;
List<OrderSkuCost> insertOrderSkuCostList = new List<OrderSkuCost>();
IList<IUpdate<OrderSkuCost>> updateOrderSkuCostList = new List<IUpdate<OrderSkuCost>>();
List<PP_QueryOrderDetailSkuResponse> createdPurchaseOrderItemList = new List<PP_QueryOrderDetailSkuResponse>();
foreach (var cargoParamGroup in request.CargoParamGroupList)
{
var purchaseAccount = request.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == cargoParamGroup.PurchasePlatform);
if (purchaseAccount == null)
throw new BusinessException($"缺少{cargoParamGroup.PurchasePlatform}采购平台账号,请在店铺配置中设置");
var client = ppPlatformClientFactory.GetClient((AdapterEnums.PlatformType)cargoParamGroup.PurchasePlatform);
var extJson = extJArray.FirstOrDefault(j => j.Value<string>("PurchaserId") == cargoParamGroup.PurchaserId);
var orderProductParamList = CombineRepeatPurchaseSku(cargoParamGroup.CargoParamList);
//var createOrderResponse = client.CreateOrder(new PP_CreateOrderRequest()
//{
// AppKey = purchaseAccount.AppKey,
// AppSecret = purchaseAccount.AppSecret,
// AppToken = purchaseAccount.AppToken,
// Consignee = new PP_ConsigneeRequest()
// {
// Address = request.Consignee.Address,
// City = request.Consignee.City,
// ContactName = request.Consignee.ContactName,
// County = request.Consignee.County,
// Mobile = request.Consignee.Mobile,
// Province = request.Consignee.Province,
// TelePhone = request.Consignee.TelePhone,
// Town = request.Consignee.Town
// },
// Platform = (AdapterEnums.PlatformType)purchaseAccount.PurchasePlatformId,
// PurchaseMode = (AdapterEnums.PurchaseMode)request.PurchaseOrderMode,
// Extensions = extJson.Value<string>("OrderTradeTypeCode"),
// Remark = !string.IsNullOrEmpty(cargoParamGroup.Remark) ? cargoParamGroup.Remark : request.Remark,
// OrderProductParamList = orderProductParamList
//});
Collect1688Helper collect1688Helper = new Collect1688Helper(cookies);
var adress = request.Consignee.Province + request.Consignee.City + request.Consignee.Town + request.Consignee.Address;
var orderModel = (Model.Enums.OrderModel)request.PurchaseOrderMode;
var prewOrder = collect1688Helper.PrewOrder(orderProductParamList.ToList(), adress, orderModel, request.Consignee.Mobile, request.Consignee.ContactName);
if (prewOrder == null)
{
throw new BusinessException($"登录失效,正在重新登陆,登录后点击下单!");
}
var remark = !string.IsNullOrEmpty(cargoParamGroup.Remark) ? cargoParamGroup.Remark : request.Remark;
var createOrderResponse = collect1688Helper.CommitOrder(prewOrder, remark);
if (!createOrderResponse.Success)
{
throw new BusinessException($"{createOrderResponse.Msg}");
}
var purchaseOrderId = createOrderResponse.Data;
var purchaseOrderSimpleInfo = client.QueryOrderDetail(new PP_QueryOrderDetailRequest()
{
AppKey = purchaseAccount.AppKey,
AppSecret = purchaseAccount.AppSecret,
AppToken = purchaseAccount.AppToken,
OrderId = purchaseOrderId
});
createdPurchaseOrderItemList.AddRange(purchaseOrderSimpleInfo.ItemList);
//totalPurchaseProductAmount += purchaseOrderSimpleInfo.ProductAmount;
//totalPurchaseFreight += purchaseOrderSimpleInfo.FreightAmount;
#region 创建订单采购关系
foreach (var cargoParam in cargoParamGroup.CargoParamList)
{
var orderSku = orderSkus.FirstOrDefault(osku => osku.SkuId == cargoParam.BelongSkuId);
insertOrderPurchaseRelationInfoList.Add(new OrderPurchaseRelationInfo()
{
Id = idGenerator.NewLong(),
BelongSkuId = cargoParam.BelongSkuId,
CreateTime = DateTime.Now,
OrderId = request.OrderId,
PurchaseOrderId = purchaseOrderSimpleInfo.OrderId,
PurchaseProductId = cargoParam.ProductId,
PurchaseSkuId = cargoParam.SkuId,
PurchaseSpecId = cargoParam.SpecId,
Quantity = cargoParam.Quantity,
SchemeId = cargoParam.SchemeId,
SourceSkuId = orderSku?.BelongSkuId,
SchemeVersion = cargoParam.SchemeVersion ?? 1
});
}
#endregion
#region 等比计算采购成本
var proportionalCalculationResultList = ProportionalCalculationCost(cargoParamGroup.CargoParamList, purchaseOrderSimpleInfo);
foreach (var proportionalCalculationResult in proportionalCalculationResultList)
{
var skuId = proportionalCalculationResult.SkuId;
var orderSku = orderSkus.FirstOrDefault(osku => osku.SkuId == skuId);
var orderCostDetail = new OrderCostDetail()
{
Id = idGenerator.NewLong(),
CreateTime = DateTime.Now,
DeductionQuantity = orderSku.ItemTotal.Value,
OrderId = request.OrderId,
ProductId = orderSku.ProductId,
PurchaseOrderId = purchaseOrderSimpleInfo.OrderId,
SkuId = skuId,
IsEnabled = true
};
orderCostDetail.CalculationOrderCostDetailCostAndProfit(proportionalCalculationResult.ProductAmount,
proportionalCalculationResult.FreightAmount,
0M,
0M);
insertOrderCostDetails.Add(orderCostDetail);
}
#endregion
#region 采购订单信息
var belongSkuIdList = cargoParamGroup.CargoParamList.Select(c => c.BelongSkuId).Distinct().ToList();
var orderPurchaserInfo = new OrderPurchaseInfo()
{
Id = idGenerator.NewLong(),
OrderId = request.OrderId,
CreateTime = DateTime.Now,
PurchaseAccountId = purchaseAccount.Id,
PurchaseAccountName = purchaseAccount.AccountName,
PurchaseMethod = Enums.PurchaseMethod.线,
OrderState = Enums.PurchaseOrderState.,
PurchaseOrderId = purchaseOrderId,
PurchasePlatform = cargoParamGroup.PurchasePlatform,
PurchaserId = cargoParamGroup.PurchaserId,
PurchaserName = cargoParamGroup.PurchaserName,
ShopId = request.ShopId,
BelongSkuIds = string.Join(",", belongSkuIdList),
IsEnabled = true,
Remark = !string.IsNullOrEmpty(cargoParamGroup.Remark) ? cargoParamGroup.Remark : request.Remark,
UpdateTime = DateTime.Now
};
insertOrderPurchaseInfos.Add(orderPurchaserInfo);
#endregion
#region 采购订单Sku信息
foreach (var purchaseOrderSku in purchaseOrderSimpleInfo.ItemList)
{
var orderPurchaseSkuInfo = new OrderPurchaseSkuInfo()
{
Id = purchaseOrderSku.OrderSkuId,
CreateTime = DateTime.Now,
OrderId = request.OrderId,
PurchaseOrderId = purchaseOrderSimpleInfo.OrderId,
PurchaseProductId = purchaseOrderSku.ProductId,
PurchaseSkuId = purchaseOrderSku.SkuId,
ShopId = request.ShopId,
PurchasedPrice = purchaseOrderSku.Price,
PurchasedAmount = purchaseOrderSku.ProductAmount,
PurchasedItemCount = purchaseOrderSku.Quantity
};
insertOrderPurchaseSkuInfos.Add(orderPurchaseSkuInfo);
}
#endregion
#region 采购限时任务
foreach (var belongSkuId in belongSkuIdList)
{
if (!updatePurchaseTimeLimitTaskOrderSkuList.Any(x => x == belongSkuId))
updatePurchaseTimeLimitTaskOrderSkuList.Add(belongSkuId);
}
#endregion
#region 封装查询齐库合格证接口参数
if (dbOrder.IntoStoreType == Enums.IntoStoreType.)
{
foreach (var belongSkuId in belongSkuIdList) //订单skuId
{
var orderSku = orderSkus.FirstOrDefault(osku => osku.SkuId == belongSkuId);
if (orderSku == null)
continue;
var cargoParam = cargoParamGroup.CargoParamList.FirstOrDefault(c => c.BelongSkuId == belongSkuId);
if (cargoParam == null)
continue;
if (!notifyQikuPackSchemeParamList.Any(x => x.SkuId == orderSku.BelongSkuId))
{
notifyQikuPackSchemeParamList.Add(new QiKuPackTaskSkuPurchaseSchemeIdRequest()
{
SkuId = orderSku.BelongSkuId,
SkuPurchaseSchemeId = cargoParam.SchemeId.ToString(),
SchemeVersion = cargoParam.SchemeVersion ?? 1
});
}
}
}
#endregion
}
#region 更新采购方案/配件
{
var allCargoParamList = new List<CargoParamRequest>();
request.CargoParamGroupList.ForEach(x => allCargoParamList.AddRange(x.CargoParamList));
#region 更新采购方案
{
var cargoParamGroupsBySchemeList = allCargoParamList.GroupBy(c => c.SchemeId);
foreach (var cargoParamGroupsByScheme in cargoParamGroupsBySchemeList)
{
var schemeId = cargoParamGroupsByScheme.Key;
var skuId = cargoParamGroupsByScheme.FirstOrDefault().BelongSkuId;
var skuItemCount = orderSkus.FirstOrDefault(osku => osku.SkuId == skuId)?.ItemTotal ?? 0;
//var lastPurchasePriceCost = cargoParamGroupsByScheme.Sum(cargoParam => createdPurchaseOrderItemList.Where(x => x.SkuId == cargoParam.SkuId)
// .Select(x => x.Price * (cargoParam.PurchaseRatio ?? 1))
// .DefaultIfEmpty(0M)
// .First());
var lastPurchasePriceCost = cargoParamGroupsByScheme.Sum(cargoParam =>
{
return (createdPurchaseOrderItemList.FirstOrDefault(x => x.SkuId == cargoParam.SkuId)?.Price ?? 0) * (cargoParam.PurchaseRatio ?? 1);
});
var purchasedAmount = insertOrderCostDetails.Where(ocd => ocd.SkuId == skuId).Sum(ocd => ocd.SkuAmount);
var update = fsql.Update<PurchaseScheme>(schemeId).Set(ps => ps.LastPurchaseTime, DateTime.Now)
.Set(ps => ps.LastPurchasePriceCost, lastPurchasePriceCost)
.Set(ps => ps.PurchasedCount + 1)
.Set(ps => ps.PurchasedItemCount + skuItemCount)
.Set(ps => ps.PurchasedAmount + purchasedAmount);
updatePurchaseSchemeList.Add(update);
}
}
#endregion
//#region 更新采购配件
//{
// foreach (var cargoParam in allCargoParamList)
// {
// var createOrderItem = createdPurchaseOrderItemList.FirstOrDefault(x => x.SkuId == cargoParam.SkuId);
// if (createOrderItem != null)
// {
// var update = fsql.Update<PurchaseSchemeProductSku>()
// .Set(pss => pss.LastPurchasePriceCost, createOrderItem.Price)
// .Where(pss => pss.PurchaseSkuId == cargoParam.SkuId && pss.SkuPurchaseSchemeId == cargoParam.SchemeId);
// updatePssList.Add(update);
// }
// }
//}
//#endregion
}
#endregion
#region 更新采购商
{
var purchaserIdList = new List<string>();
var purchaserSkuDictionary = new Dictionary<string, List<string>>();
request.CargoParamGroupList.ForEach(x =>
{
purchaserIdList.Add(x.PurchaserId);
purchaserSkuDictionary.Add(x.PurchaserId, x.CargoParamList.Select(c => c.BelongSkuId).Distinct().ToList());
});
//采购商的sku采购关系表
var dbSkuAndPurchaserRelationList = fsql.Select<SkuHistoryPurchaserRelation>()
.Where(spr => purchaserIdList.Contains(spr.PurchaserId) && spr.ShopId == request.ShopId)
.ToList();
var dbPurchaserList = fsql.Select<Purchaser>(purchaserIdList).ToList();
foreach (var purchaserId in purchaserIdList)
{
purchaserSkuDictionary.TryGetValue(purchaserId, out var fromRequestSkuList);
var fromDBSkuList = dbSkuAndPurchaserRelationList.Where(x => x.PurchaserId == purchaserId)
.Select(x => x.SkuId)
.Distinct()
.ToList();
var exceptSkuList = fromRequestSkuList.Except(fromDBSkuList);
var newSkuRelationCount = exceptSkuList.Count();
if (newSkuRelationCount > 0)
{
insertSkuHistoryPurchaserRelationList.AddRange(exceptSkuList.Select(x => new SkuHistoryPurchaserRelation()
{
Id = idGenerator.NewLong(),
CreateTime = DateTime.Now,
PurchaserId = purchaserId,
ShopId = request.ShopId,
SkuId = x
}));
}
#region 更新采购商归属
var purchaser = dbPurchaserList.FirstOrDefault(p => p.Id == purchaserId);
if (purchaser != null && !string.IsNullOrEmpty(purchaser.BelongBargainTeamId) && purchaser.BelongType == Enums.PurchaserBelongType.)
{
var updatePurchaser = fsql.Update<Purchaser>(purchaserId).Set(p => p.BelongType, Enums.PurchaserBelongType.);
updatePurchaserList.Add(updatePurchaser);
}
#endregion
}
}
#endregion
#region 订单Sku成本
var allOrderCostDetail = orderCostDetailList.Union(insertOrderCostDetails).ToList();
foreach (var orderSku in orderSkus)
{
var orderSkuCost = orderSkuCostList.FirstOrDefault(osc => osc.SkuId == orderSku.SkuId);
if (orderSkuCost == null)
{
orderSkuCost = new OrderSkuCost()
{
Id = idGenerator.NewLong(),
CreateTime = DateTime.Now,
OrderId = request.OrderId,
SkuId = orderSku.SkuId
};
orderSkuCost.CalculationOrderSkuCostAndProfit(orderSku, allOrderCostDetail);
insertOrderSkuCostList.Add(orderSkuCost);
}
else
{
orderSkuCost.CalculationOrderSkuCostAndProfit(orderSku, allOrderCostDetail);
var update = fsql.Update<OrderSkuCost>().SetSource(orderSkuCost);
updateOrderSkuCostList.Add(update);
}
}
#endregion
#region 订单成本
var orderCost = new OrderCost()
{
OrderId = request.OrderId,
CreateTime = DateTime.Now,
IsManualEdited = false
};
//var totalPurchaseProductAmount = orderCostDetailList.Union(insertOrderCostDetails).Sum(ocd => ocd.SkuAmount);
//var totalPurchaseFreight = orderCostDetailList.Union(insertOrderCostDetails).Sum(ocd => ocd.PurchaseFreight);
//orderCost.CalculationOrderCostAndProfit(dbOrder.OrderTotalPrice.Value,
// totalPurchaseProductAmount ?? 0M,
// totalPurchaseFreight ?? 0M,
// 0M,
// 0M);
var allOrderSkuCostList = orderSkuCostList.Union(insertOrderSkuCostList).ToList();
orderCost.CalculationOrderCostAndProfit(dbOrder.OrderTotalPrice.Value, allOrderSkuCostList);
if (!isRepurchase)
{
insertOrderCost = fsql.Insert(orderCost);
}
else
{
updateOrderCost = fsql.Update<OrderCost>().SetSource(orderCost).IgnoreColumns(a => new { a.CreateTime });
}
#endregion
#region 订单状态
dbOrder.CalculationOrderState(fsql, orderSkus, orderPurchaseInfoList.Union(insertOrderPurchaseInfos).ToList());
#endregion
#region 通知C端状态
Task.Factory.StartNew(() => SendPurchaseOrderStateToC(dbOrder.Id, dbOrder.OrderState.Value), CancellationToken.None, TaskCreationOptions.None, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler);
#endregion
#region 查询齐库合格证
if (dbOrder.IntoStoreType == Enums.IntoStoreType. &&
notifyQikuPackSchemeParamList != null &&
notifyQikuPackSchemeParamList.Count() > 0)
{
Task.Factory.StartNew(() => qiKuManager.SearchCerConfigured(dbOrder, notifyQikuPackSchemeParamList, orderSkus), CancellationToken.None, TaskCreationOptions.None, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler);
}
#endregion
//#region 创建优化历史
//{
// //本批次在线采购的订单sku集合
// var allBelongSkuIdList = request.CargoParamGroupList.SelectMany(cg => cg.CargoParamList.Select(c => c.BelongSkuId)).Distinct().ToList();
// //var optimizationSkuIdList = orderSkus.Where(osku => osku.IsOptimizationCompleted == 1 && allBelongSkuIdList.Contains(osku.SkuId))
// // .Select(osku => osku.SkuId)
// // .ToList();
// var optimizationTaskList = fsql.Select<SkuOptimizationTask>()
// .Where(s => allBelongSkuIdList.Contains(s.SkuId) &&
// s.IsOptimizationCompleted == true &&
// s.IsPurchasementCompleted == false)
// .ToList();
// var optimizationSkuIdList = optimizationTaskList.Select(s => s.SkuId).Distinct().ToList();
// if (optimizationSkuIdList.Count() > 0)
// {
// //优化历史
// var optimizationHistoryList = fsql.Select<SkuOptimizationHistory>()
// .Where(s1 => s1.ShopId == request.ShopId && optimizationSkuIdList.Contains(s1.SkuId))
// .GroupBy(s1 => s1.SkuId)
// .WithTempQuery(g => new { MaxId = g.Max(g.Value.Id) })
// .From<SkuOptimizationHistory>()
// .InnerJoin((s1, s2) => s1.MaxId == s2.Id)
// .ToList((s1, s2) => s2);
// foreach (var optimizationSkuId in optimizationSkuIdList)
// {
// var orderSkuCost = allOrderSkuCostList.FirstOrDefault(x => x.SkuId == optimizationSkuId);
// if (orderSkuCost == null)
// continue;
// var orderSku = orderSkus.FirstOrDefault(x => x.SkuId == optimizationSkuId);
// var lastHistory = optimizationHistoryList.FirstOrDefault(x => x.SkuId == optimizationSkuId);
// var currentPurchasePrice = orderSkuCost.SkuAmount / orderSku.ItemTotal;
// var ratio = (lastHistory?.LastPurchasePrice ?? 0) == 0 ? 0 : 1 - currentPurchasePrice / lastHistory.LastPurchasePrice;
// var newOptimizationHistory = new SkuOptimizationHistory()
// {
// Id = idGenerator.NewLong(),
// CreateTime = DateTime.Now,
// CurrentPurchasePrice = orderSkuCost.SkuAmount / orderSku.ItemTotal,
// ProductId = orderSku.ProductId,
// ShopId = request.ShopId,
// SkuId = optimizationSkuId,
// LastPurchasePrice = lastHistory?.LastPurchasePrice ?? 0,
// OptimizationRatio = ratio,
// TriggerOptimizationReason = orderSku.TriggerOptimizationReason
// };
// insertSkuOptimizationHistoryList.Add(newOptimizationHistory);
// var skuOptimizationTask = optimizationTaskList.FirstOrDefault(x => x.SkuId == optimizationSkuId);
// if (skuOptimizationTask != null)
// updateSkuOptimizationPurhcasementByIdList.Add(skuOptimizationTask.Id);
// }
// }
//}
//#endregion
fsql.Transaction(() =>
{
if (updatePurchaseTimeLimitTaskOrderSkuList.Count() > 0)
{
fsql.Update<TimeLimitTask>().Set(t => t.CompletionTime, DateTime.Now)
.SetIf(dbOrder.PayTime != null, t => t.IsTimely == (DateTime.Now < t.ExpirationTime ? true : false))
.Where(t => t.OrderId == request.OrderId)
.Where(t => updatePurchaseTimeLimitTaskOrderSkuList.Contains(t.SkuId))
.Where(t => t.CompletionTime == null)
.Where(t => t.TaskType == Enums.TimeLimitTaskType.)
.ExecuteAffrows();
}
if (insertOrderCostDetails.Count() > 0)
fsql.Insert(insertOrderCostDetails).ExecuteAffrows();
if (insertOrderPurchaseInfos.Count() > 0)
fsql.Insert(insertOrderPurchaseInfos).ExecuteAffrows();
if (insertOrderPurchaseSkuInfos.Count() > 0)
fsql.Insert(insertOrderPurchaseSkuInfos).ExecuteAffrows();
if (insertOrderPurchaseRelationInfoList.Count() > 0)
fsql.Insert(insertOrderPurchaseRelationInfoList).ExecuteAffrows();
if (insertSkuHistoryPurchaserRelationList.Count() > 0)
fsql.Insert(insertSkuHistoryPurchaserRelationList).ExecuteAffrows();
if (insertSkuOptimizationHistoryList.Count() > 0)
fsql.Insert(insertSkuOptimizationHistoryList).ExecuteAffrows();
updateOrderCost?.ExecuteAffrows();
insertOrderCost?.ExecuteAffrows();
if (updatePurchaseSchemeList.Count() > 0)
{
foreach (var update in updatePurchaseSchemeList)
update.ExecuteAffrows();
}
//if (updatePssList.Count() > 0)
//{
// foreach (var update in updatePssList)
// update.ExecuteAffrows();
//}
fsql.Update<Order>(request.OrderId).Set(o => o.OrderState, dbOrder.OrderState)
.SetIf(!string.IsNullOrEmpty(request.Remark), o => o.PurchaseRemark, request.Remark)
.Set(o => o.IsPurchased, true)
.ExecuteAffrows();
if (insertOrderSkuCostList.Count() > 0)
fsql.Insert(insertOrderSkuCostList).ExecuteAffrows();
if (updateOrderSkuCostList.Count() > 0)
{
foreach (var update in updateOrderSkuCostList)
update.ExecuteAffrows();
}
//if (updateSkuOptimizationPurhcasementByIdList.Count() > 0)
// fsql.Update<SkuOptimizationTask>(updateSkuOptimizationPurhcasementByIdList).Set(s => s.IsPurchasementCompleted, true).ExecuteAffrows();
if (updatePurchaserList.Count() > 0)
{
foreach (var update in updatePurchaserList)
update.ExecuteAffrows();
}
});
//#region 更新采购方案最新价格
//Task.Factory.StartNew(() =>
//{
// try
// {
// purchaseSchemeBusiness.RefreshPurchaseScheme(new RefreshSchemeRequest()
// {
// SchemeIdList = updatePurchaseTimeSchemeIdList
// });
// }
// catch { }
//}, CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.PurchaseOrderCallbackTaskScheduler);
//#endregion
}
}
}

2
BBWYB.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs

@ -326,7 +326,7 @@ namespace BBWYB.Server.Business
{
if (jobject["data"][locationIdList[i]] != null)
{
location = jobject["data"][locationIdList[i]]["data"]["location"].ToString();
location = jobject["data"][locationIdList[i]]["data"]["location"]?.ToString();
if (string.IsNullOrEmpty(location))
continue;
break;

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

@ -369,8 +369,10 @@ namespace BBWYB.Server.Business
});
var noCurrentBargainTeamList = dbPurchaserList.Where(dp => !string.IsNullOrEmpty(dp.BelongBargainTeamId) &&
dp.BelongBargainTeamId != uInfo.bargainTeam.Id).ToList();
//if (noCurrentBargainTeamList.Count() > 0)
// throw new BusinessException($"不能包含被其他议价组使用的采购商 [{string.Join(",", noCurrentBargainTeamList.Select(x => x.Name))}]");
if (noCurrentBargainTeamList.Count() > 0)
throw new BusinessException($"不能包含被其他议价组使用的采购商 [{string.Join(",", noCurrentBargainTeamList.Select(x => x.Name))}]");
throw new BusinessException($"该商品的供应商,已归属其他议价组.保存失败~!\r\n{string.Join(",", noCurrentBargainTeamList.Select(x => x.Name))}");
}
#endregion

2
BBWYB.Server.Business/SkuOptimization/OptimizationBusiness.cs

@ -318,7 +318,7 @@ namespace BBWYB.Server.Business
//SkuId = waitCheckOrderSku.SkuId,
TaskType = Enums.TimeLimitTaskType.,
TaskId = spuOptimizationTask.Id,
Remark = "首次采购限时任务"
Remark = $"{reason}限时任务"
});
}
#endregion

1
BBWYB.Server.Business/Vender/VenderBusiness.cs

@ -88,6 +88,7 @@ namespace BBWYB.Server.Business
.Set(pa => pa.AppToken, shopSettingRequest.AppToken)
.Set(pa => pa.AccountName, shopSettingRequest.AccountName)
.Set(pa => pa.PurchasePlatformId, ((int)shopSettingRequest.PurchasePlatformId).ToString())
.Set(pa => pa.Password, shopSettingRequest.Password)
.ExecuteAffrows();
}
return shopSettingRequest.PurchaseAccountId;

939
BBWYB.Server.Business/_1688Helper/Collect1688Helper.cs

File diff suppressed because one or more lines are too long

28
BBWYB.Server.Business/_1688Helper/Md5Helper.cs

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Server.Business._1688Helper
{
public class Md5Helper
{
//32位小写
public static string Md5_32(string str)
{
string cl = str;
string pwd = "";
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();//实例化一个md5对像
// 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
byte[] s = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(cl));
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
for (int i = 0; i < s.Length; i++)
{
//将得到的字符串使用16进制类型格式
pwd = pwd + s[i].ToString("X");
}
return pwd.ToLower();
}
}
}

7
BBWYB.Server.Model/Db/MDS/Purchaseaccount.cs

@ -55,6 +55,11 @@ namespace BBWYB.Server.Model.Db.MDS
[Column(StringLength = 50)]
public string ShopId { get; set; }
}
/// <summary>
/// 采购密码
/// </summary>
public string Password { get; set; }
}
}

9
BBWYB.Server.Model/Dto/Request/PurchaseOrder/CreateOrderRequest.cs

@ -22,4 +22,13 @@
/// </summary>
public long ShopId { get; set; }
}
public class WebCreateOrderRequest: CreateOrderRequest
{
//public string WaitPayOrderId { get; set; }
/// <summary>
/// 1688登录的Cookies
/// </summary>
public string LoginCookies { get; set; }
}
}

2
BBWYB.Server.Model/Dto/Request/PurchaseOrder/PreviewOrderRequest.cs

@ -22,4 +22,6 @@ namespace BBWYB.Server.Model.Dto
public List<CargoParamGroupRequest> CargoParamGroupList { get; set; }
}
}

2
BBWYB.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs

@ -34,5 +34,7 @@
/// 采购平台
/// </summary>
public Enums.Platform PurchasePlatformId { get; set; }
public string Password { get; set; }
}
}

17
BBWYB.Server.Model/Dto/_1688/AddressModel.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Server.Model._1688
{
public class AddressModel
{
public string AddressDetail { get; set; }
public string DivisionZip { get; set; }
public string MobileNO { get; set; }
public string PersonalName { get; set; }
public string AddressCode { get; set; }
}
}

111
BBWYB.Server.Model/Dto/_1688/OrderParameter.cs

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Server.Model._1688
{
public class OrderParameter
{
public string Csrf_token { get; set; }
public string OrderUrl { get; set; }
public string Lvid { get; set; }
public List<OrderGroupParameter> OrderGroupParameterList { get; set; }
public string Address { get; set; }
public string TownCode { get; set; }
public string IpvId { get; set; }
}
public class OrderGroupParameter
{
/// <summary>
/// 优惠券id
/// </summary>
public string PromotionId { get; set; }
/// <summary>
/// 1使用优惠券 0不使用优惠券
/// </summary>
public int ChooseFreeFreight { get; set; }
public decimal SumCarriage { get; set; }
public decimal DiscountFee { get; set; }
public decimal TotalProductAmount { get; set; }
public decimal ActualPay { get; set; }
public int PayFee { get; set; }
public int ActualPayFee { get; set; }
public string Group { get; set; }
public string StepName { get; set; }
public string OrderOutId { get; set; }
public string MemberId { get; set; }
//sellerUserId
public string SellerUserId { get; set; }
////transportType
//public string TransportType { get; set; }
////tplCode
//public string TplCode { get; set; }
//belong
public string Belong { get; set; }
public List<OrderProductParameter> OrderProductParameterList { get; set; }
}
public class OrderProductParameter
{
public decimal DiscountFee { get; set; }
public decimal SumCarriage { get; set; }
public string ProductId { get; set; }
public string SkuId { get; set; }
public string SpectId { get; set; }
public string CargoKey { get; set; }
public decimal UnitPrice { get; set; }
public decimal ProductAmount { get; set; }
public int Quantity { get; set; }
public string FreightId { get; set; }
//outId
public string OutId { get; set; }
public string? OfferPriceRangeJson { get; set; }
/// <summary>
/// 优惠券
/// </summary>
public string Couple { get; set; }
/// <summary>
/// 1使用优惠券 0不使用优惠券
/// </summary>
public int ChooseFreeFreight { get; set; }
public string Ext { get; set; }
public decimal MixAmount { get; set; }
}
}

22
BBWYB.Server.Model/Dto/_1688/OrderProduct.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Server.Model._1688
{
public class OrderProduct
{
public string ProductId { get; set; }
public string SkuId { get; set; }
public string SpectId { get; set; }
//数量
public int Quantity { get; set; }
}
}

26
BBWYB.Server.Model/Dto/_1688/PrewOrderResponse.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static BBWYB.Server.Model.Enums;
namespace BBWYB.Server.Model._1688
{
public class PrewOrderResponse
{
public OrderParameter orderParameter { get; set; }
public OrderModel OrderModel { get; set; }
public AddressModel AddressModel { get; set; }
public decimal TotalProductAmount { get; set; }
public decimal SumCarriage { get; set; }
//总订单金额
public decimal ActualPay { get; set; }
}
}

15
BBWYB.Server.Model/Dto/_1688/ProductModel.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Server.Model._1688
{
public class ProductModel
{
public int MixNumber { get; set; }
public string IpvId { get; set; }
}
}

21
BBWYB.Server.Model/Dto/_1688/_1688CookieModel.cs

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BBWYB.Server.Model._1688
{
public class _1688CookieModel
{
public string Cookie { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public DateTime LoginTime { get; set; }
}
}

10
BBWYB.Server.Model/Enums.cs

@ -381,5 +381,15 @@
= 11,
= 12
}
/// <summary>
/// 下单类型(批发(general)=0,代发(fenxiao=1)
/// </summary>
public enum OrderModel
{
general = 0,//批发
fenxiao = 1//代发
}
}
}

Loading…
Cancel
Save