作者 yangfu

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

... ... @@ -381,7 +381,8 @@ func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (inter
Offset: 0,
Limit: 100,
UserBaseId: userOrgCommand.Operator.UserBaseId,
UserType: 1,
UserType: domain.UserTypeEmployee,
EnableStatus: domain.UserStatusEnable,
PullRealTime: true,
})
if err != nil {
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type DividendsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *DividendsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type GetDividendContractsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *GetDividendContractsCommand) Valid(validation *validation.Validation) {
}
func (cmd *GetDividendContractsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type SearchDividendsEstimatesCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *SearchDividendsEstimatesCommand) Valid(validation *validation.Validation) {
}
func (cmd *SearchDividendsEstimatesCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type CooperationDividendsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *CooperationDividendsStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *CooperationDividendsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type CooperationPersonStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *CooperationPersonStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *CooperationPersonStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type GoodsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *GoodsStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *GoodsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
// Command
type IndexStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
}
func (cmd *IndexStatisticsCommand) Valid(validation *validation.Validation) {
}
func (cmd *IndexStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(cmd)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 企业端分红服务
type CompanyDividendsService struct {
}
// IndexStatistics TODO:企业的合约列表(分红信息按合约划分)
func (srv CompanyStatisticsService) GetDividendContracts(userMenusCommand *command.GetDividendContractsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:企业的合约统计(分红统计)
func (srv CompanyStatisticsService) DividendsStatistics(userMenusCommand *command.DividendsStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:企业的合约明细列表(分红预算信息)
func (srv CompanyStatisticsService) SearchDividendsEstimates(userMenusCommand *command.SearchDividendsEstimatesCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 企业端统计
type CompanyStatisticsService struct {
}
// IndexStatistics TODO:首页统计 (入口页面统计数据)
func (srv CompanyStatisticsService) IndexStatistics(userMenusCommand *command.IndexStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:共创人员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:产品统计排行榜 年月榜
func (srv CompanyStatisticsService) GoodsStatistics(userMenusCommand *command.GoodsStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
// IndexStatistics TODO:共创分红支出统计
func (srv CompanyStatisticsService) CooperationDividendsStatistics(userMenusCommand *command.CooperationDividendsStatisticsCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
}
... ...
package domain
/***** 1.用户模块 *****/
// 用户类型
const (
UserTypeEmployee = 1
UserTypeCooperation = 2
UserTypeCompanyAdmin = 1024
)
// 用户状态
const (
UserStatusEnable int = 1
UserStatusDisable int = 2
UserStatusDestroy int = 3
)
/***** 2.菜单模块 *****/
// 菜单启用状态 结合用户菜单权限
const (
MenuStatusEnable = 1 // 菜单启用
MenuStatusDisable = 2 // 菜单禁用
)
// 菜单公开状态
const (
MenuPublic = 1 // 菜单公开
MenuPrivate = 2 // 菜单未公开
)
const (
WebMenuCode = "web"
AppMenuCode = "app"
)
/***** 3.组织模块 *****/
const (
IsOrgFlag = 1 // 标记为组织
IsNotOrgFlag = 2 // 标记为非组织
)
const (
OrgStatusEnable = 1
OrgStatusDisable = 2
)
... ...
... ... @@ -94,6 +94,8 @@ type (
InOrgIds []int64 `cname:"匹配多个组织" json:"inOrgIds,omitempty"`
// 实时拉取数据 (获取最新的)
PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"`
// 状态(1:启用 2:禁用 3:注销)
EnableStatus int `cname:"状态(1:启用 2:禁用 3:注销)" json:"enableStatus,omitempty"`
}
//DataUserSearch 搜索用户列表
... ...
package mobile_client
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/service"
)
// Controller
type CooperationController struct {
baseController
}
/***** CompanyDividends 企业端分红 *****/
func (controller *CooperationController) GetDividendContracts() {
svr := service.CompanyStatisticsService{}
cmd := &command.GetDividendContractsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.GetDividendContracts(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) DividendsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.DividendsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.DividendsStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) SearchDividendsEstimates() {
svr := service.CompanyStatisticsService{}
cmd := &command.SearchDividendsEstimatesCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.SearchDividendsEstimates(cmd)
controller.Response(data, err)
}
/***** CompanyStatistics 企业端统计 *****/
func (controller *CooperationController) IndexStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.IndexStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.IndexStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) CooperationPersonStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.CooperationPersonStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CooperationPersonStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) GoodsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.GoodsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.GoodsStatistics(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) CooperationDividendsStatistics() {
svr := service.CompanyStatisticsService{}
cmd := &command.CooperationDividendsStatisticsCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.CooperationDividendsStatistics(cmd)
controller.Response(data, err)
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"
)
// router
func init() {
/***** CompanyDividends 企业端分红 *****/
web.Router("/v1/app/cooperation/company/dividends/contracts", &mobile_client.CooperationController{}, "Get:GetDividendContracts")
web.Router("/v1/app/cooperation/company/dividends/sum", &mobile_client.CooperationController{}, "Post:DividendsStatistics")
web.Router("/v1/app/cooperation/company/dividends-estimates/search", &mobile_client.CooperationController{}, "Post:SearchDividendsEstimates")
/***** CompanyStatistics 企业端统计 *****/
web.Router("/v1/app/cooperation/index", &mobile_client.CooperationController{}, "Get:IndexStatistics")
web.Router("/v1/app/cooperation/person/statistics", &mobile_client.CooperationController{}, "Post:CooperationPersonStatistics")
web.Router("/v1/app/cooperation/goods/statistics", &mobile_client.CooperationController{}, "Post:GoodsStatistics")
web.Router("/v1/app/cooperation-dividends-statistics/statistics", &mobile_client.CooperationController{}, "Post:CooperationDividendsStatistics")
}
... ...