/// <summary> /// 进入立即购买提交页面 /// </summary> /// <param name="skuIds">库存ID集合</param> /// <param name="counts">库存ID对应的数量</param> /// <param name="GroupActionId">拼团活动编号</param> /// <param name="GroupId">拼团编号</param> public ActionResult Submit(string skuIds, string counts, int islimit = 0, long shippingAddressId = 0, string couponIds = "") { var coupons = CouponApplication.ConvertUsedCoupon(couponIds); var result = OrderApplication.GetMobileSubmit(UserId, skuIds, counts, shippingAddressId, coupons); ViewBag.InvoiceContext = result.InvoiceContext; ViewBag.InvoiceTitle = result.InvoiceTitle; ViewBag.skuIds = skuIds; ViewBag.counts = counts; ViewBag.IsCashOnDelivery = result.IsCashOnDelivery; ViewBag.address = null == result.Address || result.Address.NeedUpdate ? null : result.Address; ViewBag.ConfirmModel = result; ViewBag.Islimit = islimit == 1 ? true : false; var orderTag = Guid.NewGuid().ToString("N"); ViewBag.OrderTag = orderTag; Session["OrderTag"] = orderTag; InitOrderSubmitModel(result); #region 是否开启门店授权 ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore; #endregion #region TDO:ZYF 3.2注释是否提供发票 //bool ProvideInvoice = false; //if (result.products != null) // ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList()); //ViewBag.ProvideInvoice = ProvideInvoice; #endregion bool canIntegralPerMoney = true, canCapital = true; CanDeductible(out canIntegralPerMoney, out canCapital); ViewBag.CanIntegralPerMoney = canIntegralPerMoney; ViewBag.CanCapital = canCapital; ViewBag.productType = result.ProductType; string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (result.ProductType == 1) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new HimallException("该虚拟商品已过期,不支持下单"); } if (result.products != null && result.products.Count > 0) { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId); if (verificationShipper != null) { shipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; shipperTelPhone = verificationShipper.TelPhone; } } } ViewBag.ShipperAddress = shipperAddress; ViewBag.ShipperTelPhone = shipperTelPhone; return(View()); }
public object GetElectronicCredentials(long orderId) { bool validityType = false; string validityDate = string.Empty, validityDateStart = string.Empty; int total = 0; List <OrderVerificationCodeInfo> orderVerificationCodes = null; var orderInfo = OrderApplication.GetOrder(orderId); if (orderInfo != null && orderInfo.OrderType == OrderInfo.OrderTypes.Virtual) { var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault(); if (orderItemInfo != null) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType; if (validityType) { validityDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); validityDateStart = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); } } orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { orderId }); total = orderVerificationCodes.Count; orderVerificationCodes.ForEach(a => { a.QRCode = GetQRCode(a.VerificationCode); a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, @"(\d{4})", "$1 "); }); } } return(new { success = true, validityType = validityType, validityDate = validityDate, validityDateStart = validityDateStart, total = total, orderVerificationCodes = orderVerificationCodes.Select(a => { return new { QRCode = a.QRCode, VerificationCode = a.VerificationCode, Status = a.Status, StatusText = a.Status.ToDescription() }; }) }); }
/// <summary> /// 点击立即购买调用的GET方法,但是重定向到了Submit页面 /// </summary> /// <param name="skuIds">多个库存Id</param> /// <param name="counts">每个库存对应的数据量</param> /// <param name="regionId">客户收货地区的id</param> /// <param name="collpids">组合购Id集合</param> /// <returns>订单提交页面的数据</returns> public ActionResult SubmitByProductId(string skuIds, string counts, long?regionId, string collpids = null, string CouponIds = "", sbyte productType = 0, long productId = 0) { //Logo ViewBag.Logo = SiteSettings.Logo; //获取Logo //设置会员信息 ViewBag.Member = CurrentUser; var coupons = CouponApplication.ConvertUsedCoupon(CouponIds); var submitModel = OrderApplication.SubmitByProductId(UserId, skuIds, counts, regionId, collpids, coupons, productType); ViewBag.IsCashOnDelivery = submitModel.IsCashOnDelivery; ViewBag.IsLimitBuy = submitModel.IsLimitBuy; InitOrderSubmitModel(submitModel); #region 是否开启门店授权 ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore; #endregion #region 是否提供发票 //bool ProvideInvoice = false; //if (submitModel.products != null) // ProvideInvoice = ShopApplication.HasProvideInvoice(submitModel.products.Select(p => p.shopId).ToList()); //ViewBag.ProvideInvoice = ProvideInvoice; #endregion bool canIntegralPerMoney = true, canCapital = true; CanDeductible(out canIntegralPerMoney, out canCapital); ViewBag.CanIntegralPerMoney = canIntegralPerMoney; ViewBag.CanCapital = canCapital; ViewBag.Keyword = SiteSettings.Keyword; if (productType == 1 && productId > 0) { submitModel.VirtualProductItemInfos = ProductManagerApplication.GetVirtualProductItemInfoByProductId(productId); var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(productId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new MallException("该虚拟商品已过期,不支持下单"); } } submitModel.ProductType = productType; if (productType == 1 && submitModel.products != null && submitModel.products.Count > 0) { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(submitModel.products.FirstOrDefault().shopId); if (verificationShipper != null) { ViewBag.ShipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; ViewBag.ShipperTelPhone = verificationShipper.TelPhone; } } return(View("Submit", submitModel)); }
/// <summary> /// 电子凭证 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public ActionResult ElectronicCredentials(long orderId) { bool validityType = false; string validityDate = string.Empty, validityDateStart = string.Empty; int total = 0; List <OrderVerificationCodeInfo> orderVerificationCodes = null; var orderInfo = OrderApplication.GetOrder(orderId); if (orderInfo != null && orderInfo.OrderType == OrderInfo.OrderTypes.Virtual) { var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault(); if (orderItemInfo != null) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType; if (validityType) { validityDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); validityDateStart = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); } } orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { orderId }); total = orderVerificationCodes.Count; orderVerificationCodes.ForEach(a => { a.QRCode = GetQRCode(a.VerificationCode); }); } } ViewBag.validityType = validityType; ViewBag.validityDate = validityDate; ViewBag.validityDateStart = validityDateStart; ViewBag.total = total; ViewBag.orderVerificationCodes = orderVerificationCodes; return(View()); }
/// <summary> /// 立即购买方式提交的订单 /// </summary> /// <param name="value">数据</param> private object SubmitOrderById(OrderSubmitOrderModel value) { string skuIds = value.skuIds; string counts = value.counts; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; //end string orderRemarks = string.Empty;//value.orderRemarks;//订单备注 OrderCreateModel model = new OrderCreateModel(); var orderService = ServiceProvider.Instance <IOrderService> .Create; var productService = ServiceProvider.Instance <IProductService> .Create; var skuIdArr = skuIds.Split(',').Select(item => item.ToString()); var countArr = counts.Split(',').Select(item => int.Parse(item)); model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds); IEnumerable <long> orderIds; model.PlatformType = PlatformType.WeiXinSmallProg; model.CurrentUser = CurrentUser; model.ReceiveAddressId = recieveAddressId; model.SkuIds = skuIdArr; model.Counts = countArr; model.Integral = integral; model.IsCashOnDelivery = isCashOnDelivery; model.Invoice = (InvoiceType)invoiceType; model.InvoiceContext = invoiceContext; model.InvoiceTitle = invoiceTitle; model.formId = value.formId; model.Capital = value.Capital; CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderShop[]>(value.jsonOrderShops); CommonModel.VirtualProductItem[] VirtualProductItems = Newtonsoft.Json.JsonConvert.DeserializeObject <VirtualProductItem[]>(value.VirtualProductItems); model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提 model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray(); //end if (value.isStore) { model.IsShopbranchOrder = true; } model.IsVirtual = value.ProductType == 1; if (model.IsVirtual && skuIdArr.Count() > 0) { var skuInfo = ProductManagerApplication.GetSKU(skuIdArr.FirstOrDefault()); if (skuInfo != null) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(skuInfo.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { return(Json(ErrorResult <dynamic>("该虚拟商品已过期,不支持下单"))); } } } try { //处理限时购 if (skuIdArr.Count() == 1) { var skuid = skuIdArr.ElementAt(0); if (!string.IsNullOrWhiteSpace(skuid)) { var sku = productService.GetSku(skuid); var flashSale = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(sku.ProductId); model.IslimitBuy = flashSale != null;//标识为限时购计算价格按限时购价格核算 model.FlashSaleId = flashSale != null ? flashSale.Id : 0; } } var orders = orderService.CreateOrder(model); orderIds = orders.Select(item => item.Id).ToArray(); decimal orderTotals = orders.Where(d => d.PaymentType != Entities.OrderInfo.PaymentTypes.CashOnDelivery).Sum(item => item.OrderTotalAmount); //orderIds = orderService.CreateOrder(CurrentUser.Id, skuIdArr, countArr, recieveAddressId, PlatformType); AddVshopBuyNumber(orderIds);//添加微店购买数量 #region 处理虚拟订单项 if (value.ProductType == 1 && VirtualProductItems != null && VirtualProductItems.Count() > 0) { var orderId = orderIds.FirstOrDefault(); if (orderId > 0) { var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault(); if (orderItemInfo != null) { var list = VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项 list.ForEach(a => { a.OrderId = orderId; a.OrderItemId = orderItemInfo.Id; if (a.VirtualProductItemType == (sbyte)ProductInfo.VirtualProductItemType.Picture) { a.Content = MoveImages(a.Content, CurrentUser.Id); } }); if (list.Count > 0) { OrderApplication.AddVirtualOrderItemInfo(list); } } } } #endregion return(Json(new { OrderId = string.Join(",", orderIds), OrderTotal = orderTotals, RealTotalIsZero = (orderTotals - model.Capital) == 0, msg = "提交成功" })); } catch (MallException he) { return(Json(ErrorResult <dynamic>(he.Message))); } }
public ActionResult Detail(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } string price = ""; #region 定义Model和变量 LimitTimeProductDetailModel model = new LimitTimeProductDetailModel { MainId = long.Parse(id), HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Product = new Entities.ProductInfo(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; FlashSaleModel market = null; Entities.ShopInfo shop = null; long gid = 0, mid = 0; #endregion #region 商品Id不合法 if (long.TryParse(id, out mid)) { } if (mid == 0) { //跳转到出错页面 return(RedirectToAction("Error404", "Error", new { area = "Web" })); } #endregion #region 初始化商品和店铺 market = _iLimitTimeBuyService.Get(mid); switch (market.Status) { case Entities.FlashSaleInfo.FlashSaleStatus.Ended: return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); case Entities.FlashSaleInfo.FlashSaleStatus.Cancelled: return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } if (market.Status != Entities.FlashSaleInfo.FlashSaleStatus.Ongoing) { return(RedirectToAction("Home")); } model.FlashSale = market; if (market == null || market.Id == 0 || market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { //可能参数是商品ID market = market == null?_iLimitTimeBuyService.GetFlaseSaleByProductId(mid) : market; if (market == null) { //跳转到404页面 return(RedirectToAction("Error404", "Error", new { area = "Mobile" })); } if (market.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { return(RedirectToAction("Detail", "Product", new { id = market.ProductId })); } } model.MaxSaleCount = market.LimitCountOfThePeople; model.Title = market.Title; shop = _iShopService.GetShop(market.ShopId); model.Shop.Name = shop.ShopName; #endregion #region 商品描述 var product = _iProductService.GetProduct(market.ProductId); gid = market.ProductId; var brandModel = ServiceApplication.Create <IBrandService>().GetBrand(product.BrandId); product.BrandName = brandModel == null ? "" : brandModel.Name; if (CurrentUser != null && CurrentUser.Id > 0) { product.IsFavorite = ProductManagerApplication.IsFavorite(product.Id, CurrentUser.Id); } model.Product = product; model.Skus = ProductManagerApplication.GetSKUsByProduct(new List <long> { product.Id }); var description = ProductManagerApplication.GetProductDescription(product.Id); model.ProductDescription = description.Description; if (description.DescriptionPrefixId != 0) { var desc = _iProductDescriptionTemplateService .GetTemplate(description.DescriptionPrefixId, product.ShopId); model.DescriptionPrefix = desc == null ? "" : desc.Content; } if (description.DescriptiondSuffixId != 0) { var desc = _iProductDescriptionTemplateService .GetTemplate(description.DescriptiondSuffixId, product.ShopId); model.DescriptiondSuffix = desc == null ? "" : desc.Content; } #endregion #region 店铺 var categories = _iShopCategoryService.GetShopCategory(product.ShopId); List <Entities.ShopCategoryInfo> allcate = categories.ToList(); foreach (var main in allcate.Where(s => s.ParentCategoryId == 0)) { var topC = new CategoryJsonModel() { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; foreach (var secondItem in allcate.Where(s => s.ParentCategoryId == main.Id)) { var secondC = new SecondLevelCategory() { Name = secondItem.Name, Id = secondItem.Id.ToString(), }; topC.SubCategory.Add(secondC); } model.ShopCategory.Add(topC); } model.CashDeposits = _iCashDepositsService.GetCashDepositsObligation(product.Id); #endregion #region 热门销售 //会员折扣 decimal discount = 1M; long SelfShopId = 0; if (CurrentUser != null) { discount = CurrentUser.MemberDiscount; var shopInfo = ShopApplication.GetSelfShop(); SelfShopId = shopInfo.Id; } var sale = _iProductService.GetHotSaleProduct(shop.Id, 5); if (sale != null) { foreach (var item in sale.ToArray()) { var salePrice = item.MinSalePrice; if (item.ShopId == SelfShopId) { salePrice = item.MinSalePrice * discount; } var limitBuy = LimitTimeApplication.GetLimitTimeMarketItemByProductId(item.Id); if (limitBuy != null) { salePrice = limitBuy.MinPrice; } model.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = Math.Round(salePrice, 2), Id = item.Id, SaleCount = (int)item.SaleCounts + Mall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts) }); } } #endregion #region 热门关注 var hot = _iProductService.GetHotConcernedProduct(shop.Id, 5); if (hot != null) { foreach (var item in hot.ToArray()) { model.HotAttentionProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } #endregion #region 商品规格 Entities.TypeInfo typeInfo = _iTypeService.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product != null) { colorAlias = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias; } model.ColorAlias = colorAlias; model.SizeAlias = sizeAlias; model.VersionAlias = versionAlias; var skus = _iProductService.GetSKUs(product.Id); if (skus.Count > 0) { long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in skus) { var specs = sku.Id.Split('_'); if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color)) { if (long.TryParse(specs[1], out colorId)) { } if (colorId != 0) { if (!model.Color.Any(v => v.Value.Equals(sku.Color))) { var c = skus.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色", Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = Mall.Core.MallIO.GetImagePath(sku.ShowPic) }); } } } if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size)) { if (long.TryParse(specs[2], out sizeId)) { } if (sizeId != 0) { if (!model.Size.Any(v => v.Value.Equals(sku.Size))) { var ss = skus.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码", Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", SelectedClass = "", SkuId = sizeId, Value = sku.Size }); } } } if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version)) { if (long.TryParse(specs[3], out versionId)) { } if (versionId != 0) { if (!model.Version.Any(v => v.Value.Equals(sku.Version))) { var v = skus.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本", Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } price = ProductWebApplication.GetProductPriceStr(product, skus, discount);//最小价或区间价文本 } model.Price = string.IsNullOrWhiteSpace(price) ? product.MinSalePrice.ToString("f2") : price; #endregion #region 商品属性 List <TypeAttributesModel> ProductAttrs = new List <TypeAttributesModel>(); var prodAttrs = ProductManagerApplication.GetProductAttributes(product.Id); foreach (var attr in prodAttrs) { if (!ProductAttrs.Any(p => p.AttrId == attr.AttributeId)) { var attribute = _iTypeService.GetAttribute(attr.AttributeId); var values = _iTypeService.GetAttributeValues(attr.AttributeId); var attrModel = new TypeAttributesModel() { AttrId = attr.AttributeId, AttrValues = new List <TypeAttrValue>(), Name = attribute.Name }; foreach (var attrV in values) { if (prodAttrs.Any(p => p.ValueId == attrV.Id)) { attrModel.AttrValues.Add(new TypeAttrValue { Id = attrV.Id.ToString(), Name = attrV.Value }); } } ProductAttrs.Add(attrModel); } else { var attrTemp = ProductAttrs.FirstOrDefault(p => p.AttrId == attr.AttributeId); var values = _iTypeService.GetAttributeValues(attr.AttributeId); if (!attrTemp.AttrValues.Any(p => p.Id == attr.ValueId.ToString())) { attrTemp.AttrValues.Add(new TypeAttrValue { Id = attr.ValueId.ToString(), Name = values.FirstOrDefault(a => a.Id == attr.ValueId).Value }); } } } model.ProductAttrs = ProductAttrs; #endregion #region 获取评论、咨询数量 model.CommentCount = CommentApplication.GetCommentCountByProduct(product.Id); var consultations = _iConsultationService.GetConsultations(gid); model.Consultations = consultations.Count(); #endregion #region 累加浏览次数、 加入历史记录 if (CurrentUser != null) { BrowseHistrory.AddBrowsingProduct(product.Id, CurrentUser.Id); } else { BrowseHistrory.AddBrowsingProduct(product.Id); } //_iProductService.LogProductVisti(gid); //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); #endregion #region 红包 var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(product.ShopId); if (bonus != null) { model.GrantPrice = bonus.GrantPrice; } else { model.GrantPrice = 0; } #endregion #region 获取店铺的评价统计 var shopStatisticOrderComments = _iShopService.GetShopStatisticOrderComments(shop.Id); var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault(); var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault(); var sellerDeliverySpeed = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault(); var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault(); var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault(); var sellerDeliverySpeedPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault(); var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault(); var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault(); var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault(); var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault(); var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault(); var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault(); decimal defaultValue = 5; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { ViewBag.ProductAndDescription = productAndDescription.CommentValue; ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue; ViewBag.ProductAndDescriptionMin = productAndDescriptionMin.CommentValue; ViewBag.ProductAndDescriptionMax = productAndDescriptionMax.CommentValue; } else { ViewBag.ProductAndDescription = defaultValue; ViewBag.ProductAndDescriptionPeer = defaultValue; ViewBag.ProductAndDescriptionMin = defaultValue; ViewBag.ProductAndDescriptionMax = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { ViewBag.SellerServiceAttitude = sellerServiceAttitude.CommentValue; ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue; ViewBag.SellerServiceAttitudeMax = sellerServiceAttitudeMax.CommentValue; ViewBag.SellerServiceAttitudeMin = sellerServiceAttitudeMin.CommentValue; } else { ViewBag.SellerServiceAttitude = defaultValue; ViewBag.SellerServiceAttitudePeer = defaultValue; ViewBag.SellerServiceAttitudeMax = defaultValue; ViewBag.SellerServiceAttitudeMin = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { ViewBag.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue; ViewBag.SellerDeliverySpeedMax = sellerDeliverySpeedMax.CommentValue; ViewBag.sellerDeliverySpeedMin = sellerDeliverySpeedMin.CommentValue; } else { ViewBag.SellerDeliverySpeed = defaultValue; ViewBag.SellerDeliverySpeedPeer = defaultValue; ViewBag.SellerDeliverySpeedMax = defaultValue; ViewBag.sellerDeliverySpeedMin = defaultValue; } #endregion #region 客服 model.Service = ServiceApplication.Create <ICustomerService>().GetCustomerService(shop.Id).Where(c => c.Type == Entities.CustomerServiceInfo.ServiceType.PreSale && c.TerminalType == Entities.CustomerServiceInfo.ServiceTerminalType.PC).OrderBy(m => m.Tool); #endregion #region 开团提醒场景二维码 var siteSetting = SiteSettingApplication.SiteSettings; if (DateTime.Parse(model.FlashSale.BeginDate) > DateTime.Now && WXIsConfig(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret)) { try { var token = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret); SceneHelper helper = new SceneHelper(); SceneModel scene = new SceneModel(QR_SCENE_Type.FlashSaleRemind, model.FlashSale.Id); int sceneId = helper.SetModel(scene); var ticket = QrCodeApi.Create(token, 86400, sceneId, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null).ticket; ViewBag.ticket = ticket; } catch { } } #endregion model.Logined = (null != CurrentUser) ? 1 : 0; model.EnabledBuy = product.AuditStatus == Entities.ProductInfo.ProductAuditStatus.Audited && DateTime.Parse(market.BeginDate) <= DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now && product.SaleStatus == Entities.ProductInfo.ProductSaleStatus.OnSale; if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) < DateTime.Now && DateTime.Parse(market.EndDate) > DateTime.Now) { TimeSpan end = new TimeSpan(DateTime.Parse(market.EndDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; } else if (market.Status == FlashSaleInfo.FlashSaleStatus.Ongoing && DateTime.Parse(market.BeginDate) > DateTime.Now) { TimeSpan end = new TimeSpan(DateTime.Parse(market.BeginDate).Ticks); TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = end.Subtract(start); model.Second = ts.TotalSeconds < 0 ? 0 : ts.TotalSeconds; } //补充当前店铺红包功能 ViewBag.isShopPage = true; ViewBag.CurShopId = product.ShopId; TempData["isShopPage"] = true; TempData["CurShopId"] = product.ShopId; ViewBag.Keyword = SiteSettings.Keyword; ViewBag.Quantity = market.Quantity;//总活动库存 model.VirtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(product.Id); model.FreightTemplate = FreightTemplateApplication.GetFreightTemplate(product.FreightTemplateId); return(View(model)); }
public object GetOrderDetail(long id) { CheckUserLogin(); long shopid = CurrentShopBranch.ShopId; long sbid = CurrentUser.ShopBranchId; var ordser = ServiceProvider.Instance <IOrderService> .Create; Entities.OrderInfo order = ordser.GetOrder(id); if (order == null || order.ShopBranchId != sbid) { throw new HimallApiException("错误的订单编号"); } var bonusService = ServiceProvider.Instance <IShopBonusService> .Create; var orderRefundService = ServiceProvider.Instance <IRefundService> .Create; var shopService = ServiceProvider.Instance <IShopService> .Create; var productService = ServiceProvider.Instance <IProductService> .Create; var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId); var orderitems = OrderApplication.GetOrderItems(order.Id); bool isCanApply = false; //获取订单商品项数据 var orderDetail = new { ShopName = shopService.GetShop(order.ShopId).ShopName, ShopId = order.ShopId, OrderItems = orderitems.Select(item => { var productinfo = productService.GetProduct(item.ProductId); if (order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitDelivery) { isCanApply = orderRefundService.CanApplyRefund(id, item.Id); } else { isCanApply = orderRefundService.CanApplyRefund(id, item.Id, false); } Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(productinfo.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (productinfo != null) { colorAlias = !string.IsNullOrWhiteSpace(productinfo.ColorAlias) ? productinfo.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(productinfo.SizeAlias) ? productinfo.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(productinfo.VersionAlias) ? productinfo.VersionAlias : versionAlias; } return(new { ItemId = item.Id, ProductId = item.ProductId, ProductName = item.ProductName, Count = item.Quantity, Price = item.SalePrice, //ProductImage = "http://" + Url.Request.RequestUri.Host + productService.GetProduct(item.ProductId).GetImage(ProductInfo.ImageSize.Size_100), ProductImage = Core.HimallIO.GetRomoteProductSizeImage(productService.GetProduct(item.ProductId).RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100), color = item.Color, size = item.Size, version = item.Version, IsCanRefund = isCanApply, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias }); }) }; VirtualProductInfo virtualProductInfo = null; List <dynamic> codes = null; List <dynamic> virtualItems = null; int validityType = 0; string startDate = string.Empty, endDate = string.Empty; if (order.OrderType == OrderInfo.OrderTypes.Virtual && orderDetail.OrderItems != null) { virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderDetail.OrderItems.FirstOrDefault().ProductId); if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType ? 1 : 0; if (validityType == 1) { startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); endDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); } } var verificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }); if (verificationCodes != null) { verificationCodes.ForEach(a => { if (a.Status == OrderInfo.VerificationCodeStatus.WaitVerification || a.Status == OrderInfo.VerificationCodeStatus.Refund) { a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, "(\\d{4})\\d{4}(\\d{4})", "$1****$2"); } a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, @"(\d{4})", "$1 "); }); } codes = verificationCodes.Select(p => { return(new { VerificationCode = p.VerificationCode, Status = p.Status, StatusText = p.Status.ToDescription() }); }).ToList <dynamic>(); var virtualOrderItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id); virtualItems = virtualOrderItems.Select(p => { return(new { VirtualProductItemName = p.VirtualProductItemName, VirtualProductItemType = p.VirtualProductItemType, Content = ReplaceImage(p.Content, p.VirtualProductItemType) }); }).ToList <dynamic>(); } var orderModel = new { Id = order.Id, OrderType = order.OrderType, OrderTypeName = order.OrderType.ToDescription(), Status = order.OrderStatus.ToDescription(), ShipTo = order.ShipTo, Phone = order.CellPhone, Address = order.RegionFullName + " " + order.Address, HasExpressStatus = !string.IsNullOrWhiteSpace(order.ShipOrderNumber), ExpressCompanyName = order.ExpressCompanyName, Freight = order.Freight, Tax = order.Tax, IntegralDiscount = order.IntegralDiscount, RealTotalAmount = order.OrderTotalAmount - order.RefundTotalAmount, CapitalAmount = order.CapitalAmount, RefundTotalAmount = order.RefundTotalAmount, ProductTotalAmount = order.ProductTotalAmount, OrderDate = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"), ShopName = order.ShopName, ShopBranchName = CurrentShopBranch.ShopBranchName, VShopId = vshop == null ? 0 : vshop.Id, commentCount = OrderApplication.GetOrderCommentCount(order.Id), ShopId = order.ShopId, orderStatus = (int)order.OrderStatus, //Invoice = order.InvoiceType.ToDescription(), //InvoiceValue = (int)order.InvoiceType, //InvoiceContext = order.InvoiceContext, //InvoiceTitle = order.InvoiceTitle, PaymentType = order.PaymentType.ToDescription(), PaymentTypeValue = (int)order.PaymentType, PaymentTypeDesc = order.PaymentTypeDesc, OrderPayAmount = order.OrderPayAmount, PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName, FullDiscount = order.FullDiscount, DiscountAmount = order.DiscountAmount, OrderRemarks = order.OrderRemarks, DeliveryType = order.DeliveryType, //InvoiceCode = order.InvoiceCode, OrderInvoice = OrderApplication.GetOrderInvoiceInfo(order.Id) }; return(new { success = true, Order = orderModel, OrderItem = orderDetail.OrderItems, VerificationCodes = codes, VirtualOrderItems = virtualItems, StartDate = startDate, EndDate = endDate, ValidityType = validityType }); }
public object GetVerificationRecordDetail(long id) { CheckUserLogin(); var recordInfo = OrderApplication.GetVerificationRecordInfoById(id); if (recordInfo == null) { return new { success = false, msg = "错误的ID" } } ; var order = OrderApplication.GetOrderInfo(recordInfo.OrderId); if (order == null) { return new { success = false, msg = "该核销码无效" } } ; if (order.ShopBranchId != this.CurrentShopBranch.Id) { return new { success = false, msg = "非本店核销记录" } } ; var orderItem = Application.OrderApplication.GetOrderItemsByOrderId(order.Id); foreach (var item in orderItem) { item.ThumbnailsUrl = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_100); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetTypeByProductId(item.ProductId); item.ColorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; item.SizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; item.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; var productInfo = ProductManagerApplication.GetProduct(item.ProductId); if (productInfo != null) { item.ColorAlias = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : item.ColorAlias; item.SizeAlias = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : item.SizeAlias; item.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : item.VersionAlias; } } int validityType = 0; string startDate = string.Empty, endDate = string.Empty; var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItem.FirstOrDefault().ProductId); if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType ? 1 : 0; if (validityType == 1) { startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); endDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); } } var verificationCode = recordInfo.VerificationCodeIds.Trim(',').Split(',').ToList(); verificationCode = verificationCode.Select(a => a = Regex.Replace(a, @"(\d{4})", "$1 ")).ToList(); var virtualOrderItemInfos = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id).Select(p => { return(new { VirtualProductItemType = p.VirtualProductItemType, VirtualProductItemName = p.VirtualProductItemName, Content = ReplaceImage(p.Content, p.VirtualProductItemType) }); }); order.OrderStatusText = order.OrderStatus.ToDescription(); return(new { success = true, order = order, orderItem = orderItem, virtualOrderItemInfos = virtualOrderItemInfos, verificationCodes = verificationCode, validityType = validityType, startDate = startDate, endDate = endDate, verificationTime = recordInfo.VerificationTime.ToString("yyyy-MM-dd HH:mm:ss"), verificationUser = recordInfo.VerificationUser }); }
public ActionResult ExportToExcel(long?categoryId = null, string brandName = "", string productCode = "", int?auditStatus = null, string ids = "", string keyWords = "", string shopName = "", int?saleStatus = null, sbyte?productType = null) { var query = new ProductQuery() { PageSize = int.MaxValue, PageNo = 1, BrandName = brandName, KeyWords = keyWords, CategoryId = categoryId, Ids = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)), ShopName = shopName, ProductCode = productCode, NotIncludedInDraft = true }; if (productType.HasValue && productType.Value > -1) { query.ProductType = productType.Value; } if (auditStatus.HasValue) { query.AuditStatus = new ProductInfo.ProductAuditStatus[] { (ProductInfo.ProductAuditStatus)auditStatus }; if (auditStatus == (int)ProductInfo.ProductAuditStatus.WaitForAuditing) { query.SaleStatus = ProductInfo.ProductSaleStatus.OnSale; } } if (saleStatus.HasValue) { query.SaleStatus = (ProductInfo.ProductSaleStatus)saleStatus; } var data = ProductManagerApplication.GetProducts(query); #region 先查询到列表,便于下面循环读取 List <CategoryInfo> listproductcate = new List <CategoryInfo>(); //商品分类 List <BrandInfo> listbrand = new List <BrandInfo>(); //品牌 List <FreightTemplateInfo> listtemplate = new List <FreightTemplateInfo>(); //运费模板 List <Mall.DTO.ProductShopCategory> listshopcate = new List <DTO.ProductShopCategory>(); //商铺分类 Dictionary <long, string> shopnames = new Dictionary <long, string>(); if (data.Models != null) { List <long> cateids = data.Models.Select(p => p.CategoryId).ToList(); listproductcate = CategoryApplication.GetCateogryListByIds(cateids);//平台分类 if (listproductcate == null) { listproductcate = new List <CategoryInfo>(); } List <long> templateIds = data.Models.Select(p => p.FreightTemplateId).ToList(); listtemplate = FreightTemplateApplication.GetFreightTemplateList(templateIds);//运费模板 if (listtemplate == null) { listtemplate = new List <FreightTemplateInfo>(); //实例下便免下面循环里判断空 } IEnumerable <long> brandIds = data.Models.Select(p => p.BrandId); //品牌 listbrand = BrandApplication.GetBrands(brandIds); if (listbrand == null) { listbrand = new List <BrandInfo>(); } List <long> productids = data.Models.Select(p => p.Id).ToList();//商铺分类 listshopcate = ShopCategoryApplication.GetCategorysByProduct(productids); if (listshopcate == null) { listshopcate = new List <DTO.ProductShopCategory>(); } List <long> shopids = data.Models.Select(p => p.ShopId).ToList(); shopnames = ShopApplication.GetShopNames(shopids); if (shopnames == null) { shopnames = new Dictionary <long, string>(); } } #endregion var products = data.Models.Select(item => { var desc = ProductManagerApplication.GetProductDescription(item.Id); var skus = _iProductService.GetSKUs(item.Id); var brand = (item.BrandId <= 0) ? null : listbrand.Where(p => p.Id == item.BrandId).FirstOrDefault(); //品牌 var freightTem = (item.FreightTemplateId <= 0) ? null : listtemplate.Where(p => p.Id == item.FreightTemplateId).FirstOrDefault(); //运费模板 var platFormCate = (item.CategoryId <= 0) ? null : listproductcate.Where(p => p.Id == item.CategoryId).FirstOrDefault(); //平台分类 var shopcate = listshopcate.Where(p => p.ProductId == item.Id).FirstOrDefault(); //商铺分类 return(new ProductModel() { //TODO:FG 循环内查询调用(大数据量) name = item.ProductName, brandName = brand == null ? "" : brand.Name, id = item.Id, imgUrl = item.GetImage(ImageSize.Size_50), price = item.MinSalePrice, state = item.ShowProductState, auditStatus = (int)item.AuditStatus, url = "", auditReason = desc?.AuditReason ?? string.Empty, //shopName = shopService.GetShopBasicInfo(item.ShopId) == null ? "" : shopService.GetShopBasicInfo(item.ShopId).ShopName, shopName = shopnames[item.ShopId], saleStatus = (int)item.SaleStatus, productCode = item.ProductCode, categoryName = platFormCate == null ? "" : platFormCate.Name, //平台分类 ShopCategoryName = shopcate == null ? "" : shopcate.ShopCategoryName, //商家分类 AuditStatusText = (item.AuditStatus == ProductInfo.ProductAuditStatus.Audited ? "已审核" : "待审核"), MeasureUnit = item.MeasureUnit, HasSKU = item.HasSKU, SKUInfo = skus, FreightTemplateName = freightTem == null ? "" : freightTem.Name, //运费模板名称 IsOpenLadder = item.IsOpenLadder, //是否开启阶梯批发 ProductLadderPrice = ProductManagerApplication.GetLadderPriceInfosByProductId(item.Id, item.IsOpenLadder), ProductTypeName = item.ProductType == 1 ? "虚拟商品" : "实物商品", //商品类型(虚拟或实物) VirtualProduct = (item.ProductType == 1 ? ProductManagerApplication.GetVirtualProductInfoByProductId(item.Id) : null), //虚拟商品 AuditReason = desc == null?"":desc.AuditReason, //审核备注 AddedDate = item.AddedDate.ToString(), //发布日期 MarketPrice = item.MarketPrice, //市场价 }); }); #region 构建Excel文档 ViewData.Model = products; string viewHtml = RenderPartialViewToString(this, "ExportProductinfo"); return(File(System.Text.Encoding.UTF8.GetBytes(viewHtml), "application/ms-excel", string.Format("平台商品信息_{0}.xls", DateTime.Now.ToString("yyyy-MM-dd")))); #endregion }
public object PostSubmitOrder(OrderSubmitOrderModel value) { CheckUserLogin(); if (value.CapitalAmount > 0 && !string.IsNullOrEmpty(value.PayPwd)) { var flag = MemberApplication.VerificationPayPwd(CurrentUser.Id, value.PayPwd); if (!flag) { throw new MallApiException("预存款支付密码错误"); } } string skuIds = value.skuIds; string counts = value.counts; long recieveAddressId = value.recieveAddressId; string couponIds = value.couponIds; int integral = value.integral; bool isCashOnDelivery = value.isCashOnDelivery; int invoiceType = value.invoiceType; string invoiceTitle = value.invoiceTitle; string invoiceContext = value.invoiceContext; //end string orderRemarks = string.Empty;//value.orderRemarks;//订单备注 OrderCreateModel model = new OrderCreateModel(); var orderService = ServiceProvider.Instance<IOrderService>.Create; var productService = ServiceProvider.Instance<IProductService>.Create; var skuIdArr = skuIds.Split(',').Select(item => item.ToString()); var countArr = counts.Split(',').Select(item => int.Parse(item)); model.CouponIdsStr = CouponApplication.ConvertUsedCoupon(couponIds); IEnumerable<long> orderIds; model.PlatformType = PlatformType.Android; model.CurrentUser = CurrentUser; model.ReceiveAddressId = recieveAddressId; model.SkuIds = skuIdArr; model.Counts = countArr; model.Integral = integral; model.Capital = value.CapitalAmount; model.IsCashOnDelivery = isCashOnDelivery; model.Invoice = (InvoiceType)invoiceType; model.InvoiceContext = invoiceContext; model.InvoiceTitle = invoiceTitle; model.InvoiceCode = value.invoiceCode; CommonModel.OrderShop[] OrderShops = Newtonsoft.Json.JsonConvert.DeserializeObject<OrderShop[]>(value.jsonOrderShops); CommonModel.VirtualProductItem[] VirtualProductItems = Newtonsoft.Json.JsonConvert.DeserializeObject<VirtualProductItem[]>(value.VirtualProductItems); model.OrderShops = OrderShops;//用户APP选择门店自提时用到,2.5版本未支持门店自提 model.OrderRemarks = OrderShops.Select(p => p.Remark).ToArray(); //end model.IsShopbranchOrder = true; model.IsVirtual = value.ProductType == 1; if (model.IsVirtual && skuIdArr.Count() > 0) { var skuInfo = ProductManagerApplication.GetSKU(skuIdArr.FirstOrDefault()); if (skuInfo != null) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(skuInfo.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { return ErrorResult("该虚拟商品已过期,不支持下单"); } } } try { //处理限时购 if (skuIdArr.Count() == 1) { var skuid = skuIdArr.ElementAt(0); if (!string.IsNullOrWhiteSpace(skuid)) { var sku = productService.GetSku(skuid); bool isltmbuy = ServiceProvider.Instance<ILimitTimeBuyService>.Create.IsLimitTimeMarketItem(sku.ProductId); model.IslimitBuy = isltmbuy;//标识为限时购计算价格按限时购价格核算 } } var orders = orderService.CreateOrder(model); orderIds = orders.Select(item => item.Id).ToArray(); decimal orderTotals = orders.Sum(item => item.OrderTotalAmount); //orderIds = orderService.CreateOrder(CurrentUser.Id, skuIdArr, countArr, recieveAddressId, PlatformType); AddVshopBuyNumber(orderIds);//添加微店购买数量 #region 处理虚拟订单项 if (value.ProductType == 1 && VirtualProductItems != null && VirtualProductItems.Count() > 0) { var orderId = orderIds.FirstOrDefault(); if (orderId > 0) { var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(orderId).FirstOrDefault(); if (orderItemInfo != null) { var list = VirtualProductItems.ToList().Where(a => !string.IsNullOrWhiteSpace(a.Content)).ToList();//过滤空项 list.ForEach(a => { a.OrderId = orderId; a.OrderItemId = orderItemInfo.Id; if (a.VirtualProductItemType == (sbyte)ProductInfo.VirtualProductItemType.Picture) { a.Content = MoveImages(a.Content, CurrentUser.Id); } }); if (list.Count > 0) { OrderApplication.AddVirtualOrderItemInfo(list); } } } } #endregion var _result = new { success = true, OrderIds = orderIds, RealTotalIsZero = orderTotals == 0 }; return _result; } catch (MallException he) { return ErrorResult(he.Message); } catch (Exception ex) { return ErrorResult("提交订单异常"); } }
// GET: Web/UserOrder public ActionResult Index(string orderDate, string keywords, string orderids, DateTime?startDateTime, DateTime?endDateTime, int?orderStatus, int pageNo = 1, int pageSize = 10) { ViewBag.Grant = null; if (!string.IsNullOrEmpty(orderids) && orderids.IndexOf(',') <= 0) { ViewBag.Grant = _iShopBonusService.GetByOrderId(long.Parse(orderids)); } DateTime?startDate = startDateTime; DateTime?endDate = endDateTime; if (!string.IsNullOrEmpty(orderDate) && orderDate.ToLower() != "all") { switch (orderDate.ToLower()) { case "threemonth": startDate = DateTime.Now.AddMonths(-3); break; case "halfyear": startDate = DateTime.Now.AddMonths(-6); break; case "year": startDate = DateTime.Now.AddYears(-1); break; case "yearago": endDate = DateTime.Now.AddYears(-1); break; } } if (orderStatus.HasValue && orderStatus == 0) { orderStatus = null; } var queryModel = new OrderQuery() { StartDate = startDate, EndDate = endDate, Status = (Entities.OrderInfo.OrderOperateStatus?)orderStatus, UserId = CurrentUser.Id, SearchKeyWords = keywords, PageSize = pageSize, PageNo = pageNo }; var orders = OrderApplication.GetOrders(queryModel); var orderComments = OrderApplication.GetOrderCommentCount(orders.Models.Select(p => p.Id)); var orderItems = OrderApplication.GetOrderItemsByOrderId(orders.Models.Select(p => p.Id)); var orderRefunds = OrderApplication.GetOrderRefunds(orderItems.Select(p => p.Id)); PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = orders.Total }; ViewBag.pageInfo = info; ViewBag.UserId = CurrentUser.Id; var siteSetting = SiteSettingApplication.SiteSettings; var shopBonus = _iShopBonusService; ViewBag.SalesRefundTimeout = siteSetting.SalesReturnTimeout; var cashDepositsService = _iCashDepositsService; var orderList = orders.Models.Select(item => new OrderListModel { Id = item.Id, ActiveType = item.ActiveType, OrderType = item.OrderType, Address = item.Address, CellPhone = item.CellPhone, CloseReason = item.CloseReason, CommisTotalAmount = item.CommisAmount, DiscountAmount = item.DiscountAmount, ExpressCompanyName = item.ExpressCompanyName, FinishDate = item.FinishDate, Freight = item.Freight, GatewayOrderId = item.GatewayOrderId, IntegralDiscount = item.IntegralDiscount, CapitalAmount = item.CapitalAmount, UserId = item.UserId, ShopId = item.ShopId, ShopName = item.ShopName, ShopBranchId = item.ShopBranchId, ShopBranchName = GetShopBranchName(item.ShopBranchId), ShipTo = item.ShipTo, OrderTotalAmount = item.OrderTotalAmount, PaymentTypeName = item.PaymentTypeName, //满额减 FullDiscount = item.FullDiscount, OrderStatus = item.OrderStatus, RefundStats = item.RefundStats, CommentCount = orderComments.ContainsKey(item.Id) ? orderComments[item.Id] : 0, OrderDate = item.OrderDate, PaymentType = item.PaymentType, PickupCode = item.PickupCode, OrderItemList = orderItems.Where(oi => oi.OrderId == item.Id).Select(oItem => { var itemrefund = orderRefunds.Where(or => or.OrderItemId == oItem.Id && or.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund).FirstOrDefault(); var orderItem = new OrderItemListModel { Id = oItem.Id, ProductId = oItem.ProductId, Color = oItem.Color, Size = oItem.Size, Version = oItem.Version, ProductName = oItem.ProductName, ThumbnailsUrl = oItem.ThumbnailsUrl, SalePrice = oItem.SalePrice, SkuId = oItem.SkuId, Quantity = oItem.Quantity, CashDepositsObligation = cashDepositsService.GetCashDepositsObligation(oItem.ProductId), }; if (itemrefund != null) { orderItem.RefundStats = itemrefund.RefundStatusValue; orderItem.ItemRefundId = itemrefund.Id; string showRefundStats = ""; if (itemrefund.SellerAuditStatus == OrderRefundInfo.OrderRefundAuditStatus.Audited) { showRefundStats = itemrefund.ManagerConfirmStatus.ToDescription(); } else if (item.DeliveryType == CommonModel.DeliveryType.SelfTake || item.ShopBranchId > 0)//如果是自提订单或分配门店订单则转为门店审核状态 { showRefundStats = ((CommonModel.Enum.OrderRefundShopAuditStatus)itemrefund.SellerAuditStatus).ToDescription(); } else { showRefundStats = itemrefund.SellerAuditStatus.ToDescription(); } orderItem.ShowRefundStats = showRefundStats; } orderItem.EnabledRefundAmount = oItem.EnabledRefundAmount; var typeInfo = _iTypeService.GetTypeByProductId(oItem.ProductId); var prodata = ProductManagerApplication.GetProduct(oItem.ProductId); orderItem.ColorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; orderItem.SizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; orderItem.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (prodata != null) { orderItem.ColorAlias = !string.IsNullOrWhiteSpace(prodata.ColorAlias) ? prodata.ColorAlias : orderItem.ColorAlias; orderItem.SizeAlias = !string.IsNullOrWhiteSpace(prodata.SizeAlias) ? prodata.SizeAlias : orderItem.SizeAlias; orderItem.VersionAlias = !string.IsNullOrWhiteSpace(prodata.VersionAlias) ? prodata.VersionAlias : orderItem.VersionAlias; } return(orderItem); }).ToList(), ReceiveBonus = shopBonus.GetGrantByUserOrder(item.Id, CurrentUser.Id), }).ToList(); foreach (var o in orderList) { o.HasAppendComment = HasAppendComment(o); if (o.ReceiveBonus != null) { var bouns = shopBonus.GetByGrantId(o.ReceiveBonus.Id); o.ReceiveBonusCount = bouns?.Count ?? 0; } } #region 数据补偿 List <long> ordidl = orderList.Select(d => d.Id).ToList(); if (ordidl.Count > 0) { foreach (var item in orderList) { if (item.OrderType != OrderInfo.OrderTypes.Virtual) { var _ord = orders.Models.FirstOrDefault(o => o.Id == item.Id); item.IsRefundTimeOut = OrderApplication.IsRefundTimeOut(_ord); item.EnabledRefundAmount = _ord.OrderEnabledRefundAmount; //退款状态补偿 var _tmpobj = orderRefunds.FirstOrDefault(d => d.OrderId == item.Id && d.RefundMode == OrderRefundInfo.OrderRefundMode.OrderRefund); if (_tmpobj != null) { item.RefundStats = (int)_tmpobj.SellerAuditStatus; item.OrderRefundId = _tmpobj.Id; } item.OrderCanRefund = false; if (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.Finish) { if (item.FinishDate.Value.AddDays(siteSetting.SalesReturnTimeout) > DateTime.Now) { item.OrderCanRefund = true; } } if (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitReceiving) { item.OrderCanRefund = true; } if (item.PaymentType == Entities.OrderInfo.PaymentTypes.CashOnDelivery) { if (item.OrderStatus == Entities.OrderInfo.OrderOperateStatus.Finish) { item.OrderCanRefund = true; } } else { item.OrderCanRefund = true; } item.FightGroupCanRefund = true; //非拼团订单默认可退 //拼团状态补偿 if (item.OrderType == Entities.OrderInfo.OrderTypes.FightGroup) { var fgord = _iFightGroupService.GetFightGroupOrderStatusByOrderId(item.Id); if (fgord != null) { item.FightGroupJoinStatus = fgord.GetJoinStatus; item.FightGroupCanRefund = fgord.CanRefund; } else { item.FightGroupJoinStatus = CommonModel.FightGroupOrderJoinStatus.JoinFailed; item.FightGroupCanRefund = false; } item.OrderCanRefund = item.OrderCanRefund && item.FightGroupCanRefund; } } else { var itemInfo = item.OrderItemList.FirstOrDefault(); if (itemInfo != null) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(itemInfo.ProductId); if (virtualProductInfo != null) { //如果该商品支持退款,而订单状态为待消费,则可退款 if (virtualProductInfo.SupportRefundType == (sbyte)ProductInfo.SupportVirtualRefundType.SupportAnyTime) { if (item.OrderStatus == OrderInfo.OrderOperateStatus.WaitVerification) { item.OrderCanRefund = true; } } else if (virtualProductInfo.SupportRefundType == (sbyte)ProductInfo.SupportVirtualRefundType.SupportValidity) { if (virtualProductInfo.EndDate.Value > DateTime.Now) { if (item.OrderStatus == OrderInfo.OrderOperateStatus.WaitVerification) { item.OrderCanRefund = true; } } } else if (virtualProductInfo.SupportRefundType == (sbyte)ProductInfo.SupportVirtualRefundType.NonSupport) { item.OrderCanRefund = false; } if (item.OrderCanRefund) { var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { item.Id }); long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count(); if (num > 0) { item.OrderCanRefund = true; } else { item.OrderCanRefund = false; } } } } } } } #endregion ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View(orderList.ToList())); }
public object GetOrderDetail(long id) { CheckUserLogin(); OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(id, CurrentUser.Id); var orderService = ServiceProvider.Instance <IOrderService> .Create; var bonusService = ServiceProvider.Instance <IShopBonusService> .Create; var orderRefundService = ServiceProvider.Instance <IRefundService> .Create; var bonusmodel = bonusService.GetGrantByUserOrder(id, CurrentUser.Id); bool hasBonus = bonusmodel != null ? true : false; string shareHref = ""; string shareTitle = ""; string shareDetail = ""; string shareImg = ""; if (hasBonus) { shareHref = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/shopbonus/index/" + bonusService.GetGrantIdByOrderId(id); var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId); shareTitle = bonus.ShareTitle; shareDetail = bonus.ShareDetail; shareImg = HimallIO.GetRomoteImagePath(bonus.ShareImg); } var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId); var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(order.ShopId); var shop = ShopApplication.GetShop(order.ShopId); var orderItems = OrderApplication.GetOrderItemsByOrderId(order.Id); var products = ProductManagerApplication.GetProducts(orderItems.Select(p => p.ProductId)); var refunds = OrderApplication.GetOrderRefundsByOrder(order.Id); //获取订单商品项数据 var orderDetail = new { ShopId = shop.Id, ShopName = shop.ShopName, OrderItems = orderItems.Select(item => { var product = products.FirstOrDefault(p => p.Id == item.ProductId); var typeInfo = TypeApplication.GetType(product.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (product != null) { colorAlias = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias; sizeAlias = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias; versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias; } var itemrefund = refunds.FirstOrDefault(d => d.OrderItemId == item.Id && d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund); int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus); itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate); var IsCanRefund = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id); return(new { ItemId = item.Id, ProductId = item.ProductId, ProductName = item.ProductName, Count = item.Quantity, Price = item.SalePrice, ProductImage = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100), color = item.Color, size = item.Size, version = item.Version, IsCanRefund = IsCanRefund, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, EnabledRefundAmount = item.EnabledRefundAmount, OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id), RefundStats = itemrefstate }); }) }; //取拼团订单状态 var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id); var _ordrefobj = orderRefundService.GetOrderRefundByOrderId(order.Id) ?? new OrderRefundInfo { Id = 0 }; if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp) { _ordrefobj = new OrderRefundInfo { Id = 0 }; } int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus); ordrefstate = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate); var hasAppendComment = ServiceProvider.Instance <ICommentService> .Create.HasAppendComment(orderItems.FirstOrDefault().Id); var orderModel = new { Id = order.Id, OrderType = order.OrderType, OrderTypeName = order.OrderType.ToDescription(), Status = order.OrderStatus.ToDescription(), JoinStatus = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus, ShipTo = order.ShipTo, Phone = order.CellPhone, Address = order.RegionFullName + " " + order.Address, HasExpressStatus = !string.IsNullOrWhiteSpace(order.ShipOrderNumber), ExpressCompanyName = order.ExpressCompanyName, Freight = order.Freight, Tax = order.Tax, IntegralDiscount = order.IntegralDiscount, RealTotalAmount = order.OrderTotalAmount, CapitalAmount = order.CapitalAmount, RefundTotalAmount = order.RefundTotalAmount, ProductTotalAmount = order.ProductTotalAmount, OrderPayAmount = order.OrderPayAmount,//订单需要第三方支付的金额 PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName, PaymentTypeDesc = order.PaymentTypeDesc, OrderDate = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"), ShopName = order.ShopName, VShopId = vshop == null ? 0 : vshop.Id, commentCount = OrderApplication.GetOrderCommentCount(order.Id), ShopId = order.ShopId, orderStatus = (int)order.OrderStatus, //Invoice = order.InvoiceType.ToDescription(), //InvoiceValue = (int)order.InvoiceType, //InvoiceContext = order.InvoiceContext, //InvoiceTitle = order.InvoiceTitle, //InvoiceCode = order.InvoiceCode, PaymentType = order.PaymentType.ToDescription(), PaymentTypeValue = (int)order.PaymentType, FullDiscount = order.FullDiscount, DiscountAmount = order.DiscountAmount, OrderRemarks = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks, HasBonus = hasBonus, ShareHref = shareHref, ShareTitle = shareTitle, ShareDetail = shareDetail, ShareImg = shareImg, IsCanRefund = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, ordrefstate, null), RefundStats = ordrefstate, OrderRefundId = _ordrefobj.Id > 0 ? _ordrefobj.Id : 0, EnabledRefundAmount = order.OrderEnabledRefundAmount, HasAppendComment = hasAppendComment, SelfTake = order.DeliveryType == Himall.CommonModel.DeliveryType.SelfTake ? 1 : 0, OrderInvoice = OrderApplication.GetOrderInvoiceInfo(order.Id) }; #region 门店配送信息 Himall.DTO.ShopBranch storeInfo = null; if (order.ShopBranchId > 0) { storeInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId); } #endregion #region 虚拟订单信息 VirtualProductInfo virtualProductInfo = null; int validityType = 0; string startDate = string.Empty, endDate = string.Empty; List <dynamic> orderVerificationCodes = null; List <dynamic> virtualOrderItemInfos = null; bool isCanRefundVirtual = false; if (order.OrderType == OrderInfo.OrderTypes.Virtual) { var orderItemInfo = orderItems.FirstOrDefault(); if (orderItemInfo != null) { virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType ? 1 : 0; if (validityType == 1) { startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); endDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); } } var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }); orderVerificationCodes = codes.Select(p => { return(new { VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "), Status = p.Status, StatusText = p.Status.ToDescription(), QRCode = GetQRCode(p.VerificationCode) }); }).ToList <dynamic>(); var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id); virtualOrderItemInfos = virtualItems.Select(p => { return(new { VirtualProductItemName = p.VirtualProductItemName, Content = ReplaceImage(p.Content, p.VirtualProductItemType), VirtualProductItemType = p.VirtualProductItemType }); }).ToList <dynamic>(); } } if (order.OrderStatus == Himall.Entities.OrderInfo.OrderOperateStatus.WaitVerification) { if (virtualProductInfo != null) { if (virtualProductInfo.SupportRefundType == 2) { isCanRefundVirtual = true; } else if (virtualProductInfo.SupportRefundType == 1) { if (virtualProductInfo.EndDate.Value > DateTime.Now) { isCanRefundVirtual = true; } } else if (virtualProductInfo.SupportRefundType == 3) { isCanRefundVirtual = false; } if (isCanRefundVirtual) { long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count(); if (num > 0) { isCanRefundVirtual = true; } else { isCanRefundVirtual = false; } } } } #endregion #region 虚拟订单核销地址信息 string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (order.OrderType == OrderInfo.OrderTypes.Virtual) { if (order.ShopBranchId > 0 && storeInfo != null) { shipperAddress = RegionApplication.GetFullName(storeInfo.AddressId) + " " + storeInfo.AddressDetail; shipperTelPhone = storeInfo.ContactPhone; } else { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId); if (verificationShipper != null) { shipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; shipperTelPhone = verificationShipper.TelPhone; } } } #endregion return(new { success = true, Order = orderModel, OrderItem = orderDetail.OrderItems, StoreInfo = storeInfo, CustomerServices = customerServices, ValidityType = validityType, StartDate = startDate, EndDate = endDate, OrderVerificationCodes = orderVerificationCodes, VirtualOrderItemInfos = virtualOrderItemInfos, IsCanRefundVirtual = isCanRefundVirtual, ShipperAddress = shipperAddress, ShipperTelPhone = shipperTelPhone }); }
/// <summary> /// 订单详细信息页面 /// </summary> /// <param name="id">订单Id</param> public ActionResult Detail(long id) { OrderDetailView view = OrderApplication.Detail(id, UserId, PlatformType, Request.Url.Host); ViewBag.Detail = view.Detail; ViewBag.Bonus = view.Bonus; ViewBag.ShareHref = view.ShareHref; ViewBag.IsRefundTimeOut = view.IsRefundTimeOut; ViewBag.Logo = SiteSettings.Logo; view.Order.FightGroupOrderJoinStatus = view.FightGroupJoinStatus; view.Order.FightGroupCanRefund = view.FightGroupCanRefund; var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(view.Order.ShopId); ViewBag.CustomerServices = customerServices; string shipperAddress = string.Empty, shipperTelPhone = string.Empty; #region 门店信息 if (view.Order.ShopBranchId > 0) { var shopBranchInfo = ShopBranchApplication.GetShopBranchById(view.Order.ShopBranchId); ViewBag.ShopBranchInfo = shopBranchInfo; if (view.Order.OrderType == OrderInfo.OrderTypes.Virtual && shopBranchInfo != null) { shipperAddress = RegionApplication.GetFullName(shopBranchInfo.AddressId) + " " + shopBranchInfo.AddressDetail; shipperTelPhone = shopBranchInfo.ContactPhone; } } else { if (view.Order.OrderType == OrderInfo.OrderTypes.Virtual) { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(view.Order.ShopId); if (verificationShipper != null) { shipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; shipperTelPhone = verificationShipper.TelPhone; } } } #endregion ViewBag.isCanRefundOrder = OrderApplication.CanRefund(view.Order); #region 虚拟订单信息 if (view.Order.OrderType == OrderInfo.OrderTypes.Virtual) { var orderItemInfo = view.Detail.OrderItems.FirstOrDefault(); if (orderItemInfo != null) { ViewBag.virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { view.Order.Id }); orderVerificationCodes.ForEach(a => { a.QRCode = GetQRCode(a.VerificationCode); }); ViewBag.orderVerificationCodes = orderVerificationCodes; ViewBag.virtualOrderItemInfos = OrderApplication.GetVirtualOrderItemInfosByOrderId(view.Order.Id); } } #endregion //发票信息 ViewBag.OrderInvoiceInfo = OrderApplication.GetOrderInvoiceInfo(view.Order.Id); //统一显示支付方式名称 view.Order.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(view.Order.PaymentTypeGateway) ?? view.Order.PaymentTypeName; ViewBag.ShipperAddress = shipperAddress; ViewBag.ShipperTelPhone = shipperTelPhone; return(View(view.Order)); }
/// <summary> /// 根据核销码取订单 /// </summary> /// <param name="pickcode"></param> /// <returns></returns> public object GetShopOrder(string pickcode) { CheckUserLogin(); var codeInfo = OrderApplication.GetOrderVerificationCodeInfoByCode(pickcode); if (codeInfo == null) { return new { success = false, msg = "该核销码无效" } } ; var order = OrderApplication.GetOrderInfo(codeInfo.OrderId); if (order == null) { return new { success = false, msg = "该核销码无效" } } ; if (order.OrderType != OrderInfo.OrderTypes.Virtual) { return new { success = false, msg = "核销订单无效" } } ; if (order.ShopId != this.CurrentShop.Id) { return new { success = false, msg = "非本店核销码,请买家核对信息" } } ; if (order.ShopBranchId > 0)//商家只能核销本商家,而非下面门店的 { return new { success = false, msg = "非本店核销码,请买家核对信息" } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.AlreadyVerification) { return new { success = false, msg = string.Format("该核销码于{0}已核销", codeInfo.VerificationTime.Value.ToString("yyyy-MM-dd HH:mm")) } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.Expired) { return new { success = false, msg = "此核销码已过期,无法核销" } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.Refund) { return new { success = false, msg = "此核销码正处于退款中,无法核销" } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.RefundComplete) { return new { success = false, msg = "此核销码已经退款成功,无法核销" } } ; var orderItem = Application.OrderApplication.GetOrderItemsByOrderId(order.Id); var orderItemInfo = orderItem.FirstOrDefault(); var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now < virtualProductInfo.StartDate.Value) { return(new { success = false, msg = "该核销码暂时不能核销,请留意生效时间!" }); } if (orderItemInfo.EffectiveDate.HasValue) { if (DateTime.Now < orderItemInfo.EffectiveDate.Value) { return new { success = false, msg = "该核销码暂时不能核销,请留意生效时间!" } } ; } foreach (var item in orderItem) { item.ThumbnailsUrl = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_100); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetTypeByProductId(item.ProductId); item.ColorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; item.SizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; item.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; var productInfo = ProductManagerApplication.GetProduct(item.ProductId); if (productInfo != null) { item.ColorAlias = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : item.ColorAlias; item.SizeAlias = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : item.SizeAlias; item.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : item.VersionAlias; } } int validityType = 0; string startDate = string.Empty, endDate = string.Empty; if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType ? 1 : 0; if (validityType == 1) { startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); endDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); } } var verifications = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }).Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification); var codes = verifications.ToList();//待消费的核销码 if (codes != null) { codes.ForEach(a => { a.SourceCode = a.VerificationCode; a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, "(\\d{4})\\d{4}(\\d{4})", "$1****$2"); }); } var verificationCode = codes.Select(p => { return(new { Status = p.Status, VerificationCode = p.VerificationCode, SourceCode = p.SourceCode }); }); var virtualOrderItemInfos = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id).Select(p => { return(new { VirtualProductItemType = p.VirtualProductItemType, VirtualProductItemName = p.VirtualProductItemName, Content = ReplaceImage(p.Content, p.VirtualProductItemType) }); }); order.OrderStatusText = order.OrderStatus.ToDescription(); order.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName;//统一显示支付方式名称 return(new { success = true, order = order, orderItem = orderItem, virtualOrderItemInfos = virtualOrderItemInfos, verificationCodes = verificationCode, validityType = validityType, startDate = startDate, endDate = endDate }); }
/// <summary> /// 获取立即购买提交页面的数据 /// </summary> /// <param name="skuIds">库存ID集合</param> /// <param name="counts">库存ID对应的数量</param> object GetSubmitModelById(string skuId, int count, long shippingAddressId = 0, IEnumerable <string[]> CouponIdsStr = null, bool isStore = false, sbyte productType = 0, long shopBranchId = 0) { CheckUserLogin(); dynamic d = new System.Dynamic.ExpandoObject(); var siteconfig = SiteSettingApplication.SiteSettings; var result = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, CouponIdsStr, shopBranchId); dynamic add = new System.Dynamic.ExpandoObject(); if (result.Address != null) { add = new { ShippingId = result.Address.Id, ShipTo = result.Address.ShipTo, CellPhone = result.Address.Phone, FullRegionName = result.Address.RegionFullName, FullAddress = result.Address.RegionFullName + " " + result.Address.Address + " " + result.Address.AddressDetail, Address = result.Address.Address, RegionId = result.Address.RegionId }; } else { add = null; } string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (isStore) { if (productType == 0) { throw new MallException("门店订单暂时不允许立即购买"); } //门店订单 Mall.DTO.ShopBranch storeInfo = Application.ShopBranchApplication.GetShopBranchById(shopBranchId); if (storeInfo == null) { throw new MallException("获取门店信息失败,不可提交非门店商品"); } d.shopBranchId = shopBranchId; d.shopBranchInfo = storeInfo; if (storeInfo != null) { shipperAddress = RegionApplication.GetFullName(storeInfo.AddressId) + storeInfo.AddressDetail; shipperTelPhone = storeInfo.ContactPhone; } } d.ProductType = productType; if (result.ProductType == 1) { d.VirtualProductItemInfos = ProductManagerApplication.GetVirtualProductItemInfoByProductId(result.ProductId); var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new MallException("该虚拟商品已过期,不支持下单"); } if (result.products != null && result.products.Count > 0 && !isStore) { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);//虚拟订单支持立即购买所以商家只有一个 if (verificationShipper != null) { shipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; shipperTelPhone = verificationShipper.TelPhone; } } } d.shipperAddress = shipperAddress; d.shipperTelPhone = shipperTelPhone; bool canIntegralPerMoney = true, canCapital = true; CanDeductible(out canIntegralPerMoney, out canCapital); d.InvoiceContext = result.InvoiceContext; d.InvoiceTitle = result.InvoiceTitle; d.cellPhone = result.cellPhone; d.email = result.email; d.vatInvoice = result.vatInvoice; d.invoiceName = result.invoiceName; //默认抬头(普通、电子) d.invoiceCode = result.invoiceCode; //默认税号(普通、电子) d.products = result.products; d.TotalAmount = result.totalAmount; d.Freight = result.Freight; d.orderAmount = result.orderAmount; d.IsCashOnDelivery = result.IsCashOnDelivery; d.IsOpenStore = siteconfig.IsOpenStore; d.Address = add; d.integralPerMoney = result.integralPerMoney; d.userIntegralMaxDeductible = result.userIntegralMaxDeductible; d.integralPerMoneyRate = result.integralPerMoneyRate; d.userIntegralMaxRate = siteconfig.IntegralDeductibleRate; d.userIntegrals = result.userIntegrals; d.TotalMemberIntegral = result.memberIntegralInfo.AvailableIntegrals; d.canIntegralPerMoney = canIntegralPerMoney; d.canCapital = canCapital; d.capitalAmount = result.capitalAmount; return(Json(d)); }
public object GetOrderDetail(long orderId) { CheckUserLogin(); var orderService = ServiceProvider.Instance <IOrderService> .Create; var order = orderService.GetOrder(orderId, CurrentUser.Id); var orderitems = orderService.GetOrderItemsByOrderId(order.Id); var orderRefundService = ServiceProvider.Instance <IRefundService> .Create; var productService = ServiceProvider.Instance <IProductService> .Create; var coupon = ServiceProvider.Instance <ICouponService> .Create.GetCouponRecordInfo(order.UserId, order.Id); string couponName = ""; decimal couponAmout = 0; if (coupon != null) { var c = CouponApplication.GetCouponInfo(coupon.CouponId); couponName = c.CouponName; couponAmout = c.Price; } //订单信息是否正常 if (order == null) { throw new MallException("订单号不存在!"); } dynamic expressTrace = new ExpandoObject(); //取订单物流信息 if (!string.IsNullOrWhiteSpace(order.ShipOrderNumber)) { var expressData = ServiceProvider.Instance <IExpressService> .Create.GetExpressData(order.ExpressCompanyName, order.ShipOrderNumber); if (expressData.Success) { expressData.ExpressDataItems = expressData.ExpressDataItems.OrderByDescending(item => item.Time);//按时间逆序排列 expressTrace.traces = expressData.ExpressDataItems.Select(item => new { acceptTime = item.Time.ToString("yyyy-MM-dd HH:mm:ss"), acceptStation = item.Content }); } } var orderRefunds = OrderApplication.GetOrderRefunds(orderitems.Select(p => p.Id)); var isCanOrderReturn = OrderApplication.CanRefund(order); //获取订单商品项数据 var orderDetail = new { ShopId = order.ShopId, EnabledRefundAmount = order.OrderEnabledRefundAmount, OrderItems = orderitems.Select(item => { var productinfo = productService.GetProduct(item.ProductId); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(productinfo.TypeId); string colorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; string sizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; var itemStatusText = ""; var itemrefund = orderRefunds.Where(or => or.OrderItemId == item.Id).FirstOrDefault(d => d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund); int?itemrefstate = (itemrefund == null ? 0 : (int?)itemrefund.SellerAuditStatus); itemrefstate = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate); if (itemrefund != null) { //默认为商家处理进度 if (itemrefstate == 4) { //商家拒绝,可以再发起申请 itemStatusText = ""; } else { itemStatusText = "售后处理中"; } } if (itemrefstate > 4) {//如果商家已经处理完,则显示平台处理进度 if (itemrefstate == 7) { itemStatusText = "退款成功"; } } if (productinfo != null) { colorAlias = (!string.IsNullOrWhiteSpace(productinfo.ColorAlias)) ? productinfo.ColorAlias : colorAlias;//如果商品有自定义规格名称,则用 sizeAlias = (!string.IsNullOrWhiteSpace(productinfo.SizeAlias)) ? productinfo.SizeAlias : sizeAlias; versionAlias = (!string.IsNullOrWhiteSpace(productinfo.VersionAlias)) ? productinfo.VersionAlias : versionAlias; } long activeId = 0; int activetype = 0; var limitbuyser = ServiceProvider.Instance <ILimitTimeBuyService> .Create; var limitBuy = limitbuyser.GetLimitTimeMarketItemByProductId(item.ProductId); if (limitBuy != null) { //salePrice = limitBuy.MinPrice; activeId = limitBuy.Id; activetype = 1; } else { #region 限时购预热 var FlashSale = limitbuyser.IsFlashSaleDoesNotStarted(item.ProductId); var FlashSaleConfig = limitbuyser.GetConfig(); if (FlashSale != null) { TimeSpan flashSaleTime = DateTime.Parse(FlashSale.BeginDate) - DateTime.Now; //开始时间还剩多久 TimeSpan preheatTime = new TimeSpan(FlashSaleConfig.Preheat, 0, 0); //预热时间是多久 if (preheatTime >= flashSaleTime) //预热大于开始 { if (!FlashSaleConfig.IsNormalPurchase) { activeId = FlashSale.Id; activetype = 1; } } } #endregion } return(new { Status = itemrefstate, StatusText = itemStatusText, Id = item.Id, SkuId = item.SkuId, ProductId = item.ProductId, Name = item.ProductName, Amount = item.Quantity, Price = item.SalePrice, //ProductImage = "http://" + Url.Request.RequestUri.Host + productService.GetProduct(item.ProductId).GetImage(ProductInfo.ImageSize.Size_100), Image = Core.MallIO.GetRomoteProductSizeImage(productService.GetProduct(item.ProductId).RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_100), color = item.Color, size = item.Size, version = item.Version, IsCanRefund = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id), ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, SkuText = colorAlias + ":" + item.Color + ";" + sizeAlias + ":" + item.Size + ";" + versionAlias + ":" + item.Version, EnabledRefundAmount = item.EnabledRefundAmount, ActiveId = activeId, //活动Id ActiveType = activetype //活动类型(1代表限购,2代表团购,3代表商品预售,4代表限购预售,5代表团购预售) }); }) }; //取拼团订单状态 var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id); #region 门店信息 var branchInfo = new ShopBranch(); if (order.ShopBranchId > 0) { branchInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId); } else { branchInfo = null; } #endregion #region 虚拟订单信息 VirtualProductInfo virtualProductInfo = null; int validityType = 0; string startDate = string.Empty, endDate = string.Empty; List <dynamic> orderVerificationCodes = null; List <dynamic> virtualOrderItemInfos = null; bool isCanRefundVirtual = false; if (order.OrderType == OrderInfo.OrderTypes.Virtual) { var orderItemInfo = orderitems.FirstOrDefault(); if (orderItemInfo != null) { virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null) { validityType = virtualProductInfo.ValidityType ? 1 : 0; if (validityType == 1) { startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); endDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); } } var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }); orderVerificationCodes = codes.Select(p => { return(new { VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "), Status = p.Status, StatusText = p.Status.ToDescription(), QRCode = GetQRCode(p.VerificationCode) }); }).ToList <dynamic>(); var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id); virtualOrderItemInfos = virtualItems.Select(p => { return(new { VirtualProductItemName = p.VirtualProductItemName, Content = ReplaceImage(p.Content, p.VirtualProductItemType), VirtualProductItemType = p.VirtualProductItemType }); }).ToList <dynamic>(); } } if (order.OrderStatus == Mall.Entities.OrderInfo.OrderOperateStatus.WaitVerification) { if (virtualProductInfo != null) { if (virtualProductInfo.SupportRefundType == 2) { isCanRefundVirtual = true; } else if (virtualProductInfo.SupportRefundType == 1) { if (virtualProductInfo.EndDate.Value > DateTime.Now) { isCanRefundVirtual = true; } } else if (virtualProductInfo.SupportRefundType == 3) { isCanRefundVirtual = false; } if (isCanRefundVirtual) { long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count(); if (num > 0) { isCanRefundVirtual = true; } else { isCanRefundVirtual = false; } } } } #endregion #region 虚拟订单核销地址信息 string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (order.OrderType == OrderInfo.OrderTypes.Virtual) { if (order.ShopBranchId > 0 && branchInfo != null) { shipperAddress = RegionApplication.GetFullName(branchInfo.AddressId) + " " + branchInfo.AddressDetail; shipperTelPhone = branchInfo.ContactPhone; } else { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId); if (verificationShipper != null) { shipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; shipperTelPhone = verificationShipper.TelPhone; } } } #endregion var bonusmodel = ServiceProvider.Instance <IShopBonusService> .Create.GetGrantByUserOrder(orderId, CurrentUser.Id); bool hasBonus = bonusmodel != null ? true : false; string shareHref = ""; string shareTitle = ""; string shareDetail = ""; string shareImg = ""; if (hasBonus) { shareHref = "/m-weixin/ShopBonus/Index/" + ServiceProvider.Instance <IShopBonusService> .Create.GetGrantIdByOrderId(orderId); var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId); shareTitle = bonus.ShareTitle; shareDetail = bonus.ShareDetail; shareImg = MallIO.GetRomoteImagePath(bonus.ShareImg); } var orderModel = new { OrderId = order.Id, Status = (int)order.OrderStatus, StatusText = order.OrderStatus.ToDescription(), EnabledRefundAmount = order.OrderEnabledRefundAmount, OrderTotal = order.OrderTotalAmount, CapitalAmount = order.CapitalAmount, OrderAmount = order.ProductTotalAmount, DeductionPoints = 0, DeductionMoney = order.IntegralDiscount, //CouponAmount = couponAmout.ToString("F2"),//优惠劵金额 CouponAmount = order.DiscountAmount, //优惠劵金额 CouponName = couponName, //优惠劵名称 RefundAmount = order.RefundTotalAmount, Tax = order.Tax, AdjustedFreight = order.Freight, OrderDate = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"), ItemStatus = 0, ItemStatusText = "", ShipTo = order.ShipTo, ShipToDate = order.ShippingDate.HasValue ? order.ShippingDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", Cellphone = order.CellPhone, Address = order.DeliveryType == CommonModel.DeliveryType.SelfTake && branchInfo != null ? branchInfo.AddressFullName : (order.RegionFullName + " " + order.Address), FreightFreePromotionName = string.Empty, ReducedPromotionName = string.Empty, ReducedPromotionAmount = order.FullDiscount, SentTimesPointPromotionName = string.Empty, CanBackReturn = !string.IsNullOrWhiteSpace(order.PaymentTypeGateway), CanCashierReturn = false, PaymentType = order.PaymentType.ToDescription(), OrderPayAmount = order.OrderPayAmount,//订单需要第三方支付的金额 PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName, PaymentTypeDesc = order.PaymentTypeDesc, Remark = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks, //InvoiceTitle = order.InvoiceTitle, //Invoice = order.InvoiceType.ToDescription(), //InvoiceValue = (int)order.InvoiceType, //InvoiceContext = order.InvoiceContext, //InvoiceCode = order.InvoiceCode, ModeName = order.DeliveryType.ToDescription(), LogisticsData = expressTrace, TakeCode = order.PickupCode, LineItems = orderDetail.OrderItems, IsCanRefund = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, null, null), IsSelfTake = order.DeliveryType == Mall.CommonModel.DeliveryType.SelfTake ? 1 : 0, BranchInfo = branchInfo, DeliveryType = (int)order.DeliveryType, OrderInvoice = OrderApplication.GetOrderInvoiceInfo(order.Id), ValidityType = validityType, StartDate = startDate, EndDate = endDate, OrderVerificationCodes = orderVerificationCodes, VirtualOrderItemInfos = virtualOrderItemInfos, IsCanRefundVirtual = isCanRefundVirtual, ShipperAddress = shipperAddress, ShipperTelPhone = shipperTelPhone, OrderType = order.OrderType, JoinStatus = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus, HasBonus = hasBonus, ShareHref = shareHref, ShareTitle = shareTitle, ShareDetail = shareDetail, ShareImg = shareImg, ShopName = order.ShopName }; return(Json(orderModel)); }
/// <summary> /// 退款申请 /// </summary> /// <param name="id"></param> /// <param name="itemId"></param> /// <returns></returns> public ActionResult RefundApply(long orderid, long?itemId, long?refundid) { RefundApplyModel model = new RefundApplyModel(); model.RefundMode = null; model.OrderItemId = null; var order = _iOrderService.GetOrder(orderid, CurrentUser.Id); if (order == null) { throw new Mall.Core.MallException("该订单已删除或不属于该用户"); } if (order.OrderType != OrderInfo.OrderTypes.Virtual && (int)order.OrderStatus < 2) { throw new Mall.Core.MallException("错误的售后申请,订单状态有误"); } if (order.OrderType != OrderInfo.OrderTypes.Virtual && itemId == null && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp) { throw new Mall.Core.MallException("错误的订单退款申请,订单状态有误"); } //售后时间限制 if (order.OrderType != OrderInfo.OrderTypes.Virtual && _iOrderService.IsRefundTimeOut(orderid)) { throw new Mall.Core.MallException("订单已超过售后期"); } if (order.OrderType == OrderInfo.OrderTypes.Virtual) { //如果为虚拟商品,则要判断该商品是否允许退款,且该订单中是否至少有一个待核销的核销码 var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(order.Id).FirstOrDefault(); if (orderItemInfo != null) { itemId = orderItemInfo.Id; var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null) { if (virtualProductInfo.SupportRefundType == 3) { throw new Mall.Core.MallException("该商品不支持退款"); } if (virtualProductInfo.SupportRefundType == 1 && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new Mall.Core.MallException("该商品不支持过期退款"); } var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }); long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count(); if (num == 0) { throw new Mall.Core.MallException("该商品没有可退的核销码"); } } } } //计算可退金额 预留 _iOrderService.CalculateOrderItemRefund(orderid); var item = new Entities.OrderItemInfo(); model.MaxRefundGoodsNumber = 0; model.MaxRefundAmount = order.OrderEnabledRefundAmount; if (itemId == null) { model.OrderItems = _iOrderService.GetOrderItemsByOrderId(order.Id); if (model.OrderItems.Count == 1) { item = model.OrderItems.FirstOrDefault(); } } else { item = _iOrderService.GetOrderItem(itemId.Value); model.OrderItems.Add(item); model.MaxRefundGoodsNumber = item.Quantity - item.ReturnQuantity; model.MaxRefundAmount = item.EnabledRefundAmount - item.RefundPrice; } if (order.OrderType == OrderInfo.OrderTypes.Virtual) { var count = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }).Where(a => a.Status != OrderInfo.VerificationCodeStatus.WaitVerification).ToList().Count; if (item.EnabledRefundAmount.HasValue) { decimal price = item.EnabledRefundAmount.Value / item.Quantity; model.MaxRefundAmount = item.EnabledRefundAmount.Value - Math.Round(count * price, 2, MidpointRounding.AwayFromZero); } } foreach (var orderItem in model.OrderItems) { Entities.TypeInfo typeInfo = _iTypeService.GetTypeByProductId(orderItem.ProductId); var productInfo = ProductManagerApplication.GetProduct(orderItem.ProductId); orderItem.ColorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; orderItem.SizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; orderItem.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; if (productInfo != null) { orderItem.ColorAlias = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : orderItem.ColorAlias; orderItem.SizeAlias = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : orderItem.SizeAlias; orderItem.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : orderItem.VersionAlias; } } if (!model.MaxRefundAmount.HasValue) { model.MaxRefundAmount = 0; } bool isCanApply = false; var refundser = _iRefundService; Entities.OrderRefundInfo refunddata; if (order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitDelivery) { isCanApply = refundser.CanApplyRefund(orderid, item.Id); } else { isCanApply = refundser.CanApplyRefund(orderid, item.Id, false); } if (!refundid.HasValue) { if (order.OrderType != OrderInfo.OrderTypes.Virtual) { if (!isCanApply) { var orderRefunds = OrderApplication.GetOrderRefunds(new long[] { item.Id }); if (orderRefunds.Count == 1) { Response.Redirect("/OrderRefund/Detail/" + orderRefunds[0].Id); } throw new Mall.Core.MallException("您已申请过售后,不可重复申请"); } } //model.ContactPerson = CurrentUser.RealName; //model.ContactCellPhone = CurrentUser.CellPhone; //model.ContactCellPhone = order.CellPhone; model.ContactPerson = string.IsNullOrEmpty(order.ShipTo) ? CurrentUser.RealName : order.ShipTo; model.ContactCellPhone = string.IsNullOrEmpty(order.CellPhone) ? CurrentUser.CellPhone : order.CellPhone; model.OrderItemId = itemId; if (!model.OrderItemId.HasValue) { model.IsOrderAllRefund = true; model.RefundMode = Entities.OrderRefundInfo.OrderRefundMode.OrderRefund; } } else { refunddata = refundser.GetOrderRefund(refundid.Value, CurrentUser.Id); if (refunddata == null) { throw new Mall.Core.MallException("错误的售后数据"); } if (order.OrderType != OrderInfo.OrderTypes.Virtual && refunddata.SellerAuditStatus != Entities.OrderRefundInfo.OrderRefundAuditStatus.UnAudit) { throw new Mall.Core.MallException("错误的售后状态,不可激活"); } model.ContactPerson = refunddata.ContactPerson; model.ContactCellPhone = refunddata.ContactCellPhone; model.OrderItemId = refunddata.OrderItemId; model.IsOrderAllRefund = (refunddata.RefundMode == Entities.OrderRefundInfo.OrderRefundMode.OrderRefund); model.RefundMode = refunddata.RefundMode; model.RefundReasonValue = refunddata.Reason; model.RefundReasonDetail = refunddata.ReasonDetail; model.RefundWayValue = refunddata.RefundPayType; model.CertPic1 = refunddata.CertPic1; model.CertPic2 = refunddata.CertPic2; model.CertPic3 = refunddata.CertPic3; } if (!model.IsOrderAllRefund && item.EnabledRefundAmount.HasValue) { model.RefundGoodsPrice = item.EnabledRefundAmount.Value / item.Quantity; } model.OrderInfo = order; model.OrderId = orderid; model.RefundId = refundid; var reasons = refundser.GetRefundReasons(); foreach (var _ir in reasons) { _ir.AfterSalesText = _ir.AfterSalesText.Trim(); } List <SelectListItem> reasel = new List <SelectListItem>(); SelectListItem _tmpsel; _tmpsel = new SelectListItem { Text = "选择售后理由", Value = "" }; reasel.Add(_tmpsel); foreach (var _i in reasons) { _tmpsel = new SelectListItem { Text = _i.AfterSalesText, Value = _i.AfterSalesText }; if (!string.IsNullOrWhiteSpace(model.RefundReasonValue)) { if (_i.AfterSalesText == model.RefundReasonValue) { _tmpsel.Selected = true; } } reasel.Add(_tmpsel); } model.RefundReasons = reasel; List <SelectListItem> list = new List <SelectListItem> { new SelectListItem { Text = OrderRefundInfo.OrderRefundPayType.BackCapital.ToDescription(), Value = ((int)OrderRefundInfo.OrderRefundPayType.BackCapital).ToString() } }; if (order.CanBackOut()) { _tmpsel = new SelectListItem { Text = OrderRefundInfo.OrderRefundPayType.BackOut.ToDescription(), Value = ((int)OrderRefundInfo.OrderRefundPayType.BackOut).ToString() }; //if (model.RefundWayValue.HasValue) //{ // if (_tmpsel.Value == model.RefundWayValue.ToString()) // { // _tmpsel.Selected = true; // } //} _tmpsel.Selected = true; //若订单支付方式为支付宝、微信支付则退款方式默认选中“退款原路返回” list.Add(_tmpsel); } model.RefundWay = list; if (order.DeliveryType == CommonModel.DeliveryType.SelfTake) { var shopBranch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId); model.ReturnGoodsAddress = RegionApplication.GetFullName(shopBranch.AddressId); model.ReturnGoodsAddress += " " + shopBranch.AddressDetail; model.ReturnGoodsAddress += " " + shopBranch.ContactPhone; } ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; #region 虚拟订单退款 ViewBag.orderVerificationCode = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }).Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).ToList(); #endregion ViewBag.IsVirtual = order.OrderType == OrderInfo.OrderTypes.Virtual ? 1 : 0; return(View(model)); }
/// <summary> /// 获取立即购买提交页面的数据 /// </summary> /// <param name="skuIds">库存ID集合</param> /// <param name="counts">库存ID对应的数量</param> public object GetSubmitModel(string skuId, int count, long shippingAddressId = 0, string couponIds = "") { CheckUserLogin(); var coupons = CouponApplication.ConvertUsedCoupon(couponIds); var result = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, coupons); dynamic d = SuccessResult(); if (result.Address != null && !result.Address.NeedUpdate) { var addDetail = result.Address.AddressDetail ?? ""; var add = new { Id = result.Address.Id, ShipTo = result.Address.ShipTo, Phone = result.Address.Phone, Address = result.Address.RegionFullName + " " + result.Address.Address + " " + addDetail, RegionId = result.Address.RegionId }; d.Address = add; } else { d.Address = null; } bool canIntegralPerMoney = true, canCapital = true; CanDeductible(out canIntegralPerMoney, out canCapital); d.canIntegralPerMoney = canIntegralPerMoney; d.canCapital = canCapital; //发票信息 d.InvoiceContext = result.InvoiceContext; //发票类容 d.InvoiceTitle = result.InvoiceTitle; //发票抬头 d.cellPhone = result.cellPhone; //默认收票人手机 d.email = result.email; //默认收票人邮箱 d.vatInvoice = result.vatInvoice; //默认增值税发票 d.invoiceName = result.invoiceName; //默认抬头(普通、电子) d.invoiceCode = result.invoiceCode; //默认税号(普通、电子) d.products = result.products; d.capitalAmount = result.capitalAmount; d.TotalAmount = result.totalAmount; d.Freight = result.Freight; d.orderAmount = result.orderAmount; d.IsCashOnDelivery = result.IsCashOnDelivery; d.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore; d.ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList()); d.integralPerMoney = result.integralPerMoney; d.userIntegralMaxDeductible = result.userIntegralMaxDeductible; d.integralPerMoneyRate = result.integralPerMoneyRate; d.userIntegralMaxRate = SiteSettingApplication.SiteSettings.IntegralDeductibleRate; d.userIntegrals = result.userIntegrals; d.TotalMemberIntegral = result.memberIntegralInfo.AvailableIntegrals; d.productType = result.ProductType; string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (result.ProductType == 1) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new HimallException("该虚拟商品已过期,不支持下单"); } if (result.products != null && result.products.Count > 0) { var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(result.products.FirstOrDefault().shopId);//虚拟订单支持立即购买所以商家只有一个 if (verificationShipper != null) { shipperAddress = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address; shipperTelPhone = verificationShipper.TelPhone; } } } d.shipperAddress = shipperAddress; d.shipperTelPhone = shipperTelPhone; return(d); }
/// <summary> /// 进入立即购买提交页面 /// </summary> /// <param name="skuIds">库存ID集合</param> /// <param name="counts">库存ID对应的数量</param> /// <param name="GroupActionId">拼团活动编号</param> /// <param name="GroupId">拼团编号</param> public ActionResult Submit(string skuIds, string counts, int islimit = 0, long shippingAddressId = 0, string couponIds = "", sbyte productType = 0, long shopBranchId = 0) { if (productType == 0) { throw new MallException("门店订单不支持立即购买"); } var coupons = CouponApplication.ConvertUsedCoupon(couponIds); var result = OrderApplication.GetMobileSubmit(UserId, skuIds, counts, shippingAddressId, coupons, shopBranchId); ViewBag.InvoiceContext = result.InvoiceContext; ViewBag.InvoiceTitle = result.InvoiceTitle; ViewBag.skuIds = skuIds; ViewBag.counts = counts; ViewBag.IsCashOnDelivery = result.IsCashOnDelivery; ViewBag.address = null == result.Address || result.Address.NeedUpdate ? null : result.Address; if (result.products != null) { var bid = result.products.FirstOrDefault().ShopBranchId; result.shopBranchInfo = ShopBranchApplication.GetShopBranchInfoById(bid); } ViewBag.ConfirmModel = result; ViewBag.Islimit = islimit == 1 ? true : false; string orderTag = Guid.NewGuid().ToString("N"); ViewBag.OrderTag = orderTag; //Session["OrderTag"] = orderTag; base.HttpContext.Session.Set <string>("OrderTag", orderTag); InitOrderSubmitModel(result); #region 是否开启门店授权 ViewBag.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore; #endregion #region 是否提供发票 bool ProvideInvoice = false; if (result.products != null) { ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(p => p.shopId).ToList()); } ViewBag.ProvideInvoice = ProvideInvoice; #endregion bool canIntegralPerMoney = true, canCapital = true; CanDeductible(out canIntegralPerMoney, out canCapital); ViewBag.CanIntegralPerMoney = canIntegralPerMoney; ViewBag.CanCapital = canCapital; ViewBag.productType = productType; ViewBag.shopBranchId = shopBranchId; string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (productType == 1) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new MallException("该虚拟商品已过期,不支持下单"); } if (result.shopBranchInfo != null) { shipperAddress = RegionApplication.GetFullName(result.shopBranchInfo.AddressId) + result.shopBranchInfo.AddressDetail; shipperTelPhone = result.shopBranchInfo.ContactPhone; } } ViewBag.ShipperAddress = shipperAddress; ViewBag.ShipperTelPhone = shipperTelPhone; return(View()); }
/// <summary> /// 根据提货码取订单 /// </summary> /// <param name="pickcode"></param> /// <returns></returns> public object GetShopBranchOrder(string pickcode) { CheckUserLogin(); var codeInfo = OrderApplication.GetOrderVerificationCodeInfoByCode(pickcode); if (codeInfo != null) { var order = OrderApplication.GetOrderInfo(codeInfo.OrderId); if (order == null) { return new { success = false, msg = "该核销码无效" } } ; if (order.OrderType != OrderInfo.OrderTypes.Virtual) { return new { success = false, msg = "核销订单无效" } } ; if (order.ShopBranchId != CurrentShopBranch.Id) { return new { success = false, msg = "非本店核销码,请买家核对信息" } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.AlreadyVerification) { return new { success = false, msg = string.Format("该核销码于{0}已核销", codeInfo.VerificationTime.Value.ToString("yyyy-MM-dd HH:mm")) } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.Expired) { return new { success = false, msg = "此核销码已过期,无法核销" } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.Refund) { return new { success = false, msg = "此核销码正处于退款中,无法核销" } } ; if (codeInfo.Status == OrderInfo.VerificationCodeStatus.RefundComplete) { return new { success = false, msg = "此核销码已经退款成功,无法核销" } } ; var orderItem = Application.OrderApplication.GetOrderItemsByOrderId(order.Id); var orderItemInfo = orderItem.FirstOrDefault(); var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now < virtualProductInfo.StartDate.Value) { return(new { success = false, msg = "该核销码暂时不能核销,请留意生效时间!" }); } if (orderItemInfo.EffectiveDate.HasValue) { if (DateTime.Now < orderItemInfo.EffectiveDate.Value) { return new { success = false, msg = "该核销码暂时不能核销,请留意生效时间!" } } ; } foreach (var item in orderItem) { item.ThumbnailsUrl = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_100); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetTypeByProductId(item.ProductId); item.ColorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; item.SizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; item.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; var productInfo = ProductManagerApplication.GetProduct(item.ProductId); if (productInfo != null) { item.ColorAlias = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : item.ColorAlias; item.SizeAlias = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : item.SizeAlias; item.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : item.VersionAlias; } } var verifications = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }).Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification); var codes = verifications.ToList();//待消费的核销码 if (codes != null) { codes.ForEach(a => { a.SourceCode = a.VerificationCode; a.VerificationCode = System.Text.RegularExpressions.Regex.Replace(a.VerificationCode, "(\\d{4})\\d{4}(\\d{4})", "$1****$2"); }); } var virtualOrderItemInfos = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id).Select(p => { return(new { VirtualProductItemType = p.VirtualProductItemType, VirtualProductItemName = p.VirtualProductItemName, Content = ReplaceImage(p.Content, p.VirtualProductItemType) }); }); order.OrderStatusText = order.OrderStatus.ToDescription(); order.PaymentTypeName = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName;//统一显示支付方式名称 return(new { success = true, order = order, orderItem = orderItem, virtualProductInfo = virtualProductInfo, virtualOrderItemInfos = virtualOrderItemInfos, verificationCodes = codes }); } else { var order = Application.OrderApplication.GetOrderByPickCode(pickcode); if (order == null) { return new { success = false, msg = "该核销码无效" } } ; if (order.ShopBranchId != CurrentShopBranch.Id) { return new { success = false, msg = "非本门店核销码,请买家核对提货信息" } } ; if (order.OrderStatus == Entities.OrderInfo.OrderOperateStatus.Finish && order.DeliveryType == CommonModel.DeliveryType.SelfTake) { return new { success = false, msg = "该核销码于" + order.FinishDate.ToString() + "已核销" } } ; var orderRefundInfo = RefundApplication.GetOrderRefundByOrderId(order.Id); if (orderRefundInfo != null && orderRefundInfo.ManagerConfirmStatus == OrderRefundInfo.OrderRefundConfirmStatus.Confirmed) { return(new { success = false, msg = "该订单已退款,不能再核销" }); } var orderItem = Application.OrderApplication.GetOrderItemsByOrderId(order.Id); foreach (var item in orderItem) { item.ThumbnailsUrl = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_100); Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetTypeByProductId(item.ProductId); item.ColorAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias; item.SizeAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias; item.VersionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias; var productInfo = ProductManagerApplication.GetProduct(item.ProductId); if (productInfo != null) { item.ColorAlias = !string.IsNullOrWhiteSpace(productInfo.ColorAlias) ? productInfo.ColorAlias : item.ColorAlias; item.SizeAlias = !string.IsNullOrWhiteSpace(productInfo.SizeAlias) ? productInfo.SizeAlias : item.SizeAlias; item.VersionAlias = !string.IsNullOrWhiteSpace(productInfo.VersionAlias) ? productInfo.VersionAlias : item.VersionAlias; } } //退款状态 var refundobjs = OrderApplication.GetOrderRefunds(orderItem.Select(e => e.Id)); //小于4表示商家未确认;与平台未审核,都算退款、退货中 var refundProcessing = refundobjs.Where(e => (int)e.SellerAuditStatus > 4 && ((int)e.SellerAuditStatus < 4 || e.ManagerConfirmStatus == OrderRefundInfo.OrderRefundConfirmStatus.UnConfirm)); if (refundProcessing.Count() > 0) { order.RefundStats = 1; } order.OrderStatusText = order.OrderStatus.ToDescription(); return(new { success = true, order = order, orderItem = orderItem }); } }
public object GetSubmitModel(string skuId, int count, long shippingAddressId = 0, string couponIds = "", sbyte productType = 0, long shopBranchId = 0) { if (productType == 0) throw new MallException("门店订单暂时不允许立即购买"); //门店订单 Mall.DTO.ShopBranch storeInfo = Application.ShopBranchApplication.GetShopBranchById(shopBranchId); if (storeInfo == null) throw new MallException("获取门店信息失败,不可提交非门店商品"); CheckUserLogin(); var coupons = CouponApplication.ConvertUsedCoupon(couponIds); var result = OrderApplication.GetMobileSubmit(CurrentUserId, skuId.ToString(), count.ToString(), shippingAddressId, coupons, shopBranchId); dynamic d = SuccessResult(); bool canIntegralPerMoney = true, canCapital = true; CanDeductible(out canIntegralPerMoney, out canCapital); //解决循环引用的序列化的问题 dynamic address = new System.Dynamic.ExpandoObject(); if (result.Address != null) { var addDetail = result.Address.AddressDetail ?? ""; var add = new { Id = result.Address.Id, ShipTo = result.Address.ShipTo, Phone = result.Address.Phone, Address = result.Address.RegionFullName + " " + result.Address.Address + " " + addDetail, RegionId = result.Address.RegionId }; address = add; } else address = null; //d.InvoiceContext = result.InvoiceContext; //d.InvoiceTitle = OrderApplication.GetInvoiceTitles(CurrentUserId); d.InvoiceContext = result.InvoiceContext;//发票类容 d.InvoiceTitle = result.InvoiceTitle;//发票抬头 d.cellPhone = result.cellPhone;//默认收票人手机 d.email = result.email;//默认收票人邮箱 d.vatInvoice = result.vatInvoice;//默认增值税发票 d.invoiceName = result.invoiceName;//默认抬头(普通、电子) d.invoiceCode = result.invoiceCode;//默认税号(普通、电子) d.products = result.products; d.TotalAmount = result.totalAmount; d.Freight = result.Freight; d.orderAmount = result.orderAmount; d.IsCashOnDelivery = result.IsCashOnDelivery; d.IsOpenStore = SiteSettingApplication.SiteSettings != null && SiteSettingApplication.SiteSettings.IsOpenStore; d.ProvideInvoice = ShopApplication.HasProvideInvoice(result.products.Select(s => s.shopId).Distinct().ToList()); d.integralPerMoney = result.integralPerMoney; d.userIntegralMaxDeductible = result.userIntegralMaxDeductible; d.integralPerMoneyRate = result.integralPerMoneyRate; d.userIntegralMaxRate = SiteSettingApplication.SiteSettings.IntegralDeductibleRate; d.userIntegrals = result.userIntegrals; d.TotalMemberIntegral = result.memberIntegralInfo.AvailableIntegrals; d.canIntegralPerMoney = canIntegralPerMoney; d.canCapital = canCapital; d.capitalAmount = result.capitalAmount; d.productType = productType; d.shopBranchId = shopBranchId; d.shopBranchInfo = storeInfo; string shipperAddress = string.Empty, shipperTelPhone = string.Empty; if (productType == 1) { var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(result.ProductId); if (virtualProductInfo != null && virtualProductInfo.ValidityType && DateTime.Now > virtualProductInfo.EndDate.Value) { throw new MallException("该虚拟商品已过期,不支持下单"); } if (storeInfo != null) { shipperAddress = RegionApplication.GetFullName(storeInfo.AddressId) + storeInfo.AddressDetail;//ShopBranchApplication.RenderAddress(storeInfo.AddressPath, storeInfo.AddressDetail, 2); shipperTelPhone = storeInfo.ContactPhone; } } d.shipperAddress = shipperAddress; d.shipperTelPhone = shipperTelPhone; return d; }
/// <summary> /// 获取申请售后的信息 /// </summary> /// <param name="id">订单ID</param> /// <param name="itemId">子订单ID</param> /// <returns></returns> public object GetOrderRefundModel(long id, long?itemId = null, long?refundId = null) { CheckUserLogin(); try { dynamic d = new System.Dynamic.ExpandoObject(); var ordser = ServiceProvider.Instance <IOrderService> .Create; var refundser = ServiceProvider.Instance <IRefundService> .Create; var order = ordser.GetOrder(id, CurrentUser.Id); if (order == null) { throw new Himall.Core.HimallException("该订单已删除或不属于该用户"); } if (order.OrderType != OrderInfo.OrderTypes.Virtual && (int)order.OrderStatus < 2) { throw new Himall.Core.HimallException("错误的售后申请,订单状态有误"); } if (order.OrderType != OrderInfo.OrderTypes.Virtual && itemId == null && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp) { throw new Himall.Core.HimallException("错误的订单退款申请,订单状态有误"); } if (order.OrderType == OrderInfo.OrderTypes.Virtual) { //如果为虚拟商品,则要判断该商品是否允许退款,且该订单中是否至少有一个待核销的核销码 var orderItemInfo = OrderApplication.GetOrderItemsByOrderId(order.Id).FirstOrDefault(); if (orderItemInfo != null) { itemId = orderItemInfo.Id; var virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId); if (virtualProductInfo != null) { if (virtualProductInfo.SupportRefundType == 3) { return(new { success = false, msg = "该商品不支持退款" }); } if (virtualProductInfo.SupportRefundType == 1 && DateTime.Now > virtualProductInfo.EndDate.Value) { return(new { success = false, msg = "该商品不支持过期退款" }); } var orderVerificationCodes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }); long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count(); if (num == 0) { return(new { success = false, msg = "该商品没有可退的核销码" }); } int validityType = 0; string startDate = string.Empty, endDate = string.Empty; validityType = virtualProductInfo.ValidityType ? 1 : 0; if (validityType == 1) { startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd"); endDate = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd"); } d.ValidityType = validityType; d.StartDate = startDate; d.EndDate = endDate; } } } //计算可退金额 预留 ordser.CalculateOrderItemRefund(id); var orderitems = OrderApplication.GetOrderItems(order.Id); OrderRefundModel refundModel = new OrderRefundModel(); var item = new OrderItemInfo(); refundModel.MaxRGDNumber = 0; refundModel.MaxRefundAmount = order.OrderEnabledRefundAmount; if (itemId == null) { item = orderitems.FirstOrDefault(); } else { item = orderitems.Where(a => a.Id == itemId).FirstOrDefault(); refundModel.MaxRGDNumber = item.Quantity - item.ReturnQuantity; refundModel.MaxRefundAmount = (decimal)(item.EnabledRefundAmount - item.RefundPrice); } if (order.OrderType == OrderInfo.OrderTypes.Virtual) { var count = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }).Where(a => a.Status != OrderInfo.VerificationCodeStatus.WaitVerification).ToList().Count; if (item.EnabledRefundAmount.HasValue) { decimal price = item.EnabledRefundAmount.Value / item.Quantity; refundModel.MaxRefundAmount = item.EnabledRefundAmount.Value - Math.Round(count * price, 2, MidpointRounding.AwayFromZero); } } bool isCanApply = false; if (refundModel.MaxRefundAmount <= 0) { return(new { success = false, msg = "此为优惠券全额抵扣订单不支持退款" }); } if (order.OrderStatus == OrderInfo.OrderOperateStatus.WaitDelivery) { isCanApply = refundser.CanApplyRefund(id, item.Id); } else { isCanApply = refundser.CanApplyRefund(id, item.Id, false); } if (!refundId.HasValue) { if (!isCanApply) { throw new Himall.Core.HimallException("您已申请过售后,不可重复申请"); } d.ContactPerson = string.IsNullOrEmpty(order.ShipTo) ? CurrentUser.RealName : order.ShipTo; d.ContactCellPhone = string.IsNullOrEmpty(order.CellPhone) ? CurrentUser.CellPhone : order.CellPhone; d.OrderItemId = itemId; d.RefundType = 0; d.IsRefundOrder = false; if (!itemId.HasValue) { d.IsRefundOrder = true; d.RefundType = 1; } var reasonlist = refundser.GetRefundReasons(); d.Id = order.Id; d.MaxRGDNumber = refundModel.MaxRGDNumber; d.MaxRefundAmount = refundModel.MaxRefundAmount; d.OrderStatus = order.OrderStatus.ToDescription(); d.OrderStatusValue = (int)order.OrderStatus; d.BackOut = false; d.RefundReasons = reasonlist; if (order.CanBackOut()) { d.BackOut = true; } } else { var refunddata = refundser.GetOrderRefund(refundId.Value, CurrentUser.Id); if (refunddata == null) { throw new Himall.Core.HimallException("错误的售后数据"); } if (order.OrderType != OrderInfo.OrderTypes.Virtual && refunddata.SellerAuditStatus != Entities.OrderRefundInfo.OrderRefundAuditStatus.UnAudit) { throw new Himall.Core.HimallException("错误的售后状态,不可激活"); } d.ContactPerson = refunddata.ContactPerson; d.ContactCellPhone = refunddata.ContactCellPhone; d.OrderItemId = refunddata.OrderItemId; d.IsRefundOrder = (refunddata.RefundMode == Entities.OrderRefundInfo.OrderRefundMode.OrderRefund); d.RefundType = (refunddata.RefundMode == Entities.OrderRefundInfo.OrderRefundMode.OrderRefund ? 1 : 0); var reasonlist = refundser.GetRefundReasons(); d.RefundReasons = reasonlist; //理由List d.Id = id; d.MaxRGDNumber = refundModel.MaxRGDNumber; d.MaxRefundAmount = refundModel.MaxRefundAmount; d.OrderStatus = order.OrderStatus.ToDescription(); d.OrderStatusValue = (int)order.OrderStatus; d.BackOut = false; d.ReasonDetail = refunddata.ReasonDetail; d.CertPic1 = Himall.Core.HimallIO.GetRomoteImagePath(refunddata.CertPic1); d.CertPic2 = Himall.Core.HimallIO.GetRomoteImagePath(refunddata.CertPic2); d.CertPic3 = Himall.Core.HimallIO.GetRomoteImagePath(refunddata.CertPic3); if (order.CanBackOut()) { d.BackOut = true; } } if (!d.IsRefundOrder && item.EnabledRefundAmount.HasValue) { d.RefundGoodsPrice = item.EnabledRefundAmount.Value / item.Quantity; } d.DeliveryType = order.DeliveryType; if (order.DeliveryType == CommonModel.DeliveryType.SelfTake) { var shopBranch = ShopBranchApplication.GetShopBranchById(order.ShopBranchId); d.ReturnGoodsAddress = RegionApplication.GetFullName(shopBranch.AddressId); d.ReturnGoodsAddress += " " + shopBranch.AddressDetail; d.ReturnGoodsAddress += " " + shopBranch.ContactPhone; } d.IsVirtual = order.OrderType == OrderInfo.OrderTypes.Virtual ? 1 : 0; if (order.OrderType == OrderInfo.OrderTypes.Virtual) { var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>() { order.Id }).Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).ToList(); d.OrderVerificationCode = codes.Select(a => a.VerificationCode).Select(p => p = Regex.Replace(p, @"(\d{4})", "$1 ")); } return(new { success = true, RefundMode = d }); } catch (HimallException himallex) { return(ErrorResult(himallex.Message)); } catch (Exception ex) { return(ErrorResult("系统异常:" + ex.Message)); } }