contract_dividends_person.go 3.0 KB
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_cooperation"
)

// 企业端分红服务
type PersonDividendsService struct {
}

// GetDividendContracts  企业的合约列表(分红信息按合约划分)
func (srv PersonDividendsService) GetDividendContracts(cmd *command.GetDividendContractsCommand) (interface{}, error) {
	gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
		cmd.Operator)
	result, err := gateway.CooperationStatistics(allied_creation_cooperation.GetContractDividends, map[string]interface{}{
		"contractId": cmd.ContractId,
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return result, nil
}

// GetDividendContracts  企业的合约列表(分红信息按合约划分)
func (srv PersonDividendsService) SearchDividendContracts(cmd *command.SearchDividendContractsCommand) (int64, interface{}, error) {
	cmd.UserBaseId = cmd.Operator.UserBaseId
	gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
		cmd.Operator)
	result, err := gateway.CooperationStatistics(allied_creation_cooperation.SearchContractDividends, map[string]interface{}{
		"orgId":      cmd.OrgId,
		"userBaseId": cmd.UserBaseId,
		"limit":      cmd.PageSize,
		"offset":     cmd.PageNumber * cmd.PageSize,
	})
	if err != nil {
		return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return 0, result, nil
}

// DividendsStatistics  个人合约统计(分红统计)
func (srv PersonDividendsService) DividendsStatistics(cmd *command.DividendsStatisticsCommand) (interface{}, error) {
	gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
		cmd.Operator)
	result, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{
		"userBaseId": cmd.Operator.UserBaseId,
		"orgId":      cmd.OrgId,
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return result, nil
}

// SearchDividendsEstimates  企业的合约明细列表(分红预算信息)
func (srv PersonDividendsService) SearchDividendsEstimates(cmd *command.SearchDividendsEstimatesCommand) (int64, interface{}, error) {
	gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
		cmd.Operator)
	result, err := gateway.CooperationStatistics(allied_creation_cooperation.SearchDividendsEstimates, map[string]interface{}{
		//"companyId": cmd.Operator.CompanyId,
		"orgId":                  cmd.OrgId,
		"userBaseId":             cmd.Operator.UserBaseId,
		"dividendsAccountStatus": cmd.Status,
		"offset":                 cmd.PageNumber * cmd.PageSize,
		"limit":                  cmd.PageSize,
	})
	if err != nil {
		return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return 0, result, nil
}