/// <summary> /// 获取用户的问卷链接信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <OperationResult <string> > GetQuestionnaireURLAsync(Models.Requests.GetQuestionnaireURLRequest model) { if (model.QuestionnaireType < 2)//售后问卷 { if (model.ComplaintsID <= 0) { return(OperationResult.FromError <string>(nameof(Resource.ParameterError_ComplaintsID_NotNull), Resource.ParameterError_ComplaintsID_NotNull)); } if (string.IsNullOrEmpty(model.Department)) { return(OperationResult.FromError <string>(nameof(Resource.ParameterError_Department_NotNull), Resource.ParameterError_Department_NotNull)); } } else if (model.QuestionnaireType == 2) //售前问卷 { if (model.OrderID <= 0) { return(OperationResult.FromError <string>(nameof(Resource.ParameterError_OrderID_NotNull), Resource.ParameterError_OrderID_NotNull)); } if (string.IsNullOrEmpty(model.UserPhone)) { return(OperationResult.FromError <string>(nameof(Resource.ParameterError_UserPhone_NotNull), Resource.ParameterError_UserPhone_NotNull)); } if (string.IsNullOrEmpty(model.StaffEmail)) { return(OperationResult.FromError <string>(nameof(Resource.ParameterError_StaffEmail_NotNull), Resource.ParameterError_StaffEmail_NotNull)); } } if (model.UserID == Guid.Empty) { return(OperationResult.FromError <string>(nameof(Resource.ParameterError_UserID_NotNull), Resource.ParameterError_UserID_NotNull)); } return(await QuestionnaireManager.GetQuestionnaireURLAsync(model)); }
/// <summary> /// 获取用户的问卷链接信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static async Task <OperationResult <string> > GetQuestionnaireURLAsync(Models.Requests.GetQuestionnaireURLRequest model) { //AutoMapper初始化配置文件 var config = new MapperConfiguration(cfg => { cfg.CreateMap <Models.Requests.GetQuestionnaireURLRequest, UserQuestionnaireURLModel>(); }); var mapper = config.CreateMapper(); int objectId = 0;//业务对象ID UserQuestionnaireURLModel userModel = mapper.Map <UserQuestionnaireURLModel>(model); userModel.PageID = Guid.NewGuid(); userModel.OriginalURL = ConfigurationManager.AppSettings["QuestionnaireURL"].ToString() + "pageId=" + userModel.PageID; if (model.QuestionnaireType < 2)//售后问卷 { //获取问卷和定责部门关系信息 var mappingInfo = await DalQuestionnaireDptMapping.GetQuestionnaireDptMappingInfo(userModel.Department, userModel.ComplaintsType, userModel.IsAtStore); if (mappingInfo != null) { userModel.QuestionnaireNo = mappingInfo.QuestionnaireNo; } else { return(OperationResult.FromError <string>(nameof(Resource.Error_GetQuestionnaireURL_Failure), string.Format(Resource.Error_GetQuestionnaireURL_Failure))); } objectId = model.ComplaintsID; } else if (model.QuestionnaireType == 2)//售前问卷 { var questionnaireInfo = await DalQuestionnaire.GetQuestionnaireInfoByType(model.QuestionnaireType); userModel.QuestionnaireNo = questionnaireInfo.QuestionnaireNo; objectId = model.OrderID.Value; } //获取短连接 using (var client = new UtilityClient()) { var shortUrlResult = await client.GetTuhuDwzAsync(userModel.OriginalURL, "投诉问卷"); if (shortUrlResult.Success) { userModel.ShortURL = shortUrlResult.Result; } else { return(OperationResult.FromError <string>(nameof(Resource.Error_GetQuestionnaireURL_Failure), string.Format(Resource.Error_GetQuestionnaireURL_Failure))); } } //删除重复问卷答题记录和获取问卷记录 await QuestionnaireManager.DelExistRecord(model.UserID, objectId, model.QuestionnaireType); int result = await DalUserQuestionnaireURL.AddUserQuestionnaireURL(userModel); if (result > 0) { return(OperationResult.FromResult(userModel.ShortURL)); } return(OperationResult.FromError <string>(nameof(Resource.Error_GetQuestionnaireURL_Failure), string.Format(Resource.Error_GetQuestionnaireURL_Failure))); }