//执行新增交易 public static bool ExecInsertTrans(CitizenOrder co, Gs_f_Access gf) { //insert into CITIZENORDER //insert into gs_f_access StringBuilder sql = new StringBuilder(); sql.Append(" begin "); #region insert into CITIZENORDER sql.Append(@"insert into CITIZENORDER("); sql.Append("OUTORDERNO,NAME,ICNO,PRODUCTID,BARCODE,TRANSDATE)"); sql.Append(" values("); sql.Append(string.Format(@"'{0}',N'{1}','{2}',{3},'{4}','{5}'", co.OUTORDERNO, co.NAME, co.ICNO, co.PRODUCTID, co.BARCODE, co.TRANSDATE)); sql.Append(");"); #endregion #region insert into GS_F_ACCESS_CITIZENCARD sql.Append(@"insert into GS_F_ACCESS_CITIZENCARD("); sql.Append("ndealid,sbarcode,nticketid,nstatus,sselldate,stickettype,STERMINAL,NINCOUNT,"); sql.Append("NOUTCOUNT,NENTRANCECOUNT,NALLPARKCOUNT,DVSTARTDATE,DVENDDATE,NISREFUND,NISREPRINT,"); sql.Append("NISDELAY,NTYPE,NSALDAYS,NTIMES,NPRICE,NIVALIDDAYSCOUNT,NPRINTPRICE)"); sql.Append(" values("); sql.Append(string.Format(@"'{0}','{1}',{2},{3},to_date('{4}','YYYY-MM-DD HH24:MI:SS'),'{5}','{6}',{7},", gf.NDEALID, gf.SBARCODE, Convert.ToInt32(gf.NTICKETID), gf.NSTATUS, gf.SSELLDATE, gf.STICKETTYPE, gf.STERMINAL, gf.NINCOUNT)); sql.Append(string.Format(@"{0},{1},{2},to_date('{3}','yyyy-MM-dd'),to_date('{4}','yyyy-MM-dd'),{5},{6},", gf.NOUTCOUNT, gf.NENTRANCECOUNT, gf.NALLPARKCOUNT, gf.DVSTARTDATE, gf.DVENDDATE, gf.NISREFUND, gf.NISREPRINT)); sql.Append(string.Format(@"{0},{1},{2},{3},{4},{5},{6}", gf.NISDELAY, gf.NTYPE, gf.NSALDAYS, gf.NTIMES, gf.NPRICE, gf.NIVALIDDAYSCOUNT, gf.NPRINTPRICE)); sql.Append(");"); #endregion sql.Append(" end;"); OracleHelper db = new OracleHelper(); return(db.ExecSQLTransaction(sql.ToString()) > 0?true:false); }
//执行Update Barcode交易 public static bool ExecUpdateTrans(CitizenOrder co, Gs_f_Access g) { //insert into CITIZENORDER //update GS_F_ACCESS_CITIZENCARD StringBuilder sql = new StringBuilder(); sql.Append(" begin "); #region insert into CITIZENORDER sql.Append(@"insert into CITIZENORDER("); sql.Append("OUTORDERNO,NAME,ICNO,PRODUCTID,BARCODE,TRANSDATE)"); sql.Append(" values("); sql.Append(string.Format(@"'{0}',N'{1}','{2}',{3},'{4}','{5}'", co.OUTORDERNO, co.NAME, co.ICNO, co.PRODUCTID, co.BARCODE, co.TRANSDATE)); sql.Append(");"); #endregion //update GS_F_ACCESS_CITIZENCARD set sbarcode='140101112236' where SBARCODE='151018100368' string last_Barcode = OrderService.GetLastBarcode(co.OUTORDERNO); if (last_Barcode == "" || string.IsNullOrEmpty(last_Barcode)) { throw new Exception("市民卡订单号异常,此单中断,请市民卡确认!"); } #region update access sql.Append(" update GS_F_ACCESS_CITIZENCARD "); sql.AppendFormat(" set sbarcode = '{0}'", co.BARCODE); sql.AppendFormat(" where SBARCODE = '{0}'", last_Barcode); //订单号 sql.Append(";"); #endregion sql.Append(" end;"); OracleHelper db = new OracleHelper(); return(db.ExecSQLTransaction(sql.ToString()) > 0 ? true : false); }
/// <summary> /// 获取门票基础信息,构造过闸检票数据 /// </summary> /// <param name="co">The co.</param> /// <returns></returns> /// <remarks>Created At Time: [ 2017-2-22 1:32 ], By User:lishuai, On Machine:Brian-NB</remarks> public static Gs_f_Access GetAccess(CitizenOrder co) { //根据票种co.PRODUCTID获取Access相关数据 Gs_f_Access gs_f_access = new Gs_f_Access(); gs_f_access.NTICKETID = co.PRODUCTID.ToString(); gs_f_access.NDEALID = co.OUTORDERNO; gs_f_access.SBARCODE = co.BARCODE; gs_f_access.SSELLDATE = DateTime.Now.ToString("G"); gs_f_access.STERMINAL = TerminalID; gs_f_access.NINCOUNT = 0; //默认是没有进入 // gs_f_access.NTYPE = 1; gs_f_access.NSTATUS = 0; gs_f_access.NISDELAY = 0; gs_f_access.NISREFUND = 0; gs_f_access.NISREPRINT = 0; gs_f_access.NOUTCOUNT = 0; gs_f_access.NIVALIDDAYSCOUNT = 1; gs_f_access.DVSTARTDATE = DateTime.Now.ToString("d"); gs_f_access.DVENDDATE = DateTime.Now.ToString("d"); DataSet ds_base = new DataSet(); ds_base = GetTicketBaseInfo(co.PRODUCTID); if (ds_base == null) { return(null); } else { gs_f_access.NPRICE = Convert.ToDecimal(ds_base.Tables[0].Rows[0]["NGENERALPRICE"]); gs_f_access.NPRINTPRICE = Convert.ToDecimal(ds_base.Tables[0].Rows[0]["NPRINTPRICE"]); gs_f_access.NSALDAYS = 0; gs_f_access.STICKETTYPE = ds_base.Tables[0].Rows[0]["NTICKETTYPE"].ToString(); gs_f_access.NTIMES = 999; } DataSet dsInparkCount = new DataSet(); dsInparkCount = GetInParkCount(co.PRODUCTID); if (dsInparkCount == null) { return(null); } else { gs_f_access.NALLPARKCOUNT = Convert.ToInt32(dsInparkCount.Tables[0].Rows[0]["NALLPARKCOUNT"]); gs_f_access.NENTRANCECOUNT = Convert.ToInt32(dsInparkCount.Tables[0].Rows[0]["NINPARKCOUNT"]); } DataSet ds_validity = new DataSet(); ds_validity = GetValidity(co.PRODUCTID); if (ds_validity == null) { return(null); } else { gs_f_access.NTIMES = Convert.ToInt32(ds_validity.Tables[0].Rows[0]["NTIMES"]); //gs_f_access.NINCOUNT = gs_f_access.NTIMES; gs_f_access.NSALDAYS = Convert.ToInt32(ds_validity.Tables[0].Rows[0]["NSALEDAYS"]); gs_f_access.NTYPE = Convert.ToInt32(ds_validity.Tables[0].Rows[0]["NTYPE"]); //DbNull.Value SSTARTTIME SENDTIME SSTARTDATE SENDDATE gs_f_access.DVSTARTTIME = ds_validity.Tables[0].Rows[0]["SSTARTTIME"].ToString() == "" ? "06:00:00" : ds_validity.Tables[0].Rows[0]["SSTARTTIME"].ToString(); gs_f_access.DVENDTIME = ds_validity.Tables[0].Rows[0]["SENDTIME"].ToString() == "" ? "22:00:00" : ds_validity.Tables[0].Rows[0]["SENDTIME"].ToString(); } return(gs_f_access); }
public Result SaveCard(Card oData) { //1、参数过滤; //2、签名验证; //3、条码重复验证; //4、解析Json为对象数据;V //5、没有这个订单数据,Insert DB(市民卡订单表CITIZENORDER、GS_F_ACCESS) //6、有这个订单数据,Update GS_F_ACCESS Barcode; //7、返回结果; #region log string resultJson = string.Empty; //增加参数日志记录 DateTime stime = DateTime.Now; StringBuilder logInfo = new StringBuilder(); logInfo.Append("调用接口名:SaveCard \r\n"); logInfo.Append("\r\n"); logInfo.Append("参数:\r\n"); logInfo.AppendFormat("merchantCode:{0}\r\n", oData.MerchantCode); logInfo.AppendFormat("ProductId:{0}\r\n", oData.ProductId); logInfo.AppendFormat("Barcode:{0}\r\n", oData.Barcode); logInfo.AppendFormat("IcNo:{0}\r\n", oData.IcNo); logInfo.AppendFormat("Name:{0}\r\n", oData.Name); logInfo.AppendFormat("OuterNo:{0}\r\n", oData.OuterNo); logInfo.AppendFormat("Signature:{0}\r\n", oData.Signature); logInfo.Append("\r\n"); #endregion try { Result result = new Result(); result.IsTrue = false; Gs_f_Access gs = new Gs_f_Access(); CitizenOrder corder = new CitizenOrder { BARCODE = oData.Barcode, ICNO = oData.IcNo, NAME = oData.Name, OUTORDERNO = oData.OuterNo, PRODUCTID = oData.ProductId, TRANSDATE = DateTime.Now.ToString("G") }; #region 检测参数是否为空 if (oData == null) { return(Common.GetResultMsg("104")); //参数空值 } #endregion #region 检测是否包含特殊字符 if (Common.CheckParameters(oData.Barcode)) { return(Common.GetResultMsg("102")); //参数含有非法字符 } if (Common.CheckParameters(oData.IcNo)) { return(Common.GetResultMsg("102")); //参数含有非法字符 } if (Common.CheckParameters(oData.MerchantCode)) { return(Common.GetResultMsg("102")); //参数含有非法字符 } if (Common.CheckParameters(oData.Name)) { return(Common.GetResultMsg("102")); //参数含有非法字符 } if (Common.CheckParameters(oData.OuterNo)) { return(Common.GetResultMsg("102")); //参数含有非法字符 } if (Common.CheckParameters(oData.ProductId.ToString())) { return(Common.GetResultMsg("102")); //参数含有非法字符 } if (Common.CheckParameters(oData.Signature)) { return(Common.GetResultMsg("102")); //参数含有非法字符 } #endregion #region 验证票种是否正确 if (!OrderService.CheckIsOkProduct(oData.ProductId)) { return(Common.GetResultMsg("109")); //参数空值 } #endregion //string innerSignature = Mcode + oData.ProductId.ToString() + oData.IcNo + oData.Name + oData.Barcode + oData.OuterNo + Pwd; string innerSignature = Mcode + oData.ProductId.ToString() + oData.IcNo + oData.Barcode + oData.OuterNo + Pwd; if (Common.CheckSignature(oData.Signature, innerSignature)) { #region 验证条码重复 if (OrderService.HaveSameBarcode(oData.Barcode)) { return(Common.GetResultMsg("103")); //此条码已存在 } #endregion #region DB判断 if (OrderService.HaveTheOrder(oData.OuterNo, oData.Barcode)) { gs = OrderService.GetAccess(corder); if (gs == null) { //107市民卡提交json信息解析错误,请检查json格式和必选参数是否为空 return(Common.GetResultMsg("107")); //市民卡提交数据错误 } if (OrderService.ExecUpdateTrans(corder, gs)) { result.IsTrue = true; result.ResultCode = "00"; result.ResultMsg = "成功"; result.ResultJson = null; return(result); } else { result.ResultCode = "110"; result.ResultMsg = "失败"; result.ResultJson = null; return(result); } } else { gs = OrderService.GetAccess(corder); if (gs == null) { //107市民卡提交json信息解析错误,请检查json格式和必选参数是否为空 return(Common.GetResultMsg("107")); //市民卡提交数据错误 } if (OrderService.ExecInsertTrans(corder, gs)) { result.IsTrue = true; result.ResultCode = "00"; result.ResultMsg = "成功"; result.ResultJson = null; return(result); } else { result.ResultCode = "110"; result.ResultMsg = "失败"; result.ResultJson = null; return(result); } } #endregion } else { return(Common.GetResultMsg("106")); //签名失败 } } catch (Exception ex) { //添加错误信息记录 logInfo.AppendFormat("错误信息:{0}\r\n", ex.Message); logInfo.AppendFormat("引发异常的方法:{0}\r\n", ex.TargetSite); logInfo.AppendFormat("错误应用程序或对象名称:{0}\r\n", ex.Source); logInfo.AppendFormat("在堆栈中表现形式:{0}\r\n", ex.StackTrace); logInfo.Append("\r\n"); return(Common.GetResultMsg("101")); } finally { //返回信息记录 logInfo.AppendFormat("返回:{0}\r\n", resultJson); DateTime etime = DateTime.Now; //添加时间记录 logInfo.Append(Common.GetLogTimeSpan(stime, etime)); //写入日志 Common.WriteLog("", DateTime.Now.ToString("yyyy-MM-dd") + oData.MerchantCode, logInfo.ToString()); } }