public static async Task <int> SubmitZeroActivityApplicationAsync(ZeroActivityRequest requestModel) { try { var activityDetail = await FetchZeroActivityDetailAsync(requestModel.Period); if (activityDetail == null) { return(-2); } else if (activityDetail.StatusOfActivity != 1) { return(-3); } else if (activityDetail.PID == null || activityDetail.ProductName == null) { return(-4); } if (await DalZeroActivity.HasZeroActivityApplicationSubmittedAsync(requestModel.UserId, requestModel.Period)) { return(-1); } string userMobile = ""; using (var uClient = new UserAccountClient()) { var result = await uClient.GetUserByIdAsync(requestModel.UserId); if (result.Success && !string.IsNullOrWhiteSpace(result.Result?.MobileNumber) && result.Result.MobileNumber.Length <= 30) { userMobile = result.Result.MobileNumber; } } var count = await DalZeroActivity.SubmitZeroActivityApplicationAsync(requestModel, activityDetail, userMobile); if (count > 0) { var actionQueueDic = new Dictionary <string, string>(); actionQueueDic["UserId"] = requestModel.UserId.ToString("B"); actionQueueDic["ActionName"] = "12PublicTest"; TuhuNotification.SendNotification("notification.TaskActionQueue", actionQueueDic); using (var client = CacheHelper.CreateCacheClient(DefaultClientName)) { var existenceResult = await client.ExistsAsync(GlobalConstant.MyZeroApplyApplications + requestModel.UserId.ToString("B") + "/0/"); if (existenceResult.Success) { var removeResult = await client.RemoveAsync(GlobalConstant.MyZeroApplyApplications + requestModel.UserId.ToString("B") + "/0/"); if (!removeResult.Success) { Logger.Warn($"删除用户众测申请列表(申请中)缓存redis失败MyZeroApplyApplications:{GlobalConstant.MyZeroApplyApplications + requestModel.UserId.ToString("B") + "/0/"};Error:{removeResult.Message}", removeResult.Exception); } } } } return(count); } catch (Exception ex) { Logger.ErrorException("SubmitZeroActivityApplication逻辑进行中出现异常", ex); return(0); } }
public static async Task <bool> HasZeroActivityApplicationSubmittedAsync(Guid userId, int period) { return(await DalZeroActivity.HasZeroActivityApplicationSubmittedAsync(userId, period)); }