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.
118 lines
4.5 KiB
118 lines
4.5 KiB
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
|
|
namespace BBWYB.Client.Models
|
|
{
|
|
/// <summary>
|
|
/// 采购方案
|
|
/// </summary>
|
|
public class PurchaseScheme : ObservableObject
|
|
{
|
|
private decimal defaultCost;
|
|
private decimal realCost;
|
|
public long Id { get; set; }
|
|
|
|
public long ShopId { get; set; }
|
|
public string ProductId { get; set; }
|
|
|
|
public string SkuId { get; set; }
|
|
public decimal DefaultCost { get => defaultCost; set { SetProperty(ref defaultCost, value); } }
|
|
public decimal RealCost { get => realCost; set { SetProperty(ref realCost, value); } }
|
|
|
|
//public string PurchaserId { get; set; }
|
|
//public string PurchaserId2 { get; set; }
|
|
public string PurchaserName { get; set; }
|
|
//public string PurchaserLocation { get; set; }
|
|
public string PurchaseProductId1 { get; set; }
|
|
public int PurchaseProductSkuCount1 { get; set; }
|
|
public string PurchaseProductId2 { get; set; }
|
|
public int PurchaseProductSkuCount2 { get; set; }
|
|
public string PurchaseProductId3 { get; set; }
|
|
public int PurchaseProductSkuCount3 { get; set; }
|
|
public string PurchaseProductId4 { get; set; }
|
|
public int PurchaseProductSkuCount4 { get; set; }
|
|
|
|
/// <summary>
|
|
/// 采购平台
|
|
/// </summary>
|
|
//public Platform PurchasePlatform { get; set; }
|
|
|
|
/// <summary>
|
|
/// 最后采购时间
|
|
/// </summary>
|
|
public DateTime? LastPurchaseTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 采购方案的商品集合
|
|
/// </summary>
|
|
public IList<PurchaseSchemeProduct> PurchaseSchemeProductList { get; set; }
|
|
|
|
public List<Purchaser> PurchaserList { get; set; }
|
|
|
|
public PurchaseScheme()
|
|
{
|
|
PurchaseSchemeProductList = new ObservableCollection<PurchaseSchemeProduct>();
|
|
PurchaserList = new List<Purchaser>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否转换方案中已选中的sku
|
|
/// </summary>
|
|
/// <param name="apiModel"></param>
|
|
/// <param name="convertSelectedSku"></param>
|
|
/// <returns></returns>
|
|
public static PurchaseScheme Convert(PurchaseSchemeResponse apiModel)
|
|
{
|
|
var model = new PurchaseScheme()
|
|
{
|
|
Id = apiModel.Id,
|
|
ProductId = apiModel.ProductId,
|
|
SkuId = apiModel.SkuId,
|
|
DefaultCost = apiModel.DefaultCost ?? 0,
|
|
RealCost = apiModel.RealCost ?? 0
|
|
//PurchaserId = apiModel.PurchaserId,
|
|
//PurchaserName = apiModel.PurchaserName,
|
|
//PurchaserLocation = apiModel.PurchaserLocation,
|
|
//PurchasePlatform = apiModel.PurchasePlatform
|
|
};
|
|
foreach (var p in apiModel.PurchaserList)
|
|
{
|
|
model.PurchaserList.Add(p);
|
|
}
|
|
model.PurchaserName = model.PurchaserList.Count() == 1 ? model.PurchaserList[0].Name : $"{model.PurchaserList[0].Name}等{model.PurchaserList.Count()}个采购商";
|
|
foreach (var apiProduct in apiModel.PurchaseSchemeProductList)
|
|
{
|
|
model.PurchaseSchemeProductList.Add(PurchaseSchemeProduct.Convert(apiProduct));
|
|
}
|
|
for (var i = 0; i < model.PurchaseSchemeProductList.Count; i++)
|
|
{
|
|
var purchaseProductId = model.PurchaseSchemeProductList[i].PurchaseProductId;
|
|
var purchaseProductSkuCount = model.PurchaseSchemeProductList[i].PurchaseSkuCount;
|
|
if (i == 0)
|
|
{
|
|
model.PurchaseProductId1 = purchaseProductId;
|
|
model.PurchaseProductSkuCount1 = purchaseProductSkuCount;
|
|
}
|
|
else if (i == 1)
|
|
{
|
|
model.PurchaseProductId2 = purchaseProductId;
|
|
model.PurchaseProductSkuCount2 = purchaseProductSkuCount;
|
|
}
|
|
else if (i == 2)
|
|
{
|
|
model.PurchaseProductId3 = purchaseProductId;
|
|
model.PurchaseProductSkuCount3 = purchaseProductSkuCount;
|
|
}
|
|
else if (i == 3)
|
|
{
|
|
model.PurchaseProductId4 = purchaseProductId;
|
|
model.PurchaseProductSkuCount4 = purchaseProductSkuCount;
|
|
}
|
|
}
|
|
return model;
|
|
}
|
|
}
|
|
}
|
|
|