Exemplo n.º 1
0
        /// <summary>
        /// 获取退款记录列表(忽略分页)
        /// </summary>
        /// <param name="refundQuery"></param>
        /// <returns></returns>
        public static List <OrderRefundExportModel> GetAllFullOrderReFunds(RefundQuery refundQuery)
        {
            var data = Service.GetAllOrderRefunds(refundQuery);

            if (data == null || data.Count() <= 0)
            {
                return(new List <OrderRefundExportModel>());
            }

            var orderResults = new List <OrderRefundExportModel>();

            #region 购置OrderRefundExportModel实体
            var orders     = Application.OrderApplication.GetOrders(data.Select(p => p.OrderId));
            var orderItems = Application.OrderApplication.GetOrderItems(data.Select(p => p.OrderItemId));

            foreach (var item in data)
            {
                string strProductName = "订单所有商品";//退款时商品名称
                #region 店名称
                var    order             = orders.Where(p => p.Id == item.OrderId).First();
                string strShopBranchName = order.ShopName;//门店名称
                if (order != null && order.ShopBranchId > 0)
                {
                    var shopBranchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
                    if (shopBranchInfo != null)
                    {
                        strShopBranchName = shopBranchInfo.ShopBranchName;
                    }
                }
                #endregion

                #region 商品名称
                if (item.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund)
                {
                    var    orderItem = orderItems.FirstOrDefault(p => p.Id == item.OrderItemId);
                    string spec      = ((string.IsNullOrWhiteSpace(orderItem.Color) ? "" : orderItem.Color + ",")
                                        + (string.IsNullOrWhiteSpace(orderItem.Size) ? "" : orderItem.Size + ",")
                                        + (string.IsNullOrWhiteSpace(orderItem.Version) ? "" : orderItem.Version + ",")).TrimEnd(',');
                    if (!string.IsNullOrWhiteSpace(spec))
                    {
                        spec = "  【" + spec + " 】";
                    }
                    strProductName = orderItem.ProductName + spec;
                }
                #endregion

                var refundModel = new OrderRefundExportModel()
                {
                    RefundId         = item.Id,
                    OrderId          = item.OrderId,
                    ShopName         = item.ShopName,
                    ProductName      = strProductName,    //商品名称
                    ShopBranchName   = strShopBranchName, //门店名称
                    UserName         = item.Applicant,    //用户名
                    ContactPerson    = item.ContactPerson,
                    ContactCellPhone = item.ContactCellPhone,
                    ApplyDate        = item.ApplyDate.ToString(),
                    SellerRemark     = item.SellerRemark,
                    Amount           = item.Amount.ToString("f2"),
                    RefundStatus     = item.RefundStatus,
                    RefundPayType    = item.RefundPayType.ToDescription(),//退款支付方式
                    Reason           = item.Reason,
                    CertPic1         = Core.MallIO.GetImagePath(item.CertPic1),
                    CertPic2         = Core.MallIO.GetImagePath(item.CertPic2),
                    CertPic3         = Core.MallIO.GetImagePath(item.CertPic3),
                    ReasonDetail     = item.ReasonDetail,
                    ManagerRemark    = item.ManagerRemark,
                    RefundMode       = item.RefundMode.GetHashCode(), //退款方式
                    ReturnQuantity   = item.ReturnQuantity,           //退货数量
                };
                orderResults.Add(refundModel);
            }
            #endregion

            return(orderResults);
        }