作者 yangfu

共创统计修改

@@ -11,7 +11,7 @@ type EndCooperationProjectCommand struct { @@ -11,7 +11,7 @@ type EndCooperationProjectCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 共创项目id 13 // 共创项目id
14 - CooperationProjectId []int `json:"cooperationProjectId,omitempty"` 14 + CooperationProjectId int `json:"cooperationProjectId,omitempty"`
15 } 15 }
16 16
17 func (endCooperationProjectCommand *EndCooperationProjectCommand) Valid(validation *validation.Validation) { 17 func (endCooperationProjectCommand *EndCooperationProjectCommand) Valid(validation *validation.Validation) {
@@ -9,7 +9,7 @@ import ( @@ -9,7 +9,7 @@ import (
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
10 ) 10 )
11 11
12 -// CooperationProjectService 共创项目服务 【完成 12 +// CooperationProjectService 共创项目服务 【90%
13 type CooperationProjectService struct { 13 type CooperationProjectService struct {
14 } 14 }
15 15
@@ -69,21 +69,19 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP @@ -69,21 +69,19 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP
69 return updateCooperationProjectCommand, nil 69 return updateCooperationProjectCommand, nil
70 } 70 }
71 71
72 -// EndCooperationProject 企业结束共创项目 72 +// EndCooperationProject TODO:企业结束共创项目
73 func (srv CooperationProjectService) EndCooperationProject(endCooperationProjectCommand *command.EndCooperationProjectCommand) (interface{}, error) { 73 func (srv CooperationProjectService) EndCooperationProject(endCooperationProjectCommand *command.EndCooperationProjectCommand) (interface{}, error) {
74 - creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator) 74 + //creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
75 var projectIds []string 75 var projectIds []string
76 - for _, v := range endCooperationProjectCommand.CooperationProjectId {  
77 - idStr := strconv.Itoa(v) 76 + idStr := strconv.Itoa(endCooperationProjectCommand.CooperationProjectId)
78 projectIds = append(projectIds, idStr) 77 projectIds = append(projectIds, idStr)
79 - }  
80 - _, err := creationCooperationGateway.CooperationProjectBatchEnd(allied_creation_cooperation.ReqCooperationProjectBatchEnd{  
81 - CooperationProjectIds: projectIds,  
82 - })  
83 - if err != nil {  
84 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
85 - }  
86 - return endCooperationProjectCommand, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 78 + //_, err := creationCooperationGateway.CooperationProjectBatchEnd(allied_creation_cooperation.ReqCooperationProjectBatchEnd{
  79 + // CooperationProjectIds: projectIds,
  80 + //})
  81 + //if err != nil {
  82 + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  83 + //}
  84 + return endCooperationProjectCommand, nil
87 } 85 }
88 86
89 // SearchCooperationProject 企业获取共创项目列表 87 // SearchCooperationProject 企业获取共创项目列表
@@ -31,7 +31,7 @@ func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.Go @@ -31,7 +31,7 @@ func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.Go
31 return map[string]interface{}{}, nil 31 return map[string]interface{}{}, nil
32 } 32 }
33 33
34 -// CooperationDividendsStatistics TODO:共创分红支出统计 34 +// CooperationDividendsStatistics TODO:公司共创人员列表(分红支出统计)
35 func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) { 35 func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) {
36 return map[string]interface{}{}, nil 36 return map[string]interface{}{}, nil
37 } 37 }
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "github.com/linmadan/egglib-go/core/application"
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
5 ) 7 )
6 8
7 // 个人端统计 【0%】 9 // 个人端统计 【0%】
@@ -65,7 +67,16 @@ func (srv PersonStatisticsService) CompanyDividendStatistics(userMenusCommand *c @@ -65,7 +67,16 @@ func (srv PersonStatisticsService) CompanyDividendStatistics(userMenusCommand *c
65 return map[string]interface{}{}, nil 67 return map[string]interface{}{}, nil
66 } 68 }
67 69
68 -// CooperationProjectRecommend 猜你喜欢(共创项目)  
69 -func (srv PersonStatisticsService) CooperationProjectRecommend(userMenusCommand *command.GoodsStatisticsCommand) (interface{}, error) {  
70 - return map[string]interface{}{}, nil 70 +// CooperationProjectRecommend TODO:其他公司按公开的项目查 猜你喜欢(共创项目)
  71 +func (srv PersonStatisticsService) CooperationProjectRecommend(projectQuery *command.ListCooperationProjectQuery) (int64, interface{}, error) {
  72 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
  73 + projectQuery.Operator)
  74 + result, err := creationCooperationGateway.CooperationProjectsSearch(allied_creation_cooperation.ReqCooperationProjectSearch{
  75 + PageNumber: projectQuery.PageNumber,
  76 + PageSize: projectQuery.PageSize,
  77 + })
  78 + if err != nil {
  79 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  80 + }
  81 + return int64(result.Total), result.List, nil
71 } 82 }
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/beego/beego/v2/core/validation"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 +)
  8 +
  9 +//标记已读
  10 +type MessageMarkReadCommand struct {
  11 + Operator domain.Operator `json:"-"`
  12 + MsgId int `json:"msgId"`
  13 + ReadAll int `json:"readAll"`
  14 +}
  15 +
  16 +func (cmd *MessageMarkReadCommand) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (cmd *MessageMarkReadCommand) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(cmd)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
@@ -166,10 +166,15 @@ func (srv UserService) DepartmentsUsers(departmentsUsersQuery *query.Departments @@ -166,10 +166,15 @@ func (srv UserService) DepartmentsUsers(departmentsUsersQuery *query.Departments
166 } 166 }
167 167
168 //MessagesList 消息列表 168 //MessagesList 消息列表
169 -func (srv UserService) MessagesList(messagesListQuery *query.MessagesListQuery) (int64, interface{}, error) { 169 +func (srv UserService) MessagesList(cmd *query.MessagesListQuery) (int64, interface{}, error) {
170 var results []*dto.MessageDto 170 var results []*dto.MessageDto
171 for i := 0; i < 5; i++ { 171 for i := 0; i < 5; i++ {
172 results = append(results, dto.NewMessageDto()) 172 results = append(results, dto.NewMessageDto())
173 } 173 }
174 return 2, results, nil 174 return 2, results, nil
175 } 175 }
  176 +
  177 +//MessagesList 消息列表
  178 +func (srv UserService) MessagesMarkRead(cmd *command.MessageMarkReadCommand) (interface{}, error) {
  179 + return struct{}{}, nil
  180 +}
1 package dto 1 package dto
2 2
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  6 +)
  7 +
3 type OrgItem struct { 8 type OrgItem struct {
4 OrgId string `json:"orgId"` 9 OrgId string `json:"orgId"`
5 OrgName string `json:"orgName"` 10 OrgName string `json:"orgName"`
@@ -9,3 +14,71 @@ type OrgItem struct { @@ -9,3 +14,71 @@ type OrgItem struct {
9 ParentDepName string `json:"parentDepName"` 14 ParentDepName string `json:"parentDepName"`
10 OrgStatus int `json:"orgStatus"` 15 OrgStatus int `json:"orgStatus"`
11 } 16 }
  17 +
  18 +type DepartmentUsersDto struct {
  19 + Departments []*Department `json:"departments,omitempty"`
  20 + Users []interface{} `json:"users,omitempty"`
  21 +}
  22 +
  23 +type Department struct {
  24 + DepartmentID int64 `json:"departmentId,string"`
  25 + DepartmentName string `json:"departmentName"`
  26 + Users []User `json:"users"`
  27 +}
  28 +
  29 +type User struct {
  30 + UserID int `json:"userId,string"`
  31 + UserCode string `json:"userCode"`
  32 + UserInfo map[string]interface{} `json:"userInfo"`
  33 +}
  34 +
  35 +func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
  36 + if dataType == 1 {
  37 + for i := range userSearch.Users {
  38 + user := userSearch.Users[i]
  39 + dto.Users = append(dto.Users, map[string]interface{}{
  40 + "userId": user.UserId,
  41 + "userInfo": user.UserInfo,
  42 + "department": user.Department,
  43 + })
  44 + }
  45 + return nil
  46 + }
  47 + var mapDepartment = make(map[int64]*Department)
  48 + mapDepartment[-1] = &Department{
  49 + DepartmentID: -1,
  50 + DepartmentName: "共创部门",
  51 + Users: make([]User, 0),
  52 + }
  53 +
  54 + for i := range subDepartment.Orgs {
  55 + org := subDepartment.Orgs[i]
  56 + dep := &Department{
  57 + DepartmentID: int64(org.OrgID),
  58 + DepartmentName: org.OrgName,
  59 + Users: make([]User, 0),
  60 + }
  61 + dto.Departments = append(dto.Departments, dep)
  62 + mapDepartment[dep.DepartmentID] = dep
  63 + }
  64 +
  65 + for i := range userSearch.Users {
  66 + user := userSearch.Users[i]
  67 + u := User{
  68 + UserID: user.UserId,
  69 + UserCode: user.UserCode,
  70 + UserInfo: map[string]interface{}{
  71 + "userName": user.UserInfo.UserName,
  72 + "phone": user.UserInfo.Phone,
  73 + },
  74 + }
  75 + if (user.UserType & domain.UserTypeCooperation) > 0 {
  76 + mapDepartment[-1].Users = append(mapDepartment[-1].Users, u)
  77 + continue
  78 + }
  79 + if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
  80 + v.Users = append(v.Users, u)
  81 + }
  82 + }
  83 + return nil
  84 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/beego/beego/v2/core/validation"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 +)
  8 +
  9 +//获取自定义菜单列表
  10 +type DepartmentsUsersQuery struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 + // 类型0:部门用户列表 1:全部用户列表(不包含部门)
  14 + Type int `json:"type"`
  15 +}
  16 +
  17 +func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
  18 +
  19 +}
  20 +
  21 +func (departmentsUsersQuery *DepartmentsUsersQuery) ValidateQuery() error {
  22 + valid := validation.Validation{}
  23 + b, err := valid.Valid(departmentsUsersQuery)
  24 + if err != nil {
  25 + return err
  26 + }
  27 + if !b {
  28 + for _, validErr := range valid.Errors {
  29 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  30 + }
  31 + }
  32 + return nil
  33 +}
@@ -148,6 +148,31 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub @@ -148,6 +148,31 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub
148 }, nil 148 }, nil
149 } 149 }
150 150
  151 +//DepartmentsUsers 部门用户列表
  152 +func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsUsersQuery) (interface{}, error) {
  153 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  154 + departmentsUsersQuery.Operator)
  155 + orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{
  156 + OrgId: departmentsUsersQuery.Operator.OrgId,
  157 + })
  158 + if err != nil {
  159 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  160 + }
  161 +
  162 + users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  163 + CompanyId: departmentsUsersQuery.Operator.CompanyId,
  164 + OrganizationId: departmentsUsersQuery.Operator.OrgId,
  165 + })
  166 + if err != nil {
  167 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  168 + }
  169 + departmentUsersDto := &dto.DepartmentUsersDto{}
  170 + if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil {
  171 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  172 + }
  173 + return departmentUsersDto, nil
  174 +}
  175 +
151 func NewOrgsService(options map[string]interface{}) *OrgsService { 176 func NewOrgsService(options map[string]interface{}) *OrgsService {
152 newOrgsService := &OrgsService{} 177 newOrgsService := &OrgsService{}
153 return newOrgsService 178 return newOrgsService
@@ -555,13 +555,13 @@ func (controller *CooperationController) PersonCompanyDividendStatistics() { @@ -555,13 +555,13 @@ func (controller *CooperationController) PersonCompanyDividendStatistics() {
555 555
556 func (controller *CooperationController) PersonCooperationProjectRecommend() { 556 func (controller *CooperationController) PersonCooperationProjectRecommend() {
557 svr := service.PersonStatisticsService{} 557 svr := service.PersonStatisticsService{}
558 - cmd := &command.GoodsStatisticsCommand{} 558 + cmd := &command.ListCooperationProjectQuery{}
559 err := controller.Unmarshal(cmd) 559 err := controller.Unmarshal(cmd)
560 if err != nil { 560 if err != nil {
561 controller.Response(nil, err) 561 controller.Response(nil, err)
562 return 562 return
563 } 563 }
564 cmd.Operator = controller.GetOperator() 564 cmd.Operator = controller.GetOperator()
565 - data, err := svr.CooperationProjectRecommend(cmd)  
566 - controller.Response(data, err) 565 + total, data, err := svr.CooperationProjectRecommend(cmd)
  566 + controller.ReturnPageListData(total, data, err, cmd.PageNumber)
567 } 567 }
@@ -111,3 +111,16 @@ func (controller *UserController) Messages() { @@ -111,3 +111,16 @@ func (controller *UserController) Messages() {
111 total, data, err := svr.MessagesList(messagesListQuery) 111 total, data, err := svr.MessagesList(messagesListQuery)
112 controller.ReturnPageListData(total, data, err, messagesListQuery.PageNumber) 112 controller.ReturnPageListData(total, data, err, messagesListQuery.PageNumber)
113 } 113 }
  114 +
  115 +func (controller *UserController) MessagesMarkRead() {
  116 + svr := service.UserService{}
  117 + cmd := &command.MessageMarkReadCommand{}
  118 + err := controller.Unmarshal(cmd)
  119 + if err != nil {
  120 + controller.Response(nil, err)
  121 + return
  122 + }
  123 + cmd.Operator = controller.GetOperator()
  124 + data, err := svr.MessagesMarkRead(cmd)
  125 + controller.Response(data, err)
  126 +}
  1 +package web_client
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/query"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/orgs/service"
  6 +)
  7 +
  8 +type OrgController struct {
  9 + baseController
  10 +}
  11 +
  12 +func (controller *OrgController) DepartmentUsers() {
  13 + orgService := service.OrgsService{}
  14 + departmentsUsersQuery := &query.DepartmentsUsersQuery{}
  15 + err := controller.Unmarshal(departmentsUsersQuery)
  16 + if err != nil {
  17 + controller.Response(nil, err)
  18 + return
  19 + }
  20 + departmentsUsersQuery.Operator = controller.GetOperator()
  21 + data, err := orgService.DepartmentsUsers(departmentsUsersQuery)
  22 + controller.Response(data, err)
  23 +}
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
7 ) 8 )
8 9
9 func init() { 10 func init() {
@@ -19,9 +20,9 @@ func init() { @@ -19,9 +20,9 @@ func init() {
19 web.Router("/v1/user/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount") 20 web.Router("/v1/user/destroy-account", &mobile_client.UserController{}, "Post:DestroyAccount")
20 web.Router("/v1/user/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") 21 web.Router("/v1/user/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers")
21 web.Router("/v1/user/msgs", &mobile_client.UserController{}, "Post:Messages") 22 web.Router("/v1/user/msgs", &mobile_client.UserController{}, "Post:Messages")
22 - web.Router("/v1/user/msgs/mark-read", &mobile_client.UserController{}, "Post:Messages") 23 + web.Router("/v1/user/msgs/mark-read", &mobile_client.UserController{}, "Post:MessagesMarkRead")
23 24
24 // 特殊处理 25 // 特殊处理
25 web.Router("/v1/app/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") 26 web.Router("/v1/app/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers")
26 - web.Router("/v1/web/orgs/department-users", &mobile_client.UserController{}, "Post:DepartmentUsers") 27 + web.Router("/v1/web/orgs/department-users", &web_client.OrgController{}, "Post:DepartmentUsers")
27 } 28 }