作者 yangfu

增加天联共创 企业端分红、首页统计

@@ -381,7 +381,8 @@ func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (inter @@ -381,7 +381,8 @@ func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (inter
381 Offset: 0, 381 Offset: 0,
382 Limit: 100, 382 Limit: 100,
383 UserBaseId: userOrgCommand.Operator.UserBaseId, 383 UserBaseId: userOrgCommand.Operator.UserBaseId,
384 - UserType: 1, 384 + UserType: domain.UserTypeEmployee,
  385 + EnableStatus: domain.UserStatusEnable,
385 PullRealTime: true, 386 PullRealTime: true,
386 }) 387 })
387 if err != nil { 388 if err != nil {
  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 +// Command
  10 +type DividendsStatisticsCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *DividendsStatisticsCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  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 +// Command
  10 +type GetDividendContractsCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *GetDividendContractsCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *GetDividendContractsCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  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 +// Command
  10 +type SearchDividendsEstimatesCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *SearchDividendsEstimatesCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *SearchDividendsEstimatesCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  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 +// Command
  10 +type CooperationDividendsStatisticsCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *CooperationDividendsStatisticsCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *CooperationDividendsStatisticsCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  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 +// Command
  10 +type CooperationPersonStatisticsCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *CooperationPersonStatisticsCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *CooperationPersonStatisticsCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  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 +// Command
  10 +type GoodsStatisticsCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *GoodsStatisticsCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *GoodsStatisticsCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  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 +// Command
  10 +type IndexStatisticsCommand struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (cmd *IndexStatisticsCommand) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (cmd *IndexStatisticsCommand) ValidateCommand() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(cmd)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  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_user"
  7 +)
  8 +
  9 +// 企业端分红服务
  10 +type CompanyDividendsService struct {
  11 +}
  12 +
  13 +// IndexStatistics TODO:企业的合约列表(分红信息按合约划分)
  14 +func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (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 + }
  23 + return map[string]interface{}{
  24 + "accessMenus": resultMenu.Menus,
  25 + }, nil
  26 +}
  27 +
  28 +// IndexStatistics TODO:企业的合约统计(分红统计)
  29 +func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
  30 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  31 + userMenusCommand.Operator)
  32 + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
  33 + UserId: int(userMenusCommand.Operator.UserId),
  34 + })
  35 + if err != nil {
  36 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  37 + }
  38 + return map[string]interface{}{
  39 + "accessMenus": resultMenu.Menus,
  40 + }, nil
  41 +}
  42 +
  43 +// IndexStatistics TODO:企业的合约明细列表(分红预算信息)
  44 +func (srv CompanyStatisticsService) SearchDividendsEstimates(userMenusCommand *command.SearchDividendsEstimatesCommand) (interface{}, error) {
  45 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  46 + userMenusCommand.Operator)
  47 + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
  48 + UserId: int(userMenusCommand.Operator.UserId),
  49 + })
  50 + if err != nil {
  51 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  52 + }
  53 + return map[string]interface{}{
  54 + "accessMenus": resultMenu.Menus,
  55 + }, nil
  56 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  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_user"
  7 +)
  8 +
  9 +// 企业端统计
  10 +type CompanyStatisticsService struct {
  11 +}
  12 +
  13 +// IndexStatistics TODO:首页统计 (入口页面统计数据)
  14 +func (srv CompanyStatisticsService) 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 + }
  23 + return map[string]interface{}{
  24 + "accessMenus": resultMenu.Menus,
  25 + }, nil
  26 +}
  27 +
  28 +// IndexStatistics TODO:共创人员统计(共创人员明细)
  29 +func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
  30 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  31 + userMenusCommand.Operator)
  32 + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
  33 + UserId: int(userMenusCommand.Operator.UserId),
  34 + })
  35 + if err != nil {
  36 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  37 + }
  38 + return map[string]interface{}{
  39 + "accessMenus": resultMenu.Menus,
  40 + }, nil
  41 +}
  42 +
  43 +// IndexStatistics TODO:产品统计排行榜 年月榜
  44 +func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.GoodsStatisticsCommand) (interface{}, error) {
  45 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  46 + userMenusCommand.Operator)
  47 + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
  48 + UserId: int(userMenusCommand.Operator.UserId),
  49 + })
  50 + if err != nil {
  51 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  52 + }
  53 + return map[string]interface{}{
  54 + "accessMenus": resultMenu.Menus,
  55 + }, nil
  56 +}
  57 +
  58 +// IndexStatistics TODO:共创分红支出统计
  59 +func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) {
  60 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  61 + userMenusCommand.Operator)
  62 + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
  63 + UserId: int(userMenusCommand.Operator.UserId),
  64 + })
  65 + if err != nil {
  66 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  67 + }
  68 + return map[string]interface{}{
  69 + "accessMenus": resultMenu.Menus,
  70 + }, nil
  71 +}
  1 +package domain
  2 +
  3 +/***** 1.用户模块 *****/
  4 +// 用户类型
  5 +const (
  6 + UserTypeEmployee = 1
  7 + UserTypeCooperation = 2
  8 + UserTypeCompanyAdmin = 1024
  9 +)
  10 +
  11 +// 用户状态
  12 +const (
  13 + UserStatusEnable int = 1
  14 + UserStatusDisable int = 2
  15 + UserStatusDestroy int = 3
  16 +)
  17 +
  18 +/***** 2.菜单模块 *****/
  19 +// 菜单启用状态 结合用户菜单权限
  20 +const (
  21 + MenuStatusEnable = 1 // 菜单启用
  22 + MenuStatusDisable = 2 // 菜单禁用
  23 +)
  24 +
  25 +// 菜单公开状态
  26 +const (
  27 + MenuPublic = 1 // 菜单公开
  28 + MenuPrivate = 2 // 菜单未公开
  29 +)
  30 +
  31 +const (
  32 + WebMenuCode = "web"
  33 + AppMenuCode = "app"
  34 +)
  35 +
  36 +/***** 3.组织模块 *****/
  37 +const (
  38 + IsOrgFlag = 1 // 标记为组织
  39 + IsNotOrgFlag = 2 // 标记为非组织
  40 +)
  41 +
  42 +const (
  43 + OrgStatusEnable = 1
  44 + OrgStatusDisable = 2
  45 +)
@@ -94,6 +94,8 @@ type ( @@ -94,6 +94,8 @@ type (
94 InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"` 94 InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"`
95 // 实时拉取数据 (获取最新的) 95 // 实时拉取数据 (获取最新的)
96 PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"` 96 PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"`
  97 + // 状态(1:启用 2:禁用 3:注销)
  98 + EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"`
97 } 99 }
98 100
99 //DataUserSearch 搜索用户列表 101 //DataUserSearch 搜索用户列表
  1 +package mobile_client
  2 +
  3 +import (
  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/service"
  6 +)
  7 +
  8 +// Controller
  9 +type CooperationController struct {
  10 + baseController
  11 +}
  12 +
  13 +/***** CompanyDividends 企业端分红 *****/
  14 +func (controller *CooperationController) GetDividendContracts() {
  15 + svr := service.CompanyStatisticsService{}
  16 + cmd := &command.GetDividendContractsCommand{}
  17 + err := controller.Unmarshal(cmd)
  18 + if err != nil {
  19 + controller.Response(nil, err)
  20 + return
  21 + }
  22 + cmd.Operator = controller.GetOperator()
  23 + data, err := svr.GetDividendContracts(cmd)
  24 + controller.Response(data, err)
  25 +}
  26 +
  27 +func (controller *CooperationController) DividendsStatistics() {
  28 + svr := service.CompanyStatisticsService{}
  29 + cmd := &command.DividendsStatisticsCommand{}
  30 + err := controller.Unmarshal(cmd)
  31 + if err != nil {
  32 + controller.Response(nil, err)
  33 + return
  34 + }
  35 + cmd.Operator = controller.GetOperator()
  36 + data, err := svr.DividendsStatistics(cmd)
  37 + controller.Response(data, err)
  38 +}
  39 +
  40 +func (controller *CooperationController) SearchDividendsEstimates() {
  41 + svr := service.CompanyStatisticsService{}
  42 + cmd := &command.SearchDividendsEstimatesCommand{}
  43 + err := controller.Unmarshal(cmd)
  44 + if err != nil {
  45 + controller.Response(nil, err)
  46 + return
  47 + }
  48 + cmd.Operator = controller.GetOperator()
  49 + data, err := svr.SearchDividendsEstimates(cmd)
  50 + controller.Response(data, err)
  51 +}
  52 +
  53 +/***** CompanyStatistics 企业端统计 *****/
  54 +
  55 +func (controller *CooperationController) IndexStatistics() {
  56 + svr := service.CompanyStatisticsService{}
  57 + cmd := &command.IndexStatisticsCommand{}
  58 + err := controller.Unmarshal(cmd)
  59 + if err != nil {
  60 + controller.Response(nil, err)
  61 + return
  62 + }
  63 + cmd.Operator = controller.GetOperator()
  64 + data, err := svr.IndexStatistics(cmd)
  65 + controller.Response(data, err)
  66 +}
  67 +
  68 +func (controller *CooperationController) CooperationPersonStatistics() {
  69 + svr := service.CompanyStatisticsService{}
  70 + cmd := &command.CooperationPersonStatisticsCommand{}
  71 + err := controller.Unmarshal(cmd)
  72 + if err != nil {
  73 + controller.Response(nil, err)
  74 + return
  75 + }
  76 + cmd.Operator = controller.GetOperator()
  77 + data, err := svr.CooperationPersonStatistics(cmd)
  78 + controller.Response(data, err)
  79 +}
  80 +
  81 +func (controller *CooperationController) GoodsStatistics() {
  82 + svr := service.CompanyStatisticsService{}
  83 + cmd := &command.GoodsStatisticsCommand{}
  84 + err := controller.Unmarshal(cmd)
  85 + if err != nil {
  86 + controller.Response(nil, err)
  87 + return
  88 + }
  89 + cmd.Operator = controller.GetOperator()
  90 + data, err := svr.GoodsStatistics(cmd)
  91 + controller.Response(data, err)
  92 +}
  93 +
  94 +func (controller *CooperationController) CooperationDividendsStatistics() {
  95 + svr := service.CompanyStatisticsService{}
  96 + cmd := &command.CooperationDividendsStatisticsCommand{}
  97 + err := controller.Unmarshal(cmd)
  98 + if err != nil {
  99 + controller.Response(nil, err)
  100 + return
  101 + }
  102 + cmd.Operator = controller.GetOperator()
  103 + data, err := svr.CooperationDividendsStatistics(cmd)
  104 + controller.Response(data, err)
  105 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
  6 +)
  7 +
  8 +// router
  9 +
  10 +func init() {
  11 +
  12 + /***** CompanyDividends 企业端分红 *****/
  13 + web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Get:GetDividendContracts")
  14 + web.Router("/v1/app/cooperation/company/dividends/sum", &mobile_client.CooperationController{}, "Post:DividendsStatistics")
  15 + web.Router("/v1/app/cooperation/company/dividends-estimates/search", &mobile_client.CooperationController{}, "Post:SearchDividendsEstimates")
  16 +
  17 + /***** CompanyStatistics 企业端统计 *****/
  18 + web.Router("/v1/app/cooperation/index", &mobile_client.CooperationController{}, "Get:IndexStatistics")
  19 + web.Router("/v1/app/cooperation/person/statistics", &mobile_client.CooperationController{}, "Post:CooperationPersonStatistics")
  20 + web.Router("/v1/app/cooperation/goods/statistics", &mobile_client.CooperationController{}, "Post:GoodsStatistics")
  21 + web.Router("/v1/app/cooperation-dividends-statistics/statistics", &mobile_client.CooperationController{}, "Post:CooperationDividendsStatistics")
  22 +}