Example #1
0
 private void btnAddBalance_Click(object sender, EventArgs e)
 {
     if (!RoleHelper.GetUserPrivileges(HiContext.Current.User.Username).Contains(0x232a) && (HiContext.Current.User.UserRole != UserRole.SiteManager))
     {
         this.ShowMsg("权限不够", false);
     }
     else
     {
         decimal num;
         int     length = 0;
         if (this.txtReCharge.Text.Trim().IndexOf(".") > 0)
         {
             length = this.txtReCharge.Text.Trim().Substring(this.txtReCharge.Text.Trim().IndexOf(".") + 1).Length;
         }
         int userId = int.Parse(this.currentUserId.Value);
         if (!decimal.TryParse(this.txtReCharge.Text.Trim(), out num) || (length > 2))
         {
             this.ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false);
         }
         else if ((num < -10000000M) || (num > 10000000M))
         {
             this.ShowMsg("金额大小必须在正负1000万之间", false);
         }
         else
         {
             Member user = Users.GetUser(userId, false) as Member;
             if ((user == null) || !user.IsOpenBalance)
             {
                 this.ShowMsg("本次充值已失败,该用户不存在或预付款还没有开通", false);
             }
             else
             {
                 decimal           num4   = num + user.Balance;
                 BalanceDetailInfo target = new BalanceDetailInfo();
                 target.UserId    = userId;
                 target.UserName  = user.Username;
                 target.TradeDate = DateTime.Now;
                 target.TradeType = TradeTypes.BackgroundAddmoney;
                 target.Income    = new decimal?(num);
                 target.Balance   = num4;
                 target.Remark    = Globals.HtmlEncode(this.txtRemark.Text.Trim());
                 ValidationResults results = Hishop.Components.Validation.Validation.Validate <BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" });
                 string            msg     = string.Empty;
                 if (!results.IsValid)
                 {
                     foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                     {
                         msg = msg + Formatter.FormatErrorMessage(result.Message);
                     }
                     this.ShowMsg(msg, false);
                 }
                 else if (MemberHelper.AddBalance(target, num))
                 {
                     this.txtReCharge.Text = "";
                     this.ReBind(false);
                 }
             }
         }
     }
 }
        private void btnAddBalance_Click(object sender, System.EventArgs e)
        {
            ManagerHelper.CheckPrivilege(Privilege.MemberReCharge);
            int num = 0;

            if (this.txtReCharge.Text.Trim().IndexOf(".") > 0)
            {
                num = this.txtReCharge.Text.Trim().Substring(this.txtReCharge.Text.Trim().IndexOf(".") + 1).Length;
            }
            int     userId = int.Parse(this.currentUserId.Value);
            decimal num2;

            if (!decimal.TryParse(this.txtReCharge.Text.Trim(), out num2) || num > 2)
            {
                this.ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false);
                return;
            }
            if (num2 < -10000000m || num2 > 10000000m)
            {
                this.ShowMsg("金额大小必须在正负1000万之间", false);
                return;
            }
            Member member = Users.GetUser(userId, false) as Member;

            if (member == null || !member.IsOpenBalance)
            {
                this.ShowMsg("本次充值已失败,该用户不存在或预付款还没有开通", false);
                return;
            }
            decimal           balance           = num2 + member.Balance;
            BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo();

            balanceDetailInfo.UserId    = userId;
            balanceDetailInfo.UserName  = member.Username;
            balanceDetailInfo.TradeDate = System.DateTime.Now;
            balanceDetailInfo.TradeType = TradeTypes.BackgroundAddmoney;
            balanceDetailInfo.Income    = new decimal?(num2);
            balanceDetailInfo.Balance   = balance;
            balanceDetailInfo.Remark    = Globals.HtmlEncode(this.txtRemark.Text.Trim());
            ValidationResults validationResults = Validation.Validate <BalanceDetailInfo>(balanceDetailInfo, new string[]
            {
                "ValBalanceDetail"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMsg(text, false);
                return;
            }
            if (MemberHelper.AddBalance(balanceDetailInfo, num2))
            {
                this.txtReCharge.Text = "";
                this.ReBind(false);
            }
        }
        private void btnAddBalance_Click(object sender, EventArgs e)
        {
            decimal num;
            int     length = 0;

            if (txtReCharge.Text.Trim().IndexOf(".") > 0)
            {
                length = txtReCharge.Text.Trim().Substring(txtReCharge.Text.Trim().IndexOf(".") + 1).Length;
            }
            int userId = int.Parse(currentUserId.Value);

            if (!(decimal.TryParse(txtReCharge.Text.Trim(), out num) && (length <= 2)))
            {
                ShowMsg("本次充值要给当前客户加款的金额只能是数值,且不能超过2位小数", false);
            }
            else if ((num < -10000000M) || (num > 10000000M))
            {
                ShowMsg("金额大小必须在正负1000万之间", false);
            }
            else
            {
                Member user = Users.GetUser(userId, false) as Member;
                if (!((user != null) && user.IsOpenBalance))
                {
                    ShowMsg("本次充值已失败,该用户不存在或预付款还没有开通", false);
                }
                else
                {
                    decimal           num4  = num + user.Balance;
                    BalanceDetailInfo info2 = new BalanceDetailInfo();
                    info2.UserId    = userId;
                    info2.UserName  = user.Username;
                    info2.TradeDate = DateTime.Now;
                    info2.TradeType = TradeTypes.BackgroundAddmoney;
                    info2.Income    = new decimal?(num);
                    info2.Balance   = num4;
                    info2.Remark    = Globals.HtmlEncode(txtRemark.Text.Trim());
                    BalanceDetailInfo target  = info2;
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <BalanceDetailInfo>(target, new string[] { "ValBalanceDetail" });
                    string            msg     = string.Empty;
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            msg = msg + Formatter.FormatErrorMessage(result.Message);
                        }
                        ShowMsg(msg, false);
                    }
                    else if (MemberHelper.AddBalance(target))
                    {
                        txtReCharge.Text = "";
                        ReBind(false);
                    }
                }
            }
        }
Example #4
0
        private void AddMoney(HttpContext context)
        {
            ManagerHelper.CheckPrivilege(Privilege.MemberReCharge);
            decimal parameter  = base.GetParameter(context, "income", default(decimal));
            int     parameter2 = base.GetParameter(context, "userid", 0);
            string  parameter3 = base.GetParameter(context, "remark", true);
            decimal d          = decimal.Parse(parameter.F2ToString("f2"));

            if (parameter > d)
            {
                throw new HidistroAshxException("金额不能超过2位小数");
            }
            if (parameter < -10000000m || parameter > 10000000m)
            {
                throw new HidistroAshxException("金额大小必须在正负1000万之间");
            }
            MemberInfo user = Users.GetUser(parameter2);

            if (user == null)
            {
                throw new HidistroAshxException("该用户不存在");
            }
            decimal           balance           = parameter + user.Balance;
            BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo();

            balanceDetailInfo.UserId    = parameter2;
            balanceDetailInfo.UserName  = user.UserName;
            balanceDetailInfo.TradeDate = DateTime.Now;
            balanceDetailInfo.TradeType = TradeTypes.BackgroundAddmoney;
            balanceDetailInfo.Income    = parameter;
            balanceDetailInfo.Balance   = balance;
            balanceDetailInfo.Remark    = parameter3;
            ValidationResults validationResults = Validation.Validate(balanceDetailInfo, "ValBalanceDetail");
            string            text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult item in (IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(item.Message);
                }
                throw new HidistroAshxException(text);
            }
            if (MemberHelper.AddBalance(balanceDetailInfo, parameter))
            {
                base.ReturnSuccessResult(context, "操作成功", 0, true);
            }
        }
Example #5
0
        private void BtnRefund_Click(object sender, EventArgs e)
        {
            OrderInfo orderInfo = OrderHelper.GetOrderInfo(orderId);

            if (!orderInfo.CheckAction(OrderActions.SELLER_REJECT_REFUND))
            {
                ShowMsg("未付款或不在进行中的订单没有退款操作", false);
            }
            else
            {
                int     length = 0;
                decimal result = 0M;
                if (orderInfo.OrderStatus == OrderStatus.SellerAlreadySent)
                {
                    if (txtRefundTotal.Text.Trim().IndexOf(".") > 0)
                    {
                        length = txtRefundTotal.Text.Trim().Substring(txtRefundTotal.Text.Trim().IndexOf(".") + 1).Length;
                    }
                    if (!(decimal.TryParse(txtRefundTotal.Text.Trim(), out result) && (length <= 2)))
                    {
                        ShowMsg("退款金额只能是数值,且不能超过2位小数", false);
                        return;
                    }
                    if ((result <= 0M) || (result > orderInfo.GetTotal()))
                    {
                        ShowMsg("退款金额必须大于0,小于等于实收款", false);
                        return;
                    }
                }
                if (txtRefundRemark.Text.Length > 200)
                {
                    ShowMsg("退款说明限制在200个字符以内", false);
                }
                else
                {
                    decimal money;
                    Member  user = Users.GetUser(orderInfo.UserId) as Member;
                    if (orderInfo.OrderStatus == OrderStatus.SellerAlreadySent)
                    {
                        money = result;
                    }
                    else if ((orderInfo.GroupBuyId > 0) && (orderInfo.GroupBuyStatus != GroupBuyStatus.Failed))
                    {
                        money = ((decimal)lblTotalPrice.Money) - orderInfo.NeedPrice;
                    }
                    else
                    {
                        money = (decimal)lblTotalPrice.Money;
                    }
                    BalanceDetailInfo info3 = new BalanceDetailInfo();
                    info3.UserId    = orderInfo.UserId;
                    info3.UserName  = orderInfo.Username;
                    info3.TradeDate = DateTime.Now;
                    info3.TradeType = TradeTypes.RefundOrder;
                    info3.Income    = new decimal?(money);
                    info3.Balance   = user.Balance + money;
                    info3.Remark    = "订单退款到预付款";
                    BalanceDetailInfo balanceDetails = info3;
                    if (rdolist.SelectedValue == "2")
                    {
                        if (!user.IsOpenBalance)
                        {
                            ShowMsg("本次退款已失败,该用户的预付款还没有开通", false);
                        }
                        else if (MemberHelper.AddBalance(balanceDetails))
                        {
                            orderInfo.RefundAmount = money;
                            orderInfo.RefundRemark = Globals.HtmlEncode(txtRefundRemark.Text.Trim());
                            orderInfo.FinishDate   = DateTime.Now;
                            orderInfo.RefundStatus = RefundStatus.Refund;
                            if (OrderHelper.RefundOrder(orderInfo))
                            {
                                Messenger.OrderRefund(user, orderInfo.OrderId, money);
                                orderInfo.OnRefund();
                                Page.Response.Redirect(Globals.ApplicationPath + string.Format("/Admin/sales/RefundOrderDetails.aspx?OrderId={0}", orderInfo.OrderId));
                            }
                            else
                            {
                                ShowMsg("退款失败", false);
                            }
                        }
                    }
                    else
                    {
                        orderInfo.RefundAmount = money;
                        orderInfo.RefundRemark = Globals.HtmlEncode(txtRefundRemark.Text.Trim());
                        orderInfo.FinishDate   = DateTime.Now;
                        orderInfo.RefundStatus = RefundStatus.Below;
                        if (OrderHelper.RefundOrder(orderInfo))
                        {
                            Messenger.OrderRefund(user, orderInfo.OrderId, money);
                            orderInfo.OnRefund();
                            Page.Response.Redirect(Globals.ApplicationPath + string.Format("/Admin/sales/RefundOrderDetails.aspx?OrderId={0}", orderInfo.OrderId));
                        }
                        else
                        {
                            ShowMsg("退款失败", false);
                        }
                    }
                }
            }
        }
Example #6
0
        private void BalanceRecharge()
        {
            string userid    = Request["userid"];
            string userdata  = Request["userdata"];
            string timestamp = Request["timestamp"];
            string source    = Request["source"];
            string amount    = Request["amount"];
            string tradeno   = Request["tradeno"];

            if (string.IsNullOrWhiteSpace(userid) ||
                string.IsNullOrWhiteSpace(userdata) ||
                string.IsNullOrWhiteSpace(timestamp) ||
                string.IsNullOrWhiteSpace(source) ||
                string.IsNullOrWhiteSpace(amount) ||
                string.IsNullOrWhiteSpace(tradeno))
            {
                Response.Write("fail,缺少必要参数");
                Response.End();
            }

            string key = ConfigurationManager.AppSettings["Key_CCB"];
            string iv  = ConfigurationManager.AppSettings["IV_CCB"];

            string dataKey     = Cryptographer.DESDecrypt(userdata, key, iv);
            string deUserId    = Cryptographer.DESDecrypt(userid, dataKey, iv);
            string deTimestamp = Cryptographer.DESDecrypt(timestamp, dataKey, iv);
            string deAmount    = Cryptographer.DESDecrypt(amount, dataKey, iv);
            string deTradeno   = Cryptographer.DESDecrypt(tradeno, dataKey, iv);

            if (string.IsNullOrWhiteSpace(dataKey) ||
                string.IsNullOrWhiteSpace(deUserId) ||
                string.IsNullOrWhiteSpace(deTimestamp) ||
                string.IsNullOrWhiteSpace(deAmount) ||
                string.IsNullOrWhiteSpace(deTradeno))
            {
                Response.Write("fail,请求参数无效");
                Response.End();
            }

            DateTime time = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(new TimeSpan(long.Parse(deTimestamp + "0000000")));
            TimeSpan span = DateTime.Now - time;

            if (span.TotalSeconds > 60)
            {
                Response.Write("fail,请求已过期");
                Response.End();
            }

            decimal money = 0;

            if (!decimal.TryParse(deAmount, out money))
            {
                Response.Write("fail,充值金额只能是数值");
                Response.End();
            }

            money = money / 100;
            if (money <= 0 || money > 10000000m)
            {
                Response.Write("fail,充值金额必须大于0且小于等于1000万元");
                Response.End();
            }

            Member member = Users.GetUserByCcbOpenId(deUserId) as Member;

            if (member == null || !member.IsOpenBalance)
            {
                // fail,返回原因
                Response.Write("fail,该用户不存在或还没有开通预付款账户");
                Response.End();
            }

            deTradeno = "CCB" + deTradeno;//加上ccb前缀以区分是建行的充值。
            // 检查交易号是否重复
            if (MemberHelper.IsTradeNoExists(deTradeno))
            {
                Response.Write("fail,交易号已失效");
                Response.End();
            }

            BalanceDetailInfo balanceDetailInfo = new BalanceDetailInfo();

            balanceDetailInfo.UserId    = member.UserId;
            balanceDetailInfo.UserName  = member.Username;
            balanceDetailInfo.TradeDate = DateTime.Now;
            balanceDetailInfo.TradeType = TradeTypes.CcbRecharge;
            balanceDetailInfo.Income    = money;
            balanceDetailInfo.Balance   = money + member.Balance;
            balanceDetailInfo.Remark    = "建行预付款充值";
            balanceDetailInfo.InpourId  = deTradeno;

            // success: 充值成功,将金额充值到用户预存款帐户上
            if (MemberHelper.AddBalance(balanceDetailInfo, money))
            {
                //Response.Redirect("/User/UserDefault.aspx", true);
                Response.Write("success,充值成功");
                Response.End();
            }

            // fail,返回原因
            Response.Write("fail,充值失败,请稍后重试");
            Response.End();
        }