private void OfflinePayOder()
		{
			if (this.offlineOrder != null && this.offlineOrder.Status == 0)
			{
				this.offlineOrder.Status = 1;
				this.offlineOrder.PayTime = DateTime.Now;
				if (StoresHelper.UpdateStoreCollectionInfo(this.offlineOrder) && this.isOfflineOrder)
				{
					string text = "";
					StoresInfo storeById = DepotHelper.GetStoreById(this.offlineOrder.StoreId);
					if (storeById != null)
					{
						text = storeById.StoreName;
						StoreBalanceDetailInfo storeBalanceDetailInfo = new StoreBalanceDetailInfo();
						storeBalanceDetailInfo.StoreId = this.offlineOrder.StoreId;
						storeBalanceDetailInfo.TradeDate = DateTime.Now;
						storeBalanceDetailInfo.TradeType = StoreTradeTypes.OfflineCashier;
						storeBalanceDetailInfo.Expenses = default(decimal);
						storeBalanceDetailInfo.Income = this.offlineOrder.PayAmount;
						storeBalanceDetailInfo.Balance = storeById.Balance + this.offlineOrder.PayAmount;
						storeBalanceDetailInfo.Remark = "线下收银(" + this.offlineOrder.OrderId + ")";
						storeBalanceDetailInfo.ManagerUserName = "";
						storeBalanceDetailInfo.TradeNo = this.offlineOrder.OrderId;
						storeBalanceDetailInfo.CreateTime = DateTime.Now;
						storeBalanceDetailInfo.PlatCommission = decimal.Zero;
						StoreBalanceHelper.AddBalanceDetailInfo(storeBalanceDetailInfo);
					}
					if (storeById != null)
					{
						VShopHelper.AppPsuhRecordForStore(storeById.StoreId, this.offlineOrder.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
					}
				}
			}
		}
Ejemplo n.º 2
0
        private void ChangeOrderStore(HttpContext context)
        {
            string orderId = context.Request["orderId"].ToString();
            int    num     = context.Request["storeId"].ToInt(0);
            int    num2    = context.Request["isGetStore"].ToInt(0);
            string text    = "";
            bool   flag    = StoresHelper.ChangeOrderStore(orderId, num, out text);

            if (num > 0 & flag)
            {
                if (num2 == 1)
                {
                    VShopHelper.AppPsuhRecordForStore(num, orderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                }
                else
                {
                    VShopHelper.AppPsuhRecordForStore(num, orderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                }
            }
            if (num2 != 1)
            {
                ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                StoresInfo   storeById             = StoresHelper.GetStoreById(num);
                OrderInfo    orderInfo             = OrderHelper.GetOrderInfo(orderId);
                Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storeById, null, orderInfo, orderInfo.GetTotal(false));
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write("{\"state\":" + (flag ? "1" : "0") + ",\"message\": \"" + text + "\"}");
        }
 private void OfflinePayOder()
 {
     if (this.offlineOrder != null && this.offlineOrder.Status == 0)
     {
         if (this.offlineOrder.Status == 1)
         {
             if (this.isOfflineOrder)
             {
                 base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}</p>", this.OrderId, this.Amount.ToString("F")));
             }
         }
         else
         {
             this.offlineOrder.Status  = 1;
             this.offlineOrder.PayTime = DateTime.Now;
             if (StoresHelper.UpdateStoreCollectionInfo(this.offlineOrder) && this.isOfflineOrder)
             {
                 string     text      = "";
                 StoresInfo storeById = DepotHelper.GetStoreById(this.offlineOrder.StoreId);
                 if (storeById != null)
                 {
                     text = storeById.StoreName;
                 }
                 if (storeById != null)
                 {
                     VShopHelper.AppPsuhRecordForStore(storeById.StoreId, this.offlineOrder.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                 }
                 base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}</p>", this.OrderId, this.Amount.ToString("F")));
             }
         }
     }
 }
Ejemplo n.º 4
0
 private void UserPayOrder()
 {
     if (this.Order != null && this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
         this.ResponseReturn(true, "");
     }
     else if ((this.Order != null && this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid) || (this.offlineOrder != null && this.offlineOrder.Status == 1))
     {
         this.ResponseReturn(true, "");
     }
     else
     {
         try
         {
             int maxCount        = 0;
             int yetOrderNum     = 0;
             int currentOrderNum = 0;
             if (this.Order != null)
             {
                 if (this.Order.GroupBuyId > 0)
                 {
                     GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                     if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                     {
                         return;
                     }
                     yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                     currentOrderNum = this.Order.GetGroupBuyOerderNumber();
                     maxCount        = groupBuy.MaxCount;
                     if (maxCount < yetOrderNum + currentOrderNum)
                     {
                         return;
                     }
                 }
                 if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
                 {
                     Task.Factory.StartNew(delegate
                     {
                         TradeHelper.UserPayOrder(this.Order, false, true);
                         try
                         {
                             if (this.offlineOrder != null)
                             {
                                 OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
                                 OrderHelper.ConfirmTakeGoods(this.Order, true);
                             }
                             if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                             {
                                 TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                             }
                             if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                             {
                                 string verificationPasswords = "";
                                 if (this.Order.OrderType == OrderType.ServiceOrder)
                                 {
                                     verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
                                 }
                                 Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
                                 if (user != null)
                                 {
                                     Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(true), verificationPasswords);
                                 }
                             }
                             StoresInfo storesInfo2 = null;
                             if (this.Order.StoreId > 0)
                             {
                                 storesInfo2 = DepotHelper.GetStoreById(this.Order.StoreId);
                             }
                             if (storesInfo2 != null)
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                                 if (this.offlineOrder == null)
                                 {
                                     if (this.Order.ShippingModeId == -2)
                                     {
                                         VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                                     }
                                     else
                                     {
                                         VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                                     }
                                 }
                             }
                             if (this.offlineOrder == null)
                             {
                                 ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                                 Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo2, null, this.Order, this.Order.GetTotal(true));
                             }
                             this.Order.OnPayment();
                         }
                         catch (Exception ex2)
                         {
                             IDictionary <string, string> dictionary2 = new Dictionary <string, string>();
                             dictionary2.Add("ErrorMessage", ex2.Message);
                             dictionary2.Add("StackTrace", ex2.StackTrace);
                             if (ex2.InnerException != null)
                             {
                                 dictionary2.Add("InnerException", ex2.InnerException.ToString());
                             }
                             if (ex2.GetBaseException() != null)
                             {
                                 dictionary2.Add("BaseException", ex2.GetBaseException().Message);
                             }
                             if (ex2.TargetSite != (MethodBase)null)
                             {
                                 dictionary2.Add("TargetSite", ex2.TargetSite.ToString());
                             }
                             dictionary2.Add("ExSource", ex2.Source);
                             Globals.AppendLog(dictionary2, "支付更新订单收款记录或者消息通知时出错:" + ex2.Message, "", "", "UserPay");
                         }
                         this.Order.OnPayment();
                         this.ResponseReturn(true, "");
                     });
                 }
                 if (this.Order.FightGroupId > 0)
                 {
                     VShopHelper.SetFightGroupSuccess(this.Order.FightGroupId);
                 }
             }
             if (this.offlineOrder != null && this.offlineOrder.Status == 0)
             {
                 this.offlineOrder.Status  = 1;
                 this.offlineOrder.PayTime = DateTime.Now;
                 if (StoresHelper.UpdateStoreCollectionInfo(this.offlineOrder) && this.isOfflineOrder)
                 {
                     string     text      = "";
                     StoresInfo storeById = DepotHelper.GetStoreById(this.offlineOrder.StoreId);
                     if (storeById != null)
                     {
                         text = storeById.StoreName;
                         StoreBalanceDetailInfo storeBalanceDetailInfo = new StoreBalanceDetailInfo();
                         storeBalanceDetailInfo.StoreId         = this.offlineOrder.StoreId;
                         storeBalanceDetailInfo.TradeDate       = DateTime.Now;
                         storeBalanceDetailInfo.TradeType       = StoreTradeTypes.OfflineCashier;
                         storeBalanceDetailInfo.Expenses        = default(decimal);
                         storeBalanceDetailInfo.Income          = this.offlineOrder.PayAmount;
                         storeBalanceDetailInfo.Balance         = storeById.Balance + this.offlineOrder.PayAmount;
                         storeBalanceDetailInfo.Remark          = "线下收银(" + this.offlineOrder.OrderId + ")";
                         storeBalanceDetailInfo.ManagerUserName = "";
                         storeBalanceDetailInfo.TradeNo         = this.offlineOrder.OrderId;
                         storeBalanceDetailInfo.CreateTime      = DateTime.Now;
                         storeBalanceDetailInfo.PlatCommission  = decimal.Zero;
                         if (StoreBalanceHelper.AddBalanceDetailInfo(storeBalanceDetailInfo))
                         {
                             StoresInfo storesInfo = storeById;
                             storesInfo.Balance += this.offlineOrder.PayAmount;
                             StoresHelper.UpdateStore(storeById);
                         }
                     }
                     if (storeById != null)
                     {
                         VShopHelper.AppPsuhRecordForStore(storeById.StoreId, this.offlineOrder.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             IDictionary <string, string> dictionary = new Dictionary <string, string>();
             dictionary.Add("ErrorMessage", ex.Message);
             dictionary.Add("StackTrace", ex.StackTrace);
             if (ex.InnerException != null)
             {
                 dictionary.Add("InnerException", ex.InnerException.ToString());
             }
             if (ex.GetBaseException() != null)
             {
                 dictionary.Add("BaseException", ex.GetBaseException().Message);
             }
             if (ex.TargetSite != (MethodBase)null)
             {
                 dictionary.Add("TargetSite", ex.TargetSite.ToString());
             }
             dictionary.Add("ExSource", ex.Source);
             Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay1");
         }
         this.ResponseReturn(true, "");
     }
 }
Ejemplo n.º 5
0
        public void ProcessorOrderVerificationItemsExpire()
        {
            StringBuilder stringBuilder = new StringBuilder();

            try
            {
                Database          obj = this.database;
                ProductSaleStatus productSaleStatus = ProductSaleStatus.UnSale;
                object            arg  = productSaleStatus.GetHashCode();
                object            arg2 = DateTime.Now;
                productSaleStatus = ProductSaleStatus.OnSale;
                obj.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE Hishop_StoreProducts SET SaleStatus = {0} WHERE SaleStatus = {2} AND ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1  AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{1}')", arg, arg2, productSaleStatus.GetHashCode()));
                StringBuilder stringBuilder2 = stringBuilder;
                productSaleStatus = ProductSaleStatus.UnSale;
                object arg3 = productSaleStatus.GetHashCode();
                object arg4 = DateTime.Now;
                productSaleStatus = ProductSaleStatus.OnSale;
                stringBuilder2.AppendLine(string.Format("UPDATE Hishop_StoreProducts SET SaleStatus = {0} WHERE SaleStatus = {2} AND ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1  AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{1}')", arg3, arg4, productSaleStatus.GetHashCode()));
                this.database.ExecuteNonQuery(CommandType.Text, $"DELETE FROM Hishop_StoreSKUs WHERE  ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1  AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{DateTime.Now}')");
                stringBuilder.AppendLine($"DELETE FROM Hishop_StoreSKUs WHERE  ProductId IN(SELECT ProductId FROM Hishop_Products WHERE ProductType = 1  AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{DateTime.Now}')");
                Database obj2 = this.database;
                productSaleStatus = ProductSaleStatus.UnSale;
                object arg5 = productSaleStatus.GetHashCode();
                object arg6 = DateTime.Now;
                productSaleStatus = ProductSaleStatus.OnSale;
                obj2.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE Hishop_Products SET SaleStatus = {0} WHERE ProductType = 1 AND SaleStatus = {2} AND IsValid = 0 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{1}'", arg5, arg6, productSaleStatus.GetHashCode()));
                StringBuilder stringBuilder3 = stringBuilder;
                productSaleStatus = ProductSaleStatus.UnSale;
                stringBuilder3.AppendLine($"UPDATE Hishop_Products SET SaleStatus = {productSaleStatus.GetHashCode()} WHERE ProductType = 1 AND ValidStartDate IS NOT NULL AND ValidEndDate IS NOT NULL AND ValidEndDate <= '{DateTime.Now}'");
                DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_OrderVerificationItems SET VerificationStatus = " + 3 + " WHERE OrderId IN(SELECT OrderId FROM Hishop_OrderItems WHERE(IsValid = 0 OR IsValid IS NULL)  AND ValidEndDate IS NOT NULL AND ValidEndDate < @Now) AND VerificationStatus = " + 0);
                this.database.AddInParameter(sqlStringCommand, "Now", DbType.DateTime, DateTime.Now);
                this.database.ExecuteNonQuery(sqlStringCommand);
                stringBuilder.AppendLine(string.Format("UPDATE Hishop_OrderVerificationItems SET VerificationStatus = " + 3 + " WHERE OrderId IN(SELECT OrderId FROM Hishop_OrderItems WHERE(IsValid = 0 OR IsValid IS NULL)  AND ValidEndDate IS NOT NULL AND ValidEndDate < '@Now') AND VerificationStatus = " + 0).Replace("@Now", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                StringBuilder stringBuilder4 = new StringBuilder();
                StringBuilder stringBuilder5 = stringBuilder4;
                object[]      obj3           = new object[4];
                OrderStatus   orderStatus    = OrderStatus.Finished;
                obj3[0] = orderStatus.GetHashCode();
                OrderType orderType = OrderType.ServiceOrder;
                obj3[1] = orderType.GetHashCode();
                VerificationStatus verificationStatus = VerificationStatus.Expired;
                obj3[2]     = verificationStatus.GetHashCode();
                orderStatus = OrderStatus.BuyerAlreadyPaid;
                obj3[3]     = orderStatus.GetHashCode();
                stringBuilder5.Append(string.Format("UPDATE Hishop_Orders SET OrderStatus = {0} WHERE OrderStatus = {3} AND OrderType = {1} AND OrderId IN(SELECT OrderId FROM Hishop_OrderItems oi WHERE oi.Quantity = (SELECT COUNT(Id) FROM Hishop_OrderVerificationItems WHERE VerificationStatus =  {2} AND OrderId = oi.OrderId))", obj3));
                StringBuilder stringBuilder6 = stringBuilder4;
                object[]      obj4           = new object[4];
                orderStatus        = OrderStatus.Closed;
                obj4[0]            = orderStatus.GetHashCode();
                orderType          = OrderType.ServiceOrder;
                obj4[1]            = orderType.GetHashCode();
                verificationStatus = VerificationStatus.Expired;
                obj4[2]            = verificationStatus.GetHashCode();
                orderStatus        = OrderStatus.BuyerAlreadyPaid;
                obj4[3]            = orderStatus.GetHashCode();
                stringBuilder6.Append(string.Format("UPDATE Hishop_Orders SET OrderStatus = {0} WHERE OrderStatus = {3} AND OrderType = {1} AND OrderId IN(SELECT OrderId FROM Hishop_OrderItems oi WHERE oi.Quantity = (SELECT COUNT(Id) FROM Hishop_OrderVerificationItems WHERE (VerificationStatus =  {2}) AND OrderId = oi.OrderId AND oi.IsOverRefund = 0))", obj4));
                StringBuilder stringBuilder7 = stringBuilder4;
                object[]      obj5           = new object[6];
                orderStatus        = OrderStatus.Finished;
                obj5[0]            = orderStatus.GetHashCode();
                orderType          = OrderType.ServiceOrder;
                obj5[1]            = orderType.GetHashCode();
                verificationStatus = VerificationStatus.Expired;
                obj5[2]            = verificationStatus.GetHashCode();
                verificationStatus = VerificationStatus.Finished;
                obj5[3]            = verificationStatus.GetHashCode();
                orderStatus        = OrderStatus.BuyerAlreadyPaid;
                obj5[4]            = orderStatus.GetHashCode();
                verificationStatus = VerificationStatus.Refunded;
                obj5[5]            = verificationStatus.GetHashCode();
                stringBuilder7.Append(string.Format("UPDATE Hishop_Orders SET OrderStatus = {0} WHERE OrderStatus = {4} AND OrderType = {1} AND OrderId IN(SELECT OrderId FROM Hishop_OrderItems oi WHERE oi.Quantity = (SELECT COUNT(Id) FROM Hishop_OrderVerificationItems WHERE (VerificationStatus =  {2} OR VerificationStatus =  {3} OR VerificationStatus =  {5}) AND OrderId = oi.OrderId))", obj5));
                stringBuilder.AppendLine(stringBuilder4.ToString());
                this.database.ExecuteNonQuery(CommandType.Text, stringBuilder4.ToString());
                DbCommand sqlStringCommand2 = this.database.GetSqlStringCommand("SELECT oi.Quantity, oi.OrderId,oi.ProductId,StoreId,VerificationStatus,UserName,VerificationPassword FROM [Hishop_OrderItems] oi INNER JOIN Hishop_OrderVerificationItems ov ON ov.OrderId = oi.OrderId  WHERE (IsValid = 0 OR IsValid IS NULL) AND IsOverRefund = 1 AND VerificationStatus =" + 3 + ";");
                stringBuilder.AppendLine("SELECT oi.Quantity, oi.OrderId,oi.ProductId,StoreId,VerificationStatus,UserName FROM [Hishop_OrderItems] oi INNER JOIN Hishop_OrderVerificationItems ov ON ov.OrderId = oi.OrderId  WHERE (IsValid = 0 OR IsValid IS NULL) AND IsOverRefund = 1 AND VerificationStatus =" + 3 + ";");
                using (IDataReader objReader = this.database.ExecuteReader(sqlStringCommand2))
                {
                    IList <VerificationItemsExipreInfo> list = DataHelper.ReaderToList <VerificationItemsExipreInfo>(objReader);
                    if (list != null && list.Count > 0)
                    {
                        List <string> list2 = (from o in list
                                               select o.OrderId).Distinct().ToList();
                        foreach (string item in list2)
                        {
                            OrderInfo orderInfo = OrderHelper.GetOrderInfo(item);
                            if (orderInfo != null)
                            {
                                MemberInfo user = Users.GetUser(orderInfo.UserId);
                                if (user != null)
                                {
                                    IList <VerificationItemsExipreInfo> list3 = (from v in list
                                                                                 where v.OrderId == item
                                                                                 select v).ToList();
                                    decimal    num        = ((decimal)list3.Count * (orderInfo.GetTotal(false) / (decimal)orderInfo.GetBuyQuantity() * 1.0m) * 1.0m).F2ToString("f2").ToDecimal(0);
                                    string     generateId = Globals.GetGenerateId();
                                    RefundInfo refund     = new RefundInfo
                                    {
                                        UserRemark      = "",
                                        RefundReason    = "核销码过期自动退款",
                                        RefundType      = ((orderInfo.Gateway.ToNullString().ToLower() == EnumDescription.GetEnumDescription((Enum)(object)EnumPaymentType.AdvancePay, 1) || orderInfo.BalanceAmount > decimal.Zero) ? RefundTypes.InBalance : RefundTypes.BackReturn),
                                        RefundGateWay   = orderInfo.Gateway,
                                        RefundOrderId   = generateId,
                                        RefundAmount    = num,
                                        StoreId         = orderInfo.StoreId,
                                        ApplyForTime    = DateTime.Now,
                                        BankName        = "",
                                        BankAccountName = "",
                                        BankAccountNo   = "",
                                        OrderId         = item,
                                        HandleStatus    = RefundStatus.Applied,
                                        ValidCodes      = string.Join(",", from ii in list3
                                                                      select ii.VerificationPassword),
                                        IsServiceProduct = true,
                                        Quantity         = list3.Count
                                    };
                                    try
                                    {
                                        int num2 = TradeHelper.ServiceOrderApplyForRefund(refund);
                                        if (num2 > 0)
                                        {
                                            refund = TradeHelper.GetRefundInfo(num2);
                                            if (refund.Quantity == orderInfo.GetAllQuantity(true))
                                            {
                                                OrderHelper.UpdateOrderStatus(orderInfo, OrderStatus.ApplyForRefund);
                                            }
                                            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                                            if (masterSettings.IsAutoDealRefund)
                                            {
                                                if (orderInfo.GetTotal(false) == decimal.Zero)
                                                {
                                                    if (OrderHelper.CheckRefund(orderInfo, refund, decimal.Zero, "", "自动退款", true, true))
                                                    {
                                                        VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund);
                                                        Messenger.OrderRefund(user, orderInfo, "");
                                                    }
                                                    else
                                                    {
                                                        TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund);
                                                    }
                                                }
                                                else if (refund.RefundType == RefundTypes.InBalance)
                                                {
                                                    if (OrderHelper.CheckRefund(orderInfo, refund, num, "", "自动退款", true, true))
                                                    {
                                                        VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund);
                                                        Messenger.OrderRefund(user, orderInfo, "");
                                                    }
                                                    else
                                                    {
                                                        TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund);
                                                    }
                                                }
                                                else
                                                {
                                                    string text = TradeHelper.SendWxRefundRequest(orderInfo, num, refund.RefundOrderId);
                                                    if (text == "")
                                                    {
                                                        if (OrderHelper.CheckRefund(orderInfo, refund, num, "", "自动退款", true, true))
                                                        {
                                                            VShopHelper.AppPushRecordForOrder(orderInfo.OrderId, "", EnumPushOrderAction.OrderRefund);
                                                            Messenger.OrderRefund(user, orderInfo, "");
                                                        }
                                                        else
                                                        {
                                                            TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        TradeHelper.SaveRefundErr(num2, text, true);
                                                        TradeHelper.SetOrderVerificationItemStatus(item, refund.ValidCodes, VerificationStatus.ApplyRefund);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                TradeHelper.SetOrderVerificationItemStatus(orderInfo.OrderId, refund.ValidCodes, VerificationStatus.ApplyRefund);
                                            }
                                            if (orderInfo.StoreId > 0)
                                            {
                                                VShopHelper.AppPsuhRecordForStore(orderInfo.StoreId, orderInfo.OrderId, "", EnumPushStoreAction.StoreOrderRefundApply);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Globals.WriteExceptionLog_Page(ex, null, "O2OAutoRefundError");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex2)
            {
                IDictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("Sql", stringBuilder.ToString());
                Globals.WriteExceptionLog(ex2, dictionary, "ProcessorOrderVerificationItemsExpire");
            }
        }
		private void UserPayOrder()
		{
			if (this.Order != null && this.Order.OrderStatus == OrderStatus.Closed)
			{
				OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
				Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
				base.Response.Write("success");
			}
			else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
			{
				Globals.WriteLog(new NameValueCollection
				{
					this.Page.Request.Form,
					this.Page.Request.QueryString
				}, "订单状态为已支付", "", "", "alipay");
				base.Response.Write("success");
			}
			else
			{
				int maxCount = 0;
				int yetOrderNum = 0;
				int currentOrderNum = 0;
				if (this.Order.GroupBuyId > 0)
				{
					GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
					if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
					{
						Globals.WriteLog(new NameValueCollection
						{
							this.Page.Request.Form,
							this.Page.Request.QueryString
						}, "错误的团购信息或者状态", "", "", "alipay");
						base.Response.Write("success");
						return;
					}
					yetOrderNum = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
					currentOrderNum = this.Order.GetGroupBuyOerderNumber();
					maxCount = groupBuy.MaxCount;
					if (maxCount < yetOrderNum + currentOrderNum)
					{
						Globals.WriteLog(new NameValueCollection
						{
							this.Page.Request.Form,
							this.Page.Request.QueryString
						}, "团购数量已超过指定数量错", "", "", "alipay");
						base.Response.Write("success");
						return;
					}
				}
				if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
				{
					Task.Factory.StartNew(delegate
					{
						TradeHelper.UserPayOrder(this.Order, false, true);
						try
						{
							if (this.offlineOrder != null)
							{
								OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
								OrderHelper.ConfirmTakeGoods(this.Order, true);
							}
							if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
							{
								TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
							}
							if (this.Order.UserId != 0 && this.Order.UserId != 1100)
							{
								Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
								string verificationPasswords = "";
								if (this.Order.OrderType == OrderType.ServiceOrder)
								{
									verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
								}
								if (user != null)
								{
									Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(false), verificationPasswords);
								}
							}
							StoresInfo storesInfo = null;
							if (this.Order.StoreId > 0)
							{
								storesInfo = DepotHelper.GetStoreById(this.Order.StoreId);
							}
							if (storesInfo != null)
							{
								VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
								if (this.offlineOrder == null)
								{
									if (this.Order.ShippingModeId == -2)
									{
										VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
									}
									else
									{
										VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
									}
								}
							}
							if (this.offlineOrder == null)
							{
								ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
								Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo, null, this.Order, this.Order.GetTotal(false));
							}
							this.Order.OnPayment();
						}
						catch (Exception ex)
						{
							IDictionary<string, string> dictionary = new Dictionary<string, string>();
							dictionary.Add("ErrorMessage", ex.Message);
							dictionary.Add("StackTrace", ex.StackTrace);
							if (ex.InnerException != null)
							{
								dictionary.Add("InnerException", ex.InnerException.ToString());
							}
							if (ex.GetBaseException() != null)
							{
								dictionary.Add("BaseException", ex.GetBaseException().Message);
							}
							if (ex.TargetSite != (MethodBase)null)
							{
								dictionary.Add("TargetSite", ex.TargetSite.ToString());
							}
							dictionary.Add("ExSource", ex.Source);
							Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
						}
					});
					base.Response.Write("success");
				}
				else
				{
					Globals.WriteLog(new NameValueCollection
					{
						this.Page.Request.Form,
						this.Page.Request.QueryString
					}, "订单不是待支付状态,或者更新订单状态失败", "", "", "alipay");
					base.Response.Write("success");
				}
			}
		}
Ejemplo n.º 7
0
        private void btnRefund_Click(object sender, EventArgs e)
        {
            string text = this.Page.Request.QueryString["returnUrl"].ToNullString();

            if (string.IsNullOrEmpty(text))
            {
                text = this.Page.Request.UrlReferrer.ToNullString();
                if (text == this.Page.Request.Url.ToString())
                {
                    text = "/User/UserOrders";
                }
            }
            string text2 = "";
            string text3 = "";
            string text4 = "";

            text2            = Globals.StripAllTags(this.txtBankName.Value);
            text3            = Globals.StripAllTags(this.txtBankAccountName.Value);
            text4            = Globals.StripAllTags(this.txtBankAccountNo.Value);
            this.iRefundType = this.hidRefundType.Value.ToInt(0);
            if (!Enum.IsDefined(typeof(RefundTypes), this.iRefundType))
            {
                this.ShowMessage("错误的退款方式", false, "", 1);
            }
            string enumDescription = EnumDescription.GetEnumDescription((Enum)(object)EnumPaymentType.AdvancePay, 1);

            if ((this.order.Gateway.ToLower() == enumDescription || this.order.DepositGatewayOrderId.ToNullString().ToLower() == enumDescription) && this.iRefundType != 1)
            {
                this.ShowMessage("预付款支付的订单只能退回到预付款帐号", false, "", 1);
            }
            else
            {
                if (this.order.FightGroupId > 0)
                {
                    FightGroupInfo fightGroup = VShopHelper.GetFightGroup(this.order.FightGroupId);
                    if (fightGroup != null && fightGroup.Status == FightGroupStatus.FightGroupIn)
                    {
                        this.ShowMessage("拼团过程中时,已完成支付的订单不能发起退款;", false, "", 1);
                        return;
                    }
                }
                if (!TradeHelper.CanRefund(this.order, ""))
                {
                    this.ShowMessage("当前订单不能进行退款操作!", false, "", 1);
                }
                else
                {
                    string userRemark = Globals.StripAllTags(this.txtRemark.Text.Trim());
                    if (this.iRefundType == 2 && (string.IsNullOrEmpty(text2) || string.IsNullOrEmpty(text3) || string.IsNullOrEmpty(text4)))
                    {
                        this.ShowMessage("您选择了银行退款,请在退款说明中输入退款的银行卡信息!", true, "", 1);
                    }
                    else if (!this.CanRefundBalance())
                    {
                        this.ShowMessage("请先开通预付款账户", false, "", 1);
                    }
                    else
                    {
                        string selectedValue = this.DropRefundReason.SelectedValue;
                        if (string.IsNullOrEmpty(selectedValue))
                        {
                            this.ShowMessage("请选择退款原因", true, "", 1);
                        }
                        string refundGateWay = string.IsNullOrEmpty(this.order.Gateway) ? "" : this.order.Gateway.ToLower().Replace(".payment.", ".refund.");
                        int    num           = 0;
                        num = this.order.GetAllQuantity(true);
                        GroupBuyInfo groupbuy = null;
                        if (this.order.GroupBuyId > 0)
                        {
                            groupbuy = ProductBrowser.GetGroupBuy(this.order.GroupBuyId);
                        }
                        decimal canRefundAmount = this.order.GetCanRefundAmount("", groupbuy, 0);
                        string  orderId         = this.order.OrderId;
                        if (this.RefundItem != null)
                        {
                            orderId = this.RefundItem.ItemDescription + this.RefundItem.SKUContent;
                            num     = this.RefundItem.ShipmentQuantity;
                        }
                        string     generateId = Globals.GetGenerateId();
                        RefundInfo refundInfo = new RefundInfo();
                        refundInfo.OrderId         = this.order.OrderId;
                        refundInfo.UserRemark      = userRemark;
                        refundInfo.RefundGateWay   = refundGateWay;
                        refundInfo.RefundOrderId   = generateId;
                        refundInfo.BankName        = text2;
                        refundInfo.BankAccountNo   = text4;
                        refundInfo.BankAccountName = text3;
                        refundInfo.ApplyForTime    = DateTime.Now;
                        refundInfo.StoreId         = this.order.StoreId;
                        refundInfo.RefundReason    = selectedValue;
                        refundInfo.RefundType      = (RefundTypes)this.iRefundType;
                        refundInfo.RefundAmount    = canRefundAmount;
                        if (TradeHelper.ApplyForRefund(refundInfo))
                        {
                            if (this.order.StoreId > 0)
                            {
                                VShopHelper.AppPsuhRecordForStore(this.order.StoreId, this.OrderId, "", EnumPushStoreAction.StoreOrderRefundApply);
                            }
                            this.ShowMessage("成功的申请了退款", true, text, 2);
                        }
                        else
                        {
                            this.ShowMessage("申请退款失败", false, "", 1);
                        }
                    }
                }
            }
        }
 private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
     }
     else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
     }
     else
     {
         int maxCount        = 0;
         int yetOrderNum     = 0;
         int currentOrderNum = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,团购活动已结束,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
             yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             currentOrderNum = this.Order.GetGroupBuyOerderNumber();
             maxCount        = groupBuy.MaxCount;
             if (maxCount < yetOrderNum + currentOrderNum)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,订购数量超过订购总数,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
         {
             Task.Factory.StartNew(delegate
             {
                 TradeHelper.UserPayOrder(this.Order, false, true);
                 try
                 {
                     if (this.offlineOrder != null)
                     {
                         OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
                         OrderHelper.ConfirmTakeGoods(this.Order, true);
                     }
                     if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                     {
                         TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                     }
                     if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                     {
                         Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
                         string verificationPasswords = "";
                         if (this.Order.OrderType == OrderType.ServiceOrder)
                         {
                             verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
                         }
                         if (user != null)
                         {
                             Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(false), verificationPasswords);
                         }
                     }
                     StoresInfo storesInfo = null;
                     if (this.Order.StoreId > 0)
                     {
                         storesInfo = DepotHelper.GetStoreById(this.Order.StoreId);
                     }
                     if (storesInfo != null)
                     {
                         VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                         if (this.offlineOrder == null)
                         {
                             if (this.Order.ShippingModeId == -2)
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                             }
                             else
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                             }
                         }
                     }
                     if (this.offlineOrder == null)
                     {
                         ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                         Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo, null, this.Order, this.Order.GetTotal(false));
                     }
                     this.Order.OnPayment();
                 }
                 catch (Exception ex)
                 {
                     IDictionary <string, string> dictionary = new Dictionary <string, string>();
                     dictionary.Add("ErrorMessage", ex.Message);
                     dictionary.Add("StackTrace", ex.StackTrace);
                     if (ex.InnerException != null)
                     {
                         dictionary.Add("InnerException", ex.InnerException.ToString());
                     }
                     if (ex.GetBaseException() != null)
                     {
                         dictionary.Add("BaseException", ex.GetBaseException().Message);
                     }
                     if (ex.TargetSite != (MethodBase)null)
                     {
                         dictionary.Add("TargetSite", ex.TargetSite.ToString());
                     }
                     dictionary.Add("ExSource", ex.Source);
                     Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
                 }
                 this.Order.OnPayment();
             });
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
         else
         {
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
     }
 }
Ejemplo n.º 9
0
        private void btnReturns_Click(object sender, EventArgs e)
        {
            string text = this.Page.Request.QueryString["returnUrl"].ToNullString();

            if (string.IsNullOrEmpty(text))
            {
                text = this.Page.Request.UrlReferrer.ToNullString();
                if (text == this.Page.Request.Url.ToString())
                {
                    text = "/User/UserOrders";
                }
            }
            int    num   = 3;
            string text2 = "";
            string text3 = "";
            string text4 = "";

            this.iRefundType = this.hidRefundType.Value.ToInt(0);
            num = this.hidAfterSaleType.Value.ToInt(0);
            if (string.IsNullOrEmpty(this.SkuId) || !this.order.LineItems.ContainsKey(this.SkuId))
            {
                this.ShowMessage("请选择要进行售后的商品", false, "", 1);
            }
            if (!TradeHelper.CanReturn(this.order, this.SkuId))
            {
                this.ShowMessage("该商品正在售后中!", false, "", 1);
            }
            else if (num != 2 && !Enum.IsDefined(typeof(RefundTypes), this.iRefundType))
            {
                this.ShowMessage("错误的退款方式", false, "", 1);
            }
            else
            {
                string enumDescription = EnumDescription.GetEnumDescription((Enum)(object)EnumPaymentType.AdvancePay, 1);
                if ((this.order.Gateway.ToLower() == enumDescription || this.order.DepositGatewayOrderId.ToNullString().ToLower() == enumDescription) && this.iRefundType != 1)
                {
                    this.ShowMessage("预付款支付的订单只能退回到预付款帐号", false, "", 1);
                }
                else if (!Enum.IsDefined(typeof(AfterSaleTypes), num))
                {
                    this.ShowMessage("错误的售后类型", false, "", 1);
                }
                else
                {
                    string userRemark = Globals.StripAllTags(this.txtRemark.Text.Trim());
                    if (!this.CanRefundBalance())
                    {
                        this.ShowMessage("请先开通预付款账户", false, "", 1);
                    }
                    else
                    {
                        text2 = Globals.StripAllTags(this.txtBankName.Value);
                        text3 = Globals.StripAllTags(this.txtBankAccountName.Value);
                        text4 = Globals.StripAllTags(this.txtBankAccountNo.Value);
                        string text5          = "";
                        string text6          = this.hidePicture.Value.Trim();
                        string imageServerUrl = Globals.GetImageServerUrl();
                        if (text6.Length > 0)
                        {
                            string[] array = text6.Split(',');
                            for (int i = 0; i < array.Length; i++)
                            {
                                text5 += (string.IsNullOrEmpty(imageServerUrl) ? (Globals.SaveFile("user\\Credentials", array[i], "/Storage/master/", true, false, "") + "|") : (array[i] + "|"));
                            }
                        }
                        text5 = text5.TrimEnd('|');
                        string selectedValue = this.DropReturnsReason.SelectedValue;
                        if (string.IsNullOrEmpty(selectedValue))
                        {
                            this.ShowMessage("请选择售后原因", false, "", 1);
                        }
                        string refundGateWay = string.IsNullOrEmpty(this.order.Gateway) ? "" : this.order.Gateway.ToLower().Replace(".payment.", ".refund.");
                        int    num2          = this.ReturnsItem.ShipmentQuantity;
                        if (num != 3)
                        {
                            int.TryParse(this.txtQuantity.Value, out num2);
                            if (num2 == 0)
                            {
                                num2 = TradeHelper.GetMaxQuantity(this.order, this.SkuId);
                            }
                            else if (this.ReturnsItem != null)
                            {
                                if (num2 > this.ReturnsItem.ShipmentQuantity)
                                {
                                    this.ShowMessage("数量不能大于购买商品的数量", false, "", 1);
                                    return;
                                }
                            }
                            else if (num2 > this.order.GetAllQuantity(true))
                            {
                                this.ShowMessage("数量不能大于订单中商品的数量", false, "", 1);
                                return;
                            }
                        }
                        decimal num3 = default(decimal);
                        decimal.TryParse(this.txtRefundAmount.Text, out num3);
                        decimal canRefundAmount = this.order.GetCanRefundAmount(this.SkuId, this.groupBuy, 1);
                        if (num == 3 && canRefundAmount <= decimal.Zero)
                        {
                            this.ShowMessage("订单支付金额为0时不能进行仅退款操作。", false, "", 1);
                        }
                        else
                        {
                            decimal num4 = this.litMaxAmount.Text.ToDecimal(0);
                            if (num2 < this.litMaxQuantity.Text.ToInt(0))
                            {
                                num4 = canRefundAmount * (decimal)num2;
                            }
                            if (num3 < decimal.Zero && num != 2)
                            {
                                this.ShowMessage("退款金额必须大于0", false, "", 1);
                            }
                            else if (num3 > num4)
                            {
                                this.ShowMessage(string.Format("退款金额不能大于最大可退款金额({0})", num4.F2ToString("f2")), true, "", 1);
                            }
                            else
                            {
                                string text7 = (num == 3) ? "退款" : "退货";
                                if (num == 3 || num == 1)
                                {
                                    string     generateId = Globals.GetGenerateId();
                                    ReturnInfo returnInfo = new ReturnInfo
                                    {
                                        UserRemark      = userRemark,
                                        ReturnReason    = selectedValue,
                                        RefundType      = (RefundTypes)this.iRefundType,
                                        RefundGateWay   = refundGateWay,
                                        RefundOrderId   = generateId,
                                        RefundAmount    = num3,
                                        StoreId         = this.order.StoreId,
                                        ApplyForTime    = DateTime.Now,
                                        BankName        = text2,
                                        BankAccountName = text3,
                                        BankAccountNo   = text4,
                                        HandleStatus    = ReturnStatus.Applied,
                                        OrderId         = this.order.OrderId,
                                        SkuId           = this.SkuId,
                                        Quantity        = num2,
                                        UserCredentials = text5,
                                        AfterSaleType   = (AfterSaleTypes)num
                                    };
                                    if (TradeHelper.ApplyForReturn(returnInfo))
                                    {
                                        if (this.order.StoreId > 0)
                                        {
                                            VShopHelper.AppPsuhRecordForStore(this.order.StoreId, this.OrderId, this.SkuId, EnumPushStoreAction.StoreOrderReturnApply);
                                        }
                                        this.ShowMessage("成功的申请了退货", true, text, 2);
                                    }
                                    else
                                    {
                                        this.ShowMessage("申请退货失败", false, text, 2);
                                    }
                                }
                                else
                                {
                                    ReplaceInfo replace = new ReplaceInfo
                                    {
                                        ApplyForTime    = DateTime.Now,
                                        HandleStatus    = ReplaceStatus.Applied,
                                        OrderId         = this.order.OrderId,
                                        Quantity        = num2,
                                        ReplaceReason   = selectedValue,
                                        SkuId           = this.SkuId,
                                        StoreId         = this.order.StoreId,
                                        UserCredentials = text5,
                                        UserRemark      = userRemark
                                    };
                                    if (TradeHelper.ApplyForReplace(replace))
                                    {
                                        if (this.order.StoreId > 0)
                                        {
                                            VShopHelper.AppPsuhRecordForStore(this.order.StoreId, this.OrderId, this.SkuId, EnumPushStoreAction.StoreOrderReplaceApply);
                                        }
                                        this.ShowMessage("成功的申请了换货", true, text, 2);
                                    }
                                    else
                                    {
                                        this.ShowMessage("申请换货失败", false, "", 1);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }