...
|
...
|
@@ -2,7 +2,9 @@ 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/application/mobile/cooperation/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -15,19 +17,58 @@ type PersonCreditAccountService struct { |
|
|
func (srv PersonCreditAccountService) CreditAccountPaySearch(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) {
|
|
|
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
|
|
|
cmd.Operator)
|
|
|
var beginTime, endTime time.Time
|
|
|
if cmd.BeginTime > 0 {
|
|
|
beginTime = time.Unix(cmd.BeginTime/1000, 0)
|
|
|
}
|
|
|
if cmd.EndTime > 0 {
|
|
|
endTime = time.Unix(cmd.EndTime/1000, 0)
|
|
|
}
|
|
|
resultMenu, err := gateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{
|
|
|
PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
|
|
|
PageSize: cmd.PageSize,
|
|
|
PaymentStatus: 2,
|
|
|
UserBaseId: cmd.Operator.UserBaseId,
|
|
|
BeginTime: beginTime,
|
|
|
EndTime: endTime,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
queryOptions := map[string]interface{}{
|
|
|
"userBaseId": cmd.Operator.UserBaseId,
|
|
|
}
|
|
|
if cmd.BeginTime > 0 {
|
|
|
queryOptions["beginTime"] = beginTime
|
|
|
}
|
|
|
if cmd.EndTime > 0 {
|
|
|
queryOptions["endTime"] = endTime
|
|
|
}
|
|
|
// 2.分红统计
|
|
|
dividendStatisticsResult, err := gateway.CooperationStatistics(allied_creation_cooperation.CreditAccountStatistics, queryOptions)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
type AnnualDividend struct {
|
|
|
Total float64 `json:"total"`
|
|
|
Accounting float64 `json:"accounting"`
|
|
|
Accounted float64 `json:"accounted"`
|
|
|
Paid float64 `json:"paid"`
|
|
|
Unpaid float64 `json:"unpaid"`
|
|
|
}
|
|
|
var annualDividend = &AnnualDividend{}
|
|
|
if err := json.UnmarshalFromString(json.MarshalToString(dividendStatisticsResult), annualDividend); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
var items = make([]*dto.CreditAccountItem, 0)
|
|
|
for i := 0; i < len(resultMenu.Grid.List); i++ {
|
|
|
items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i]))
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"grid": map[string]interface{}{
|
|
|
"list": resultMenu.Grid.List,
|
|
|
"sum": 6000,
|
|
|
"list": items,
|
|
|
"sum": annualDividend.Paid,
|
|
|
},
|
|
|
}, nil
|
|
|
}
|
...
|
...
|
|