public string DelMember(int user_id) { if (!Request.IsAuthenticated || StaticMethod.GetType(UserID) != 0) { return(JsonConvert.SerializeObject(new ReturnResponse(24000, "身份验证未通过"))); } using (var db = new DoCoverEntities()) { Users user = db.Users.FirstOrDefault(m => m.user_id == user_id); if (user == null) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 31002, message = "该用户不存在" })); } if ((user.Orders_Create != null && user.Orders_Create.Count > 0) || (user.Orders_Finish != null && user.Orders_Finish.Count > 0)) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 21001, message = "该用户有关联订单,推荐使用禁用功能" })); } db.Users.Remove(user); db.SaveChanges(); } return(JsonConvert.SerializeObject(new ReturnResponse(200))); }
public string UpdatePassword(string oldPassword, string newPassword) { if (!Request.IsAuthenticated) { return(JsonConvert.SerializeObject(new ReturnResponse(24000, "身份验证未通过"))); } try { using (var db = new DoCoverEntities()) { Users user = db.Users.FirstOrDefault(m => m.user_id == UserID); if (user.user_pwd != Security.EncryptQueryString(oldPassword)) { return(JsonConvert.SerializeObject(new ReturnResponse(24001, "当前密码不正确"))); } user.user_pwd = Security.EncryptQueryString(newPassword); user.user_last_update_ip = StaticMethod.GetClientIP(); user.user_last_update_time = DateTime.Now; db.SaveChanges(); } return(JsonConvert.SerializeObject(new ReturnResponse(200))); } catch (Exception ex) { return(JsonConvert.SerializeObject(new ReturnResponse(25001, ex.Message))); } }
public string EditMemberStatus(int user_id, bool user_status, string user_remark = "") { if (!Request.IsAuthenticated || StaticMethod.GetType(UserID) != 0) { return(JsonConvert.SerializeObject(new ReturnResponse(24000, "身份验证未通过"))); } using (var db = new DoCoverEntities()) { Users user = db.Users.FirstOrDefault(m => m.user_id == user_id); if (user == null) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 31002, message = "该用户不存在" })); } user.user_status = user_status; user.user_remark = user_remark; user.user_last_update_ip = StaticMethod.GetClientIP(); user.user_last_update_time = DateTime.Now;; db.SaveChanges(); } return(JsonConvert.SerializeObject(new ReturnResponse(200))); }
public string AddMember(string data) { if (!Request.IsAuthenticated || StaticMethod.GetType(UserID) != 0) { return(JsonConvert.SerializeObject(new ReturnResponse(24000, "身份验证未通过"))); } Users user = JsonConvert.DeserializeObject <Users>(data); user.user_pwd = Security.EncryptQueryString("123456"); user.user_reg_ip = StaticMethod.GetClientIP(); user.user_reg_time = DateTime.Now; using (var db = new DoCoverEntities()) { if (db.Users.Count(m => m.user_name == user.user_name) > 0) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 31001, message = "用户名重复" })); } db.Users.Add(user); db.SaveChanges(); } return(JsonConvert.SerializeObject(new ReturnResponse(200))); }
public string UpdateInfo(string data) { if (!Request.IsAuthenticated) { return(JsonConvert.SerializeObject(new ReturnResponse(24000, "身份验证未通过"))); } try { Users info = JsonConvert.DeserializeObject <Users>(data); using (var db = new DoCoverEntities()) { Users user = db.Users.FirstOrDefault(m => m.user_id == UserID); user.user_nick_name = info.user_nick_name; user.user_qq = info.user_qq; user.user_phone = info.user_phone; user.user_email = info.user_email; user.user_last_update_ip = StaticMethod.GetClientIP(); user.user_last_update_time = DateTime.Now; db.SaveChanges(); } return(JsonConvert.SerializeObject(new ReturnResponse(200))); } catch (Exception ex) { return(JsonConvert.SerializeObject(new ReturnResponse(25001, ex.Message))); } }
/// <summary> /// 请添加支付失败后的处理 /// </summary> private void DoFailedProcess(AlipayF2FQueryResult queryResult) { using (var db = new DoCoverEntities()) { var order = db.Orders.FirstOrDefault(m => m.order_id == queryResult.response.OutTradeNo); if (order == null) { return; } order.order_status = 0; db.SaveChanges(); } }
/// <summary> /// 请添加支付成功后的处理 /// </summary> private void DoSuccessProcess(AlipayF2FQueryResult queryResult) { using (var db = new DoCoverEntities()) { var order = db.Orders.FirstOrDefault(m => m.order_id == queryResult.response.OutTradeNo); if (order == null) { return; } string mail = order.order_cust_email; order.order_status = 3; db.SaveChanges(); SendMailUse(mail, "才几美工系统", "订单提示", $"你的订单号为{queryResult.response.OutTradeNo}的订单已成功付款,请静候佳音!"); } }
public string EditMember(string data) { if (!Request.IsAuthenticated || StaticMethod.GetType(UserID) != 0) { return(JsonConvert.SerializeObject(new ReturnResponse(24000, "身份验证未通过"))); } Users info = JsonConvert.DeserializeObject <Users>(data); info.user_last_update_ip = StaticMethod.GetClientIP(); info.user_last_update_time = DateTime.Now; using (var db = new DoCoverEntities()) { Users user = db.Users.FirstOrDefault(m => m.user_id == info.user_id); if (user == null) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 31002, message = "该用户不存在" })); } if (user.user_name != info.user_name) { if (db.Users.Count(m => m.user_name != user.user_name && m.user_name == info.user_name) > 0) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 31001, message = "用户名重复" })); } } if (info.user_pwd != null && info.user_pwd != "") { user.user_pwd = Security.EncryptQueryString(info.user_pwd); } user.user_name = info.user_name; user.user_nick_name = info.user_nick_name; user.user_qq = info.user_qq; user.user_phone = info.user_phone; user.user_email = info.user_email; user.user_last_update_ip = info.user_last_update_ip; user.user_last_update_time = info.user_last_update_time; db.SaveChanges(); } return(JsonConvert.SerializeObject(new ReturnResponse(200))); }
public string Validate(string name, string password) { ReturnResponse response = new ReturnResponse(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password)) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 500, message = "用户名或者密码错误", result = null })); } using (var db = new DoCoverEntities()) { try { password = Security.EncryptQueryString(password); Users user = db.Users.FirstOrDefault(m => m.user_name == name && m.user_pwd == password); if (user == null) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 500, message = "用户名或者密码错误", result = null })); } if (user.user_status == false) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 501, message = $"账号 {user.user_name} 被禁用,原因:{user.user_remark ?? "无"}", result = null })); } string data = user.user_type.ToString(); var ticket = new FormsAuthenticationTicket(2, user.user_id.ToString(), DateTime.Now, DateTime.Now.AddDays(1), true, data); var cookieValue = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookieValue) { HttpOnly = true, Secure = FormsAuthentication.RequireSSL, Domain = FormsAuthentication.CookieDomain, Path = FormsAuthentication.FormsCookiePath }; cookie.Expires = DateTime.Now.AddDays(1); var context = System.Web.HttpContext.Current; context.Response.Cookies.Remove(cookie.Name); context.Response.Cookies.Add(cookie); user.user_login_num = (user.user_login_num ?? 0) + 1; user.user_last_login_time = DateTime.Now; user.user_last_login_ip = StaticMethod.GetClientIP(); db.SaveChanges(); } catch (Exception ex) { return(JsonConvert.SerializeObject(new ReturnResponse(25001, ex.Message))); } } return(JsonConvert.SerializeObject(new ReturnResponse() { code = 200, message = "", result = null })); }
public string CreateOrder(string data) { try { Orders orderInfo = JsonConvert.DeserializeObject <Orders>(data); if (orderInfo == null) { return(JsonConvert.SerializeObject(new ReturnResponse(21500, "参数错误"))); } AlipayTradePrecreateContentBuilder builder = BuildPrecreateContent(orderInfo); string out_trade_no = builder.out_trade_no; using (var db = new DoCoverEntities()) { orderInfo.order_status = 2; db.Orders.Add(orderInfo); string a = ""; db.Database.Log = (c) => { a = c; }; db.SaveChanges(); } AlipayF2FPrecreateResult precreateResult = serviceClient.tradePrecreate(builder); //以下返回结果的处理供参考。 //payResponse.QrCode即二维码对于的链接 //将链接用二维码工具生成二维码打印出来,顾客可以用支付宝钱包扫码支付。 string result = ""; int code = 0; string message = ""; switch (precreateResult.Status) { case ResultEnum.SUCCESS: code = 200; result = DoWaitProcess(precreateResult); message = "生成订单成功"; break; case ResultEnum.FAILED: code = 500; message = "生成订单失败"; break; case ResultEnum.UNKNOWN: code = 500; if (precreateResult.response == null) { message = "配置或网络异常,请检查后重试"; } else { message = "系统异常,请更新外部订单后重新发起请求"; } break; } return(JsonConvert.SerializeObject(new ReturnResponse() { code = code, message = message, result = new { order_id = out_trade_no, money = orderInfo.order_price, data = result } })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new ReturnResponse() { code = 15001, message = ex.Message })); } }