using AllBase.Helper;
using AllBase.Model.MvvmBaseClasses;
using NaiBa.Util;
using NaiBa.Util.Extension;
using NPOI.OpenXmlFormats.Dml.Diagram;
using NPOI.OpenXmlFormats.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using Color = System.Windows.Media.Color;
namespace AllBase.Model.DBModel
{
public class oms_wei_order_info : PropertyNotifyObject
{
///
/// 订单对应店铺
///
public ShopLoginInfo Shop
{
get { return this.GetValue(x => x.Shop); }
set { this.SetValue(x => x.Shop, value); }
}
public string OrderDiffItemCountStr
{
get { return this.GetValue(x => x.OrderDiffItemCountStr); }
set { this.SetValue(x => x.OrderDiffItemCountStr, value); }
}
public string OrderBuyType
{
get { return this.GetValue(x => x.OrderBuyType); }
set { this.SetValue(x => x.OrderBuyType, value); OrderBuyTypeVisibility = string.IsNullOrWhiteSpace(value) ? Visibility.Collapsed : Visibility.Visible; }
}
public Visibility OrderBuyTypeVisibility
{
get { return this.GetValue(x => x.OrderBuyTypeVisibility); }
set { this.SetValue(x => x.OrderBuyTypeVisibility, value); }
}
public SolidColorBrush OrderBuyTypeColor
{
get { return this.GetValue(x => x.OrderBuyTypeColor); }
set { this.SetValue(x => x.OrderBuyTypeColor, value); }
}
public ObservableCollection orderItems { get; set; } = new ObservableCollection();
public oms_wei_order_item_info orderItem
{
get { return this.GetValue(x => x.orderItem); }
set { this.SetValue(x => x.orderItem, value); }
}
public oms_wei_order_item_info orderItem2
{
get { return this.GetValue(x => x.orderItem2); }
set { this.SetValue(x => x.orderItem2, value); }
}
public oms_wei_order_item_info orderItem3
{
get { return this.GetValue(x => x.orderItem3); }
set { this.SetValue(x => x.orderItem3, value); }
}
public oms_wei_order_item_info orderItem4
{
get { return this.GetValue(x => x.orderItem4); }
set { this.SetValue(x => x.orderItem4, value); }
}
public oms_wei_order_item_info orderItem5
{
get { return this.GetValue(x => x.orderItem5); }
set { this.SetValue(x => x.orderItem5, value); }
}
public ObservableCollection refundItems { get; set; } = new ObservableCollection();
public ConcurrentList latestEWaybills { get; set; } = new ConcurrentList();
///
/// 待采购
///
public bool IsWaitBuy
{
get { return this.GetValue(x => x.IsWaitBuy); }
set { this.SetValue(x => x.IsWaitBuy, value); }
}
///
/// 待发货
///
public bool IsWaitSend
{
get { return this.GetValue(x => x.IsWaitSend); }
set { this.SetValue(x => x.IsWaitSend, value); }
}
///
/// 待收货
///
public bool IsWaitReceive
{
get { return this.GetValue(x => x.IsWaitReceive); }
set { this.SetValue(x => x.IsWaitReceive, value); }
}
///
/// 售后订单(不含售后关闭) -- 改为售后完成单 260726
///
public bool IsRefund
{
get { return this.GetValue(x => x.IsRefund); }
set { this.SetValue(x => x.IsRefund, value); }
}
///
/// 紧急订单
///
public bool IsEmergency
{
get { return this.GetValue(x => x.IsEmergency); }
set { this.SetValue(x => x.IsEmergency, value); }
}
public bool IsEmergencyDistribReturnOrder
{
get { return this.GetValue(x => x.IsEmergencyDistribReturnOrder); }
set { this.SetValue(x => x.IsEmergencyDistribReturnOrder, value); }
}
public bool IsEmergencyManualReturnOrder
{
get { return this.GetValue(x => x.IsEmergencyManualReturnOrder); }
set { this.SetValue(x => x.IsEmergencyManualReturnOrder, value); }
}
public bool IsDistribReturnOrder
{
get { return this.GetValue(x => x.IsDistribReturnOrder); }
set { this.SetValue(x => x.IsDistribReturnOrder, value); }
}
///
/// 异常单(买手异常退货)异常需重拍
///
public bool IsAbnormal
{
get { return this.GetValue(x => x.IsAbnormal); }
set { this.SetValue(x => x.IsAbnormal, value); }
}
public bool IsShowChangeWaybillBtn
{
get { return this.GetValue(x => x.IsShowChangeWaybillBtn); }
set { this.SetValue(x => x.IsShowChangeWaybillBtn, value); }
}
public bool IsShowTransitExtraPackagesBtn
{
get { return this.GetValue(x => x.IsShowTransitExtraPackagesBtn); }
set { this.SetValue(x => x.IsShowTransitExtraPackagesBtn, value); }
}
public string orderStatusStr
{
get { return this.GetValue(x => x.orderStatusStr); }
set { this.SetValue(x => x.orderStatusStr, value); }
}
public void SetOrderStatusStr()
{
//状态10 待付款;20 待发货;21 部分发货;30 待收货;100 完成;200 全部商品售后之后,订单取消;250 未付款用户主动取消或超时未付款订单自动取消;
if (status == 10)
orderStatusStr = "待付款";
else if (status == 20)
orderStatusStr = "待发货";
else if (status == 21)
orderStatusStr = "部分发货";
else if (status == 30)
orderStatusStr = "待收货";
else if (status == 100)
orderStatusStr = "完成";
else if (status == 200)
orderStatusStr = "已取消";
else if (status == 250)
orderStatusStr = "未付款已取消";
else
orderStatusStr = "未知状态";
}
public string RefundTypeStr
{
get { return this.GetValue(x => x.RefundTypeStr); }
set { this.SetValue(x => x.RefundTypeStr, value); }
}
public DateTime RefundDatetime
{
get { return this.GetValue(x => x.RefundDatetime); }
set { this.SetValue(x => x.RefundDatetime, value); }
}
///
/// 订单生成时间
///
public DateTime CreateDateTime
{
get { return this.GetValue(x => x.CreateDateTime); }
private set { this.SetValue(x => x.CreateDateTime, value); }
}
///
/// 订单更新时间
///
public DateTime UpdateDateTime
{
get { return this.GetValue(x => x.UpdateDateTime); }
private set { this.SetValue(x => x.UpdateDateTime, value); }
}
///
/// 订单发货完成时间
///
public string ShipDoneTimeStr
{
get { return this.GetValue(x => x.ShipDoneTimeStr); }
set { this.SetValue(x => x.ShipDoneTimeStr, value); }
}
///
/// 订单发货完成时间可见
///
public Visibility ShipDoneTimeVisibility
{
get { return this.GetValue(x => x.ShipDoneTimeVisibility); }
set { this.SetValue(x => x.ShipDoneTimeVisibility, value); }
}
void SetShipDoneTimeStr()
{
ShipDoneTimeStr = BaseClass.StampToDateTime(this.ship_done_time.ParseToInt()).ToString("yy-MM-dd HH:mm:ss");
ShipDoneTimeVisibility = this.ship_done_time.ParseToInt() > 0 ? Visibility.Visible : Visibility.Collapsed;
}
///
/// 订单总状态文本
///
public string DeliveryDeadlineStatusStr
{
get { return this.GetValue(x => x.DeliveryDeadlineStatusStr); }
set { this.SetValue(x => x.DeliveryDeadlineStatusStr, value); }
}
void SetDeliveryDeadlineStatusStr()
{
if (this.refundItems.Any(r => "商家受理中,待买家退货,待商家收货,平台退款中,待用户确认,待用户处理商家协商,待用户处理商家代发起的售后申请,物流拦截中".Contains(r.RefundStatusStr)))
DeliveryDeadlineStatusStr = "退款中";
else if (this.refundItems.Any(r => r.RefundStatusStr == "退款完成" || r.RefundStatusStr == "退货退款完成"))
DeliveryDeadlineStatusStr = "退款完成";
// 用户取消申请
else if ((GlobalConfig.OrderTabHeaderStr.StartsWith("售后完成单") || GlobalConfig.OrderTabHeaderStr.StartsWith("需处理售后单") || GlobalConfig.OrderTabHeaderStr.StartsWith("退货仓自动售后单")) &&
this.refundItems.Any(r => !r.RefundStatusStr.IsNullOrEmpty()))
DeliveryDeadlineStatusStr = this.refundItems.FirstOrDefault(r => !r.RefundStatusStr.IsNullOrEmpty()).RefundStatusStr;
else if (this.status == 20 || this.status == 21)
{
DeliveryDeadlineStatusStr = "剩余";
}
else
DeliveryDeadlineStatusStr = "剩余";
}
///
/// 延迟发货时间(微信小店:商品发货时效,超时此时间未发货即为发货超时)文本
///
public string DeliveryDeadlineStr
{
get { return this.GetValue(x => x.DeliveryDeadlineStr); }
set { this.SetValue(x => x.DeliveryDeadlineStr, value); }
}
public void SetDeliveryDeadlineStr()
{
if (this.status == 20 || this.status == 21)
{
var deadlineTime = BaseClass.StampToDateTime(delivery_deadline.ParseToInt());
var nowTime = DateTime.Now;
if (deadlineTime < nowTime)
DeliveryDeadlineStr = "已超时";
else
{
var timeSpan = BaseClass.StampToDateTime(delivery_deadline.ParseToInt()) - nowTime;
var durationStr = Math.Floor(timeSpan.TotalHours).ParseToInt() + "时" + timeSpan.Minutes + "分" + timeSpan.Seconds + "秒";
DeliveryDeadlineStr = durationStr;
}
}
else if (/*this.out_shipped == 1 */this.ship_done_time.ParseToInt() > 0)
DeliveryDeadlineStr = "已发货";
else
DeliveryDeadlineStr = "未发货";
}
public SolidColorBrush StatusBoxForeColor
{
get { return this.GetValue(x => x.StatusBoxForeColor); }
set { this.SetValue(x => x.StatusBoxForeColor, value); }
}
public SolidColorBrush StatusBoxBackColor
{
get { return this.GetValue(x => x.StatusBoxBackColor); }
set { this.SetValue(x => x.StatusBoxBackColor, value); }
}
public SolidColorBrush StatusBoxBorderColor
{
get { return this.GetValue(x => x.StatusBoxBorderColor); }
set { this.SetValue(x => x.StatusBoxBorderColor, value); }
}
public void SetStatusBoxColor()
{
if (DeliveryDeadlineStatusStr == "退款中" || DeliveryDeadlineStr == "已超时")
StatusBoxForeColor = GlobalConfig.RedTextBrush; // #fa4733 250, 71, 51
else if (DeliveryDeadlineStatusStr == "退款完成" || DeliveryDeadlineStr == "已发货")
StatusBoxForeColor = GlobalConfig.GreenTextBrush; // #67c23a 103, 194, 58
else
StatusBoxForeColor = GlobalConfig.CyanBrush; // #0397b5 3, 151, 181
if (DeliveryDeadlineStatusStr == "退款中" || DeliveryDeadlineStr == "已超时")
StatusBoxBackColor = GlobalConfig.RedTextBrush26; // #fa4733 0.2 26, 250, 71, 51
else if (DeliveryDeadlineStatusStr == "退款完成" || DeliveryDeadlineStr == "已发货")
StatusBoxBackColor = GlobalConfig.GreenTextBrush26; // #67c23a 0.2 26, 103, 194, 58
else
StatusBoxBackColor = GlobalConfig.CyanBrush26; // #0397b5 0.2 26, 3, 151, 181
if (DeliveryDeadlineStatusStr == "退款中" || DeliveryDeadlineStr == "已超时")
StatusBoxBorderColor = GlobalConfig.RedTextBrush50; // #fa4733 0.2 50, 250, 71, 51
else if (DeliveryDeadlineStatusStr == "退款完成" || DeliveryDeadlineStr == "已发货")
StatusBoxBorderColor = GlobalConfig.GreenTextBrush50; // #67c23a 0.2 50, 103, 194, 58
else
StatusBoxBorderColor = GlobalConfig.CyanBrush50; // #0397b5 0.2 50, 3, 151, 181
}
public string AddressStr
{
//get { return user_name + " " + tel_number + " " + province_name + " " + city_name + " " + county_name + " " + detail_info; }
//set { }
get { return this.GetValue(x => x.AddressStr); }
set { this.SetValue(x => x.AddressStr, value); }
}
public string OutExpressNoStr
{
get { return this.GetValue(x => x.OutExpressNoStr); }
set { this.SetValue(x => x.OutExpressNoStr, value); }
}
public SolidColorBrush OutExpressNoBrush
{
get { return this.GetValue(x => x.OutExpressNoBrush); }
set { this.SetValue(x => x.OutExpressNoBrush, value); }
}
void SetOutExpressNo()
{
if (this.out_shipped == 2 && !string.IsNullOrEmpty(this.out_express_no))
OutExpressNoStr = this.out_express_no + " ×";
else
OutExpressNoStr = this.out_express_no;
OutExpressNoBrush = OutExpressNoStr.EndsWith(" ×") ? GlobalConfig.RedTextBrush : GlobalConfig.BlackBrush;
}
public string GiftOrderStatusStr
{
get { return this.GetValue(x => x.GiftOrderStatusStr); }
set { this.SetValue(x => x.GiftOrderStatusStr, value); }
}
public bool GiftSuccessed
{
get { return this.GetValue(x => x.GiftSuccessed); }
set { this.SetValue(x => x.GiftSuccessed, value); }
}
public string GiftErrorMsg
{
get { return this.GetValue(x => x.GiftErrorMsg); }
set { this.SetValue(x => x.GiftErrorMsg, value); }
}
public ConcurrentList SyncLogisticsList
{
get { return this.GetValue(x => x.SyncLogisticsList); }
set
{
this.SetValue(x => x.SyncLogisticsList, value);
RealSyncWaybillId = SyncLogisticsList.FirstOrDefault()?.tracking_number;
SyncWaybillIdInfo = SyncLogisticsList.FirstOrDefault()?.tracking_number;
SyncWaybillPickNo = SyncLogisticsList.FirstOrDefault()?.pickup_code;
}
}
public string RealSyncWaybillId
{
get { return this.GetValue(x => x.RealSyncWaybillId); }
set { this.SetValue(x => x.RealSyncWaybillId, value); }
}
public string SyncWaybillIdInfo
{
get { return this.GetValue(x => x.SyncWaybillIdInfo); }
set { this.SetValue(x => x.SyncWaybillIdInfo, value); }
}
public string SyncWaybillPickNo
{
get { return this.GetValue(x => x.SyncWaybillPickNo); }
set { this.SetValue(x => x.SyncWaybillPickNo, value); }
}
///
/// 是否被选中
///
public bool IsSelect
{
get { return this.GetValue(x => x.IsSelect); }
set { this.SetValue(x => x.IsSelect, value); }
}
public Visibility OutAccountStrVisibility
{
get { return this.GetValue(x => x.OutAccountStrVisibility); }
set { this.SetValue(x => x.OutAccountStrVisibility, value); }
}
//public bool is_visible { get; set; } = true;
public long id { get; set; }
public long shop_id { get; set; }
public string shop_name { get; set; }
///
/// 商户ID
///
public string merchant_id { get; set; }
public string order_id { get; set; }
///
/// 买家身份标识
///
public string openid { get; set; }
public int create_time
{
get { return this.GetValue(x => x.create_time); }
set { this.SetValue(x => x.create_time, value); this.CreateDateTime = BaseClass.StampToDateTime(create_time.ParseToInt()); }
}
public int update_time
{
get { return this.GetValue(x => x.update_time); }
set { this.SetValue(x => x.update_time, value); this.UpdateDateTime = BaseClass.StampToDateTime(update_time.ParseToInt()); }
}
public string unionid { get; set; }
///
/// 状态10 待付款;20 待发货;21 部分发货;30 待收货;100 完成;200 全部商品售后之后,订单取消;250 未付款用户主动取消或超时未付款订单自动取消;
///
public int? status
{
get { return this.GetValue(x => x.status); }
set { this.SetValue(x => x.status, value); SetOrderStatusStr(); }
}
///
/// 售后信息json
///
public string aftersale_detail { get; set; }
///
/// 支付信息
///
public string pay_info { get; set; }
///
/// 额外信息
///
public string ext_info { get; set; }
///
/// 商品总价
///
public int? product_price { get; set; }
///
/// 订单金额,单位为分,order_price=original_order_price-discounted_price-deduction_price-change_down_price
///
public int? order_price { get; set; }
///
/// 采购价,单位为分
///
public int? purchase_price { get; set; }
///
/// 采购时间
///
public int? purchase_time { get; set; }
///
/// 运费,单位为分
///
public int? freight { get; set; }
///
/// 平台服务费(微信小店:预计技术服务费),单位为分
///
public int? predict_commission_fee { get; set; }
///
/// 达人佣金(微信小店:分账金额),单位为分
///
public int? commission_amount { get; set; }
///
/// 优惠券优惠金额,单位为分
///
public int? discounted_price { get; set; }
///
/// 利润(实付金额-采购价-平台服务费-达人佣金,达人佣金、采购价为空值则为0)
///
public int? profit { get; set; }
///
/// 采购状态,默认值为:0未采购,推送仓库时修改为1采购
///
public int? purchase_status { get; set; }
///
/// 延迟发货时间(微信小店:商品发货时效,超时此时间未发货即为发货超时)
///
public int? delivery_deadline
{
get { return this.GetValue(x => x.delivery_deadline); }
set { this.SetValue(x => x.delivery_deadline, value); }
}
///
/// 发货时间
///
public int? delivery_time { get; set; }
///
/// 收货人姓名
///
public string user_name { get; set; }
///
/// 邮编
///
public string postal_code { get; set; }
public string province_name { get; set; }
public string city_name { get; set; }
///
/// 区
///
public string county_name { get; set; }
///
/// 详细地址
///
public string detail_info
{
get { return this.GetValue(x => x.detail_info); }
set { this.SetValue(x => x.detail_info, value); }
}
public string tel_number
{
get { return this.GetValue(x => x.tel_number); }
set { this.SetValue(x => x.tel_number, value); }
}
///
/// 门牌号码
///
public string house_number
{
get { return this.GetValue(x => x.house_number); }
set
{
this.SetValue(x => x.house_number, value);
this.AddressStr = user_name + " " + tel_number + " " + province_name + " " + city_name + " " + county_name + " " + detail_info;
if (GlobalConfig.DicDecryptOrderAddress.ContainsKey(this.order_id))
{
var addressOrder = GlobalConfig.DicDecryptOrderAddress[this.order_id];
this.user_name = addressOrder.user_name;
this.tel_number = addressOrder.tel_number;
this.tel_number_ext_info = addressOrder.tel_number_ext_info;
this.province_name = addressOrder.province_name;
this.city_name = addressOrder.city_name;
this.county_name = addressOrder.county_name;
this.detail_info = addressOrder.detail_info;
this.AddressStr = addressOrder.AddressStr;
}
}
}
///
/// 虚拟发货订单联系方式(deliver_method=1时返回)
///
public string virtual_order_tel_number { get; set; }
///
/// 额外的联系方式信息(虚拟号码相关)
///
public string tel_number_ext_info { get; set; }
///
/// 0:不使用虚拟号码,1:使用虚拟号码
///
public int? use_tel_number { get; set; }
///
/// 标识当前店铺下一个唯一的用户收货地址
///
public string hash_code { get; set; }
///
/// 发货物流信息JSON
///
public string delivery_product_info { get; set; }
///
/// 发货完成时间,秒级时间戳
///
public int? ship_done_time { get; set; }
///
/// 电子面单代发时的订单密文
///
public string ewaybill_order_code { get; set; }
///
/// 结算信息json
///
public string settle_info { get; set; }
///
/// 订单审核状态(0待审核1已审核)
///
public int? audit_status { get; set; }
///
/// 订单审核时间
///
public DateTime audit_time { get; set; }
///
/// erp发货快递公司
///
public string erp_send_company { get; set; }
///
/// erp发货快递单号
///
public string erp_send_code { get; set; }
///
/// erp发货状态
///
public int? erp_send_status { get; set; }
///
/// erp发货时间
///
public DateTime erp_send_time { get; set; }
///
/// 旗帜颜色备注,1:灰旗,2:红旗,3:橙旗,4:绿旗,5:天蓝旗,6:紫旗
///
public int? colour_flag
{
get { return this.GetValue(x => x.colour_flag); }
set { this.SetValue(x => x.colour_flag, value); }
}
public SolidColorBrush ColourFlagBrush
{
get { return this.GetValue(x => x.ColourFlagBrush); }
set { this.SetValue(x => x.ColourFlagBrush, value); }
}
///
/// 旗帜备注时间
///
public DateTime colour_flag_update_time { get; set; }
///
/// 供应商备注异常单
///
public string supplier_remark_exception { get; set; }
///
/// 礼物单状态,默认值0:不存在礼物单,1:礼物单已发货,2:礼物单信息已更正 3 礼物单发货失败 4 礼物单已购买但微信发货失败 5 礼物单发货中
///
public int? gift_order_status
{
get { return this.GetValue(x => x.gift_order_status); }
set
{
this.SetValue(x => x.gift_order_status, value);
if (value == 1 || value == 2)
GiftOrderStatusStr = "礼品单已购买";
else if (value == 3)
GiftOrderStatusStr = "礼品单购买失败";
else if (value == 4)
GiftOrderStatusStr = "礼物单已购买但微信发货失败";
else if (value == 5)
GiftOrderStatusStr = "礼物单发货中";
else
GiftOrderStatusStr = "礼品单状态错误";
return;
}
}
///
/// 店铺备注:取微信ext_info.merchant_notes
///
public string shop_remark { get; set; }
///
/// 软件备注
///
public string soft_remark { get; set; }
///
/// 外采金额(单位:分,整数存储)
///
public int? out_amount { get; set; }
///
/// 外采账户
///
public string out_account
{
get { return this.GetValue(x => x.out_account); }
set { this.SetValue(x => x.out_account, value); OutAccountStrVisibility = string.IsNullOrWhiteSpace(value) ? Visibility.Collapsed : Visibility.Visible; }
}
///
/// 外采订单号
///
public string out_order_no { get; set; }
///
/// 外采快递公司
///
public string out_express_company { get; set; }
///
/// 外采快递单号
///
public string out_express_no { get; set; }
///
/// 外采是否发货(0 未发货,1 已发货)
///
public int? out_shipped { get; set; }
///
/// 判断是否优化过发货0 未优化, 1已优化
///
public int? is_shipment_optimized { get; set; }
///
/// 判断是否优随机使用快递单号0 未使用, 1已使用
///
public int? is_express_no_used { get; set; }
///
/// 外采订单售后状态
///
public string out_after_sale_status { get; set; }
///
/// 是否支持运费险:0-不支持,1-支持
///
public int? has_freight_insurance { get; set; }
///
/// 运费险金额(单位:元)
///
public decimal? freight_insurance_amount { get; set; }
///
/// 是否外采礼物单:0-否,1-是(外采订单)
///
public int? external_gift { get; set; }
///
/// 中转仓的状态 0未使用,1已创建,2创建失败(购买失败),3已创建未有上游快递单号,4已创建有上游快递单号
///
public decimal? transfer_warehouse_status { get; set; }
///
/// 店铺运费
///
public int? postage_price { get; set; }
public void SetOrderTextProperty()
{
Shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == shop_id.ParseToString());
if (this.orderItems.Any(oi => oi.OrderItemExt?.buy_type == "直发") && this.orderItems.Any(oi => oi.ItemTransitOrderWithVoid != null))
{
OrderBuyType = "云改直";
OrderBuyTypeColor = GlobalConfig.PurpleBrush190;
}
else if (this.orderItems.Any(oi => oi.OrderItemExt?.buy_type == "直发"))
{
OrderBuyType = "直发";
OrderBuyTypeColor = GlobalConfig.RedTextBrush205;
}
else if (this.orderItems.Any(oi => oi.ItemTransitOrderWithVoid != null))
{
OrderBuyType = "云仓";
OrderBuyTypeColor = GlobalConfig.GreenTextBrush;
}
else
OrderBuyType = "";
if (this.orderItems.Any(oi => oi.ItemRefund?.type == "REFUND"))
this.RefundTypeStr = "仅退款";
else if (this.orderItems.Any(oi => oi.ItemRefund?.type == "RETURN"))
this.RefundTypeStr = "退货退款";
else if (this.orderItems.Any(oi => oi.ItemRefund?.type == "REFUND") && this.orderItems.Any(oi => oi.ItemRefund?.type == "RETURN"))
this.RefundTypeStr = "仅退款/退货退款";
IsWaitBuy = GetIsWaitBuy();
IsWaitSend = GetIsWaitSend();
IsWaitReceive = GetIsWaitReceive();
IsRefund = GetIsRefund();
IsEmergency = GetIsEmergency();
IsDistribReturnOrder = GetIsDistribReturnOrder();
IsEmergencyDistribReturnOrder = IsEmergency && IsDistribReturnOrder;
IsEmergencyManualReturnOrder = IsEmergency && !IsDistribReturnOrder;
IsAbnormal = GetIsAbnormal();
if (IsWaitBuy/* || IsWaitSend*/)
IsShowChangeWaybillBtn = false;
else
IsShowChangeWaybillBtn = true;
if (IsWaitBuy || this.orderItems.All(oi => oi.ItemTransitOrderWithVoid == null))
IsShowTransitExtraPackagesBtn = false;
else
IsShowTransitExtraPackagesBtn = true;
SetDeliveryDeadlineStatusStr();
SetDeliveryDeadlineStr();
SetStatusBoxColor();
SetOutExpressNo();
SetShipDoneTimeStr();
SetColorBrush();
orderItem = orderItems.FirstOrDefault() != null ? orderItems.FirstOrDefault() : new oms_wei_order_item_info() { OrderItemVisibility = Visibility.Collapsed };
orderItem2 = orderItems.Count > 1 ? orderItems[1] : new oms_wei_order_item_info() { OrderItemVisibility = Visibility.Collapsed };
orderItem3 = orderItems.Count > 2 ? orderItems[2] : new oms_wei_order_item_info() { OrderItemVisibility = Visibility.Collapsed };
orderItem4 = orderItems.Count > 3 ? orderItems[3] : new oms_wei_order_item_info() { OrderItemVisibility = Visibility.Collapsed };
orderItem5 = orderItems.Count > 4 ? orderItems[4] : new oms_wei_order_item_info() { OrderItemVisibility = Visibility.Collapsed };
OrderDiffItemCountStr = orderItems.Count > 1 ? "该订单共有 " + orderItems.Count + " 个不同的商品规格" : "";
}
public void SetColorBrush()
{
if (this.colour_flag.ParseToInt() == 2)
ColourFlagBrush = (SolidColorBrush)Application.Current.Resources["FlagRedBrush"];
else if (colour_flag.ParseToInt() == 3)
ColourFlagBrush = (SolidColorBrush)Application.Current.Resources["FlagOrangeBrush"];
else if (colour_flag.ParseToInt() == 4)
ColourFlagBrush = (SolidColorBrush)Application.Current.Resources["FlagGreenBrush"];
else if (colour_flag.ParseToInt() == 5)
ColourFlagBrush = (SolidColorBrush)Application.Current.Resources["FlagBlueBrush"];
else if (colour_flag.ParseToInt() == 6)
ColourFlagBrush = (SolidColorBrush)Application.Current.Resources["FlagPurpleBrush"];
else
ColourFlagBrush = (SolidColorBrush)Application.Current.Resources["FlagGrayBrush"];
}
public bool GetIsWaitBuy()
{
if (order_id == "3738686976228742912")
{
}
if (status != 20 && status != 21)
return false;
if (refundItems?.Any(r => r.IsRefund) == true)
return false;
// 子表有售后信息(可能更新不及时)
if (orderItems?.Any(oi => oi.refund_status > 1) == true)
return false;
// 中转仓有拍单信息
if (orderItems.All(oi => oi.ItemTransitOrder != null))
return false;
// 采购状态为已采购
if (purchase_status != 0)
return false;
// 礼物单已发货
if (gift_order_status == 1 || gift_order_status == 2)
return false;
// 直发订单未退款
// out_after_sale_status 新拍订单也不会变,内存里直接根据退款单修改掉
if (!string.IsNullOrEmpty(out_order_no) && out_after_sale_status != "退款成功")
return false;
return true;
}
private bool GetIsWaitSend()
{
if (order_id == "3738622310043515392")
{
}
if (status != 20 && status != 21)
return false;
if (refundItems?.Any(r => r.IsRefund) == true)
return false;
if (orderItems?.Any(oi => oi.refund_status > 1) == true)
return false;
// 礼物单已发货
if (gift_order_status == 1 || gift_order_status == 2)
return false;
// 店铺未发货,外采已采购
// out_after_sale_status 新拍订单也不会变,内存里直接根据退款单修改掉
if (!orderItems.All(oi => oi.ItemTransitOrder != null) && purchase_status != 1 &&
(string.IsNullOrEmpty(out_order_no) || out_after_sale_status == "退款成功"))
return false;
return true;
}
private bool GetIsWaitReceive()
{
if (refundItems?.Any(r => r.IsRefund) == true)
return false;
if (orderItems?.Any(oi => oi.refund_status > 1) == true)
return false;
if (!(status == 30 || status == 100 || gift_order_status == 1 || gift_order_status == 2))
return false;
return true;
}
public bool GetIsAbnormal()
{
// 三退或者两退,为退款完成单
//if (orderItems.All(oi => (oi.refund_status == 4 || oi.refund_status == 11) && (oi.ItemTransitOrder != null || string.IsNullOrWhiteSpace(out_order_no)) &&
// (oi.ItemTransitOrder == null || oi.ItemTransitOrder?.refund_status == "买手退款成功") && (string.IsNullOrWhiteSpace(out_order_no) || out_after_sale_status == "退款成功")))
// return false;
// 订单完成而非退货,肯定不是异常单
if (status == 100)
return false;
// 如果有售后,直接作为售后单处理
if (orderItems.All(oi => oi.refund_status > 1))
return false;
// 直发或者云改直已购买且未退货,从异常单移除
if (orderItems.All(oi => oi.DirectPddBuyerOrder != null && oi.DirectPddBuyerAfterSale == null) /*&& (out_shipped != 2 || string.IsNullOrEmpty(this.out_express_no))*/)
return false;
if (gift_order_status == 1 || gift_order_status == 2)
return false;
if (orderItems.Any(oi => !(oi.OrderItemExt?.abnormal_text).IsNullOrEmpty()))
return true;
// 订单无售后或者售后关闭,有未作废的仓库单且仓库单买手信息为退款成功
if (orderItems.Any(oi => oi.refund_status <= 1 && oi.ItemTransitOrder != null && oi.ItemTransitOrder.refund_status == "买手退款成功"))
return true;
// 取号异常或无法调用发货也放在异常单(异常需重拍)
// 订单不满足鸿浩仓库发货条件,无法调用鸿浩仓库接口发货
else if (orderItems.Any(oi => ((oi.ItemTransitOrderWithVoid?.raw_message).ParseToString().Contains("取号异常") ||
(oi.ItemTransitOrderWithVoid?.raw_message).ParseToString().Contains("无法调用")) &&
oi.ItemTransitOrderWithVoid?.transfer_warehouse_status != 1))
return true;
return false;
}
public bool GetIsRefund()
{
// return refundItems?.Count > 0 && refundItems.Any(r => r.status != "USER_CANCELD");
if (!orderItems.Any(oi => oi.refund_status > 1))
return false;
if (GetIsEmergency())
return false;
return true;
}
public bool GetIsEmergency()
{
// 微信订单退货中
if (orderItems.Any(oi => oi.refund_status == 2 || oi.refund_status == 3))
{
return true;
}
// 微信订单退款中或退款成功,但是买手订单未完成退款
if (orderItems.Any(oi => oi.refund_status > 1 && oi.ItemTransitOrders.Count > 0 && oi.ItemTransitOrders.Any(t => !t.refund_status.Contains("退款成功"))))
{
return true;
}
if (orderItems.Any(oi => oi.refund_status > 1) && !out_order_no.IsNullOrEmpty() && this.out_after_sale_status != "退款成功")
{
return true;
}
return false;
}
public bool GetIsDistribReturnOrder()
{
//return this.orderItems.All(oi => !string.IsNullOrEmpty(oi.ItemRefund?.return_waybill_id)) && this.orderItems.All(oi => oi.ItemRefund?.return_detail == GlobalConfig.TransitReturnOrderReturnAddress);
//return this.orderItems.All(oi => oi.ItemRefund?.return_detail == GlobalConfig.TransitReturnOrderReturnAddress);
return this.orderItems.All(oi => oi.ItemRefund?.return_detail?.ToUpper().Contains(GlobalConfig.TransitReturnOrderReturnAddressLite) == true);
}
}
}