Exemplo n.º 1
0
        /// <summary>
        /// 账户花销(包含写帐户日志)
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public bool AccountExpend(decimal orderId, string ip)
        {
            Bll.Order.TOrderBLL     obll  = new TMM.Service.Bll.Order.TOrderBLL();
            Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL();

            TOrder   o   = obll.Get(orderId);
            MAccount acc = GetByUserId(o.UserId);

            if (acc.Amount >= o.Total)
            {
                AccountLog accLog = new AccountLog()
                {
                    UserId     = o.UserId,
                    OrderId    = o.OrderId,
                    Amount     = -o.Total,
                    AccountWay = (int)AmountWay.Out,
                    Ip         = ip
                };

                albll.Insert(accLog);
                acc.Amount = acc.Amount - o.Total;
                return(Update(acc));
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 账户花销(包含写帐户日志)
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public bool AccountExpend(decimal orderId,string ip)
        {
            Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL();
            Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL();

            TOrder o = obll.Get(orderId);
            MAccount acc = GetByUserId(o.UserId);
            if (acc.Amount >= o.Total)
            {

                AccountLog accLog = new AccountLog()
                {
                    UserId = o.UserId,
                    OrderId = o.OrderId,
                    Amount = -o.Total,
                    AccountWay = (int)AmountWay.Out,
                    Ip = ip
                };

                albll.Insert(accLog);
                acc.Amount = acc.Amount - o.Total;
                return Update(acc);
            }
            return false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 账户充值 for 订单
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="amount">金额</param>
        public bool AddAmount(decimal orderId, decimal amount, string ip, int payway)
        {
            Bll.Order.TOrderBLL     obll  = new TMM.Service.Bll.Order.TOrderBLL();
            Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL();

            TOrder o = obll.Get(orderId);
            //写账户日志
            AccountLog accLog = new AccountLog()
            {
                UserId     = o.UserId,
                OrderId    = o.OrderId,
                Amount     = amount,
                AccountWay = (int)AmountWay.In,
                Ip         = ip,
                PayWay     = payway
            };

            albll.Insert(accLog);
            //更新账户
            MAccount acc = GetByUserId(o.UserId);

            acc.Amount = acc.Amount + amount;
            return(Update(acc));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 链接接收
        /// </summary>
        public void Receive()
        {
            v_oid       = HttpContext.Current.Request["v_oid"];
            v_pstatus   = HttpContext.Current.Request["v_pstatus"];
            v_pstring   = HttpContext.Current.Request["v_pstring"];
            v_pmode     = HttpContext.Current.Request["v_pmode"];
            v_md5str    = HttpContext.Current.Request["v_md5str"];
            v_amount    = HttpContext.Current.Request["v_amount"];
            v_moneytype = HttpContext.Current.Request["v_moneytype"];
            remark1     = HttpContext.Current.Request["remark1"];
            remark2     = HttpContext.Current.Request["remark2"];

            string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

            str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

            MPayLog payrecordinfo = new MPayLog();

            payrecordinfo.PayUrl        = HttpContext.Current.Request.UrlReferrer + "";
            payrecordinfo.OrderId       = decimal.Parse(v_oid);
            payrecordinfo.PayResult     = v_pstatus;
            payrecordinfo.PayMoney      = decimal.Parse(v_amount);
            payrecordinfo.TransactionId = v_oid.ToString();
            payrecordinfo.PayWay        = PayWay;
            payrecordinfo.BackUrl       = HttpContext.Current.Request.Url.ToString();

            TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
            pbll.Insert(payrecordinfo);
            if (str == v_md5str)
            {
                if (v_pstatus.Equals("20"))
                {
                    Service.Bll.Order.TOrderBLL  obll = new TMM.Service.Bll.Order.TOrderBLL();
                    Service.Bll.User.MAccountBLL abll = new TMM.Service.Bll.User.MAccountBLL();
                    TOrder o = obll.Get(payrecordinfo.OrderId);
                    if (o.Status >= 0 && o.Status < 10) //新订单 -- 已付款 之间的过程
                    {
                        abll.AddAmount(payrecordinfo.OrderId, payrecordinfo.PayMoney, Utils.TmmUtils.IPAddress(), this.PayWay);
                        if (abll.AccountExpend(payrecordinfo.OrderId, Utils.TmmUtils.IPAddress()))
                        {
                            //Web.Common.OrderCallBack oCallBack = new MamShare.Mall.Web.Common.OrderCallBack(
                            //    o.UserId, o.OrderId, PayWay, (int)Models.MOrderStateInfo.己付款, "ChinaBank支付");
                            //oCallBack.Update2Paid();
                            //payOkUrl = payOkUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                            //HttpContext.Current.Response.Redirect(payOkUrl);
                            Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack();
                            oCallBack.UserId    = o.UserId;
                            oCallBack.OrderId   = o.OrderId;
                            oCallBack.PayWay    = PayWay;
                            oCallBack.Status    = (int)OrderStatus.IsPaied;
                            oCallBack.PayDetail = "ChinaBank支付";

                            oCallBack.ExecAfterPaid();
                        }
                        else
                        {
                            payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                            payErrorUrl = payErrorUrl.Replace("{2}", "账户余额不足!");
                        }
                    }

                    else
                    {
                        Utils.Log4Net.Error(string.Format("支付接口直接调用回调方法【失败】,跳转到URL:{0}", payOkUrl));
                        payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                        payErrorUrl = payErrorUrl.Replace("{2}", "订单错误!");
                    }
                }
            }
            else
            {
                payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                payErrorUrl = payErrorUrl.Replace("{2}", "校验失败,数据可疑");
                HttpContext.Current.Response.Redirect(payErrorUrl);
                //  HttpContext.Current.Response.Write("校验失败,数据可疑");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// �첽֪ͨ
        /// </summary>
        public void Notify()
        {
            v_oid = HttpContext.Current.Request["v_oid"];
            v_pstatus = HttpContext.Current.Request["v_pstatus"];
            v_pstring = HttpContext.Current.Request["v_pstring"];
            v_pmode = HttpContext.Current.Request["v_pmode"];
            v_md5str = HttpContext.Current.Request["v_md5str"];
            v_amount = HttpContext.Current.Request["v_amount"];
            v_moneytype = HttpContext.Current.Request["v_moneytype"];
            remark1 = HttpContext.Current.Request["remark1"];
            remark2 = HttpContext.Current.Request["remark2"];

            string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

            str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

            MPayLog payrecordinfo = new MPayLog();
            payrecordinfo.PayUrl = HttpContext.Current.Request.UrlReferrer + "";
            payrecordinfo.OrderId = decimal.Parse(v_oid);
            payrecordinfo.PayResult = v_pstatus;
            payrecordinfo.PayMoney = decimal.Parse(v_amount);
            payrecordinfo.TransactionId = v_oid.ToString();
            payrecordinfo.PayWay = PayWay;
            payrecordinfo.BackUrl = HttpContext.Current.Request.Url.ToString();

            TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
            pbll.Insert(payrecordinfo);
            if (str == v_md5str)
            {

                if (v_pstatus.Equals("20"))
                {
                    string domain = HttpContext.Current.Request.Url.Host;
                    //ȷ����m6go�µĶ���
                    if (remark2.ToLower().Contains(domain.ToLower()) == true)
                    {
                        Service.Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL();
                        Service.Bll.User.MAccountBLL abll = new TMM.Service.Bll.User.MAccountBLL();
                        TOrder o = obll.Get(payrecordinfo.OrderId);
                        if (o.Status >= 0 && o.Status < 10) //�¶��� -- �Ѹ��� ֮��Ĺ���
                        {
                            abll.AddAmount(payrecordinfo.OrderId, payrecordinfo.PayMoney,Utils.TmmUtils.IPAddress(),this.PayWay);
                            if (abll.AccountExpend(payrecordinfo.OrderId,Utils.TmmUtils.IPAddress()))
                            {

                                //Web.Common.OrderCallBack oCallBack = new MamShare.Mall.Web.Common.OrderCallBack(
                                //    o.UserId, o.OrderId, PayWay, (int)Models.MOrderStateInfo.������, "ChinaBank֧��");
                                //oCallBack.Update2Paid();
                                //payOkUrl = payOkUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                                //HttpContext.Current.Response.Redirect(payOkUrl);
                                Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack();
                                oCallBack.UserId = o.UserId;
                                oCallBack.OrderId = o.OrderId;
                                oCallBack.PayWay = PayWay;
                                oCallBack.Status = (int)OrderStatus.IsPaied;
                                oCallBack.PayDetail = "ChinaBank֧��";

                                oCallBack.ExecAfterPaid();
                            }
                            else
                            {
                                payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                                payErrorUrl = payErrorUrl.Replace("{2}", "�˻����㣡");
                                HttpContext.Current.Response.Redirect(payErrorUrl);
                            }
                        }
                    }
                    HttpContext.Current.Response.Write("ok");
                }
                else
                    HttpContext.Current.Response.Write("error");
            }
            else
            {
                payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                payErrorUrl = payErrorUrl.Replace("{2}", "У��ʧ��,���ݿ���");
                HttpContext.Current.Response.Write("error");
                // HttpContext.Current.Response.Redirect(payErrorUrl);
                //  HttpContext.Current.Response.Write("У��ʧ��,���ݿ���");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 账户充值 for 订单
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="amount">金额</param>
        public bool AddAmount(decimal orderId, decimal amount,string ip,int payway)
        {
            Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL();
            Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL();

            TOrder o = obll.Get(orderId);
            //写账户日志
            AccountLog accLog = new AccountLog() {
                UserId = o.UserId,
                OrderId = o.OrderId,
                Amount = amount,
                AccountWay = (int)AmountWay.In,
                Ip = ip,
                PayWay = payway
            };
            albll.Insert(accLog);
            //更新账户
            MAccount acc = GetByUserId(o.UserId);
            acc.Amount = acc.Amount + amount;
            return Update(acc);
        }