Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        /// <summary>
        /// 更新商品
        /// </summary>
        /// <param name="product">修改后的商品</param>
        /// <param name="pics">需要转移的商品图片地址</param>
        /// <param name="skus">skus,至少要有一项</param>
        /// <param name="description">描述</param>
        /// <param name="attributes">商品属性</param>
        /// <param name="goodsCategory">商家分类</param>
        /// <param name="sellerSpecifications">商家自定义规格</param>
        public static void UpdateProduct(Product product, string[] pics, SKU[] skus, ProductDescription description, ProductAttribute[] attributes, long[] goodsCategory, SellerSpecificationValue[] sellerSpecifications, ProductLadderPrice[] prices)
        {
            var productInfo = Service.GetProduct(product.Id);

            if (productInfo == null)
            {
                throw new HimallException("指定id对应的数据不存在");
            }

            var editStatus = productInfo.EditStatus;

            if (product.ProductName != productInfo.ProductName)
            {
                editStatus = GetEditStatus(editStatus);
            }
            if (product.ShortDescription != productInfo.ShortDescription)
            {
                editStatus = GetEditStatus(editStatus);
            }

            product.AddedDate = productInfo.AddedDate;
            if (productInfo.SaleStatus != Entities.ProductInfo.ProductSaleStatus.InDraft)
            {
                product.SaleStatus = productInfo.SaleStatus;
            }
            product.AuditStatus       = productInfo.AuditStatus;
            product.DisplaySequence   = productInfo.DisplaySequence;
            product.ShopId            = productInfo.ShopId;
            product.HasSKU            = productInfo.HasSKU;
            product.ImagePath         = productInfo.ImagePath;
            product.SaleCounts        = productInfo.SaleCounts;
            product.VirtualSaleCounts = productInfo.VirtualSaleCounts;

            if (product.IsOpenLadder)
            {
                editStatus = GetEditStatus(editStatus);
            }

            productInfo.ColorAlias   = product.ColorAlias;
            productInfo.SizeAlias    = product.SizeAlias;
            productInfo.VersionAlias = product.VersionAlias;
            productInfo.VideoPath    = product.VideoPath;
            product.DynamicMap(productInfo);

            productInfo.EditStatus = editStatus;

            var skuInofs                 = skus.Map <Entities.SKUInfo[]>();
            var descriptionInfo          = description.Map <Entities.ProductDescriptionInfo>();
            var attributeInfos           = attributes.Map <Entities.ProductAttributeInfo[]>();
            var sellerSpecificationInfos = sellerSpecifications.Map <Entities.SellerSpecificationValueInfo[]>();
            var ladderpricesInfos        = prices.Select(p =>
            {
                var ladder       = new Entities.ProductLadderPriceInfo();
                ladder.Id        = p.Id;
                ladder.MinBath   = p.MinBath;
                ladder.MaxBath   = p.MaxBath;
                ladder.ProductId = p.ProductId;
                ladder.Price     = p.Price;
                return(ladder);
            }).ToArray();

            Service.UpdateProduct(productInfo, pics, skuInofs, descriptionInfo, attributeInfos, goodsCategory,
                                  sellerSpecificationInfos, ladderpricesInfos);
            if (productInfo.IsOpenLadder)
            {
                //处理门店
                ShopBranchApplication.UnSaleProduct(productInfo.Id);
            }
            CreateHtml(product.Id);
        }
        /// <summary>
        /// 查询附近门店
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public static QueryPageModel <ShopBranch> SearchNearShopBranchs(ShopBranchQuery search)
        {
            QueryPageModel <ShopBranchInfo> queryPageModel = ShopBranchApplication._shopBranchService.SearchNearShopBranchs(search);

            return(new QueryPageModel <ShopBranch>()
            {
                Models = Enumerable.ToList <ShopBranch>(Enumerable.Select <ShopBranchInfo, ShopBranch>((IEnumerable <ShopBranchInfo>)queryPageModel.Models, (Func <ShopBranchInfo, ShopBranch>)(e =>
                {
                    ShopBranch shopBranch1 = new ShopBranch();
                    shopBranch1.AddressDetail = ShopBranchApplication.RenderAddress(e.AddressPath, e.AddressDetail, 1);
                    shopBranch1.ContactPhone = e.ContactPhone;
                    shopBranch1.Id = e.Id;
                    shopBranch1.ShopBranchName = e.ShopBranchName;
                    shopBranch1.Status = e.Status;
                    shopBranch1.DistanceUnit = e.Distance >= 1.0 ? (string)(object)e.Distance + (object)"KM" : (string)(object)(e.Distance * 1000.0) + (object)"M";
                    shopBranch1.Distance = e.Distance;
                    ShopBranch shopBranch2 = shopBranch1;
                    int?serveRadius;
                    int num1;
                    if (!e.ServeRadius.HasValue)
                    {
                        num1 = 0;
                    }
                    else
                    {
                        serveRadius = e.ServeRadius;
                        num1 = serveRadius.Value;
                    }
                    shopBranch2.ServeRadius = num1;
                    ShopBranch shopBranch3 = shopBranch1;
                    float?nullable;
                    double num2;
                    if (!e.Latitude.HasValue)
                    {
                        num2 = 0.0;
                    }
                    else
                    {
                        nullable = e.Latitude;
                        num2 = (double)nullable.Value;
                    }
                    shopBranch3.Latitude = (float)num2;
                    ShopBranch shopBranch4 = shopBranch1;
                    nullable = e.Longitude;
                    double num3;
                    if (!nullable.HasValue)
                    {
                        num3 = 0.0;
                    }
                    else
                    {
                        nullable = e.Longitude;
                        num3 = (double)nullable.Value;
                    }
                    shopBranch4.Longitude = (float)num3;
                    shopBranch1.DeliveFee = e.DeliveFee;
                    shopBranch1.DeliveTotalFee = e.DeliveTotalFee;
                    shopBranch1.IsAboveSelf = e.IsAboveSelf;
                    shopBranch1.IsStoreDelive = e.IsStoreDelive;
                    shopBranch1.ShopImages = HimallIO.GetRomoteImagePath(e.ShopImages, (string)null);
                    shopBranch1.ShopId = e.ShopId;
                    shopBranch1.FreeMailFee = e.FreeMailFee;
                    ShopBranch shopBranch5 = shopBranch1;
                    int num4;
                    if (!e.IsAboveSelf)
                    {
                        if (e.IsStoreDelive)
                        {
                            double distance = e.Distance;
                            serveRadius = e.ServeRadius;
                            if ((distance > (double)serveRadius.GetValueOrDefault() ? 0 : (serveRadius.HasValue ? 1 : 0)) != 0)
                            {
                                num4 = e.IsRecommend ? 1 : 0;
                                goto label_15;
                            }
                        }
                        num4 = 0;
                    }
                    else
                    {
                        num4 = 1;
                    }
                    label_15:
                    shopBranch5.IsRecommend = num4 != 0;
                    shopBranch1.RecommendSequence = e.RecommendSequence == 0L ? long.MaxValue : e.RecommendSequence;
                    return shopBranch1;
                }))),
                Total = queryPageModel.Total
            });
        }