作者 yangfu

按相关人列表过滤修改

@@ -10,6 +10,8 @@ import ( @@ -10,6 +10,8 @@ import (
10 type DividendsStatisticsCommand struct { 10 type DividendsStatisticsCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
  13 + // 组织Id
  14 + OrgId int64 `json:"companyId" valid:"Required"`
13 } 15 }
14 16
15 func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) { 17 func (cmd *DividendsStatisticsCommand) Valid(validation *validation.Validation) {
@@ -11,7 +11,7 @@ type SearchDividendsEstimatesCommand struct { @@ -11,7 +11,7 @@ type SearchDividendsEstimatesCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 查询偏离量 13 // 查询偏离量
14 - PageNumber int `json:"pageIndex" valid:"Required"` 14 + PageNumber int `json:"pageNumber" valid:"Required"`
15 // 查询限制 15 // 查询限制
16 PageSize int `json:"pageSize" valid:"Required"` 16 PageSize int `json:"pageSize" valid:"Required"`
17 //状态 17 //状态
@@ -30,6 +30,7 @@ func (srv CompanyStatisticsService) SearchDividendContracts(cmd *command.SearchD @@ -30,6 +30,7 @@ func (srv CompanyStatisticsService) SearchDividendContracts(cmd *command.SearchD
30 "offset": cmd.PageNumber * cmd.PageSize, 30 "offset": cmd.PageNumber * cmd.PageSize,
31 "limit": cmd.PageSize, 31 "limit": cmd.PageSize,
32 "orgId": cmd.Operator.OrgId, 32 "orgId": cmd.Operator.OrgId,
  33 + "userId": cmd.Operator.UserId,
33 }) 34 })
34 if err != nil { 35 if err != nil {
35 return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 36 return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -44,6 +45,7 @@ func (srv CompanyStatisticsService) DividendsStatistics(cmd *command.DividendsSt @@ -44,6 +45,7 @@ func (srv CompanyStatisticsService) DividendsStatistics(cmd *command.DividendsSt
44 result, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{ 45 result, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{
45 "companyId": cmd.Operator.CompanyId, 46 "companyId": cmd.Operator.CompanyId,
46 "orgId": cmd.Operator.OrgId, 47 "orgId": cmd.Operator.OrgId,
  48 + "userId": cmd.Operator.UserId,
47 }) 49 })
48 if err != nil { 50 if err != nil {
49 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 51 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -58,8 +60,9 @@ func (srv CompanyStatisticsService) SearchDividendsEstimates(cmd *command.Search @@ -58,8 +60,9 @@ func (srv CompanyStatisticsService) SearchDividendsEstimates(cmd *command.Search
58 result, err := gateway.CooperationStatistics(allied_creation_cooperation.SearchDividendsEstimates, map[string]interface{}{ 60 result, err := gateway.CooperationStatistics(allied_creation_cooperation.SearchDividendsEstimates, map[string]interface{}{
59 "companyId": cmd.Operator.CompanyId, 61 "companyId": cmd.Operator.CompanyId,
60 "orgId": cmd.Operator.OrgId, 62 "orgId": cmd.Operator.OrgId,
  63 + "userId": cmd.Operator.UserId,
61 "dividendsAccountStatus": cmd.Status, 64 "dividendsAccountStatus": cmd.Status,
62 - "offset": (cmd.PageNumber - 1) * cmd.PageSize, 65 + "offset": cmd.PageNumber * cmd.PageSize,
63 "limit": cmd.PageSize, 66 "limit": cmd.PageSize,
64 }) 67 })
65 if err != nil { 68 if err != nil {
@@ -40,12 +40,13 @@ func (srv PersonDividendsService) SearchDividendContracts(cmd *command.SearchDiv @@ -40,12 +40,13 @@ func (srv PersonDividendsService) SearchDividendContracts(cmd *command.SearchDiv
40 return 0, result, nil 40 return 0, result, nil
41 } 41 }
42 42
43 -// DividendsStatistics 企业的合约统计(分红统计) 43 +// DividendsStatistics 个人合约统计(分红统计)
44 func (srv PersonDividendsService) DividendsStatistics(cmd *command.DividendsStatisticsCommand) (interface{}, error) { 44 func (srv PersonDividendsService) DividendsStatistics(cmd *command.DividendsStatisticsCommand) (interface{}, error) {
45 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation( 45 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
46 cmd.Operator) 46 cmd.Operator)
47 result, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{ 47 result, err := gateway.CooperationStatistics(allied_creation_cooperation.DividendsStatistics, map[string]interface{}{
48 "userBaseId": cmd.Operator.UserBaseId, 48 "userBaseId": cmd.Operator.UserBaseId,
  49 + "orgId": cmd.OrgId,
49 }) 50 })
50 if err != nil { 51 if err != nil {
51 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 52 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -62,7 +63,7 @@ func (srv PersonDividendsService) SearchDividendsEstimates(cmd *command.SearchDi @@ -62,7 +63,7 @@ func (srv PersonDividendsService) SearchDividendsEstimates(cmd *command.SearchDi
62 "orgId": cmd.OrgId, 63 "orgId": cmd.OrgId,
63 "userBaseId": cmd.Operator.UserBaseId, 64 "userBaseId": cmd.Operator.UserBaseId,
64 "dividendsAccountStatus": cmd.Status, 65 "dividendsAccountStatus": cmd.Status,
65 - "offset": (cmd.PageNumber - 1) * cmd.PageSize, 66 + "offset": cmd.PageNumber * cmd.PageSize,
66 "limit": cmd.PageSize, 67 "limit": cmd.PageSize,
67 }) 68 })
68 if err != nil { 69 if err != nil {
@@ -18,16 +18,30 @@ type CompanyCreditAccountService struct { @@ -18,16 +18,30 @@ type CompanyCreditAccountService struct {
18 func (srv CompanyCreditAccountService) CreditAccountSearch(cmd *command.CreditAccountSearchCommand) (int64, interface{}, error) { 18 func (srv CompanyCreditAccountService) CreditAccountSearch(cmd *command.CreditAccountSearchCommand) (int64, interface{}, error) {
19 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation( 19 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
20 cmd.Operator) 20 cmd.Operator)
  21 +
  22 + cooperationContractNumbers, err := gateway.RelevantCooperationContractNumbers(allied_creation_cooperation.RelevantCooperationContractNumbers, map[string]interface{}{
  23 + "companyId": cmd.Operator.CompanyId,
  24 + "orgId": cmd.Operator.OrgId,
  25 + "userId": cmd.Operator.UserId,
  26 + })
  27 + if err != nil {
  28 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  29 + }
  30 + var items = make([]*dto.CreditAccountItem, 0)
  31 + if len(cooperationContractNumbers) == 0 {
  32 + return 0, items, nil
  33 + }
21 resultMenu, err := gateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{ 34 resultMenu, err := gateway.CreditAccountsSearch(allied_creation_cooperation.ReqCreditAccountsSearch{
22 - PageNumber: cmd.PageNumber + 1, //手机序号从0开始的  
23 - PageSize: cmd.PageSize,  
24 - PaymentStatus: cmd.PaymentStatus,  
25 - OrgId: cmd.Operator.OrgId, 35 + PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
  36 + PageSize: cmd.PageSize,
  37 + PaymentStatus: cmd.PaymentStatus,
  38 + OrgId: cmd.Operator.OrgId,
  39 + CooperationContractNumbers: cooperationContractNumbers,
26 }) 40 })
27 if err != nil { 41 if err != nil {
28 return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 42 return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
29 } 43 }
30 - var items []*dto.CreditAccountItem 44 +
31 for i := 0; i < len(resultMenu.Grid.List); i++ { 45 for i := 0; i < len(resultMenu.Grid.List); i++ {
32 items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i])) 46 items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i]))
33 } 47 }
@@ -84,6 +98,20 @@ func (srv CompanyCreditAccountService) CreditAccountPay(cmd *command.CreditAccou @@ -84,6 +98,20 @@ func (srv CompanyCreditAccountService) CreditAccountPay(cmd *command.CreditAccou
84 func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) { 98 func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) {
85 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation( 99 gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
86 cmd.Operator) 100 cmd.Operator)
  101 +
  102 + cooperationContractNumbers, err := gateway.RelevantCooperationContractNumbers(allied_creation_cooperation.RelevantCooperationContractNumbers, map[string]interface{}{
  103 + "companyId": cmd.Operator.CompanyId,
  104 + "orgId": cmd.Operator.OrgId,
  105 + "userId": cmd.Operator.UserId,
  106 + })
  107 + if err != nil {
  108 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  109 + }
  110 + var items = make([]*dto.CreditAccountItem, 0)
  111 + if len(cooperationContractNumbers) == 0 {
  112 + return items, nil
  113 + }
  114 +
87 var beginTime, endTime time.Time 115 var beginTime, endTime time.Time
88 if cmd.BeginTime > 0 { 116 if cmd.BeginTime > 0 {
89 beginTime = time.Unix(cmd.BeginTime/1000, 0) 117 beginTime = time.Unix(cmd.BeginTime/1000, 0)
@@ -92,19 +120,21 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi @@ -92,19 +120,21 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
92 endTime = time.Unix(cmd.EndTime/1000, 0) 120 endTime = time.Unix(cmd.EndTime/1000, 0)
93 } 121 }
94 req := allied_creation_cooperation.ReqCreditAccountsSearch{ 122 req := allied_creation_cooperation.ReqCreditAccountsSearch{
95 - PageNumber: cmd.PageNumber + 1, //手机序号从0开始的  
96 - PageSize: cmd.PageSize,  
97 - PaymentStatus: 2,  
98 - OrgId: cmd.Operator.OrgId,  
99 - BeginTime: beginTime,  
100 - EndTime: endTime, 123 + PageNumber: cmd.PageNumber + 1, //手机序号从0开始的
  124 + PageSize: cmd.PageSize,
  125 + PaymentStatus: 2,
  126 + OrgId: cmd.Operator.OrgId,
  127 + BeginTime: beginTime,
  128 + EndTime: endTime,
  129 + CooperationContractNumbers: cooperationContractNumbers,
101 } 130 }
102 resultMenu, err := gateway.CreditAccountsSearch(req) 131 resultMenu, err := gateway.CreditAccountsSearch(req)
103 if err != nil { 132 if err != nil {
104 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 133 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
105 } 134 }
106 queryOptions := map[string]interface{}{ 135 queryOptions := map[string]interface{}{
107 - "orgId": cmd.Operator.OrgId, 136 + "orgId": cmd.Operator.OrgId,
  137 + "cooperationContractNumbers": cooperationContractNumbers,
108 } 138 }
109 if cmd.BeginTime > 0 { 139 if cmd.BeginTime > 0 {
110 queryOptions["beginTime"] = beginTime 140 queryOptions["beginTime"] = beginTime
@@ -129,7 +159,7 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi @@ -129,7 +159,7 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
129 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 159 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
130 } 160 }
131 161
132 - var items = make([]*dto.CreditAccountItem, 0) 162 + //var items = make([]*dto.CreditAccountItem, 0)
133 for i := 0; i < len(resultMenu.Grid.List); i++ { 163 for i := 0; i < len(resultMenu.Grid.List); i++ {
134 items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i])) 164 items = append(items, dto.ToCreditAccountItem(&resultMenu.Grid.List[i]))
135 } 165 }
@@ -42,6 +42,8 @@ const ( @@ -42,6 +42,8 @@ const (
42 CreditAccountStatistics = "CreditAccountStatistics" 42 CreditAccountStatistics = "CreditAccountStatistics"
43 // 公司/个人 - 支付历史统计直方图 43 // 公司/个人 - 支付历史统计直方图
44 PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics" 44 PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
  45 + // 用户相关的项目合约编号列表查询
  46 + RelevantCooperationContractNumbers = "RelevantCooperationContractNumbers"
45 ) 47 )
46 48
47 // CooperationStatistics 共创统计 49 // CooperationStatistics 共创统计
@@ -113,3 +115,38 @@ func (gateway HttplibAlliedCreationCooperation) CreditAccountStatistics(action s @@ -113,3 +115,38 @@ func (gateway HttplibAlliedCreationCooperation) CreditAccountStatistics(action s
113 err = gateway.GetResponseData(result, &data) 115 err = gateway.GetResponseData(result, &data)
114 return &data, err 116 return &data, err
115 } 117 }
  118 +
  119 +// CreditAccountStatistics 账期结算单统计
  120 +func (gateway HttplibAlliedCreationCooperation) RelevantCooperationContractNumbers(action string, queryOptions interface{}) ([]string, error) {
  121 + url := gateway.baseUrL + "/cooperation-statistics"
  122 + method := "post"
  123 + req := gateway.CreateRequest(url, method)
  124 + log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
  125 + "api": method + ":" + url,
  126 + "param": queryOptions,
  127 + })
  128 + param := map[string]interface{}{
  129 + "action": action,
  130 + "queryOptions": queryOptions,
  131 + }
  132 + req, err := req.JSONBody(param)
  133 + if err != nil {
  134 + return nil, fmt.Errorf("请求共创统计失败:%w", err)
  135 + }
  136 +
  137 + byteResult, err := req.Bytes()
  138 + if err != nil {
  139 + return nil, fmt.Errorf("获取共创统计失败:%w", err)
  140 + }
  141 + log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
  142 + "result": string(byteResult),
  143 + })
  144 + var result service_gateway.GatewayResponse
  145 + err = json.Unmarshal(byteResult, &result)
  146 + if err != nil {
  147 + return nil, fmt.Errorf("解析共创统计:%w", err)
  148 + }
  149 + var data []string
  150 + err = gateway.GetResponseData(result, &data)
  151 + return data, err
  152 +}
@@ -90,6 +90,8 @@ type ( @@ -90,6 +90,8 @@ type (
90 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"` 90 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
91 BeginTime time.Time `json:"beginTime"` 91 BeginTime time.Time `json:"beginTime"`
92 EndTime time.Time `json:"endTime"` 92 EndTime time.Time `json:"endTime"`
  93 + // 合约编号列表
  94 + CooperationContractNumbers []string `json:"cooperationContractNumbers"`
93 } 95 }
94 96
95 DataCreditAccountsSearch struct { 97 DataCreditAccountsSearch struct {