예제 #1
0
        /// <summary>
        /// 提现成功
        /// </summary>
        /// <param name="point"></param>
        /// <param name="type"></param>
        public void ReduceUserPoint3(string usrename, decimal money, string type)
        {
            Beauty.Core.PaginationInfo paging = new Core.PaginationInfo();
            IList <User> users = iuser.Get(null, usrename, null, null, null, null, null, null, null, null, 1, 0, null, out paging);

            if (users != null && users.Count > 0)
            {
                User user = users[0];
                user.Balance -= money;
                iuser.Update(user);

                MoneyRecord moneyrecord = new MoneyRecord
                {
                    ID       = Guid.NewGuid(),
                    Money    = 0,
                    Statues  = 1,
                    Username = user.Username,
                    Balance  = user.Point - user.FreezePoint,
                    Type     = type
                };

                imoney.Create(moneyrecord);
            }
        }
예제 #2
0
        public ActionResult ProcessTrxReturn()
        {
            SortedDictionary <string, string> sPara = GetRequestGet();
            PaginationInfo paging = new PaginationInfo();

            if (sPara.Count > 0)//判断是否有带返回参数
            {
                Notify aliNotify    = new Notify();
                bool   verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]);

                if (verifyResult)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码


                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表

                    //商户订单号

                    string out_trade_no = Request.QueryString["out_trade_no"];

                    //支付宝交易号

                    string trade_no = Request.QueryString["trade_no"];

                    //交易状态
                    string trade_status = Request.QueryString["trade_status"];


                    if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")
                    {
                        //判断该笔订单是否在商户网站中已经做过处理
                        //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
                        //如果有做过处理,不执行商户的业务程序

                        MoneyRecord moneyrecord = imoney.Get(Guid.Parse(out_trade_no));
                        if (moneyrecord != null && !moneyrecord.Balance.HasValue)
                        {
                            Setting setting     = isetting.Get(Guid.Parse("2AADE1C6-59BE-4B0E-927C-7B28BFC8C397"));
                            Setting backsetting = isetting.Get(Guid.Parse("3A1FC752-0700-492B-A6C6-A5460271DC91"));
                            User    user        = iuser.Get(null, moneyrecord.Username, null, null, null, null, null, null, null, null, null, 0, null, out paging)[0];
                            user.Point          = user.Point + decimal.Round(decimal.Parse(setting.Value) * moneyrecord.Money, 2);
                            moneyrecord.Balance = user.Point - user.FreezePoint;


                            iuser.Update(user);
                            imoney.Update(moneyrecord);
                            WriteLog(user.Username + " 充值" + moneyrecord.Money.ToString());
                            if (!string.IsNullOrEmpty(user.Refer))
                            {
                                IList <User> referusers = iuser.Get(null, user.Refer, null, null, null, null, null, null, null, null, null, 0, null, out paging);
                                if (referusers != null && referusers.Count > 0)
                                {
                                    User    referuser = referusers[0];
                                    decimal addpoint  = decimal.Parse(setting.Value) * moneyrecord.Money * decimal.Parse(backsetting.Value);
                                    addpoint        = decimal.Round(addpoint, 2);
                                    referuser.Point = referuser.Point + addpoint;
                                    WriteLog(referuser.Username + " 获得返利积分" + (decimal.Parse(setting.Value) * moneyrecord.Money * decimal.Parse(backsetting.Value)).ToString());
                                    iuser.Update(referuser);

                                    MoneyRecord money = new MoneyRecord
                                    {
                                        ID       = Guid.NewGuid(),
                                        Money    = 0,
                                        Statues  = 1,
                                        Username = referuser.Username,
                                        Balance  = referuser.Point - referuser.FreezePoint,
                                        Type     = "获得返利积分:" + addpoint.ToString()
                                    };

                                    imoney.Create(money);
                                }
                            }

                            ViewBag.Money = moneyrecord.Money.ToString();
                            ViewBag.Msg   = "成功";
                            ViewBag.Type  = "OK";
                        }
                        else
                        {
                            ViewBag.Msg  = "非法操作";
                            ViewBag.Type = "Fail";
                        }
                    }
                    else
                    {
                        ViewBag.Msg  = "非法操作";
                        ViewBag.Type = "Fail";
                    }



                    //打印页面
                    //Response.Write("验证成功<br />");

                    //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——

                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
                else//验证失败
                {
                    //Response.Write("验证失败");

                    ViewBag.Msg  = "非法操作";
                    ViewBag.Type = "Fail";
                }
            }
            else
            {
                //Response.Write("无返回参数");
                ViewBag.Msg  = "非法操作";
                ViewBag.Type = "Fail";
            }

            return(View());
        }