Beispiel #1
0
 protected void btnCheck_Click(object sender, EventArgs e)
 {
     lock (ConfirmTake.submitLock)
     {
         OrderInfo orderInfo = OrderHelper.GetOrderInfo(this.hidOrderId.Value);
         if (orderInfo == null)
         {
             this.ShowMsg("订单不存在", false);
         }
         if (orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
         {
             orderInfo.IsStoreCollect = true;
             orderInfo.Gateway        = "hishop.plugins.payment.cashreceipts";
             orderInfo.PaymentType    = "现金支付";
             orderInfo.PaymentTypeId  = -99;
         }
         if (orderInfo.FightGroupId > 0 && orderInfo.FightGroupStatus != FightGroupStatus.FightGroupSuccess)
         {
             this.ShowMsg("该订单是火拼团订单,但是组团还没未成功,不能提货。", false);
         }
         else if (OrderHelper.ConfirmTakeGoods(orderInfo, false))
         {
             this.ShowMsg("成功的完成了该订单", true);
         }
         else
         {
             this.ShowMsg("完成订单失败,可能是库存不足", false);
         }
     }
 }
Beispiel #2
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, "");
     }
 }
		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");
				}
			}
		}
Beispiel #4
0
        private void HiPOSOrderConfirm(HttpContext context)
        {
            string        text          = context.Request["code"].ToNullString();
            string        value         = context.Request["sign"].ToNullString().ToLower();
            string        text2         = context.Request["device_id"].ToNullString();
            string        text3         = context.Request["method"].ToNullString();
            StringBuilder stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
            {
                string text4 = this.SetSHA1(context).ToLower();
                if (!text4.Equals(value))
                {
                    HiShopJsonResult obj = new HiShopJsonResult
                    {
                        error = new Error
                        {
                            code    = 0,
                            message = "签名错误"
                        }
                    };
                    stringBuilder.Append(JsonHelper.GetJson(obj));
                }
                else
                {
                    string    takeCode  = text.Replace(Globals.HIPOSTAKECODEPREFIX, string.Empty).Trim();
                    OrderInfo orderInfo = OrderHelper.ValidateTakeCode(takeCode, text2);
                    if (orderInfo != null)
                    {
                        if (orderInfo.FightGroupId > 0 && orderInfo.FightGroupStatus != FightGroupStatus.FightGroupSuccess)
                        {
                            HiShopJsonResult obj2 = new HiShopJsonResult
                            {
                                error = new Error
                                {
                                    code    = 0,
                                    message = "该订单是火拼团订单,但是组团还没未成功,不能提货!"
                                }
                            };
                            stringBuilder.Append(JsonHelper.GetJson(obj2));
                        }
                        else
                        {
                            orderInfo.HiPOSUseName = "HiPOS系统";
                            if (OrderHelper.ConfirmTakeGoods(orderInfo, true))
                            {
                                ConfirmingResult confirmingResult = new ConfirmingResult();
                                confirmingResult.confirming_response        = new ConfirmingResponse();
                                confirmingResult.confirming_response.result = "ok";
                                stringBuilder.Append(JsonHelper.GetJson(confirmingResult));
                                new OrderDao().UpdateOrderPaymentType(orderInfo.OrderId, "HiPOS支付");
                                if (!string.IsNullOrEmpty(text3))
                                {
                                    bool isStoreCollect = false;
                                    switch (text3.Trim().ToLower())
                                    {
                                    case "cash":
                                        isStoreCollect = true;
                                        break;

                                    case "weixin":
                                        isStoreCollect = false;
                                        break;

                                    case "alipay":
                                        isStoreCollect = false;
                                        break;
                                    }
                                    new OrderDao().UpdateOrderIsStoreCollect(orderInfo.OrderId, isStoreCollect);
                                }
                            }
                            else
                            {
                                HiShopJsonResult obj3 = new HiShopJsonResult
                                {
                                    error = new Error
                                    {
                                        code    = 0,
                                        message = "确认提货失败"
                                    }
                                };
                                stringBuilder.Append(JsonHelper.GetJson(obj3));
                            }
                        }
                    }
                    else
                    {
                        HiShopJsonResult obj4 = new HiShopJsonResult
                        {
                            error = new Error
                            {
                                code    = 0,
                                message = "提货码失效"
                            }
                        };
                        stringBuilder.Append(JsonHelper.GetJson(obj4));
                    }
                }
            }
            else
            {
                HiShopJsonResult obj5 = new HiShopJsonResult
                {
                    error = new Error
                    {
                        code    = 0,
                        message = "提货码失效"
                    }
                };
                stringBuilder.Append(JsonHelper.GetJson(obj5));
            }
            context.Response.Write(stringBuilder.ToString());
        }
 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)));
         }
     }
 }