/// <summary> /// 发货 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Send(HttpContext context) { string bizcontent = context.Request["bizcontent"]; JObject jo = (JObject)JsonConvert.DeserializeObject(bizcontent); string SendType = GetJObjectValue <string>(jo, "SendType"); string LogisticName = GetJObjectValue <string>(jo, "LogisticName"); string LogisticType = GetJObjectValue <string>(jo, "LogisticType"); string LogisticNo = GetJObjectValue <string>(jo, "LogisticNo"); long OrderId = GetJObjectValue <long>(jo, "PlatOrderNo"); int? IsSplit = GetJObjectValue <int?>(jo, "IsSplit"); string SenderName = GetJObjectValue <string>(jo, "SenderName"); string SenderTel = GetJObjectValue <string>(jo, "SenderTel"); string SenderAddress = GetJObjectValue <string>(jo, "SenderAddress"); int IsHwgFlag = GetJObjectValue <int>(jo, "IsHwgFlag"); if (OrderId <= 0) { throw new HimallApiException("订单号错误"); } Entities.OrderInfo order = OrderApplication.GetOrderInfo(OrderId); if (order == null) { throw new HimallApiException("未找到此订单"); } if (order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitDelivery) { throw new HimallApiException("当前订单状态没有付款或不是等待发货的订单,所以不能发货!"); } if (string.IsNullOrEmpty(LogisticNo)) { throw new HimallApiException("运单号码不能为空!"); } OrderApplication.SellerSendGood(OrderId, "网店管家", LogisticName, LogisticNo); StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append("\"code\":" + "\"10000\""); sb.Append(",\"message\":" + "\"SUCCESS\""); sb.Append("}"); return(sb.ToString()); }
/// <summary> /// 根据订单ID获取评价 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public JsonResult <Result <dynamic> > GetComment(long orderId) { CheckUserLogin(); var order = OrderApplication.GetOrderInfo(orderId); var comment = OrderApplication.GetOrderCommentCount(order.Id); if (order != null && comment == 0) { var model = CommentApplication.GetProductEvaluationByOrderId(orderId, CurrentUser.Id).Select(item => new { ProductId = item.ProductId, ProductName = item.ProductName, Image = Core.HimallIO.GetRomoteProductSizeImage(item.ThumbnailsUrl, 1, (int)Himall.CommonModel.ImageSize.Size_220) //商城App评论时获取商品图片 }); var orderitems = OrderApplication.GetOrderItems(order.Id); var orderEvaluation = TradeCommentApplication.GetOrderCommentInfo(orderId, CurrentUser.Id); var isVirtual = order.OrderType == Himall.Entities.OrderInfo.OrderTypes.Virtual ? 1 : 0; return(JsonResult <dynamic>(new { Product = model, orderItemIds = orderitems.Select(item => item.Id), isVirtual = isVirtual })); } else { return(Json(ErrorResult <dynamic>("该订单不存在或者已评论过"))); } }
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 }); }
/// <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 }); } }
/// <summary> /// 门店核销订单 /// </summary> /// <param name="pickcode"></param> /// <returns></returns> public object GetShopBranchOrderConfirm(string pickcode) { CheckUserLogin(); if (string.IsNullOrWhiteSpace(pickcode)) { return new { success = false, msg = "该核销码无效" } } ; var codes = pickcode.Split(',').ToList(); var list = OrderApplication.GetOrderVerificationCodeInfoByCodes(codes); if (list != null && list.Count > 0) { var orderCount = list.Select(a => a.OrderId).Distinct().Count(); if (orderCount > 1) { return(new { success = false, msg = "非同一个订单的核销码无法一起核销" }); } var order = OrderApplication.GetOrderInfo(list[0].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 = "非本店核销码,请买家核对信息" } } ; var waitVerificationNum = list.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count(); if (waitVerificationNum != list.Count) { return(new { success = false, msg = "包含非待消费的核销码" }); } var orderItem = Application.OrderApplication.GetOrderItemsByOrderId(order.Id).FirstOrDefault(); if (orderItem != null && orderItem.EffectiveDate.HasValue) { if (DateTime.Now < orderItem.EffectiveDate.Value) { return new { success = false, msg = "该核销码暂时不能核销,请留意生效时间!" } } ; } var verificationTime = DateTime.Now; OrderApplication.UpdateOrderVerificationCodeStatusByCodes(list.Select(a => a.VerificationCode).ToList(), order.Id, OrderInfo.VerificationCodeStatus.AlreadyVerification, DateTime.Now, this.CurrentShopBranch.UserName); OrderApplication.AddVerificationRecord(new VerificationRecordInfo() { OrderId = order.Id, VerificationCodeIds = "," + string.Join(",", list.Select(a => a.VerificationCode)) + ",", VerificationTime = verificationTime, VerificationUser = this.CurrentShopBranch.UserName }); return(new { success = true, msg = "已核销", verificationCodes = string.Join(",", list.Select(a => a.VerificationCode)), verificationTime = verificationTime.ToString("yyyy-MM-dd HH:mm:ss"), verificationUser = this.CurrentShopBranch.UserName }); } 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() + "已核销" } } ; if (order.OrderStatus != Entities.OrderInfo.OrderOperateStatus.WaitSelfPickUp) { return new { success = false, msg = "只有待自提的订单才能进行核销" } } ; Application.OrderApplication.ShopBranchConfirmOrder(order.Id, CurrentShopBranch.Id, this.CurrentUser.UserName); return(new { success = true, msg = "已核销" }); } }
/// <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 }); }