作者 yangfu

共创统计模块

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"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
6 ) 8 )
7 9
8 // 企业端分红服务 10 // 企业端分红服务
@@ -10,14 +12,14 @@ type CompanyDividendsService struct { @@ -10,14 +12,14 @@ type CompanyDividendsService struct {
10 } 12 }
11 13
12 // GetDividendContracts 企业的合约列表(分红信息按合约划分) 14 // GetDividendContracts 企业的合约列表(分红信息按合约划分)
13 -func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (interface{}, error) {  
14 - //var items []*dto.CompanyContractDividendDto  
15 - //for i := 0; i < 2; i++ {  
16 - // item := dto.NewCompanyContractDividendDto()  
17 - // item.LoadDto()  
18 - // items = append(items, item)  
19 - //}  
20 - return struct{}{}, nil 15 +func (srv CompanyStatisticsService) GetDividendContracts(cmd *command.GetDividendContractsCommand) (interface{}, error) {
  16 + gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
  17 + cmd.Operator)
  18 + result, err := gateway.CooperationStatistics(allied_creation_cooperation.SearchContractDividends, cmd)
  19 + if err != nil {
  20 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  21 + }
  22 + return result, nil
21 } 23 }
22 24
23 // GetDividendContracts 企业的合约列表(分红信息按合约划分) 25 // GetDividendContracts 企业的合约列表(分红信息按合约划分)
@@ -77,8 +77,10 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi @@ -77,8 +77,10 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
77 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 77 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
78 } 78 }
79 return map[string]interface{}{ 79 return map[string]interface{}{
80 - "list": resultMenu,  
81 - "sum": 6000, 80 + "grid": map[string]interface{}{
  81 + "list": resultMenu.Grid.List,
  82 + "sum": 6000,
  83 + },
82 }, nil 84 }, nil
83 } 85 }
84 86
  1 +package allied_creation_cooperation
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
  9 +)
  10 +
  11 +const (
  12 + // 合约分红列表查询
  13 + SearchContractDividends = "ContractDividends"
  14 +)
  15 +
  16 +// CooperationStatistics 共创统计
  17 +func (gateway HttplibAlliedCreationCooperation) CooperationStatistics(action string, queryOptions interface{}) (interface{}, error) {
  18 + url := gateway.baseUrL + "/cooperation-statistics"
  19 + method := "post"
  20 + req := gateway.CreateRequest(url, method)
  21 + log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
  22 + "api": method + ":" + url,
  23 + "param": queryOptions,
  24 + })
  25 + param := map[string]interface{}{
  26 + "action": action,
  27 + "queryOptions": queryOptions,
  28 + }
  29 + req, err := req.JSONBody(param)
  30 + if err != nil {
  31 + return nil, fmt.Errorf("请求共创统计失败:%w", err)
  32 + }
  33 +
  34 + byteResult, err := req.Bytes()
  35 + if err != nil {
  36 + return nil, fmt.Errorf("获取共创统计失败:%w", err)
  37 + }
  38 + log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
  39 + "result": string(byteResult),
  40 + })
  41 + var result service_gateway.GatewayResponse
  42 + err = json.Unmarshal(byteResult, &result)
  43 + if err != nil {
  44 + return nil, fmt.Errorf("解析共创统计:%w", err)
  45 + }
  46 + var data map[string]interface{}
  47 + err = gateway.GetResponseData(result, &data)
  48 + return &data, err
  49 +}
@@ -364,6 +364,7 @@ func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateB @@ -364,6 +364,7 @@ func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateB
364 //UserUpdateBaseInfo 返回用户有权限的菜单 364 //UserUpdateBaseInfo 返回用户有权限的菜单
365 func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenus) (*DataUserAccessMenus, error) { 365 func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenus) (*DataUserAccessMenus, error) {
366 url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/access-menus") 366 url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/access-menus")
  367 + url += fmt.Sprintf("?menuCategory=%v&&allDisableMenu=%v", param.MenuCategory, param.ALLDisableMenu)
367 method := "get" 368 method := "get"
368 req := gateway.CreateRequest(url, method) 369 req := gateway.CreateRequest(url, method)
369 //TODO traceID 370 //TODO traceID