示例#1
0
        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="startdatetime"></param>
        /// <param name="enddatetime"></param>
        /// <param name="timeday"></param>
        /// <param name="pgaesize"></param>
        /// <returns></returns>
        // GET: Cash
        public ActionResult Index(int?pageIndex, string startdatetime, string enddatetime, int timeday = 0, int pgaesize = 5)
        {
            ViewBag.rndstr = Utils.RndNumChar(10).ToString();

            int OrdIdState = DNTRequest.GetInt("OrdIdState", 0);

            ViewBag.OrdIdState = OrdIdState;
            int     userid    = Utils.checkloginsession();
            int     Counts    = 0;
            int     lostCount = 0;
            int     succCount = 0;
            decimal Totals    = 0.00M;
            decimal lostTotal = 0.00M;
            decimal succTotal = 0.00M;

            B_member_table b  = new B_member_table();
            M_member_table pu = new M_member_table();

            pu = b.GetModel(userid);

            //判断用户是否开户
            if (string.IsNullOrEmpty(pu.UsrCustId))
            {
                string temstr = "/opening_account/Index/" + userid.ToString();
                return(Redirect(temstr));
            }


            new BindCardController().checkbank(pu.UsrCustId);

            if (userid > 0)
            {
                if (Session["retloan1"] != null)
                {
                }
                else
                {
                    UserInfoData     ud      = new UserInfoData();
                    ReQueryBalanceBg retloan = ud.Querybalance(userid);

                    if (retloan.RespCode == "000")
                    {
                        //  string sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where  registerid=" + userid.ToString() + "";

                        //string sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + "  where  registerid=" + userid.ToString() + "";

                        //DbHelperSQL.RunSql(sql);
                        B_usercenter bu = new B_usercenter();
                        bu.DataSync(retloan, userid.ToString());

                        Session["retloan1"] = "updateUserbalance";
                    }
                }
            }


            List <V_UsrBindCardBank> vubc = ef.V_UsrBindCardBank.Where(c => c.registerid == userid && c.OpenBankId != null).ToList();



            //判断用户是否绑定一行卡
            //if (vubc.Count <= 0)
            //{
            //    string temstr = "/BindCard/Index";
            //    return Redirect(temstr);
            //}


            var ListByOwner = ef.hx_td_UserCash.Where(l => l.registerid == userid && l.OpenBankId != null).GroupBy(l => l.registerid)
                              .Select(lg => new
            {
                Owner     = lg.Key,
                Counts    = lg.Count(),
                lostCount = lg.Where(lo => lo.OrdIdState == 0).Count(),
                succCount = lg.Where(su => su.OrdIdState == 3).Count(),
                Totals    = lg.Where(w => w.OrdIdState == 3).Sum(w => w.TransAmt),
                lostTotal = lg.Where(w => w.OrdIdState == 0).Sum(w => w.TransAmt),
                succTotal = lg.Where(w => w.OrdIdState == 3).Sum(w => w.TransAmt),
            });

            foreach (var itc in ListByOwner)
            {
                if (itc.Counts > 0)
                {
                    //Counts = itc.Counts;
                    // Totals = (decimal)itc.Totals;
                    int.TryParse(itc.Counts.ToString(), out Counts);
                    decimal.TryParse(itc.Totals.ToString(), out Totals);
                    int.TryParse(itc.lostCount.ToString(), out lostCount);
                    int.TryParse(itc.succCount.ToString(), out succCount);
                    decimal.TryParse(itc.lostTotal.ToString(), out lostTotal);
                    decimal.TryParse(itc.succTotal.ToString(), out succTotal);
                }
            }
            Expression <Func <hx_td_UserCash, bool> > where = PredicateExtensionses.True <hx_td_UserCash>();
            where = where.And(p => p.UserCashId > 0);
            where = where.And(p => p.registerid == userid);

            where = where.And(p => p.OpenBankId != null);

            if (ViewBag.OrdIdState == 3)
            {
                where = where.And(p => p.OrdIdState == OrdIdState);
            }


            DateTime sdatetime = new DateTime();
            DateTime edatetime = new DateTime();

            if (Utils.IsDate(startdatetime))
            {
                sdatetime = DateTime.Parse(startdatetime);
            }

            if (Utils.IsDate(enddatetime))
            {
                edatetime = DateTime.Parse(enddatetime);
            }

            if (sdatetime > DateTime.Parse("0001-01-01 00:00:00") && edatetime > DateTime.Parse("0001-01-01 00:00:00"))
            {
                where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                DateTime dt2 = Convert.ToDateTime(edatetime.ToString("yyyy-MM-dd") + " 23:59:59");
                where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
            }
            else
            {
                DateTime dt2;
                switch (timeday)
                {
                case 0:

                    break;

                case 1:
                    sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
                    dt2       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
                    break;

                case 30:
                    sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-30);
                    dt2       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0);
                    where     = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0);
                    break;

                case 90:
                    sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-90);
                    dt2       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
                    break;

                default:
                    break;
                }
            }
            var list = ef.hx_td_UserCash.Where(where).OrderByDescending(p => p.UserCashId).ToPagedList(pageIndex ?? 1, pgaesize);



            ViewBag.startdatetime = startdatetime;
            ViewBag.enddatetime   = enddatetime;
            ViewBag.timeday       = timeday;
            ViewBag.pageIndex     = pageIndex;
            ViewBag.Counts        = Counts;
            ViewBag.Totals        = Totals;
            ViewBag.lostCount     = lostCount;

            ViewBag.lostTotal = lostTotal;


            ViewBag.succTotal = succTotal;
            ViewBag.succCount = succCount;

            ViewBag.users       = pu;
            vubc                = BusinessLogicHelper.LeftOne(vubc);
            ViewBag.UsrBindCard = vubc.OrderByDescending(c => c.defCard).ToList();

            ViewBag.Isquick = vubc.Where(c => c.Isquick == 1).Count() > 0;

            ViewBag.GENERAL = DateTime.Now.AddDays(1).ToString("MM月dd日");
            ViewBag.QM      = DateTime.Now.ToString("MM月dd日");
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Cashlist", list));
            }
            return(View(list));
        }
示例#2
0
        /// <summary>
        /// 更新用户第三方余额
        /// </summary>
        /// <param name="usrid"></param>
        /// <returns></returns>
        public ReQueryBalanceBg Querybalance(int usrid)
        {
            M_QueryBalanceBg mbg       = new M_QueryBalanceBg();
            ReQueryBalanceBg retloan   = new ReQueryBalanceBg();
            hx_member_table  mt        = ef.hx_member_table.Where(p => p.registerid == usrid).FirstOrDefault();
            string           UsrCustId = "";

            if (mt != null)
            {
                UsrCustId = mt.UsrCustId;
            }


            if (UsrCustId != null && UsrCustId != "")
            {
                if (UsrCustId.Length > 0)
                {
                    mbg.Version   = "10";
                    mbg.CmdId     = "QueryBalanceBg";
                    mbg.MerCustId = Utils.GetMerCustID();
                    mbg.UsrCustId = UsrCustId;

                    StringBuilder chkVal = new StringBuilder();
                    chkVal.Append(mbg.Version);
                    chkVal.Append(mbg.CmdId);
                    chkVal.Append(mbg.MerCustId);
                    chkVal.Append(mbg.UsrCustId);
                    string chkv = chkVal.ToString();
                    string log  = "更新用户第三方余额";
                    log += "<br>加签chkv字符:" + chkv;

                    //私钥文件的位置(这里是放在了站点的根目录下)
                    string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr();
                    //需要指定提交字符串的长度
                    int           len        = Encoding.UTF8.GetBytes(chkv).Length;
                    StringBuilder sbChkValue = new StringBuilder(256);
                    //加签
                    int str = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue);

                    LogInfo.WriteLog("加签字符:" + str.ToString());

                    mbg.ChkValue = sbChkValue.ToString();

                    log += "<br>提交信息:" + FastJSON.toJOSN(mbg);
                    log += "<br>ChkValue:" + mbg.ChkValue;


                    using (var client = new WebClient())
                    {
                        var values = new NameValueCollection();
                        values.Add("Version", mbg.Version);
                        values.Add("CmdId", mbg.CmdId);
                        values.Add("MerCustId", mbg.MerCustId);
                        values.Add("UsrCustId", mbg.UsrCustId);
                        values.Add("ChkValue", mbg.ChkValue);


                        string url = Utils.GetChinapnrUrl();
                        //同步发送form表单请求
                        byte[] result = client.UploadValues(url, "POST", values);
                        var    retStr = Encoding.UTF8.GetString(result);
                        // Response.Write(retStr);

                        LogInfo.WriteLog(retStr);

                        ReQueryBalanceBg reg = new ReQueryBalanceBg();
                        retloan = (ReQueryBalanceBg)FastJSON.ToObject(retStr, reg);


                        StringBuilder builder = new StringBuilder();
                        builder.Append(retloan.CmdId);
                        builder.Append(retloan.RespCode);
                        //builder.Append(retloan.RespDesc);
                        builder.Append(retloan.MerCustId);
                        builder.Append(retloan.UsrCustId);
                        builder.Append(retloan.AvlBal);
                        builder.Append(retloan.AcctBal);
                        builder.Append(retloan.FrzBal);
                        //  builder.Append(retloan.ChkValue);

                        var msg = builder.ToString();

                        log += "<br>返回参数:" + msg;
                        //验签
                        string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
                        int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue);

                        log += "<br>验签ret:" + ret.ToString();
                        if (ret == 0)
                        {
                            if (retloan.RespCode == "000")
                            {
                                B_usercenter bu = new B_usercenter();
                                bu.DataSync(retloan, UsrCustId, 1);


                                //  Response.Write("账户余额:  " + retloan.AcctBal + "<br>");

                                //  Response.Write("可用余额:  " + retloan.AvlBal + "<br>");

                                //   Response.Write("冻结余额:  " + retloan.FrzBal + "<br>");


                                //  AvlBal.Value = retloan.AvlBal;

                                //  FrzBal.Value = retloan.FrzBal;


                                //  string sql = "update  hx_member_table  set  available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where  UsrCustId='" + UsrCustId + "'";

                                // DbHelperSQL.RunSql(sql);
                            }
                            else
                            {
                                // Response.Write(HttpUtility.UrlDecode(retloan.RespDesc));
                            }
                        }
                    }
                    LogInfo.WriteLog(log);
                }
            }

            return(retloan);
        }