public IHttpActionResult PostWithdrawalsDetail(string v1, string password, [FromBody] WithdrawalsDetails withdrawalsHistory) { try { if (withdrawalsHistory.change <= 0) { return(notFound("必须为非空整数")); } string objectId = HttpContext.Current.Request.Headers["objectId"]; _UserBLL userModel = new _UserBLL(); var usermodel = userModel.QuerySingleById(objectId); if (!usermodel.transaction_password.Equals((password + objectId).Md5())) { return(notFound("密码错误")); } if (usermodel.overage < withdrawalsHistory.change) { return(notFound("余额不足")); } withdrawalsHistory.createdAt = DateTime.Now; withdrawalsHistory.updatedAt = DateTime.Now; withdrawalsHistory.before = usermodel.overage; withdrawalsHistory.after = usermodel.overage - withdrawalsHistory.change; withdrawalsHistory.objectId = Guid.NewGuid().ToString(); withdrawalsHistory.state = "未完成"; if (bll.saveDetail(withdrawalsHistory, objectId)) { return(ok(withdrawalsHistory.objectId)); } return(notFound("失败")); } catch (Exception e) { return(execept(e.Message)); } }
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)); } }
public Task <System.Net.Http.HttpResponseMessage> ExecuteActionFilterAsync(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken, Func <Task <System.Net.Http.HttpResponseMessage> > continuation) { string token = HttpContext.Current.Request.Headers["Session-Token"]; _UserBLL bll = new _UserBLL(); var model = bll.QuerySingleByWheres(new List <Wheres> { new Wheres("sessionToken", "=", token) }); if (model == null) { return(Task <HttpResponseMessage> .Factory.StartNew(() => { return actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, new { error = "未登录", code = (int)HttpStatusCode.Unauthorized }); })); } HttpContext.Current.Request.Headers.Add("objectId", model.objectId); return(continuation()); }
public IHttpActionResult GetMassMessage(string v1, string phone) { //短信请求前,检查用户是否已经绑定 _UserBLL bll = new _UserBLL(); if (isNUll(phone)) { return(notFound("手机号不能为空")); } if (bll.QueryBandByUsername(phone)) { return(notFound("手机号已绑定过")); } MvcApplication1.Utility.HttpClient client = new MvcApplication1.Utility.HttpClient("https://webapi.sms.mob.com"); string postUri = "sms/sendmsg?appkey=1077112ae0d07&phone=" + phone + "&zone=86"; string postResponse = client.Get(postUri); if (!string.IsNullOrEmpty(postResponse)) { JObject jo = JsonHelper.DeserializeObject(postResponse); string status = jo["status"].ToString(); if (status.Equals("200")) { return(ok("请求验证码成功")); } else { return(notFound("请求验证码失败" + postResponse)); } } else { return(notFound("验证码请求失败")); } }
static void Main(string[] args) { _UserBLL bll = new _UserBLL(); List <Wheres> whs = new List <Wheres>() { new Wheres("objectId", "like", "%1%") }; var dir = bll.QuerySingleByWheres(whs); //object c = new { name = "1", id = "2" }; //var props = c.GetType().GetProperties(); //foreach (var prop in props) //{ // string name = prop.Name; // object value = prop.GetValue(c); //} //Random ran = new Random(); //for (int i=0; i < 20; i++) { // int num=ran.Next(-3, 3); // Console.WriteLine(num); //} string initPassword = "******"; string str = initPassword.Md5(); string str1 = (initPassword.Md5() + "af5e02e5-4ceb-4cf8-81d2-bcca13a24952").Md5(); string str2 = (initPassword.Md5() + "5efb2ff4-fee6-46dc-a0e1-aaa35fea9bce").Md5(); string str3 = (initPassword.Md5() + "8879e932-f4d7-4766-9d93-f95c53c90e6e").Md5(); //5efb2ff4-fee6-46dc-a0e1-aaa35fea9bce //8879e932-f4d7-4766-9d93-f95c53c90e6e Console.WriteLine(str); Console.WriteLine(str1); Console.WriteLine(str2); Console.WriteLine(str3); //string raw = "abcd1234"; //string jiami=raw.Md5(); //Console.WriteLine(jiami); //string str = jiami + "e6d21995-50c3-4aac-81ec-a99d72f2de7f"; //string jiami1=str.Md5(); //Console.WriteLine(jiami1); //_UserBLL bll = new _UserBLL(); //Dictionary<string, string[]> dir = new Dictionary<string, string[]>(){ // {"_User",new string[]{"createdAt","password"}} //}; //var models=bll.QueryListX(0, 3, dir); //string str = JsonHelper.Serialize(models); //Console.WriteLine(str); //var model=bll.QuerySingleByIdX(@"2d1d6669-059e-4931-9365-f964f1ce93c4", dir); //string str = JsonHelper.Serialize(model); //Console.WriteLine(str); //RestClient client = new RestClient("http://192.168.191.1"); //List<Columns> li = new List<Columns>(); //Columns col = new Columns(); //col.key = "aa"; //col.value = 2; //Columns col1 = new Columns(); //col1.key = "ab"; //col1.value = 2; //li.Add(col); //li.Add(col1); //Dictionary<string, object> dic = new Dictionary<string, object>() { { "22", 3 }, { "23", 3 } }; //string[] arr = { "1", "2", "3" }; //string str = JsonHelper.Serialize(li); //string str1 = JsonHelper.Serialize(dic); //string str2 = JsonHelper.Serialize(arr); //Console.WriteLine(str); //Console.WriteLine(str1); //Console.WriteLine(str2); //string[] arr1 = JsonHelper.Deserialize<string[]>(str2); //Console.WriteLine(arr1[0]); //string[] cc = null; //object cdd = cc; //string[] ee = (string[])cdd; //Console.WriteLine(ee); //Console.WriteLine("11"); //#region Get 方式请求列表 //string str = client.Get("api/values"); //Console.WriteLine(str); //#endregion //#region Get 方式请求id对应的数据 //string strGetById = client.Get("api/values/2"); //Console.WriteLine(strGetById); //#endregion //#region Post 方式 添加数据 //string postUri = "api/users?code=333"; //string userJson = @"{""username"":""11131323"",""password"":""12""}"; //string postResponse = client.Post(userJson, postUri); //Console.WriteLine(postResponse); //#endregion //#region Delete //string deleteUri = "api/values/3"; //string deleteResponse = client.Delete(deleteUri); //Console.WriteLine(deleteResponse); //#endregion //#region Put //string putUri = "api/values/123"; //string userJson3 = @"{""Id"":11123,""Age"":12,""UserName"":""111""}"; //string putResponse = client.Post(userJson3, putUri); //Console.WriteLine(putResponse); //#endregion Console.ReadKey(); }