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);
					}
				}
			}
		}
        public void Refuse(HttpContext context)
        {
            int?intParam = base.GetIntParam(context, "id", true);

            if (!intParam.HasValue || intParam < 1)
            {
                throw new HidistroAshxException("错误的数据编号");
            }
            string parameter = base.GetParameter(context, "Reason", true);

            if (string.IsNullOrWhiteSpace(parameter))
            {
                throw new HidistroAshxException("请填写拒绝申请的原因");
            }
            if (parameter.Length > 50)
            {
                throw new HidistroAshxException("拒绝原因不能超过50字符");
            }
            if (StoreBalanceHelper.DealBalanceDrawRequestById(intParam.Value, false, ref this.sError, parameter))
            {
                base.ReturnSuccessResult(context, "拒绝申请成功", 0, true);
                return;
            }
            throw new HidistroAshxException("提现申请操作失败");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["OrderId"], out this.orderId))
     {
         base.GotoResourceNotFound();
     }
     else if (!this.Page.IsPostBack)
     {
         this.lblUserName.Text = this.Page.Request.QueryString["Name"].ToNullString();
         StoreBalanceDrawRequestQuery query = new StoreBalanceDrawRequestQuery
         {
             Id        = this.orderId,
             PageSize  = 1,
             PageIndex = 1,
             IsCount   = false
         };
         PageModel <StoreBalanceDrawRequestInfo> balanceDrawRequests = StoreBalanceHelper.GetBalanceDrawRequests(query, false);
         if (balanceDrawRequests != null && balanceDrawRequests.Models.Count() > 0)
         {
             StoreBalanceDrawRequestInfo storeBalanceDrawRequestInfo = balanceDrawRequests.Models.FirstOrDefault();
             this.lblAlipayCode.Text     = storeBalanceDrawRequestInfo.AlipayCode.ToNullString();
             this.lblAlipayRealName.Text = storeBalanceDrawRequestInfo.AlipayRealName.ToNullString();
             this.lblAccountName.Text    = storeBalanceDrawRequestInfo.AccountName.ToNullString();
             this.lblBankName.Text       = storeBalanceDrawRequestInfo.BankName.ToNullString();
             this.lblMerchantCode.Text   = storeBalanceDrawRequestInfo.MerchantCode.ToNullString();
             if (storeBalanceDrawRequestInfo.IsAlipay.ToBool())
             {
                 this.isAlipay = true;
             }
         }
     }
 }
Exemple #4
0
        public void GetList(HttpContext context)
        {
            StoreBalanceDetailQuery            dataQuery      = this.GetDataQuery(context);
            PageModel <StoreBalanceDetailInfo> balanceDetails = StoreBalanceHelper.GetBalanceDetails(dataQuery);
            string s = base.SerializeObjectToJson(new
            {
                Result = new
                {
                    total = balanceDetails.Total,
                    rows  = from b in balanceDetails.Models
                            select new
                    {
                        Income        = (b.Income.HasValue ? b.Income.Value.F2ToString("f2").ToDecimal(0) : decimal.Zero),
                        Expenses      = (b.Expenses.HasValue ? b.Expenses.Value.F2ToString("f2").ToDecimal(0) : decimal.Zero),
                        TradeType     = b.TradeType,
                        TradeTypeText = b.TradeTypeText,
                        TradeDate     = b.TradeDate.ToString("yyyy-MM-dd HH:mm"),
                        Balance       = b.Balance,
                        TradeNo       = b.TradeNo,
                        UserName      = ((new ManagerDao().FindManagerByStoreId(b.StoreId, SystemRoles.StoreAdmin) != null) ? new ManagerDao().FindManagerByStoreId(b.StoreId, SystemRoles.StoreAdmin).UserName : "")
                    }
                }
            });

            context.Response.Write(s);
            context.Response.End();
        }
Exemple #5
0
        public void ExportExcel(HttpContext context)
        {
            StoreBalanceDetailQuery dataQuery = this.GetDataQuery(context);
            StoresInfo storeById = DepotHelper.GetStoreById(dataQuery.StoreId.Value);
            IList <StoreBalanceDetailInfo> balanceDetails4Report = StoreBalanceHelper.GetBalanceDetails4Report(dataQuery);
            StringBuilder stringBuilder = new StringBuilder(300);

            stringBuilder.Append("门店");
            stringBuilder.Append(",时间");
            stringBuilder.Append(",类型");
            stringBuilder.Append(",订单号");
            stringBuilder.Append(",收入");
            stringBuilder.Append(",支出");
            stringBuilder.Append(",账户余额");
            stringBuilder.Append(",备注\r\n");
            foreach (StoreBalanceDetailInfo item in balanceDetails4Report)
            {
                stringBuilder.Append(storeById.StoreName);
                stringBuilder.Append("," + item.TradeDate);
                stringBuilder.Append("," + item.TradeTypeText);
                stringBuilder.Append("," + item.TradeNo);
                stringBuilder.Append("," + item.Income);
                stringBuilder.Append("," + item.Expenses);
                stringBuilder.Append("," + item.Balance);
                stringBuilder.Append("," + item.Remark + "\r\n");
            }
            context.Response.Clear();
            context.Response.Buffer  = false;
            context.Response.Charset = "GB2312";
            context.Response.AppendHeader("Content-Disposition", "attachment;filename=BalanceDetail.csv");
            context.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
            context.Response.ContentType     = "application/octet-stream";
            context.Response.Write(stringBuilder.ToString());
            context.Response.End();
        }
        private void CheckResult(string For, string ID, bool IsSuccess, string sError = "")
        {
            int    num  = 0;
            string text = ID.ToNullString().ToLower().Trim();

            if (text.StartsWith("pre"))
            {
                if (text.Length > 5)
                {
                    num = text.Substring(5).ToInt(0);
                }
            }
            else
            {
                num = text.ToInt(0);
            }
            if (For.ToLower().Equals("balancedraw"))
            {
                MemberHelper.OnLineBalanceDrawRequest_API(num, IsSuccess, sError);
            }
            else if (For.ToLower().Equals("splittin"))
            {
                MemberHelper.OnLineSplittinDraws_API(num, IsSuccess, sError);
            }
            else if (For.ToLower().Equals("balancedraw4supplier"))
            {
                BalanceHelper.OnLineBalanceDrawRequest_API(num, IsSuccess, sError);
            }
            else if (For.ToLower().Equals("balancedraw4store"))
            {
                StoreBalanceHelper.OnLineBalanceDrawRequest_API(num, true, sError);
            }
        }
        public void Confirm(HttpContext context)
        {
            if (!base.CurrentSiteSetting.EnableBulkPaymentAliPay)
            {
                throw new HidistroAshxException("系统已关闭支付宝批量转账功能,请拒绝转账申请");
            }
            string parameter = base.GetParameter(context, "ids", false);

            if (string.IsNullOrWhiteSpace(parameter))
            {
                throw new HidistroAshxException("错误的数据编号");
            }
            List <int> list = (from d in parameter.Split(',')
                               where !string.IsNullOrWhiteSpace(d)
                               select int.Parse(d)).ToList();
            string text = "";
            bool   flag = true;

            foreach (int item in list)
            {
                if (!StoreBalanceHelper.DealBalanceDrawRequestById(item, true, ref this.sError, ""))
                {
                    text = text + item.ToString() + ":预付款提现申请操作失败," + this.sError + "。";
                    flag = false;
                }
            }
            if (flag)
            {
                base.ReturnSuccessResult(context, "预付款提现成功,等待支付宝处理结果", 0, true);
                return;
            }
            throw new HidistroAshxException(text);
        }
        public void ExportExcel(HttpContext context)
        {
            StoreBalanceDrawRequestQuery dataQuery  = this.GetDataQuery(context);
            DbQueryResult balanceDrawRequest4Report = StoreBalanceHelper.GetBalanceDrawRequest4Report(dataQuery, true);
            string        empty = string.Empty;

            empty += "用户名";
            empty += ",门店";
            empty += ",申请时间";
            empty += ",业务摘要";
            empty += ",提现金额";
            empty += ",备注\r\n";
            foreach (DataRow row in balanceDrawRequest4Report.Data.Rows)
            {
                empty += row["UserName"];
                empty  = empty + "," + row["StoreName"];
                empty  = empty + "," + row["RequestTime"];
                empty += ",支付宝提现";
                empty  = empty + "," + row["Amount"];
                empty  = empty + "," + row["Remark"] + "\r\n";
            }
            context.Response.Clear();
            context.Response.Buffer  = false;
            context.Response.Charset = "GB2312";
            context.Response.AppendHeader("Content-Disposition", "attachment;filename=DrawRequest4Ali.csv");
            context.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
            context.Response.ContentType     = "application/octet-stream";
            context.Response.Write(empty);
            context.Response.End();
        }
Exemple #9
0
        private void GetBalanceOnLineDetailById(HttpContext context)
        {
            StoreBalanceOrderInfo balanceDetails       = StoreBalanceHelper.GetBalanceDetails(context.Request.QueryString["id"].ToInt(0));
            IsoDateTimeConverter  isoDateTimeConverter = new IsoDateTimeConverter();

            isoDateTimeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string s = JsonConvert.SerializeObject(balanceDetails, Formatting.Indented, isoDateTimeConverter);

            context.Response.Write(s);
            context.Response.End();
        }
Exemple #10
0
        public void Confirm(HttpContext context)
        {
            int?intParam = base.GetIntParam(context, "id", true);

            if (!intParam.HasValue || intParam < 1)
            {
                throw new HidistroAshxException("错误的数据编号");
            }
            if (StoreBalanceHelper.DealBalanceDrawRequestById(intParam.Value, true, ref this.sError, ""))
            {
                base.ReturnSuccessResult(context, "预付款提现成功", 0, true);
                return;
            }
            throw new HidistroAshxException(this.sError);
        }
Exemple #11
0
        private DataGridViewModel <Dictionary <string, object> > GetDataList(StoreBalanceDrawRequestQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                PageModel <StoreBalanceDrawRequestInfo> balanceDrawRequests = StoreBalanceHelper.GetBalanceDrawRequests(query, true);
                dataGridViewModel.rows  = new List <Dictionary <string, object> >();
                dataGridViewModel.total = balanceDrawRequests.Total;
                foreach (StoreBalanceDrawRequestInfo model in balanceDrawRequests.Models)
                {
                    Dictionary <string, object> item = model.ToDictionary();
                    dataGridViewModel.rows.Add(item);
                }
            }
            return(dataGridViewModel);
        }
        private DataGridViewModel <Dictionary <string, object> > GetDataList(StoreBalanceDetailQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                DbQueryResult balanceStatisticsList = StoreBalanceHelper.GetBalanceStatisticsList(query);
                dataGridViewModel.rows  = new List <Dictionary <string, object> >();
                dataGridViewModel.total = balanceStatisticsList.TotalRecords;
                foreach (DataRow row in balanceStatisticsList.Data.Rows)
                {
                    Dictionary <string, object> dictionary = DataHelper.DataRowToDictionary(row);
                    dictionary.Add("AvailableBalance", dictionary["Balance"].ToDecimal(0) - dictionary["BalanceFozen"].ToDecimal(0));
                    dataGridViewModel.rows.Add(dictionary);
                }
            }
            return(dataGridViewModel);
        }
        private DataGridViewModel <Dictionary <string, object> > GetDataList(StoreBalanceDrawRequestQuery query)
        {
            DataGridViewModel <Dictionary <string, object> > dataGridViewModel = new DataGridViewModel <Dictionary <string, object> >();

            if (query != null)
            {
                PageModel <StoreBalanceDrawRequestInfo> balanceDrawRequests = StoreBalanceHelper.GetBalanceDrawRequests(query, true);
                dataGridViewModel.rows  = new List <Dictionary <string, object> >();
                dataGridViewModel.total = balanceDrawRequests.Total;
                foreach (StoreBalanceDrawRequestInfo model in balanceDrawRequests.Models)
                {
                    Dictionary <string, object> dictionary = model.ToDictionary();
                    dictionary.Add("RequestStateText", OnLinePaymentEnumHelper.GetOnLinePaymentDescription(model.RequestState));
                    dataGridViewModel.rows.Add(dictionary);
                }
            }
            return(dataGridViewModel);
        }
        public void Cancel(HttpContext context)
        {
            int?intParam = base.GetIntParam(context, "id", true);

            if (!intParam.HasValue || intParam < 1)
            {
                throw new HidistroAshxException("错误的数据编号");
            }
            try
            {
                StoreBalanceHelper.OnLineBalanceDrawRequest_API(intParam.Value, false, "管理员:" + base.CurrentManager.UserName + "取消付款");
                base.ReturnSuccessResult(context, "取消付款成功", 0, true);
            }
            catch
            {
                throw new HidistroAshxException("取消付款操作失败");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string text  = this.Page.Request.QueryString["Ids"].ToNullString();
            string text2 = this.Page.Request.QueryString["Type"].ToNullString().ToLower();

            if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2))
            {
                base.Response.Redirect("/admin");
            }
            else
            {
                try
                {
                    switch (text2)
                    {
                    case "balance":
                        MemberHelper.OnLineBalanceDrawRequest_Alipay(text);
                        break;

                    case "splittin":
                        MemberHelper.OnLineSplittinDrawRequest_Alipay(text);
                        break;

                    case "balance4supplier":
                        BalanceHelper.OnLineBalanceDrawRequest_Alipay(text);
                        break;

                    case "balance4store":
                        StoreBalanceHelper.OnLineBalanceDrawRequest_Alipay(text);
                        break;

                    default:
                        base.Response.Redirect("/admin");
                        break;
                    }
                }
                catch
                {
                    base.Response.Redirect("/admin");
                }
            }
        }
Exemple #16
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, "");
     }
 }
Exemple #17
0
 public static void OnLine_Alipay(DataTable dt, string ForString)
 {
     if (dt != null && dt.Rows.Count > 0)
     {
         string text = "";
         try
         {
             string str = "preub";
             if (ForString.ToLower().Equals("balance"))
             {
                 str = "preub";
             }
             else if (ForString.ToLower().Equals("splittin"))
             {
                 str = "preus";
             }
             else if (ForString.ToLower().Equals("balancedraw4supplier"))
             {
                 str = "presb";
             }
             else if (ForString.ToLower().Equals("balancedraw4store"))
             {
                 str = "predb";
             }
             string[]  array  = new string[dt.Rows.Count];
             int[]     array2 = new int[dt.Rows.Count];
             decimal[] array3 = new decimal[dt.Rows.Count];
             string[]  array4 = new string[dt.Rows.Count];
             string[]  array5 = new string[dt.Rows.Count];
             string[]  array6 = new string[dt.Rows.Count];
             string[]  array7 = new string[dt.Rows.Count];
             int       num    = 0;
             foreach (DataRow row in dt.Rows)
             {
                 text        = text + row["ID"].ToNullString().Trim() + ",";
                 array[num]  = str + row["ID"].ToNullString().Trim();
                 array2[num] = row["USERID"].ToInt(0);
                 array3[num] = Math.Round(row["AMOUNT"].ToDecimal(0), 2);
                 array4[num] = row["AlipayCode"].ToNullString();
                 array5[num] = row["AlipayRealName"].ToNullString();
                 array6[num] = "";
                 array7[num] = num.ToNullString();
                 num++;
             }
             text = text.TrimEnd(',');
             string          text2       = "Hishop.Plugins.Outpay.Alipay.AlipayRequest";
             PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode(text2);
             string          settings    = paymentMode.Settings;
             ConfigData      configData  = new ConfigData(HiCryptographer.Decrypt(settings));
             settings = configData.SettingsXml;
             string        notifyUrl     = Globals.FullPath("/pay/OutpayNotify?FOR=" + ForString + "&HIGW=" + text2);
             OutpayRequest outpayRequest = OutpayRequest.CreateInstance(text2, settings, array, array3, array4, array5, array6, array2, array7, DateTime.Now, "", "", notifyUrl, "");
             outpayRequest.SendRequest();
         }
         catch (Exception ex)
         {
             IDictionary <string, string> dictionary = new Dictionary <string, string>();
             dictionary.Add("ForString", ForString);
             Globals.WriteExceptionLog(ex, dictionary, "OnLine_Alipay");
             if (ForString.ToLower().Equals("balance"))
             {
                 MemberHelper.OnLineBalanceDrawRequest_Alipay_AllError(text, ex.Message);
             }
             else if (ForString.ToLower().Equals("splittin"))
             {
                 MemberHelper.OnLineSplittinDraws_Alipay_AllError(text, ex.Message);
             }
             else if (ForString.ToLower().Equals("balancedraw4supplier"))
             {
                 BalanceHelper.OnLineBalanceDraws_Alipay_AllError(text, ex.Message);
             }
             else if (ForString.ToLower().Equals("balancedraw4store"))
             {
                 StoreBalanceHelper.OnLineBalanceDraws_Alipay_AllError(text, ex.Message);
             }
         }
     }
 }
        public override void OnLoad(HttpContext context)
        {
            base.OnLoad(context);
            if (context.Request["flag"] == "Select")
            {
                StoreBalanceDrawRequestQuery storeBalanceDrawRequestQuery = new StoreBalanceDrawRequestQuery();
                int num = context.Request["PageIndex"].ToInt(0);
                if (num < 1)
                {
                    num = 1;
                }
                int num2 = context.Request["PageSize"].ToInt(0);
                if (num2 < 1)
                {
                    num2 = 10;
                }
                storeBalanceDrawRequestQuery.PageIndex = num;
                storeBalanceDrawRequestQuery.PageSize  = num2;
                storeBalanceDrawRequestQuery.SortBy    = "RequestTime";
                storeBalanceDrawRequestQuery.SortOrder = SortAction.Desc;
                storeBalanceDrawRequestQuery.StoreId   = base.CurrentManager.StoreId;
                PageModel <StoreBalanceDrawRequestInfo> balanceDrawRequests = StoreBalanceHelper.GetBalanceDrawRequests(storeBalanceDrawRequestQuery, false);
                string s = JsonConvert.SerializeObject(new
                {
                    Result = new
                    {
                        RecordCount = balanceDrawRequests.Total,
                        List        = balanceDrawRequests.Models.Select(delegate(StoreBalanceDrawRequestInfo b)
                        {
                            DateTime dateTime   = b.RequestTime;
                            string requestTime  = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
                            decimal amount      = b.Amount.F2ToString("f2").ToDecimal(0);
                            string drawType     = (b.IsAlipay.HasValue && b.IsAlipay.Value) ? "支付宝" : "银行卡";
                            string statusText   = b.IsPass.HasValue ? (b.IsPass.Value ? "已通过审核" : "拒绝") : "审核中";
                            string requestError = b.RequestError;
                            object accountDate;
                            if (!b.AccountDate.HasValue)
                            {
                                accountDate = "";
                            }
                            else
                            {
                                dateTime    = b.AccountDate.Value;
                                accountDate = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
                            }
                            return(new
                            {
                                RequestTime = requestTime,
                                Amount = amount,
                                DrawType = drawType,
                                StatusText = statusText,
                                RequestError = requestError,
                                AccountDate = (string)accountDate,
                                Id = b.Id,
                                ManagerRemark = b.ManagerRemark,
                                Remark = b.Remark
                            });
                        })
                    }
                });
                context.Response.Write(s);
                context.Response.End();
            }
            if (context.Request["flag"] == "GetDrawCardInfo")
            {
                StoresInfo       storeById    = StoresHelper.GetStoreById(base.CurrentManager.StoreId);
                StoreBalanceInfo storeBalance = StoreBalanceHelper.GetStoreBalance(storeById.StoreId, storeById.CommissionRate);
                decimal          num3         = storeBalance.Balance - storeBalance.BalanceForzen;
                if (num3 < decimal.Zero)
                {
                    num3 = default(decimal);
                }
                SiteSettings siteSettings = HiContext.Current.SiteSettings;
                string       s2           = JsonConvert.SerializeObject(new
                {
                    Result = new
                    {
                        Balance          = num3.F2ToString("f2").ToDecimal(0),
                        IsOpenAlipayDraw = siteSettings.EnableBulkPaymentAliPay,
                        AlipayAccount    = storeById.AlipayAccount,
                        AlipayRealName   = storeById.AlipayRealName,
                        BankName         = storeById.BankName,
                        BankAccountName  = storeById.BankAccountName,
                        BankCardNo       = storeById.BankCardNo
                    }
                });
                context.Response.Write(s2);
                context.Response.End();
            }
            if (context.Request["flag"] == "ValidTradePassword")
            {
                StoresInfo storeById2 = StoresHelper.GetStoreById(base.CurrentManager.StoreId);
                string     pass       = context.Request["Password"].ToNullString();
                if (storeById2.TradePassword == Users.EncodePassword(pass, storeById2.TradePasswordSalt))
                {
                    string s3 = JsonConvert.SerializeObject(new
                    {
                        Result = new
                        {
                            Status = "SUCCESS",
                            Msg    = "验证成功"
                        }
                    });
                    context.Response.Write(s3);
                    context.Response.End();
                }
                else
                {
                    string s4 = JsonConvert.SerializeObject(new
                    {
                        Result = new
                        {
                            Status = "FAIL",
                            Msg    = "验证失败"
                        }
                    });
                    context.Response.Write(s4);
                    context.Response.End();
                }
            }
            if (context.Request["flag"] == "ApplyBalanceRequest")
            {
                StoresInfo storeById3 = StoresHelper.GetStoreById(base.CurrentManager.StoreId);
                string     pass2      = context.Request["Password"].ToNullString();
                if (storeById3.TradePassword != Users.EncodePassword(pass2, storeById3.TradePasswordSalt))
                {
                    context.Response.Write(this.GetErrorJosn(521, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.TradePassword_Error, 0)));
                    context.Response.End();
                }
                int num4 = context.Request["CardType"].ToInt(0);
                if (num4 != 1 && num4 != 2)
                {
                    context.Response.Write(this.GetErrorJosn(133, "帐号类型" + EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.ValueUndefined, 0)));
                    context.Response.End();
                }
                if (num4 == 1 && !HiContext.Current.SiteSettings.EnableBulkPaymentAliPay)
                {
                    context.Response.Write(this.GetErrorJosn(134, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.PlatNotOpenAlipayDraw, 0)));
                    context.Response.End();
                }
                if (num4 == 1 && (string.IsNullOrEmpty(storeById3.AlipayAccount) || string.IsNullOrEmpty(storeById3.AlipayRealName)))
                {
                    context.Response.Write(this.GetErrorJosn(523, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.StoreNotBindAlipayInfo, 0)));
                    context.Response.End();
                }
                if (num4 == 2 && (string.IsNullOrEmpty(storeById3.BankAccountName) || string.IsNullOrEmpty(storeById3.BankCardNo) || string.IsNullOrEmpty(storeById3.BankName)))
                {
                    context.Response.Write(this.GetErrorJosn(524, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.StoreNotBindBankCardInfo, 0)));
                    context.Response.End();
                }
                decimal num5 = context.Request["RequestAmount"].ToDecimal(0);
                if (num5 <= decimal.Zero)
                {
                    context.Response.Write(this.GetErrorJosn(526, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.RequestAmountError, 0)));
                    context.Response.End();
                }
                if (num5 > storeById3.Balance)
                {
                    context.Response.Write(this.GetErrorJosn(525, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.BalanceNotEnough, 0)));
                    context.Response.End();
                }
                string text = Globals.StripAllTags(context.Request["Remark"].ToNullString());
                if (text.Length > 2000)
                {
                    text = text.Substring(0, 2000);
                }
                StoreBalanceDrawRequestInfo storeBalanceDrawRequestInfo = new StoreBalanceDrawRequestInfo();
                if (num4 == 1)
                {
                    storeBalanceDrawRequestInfo.AlipayCode     = storeById3.AlipayAccount;
                    storeBalanceDrawRequestInfo.AlipayRealName = storeById3.AlipayRealName;
                    storeBalanceDrawRequestInfo.IsAlipay       = true;
                }
                else
                {
                    storeBalanceDrawRequestInfo.BankName     = storeById3.BankName;
                    storeBalanceDrawRequestInfo.AccountName  = storeById3.BankAccountName;
                    storeBalanceDrawRequestInfo.MerchantCode = storeById3.BankCardNo;
                    storeBalanceDrawRequestInfo.IsAlipay     = false;
                }
                storeBalanceDrawRequestInfo.RequestState = 1.ToString();
                storeBalanceDrawRequestInfo.Remark       = text;
                storeBalanceDrawRequestInfo.Amount       = num5;
                storeBalanceDrawRequestInfo.RequestTime  = DateTime.Now;
                storeBalanceDrawRequestInfo.StoreId      = storeById3.StoreId;
                if (StoreBalanceHelper.BalanceDrawRequest(storeBalanceDrawRequestInfo))
                {
                    string s5 = JsonConvert.SerializeObject(new
                    {
                        Result = new
                        {
                            Status = "SUCCESS",
                            Msg    = "申请提现成功"
                        }
                    });
                    context.Response.Write(s5);
                    context.Response.End();
                    goto IL_0738;
                }
                context.Response.Write(this.GetErrorJosn(0, ((Enum)(object)ApiErrorCode.Failed).ToDescription()));
                return;
            }
            goto IL_0738;
IL_0738:
            if (context.Request["flag"] == "CheckPasswordInfo")
            {
                StoresInfo storeById4 = StoresHelper.GetStoreById(base.CurrentManager.StoreId);
                if (storeById4.TradePassword == null || storeById4.TradePassword == "")
                {
                    string s6 = JsonConvert.SerializeObject(new
                    {
                        Result = new
                        {
                            Status = "FAIL",
                            Msg    = "未设置交易密码"
                        }
                    });
                    context.Response.Write(s6);
                    context.Response.End();
                }
                else
                {
                    string s7 = JsonConvert.SerializeObject(new
                    {
                        Result = new
                        {
                            Status = "SUCCESS",
                            Msg    = "已设置交易密码"
                        }
                    });
                    context.Response.Write(s7);
                    context.Response.End();
                }
            }
            if (context.Request["flag"] == "BindDrawCardInfo")
            {
                StoresInfo storeById5 = StoresHelper.GetStoreById(base.CurrentManager.StoreId);
                string     pass3      = context.Request["Password"].ToNullString();
                if (storeById5.TradePassword != Users.EncodePassword(pass3, storeById5.TradePasswordSalt))
                {
                    context.Response.Write(this.GetErrorJosn(521, EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.TradePassword_Error, 0)));
                    context.Response.End();
                }
                string text2 = "";
                string text3 = "";
                string text4 = "";
                string text5 = "";
                string text6 = "";
                if (base.CurrentSiteSetting.EnableBulkPaymentAliPay)
                {
                    text2 = Globals.StripAllTags(context.Request["AlipayAccount"].ToNullString());
                    text3 = Globals.StripAllTags(context.Request["AlipayRealName"].ToNullString());
                    if ((string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3)) || (!string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text3)))
                    {
                        context.Response.Write(this.GetErrorJosn(104, "支付宝帐号和真实姓名" + EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.Empty_Error, 0)));
                        context.Response.End();
                    }
                    if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3))
                    {
                        storeById5.AlipayAccount  = text2;
                        storeById5.AlipayRealName = text3;
                    }
                }
                text4 = Globals.StripAllTags(context.Request["BankName"].ToNullString());
                text5 = Globals.StripAllTags(context.Request["BankAccountName"].ToNullString());
                text6 = Globals.StripAllTags(context.Request["BankCardNo"].ToNullString());
                if (!base.CurrentSiteSetting.EnableBulkPaymentAliPay && (string.IsNullOrEmpty(text4) || string.IsNullOrEmpty(text5) || string.IsNullOrEmpty(text6)))
                {
                    context.Response.Write(this.GetErrorJosn(104, "银行卡帐号" + EnumDescription.GetEnumDescription((Enum)(object)ApiErrorCode.Empty_Error, 0)));
                    context.Response.End();
                }
                storeById5.BankName        = text4;
                storeById5.BankAccountName = text5;
                storeById5.BankCardNo      = text6;
                if (StoresHelper.UpdateStore(storeById5))
                {
                    string s8 = JsonConvert.SerializeObject(new
                    {
                        Result = new
                        {
                            Status = "SUCCESS",
                            Msg    = "更新成功"
                        }
                    });
                    context.Response.Write(s8);
                    context.Response.End();
                    goto IL_0af6;
                }
                context.Response.Write(this.GetErrorJosn(0, ((Enum)(object)ApiErrorCode.Failed).ToDescription()));
                return;
            }
            goto IL_0af6;
IL_0af6:
            if (context.Request["flag"] == "SetTradePassword")
            {
                StoresInfo storeById6 = StoresHelper.GetStoreById(base.CurrentManager.StoreId);
                if (!string.IsNullOrEmpty(storeById6.TradePassword))
                {
                    context.Response.Write(this.GetErrorJosn(519, ((Enum)(object)ApiErrorCode.TradePasswordAlreadySet).ToDescription()));
                }
                else
                {
                    string text7 = context.Request["Password"].ToNullString();
                    string b2    = context.Request["RePassword"].ToNullString();
                    if (text7 != b2)
                    {
                        context.Response.Write(this.GetErrorJosn(213, ((Enum)(object)ApiErrorCode.RePasswordNoEqualsPassword).ToDescription()));
                    }
                    else if (string.IsNullOrEmpty(text7) || text7.Length < 6)
                    {
                        context.Response.Write(this.GetErrorJosn(212, ((Enum)(object)ApiErrorCode.Password_Error).ToDescription()));
                    }
                    else
                    {
                        storeById6.TradePasswordSalt = Globals.RndStr(128, true);
                        storeById6.TradePassword     = Users.EncodePassword(text7, storeById6.TradePasswordSalt);
                        if (StoresHelper.UpdateStore(storeById6))
                        {
                            string s9 = JsonConvert.SerializeObject(new
                            {
                                Result = new
                                {
                                    Status = "SUCCESS",
                                    Msg    = ""
                                }
                            });
                            context.Response.Write(s9);
                            context.Response.End();
                        }
                        else
                        {
                            context.Response.Write(this.GetErrorJosn(0, ((Enum)(object)ApiErrorCode.Failed).ToDescription()));
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string              text            = "";
            PaymentModeInfo     paymentModeInfo = null;
            NameValueCollection form            = base.Request.Form;
            string              parameter       = this.GetParameter("FOR");
            string              parameter2      = this.GetParameter("HIGW");

            if (string.IsNullOrEmpty(parameter2))
            {
                parameter2 = this.GetParameter("Gateway");
            }
            try
            {
                NameValueCollection param = new NameValueCollection
                {
                    base.Request.Form,
                    base.Request.QueryString
                };
                if (string.IsNullOrEmpty(parameter2))
                {
                    base.Response.Write("fail");
                    Globals.WriteLog(param, "网关信息为空", "", "", "Outpay");
                    throw new Exception("网关信息为空-支付宝通知");
                }
                paymentModeInfo = TradeHelper.GetPaymentMode(parameter2);
                if (paymentModeInfo == null)
                {
                    base.Response.Write("fail");
                    Globals.WriteLog(param, "网关信息错误---" + parameter2, "", "", "Outpay");
                    throw new Exception("网关信息错误-支付宝通知");
                }
                string configXml = HiCryptographer.Decrypt(paymentModeInfo.Settings);
                this.Notify = Hishop.Plugins.OutpayNotify.CreateInstance(parameter2, form);
                if (this.Notify == null)
                {
                    base.Response.Write("fail");
                    Globals.WriteLog(param, "创建回调实例失败---" + parameter2, "", "", "Outpay");
                    throw new Exception("创建回调实例失败-支付宝通知");
                }
                bool flag = false;
                try
                {
                    flag = this.Notify.VerifyNotify(600, configXml);
                }
                catch (Exception ex)
                {
                    Globals.AppendLog(param, "通知网关或者验签失败" + ex.Message + "-" + parameter2, "", "", "Outpay");
                    base.Response.Write("fail");
                    base.Response.End();
                    throw new Exception("通知网关或者验签失败-支付宝通知");
                }
                if (flag)
                {
                    IList <string>   outpayId       = this.Notify.GetOutpayId();
                    IList <string>   gatewayOrderId = this.Notify.GetGatewayOrderId();
                    IList <decimal>  orderAmount    = this.Notify.GetOrderAmount();
                    IList <DateTime> payTime        = this.Notify.GetPayTime();
                    IList <bool>     status         = this.Notify.GetStatus();
                    IList <string>   errMsg         = this.Notify.GetErrMsg();
                    if (outpayId == null || gatewayOrderId == null || orderAmount == null || payTime == null || outpayId.Count == 0 || gatewayOrderId.Count == 0 || orderAmount.Count == 0 || payTime.Count == 0)
                    {
                        Globals.AppendLog(param, "获取返回参数错误,参数为空-" + parameter2, "", "", "Outpay");
                    }
                    else if (outpayId.Count != gatewayOrderId.Count || outpayId.Count != orderAmount.Count || outpayId.Count != payTime.Count)
                    {
                        Globals.AppendLog(param, "获取返回参数错误,参数不匹配-" + parameter2, "", "", "Outpay");
                    }
                    else
                    {
                        string text2 = "";
                        string text3 = "";
                        string text4 = "";
                        string text5 = "";
                        string text6 = "";
                        string text7 = "";
                        string text8 = "";
                        for (int i = 0; i < outpayId.Count; i++)
                        {
                            if (outpayId[i].ToLower().StartsWith("pre"))
                            {
                                if (outpayId[i].Length > 5)
                                {
                                    text8 = outpayId[i].Substring(5);
                                }
                            }
                            else
                            {
                                text8 = outpayId[i];
                            }
                            text  = text + text8 + ",";
                            text2 = text2 + ((i == 0) ? "" : ",") + text8;
                            text3 = text3 + ((i == 0) ? "" : ",") + gatewayOrderId[i];
                            text4 = text4 + ((i == 0) ? "" : ",") + orderAmount[i];
                            text5 = text5 + ((i == 0) ? "" : ",") + payTime[i];
                            text6 = text6 + ((i == 0) ? "" : ",") + status[i].ToString();
                            text7 = text7 + ((i == 0) ? "" : ",") + errMsg[i];
                            if (status[i])
                            {
                                this.CheckResult(parameter.ToNullString(), outpayId[i], true, "");
                            }
                            else
                            {
                                this.CheckResult(parameter.ToNullString(), outpayId[i], false, errMsg[i]);
                            }
                        }
                        text = text.TrimEnd(',');
                        IDictionary <string, string> dictionary = new Dictionary <string, string>();
                        dictionary.Add("outpayIdLists", text2);
                        dictionary.Add("getwayOrderIdLists", text3);
                        dictionary.Add("payAmountLists", text4);
                        dictionary.Add("payTimeLists", text5);
                        dictionary.Add("IsSuccesss", text6);
                        dictionary.Add("ErrMsgs", text7);
                        base.Response.Write("success");
                    }
                    goto end_IL_004c;
                }
                Globals.AppendLog(param, "验签失败-" + parameter2, "", "", "Outpay");
                base.Response.Write("fail");
                throw new Exception("验签失败-支付宝通知");
                end_IL_004c :;
            }
            catch (Exception ex2)
            {
                if (parameter.ToLower().Equals("balancedraw"))
                {
                    MemberHelper.OnLineBalanceDrawRequest_Alipay_AllError(text, ex2.Message);
                }
                else if (parameter.ToLower().Equals("splittin"))
                {
                    MemberHelper.OnLineSplittinDraws_Alipay_AllError(text, ex2.Message);
                }
                else if (parameter.ToLower().Equals("balancedraw4supplier"))
                {
                    BalanceHelper.OnLineBalanceDraws_Alipay_AllError(text, ex2.Message);
                }
                else if (parameter.ToLower().Equals("balancedraw4store"))
                {
                    StoreBalanceHelper.OnLineBalanceDraws_Alipay_AllError(text, ex2.Message);
                }
            }
        }