/// <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 = "已核销" }); } }