作者 yangfu

共创用户明细、企业分红支付统计

... ... @@ -17,9 +17,9 @@ type CreditAccountPaySearchCommand struct {
// 账期结算支付状态,1待支付,2已支付 0全部
PaymentStatus int32 `json:"paymentStatus"`
// 开始时间
BeginTime int `json:"beginTime"`
BeginTime int64 `json:"beginTime"`
// 结算时间
EndTime int `json:"beginTime"`
EndTime int64 `json:"beginTime"`
}
func (cmd *CreditAccountPaySearchCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -10,6 +10,8 @@ import (
type CooperationPersonStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户ID
UserId int `json:"userId"`
}
func (cmd *CooperationPersonStatisticsCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -5,6 +5,7 @@ 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/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
"time"
)
// CompanyCreditAccountService 企业端账期结算 【50%】
... ... @@ -105,19 +106,33 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
// PaymentHistoryStatistics 支付历史统计
func (srv CompanyCreditAccountService) PaymentHistoryStatistics(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) {
//gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
// cmd.Operator)
//resultMenu, err := gateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{
// PageNumber: cmd.PageNumber,
// PageSize: cmd.PageSize,
// PaymentStatus: 2,
//})
//if err != nil {
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
//}
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
queryOptions := map[string]interface{}{
"orgId": cmd.Operator.OrgId,
"offset": cmd.PageNumber * cmd.PageSize,
"limit": cmd.PageSize,
"sortByActuallyPaidAmount": 2,
}
if cmd.BeginTime > 0 {
queryOptions["beginTime"] = time.Unix(cmd.BeginTime/1000, 0)
}
if cmd.EndTime > 0 {
queryOptions["endTime"] = time.Unix(cmd.EndTime/1000, 0)
}
cooperationUsersStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CompanyCooperationUsersStatistics, queryOptions)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
creditAccountStatistics, err := gateway.CreditAccountStatistics(allied_creation_cooperation.CreditAccountStatistics, queryOptions)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"rankItems": []struct{}{},
"totalPaymentAmount": 6000,
"rankItems": cooperationUsersStatistics,
"totalPaymentAmount": creditAccountStatistics.Paid,
}, nil
}
... ...
... ... @@ -2,13 +2,14 @@ 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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 企业端统计 【25%】
// 企业端统计
type CompanyStatisticsService struct {
}
... ... @@ -142,7 +143,44 @@ func (srv CompanyStatisticsService) CooperationDividendsStatistics(cmd *command.
return 0, cooperationUsersStatistics, nil
}
// CooperationPersonStatistics TODO:共创人员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(userMenusCommand *command.CooperationPersonStatisticsCommand) (interface{}, error) {
return map[string]interface{}{}, nil
// CooperationPersonStatistics 共创人明细员统计(共创人员明细)
func (srv CompanyStatisticsService) CooperationPersonStatistics(cmd *command.CooperationPersonStatisticsCommand) (interface{}, error) {
gatewayUser := allied_creation_user.NewHttplibAlliedCreationUser(
cmd.Operator)
user, err := gatewayUser.UserGet(allied_creation_user.ReqGetUser{
UserId: cmd.UserId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
cooperationUserModeStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.CooperationUserModeStatistics, map[string]interface{}{
"userId": cmd.UserId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var modeStatistics = struct {
CooperationTypes interface{} `json:"cooperationTypes"`
DividendsDetails interface{} `json:"dividendsDetails"`
OrderDetails interface{} `json:"orderDetails"`
}{}
if err := json.UnmarshalFromString(json.MarshalToString(cooperationUserModeStatistics), &modeStatistics); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var response = map[string]interface{}{
"userName": user.UserInfo.UserName,
"cooperationTime": user.CreatedAt.Unix() * 1000,
"cooperationTypes": modeStatistics.CooperationTypes,
"dividendsDetails": modeStatistics.DividendsDetails,
"orderDetails": modeStatistics.OrderDetails,
}
return map[string]interface{}{
"cooperationPersonStatistics": response,
}, nil
}
... ...
... ... @@ -26,11 +26,16 @@ const (
SearchDividendsEstimates = "SearchDividendsEstimates"
// 公司 - 共创用户统计
CompanyCooperationUsersStatistics = "CompanyCooperationUsersStatistics"
//公司 - 共创用户模式统计
CooperationUserModeStatistics = "CooperationUserModeStatistics"
// 个人 - 共创企业统计
CooperationCompanyStatistics = "CooperationCompanyStatistics"
// 个人 - 用户合约统计
PersonCooperationContractStatistics = "PersonCooperationContractStatistics"
// 账期结算单统计
CreditAccountStatistics = "CreditAccountStatistics"
)
// CooperationStatistics 共创统计
... ... @@ -67,3 +72,38 @@ func (gateway HttplibAlliedCreationCooperation) CooperationStatistics(action str
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CreditAccountStatistics 账期结算单统计
func (gateway HttplibAlliedCreationCooperation) CreditAccountStatistics(action string, queryOptions interface{}) (*DataCreditAccountStatistics, error) {
url := gateway.baseUrL + "/cooperation-statistics"
method := "post"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
"api": method + ":" + url,
"param": queryOptions,
})
param := map[string]interface{}{
"action": action,
"queryOptions": queryOptions,
}
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求共创统计失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取共创统计失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析共创统计:%w", err)
}
var data DataCreditAccountStatistics
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
package allied_creation_cooperation
type DataCreditAccountStatistics struct {
Total float64 `json:"total"`
Accounting float64 `json:"accounting"`
Accounted float64 `json:"accounted"`
Paid float64 `json:"paid"`
}
... ...
... ... @@ -65,6 +65,8 @@ type UserDetail struct {
} `json:"im"`
// 收藏的菜单(工作台)(菜单编码列表)
FavoriteMenus []string `json:"favoriteMenus"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
}
//搜索用户列表
... ...