public ActionResult DiscountTicketInformation(int ticketId)
        {
            ViewData["key"] = ticketId;
            var model = db.TicketDiscount.Where(item => item.TicketID == ticketId).FirstOrDefault();

            ViewData["Pro"]  = StaticDictiory.GetProDataSource();
            ViewData["City"] = StaticDictiory.GetCityDataSource(model.ProvinceID);
            ViewData["Bank"] = StaticDictiory.GetBankDataSource(model.BankType);
            #region 年利率
            //票面金额-成交价格=票面金额*((年息/100)/360)*实际天数
            Decimal interest = (Decimal)(model.TicketPrice - model.BidPrice);                             //利息
            int     resDayca = RestDays(model.TicketEndTime);                                             //实际天数
            Decimal ratca    = resDayca <= 0 ? 0 : interest * 360 * 100 / (model.TicketPrice * resDayca); //例如3.17%
            ViewData["Rate"] = ratca.ToString("N2").Replace(",", "");
            #endregion
            AgencyTrade atmodel = new AgencyTrade();
            atmodel.ticketDiscount = model;

            #region MyRegion
            EndorseInfo.UserAccountInfo uif = new EndorseInfo.UserAccountInfo(model.UserID.ToString()); //持票人的虚拟账户信息
            EndorseInfo.UserAccountInfo zf  = new EndorseInfo.UserAccountInfo(model.BidId.ToString());  //资金方的虚拟账户信息
            List <TCPJW_BATradingSystemCITIC.AccountBalance> fablist =
                TCPJW_BATradingSystemCITIC.CITICYQZL.GetAccountBalance(zf.Account);
            string alertsel = string.Empty;
            if (fablist == null || fablist.Count == 0)
            {
                atmodel.PayAccount = "可用余额:0元   ";
            }


            List <TCPJW_BATradingSystemCITIC.AccountBalance> sablist =
                TCPJW_BATradingSystemCITIC.CITICYQZL.GetAccountBalance(uif.Account);
            if (sablist == null || sablist.Count == 0)
            {
                atmodel.GetAccount = "可用余额:0元   ";
            }
            foreach (var item in fablist)
            {
                atmodel.PayAccount += " 可用余额:" + item.Kyamt + "元 ";
            }
            foreach (var item in sablist)
            {
                atmodel.GetAccount += " 可用余额:" + item.Kyamt + "元";
            }

            Random ro   = new Random();
            int    rand = ro.Next(100, 999);//返回三位随机数
            atmodel.ZzMemo = string.Format("DP{0}{1}", DateTime.Now.ToString("yyMMdd"), rand.ToString());
            #endregion

            return(PartialView("DiscountTicketInformation", atmodel));
        }
        public ActionResult AjaxQueryBalance()
        {
            string         ticketID = System.Web.HttpContext.Current.Request.Form["TicketID"];
            TicketDiscount model    = db.TicketDiscount.Where(t => t.TicketID == Convert.ToInt32(ticketID)).FirstOrDefault();

            #region MyRegion
            List <GoldAccount> goldAccountList = new List <GoldAccount>();
            goldAccountList = GoldAccount.GetUserGoldAccountByUsercjrecvaccno(model.UserID, model.ToAccount);
            if (goldAccountList.Count == 0)
            {
                return(Json(new { success = false, Message = "请确保出金信息无误", Tips = "", Status = 0 }));
            }

            EndorseInfo.UserAccountInfo uif = new EndorseInfo.UserAccountInfo(model.UserID.ToString()); //持票人的虚拟账户信息
            EndorseInfo.UserAccountInfo zf  = new EndorseInfo.UserAccountInfo(model.BidId.ToString());  //资金方的虚拟账户信息

            //string queryString = e.Parameters;//button按钮参数
            string subaccno    = zf.Account;                                                         //"3110510001051004035";//资方 zf.Account
            string srecvaccnm  = zf.ComName;                                                         //"银承互联网金融信息服务(南京)有限公司";//zf.ComName
            string recvaccno   = uif.Account;                                                        //"3110510001051004033";//持票人uif.Account
            string recvaccnm   = uif.ComName;                                                        //"南京赛旭投资管理有限公司";//uif.ComName
            string cjrecvaccno = goldAccountList[0].CjrecvAccNo;                                     // "8110501013300082823";//出金账号 goldAccountList[0].CjrecvAccNo
            string cjrecvaccnm = goldAccountList[0].RecvAccNm;                                       //"银承互联网金融信息服务(南京)有限公司";//出金账号名称
            string tranamt     = Convert.ToDecimal(model.BidPrice).ToString("N2").Replace(",", "");; //"0.01";
            //string zzmemo = followID;
            string cjsamebank   = goldAccountList[0].CjsameBank == true ? "1" : "0";
            string cjrecvtgfi   = goldAccountList[0].CjrecvTgfi;
            string cjrecvbanknm = goldAccountList[0].CjrecvBankNm;
            string cjmemo       = "";
            string cjpreflg     = "0";
            string cjpredate    = "";
            string cjpretime    = "";
            #endregion

            #region MyRegion
            try
            {
                string cxcid = TCPJW_CITICPROJECT.Common.GetCiticPlatformOfGoldByTid(Convert.ToInt32(ticketID)).Pf_clientid.ToString();
                if (string.IsNullOrEmpty(cxcid))
                {
                    //if (log.IsInfoEnabled) log.InfoFormat("您还没有执行打款,没有交易状态,出金流水编号:{0}", cxcid);
                    return(Json(new { Tips = "您还没有执行打款,没有交易状态" }));
                }
            }
            catch (Exception ex)
            {
                //if (log.IsFatalEnabled) log.FatalFormat("打款未成功,无法查询最新余额,异常错误:{0}", ex.Message);
                return(Json(new { Tips = "打款未成功,无法查询最新余额" }));
            }
            try
            {
                List <TCPJW_BATradingSystemCITIC.AccountBalance> fablist = new List <AccountBalance>();
                fablist = TCPJW_BATradingSystemCITIC.CITICYQZL.GetAccountBalance(subaccno);
                string alertsel = string.Empty;
                if (fablist == null || fablist.Count == 0)
                {
                    //grid.JSProperties["cpScript"] = "alert('付款账号【" + subaccno + "】无余额信息');";
                    return(Json(new { Tips = "付款账号【" + subaccno + "】无余额信息" }));
                }
                List <TCPJW_BATradingSystemCITIC.AccountBalance> sablist = new List <AccountBalance>();
                sablist = TCPJW_BATradingSystemCITIC.CITICYQZL.GetAccountBalance(recvaccno);
                if (sablist == null || sablist.Count == 0)
                {
                    //grid.JSProperties["cpScript"] = "alert('收款账号【" + subaccno + "】无余额信息');";
                    return(Json(new { Tips = "收款账号【" + subaccno + "】无余额信息" }));
                }
                foreach (var item in fablist)
                {
                    alertsel += "付款账号【" + subaccno + "】,  可用余额:" + item.Kyamt + "元 \r\n";
                }
                foreach (var item in sablist)
                {
                    alertsel += "收款账号【" + recvaccno + "】,  可用余额:" + item.Kyamt + "元 \r\n";
                }

                return(Json(new { Tips = alertsel }));
            }
            catch (Exception ex)
            {
                // if (log.IsFatalEnabled) log.FatalFormat("查询最新余额出现异常,付款账号:{0},收款账号:{1},异常错误:{2}", subaccno, recvaccno, ex.Message);
                return(Json(new { Tips = "查询最新余额出现异常" }));
            }
            #endregion
            return(Json(new { Tips = "" }));
        }
        public ActionResult AjaxUotGold()
        {
            string         ticketID = System.Web.HttpContext.Current.Request.Form["TicketID"];
            string         followID = System.Web.HttpContext.Current.Request.Form["FollowID"];
            TicketDiscount model    = db.TicketDiscount.Where(t => t.TicketID == Convert.ToInt32(ticketID)).FirstOrDefault();

            #region MyRegion
            string             dkstatus        = string.Empty;
            List <GoldAccount> goldAccountList = GoldAccount.GetUserGoldAccountByUsercjrecvaccno(model.UserID, model.ToAccount);
            if (goldAccountList.Count == 0)
            {
                return(Json(new { success = false, Message = "请确保出金信息无误", Tips = "", Status = 0 }));
            }

            EndorseInfo.UserAccountInfo uif = new EndorseInfo.UserAccountInfo(model.UserID.ToString()); //持票人的虚拟账户信息
            EndorseInfo.UserAccountInfo zf  = new EndorseInfo.UserAccountInfo(model.BidId.ToString());  //资金方的虚拟账户信息

            //string queryString = e.Parameters;//button按钮参数
            string subaccno     = zf.Account;                                                         //"3110510001051004035";//资方 zf.Account
            string srecvaccnm   = zf.ComName;                                                         //"银承互联网金融信息服务(南京)有限公司";//zf.ComName
            string recvaccno    = uif.Account;                                                        //"3110510001051004033";//持票人uif.Account
            string recvaccnm    = uif.ComName;                                                        //"南京赛旭投资管理有限公司";//uif.ComName
            string cjrecvaccno  = goldAccountList[0].CjrecvAccNo;                                     // "8110501013300082823";//出金账号 goldAccountList[0].CjrecvAccNo
            string cjrecvaccnm  = goldAccountList[0].RecvAccNm;                                       //"银承互联网金融信息服务(南京)有限公司";//出金账号名称
            string tranamt      = Convert.ToDecimal(model.BidPrice).ToString("N2").Replace(",", "");; //"0.01";
            string zzmemo       = followID;
            string cjsamebank   = goldAccountList[0].CjsameBank == true ? "1" : "0";
            string cjrecvtgfi   = goldAccountList[0].CjrecvTgfi;
            string cjrecvbanknm = goldAccountList[0].CjrecvBankNm;
            string cjmemo       = "";
            string cjpreflg     = "0";
            string cjpredate    = "";
            string cjpretime    = "";
            #endregion

            //判断出金账户是否存在
            if (goldAccountList.Count > 0)
            {
                //判断虚拟账户里面的企业名称跟出金账户的企业名称是否一致
                if (uif.ComName != goldAccountList[0].RecvAccNm)
                {
                    return(Json(new { Tips = "出金账户与虚拟账户中的企业名称不一致", Status = 0 }));
                }
            }
            else
            {
                return(Json(new { Tips = "出金账户不存在", Status = 0 }));
            }
            #region 解冻出金
            CiticPlatformOfGold cpogmodel = new CiticPlatformOfGold();
            cpogmodel = TCPJW_CITICPROJECT.Common.GetCiticPlatformOfGoldByTid(model.TicketID);
            if (cpogmodel != null)
            {
                if (cpogmodel.Pf_id > 0)
                {
                    this.UpdateModel(model);//修改模型必须在此之后
                    model.AuditorName = "AAAAAAA";
                    db.SaveChanges();
                    //yybutton.Enabled = false;
                    //cjbutton.Enabled = false;
                    return(Json(new { Tips = "汇票编号【" + model.TicketID + "】已进行资金打款,无法重复打款!", Status = 1 }));
                }
            }

            //返回格式:状态$$$$状态值
            string   clientid    = "PCJ" + GetRandomNm(); //DateTime.Now.ToString("yyyyMMddHHmmssfff"); //wy:平台出金的客户流水号主要为了后面查询交易状态
            string   cid         = clientid;
            string[] citicstatus = TCPJW_BATradingSystemCITIC.CITICYQZL.OpThrawoutthegold(subaccno, srecvaccnm, recvaccno, recvaccnm, new Encrypt_TCPJW().Encrypto(cjrecvaccno), new Encrypt_TCPJW().Encrypto(cjrecvaccnm), tranamt, zzmemo,
                                                                                          cjsamebank, cjrecvtgfi, cjrecvbanknm, cjmemo, cjpreflg, cjpredate, cjpretime, clientid, model.TicketID).Split(new string[] { "$$$$" }, StringSplitOptions.None);

            #endregion
            if (citicstatus.Count() > 1)
            {
                dkstatus = citicstatus[0];
                if (dkstatus == "AAAAAAE" || dkstatus == "AAAAAAA" ||
                    dkstatus == "AAAAAAB" || dkstatus == "AAAAAAC" || dkstatus == "AAAAAAD")
                {
                    UpdateModel(model);//修改模型必须在此之后
                    model.AuditorName = "AAAAAAA";
                    db.SaveChanges();
                    //yybutton.Enabled = false;
                    //cjbutton.Enabled = false;
                    //cjbutton.Visible = true;
                    //cxbutton.Enabled = true;
                    return(Json(new { Tips = citicstatus[1], Status = 2 }));
                }
                return(Json(new { Tips = citicstatus[1], Status = 0 }));
            }

            return(Json(new { Tips = "", Status = 0 }));
        }