/// <summary> /// 得到一个对象实体 /// </summary> public BCW.Model.Transfer GetTransfer(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,FromId,FromName,ToId,ToName,AcCent,AddTime from tb_Transfer "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; BCW.Model.Transfer model = new BCW.Model.Transfer(); using (SqlDataReader reader = SqlHelper.ExecuteReader(strSql.ToString(), parameters)) { if (reader.HasRows) { reader.Read(); model.ID = reader.GetInt32(0); model.FromId = reader.GetInt32(1); model.FromName = reader.GetString(2); model.ToId = reader.GetInt32(3); model.ToName = reader.GetString(4); model.AcCent = reader.GetInt64(5); model.AddTime = reader.GetDateTime(6); return(model); } else { return(null); } } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(BCW.Model.Transfer model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_Transfer set "); strSql.Append("FromId=@FromId,"); strSql.Append("FromName=@FromName,"); strSql.Append("ToId=@ToId,"); strSql.Append("ToName=@ToName,"); strSql.Append("AcCent=@AcCent,"); strSql.Append("AddTime=@AddTime"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@FromId", SqlDbType.Int, 4), new SqlParameter("@FromName", SqlDbType.NVarChar, 50), new SqlParameter("@ToId", SqlDbType.Int, 4), new SqlParameter("@ToName", SqlDbType.NVarChar, 50), new SqlParameter("@AcCent", SqlDbType.BigInt, 8), new SqlParameter("@AddTime", SqlDbType.DateTime) }; parameters[0].Value = model.ID; parameters[1].Value = model.FromId; parameters[2].Value = model.FromName; parameters[3].Value = model.ToId; parameters[4].Value = model.ToName; parameters[5].Value = model.AcCent; parameters[6].Value = model.AddTime; SqlHelper.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.Model.Transfer model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_Transfer("); strSql.Append("Types,FromId,FromName,ToId,ToName,AcCent,AddTime,zfbNo)"); strSql.Append(" values ("); strSql.Append("@Types,@FromId,@FromName,@ToId,@ToName,@AcCent,@AddTime,@zfbNo)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Types", SqlDbType.Int, 4), new SqlParameter("@FromId", SqlDbType.Int, 4), new SqlParameter("@FromName", SqlDbType.NVarChar, 50), new SqlParameter("@ToId", SqlDbType.Int, 4), new SqlParameter("@ToName", SqlDbType.NVarChar, 50), new SqlParameter("@AcCent", SqlDbType.BigInt, 8), new SqlParameter("@AddTime", SqlDbType.DateTime), new SqlParameter("@zfbNo", SqlDbType.NVarChar, 100) }; parameters[0].Value = model.Types; parameters[1].Value = model.FromId; parameters[2].Value = model.FromName; parameters[3].Value = model.ToId; parameters[4].Value = model.ToName; parameters[5].Value = model.AcCent; parameters[6].Value = model.AddTime; if (model.zfbNo == null) { model.zfbNo = "no"; } parameters[7].Value = model.zfbNo; object obj = SqlHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 取得每页记录 /// </summary> /// <param name="p_pageIndex">当前页</param> /// <param name="p_pageSize">分页大小</param> /// <param name="p_recordCount">返回总记录数</param> /// <param name="strWhere">查询条件</param> /// <returns>IList Transfer</returns> public IList <BCW.Model.Transfer> GetTransfers(int p_pageIndex, int p_pageSize, string strWhere, out int p_recordCount) { IList <BCW.Model.Transfer> listTransfers = new List <BCW.Model.Transfer>(); string sTable = "tb_Transfer"; string sPkey = "id"; string sField = "ID,Types,FromId,FromName,ToId,ToName,AcCent,AddTime"; string sCondition = strWhere; string sOrder = "ID Desc"; int iSCounts = 0; using (SqlDataReader reader = SqlHelper.RunProcedureMe(sTable, sPkey, sField, p_pageIndex, p_pageSize, sCondition, sOrder, iSCounts, out p_recordCount)) { //计算总页数 if (p_recordCount > 0) { int pageCount = BasePage.CalcPageCount(p_recordCount, p_pageSize, ref p_pageIndex); } else { return(listTransfers); } while (reader.Read()) { BCW.Model.Transfer objTransfer = new BCW.Model.Transfer(); objTransfer.ID = reader.GetInt32(0); objTransfer.Types = reader.GetInt32(1); objTransfer.FromId = reader.GetInt32(2); objTransfer.FromName = reader.GetString(3); objTransfer.ToId = reader.GetInt32(4); objTransfer.ToName = reader.GetString(5); objTransfer.AcCent = reader.GetInt64(6); objTransfer.AddTime = reader.GetDateTime(7); listTransfers.Add(objTransfer); } } return(listTransfers); }
/// <summary> /// 处理环迅接口返回数据 /// </summary> /// <param name="Resultstr">返回字符串</param> /// <param name="isTips">是否提示处理状态</param> public static void updateorder(string Resultstr, bool isTips) { if (Resultstr != "") { #region 返回处理 Resultstr = Resultstr.Replace("<![CDATA[", "").Replace("]]>", ""); string MerBillNostr = ""; //单号 string CurrencyType = ""; //币种 decimal Amount = 0; //订单金额 string date = ""; //订单日期 string Status = ""; //交易状态 string RspCode = ""; //返回码 string Attach = ""; //商户数据包 string IpsBillNo = ""; //IPS订单号 string IpsTradeNo = ""; //交易流水号 string BankBillNo = ""; //银行订单号 #region 获取订单号 MerBillNostr //获取订单号 string strpattern = @"<MerBillNo>([\s\S]{1,20})</MerBillNo>";//单号 Match mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { MerBillNostr = mtitle.Groups[1].Value; } #endregion if (MerBillNostr != "") { #region 获取订单金额 Amount strpattern = @"<Amount>([\s\S]{1,10})</Amount>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { Amount = decimal.Parse(mtitle.Groups[1].Value); } #endregion #region 获取订单日期 date strpattern = @"<date>([\s\S]{1,10})</date>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { date = mtitle.Groups[1].Value; } #endregion #region 获取支付币种 CurrencyType strpattern = @"<CurrencyType>([\s\S]{1,10})</CurrencyType>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { CurrencyType = mtitle.Groups[1].Value; } #endregion #region 交易状态 Status //Y#交易成功;N#交易失败;P#交易处理中 strpattern = @"<Status>([\s\S]{1,10})</Status>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { Status = mtitle.Groups[1].Value; } #endregion #region 商户数据包 Attach strpattern = @"<Attach>([\s\S]*)</Attach>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { Attach = mtitle.Groups[1].Value; } #endregion #region 商户数据包 Attach strpattern = @"<BankBillNo>([\s\S]*)</BankBillNo>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { BankBillNo = mtitle.Groups[1].Value; } #endregion #region 返回码 RspCode strpattern = @"<RspCode>([\s\S]*)</RspCode>"; mtitle = Regex.Match(Resultstr, strpattern, RegexOptions.IgnoreCase); if (mtitle.Success) { RspCode = mtitle.Groups[1].Value; } #endregion #region 充值到账户 try { Attach = BCW.Common.DESEncrypt.Decrypt(Attach, BCW.IPSPay.IPSPayMent.IpsKey); } catch { } if (Attach.Split(',').Length == 5) { int id = 0; try { id = int.Parse(Attach.Split(',')[0].ToString()); } catch { } if (id != 0) { ///shop开头的订单,是属于商城的订单,无任何字符开头的订单,是属于网上充值的订单 int typeMer = 0;//订单类型0默认订单 1商城订单 if (MerBillNostr.StartsWith("Shop")) { typeMer = 1; } else if (MerBillNostr.Contains("AGENC")) { typeMer = 2; } switch (typeMer) { case 2: { #region 更新到中介充值数据库 BCW.Model.Payrmb model = new BCW.BLL.Payrmb().GetPayrmb(id); if (model != null && model.State == 0) { //对比订单 if (model.MerBillNo == MerBillNostr) { ////对比日期 //if (model.AddTime.ToString("yyyyMMdd") == date) //{ //对比金额 if (model.Amount.ToString("0.00") == Amount.ToString("0.00")) { //以上都对,则更新数据库 if (Status == "Y") { //成功 model.State = 1; } else { //错误 model.State = 2; } model.GatewayType = CurrencyType; model.Attach = Attach; model.BankCode = Attach.Split(',')[3].ToString(); model.ProductType = "1"; new BCW.BLL.Payrmb().Update_ips(model); #region 中介过币 //开始过币 string toname = new BCW.BLL.User().GetUsName(model.UsID); string Coin = ub.GetSub("FinanceSZXTar", xmlPath); long uGoid = long.Parse((model.Amount * decimal.Parse(Coin)).ToString("0")); string[] sArray = Regex.Split(MerBillNostr, "AGENC", RegexOptions.IgnoreCase); int Cid = int.Parse(sArray[0]); string mename = new BCW.BLL.User().GetUsName(Cid); new BCW.BLL.User().UpdateiGold(Cid, mename, -uGoid, "过户给ID" + model.UsID + "(中介专用网充链接)"); new BCW.BLL.User().UpdateiGold(model.UsID, toname, uGoid, "来自ID" + Cid + "过户(中介专用网充链接)"); BCW.Model.Transfer T_model = new BCW.Model.Transfer(); T_model.Types = 0; T_model.FromId = Cid; T_model.FromName = mename; T_model.ToId = model.UsID; T_model.ToName = toname; T_model.AcCent = uGoid; T_model.AddTime = DateTime.Now; T_model.zfbNo = MerBillNostr; new BCW.BLL.Transfer().Add(T_model); //系统内线消息 new BCW.BLL.Guest().Add(model.UsID, toname, "[url=/bbs/uinfo.aspx?uid=" + Cid + "]" + mename + "[/url]过户" + uGoid + "" + ub.Get("SiteBz") + "给您(网," + MerBillNostr + ")"); new BCW.BLL.Guest().Add(Cid, mename, "您过户" + uGoid + "" + ub.Get("SiteBz") + "给[url=/bbs/uinfo.aspx?uid=" + model.UsID + "] " + toname + " [/url]成功(网," + MerBillNostr + ")"); #endregion if (isTips) { new BCW.BLL.Guest().Add(10086, "客服", "ID:" + model.UsID + "商城购物支付,订单支付成功,单号:" + model.MerBillNo); Utils.Success("充值成功", "充值成功", Attach.Split(',')[4].ToString(), "1"); } } //} } } else { if (isTips) { Utils.Success("订单已处理", "订单已处理", Attach.Split(',')[4].ToString(), "1"); } } #endregion } break; case 1: { #region 更新商城订单 BCW.Model.Shopkeep model = new BCW.BLL.Shopkeep().GetShopkeep(id); if (model != null && model.State == 0) { //对比订单 if (model.MerBillNo == MerBillNostr) { ////对比日期 //if (model.AddTime.ToString("yyyyMMdd") == date) //{ //对比金额 if (model.Amount.ToString("0.00") == Amount.ToString("0.00")) { //以上都对,则更新数据库 if (Status == "Y") { //成功 model.State = 1; } else { //错误 model.State = 2; } model.GatewayType = CurrencyType; model.Attach = Attach; model.BankCode = Attach.Split(',')[3].ToString(); model.ProductType = "1"; new BCW.BLL.Shopkeep().Update_ips(model); string Coin = model.Para; long uGoid = long.Parse((model.Total * decimal.Parse(Coin)).ToString("0")); //充值酷币 new BCW.BLL.User().UpdateiGold(model.UsID, new BCW.BLL.User().GetUsName(model.UsID), uGoid, "商品" + model.Title + "(" + model.GiftId + ")支付成功,订单号:" + MerBillNostr); new BCW.BLL.Guest().Add(model.UsID, new BCW.BLL.User().GetUsName(model.UsID), "支付订单:" + model.MerBillNo + "成功[url=" + Attach.Split(',')[4].ToString() + "]查看[/url]"); if (isTips) { new BCW.BLL.Guest().Add(10086, "客服", "ID:" + model.UsID + "商城购物支付,订单支付成功,单号:" + model.MerBillNo); Utils.Success("支付成功", "支付成功", Attach.Split(',')[4].ToString(), "1"); } } //} } } else { if (isTips) { Utils.Success("订单已处理", "订单已处理", Attach.Split(',')[4].ToString(), "1"); } } #endregion } break; case 0: { #region 更新到网上支付数据库 BCW.Model.Payrmb model = new BCW.BLL.Payrmb().GetPayrmb(id); if (model != null && model.State == 0) { //对比订单 if (model.MerBillNo == MerBillNostr) { ////对比日期 //if (model.AddTime.ToString("yyyyMMdd") == date) //{ //对比金额 if (model.Amount.ToString("0.00") == Amount.ToString("0.00")) { //以上都对,则更新数据库 if (Status == "Y") { //成功 model.State = 1; } else { //错误 model.State = 2; } model.GatewayType = CurrencyType; model.Attach = Attach; model.BankCode = Attach.Split(',')[3].ToString(); model.ProductType = "1"; new BCW.BLL.Payrmb().Update_ips(model); if (ub.GetSub("FinanceSZXType", xmlPath) == "0") { string Coin = ub.GetSub("FinanceSZXTar", xmlPath); long uGoid = long.Parse((model.Amount * decimal.Parse(Coin)).ToString("0")); //充值酷币 new BCW.BLL.User().UpdateiGold(model.UsID, new BCW.BLL.User().GetUsName(model.UsID), uGoid, "网上支付成功,订单号:" + MerBillNostr); new BCW.BLL.Guest().Add(model.UsID, new BCW.BLL.User().GetUsName(model.UsID), "网上支付订单:" + model.MerBillNo + "成功[url=" + Attach.Split(',')[4].ToString() + "]查看[/url]"); //点值抽奖 try { new BCW.Draw.draw().Addjfbychongzhi(model.UsID, new BCW.BLL.User().GetUsName(model.UsID), model.Amount, "网上充值" + model.Amount + "奖励"); } catch { } } else { } if (isTips) { new BCW.BLL.Guest().Add(10086, "客服", "ID:" + model.UsID + "商城购物支付,订单支付成功,单号:" + model.MerBillNo); Utils.Success("充值成功", "充值成功", Attach.Split(',')[4].ToString(), "1"); } } //} } } else { if (isTips) { Utils.Success("订单已处理", "订单已处理", Attach.Split(',')[4].ToString(), "1"); } } #endregion } break; } } } #endregion } #endregion } else { //Utils.Success("数据错误", "提交数据错误", "Default.aspx", "1"); } }