作者 tangxuhui
... ... @@ -35,7 +35,7 @@ type CreditAccountItem struct {
Company domain.CompanyData `json:"company"` // 公司
CreatedAt int64 `json:"createdAt"` // 创建时间
UpdatedAt int64 `json:"updatedAt"` // 更新时间
AccountDetail struct {
AccountDetail []struct {
DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
DividendsType int `json:"dividendsType"`
DividendsAmount float64 `json:"dividendsAmount"`
... ...
... ... @@ -39,7 +39,7 @@ func (srv CompanyStatisticsService) SearchDividendContracts(cmd *command.SearchD
return 0, result, nil
}
// DividendsStatistics TODO:企业的合约统计(分红统计)
// DividendsStatistics 企业的合约统计(分红统计)
func (srv CompanyStatisticsService) DividendsStatistics(cmd *command.DividendsStatisticsCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
... ...
... ... @@ -35,18 +35,17 @@ func (srv CompanyCreditAccountService) CreditAccountSearch(cmd *command.CreditAc
func (srv CompanyCreditAccountService) CreditAccountGet(cmd *command.CreditAccountGetCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
resultMenu, err := gateway.CreditAccountGet(allied_creation_cooperation.ReqCreditAccountGet{
credit, err := gateway.CreditAccountGet(allied_creation_cooperation.ReqCreditAccountGet{
CreditAccountId: cmd.CreditAccountId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
result := map[string]interface{}{
"creditAccount": dto.ToCreditAccountItem(&resultMenu.CreditAccount),
//TODO:dividendsEstimate 结算明细
"dividendsEstimate": []struct{}{},
ret := map[string]interface{}{
"creditAccount": dto.ToCreditAccountItem(&credit.CreditAccount),
"dividendsEstimate": credit.CreditAccount.AccountDetail,
}
return result, nil
return ret, nil
}
// CreditAccountDelete 企业的账期结算删除
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/json"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
... ... @@ -12,11 +13,12 @@ import (
type PersonStatisticsService struct {
}
// IndexStatistics TODO:个人端 - 首页统计 (入口页面统计数据)
// IndexStatistics 个人端 - 首页统计 (入口页面统计数据)
func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
// 项目概览统计
// 1.项目概览统计
contracts, err := gateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
PageNumber: 1,
PageSize: 1,
... ... @@ -25,7 +27,6 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 项目概览统计
stoppedContracts, err := gateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{
PageNumber: 1,
PageSize: 1,
... ... @@ -47,56 +48,70 @@ func (srv PersonStatisticsService) IndexStatistics(cmd *command.IndexStatisticsC
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var overview = map[string]interface{}{
"contractSum": contracts.Grid.Total,
"contractStoppedSum": stoppedContracts.Grid.Total,
"companySum": users.Count,
"contractSum": contracts.Grid.Total, //总合约数
"contractStoppedSum": stoppedContracts.Grid.Total, //停止的合约数
"companySum": users.Count, //共创企业数
}
// 2.本月分红统计 - 个人
dividendStatisticsResult, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
type AnnualDividend struct {
AnnualDividends struct {
Accounted int `json:"accounted"`
Accounting int `json:"accounting"`
Paid int `json:"paid"`
Total int `json:"total"`
} `json:"annualDividends"`
}
var annualDividend = &AnnualDividend{}
if err := json.UnmarshalFromString(json.MarshalToString(dividendStatisticsResult), annualDividend); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
dividendStatistics := map[string]interface{}{
"dividendAmount": annualDividend.AnnualDividends.Total, // 分红金额
"paidAmount": annualDividend.AnnualDividends.Paid, // 已支付
"unPaidAmount": annualDividend.AnnualDividends.Accounting, // 未支付
}
return map[string]interface{}{
"overview": overview,
"dividendStatistics": map[string]interface{}{
"dividendAmount": 9000,
"paidAmount": 2000,
"unPaidAmount": 7000,
},
"dividendStatistics": dividendStatistics,
}, nil
//return map[string]interface{}{
// "overview": map[string]interface{}{
// "contractSum": 60,
// "contractStoppedSum": 70,
// "companySum": 6,
// },
// "dividendStatistics": map[string]interface{}{
// "dividendAmount": 9000,
// "paidAmount": 2000,
// "unPaidAmount": 7000,
// },
//}, nil
}
// CompanyStatistics 共创用户-共创企业统计
func (srv PersonStatisticsService) CompanyStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
var values []interface{}
values = append(values, map[string]interface{}{
"company": map[string]interface{}{
"companyId": 5,
"companyName": "机会平台",
},
"cooperationProjectCount": 10,
"cooperationContractCount": 5,
"dividendsRatio": 50,
"dividendsIncome": 10009965,
})
values = append(values, map[string]interface{}{
"company": map[string]interface{}{
"companyId": 6,
"companyName": "机会平台2",
},
"cooperationProjectCount": 10,
"cooperationContractCount": 5,
"dividendsRatio": 50,
"dividendsIncome": 10009965,
func (srv PersonStatisticsService) CompanyStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
gatewayUser := allied_creation_user.NewHttplibAlliedCreationUser(
cmd.Operator)
users, err := gatewayUser.UserSearch(allied_creation_user.ReqUserSearch{
Limit: 100,
Offset: 0,
UserBaseId: cmd.Operator.UserBaseId,
UserType: domain.UserTypeCooperation,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var values []interface{}
for i := range users.Users {
user := users.Users[i]
item := map[string]interface{}{
"company": user.Company,
"cooperationProjectCount": 0,
"cooperationContractCount": 0,
"dividendsRatio": 0,
"dividendsIncome": 0,
}
values = append(values, item)
}
return map[string]interface{}{
"list": values,
}, nil
... ...