/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <FinanceRefundEntity> GetFinanceRefundAll() { string sql = @"SELECT [Id],[OrderCode],[PayTradeNo],[RebackFee],[Description],[CreateTime],[Status],[FinanceDealTime],[DealManId] from dbo.[FinanceRefund] WITH(NOLOCK) "; IList <FinanceRefundEntity> entityList = new List <FinanceRefundEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { FinanceRefundEntity entity = new FinanceRefundEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.OrderCode = StringUtils.GetDbLong(reader["OrderCode"]); entity.PayTradeNo = StringUtils.GetDbString(reader["PayTradeNo"]); entity.RebackFee = StringUtils.GetDbDecimal(reader["RebackFee"]); entity.Description = StringUtils.GetDbString(reader["Description"]); entity.CreateTime = StringUtils.GetDbDateTime(reader["CreateTime"]); entity.Status = StringUtils.GetDbInt(reader["Status"]); entity.FinanceDealTime = StringUtils.GetDbDateTime(reader["FinanceDealTime"]); entity.DealManId = StringUtils.GetDbInt(reader["DealManId"]); entityList.Add(entity); } } return(entityList); }
/// <summary> /// 判断当前节点是否已存在相同的 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int ExistNum(FinanceRefundEntity entity) { ///id=0,判断总数,ID>0判断除自己之外的总数 string sql = @"Select count(1) from dbo.[FinanceRefund] WITH(NOLOCK) "; string where = "where "; if (entity.Id == 0) { } else { } sql = sql + where; DbCommand cmd = db.GetSqlStringCommand(sql); if (entity.Id > 0) { db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); } object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
/// <summary> /// 根据主键值读取记录。如果数据库不存在这条数据将返回null /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public FinanceRefundEntity GetFinanceRefund(int id) { string sql = @"SELECT [Id],[OrderCode],[PayTradeNo],[RebackFee],ActRebackFee,ReturnXSId,[Description],[CreateTime],[Status],[FinanceDealTime],[DealManId] ,ReBackIntegral,IntegralStatus,ActReBackIntegral FROM dbo.[FinanceRefund] WITH(NOLOCK) WHERE [Id]=@id" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@Id", DbType.Int32, id); FinanceRefundEntity entity = new FinanceRefundEntity(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.OrderCode = StringUtils.GetDbLong(reader["OrderCode"]); entity.PayTradeNo = StringUtils.GetDbString(reader["PayTradeNo"]); entity.RebackFee = StringUtils.GetDbDecimal(reader["RebackFee"]); entity.Description = StringUtils.GetDbString(reader["Description"]); entity.ActRebackFee = StringUtils.GetDbDecimal(reader["ActRebackFee"]); entity.ReturnXSId = StringUtils.GetDbInt(reader["ReturnXSId"]); entity.CreateTime = StringUtils.GetDbDateTime(reader["CreateTime"]); entity.Status = StringUtils.GetDbInt(reader["Status"]); entity.ActReBackIntegral = StringUtils.GetDbInt(reader["ActReBackIntegral"]); entity.ReBackIntegral = StringUtils.GetDbInt(reader["ReBackIntegral"]); entity.IntegralStatus = StringUtils.GetDbInt(reader["IntegralStatus"]); entity.FinanceDealTime = StringUtils.GetDbDateTime(reader["FinanceDealTime"]); entity.DealManId = StringUtils.GetDbInt(reader["DealManId"]); } } return(entity); }
/// <summary> /// 插入一条记录到表FinanceRefund,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="financeRefund">要添加的FinanceRefund数据实体对象</param> public int AddFinanceRefund(FinanceRefundEntity financeRefund) { if (financeRefund.Id > 0) { return(UpdateFinanceRefund(financeRefund)); } else if (FinanceRefundBLL.Instance.IsExist(financeRefund)) { return((int)CommonStatus.ADD_Fail_Exist); } else { return(FinanceRefundDA.Instance.AddFinanceRefund(financeRefund)); } }
/// <summary> /// 读取记录列表。 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param> public IList <FinanceRefundEntity> GetFinanceRefundList(int pagesize, int pageindex, ref int recordCount) { string sql = @"SELECT [Id],[OrderCode],[PayTradeNo],[RebackFee],[Description],[CreateTime],[Status],[FinanceDealTime],[DealManId] FROM (SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER, [Id],[OrderCode],[PayTradeNo],[RebackFee],[Description],[CreateTime],[Status],[FinanceDealTime],[DealManId] from dbo.[FinanceRefund] WITH(NOLOCK) WHERE 1=1 ) as temp where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize" ; string sql2 = @"Select count(1) from dbo.[FinanceRefund] with (nolock) "; IList <FinanceRefundEntity> entityList = new List <FinanceRefundEntity>(); DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize); using (IDataReader reader = db.ExecuteReader(cmd)) { while (reader.Read()) { FinanceRefundEntity entity = new FinanceRefundEntity(); entity.Id = StringUtils.GetDbInt(reader["Id"]); entity.OrderCode = StringUtils.GetDbLong(reader["OrderCode"]); entity.PayTradeNo = StringUtils.GetDbString(reader["PayTradeNo"]); entity.RebackFee = StringUtils.GetDbDecimal(reader["RebackFee"]); entity.Description = StringUtils.GetDbString(reader["Description"]); entity.CreateTime = StringUtils.GetDbDateTime(reader["CreateTime"]); entity.Status = StringUtils.GetDbInt(reader["Status"]); entity.FinanceDealTime = StringUtils.GetDbDateTime(reader["FinanceDealTime"]); entity.DealManId = StringUtils.GetDbInt(reader["DealManId"]); entityList.Add(entity); } } cmd = db.GetSqlStringCommand(sql2); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { recordCount = StringUtils.GetDbInt(reader[0]); } else { recordCount = 0; } } return(entityList); }
/// <summary> /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。 /// 如果数据库有数据被更新了则返回True,否则返回False /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="financeRefund">待更新的实体对象</param> public int UpdateFinanceRefund(FinanceRefundEntity entity) { string sql = @" UPDATE dbo.[FinanceRefund] SET [ReturnXSId]=@ReturnXSId,[OrderCode]=@OrderCode,[PayTradeNo]=@PayTradeNo,[RebackFee]=@RebackFee,[Description]=@Description,[CreateTime]=@CreateTime,[Status]=@Status,[FinanceDealTime]=@FinanceDealTime,[DealManId]=@DealManId WHERE [Id]=@id"; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id); db.AddInParameter(cmd, "@OrderCode", DbType.Int64, entity.OrderCode); db.AddInParameter(cmd, "@PayTradeNo", DbType.String, entity.PayTradeNo); db.AddInParameter(cmd, "@RebackFee", DbType.Decimal, entity.RebackFee); db.AddInParameter(cmd, "@Description", DbType.String, entity.Description); db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime); db.AddInParameter(cmd, "@Status", DbType.Int32, entity.Status); db.AddInParameter(cmd, "@FinanceDealTime", DbType.DateTime, entity.FinanceDealTime); db.AddInParameter(cmd, "@DealManId", DbType.Int32, entity.DealManId); db.AddInParameter(cmd, "@ReturnXSId", DbType.Int32, entity.ReturnXSId); return(db.ExecuteNonQuery(cmd)); }
/// <summary> /// 添加退款信息 /// </summary> /// <returns></returns> public string AddPayReback() { ResultObj obj = new ResultObj(); long _batchno = FormString.LongIntSafeQ("batchno"); int _refundid = FormString.IntSafeQ("refundid"); long _ordercode = FormString.LongIntSafeQ("ordercode"); string _tradecode = FormString.SafeQ("tradecode"); decimal _rebackfee = FormString.DecimalSafeQ("rebackfee"); string _returnreason = FormString.SafeQ("returnreason", 1000); OrderEntity orderentity = OrderBLL.Instance.GetOrderByCode(_ordercode); FinanceRefundEntity Refundentity = FinanceRefundBLL.Instance.GetFinanceRefund(_refundid); if (orderentity.ActPrice - orderentity.ReBackFee >= _rebackfee && Refundentity.RebackFee >= _rebackfee) { PayRebackEntity entity = new PayRebackEntity(); entity.BatchNo = _batchno; entity.OrderCode = _ordercode; entity.TradeNoLog = _tradecode; entity.RebackFee = _rebackfee; entity.Remack = _returnreason; entity.RebackTime = DateTime.Now; entity.CreateTime = DateTime.Now; entity.FinanceRefundId = _refundid; int _result = PayRebackBLL.Instance.AddPayReback(entity); if (_result > 0) { obj.Status = (int)CommonStatus.Success; } else { obj.Status = _result; } } else { obj.Status = (int)CommonStatus.AddPayRebackBig; } //int _result = OrderBLL.Instance.UpdateOrderRebackFee(_ordercode,_rebackfee); return(JsonJC.ObjectToJson(obj)); }
public string AddPayRebackIntegral() { ResultObj obj = new ResultObj(); long _batchno = FormString.LongIntSafeQ("batchno"); int _refundid = FormString.IntSafeQ("refundid"); long _ordercode = FormString.LongIntSafeQ("ordercode"); string _tradecode = FormString.SafeQ("tradecode"); int _returnintegral = FormString.IntSafeQ("returnintegral"); string _returnreason = FormString.SafeQ("returnreason", 1000); OrderEntity orderentity = OrderBLL.Instance.GetOrderByCode(_ordercode); FinanceRefundEntity Refundentity = FinanceRefundBLL.Instance.GetFinanceRefund(_refundid); //if (Refundentity.IntegralStatus == (int)ReBackIntegralStatus.WaitReback) //{ if (orderentity.Integral - orderentity.ReBackFeeIntegral >= _returnintegral && Refundentity.ReBackIntegral - Refundentity.ActReBackIntegral >= _returnintegral) { int _result = OrderBLL.Instance.RebackIntegral(_ordercode, orderentity.TimeStampCode, _refundid, _returnintegral, orderentity.MemId); if (_result > 0) { obj.Status = (int)CommonStatus.Success; } else { obj.Status = _result; } } else { obj.Status = (int)CommonStatus.RebackIntegralBig; } //} //else //{ // obj.Status = (int)CommonStatus.RebackIntegralBig; //} //int _result = OrderBLL.Instance.UpdateOrderRebackFee(_ordercode,_rebackfee); return(JsonJC.ObjectToJson(obj)); }
/// <summary> /// 插入一条记录到表FinanceRefund,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0 /// </summary> /// <param name="db">数据库操作对象</param> /// <param name="financeRefund">待插入的实体对象</param> public int AddFinanceRefund(FinanceRefundEntity entity) { string sql = @"insert into FinanceRefund( [ReturnXSId],[OrderCode],[PayTradeNo],[RebackFee],[Description],[CreateTime],[Status],[FinanceDealTime],[DealManId])VALUES ( @ReturnXSId,@OrderCode,@PayTradeNo,@RebackFee,@Description,@CreateTime,@Status,@FinanceDealTime,@DealManId); SELECT SCOPE_IDENTITY();" ; DbCommand cmd = db.GetSqlStringCommand(sql); db.AddInParameter(cmd, "@OrderCode", DbType.Int64, entity.OrderCode); db.AddInParameter(cmd, "@PayTradeNo", DbType.String, entity.PayTradeNo); db.AddInParameter(cmd, "@RebackFee", DbType.Decimal, entity.RebackFee); db.AddInParameter(cmd, "@Description", DbType.String, entity.Description); db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime); db.AddInParameter(cmd, "@Status", DbType.Int32, entity.Status); db.AddInParameter(cmd, "@FinanceDealTime", DbType.DateTime, entity.FinanceDealTime); db.AddInParameter(cmd, "@DealManId", DbType.Int32, entity.DealManId); db.AddInParameter(cmd, "@ReturnXSId", DbType.Int32, entity.ReturnXSId); object identity = db.ExecuteScalar(cmd); if (identity == null || identity == DBNull.Value) { return(0); } return(Convert.ToInt32(identity)); }
/// <summary> /// 更新一条FinanceRefund记录。 /// 该方法提供给界面等UI层调用 /// </summary> /// <param name="financeRefund">待更新的实体对象</param> /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param> public int UpdateFinanceRefund(FinanceRefundEntity financeRefund) { return(FinanceRefundDA.Instance.UpdateFinanceRefund(financeRefund)); }
/// <summary> /// 判断对象是否存在 /// </summary> /// <param name="dicEnum"></param> /// <returns></returns> public bool IsExist(FinanceRefundEntity financeRefund) { return(FinanceRefundDA.Instance.ExistNum(financeRefund) > 0); }