// GET api/RefundAccount/SaveRefundAccount?uid={uid}&realname={realname}&batchfee={batchfee}&accountname={accountname}&remark={remark} public object SaveRefundAccount(string uid, string realname, string batchfee, string accountname, string remark) { Random ran = new Random(); RefundAccountEntity refundAccountEntity = new RefundAccountEntity(); refundAccountEntity.UserId = uid; refundAccountEntity.RealName = realname; refundAccountEntity.BatchFee = Convert.ToSingle(batchfee) < 0?0 - Convert.ToSingle(batchfee): Convert.ToSingle(batchfee); refundAccountEntity.AccountName = accountname; refundAccountEntity.Remark = remark; refundAccountEntity.BatchNo = $"{DateTime.Now:yyyyMMdd}" + ran.RandomNumber(16); refundAccountEntity.AddTime = DateTime.Now; refundAccountEntity.Status = 1; if (RefundAccountBll.Instance.Add(refundAccountEntity) > 0) { MemberBll.Instance.UpdateIntegral(refundAccountEntity.UserId, "Deposit", (Convert.ToSingle(batchfee) > 0 ? 0 - Convert.ToSingle(batchfee) : Convert.ToSingle(batchfee)).ToString()); return(new Dictionary <string, string>() { { "status", "200" } }); } else { return(new Dictionary <string, string>() { { "status", "400" }, { "message", "保存失败" } }); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(RefundAccountEntity model) { try { return(RefundAccountDb.Instance.Update(model)); } catch (System.Exception ex) { WriteLog.WriteError(ex); throw ex; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(RefundAccountEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sns_refundAccount set "); strSql.Append("UserId=@UserId,"); strSql.Append("RealName=@RealName,"); strSql.Append("BatchNo=@BatchNo,"); strSql.Append("BatchFee=@BatchFee,"); strSql.Append("AccountName=@AccountName,"); strSql.Append("Remark=@Remark,"); strSql.Append("AddTime=@AddTime,"); strSql.Append("Status=@Status"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.VarChar, 50), new SqlParameter("@RealName", SqlDbType.VarChar, 50), new SqlParameter("@BatchNo", SqlDbType.VarChar, 50), new SqlParameter("@BatchFee", SqlDbType.Money, 8), new SqlParameter("@AccountName", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@AddTime", SqlDbType.DateTime, 8), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.RealName; parameters[2].Value = model.BatchNo; parameters[3].Value = model.BatchFee; parameters[4].Value = model.AccountName; parameters[5].Value = model.Remark; parameters[6].Value = model.AddTime; parameters[7].Value = model.Status; parameters[8].Value = model.Id; int rows = SqlHelper.Instance.ExecSqlNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public RefundAccountEntity DataRowToModel(DataRow row) { RefundAccountEntity model = new RefundAccountEntity(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["UserId"] != null) { model.UserId = row["UserId"].ToString(); } if (row["RealName"] != null) { model.RealName = row["RealName"].ToString(); } if (row["BatchNo"] != null) { model.BatchNo = row["BatchNo"].ToString(); } //model.BatchFee=row["BatchFee"].ToString(); if (row["AccountName"] != null) { model.AccountName = row["AccountName"].ToString(); } if (row["Remark"] != null) { model.Remark = row["Remark"].ToString(); } if (row["AddTime"] != null && row["AddTime"].ToString() != "") { model.AddTime = DateTime.Parse(row["AddTime"].ToString()); } if (row["Status"] != null && row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(RefundAccountEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sns_refundAccount("); strSql.Append("UserId,RealName,BatchNo,BatchFee,AccountName,Remark,AddTime,Status)"); strSql.Append(" values ("); strSql.Append("@UserId,@RealName,@BatchNo,@BatchFee,@AccountName,@Remark,@AddTime,@Status)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.VarChar, 50), new SqlParameter("@RealName", SqlDbType.VarChar, 50), new SqlParameter("@BatchNo", SqlDbType.VarChar, 50), new SqlParameter("@BatchFee", SqlDbType.Money, 8), new SqlParameter("@AccountName", SqlDbType.VarChar, 50), new SqlParameter("@Remark", SqlDbType.VarChar, 500), new SqlParameter("@AddTime", SqlDbType.DateTime, 8), new SqlParameter("@Status", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.RealName; parameters[2].Value = model.BatchNo; parameters[3].Value = model.BatchFee; parameters[4].Value = model.AccountName; parameters[5].Value = model.Remark; parameters[6].Value = model.AddTime; parameters[7].Value = model.Status; object obj = SqlHelper.Instance.ExecSqlScalar(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public RefundAccountEntity GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,UserId,RealName,BatchNo,BatchFee,AccountName,Remark,AddTime,Status from sns_refundAccount "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; RefundAccountEntity model = new RefundAccountEntity(); DataSet ds = SqlHelper.Instance.ExecSqlDataSet(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
// POST api/RefundAccount/AddRefundAccount public object AddRefundAccount([FromBody] RefundAccountEntity refundAccountEntity) { Random ran = new Random(); refundAccountEntity.BatchFee = refundAccountEntity.BatchFee < 0 ? 0 - refundAccountEntity.BatchFee : refundAccountEntity.BatchFee; refundAccountEntity.BatchNo = $"{DateTime.Now:yyyyMMdd}" + ran.RandomNumber(16); refundAccountEntity.AddTime = DateTime.Now; refundAccountEntity.Status = 1; if (RefundAccountBll.Instance.Add(refundAccountEntity) > 0) { MemberBll.Instance.UpdateIntegral(refundAccountEntity.UserId, "Deposit", (refundAccountEntity.BatchFee > 0 ? 0 - refundAccountEntity.BatchFee : refundAccountEntity.BatchFee).ToString()); return(new Dictionary <string, string>() { { "status", "200" } }); } else { return(new Dictionary <string, string>() { { "status", "400" }, { "message", "保存失败" } }); } }