| | |
| | | using System.Threading.Tasks; |
| | | using CoreCms.Net.Configuration; |
| | | using CoreCms.Net.Filter; |
| | | using CoreCms.Net.IRepository.UnitOfWork; |
| | | using CoreCms.Net.IServices; |
| | | using CoreCms.Net.Loging; |
| | | using CoreCms.Net.Model.Entities; |
| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Hosting; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.CodeAnalysis.Operations; |
| | | using SqlSugar; |
| | | |
| | | namespace CoreCms.Net.Web.Admin.Controllers |
| | |
| | | private readonly ICoreCmsDistributionGradeServices _distributionGradeServices; |
| | | private readonly ICoreCmsUserServices _userServices; |
| | | private readonly IWebHostEnvironment _webHostEnvironment; |
| | | private readonly ICoreCmsAreaServices _areaServices; |
| | | private readonly ICoreCmsSettingServices _coreCmsSettingServices; |
| | | private readonly IUnitOfWork _unitOfWork; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | public CoreCmsDistributionController(IWebHostEnvironment webHostEnvironment |
| | | , ICoreCmsDistributionServices coreCmsDistributionServices, ICoreCmsUserGradeServices userGradeServices, ICoreCmsDistributionGradeServices distributionGradeServices, ICoreCmsUserServices userServices) |
| | | , ICoreCmsDistributionServices coreCmsDistributionServices, |
| | | ICoreCmsUserGradeServices userGradeServices, |
| | | ICoreCmsDistributionGradeServices distributionGradeServices, |
| | | ICoreCmsUserServices userServices, |
| | | ICoreCmsAreaServices areaServices, |
| | | ICoreCmsSettingServices coreCmsSettingServices, |
| | | IUnitOfWork unitOfWork) |
| | | { |
| | | _webHostEnvironment = webHostEnvironment; |
| | | _coreCmsDistributionServices = coreCmsDistributionServices; |
| | | _userGradeServices = userGradeServices; |
| | | _distributionGradeServices = distributionGradeServices; |
| | | _userServices = userServices; |
| | | _areaServices = areaServices; |
| | | _coreCmsSettingServices = coreCmsSettingServices; |
| | | _unitOfWork = unitOfWork; |
| | | } |
| | | |
| | | #region 获取列表============================================================ |
| | |
| | | where = where.And(p => p.isDelete == false); |
| | | //获取数据 |
| | | var list = await _coreCmsDistributionServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize); |
| | | |
| | | //返回数据 |
| | | jm.data = list; |
| | | jm.code = 0; |
| | |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | //事物处理过程开始 |
| | | oldModel.name = entity.name; |
| | | oldModel.gradeId = entity.gradeId; |
| | | oldModel.mobile = entity.mobile; |
| | | oldModel.weixin = entity.weixin; |
| | | oldModel.qq = entity.qq; |
| | | oldModel.verifyStatus = entity.verifyStatus; |
| | | oldModel.updateTime = DateTime.Now; |
| | | if (oldModel.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) oldModel.verifyTime = DateTime.Now; |
| | | |
| | | //事物处理过程结束 |
| | | var bl = await _coreCmsDistributionServices.UpdateAsync(oldModel); |
| | | jm.code = bl ? 0 : 1; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | try |
| | | { |
| | | _unitOfWork.BeginTran(); |
| | | if (oldModel.verifyStatus != (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes && entity.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | { |
| | | var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries(); |
| | | var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey); |
| | | var group = await _userGradeServices.GetUserGradeByValueKey(kc); |
| | | if (group != null) |
| | | { |
| | | var olduser = await _userServices.QueryByIdAsync(oldModel.userId); |
| | | if (olduser != null) |
| | | { |
| | | olduser.grade = group.id; |
| | | olduser.updataTime = DateTime.Now; |
| | | await _userServices.UpdateAsync(olduser); |
| | | |
| | | return jm; |
| | | } |
| | | } |
| | | |
| | | //如果是通过审核 |
| | | oldModel.verifyTime = DateTime.Now; |
| | | } |
| | | else |
| | | if (oldModel.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes && entity.verifyStatus != (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | { |
| | | //如果是取消审核 |
| | | |
| | | var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries(); |
| | | var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey); |
| | | var group = await _userGradeServices.GetUserGradeByValueKey(kc); |
| | | var defgroup = await _userGradeServices.GetDefaultUserGrade(); |
| | | if (defgroup != null) |
| | | { |
| | | var olduser = await _userServices.QueryByIdAsync(oldModel.userId); |
| | | if (olduser != null) |
| | | { |
| | | if (olduser.grade == group.id) |
| | | { |
| | | if (defgroup != null) |
| | | { |
| | | olduser.grade = defgroup.id; |
| | | } |
| | | else |
| | | { |
| | | |
| | | olduser.grade = 0; |
| | | } |
| | | |
| | | olduser.updataTime = DateTime.Now; |
| | | await _userServices.UpdateAsync(olduser); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | oldModel.verifyStatus = entity.verifyStatus; |
| | | oldModel.updateTime = DateTime.Now; |
| | | //if (oldModel.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | //{ |
| | | // oldModel.verifyTime = DateTime.Now; |
| | | //} |
| | | |
| | | //事物处理过程结束 |
| | | var bl = await _coreCmsDistributionServices.UpdateAsync(oldModel); |
| | | |
| | | _unitOfWork.CommitTran(); |
| | | jm.code = bl ? 0 : 1; |
| | | jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | |
| | | return jm; |
| | | } |
| | | catch (Exception ) |
| | | { |
| | | _unitOfWork.RollbackTran(); |
| | | jm.code = 1; |
| | | jm.msg = GlobalConstVars.EditFailure; |
| | | |
| | | return jm; |
| | | |
| | | } |
| | | //if(oldModel.verifyStatus!= (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes&& entity.verifyStatus== (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | //{ |
| | | // var allConfigs = await _coreCmsSettingServices.GetConfigDictionaries(); |
| | | // var kc = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.DictionaryUserGroupKey); |
| | | // var group = await _userGradeServices.GetUserGradeByValueKey(kc); |
| | | |
| | | // //如果是通过审核 |
| | | // oldModel.verifyTime = DateTime.Now; |
| | | //} |
| | | //else |
| | | // if(oldModel.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes && entity.verifyStatus != (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | //{ |
| | | // //如果是取消审核 |
| | | |
| | | //} |
| | | //oldModel.verifyStatus = entity.verifyStatus; |
| | | //oldModel.updateTime = DateTime.Now; |
| | | ////if (oldModel.verifyStatus == (int)GlobalEnumVars.DistributionVerifyStatus.VerifyYes) |
| | | ////{ |
| | | //// oldModel.verifyTime = DateTime.Now; |
| | | ////} |
| | | |
| | | ////事物处理过程结束 |
| | | //var bl = await _coreCmsDistributionServices.UpdateAsync(oldModel); |
| | | //jm.code = bl ? 0 : 1; |
| | | //jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; |
| | | |
| | | //return jm; |
| | | } |
| | | |
| | | #endregion |