using AllBase.Model.Result; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using WPFCommon.Helpers; using WPFCommon.Models; namespace _29WxOrderWpf.Ctrls.PDDInvoice.ViewModels; /// /// 订单发票Model /// public class PddBrowserOrderInvoiceViewModel : BindableBaseEx { private bool _isSelected; /// /// 是否被勾选(用于批量开票) /// public bool IsSelected { get => _isSelected; set => SetProperty(ref _isSelected, value, nameof(IsSelected)); } public string buyerId { get; set; } // 买手Id public string buyerName { get; set; } // 买手名称 /// /// 订单价 /// public int order_amount { get; set; } /// /// 实付款 /// public string display_amount { get; set; } /// /// 下单时间 /// public long order_time { get; set; } /// /// 订单号 /// public string order_sn { get; set; } public int status { get; set; } public int pay_status { get; set; } public string order_status_prompt { get; set; } /// /// 订单详情 /// public string order_link_url { get; set; } public List order_Goods { get; set; } public List order_buttons { get; set; } private string _goodsName; public string GoodsName { get => _goodsName ?? order_Goods?.FirstOrDefault()?.goods_name ?? ""; set => _goodsName = value; } /// /// 是否已开票 /// public bool IsInvoiced { get => GetValue(); set { SetValue(value); base.RaisePropertyChanged(nameof(InvoiceStatusText)); } } public int Quantity => order_Goods?.Sum(a => a.goods_number.Value) ?? 0; /// 发票状态文案:已开票 / 待开票 public string InvoiceStatusText => IsInvoiced ? "已提交申请" : "待开票"; public DateTime OrderTime { get => DateTimeHelper.ConvertFromUnixTimestampInSeconds(order_time); } private string _thumburl; public string ThumbUrl { get { return _thumburl ?? order_Goods?.FirstOrDefault()?.thumb_url ?? ""; } set { _thumburl = value; } } public string DisplayAmount => (order_amount / 100.0).ToString("F2"); public PddBrowserOrderInvoiceViewModel() { } public PddBrowserOrderInvoiceViewModel(OrderInvoiceInfo info) { _goodsName = info.GoodsName; order_amount = info.order_amount; order_time = info.order_time; order_sn = info.order_sn; order_link_url = info.order_link_url; IsInvoiced = info.IsInvoiced; _thumburl = info.ThumbUrl; } } public class OrderButtonItem { public int button_code { get; set; } public string brief_prompt { get; set; } public ButtonTypeValue type_value { get; set; } } public class ButtonTypeValue { public string Url { get; set; } } public class OrderInvoiceInfo { /// /// 订单价 /// public int order_amount { get; set; } /// /// 下单时间 /// public long order_time { get; set; } /// /// 订单号 /// public string order_sn { get; set; } /// /// 订单详情 /// public string order_link_url { get; set; } /// /// 是否已开票 /// public bool IsInvoiced { get; set; } public string ThumbUrl { get; set; } public string GoodsName { get; set; } }