作者 yangfu

个人统计修改

@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
9 ) 9 )
10 10
11 -// CooperationApplicationsService 共创申请服务 【80%】 11 +// CooperationApplicationsService 共创申请服务 【100%】
12 type CooperationApplicationsService struct { 12 type CooperationApplicationsService struct {
13 } 13 }
14 14
@@ -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 共创项目服务 【90%】 12 +// CooperationProjectService 共创项目服务 【100%】
13 type CooperationProjectService struct { 13 type CooperationProjectService struct {
14 } 14 }
15 15
@@ -69,18 +69,18 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP @@ -69,18 +69,18 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP
69 return updateCooperationProjectCommand, nil 69 return updateCooperationProjectCommand, nil
70 } 70 }
71 71
72 -// EndCooperationProject TODO:企业结束共创项目 72 +// EndCooperationProject 企业结束共创项目
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)  
75 - var projectIds []string 74 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(endCooperationProjectCommand.Operator)
  75 + //var projectIds []string
76 idStr := strconv.Itoa(endCooperationProjectCommand.CooperationProjectId) 76 idStr := strconv.Itoa(endCooperationProjectCommand.CooperationProjectId)
77 - projectIds = append(projectIds, idStr)  
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 - //} 77 + //projectIds = append(projectIds, idStr)
  78 + _, err := creationCooperationGateway.CooperationProjectEnd(allied_creation_cooperation.ReqCooperationProjectEnd{
  79 + CooperationProjectId: idStr,
  80 + })
  81 + if err != nil {
  82 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  83 + }
84 return endCooperationProjectCommand, nil 84 return endCooperationProjectCommand, nil
85 } 85 }
86 86
@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "fmt" 4 "fmt"
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
7 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"  
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
@@ -18,11 +17,6 @@ type CompanyStatisticsService struct { @@ -18,11 +17,6 @@ type CompanyStatisticsService struct {
18 17
19 // IndexStatistics 首页统计 (入口页面统计数据) 18 // IndexStatistics 首页统计 (入口页面统计数据)
20 func (srv CompanyStatisticsService) IndexStatistics(cmd *command.IndexStatisticsCommand) (interface{}, error) { 19 func (srv CompanyStatisticsService) IndexStatistics(cmd *command.IndexStatisticsCommand) (interface{}, error) {
21 - value := dto.IndexStatistics{}  
22 - value.ProjectOverviewStatistics.ContractSum = 20  
23 - value.ProjectOverviewStatistics.CooperationUserCount = 5  
24 - value.ProjectOverviewStatistics.ProjectSum = 5  
25 -  
26 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation( 20 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
27 cmd.Operator) 21 cmd.Operator)
28 companyDividendsStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyDividendsStatistics, map[string]interface{}{ 22 companyDividendsStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyDividendsStatistics, map[string]interface{}{
@@ -71,6 +65,8 @@ func (srv CompanyStatisticsService) IndexStatistics(cmd *command.IndexStatistics @@ -71,6 +65,8 @@ func (srv CompanyStatisticsService) IndexStatistics(cmd *command.IndexStatistics
71 contracts, err := gateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{ 65 contracts, err := gateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
72 PageNumber: 1, 66 PageNumber: 1,
73 PageSize: 1, 67 PageSize: 1,
  68 + CompanyId: cmd.Operator.CompanyId,
  69 + OrgId: cmd.Operator.OrgId,
74 }) 70 })
75 if err != nil { 71 if err != nil {
76 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 72 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -3,7 +3,9 @@ package service @@ -3,7 +3,9 @@ package service
3 import ( 3 import (
4 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
5 "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/domain"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
7 ) 9 )
8 10
9 // 个人端统计 【0%】 11 // 个人端统计 【0%】
@@ -11,27 +13,65 @@ type PersonStatisticsService struct { @@ -11,27 +13,65 @@ type PersonStatisticsService struct {
11 } 13 }
12 14
13 // IndexStatistics TODO:个人端 - 首页统计 (入口页面统计数据) 15 // IndexStatistics TODO:个人端 - 首页统计 (入口页面统计数据)
14 -func (srv PersonStatisticsService) IndexStatistics(userMenusCommand *command.IndexStatisticsCommand) (interface{}, error) {  
15 - //creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(  
16 - // userMenusCommand.Operator)  
17 - //resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{  
18 - // UserId: int(userMenusCommand.Operator.UserId),  
19 - //})  
20 - //if err != nil {  
21 - // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
22 - //} 16 +func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsCommand) (interface{}, error) {
  17 + gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
  18 + cmd.Operator)
  19 + // 项目概览统计
  20 + contracts, err := gateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
  21 + PageNumber: 1,
  22 + PageSize: 1,
  23 + UserBaseId: cmd.Operator.UserBaseId,
  24 + })
  25 + if err != nil {
  26 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  27 + }
  28 + // 项目概览统计
  29 + stoppedContracts, err := gateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
  30 + PageNumber: 1,
  31 + PageSize: 1,
  32 + Status: 2,
  33 + UserBaseId: cmd.Operator.UserBaseId,
  34 + })
  35 + if err != nil {
  36 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  37 + }
  38 + gatewayUser := allied_creation_user.NewHttplibAlliedCreationUser(
  39 + cmd.Operator)
  40 + users, err := gatewayUser.UserSearch(allied_creation_user.ReqUserSearch{
  41 + Limit: 1,
  42 + Offset: 0,
  43 + UserType: domain.UserTypeCooperation,
  44 + UserBaseId: cmd.Operator.UserBaseId,
  45 + })
  46 + if err != nil {
  47 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  48 + }
  49 + var overview = map[string]interface{}{
  50 + "contractSum": contracts.Grid.Total,
  51 + "contractStoppedSum": stoppedContracts.Grid.Total,
  52 + "companySum": users.Count,
  53 + }
23 return map[string]interface{}{ 54 return map[string]interface{}{
24 - "overview": map[string]interface{}{  
25 - "contractSum": 60,  
26 - "contractStoppedSum": 70,  
27 - "companySum": 6,  
28 - }, 55 + "overview": overview,
29 "dividendStatistics": map[string]interface{}{ 56 "dividendStatistics": map[string]interface{}{
30 "dividendAmount": 9000, 57 "dividendAmount": 9000,
31 "paidAmount": 2000, 58 "paidAmount": 2000,
32 "unPaidAmount": 7000, 59 "unPaidAmount": 7000,
33 }, 60 },
34 }, nil 61 }, nil
  62 +
  63 + //return map[string]interface{}{
  64 + // "overview": map[string]interface{}{
  65 + // "contractSum": 60,
  66 + // "contractStoppedSum": 70,
  67 + // "companySum": 6,
  68 + // },
  69 + // "dividendStatistics": map[string]interface{}{
  70 + // "dividendAmount": 9000,
  71 + // "paidAmount": 2000,
  72 + // "unPaidAmount": 7000,
  73 + // },
  74 + //}, nil
35 } 75 }
36 76
37 // CompanyStatistics 共创用户-共创企业统计 77 // CompanyStatistics 共创用户-共创企业统计
@@ -287,3 +287,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationProjectBatchEnd(param @@ -287,3 +287,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationProjectBatchEnd(param
287 err = gateway.GetResponseData(result, &data) 287 err = gateway.GetResponseData(result, &data)
288 return &data, err 288 return &data, err
289 } 289 }
  290 +
  291 +//CooperationProjectBatchEnd 批量结束共创项目
  292 +func (gateway HttplibAlliedCreationCooperation) CooperationProjectEnd(param ReqCooperationProjectEnd) (*DataCooperationProjectEnd, error) {
  293 + url := gateway.baseUrL + "/cooperation-projects/end"
  294 + method := "POST"
  295 + req := gateway.CreateRequest(url, method)
  296 + log.Logger.Debug("向业务模块请求数据:批量结束共创项目。", map[string]interface{}{
  297 + "api": method + ":" + url,
  298 + "param": param,
  299 + })
  300 + req, err := req.JSONBody(param)
  301 + if err != nil {
  302 + return nil, fmt.Errorf("请求批量结束共创项目失败:%w", err)
  303 + }
  304 +
  305 + byteResult, err := req.Bytes()
  306 + if err != nil {
  307 + return nil, fmt.Errorf("批量结束共创项目失败:%w", err)
  308 + }
  309 + log.Logger.Debug("获取业务模块请求数据:批量结束共创项目。", map[string]interface{}{
  310 + "result": string(byteResult),
  311 + })
  312 + var result service_gateway.GatewayResponse
  313 + err = json.Unmarshal(byteResult, &result)
  314 + if err != nil {
  315 + return nil, fmt.Errorf("解析批量结束共创项目:%w", err)
  316 + }
  317 + var data DataCooperationProjectEnd
  318 + err = gateway.GetResponseData(result, &data)
  319 + return &data, err
  320 +}
@@ -211,6 +211,13 @@ type ( @@ -211,6 +211,13 @@ type (
211 PageSize int `json:"pageSize"` 211 PageSize int `json:"pageSize"`
212 CooperationContractNumber string `json:"cooperationContractNumber"` //合约编号 212 CooperationContractNumber string `json:"cooperationContractNumber"` //合约编号
213 SponsorName string `json:"sponsorName"` //发起人名字 213 SponsorName string `json:"sponsorName"` //发起人名字
  214 + Status int `json:"status"`
  215 + // 公司ID,通过集成REST上下文获取
  216 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  217 + // 组织机构ID
  218 + OrgId int64 `cname:"组织机构ID" json:"orgId"`
  219 + // 用户基础数据id
  220 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId`
214 } 221 }
215 222
216 DataCooperationContractSearch struct { 223 DataCooperationContractSearch struct {
@@ -271,3 +271,13 @@ type ( @@ -271,3 +271,13 @@ type (
271 DataCooperationProjectBatchEnd struct { 271 DataCooperationProjectBatchEnd struct {
272 } 272 }
273 ) 273 )
  274 +
  275 +// 结束项目
  276 +type (
  277 + ReqCooperationProjectEnd struct {
  278 + CooperationProjectId string `json:"cooperationProjectId"`
  279 + }
  280 +
  281 + DataCooperationProjectEnd struct {
  282 + }
  283 +)