作者 yangfu

按相关人列表过滤修改

... ... @@ -10,6 +10,8 @@ import (
type DividendsStatisticsCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 组织Id
OrgId int64 `json:"companyId" valid:"Required"`
}
func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,7 +11,7 @@ type SearchDividendsEstimatesCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 查询偏离量
PageNumber int `json:"pageIndex" valid:"Required"`
PageNumber int `json:"pageNumber" valid:"Required"`
// 查询限制
PageSize int `json:"pageSize" valid:"Required"`
//状态
... ...
... ... @@ -30,6 +30,7 @@ func (srv CompanyStatisticsService) SearchDividendContracts(cmd *command.SearchD
"offset": cmd.PageNumber * cmd.PageSize,
"limit": cmd.PageSize,
"orgId": cmd.Operator.OrgId,
"userId": cmd.Operator.UserId,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -44,6 +45,7 @@ func (srv CompanyStatisticsService) DividendsStatistics(cmd *command.DividendsSt
result, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
"userId": cmd.Operator.UserId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -58,8 +60,9 @@ func (srv CompanyStatisticsService) SearchDividendsEstimates(cmd *command.Search
result, err := gateway.CooperationStatistics(allied_creation_cooperation.SearchDividendsEstimates, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
"userId": cmd.Operator.UserId,
"dividendsAccountStatus": cmd.Status,
"offset": (cmd.PageNumber - 1) * cmd.PageSize,
"offset": cmd.PageNumber * cmd.PageSize,
"limit": cmd.PageSize,
})
if err != nil {
... ...
... ... @@ -40,12 +40,13 @@ func (srv PersonDividendsService) SearchDividendContracts(cmd *command.SearchDiv
return 0, result, nil
}
// DividendsStatistics 企业的合约统计(分红统计)
// 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())
... ... @@ -62,7 +63,7 @@ func (srv PersonDividendsService) SearchDividendsEstimates(cmd *command.SearchDi
"orgId": cmd.OrgId,
"userBaseId": cmd.Operator.UserBaseId,
"dividendsAccountStatus": cmd.Status,
"offset": (cmd.PageNumber - 1) * cmd.PageSize,
"offset": cmd.PageNumber * cmd.PageSize,
"limit": cmd.PageSize,
})
if err != nil {
... ...
... ... @@ -18,16 +18,30 @@ type CompanyCreditAccountService struct {
func (srv CompanyCreditAccountService) CreditAccountSearch(cmd *command.CreditAccountSearchCommand) (int64, interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
cooperationContractNumbers, err := gateway.RelevantCooperationContractNumbers(allied_creation_cooperation.RelevantCooperationContractNumbers, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
"userId": cmd.Operator.UserId,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var items = make([]*dto.CreditAccountItem, 0)
if len(cooperationContractNumbers) == 0 {
return 0, items, nil
}
resultMenu, err := gateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{
PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
PageSize: cmd.PageSize,
PaymentStatus: cmd.PaymentStatus,
OrgId: cmd.Operator.OrgId,
PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
PageSize: cmd.PageSize,
PaymentStatus: cmd.PaymentStatus,
OrgId: cmd.Operator.OrgId,
CooperationContractNumbers: cooperationContractNumbers,
})
if err != nil {
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var items []*dto.CreditAccountItem
for i := 0; i < len(resultMenu.Grid.List); i++ {
items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i]))
}
... ... @@ -84,6 +98,20 @@ func (srv CompanyCreditAccountService) CreditAccountPay(cmd *command.CreditAccou
func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
cooperationContractNumbers, err := gateway.RelevantCooperationContractNumbers(allied_creation_cooperation.RelevantCooperationContractNumbers, map[string]interface{}{
"companyId": cmd.Operator.CompanyId,
"orgId": cmd.Operator.OrgId,
"userId": cmd.Operator.UserId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var items = make([]*dto.CreditAccountItem, 0)
if len(cooperationContractNumbers) == 0 {
return items, nil
}
var beginTime, endTime time.Time
if cmd.BeginTime > 0 {
beginTime = time.Unix(cmd.BeginTime/1000, 0)
... ... @@ -92,19 +120,21 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
endTime = time.Unix(cmd.EndTime/1000, 0)
}
req := allied_creation_cooperation.ReqCreditAccountsSearch{
PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
PageSize: cmd.PageSize,
PaymentStatus: 2,
OrgId: cmd.Operator.OrgId,
BeginTime: beginTime,
EndTime: endTime,
PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
PageSize: cmd.PageSize,
PaymentStatus: 2,
OrgId: cmd.Operator.OrgId,
BeginTime: beginTime,
EndTime: endTime,
CooperationContractNumbers: cooperationContractNumbers,
}
resultMenu, err := gateway.CreditAccountsSearch(req)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
queryOptions := map[string]interface{}{
"orgId": cmd.Operator.OrgId,
"orgId": cmd.Operator.OrgId,
"cooperationContractNumbers": cooperationContractNumbers,
}
if cmd.BeginTime > 0 {
queryOptions["beginTime"] = beginTime
... ... @@ -129,7 +159,7 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var items = make([]*dto.CreditAccountItem, 0)
//var items = make([]*dto.CreditAccountItem, 0)
for i := 0; i < len(resultMenu.Grid.List); i++ {
items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i]))
}
... ...
... ... @@ -42,6 +42,8 @@ const (
CreditAccountStatistics = "CreditAccountStatistics"
// 公司/个人 - 支付历史统计直方图
PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
// 用户相关的项目合约编号列表查询
RelevantCooperationContractNumbers = "RelevantCooperationContractNumbers"
)
// CooperationStatistics 共创统计
... ... @@ -113,3 +115,38 @@ func (gateway HttplibAlliedCreationCooperation) CreditAccountStatistics(action s
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CreditAccountStatistics 账期结算单统计
func (gateway HttplibAlliedCreationCooperation) RelevantCooperationContractNumbers(action string, queryOptions interface{}) ([]string, 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 []string
err = gateway.GetResponseData(result, &data)
return data, err
}
... ...
... ... @@ -90,6 +90,8 @@ type (
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
// 合约编号列表
CooperationContractNumbers []string `json:"cooperationContractNumbers"`
}
DataCreditAccountsSearch struct {
... ...