/// <summary> /// 用户vip过期时间 POST: /vip/expiretime /// </summary> /// <returns></returns> public ActionResult ExpireTime(int UserLevel) { Tnet_User_Role daInfo = new Tnet_User_Role(); if (!daInfo.SelectByUserId_UserLevel(Package.UserId, UserLevel)) { return(FailResult("会员还未成为VIP", (int)ApiStatusCode.PARAMETER_CONFLICT)); } var data = new { ExpireTime = daInfo.Expire_Time, }; return(SuccessResult(data)); }
private bool UpgradeUserRole(SubOrder subOrder, UserLevel level) { DateTime start = DateTime.Now; BeginTransaction(); Tnet_User_Role daVip = new Tnet_User_Role(); daVip.ReferenceTransactionFrom(Transaction); if (!daVip.SelectByUserId_UserLevel(subOrder.User_Id, (int)level)) { daVip.User_Id = subOrder.User_Id; daVip.Expire_Time = start.AddYears(1); daVip.Last_Modify_Time = DateTime.Now; daVip.User_Level = (int)level; daVip.Role_Name = UserLevel.VIP会员.ToString(); if (!daVip.Insert()) { Rollback(); return(false); } } else { if (daVip.Expire_Time > start) { start = daVip.Expire_Time; } daVip.Expire_Time = start.AddYears(1); daVip.Last_Modify_Time = DateTime.Now; if (!daVip.Update()) { Rollback(); return(false); } } if (!string.IsNullOrEmpty(this.Order.Biz_Args)) { JsonObject arg = JsonObject.Parse(this.Order.Biz_Args); string org_code = arg.GetString("Org_Code"); if (!string.IsNullOrEmpty(org_code)) { Tnet_Organization daOrg = new Tnet_Organization(); if (!daOrg.SelectByOrgCode(org_code)) { Rollback(); Alert("归属俱乐部未找到"); return(false); } Tnet_User_Profile daProfile = new Tnet_User_Profile(); daProfile.ReferenceTransactionFrom(Transaction); daProfile.User_Id = daVip.User_Id; daProfile.Org_Id = daOrg.Org_Id; daProfile.Last_Modify_Time = DateTime.Now; if (!daProfile.Update()) { Rollback(); Alert("修改归属信息失败"); return(false); } } } Tnet_User daUser = new Tnet_User(); daUser.ReferenceTransactionFrom(Transaction); if (!daUser.UpdateUserLevel(subOrder.User_Id, level)) { Rollback(); Alert("更新会员角色失败"); return(false); } Commit(); return(true); }