Browse Source

店铺设置切换平台,关联订单切换平台

qianyi
shanji 2 years ago
parent
commit
3b76d3082d
  1. 14
      BBWY.Client/Models/Order/OrderDropShipping.cs
  2. 54
      BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
  3. 46
      BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs
  4. 22
      BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs
  5. 2
      BBWY.Client/Views/Setting/ShopSetting.xaml
  6. 8
      BBWY.Server.Business/Vender/VenderBusiness.cs
  7. 5
      BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs

14
BBWY.Client/Models/Order/OrderDropShipping.cs

@ -19,7 +19,17 @@ namespace BBWY.Client.Models
public decimal DeliveryFreight { get => deliveryFreight; set { Set(ref deliveryFreight, value); } }
public string PurchaseOrderId { get => purchaseOrderId; set { Set(ref purchaseOrderId, value); } }
public string MerchantOrderId { get => merchantOrderId; set { Set(ref merchantOrderId, value); } }
public Platform PurchasePlatform { get => purchasePlatform; set { Set(ref purchasePlatform, value); } }
public Platform PurchasePlatform
{
get => purchasePlatform;
set
{
if (Set(ref purchasePlatform, value))
{
OnPurchasePlatformChanged?.Invoke(this);
}
}
}
public decimal PurchaseAmount { get => purchaseAmount; set { Set(ref purchaseAmount, value); } }
public decimal SkuAmount
@ -71,6 +81,8 @@ namespace BBWY.Client.Models
[JsonIgnore]
public Action OnPurchaseAmountChanged { get; set; }
[JsonIgnore]
public Action<OrderDropShipping> OnPurchasePlatformChanged { get; set; }
public object Clone()
{

54
BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs

@ -161,7 +161,6 @@ namespace BBWY.Client.ViewModels
tradeMode = string.Empty;
ProductAmount = FreightAmount = TotalAmount = 0;
ContactName = Address = Mobile = Province = City = County = Town = PrucahseRemark = string.Empty;
}
private void LoadPurchaseProduct(Platform platform, PurchaseSchemeProduct purchaseSchemeProduct, OrderSku orderSku, ManualResetEvent ewh)
@ -192,55 +191,6 @@ namespace BBWY.Client.ViewModels
ewh.Dispose();
}
//private IList<PurchaseSchemeProductSku> LoadPurchaseProductCore(PurchaseSchemeProduct purchaseSchemeProduct, out string errorMsg)
//{
// errorMsg = string.Empty;
// //1688商品详情接口
// var response = oneBoundAPIService.GetProductInfo("1688", purchaseSchemeProduct.PurchaseProductId);
// if (!response.Success)
// {
// //记录日志
// errorMsg = response.Msg;
// Console.WriteLine(errorMsg);
// return null;
// }
// var jobject = response.Data;
// var skuJArray = (JArray)jobject["item"]["skus"]["sku"];
// if (skuJArray.Count == 0)
// {
// errorMsg = $"商品{purchaseSchemeProduct.PurchaseProductId}缺少sku信息";
// return null;
// }
// return skuJArray.Select(j => new PurchaseSchemeProductSku()
// {
// ProductId = purchaseSchemeProduct.ProductId,
// SkuId = purchaseSchemeProduct.SkuId,
// PurchaseProductId = purchaseSchemeProduct.PurchaseProductId,
// Price = j.Value<decimal>("price"),
// PurchaseSkuId = j.Value<string>("sku_id"),
// PurchaseSkuSpecId = j.Value<string>("spec_id"),
// Title = j.Value<string>("properties_name"),
// Logo = GetSkuLogo(j, (JArray)jobject["item"]["prop_imgs"]["prop_img"])
// }).ToList();
//}
private string GetSkuLogo(JToken skuJToken, JArray prop_img)
{
if (!prop_img.HasValues)
return "pack://application:,,,/Resources/Images/defaultItem.png";
var properties = skuJToken.Value<string>("properties").Split(';', StringSplitOptions.RemoveEmptyEntries);
foreach (var p in properties)
{
var imgJToken = prop_img.FirstOrDefault(g => g.Value<string>("properties") == p);
if (imgJToken != null)
return imgJToken.Value<string>("url");
}
return "pack://application:,,,/Resources/Images/defaultItem.png";
}
private void OnItemTotalChanged(int itemTotal)
{
@ -255,7 +205,7 @@ namespace BBWY.Client.ViewModels
IsLoading = false;
return;
}
if (string.IsNullOrEmpty(ContactName) ||
string.IsNullOrEmpty(Address) ||
string.IsNullOrEmpty(Mobile) ||
@ -279,7 +229,7 @@ namespace BBWY.Client.ViewModels
Province = Province,
TelePhone = Mobile,
Town = Town
}, PurchaseSchemeProductSkuList, Platform., purchaseAccount, PurchaseOrderMode))
}, PurchaseSchemeProductSkuList, purchaseAccount.PurchasePlatformId, purchaseAccount, PurchaseOrderMode))
.ContinueWith(t =>
{
IsLoading = false;

46
BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs

@ -29,8 +29,11 @@ namespace BBWY.Client.ViewModels
private string siNanDingDingKey;
private SiNanPolicyLevel selectedSiNanPolicyLevel;
private Platform purchasePlatform;
public ICommand SaveCommand { get; set; }
public ICommand SetPanelIndexCommand { get; set; }
public PurchaseAccount PurchaseAccount { get => purchaseAccount; set { Set(ref purchaseAccount, value); } }
@ -52,6 +55,19 @@ namespace BBWY.Client.ViewModels
public string SiNanDingDingKey { get => siNanDingDingKey; set { Set(ref siNanDingDingKey, value); } }
public SiNanPolicyLevel SelectedSiNanPolicyLevel { get => selectedSiNanPolicyLevel; set { Set(ref selectedSiNanPolicyLevel, value); } }
/// <summary>
/// 采购平台
/// </summary>
public Platform PurchasePlatform
{
get => purchasePlatform;
set
{
if (Set(ref purchasePlatform, value))
OnPurchasePlatformChanged();
}
}
public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService)
{
PanelIndex = 0;
@ -89,6 +105,9 @@ namespace BBWY.Client.ViewModels
protected override void Load()
{
if (globalContext.User.Shop.PurchaseAccountList == null)
globalContext.User.Shop.PurchaseAccountList = new List<PurchaseAccount>();
IsLoading = false;
if (!string.IsNullOrEmpty(globalContext.User.Shop.ManagePwd))
{
@ -99,9 +118,7 @@ namespace BBWY.Client.ViewModels
isValidated = true;
this.ManagePwd = globalContext.User.Shop.ManagePwd;
this.PlatformCommissionRatio = (globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M) * 100;
this.PurchaseAccount = globalContext.User.Shop.PurchaseAccountList == null || globalContext.User.Shop.PurchaseAccountList.Count() == 0 ?
new PurchaseAccount() :
globalContext.User.Shop.PurchaseAccountList[0].Clone() as PurchaseAccount;
DingDingKey = globalContext.User.Shop.DingDingKey;
DingDingWebHook = globalContext.User.Shop.DingDingWebHook;
SelectedSkuSafeTurnoverDay = SafeDayList.FirstOrDefault(s => s.Value == globalContext.User.Shop.SkuSafeTurnoverDays.ToString());
@ -109,11 +126,13 @@ namespace BBWY.Client.ViewModels
SelectedSiNanPolicyLevel = (SiNanPolicyLevel)globalContext.User.Shop.SiNanPolicyLevel;
SiNanDingDingKey = globalContext.User.Shop.SiNanDingDingKey;
SiNanDingDingWebHook = globalContext.User.Shop.SiNanDingDingWebHook;
PurchasePlatform = Platform.;
}
protected override void Unload()
{
this.PurchaseAccount = null;
//this.PurchaseAccount = null;
this.PlatformCommissionRatio = 0M;
this.ManagePwd = string.Empty;
this.isValidated = false;
@ -163,11 +182,7 @@ namespace BBWY.Client.ViewModels
return;
}
if (globalContext.User.Shop.PurchaseAccountList == null)
globalContext.User.Shop.PurchaseAccountList = new List<PurchaseAccount>();
globalContext.User.Shop.PurchaseAccountList.Clear();
PurchaseAccount.Id = response.Data;
globalContext.User.Shop.PurchaseAccountList.Add(PurchaseAccount);
globalContext.User.Shop.PlatformCommissionRatio = p;
globalContext.User.Shop.ManagePwd = this.ManagePwd;
globalContext.User.Shop.DingDingKey = this.DingDingKey;
@ -179,5 +194,20 @@ namespace BBWY.Client.ViewModels
globalContext.User.Shop.SiNanPolicyLevel = (int)this.SelectedSiNanPolicyLevel;
});
}
private void OnPurchasePlatformChanged()
{
var pa = globalContext.User.Shop.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == PurchasePlatform);
if (pa == null)
{
pa = new PurchaseAccount()
{
PurchasePlatformId = PurchasePlatform,
};
globalContext.User.Shop.PurchaseAccountList.Add(pa);
}
this.PurchaseAccount = pa;
}
}
}

22
BBWY.Client/Views/Order/RelationPurchaseOrder.xaml.cs

@ -87,6 +87,7 @@ namespace BBWY.Client.Views.Order
OrderDropShippingList.Add(ods1);
ods1.OnPurchaseAmountChanged = OnPurchaseAmountChanged;
ods1.OnPurchasePlatformChanged = OnPurchasePlatformChanged;
}
}
@ -99,12 +100,18 @@ namespace BBWY.Client.Views.Order
OnPurchaseAmountChanged();
AddOrderDropShippingCommand = new RelayCommand(() => OrderDropShippingList.Add(new OrderDropShipping()
AddOrderDropShippingCommand = new RelayCommand(() =>
{
OrderId = this.OrderId,
BuyerAccount = PurchaseAccountList.FirstOrDefault()?.AccountName,
OnPurchaseAmountChanged = OnPurchaseAmountChanged
}));
var ods = new OrderDropShipping()
{
OrderId = this.OrderId,
//BuyerAccount = PurchaseAccountList.FirstOrDefault()?.AccountName,
OnPurchaseAmountChanged = OnPurchaseAmountChanged,
OnPurchasePlatformChanged = OnPurchasePlatformChanged
};
ods.PurchasePlatform = Platform.;
OrderDropShippingList.Add(ods);
});
AddRelationPurchaseOrderSkuCommand = new RelayCommand<OrderDropShipping>(AddRelationPurchaseOrderSku);
CloseShowChooseSkuPanelCommand = new RelayCommand(() => IsShowChooseSkuPanel = false);
RePurchaseCommand = new RelayCommand(() =>
@ -197,5 +204,10 @@ namespace BBWY.Client.Views.Order
foreach (var noChooseSku in noChooseList)
ChooseRelationPurchaseOrderSkuList.Add(noChooseSku);
}
private void OnPurchasePlatformChanged(OrderDropShipping orderDropShipping)
{
orderDropShipping.BuyerAccount = PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == orderDropShipping.PurchasePlatform)?.AccountName;
}
}
}

2
BBWY.Client/Views/Setting/ShopSetting.xaml

@ -104,7 +104,7 @@
<TextBlock Text="采购平台" Style="{StaticResource textblockPropertyStyle}"/>
<ComboBox ItemsSource="{Binding Source={StaticResource PlatformProvider}}" Grid.Column="1"
SelectedItem="{Binding PurchaseAccount.PurchasePlatformId}"
SelectedItem="{Binding PurchasePlatform,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="."
Height="25"
Width="150"

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

@ -83,14 +83,6 @@ namespace BBWY.Server.Business
Platform = Enums.Platform.
});
//_ = restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/UpdateShop", new
//{
// venderResponse.ShopName,
// venderResponse.ShopId,
// ShopType = venderResponse.ColType,
// AppToken = jDShopToken.AccessToken,
// venderResponse.VenderId
//}, new Dictionary<string, string>() { { "qy", "qy" } }, HttpMethod.Post);
var shop = freeSqlMultiDBManager.MDSfsql.Select<Shops>().Where(s => s.ShopName == venderResponse.ShopName).ToOne();
if (shop == null)

5
BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs

@ -41,5 +41,10 @@
/// 采购商Id
/// </summary>
public string PurchaserId { get; set; }
/// <summary>
/// 扩展数据
/// </summary>
public string Extensions { get; set; }
}
}

Loading…
Cancel
Save