/// <summary> /// 用户绑定 /// </summary> public IActionResult BindUser(string code, string state) { //Logger.InfoFormat("code:{0} state:{1}", code, state); //var oauth = _weChatOAuthAppService.GetAccessTokenAsync(code).Result; //存储openId 避免重复提交 SetUserOpenId(code); var tenantId = GetTenantId(); //var openid = "C9E6F8A3-6A08-418A-A258-0ABCBEC17573"; var user = _weChatUserAppService.GetWeChatUserAsync(UserOpenId, tenantId).Result; if (user == null) { user = new WeChatUserListDto(); } //var wuser = _weChatOAuthAppService.GetUserInfoAsync(oauth.access_token, oauth.openid).Result; user.NickName = user.NickName; //user.HeadImgUrl = wuser.headimgurl; if (user.UserType == UserTypeEnum.零售客户 || user.UserType == UserTypeEnum.内部员工) { var formCount = _activityFormAppService.GetActivityFormCountByUserAsync(user).Result; ViewBag.OutstandingCount = formCount.OutstandingCount; ViewBag.CompletedCount = formCount.CompletedCount; user.HeadImgUrl = user.HeadImgUrl ?? "static/img/index/timg-4.jpeg"; return(View("UserIndex", user)); } ViewBag.NickName = user.NickName; ViewBag.OpenId = UserOpenId; ViewBag.TenantId = tenantId; var root = _appConfiguration["App:ServerRootAddress"]; ViewBag.ServerRootAddress = root; //var url = root + "YiBinWX/BindUser"; //ViewBag.Url = _weChatOAuthAppService.GetAuthorizeUrl(url, tenantId.ToString(), Senparc.Weixin.MP.OAuthScope.snsapi_base); //Logger.InfoFormat("Url:{0}", ViewBag.Url); return(View()); }
public async Task <ActivityFormCountDto> GetActivityFormCountByUserAsync(WeChatUserListDto user) { using (CurrentUnitOfWork.SetTenantId(user.TenantId)) { ActivityFormCountDto countDto = new ActivityFormCountDto(); switch (user.UserType) { case UserTypeEnum.零售客户: { countDto.OutstandingCount = await _activityformRepository.GetAll() .Where(a => a.CreationId == user.UserId) .Where(a => a.Status == FormStatusEnum.提交申请 || a.Status == FormStatusEnum.初审通过 || a.Status == FormStatusEnum.资料回传已审核).CountAsync(); countDto.CompletedCount = await _activityformRepository.GetAll().Where(a => a.CreationId == user.UserId && a.Status == FormStatusEnum.营销中心已审核).CountAsync(); } break; case UserTypeEnum.内部员工: { countDto.OutstandingCount = await _activityformRepository.GetAll() .Where(a => a.ManagerId == user.UserId) .Where(a => a.Status == FormStatusEnum.提交申请 || a.Status == FormStatusEnum.初审通过 || a.Status == FormStatusEnum.资料回传已审核).CountAsync(); countDto.CompletedCount = await _activityformRepository.GetAll().Where(a => a.ManagerId == user.UserId && a.Status == FormStatusEnum.营销中心已审核).CountAsync(); } break; default: break; } return(countDto); } }
public async Task <ActivityFormForWechat> GetActivityFormList(bool check, WeChatUserListDto user) { using (CurrentUnitOfWork.SetTenantId(user.TenantId)) { var query = _activityformRepository.GetAll() .WhereIf(user.UserType == UserTypeEnum.内部员工, a => a.ManagerId == user.UserId) .WhereIf(user.UserType == UserTypeEnum.零售客户, a => a.CreationId == user.UserId) .WhereIf(check, a => a.Status == FormStatusEnum.营销中心已审核) .WhereIf(!check, a => a.Status == FormStatusEnum.初审通过 || a.Status == FormStatusEnum.提交申请 || a.Status == FormStatusEnum.资料回传已审核) .OrderByDescending(a => a.CreationTime); ActivityFormForWechat result = new ActivityFormForWechat(); if (check) { result.ActivityFormListDtos = query.Take(30).MapTo <List <ActivityFormListDto> >(); } else { result.ActivityFormListDtos = query.MapTo <List <ActivityFormListDto> >(); } result.Count = await query.CountAsync(); return(result.MapTo <ActivityFormForWechat>()); } }