Esempio 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.HimallIO.GetImagePath(item.CertPic1),
                    CertPic2         = Core.HimallIO.GetImagePath(item.CertPic2),
                    CertPic3         = Core.HimallIO.GetImagePath(item.CertPic3),
                    ReasonDetail     = item.ReasonDetail,
                    ManagerRemark    = item.ManagerRemark,
                    RefundMode       = item.RefundMode.GetHashCode(), //退款方式
                    ReturnQuantity   = item.ReturnQuantity,           //退货数量
                };
                orderResults.Add(refundModel);
            }
            #endregion

            return(orderResults);
        }
Esempio n. 2
0
        public static bool BranchCanBuy(long userId, long productId, int count, string skuId, long shopBranchId, out int reason)
        {
            var product = Service.GetProduct(productId);

            if (product.SaleStatus != Entities.ProductInfo.ProductSaleStatus.OnSale || product.AuditStatus != Entities.ProductInfo.ProductAuditStatus.Audited)
            {
                //商城商品下架,但是门店的商品状态销售中,允许用户购买。
                //商城商品下架后,销售状态-仓库中,审核状态-待审核
                if (product.SaleStatus != Entities.ProductInfo.ProductSaleStatus.InStock && product.AuditStatus != Entities.ProductInfo.ProductAuditStatus.WaitForAuditing)
                {
                    reason = 1;
                    return(false);
                }
            }
            var sku = ProductManagerApplication.GetSKU(skuId);

            if (sku == null)
            {
                reason = 2;
                return(false);
            }
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                reason = 4;
                return(false);
            }
            var shopBranchSkuList = ShopBranchApplication.GetSkusByIds(shopBranchId, new List <string> {
                skuId
            });

            if (shopBranchSkuList == null || shopBranchSkuList.Count == 0 || shopBranchSkuList[0].Status == ShopBranchSkuStatus.InStock)
            {
                reason = 2;
                return(false);
            }
            var sbsku = shopBranchSkuList.FirstOrDefault();

            if (sbsku.Stock < count)
            {
                reason = 9;
                return(false);
            }
            if (product.IsDeleted)
            {
                reason = 2;
                return(false);
            }

            if (product.MaxBuyCount <= 0)
            {
                reason = 0;
                return(true);
            }

            var buyedCounts = OrderApplication.GetProductBuyCount(userId, new long[] { productId });

            if (product.MaxBuyCount < count + (buyedCounts.ContainsKey(productId) ? buyedCounts[productId] : 0))
            {
                reason = 3;
                return(false);
            }
            reason = 0;
            return(true);
        }