コード例 #1
0
///<summary>
///向数据库中添加一条记录
///</summary>
///<param name="model">要添加的实体</param>
        public bool Insert(RechargeHistory model)
        {
            const string sql = @"INSERT INTO [dbo].[RechargeHistory] (objectId,updatedAt,createdAt,userId,name,body,create_time,out_trade_no,transaction_id,pay_type,total_fee,trade_state) VALUES (@objectId,@updatedAt,@createdAt,@userId,@name,@body,@create_time,@out_trade_no,@transaction_id,@pay_type,@total_fee,@trade_state)";
            int          res = SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@objectId", model.objectId.ToDBValue()), new SqlParameter("@updatedAt", model.updatedAt.ToDBValue()), new SqlParameter("@createdAt", model.createdAt.ToDBValue()), new SqlParameter("@userId", model.userId.ToDBValue()), new SqlParameter("@name", model.name.ToDBValue()), new SqlParameter("@body", model.body.ToDBValue()), new SqlParameter("@create_time", model.create_time.ToDBValue()), new SqlParameter("@out_trade_no", model.out_trade_no.ToDBValue()), new SqlParameter("@transaction_id", model.transaction_id.ToDBValue()), new SqlParameter("@pay_type", model.pay_type.ToDBValue()), new SqlParameter("@total_fee", model.total_fee.ToDBValue()), new SqlParameter("@trade_state", model.trade_state.ToDBValue()));

            return(res > 0);
        }
コード例 #2
0
/// <summary>
/// 查询单个模型实体
/// </summary>
/// <param name="id">objectId</param>);
/// <returns>实体</returns>);
        public RechargeHistory QuerySingleById(string objectId)
        {
            const string sql = "SELECT TOP 1 objectId,updatedAt,createdAt,userId,name,body,create_time,out_trade_no,transaction_id,pay_type,total_fee,trade_state from RechargeHistory WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    RechargeHistory model = SqlHelper.MapEntity <RechargeHistory>(reader);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #3
0
        public IHttpActionResult Post(string v1, [FromBody] order myOrder)
        {
            try {
                //string objectId = myOrder.trade_no;
                //RechargeHistory model = bll.QuerySingleById(objectId);
                //HttpClint query = new HttpClint();

                //RechargeHistory mm = new RechargeHistory();
                //mm.createdAt = DateTime.Now;
                //mm.updatedAt = DateTime.Now;
                //mm.objectId = "11111111";
                //bll.Update(mm);

                string          out_trade_no = myOrder.out_trade_no;
                string          response     = HttpHelper.Get(@"https://api.bmob.cn/1/pay/" + out_trade_no, new { });
                RechargeHistory model        = JsonHelper.Deserialize <RechargeHistory>(response);


                RechargeHistory modelX = bll.QuerySingleById(model.body);

                model.updatedAt = DateTime.Now;
                model.createdAt = modelX.createdAt;


                model.objectId     = model.body;
                model.userId       = modelX.userId;
                model.trade_state  = myOrder.trade_status;
                model.out_trade_no = myOrder.out_trade_no;
                bool     result    = bll.Update(model);
                _UserBLL userbll   = new _UserBLL();
                _User    userModel = userbll.QuerySingleById(model.userId);
                userbll.UpdateById(model.userId, new Dictionary <string, object> {
                    { "overage", userModel.overage + model.total_fee * 100 }
                });
                if (result)
                {
                    return(ok("success"));
                }
                return(ok("failure"));
            }
            catch (Exception e) {
                return(ok(e.Message));
            }
        }
コード例 #4
0
        public IHttpActionResult GetrechargeHistory(String v1, string userId)
        {
            RechargeHistory model = new RechargeHistory();
            Guid            guid  = Guid.NewGuid();

            model.objectId = guid.ToString();

            model.createdAt = DateTime.Now;
            model.updatedAt = DateTime.Now;
            model.userId    = userId;

            bool result = bll.Insert(model);

            if (result)
            {
                return(ok(model.objectId));
                //return create(model.objectId);
            }
            return(notFound("订单生成失败"));
        }
コード例 #5
0
///<summary>
///分页查询一个集合
///</summary>
///<param name="index">页码</param>
///<param name="size">页大小</param>
///<param name="wheres">条件匿名类</param>
///<param name="orderField">排序字段</param>
///<param name="isDesc">是否降序排序</param>
///<returns>实体集合</returns>
        public IEnumerable <RechargeHistory> QueryList(int index, int size, object wheres = null, string orderField = "objectId", bool isDesc = true)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            orderField   = string.IsNullOrEmpty(orderField) ? "objectId" : orderField;
            var sql = SqlHelper.GenerateQuerySql("RechargeHistory", new string[] { "objectId", "updatedAt", "createdAt", "userId", "name", "body", "create_time", "out_trade_no", "transaction_id", "pay_type", "total_fee", "trade_state" }, index, size, where, orderField, isDesc);

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        RechargeHistory model = SqlHelper.MapEntity <RechargeHistory>(reader);
                        yield return(model);
                    }
                }
            }
        }
コード例 #6
0
 public JsonActionResult <bool> DrawReceipt(RechargeHistory entity)
 {
     return(SafeExecute(() => RechargeHistoryService.DrawReceipt(entity)));
 }
コード例 #7
0
/// <summary>
/// 根据主键更新一条记录
/// </summary>
/// <param name="model">更新后的实体</param>
/// <returns>执行结果受影响行数</returns>
        public bool Update(RechargeHistory model)
        {
            return(_dao.Update(model));
        }
コード例 #8
0
/// <summary>
/// 向数据库中添加一条记录
/// </summary>
/// <param name="model">要添加的实体</param>
/// <returns>是否成功</returns>
        public bool Insert(RechargeHistory model)
        {
            return(_dao.Insert(model));
        }
コード例 #9
0
/// <summary>
/// 根据主键更新一条记录
/// </summary>
/// <param name="model">更新后的实体</param>
/// <returns>是否成功</returns>
        public bool Update(RechargeHistory model)
        {
            const string sql = @"UPDATE [dbo].[RechargeHistory] SET  updatedAt=@updatedAt,createdAt=@createdAt,userId=@userId,name=@name,body=@body,create_time=@create_time,out_trade_no=@out_trade_no,transaction_id=@transaction_id,pay_type=@pay_type,total_fee=@total_fee,trade_state=@trade_state  WHERE [objectId] = @objectId";

            return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@objectId", model.objectId.ToDBValue()), new SqlParameter("@updatedAt", model.updatedAt.ToDBValue()), new SqlParameter("@createdAt", model.createdAt.ToDBValue()), new SqlParameter("@userId", model.userId.ToDBValue()), new SqlParameter("@name", model.name.ToDBValue()), new SqlParameter("@body", model.body.ToDBValue()), new SqlParameter("@create_time", model.create_time.ToDBValue()), new SqlParameter("@out_trade_no", model.out_trade_no.ToDBValue()), new SqlParameter("@transaction_id", model.transaction_id.ToDBValue()), new SqlParameter("@pay_type", model.pay_type.ToDBValue()), new SqlParameter("@total_fee", model.total_fee.ToDBValue()), new SqlParameter("@trade_state", model.trade_state.ToDBValue())) > 0);
        }