public ActionResult Identify(FormCollection form) { RequireLogin(); UserViewModel model = new UserViewModel { UserEntity = UserInfo }; UserService service = new UserService(); try { UserVip vipInfo = service.GetUserVipInfoByUserId(UserInfo.UserId); string errorMsg = string.Empty; string imgUrl = string.Empty; try { HttpPostedFileBase postFile = this.HttpContext.Request.Files["IdentiyImg"]; using (System.Drawing.Image img = System.Drawing.Image.FromStream(postFile.InputStream)) { } } catch { errorMsg = "图片格式错误,请重新选择"; } if (string.IsNullOrEmpty(errorMsg)) { errorMsg = FileUploadHelper.SaveFile(this.HttpContext, "IdentiyImg", out imgUrl); if (string.IsNullOrEmpty(errorMsg)) { UserInfo.IdentiyImg = imgUrl; UserInfo.Vip = (int)VipState.Normal; if (service.UserUpdate(UserInfo) && service.UpdateUserVipInfo(vipInfo.Id, vipInfo.OrderId, imgUrl, DateTime.Now, DateTime.Now, vipInfo.Duration, vipInfo.Amount, VipState.Normal)) { errorMsg = "图片上传成功,等待管理员审核"; } } } // get it again model.VipInfo = service.GetUserVipInfoByUserId(UserInfo.UserId); if (string.IsNullOrEmpty(errorMsg)) { errorMsg = GetErrorMessage(model.VipInfo); } model.ErrorMsg = errorMsg; } catch (Exception e) { LogService.Log("Identify 出错了!", e.ToString()); } model.VipInfo = model.VipInfo ?? service.GetUserVipInfoByUserId(UserInfo.UserId); return View(model); }
public ActionResult Identify(string identifyImgUrl, string returnUrl = null) { WeChatUserViewModel model = new WeChatUserViewModel { UserEntity = UserInfo }; if (!string.IsNullOrWhiteSpace(identifyImgUrl)) { UserService service = new UserService(); try { UserVip vipInfo = service.GetUserVipInfoByUserId(UserInfo.UserId); CurrentUser.IdentiyImg = identifyImgUrl; CurrentUser.Vip = (int)VipState.Normal; if (service.UserUpdate(CurrentUser) && service.UpdateUserVipInfo(vipInfo.Id, vipInfo.OrderId, identifyImgUrl, DateTime.Now, DateTime.Now, vipInfo.Duration, vipInfo.Amount, VipState.Normal)) { model.ErrorMsg = "照片上传成功,等待管理员审核"; } // get it again model.VipInfo = service.GetUserVipInfoByUserId(UserInfo.UserId); if (string.IsNullOrEmpty(model.ErrorMsg)) { model.ErrorMsg = GetErrorMessage(model.VipInfo); } } catch (Exception e) { LogService.Log("Identify 出错了!", e.ToString()); model.ErrorMsg = "认证照片上传失败!"; } } else { model.ErrorMsg = "请选择认证照片!"; } if (!string.IsNullOrWhiteSpace(returnUrl)) { return Redirect(returnUrl); } return View(model); }
public ActionResult VipOrder(string vipDuration) { string result = "生成VIP会员充值订单失败"; if (UserInfo != null) { UserService userService = new UserService(); try { if (UserInfo != null) { int duration = -1; decimal totalAmount = 0; int.TryParse(vipDuration, out duration); if (duration < 1 || duration > 5) { throw new ArgumentException("充值VIP时间不正确,请重新选择"); } totalAmount = 100 * duration; UserVip vipInfo = userService.GetUserVipInfoByUserId(UserInfo.UserId); if (vipInfo != null) { if (vipInfo.State == (int)VipState.Normal || vipInfo.State == (int)VipState.Invalid) { throw new ArgumentException("认证资料还没有通过审核,请先上传认证资料"); } TradeOrder order = null; string url = GetUrl("/m/user/VipInfo"); if (!string.IsNullOrEmpty(vipInfo.OrderId)) { order = orderService.GetOrderByOrderId(vipInfo.OrderId); } if (order != null && order.UserName == UserInfo.UserName && order.Amount == totalAmount) { result = string.Format(Constant.PostPayInfoFormatForMobile, order.OrderId, url); } else { // 删掉原来的订单 if (order != null) { orderService.DeleteOrderById(order.OrderId); } string orderId = orderService.GenerateNewOrderNumber(); string subject = "活动在线网 | 用户VIP会员充值"; string body = "用户" + UserInfo.UserName + "充值VIP会员" + duration + "年"; int userId = UserInfo.UserId; string username = UserInfo.UserName; decimal amount = totalAmount; int state = (int)OrderState.New; string resourceUrl = url; order = orderService.AddNewOrder(orderId, subject, body, amount, state, username, resourceUrl, (int)OrderType.ToVip, userId); bool success = userService.UpdateUserVipInfo(vipInfo.Id, orderId, vipInfo.IdentifyImg, vipInfo.StartTime, vipInfo.EndTime, duration, totalAmount, VipState.Identified); if (success && order != null) { result = string.Format(Constant.PostPayInfoFormatForMobile, orderId, url); } else { result = "生成VIP充值支付订单信息失败,请重新尝试"; } } } } } catch (ArgumentException e) { result = e.Message; } catch (Exception e) { LogService.Log("生成VIP充值支付订单信息", e.ToString()); result = "生成VIP充值支付订单信息,请重新尝试"; } } else { result = "您还未登录或登录超时,请重新登录"; } return Content(result); }