作者 tangxuhui
... ... @@ -318,6 +318,7 @@ func (svr AuthService) GetUserMenus(userMenusCommand *command.UserMenusCommand)
UserId: int(userMenusCommand.Operator.UserId),
MenuCategory: userMenusCommand.MenuCategory,
ALLDisableMenu: userMenusCommand.ALLDisableMenu,
OrgId: userMenusCommand.Operator.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -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 {
... ...
... ... @@ -75,7 +75,7 @@ func (srv CooperationApplicationsService) SearchCooperationApplications(applicat
resultApplications, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
PageNumber: applicationQuery.PageNumber + 1, //手机序号从0开始的
PageSize: applicationQuery.PageSize,
//CompanyId: int(applicationQuery.Operator.CompanyId),
CompanyId: int(applicationQuery.Operator.CompanyId),
OrgId: applicationQuery.Operator.OrgId,
CooperationApplicationStatus: applicationQuery.Status,
})
... ...
... ... @@ -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,
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)
... ... @@ -98,6 +126,7 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
OrgId: cmd.Operator.OrgId,
BeginTime: beginTime,
EndTime: endTime,
CooperationContractNumbers: cooperationContractNumbers,
}
resultMenu, err := gateway.CreditAccountsSearch(req)
if err != nil {
... ... @@ -105,6 +134,7 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
}
queryOptions := map[string]interface{}{
"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]))
}
... ... @@ -145,7 +175,25 @@ func (srv CompanyCreditAccountService) CreditAccountPaySearch(cmd *command.Credi
func (srv CompanyCreditAccountService) PaymentHistoryStatistics(cmd *command.CreditAccountPaySearchCommand) (interface{}, error) {
gateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
cmd.Operator)
var response = struct {
rankItems interface{} `json:"rankItems"`
TotalPaymentAmount interface{} `json:"totalPaymentAmount"`
}{}
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())
}
if len(cooperationContractNumbers) == 0 {
return response, nil
}
queryOptions := map[string]interface{}{
"userId": cmd.Operator.UserId,
"orgId": cmd.Operator.OrgId,
"offset": cmd.PageNumber * cmd.PageSize,
"limit": cmd.PageSize,
... ... @@ -162,15 +210,15 @@ func (srv CompanyCreditAccountService) PaymentHistoryStatistics(cmd *command.Cre
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
queryOptions["cooperationContractNumbers"] = cooperationContractNumbers
creditAccountStatistics, err := gateway.CreditAccountStatistics(allied_creation_cooperation.CreditAccountStatistics, queryOptions)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
response.rankItems = cooperationUsersStatistics
response.TotalPaymentAmount = creditAccountStatistics.Paid
return map[string]interface{}{
"rankItems": cooperationUsersStatistics,
"totalPaymentAmount": creditAccountStatistics.Paid,
}, nil
return response, nil
}
// PaymentHistoryHistogramStatistics 支付历史统计-直方图
... ... @@ -179,6 +227,9 @@ func (srv CompanyCreditAccountService) PaymentHistoryHistogramStatistics(cmd *co
cmd.Operator)
paymentHistoryHistogramStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.PaymentHistoryHistogramStatistics, map[string]interface{}{
"orgId": cmd.Operator.OrgId,
"userId": cmd.Operator.UserId,
"beginTime": time.Unix(cmd.BeginTime/1000, 0),
"endTime": time.Unix(cmd.EndTime/1000, 0),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -112,6 +112,8 @@ func (srv PersonCreditAccountService) PaymentHistoryHistogramStatistics(cmd *com
cmd.Operator)
paymentHistoryHistogramStatistics, err := gateway.CooperationStatistics(allied_creation_cooperation.PaymentHistoryHistogramStatistics, map[string]interface{}{
"userBaseId": cmd.Operator.UserBaseId,
"beginTime": time.Unix(cmd.BeginTime/1000, 0),
"endTime": time.Unix(cmd.EndTime/1000, 0),
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -155,6 +155,7 @@ func (cooperationModeService *CooperationModeService) CooperationModeSelector(li
OrgIds: nil,
OrgId: listCooperationModeQuery.Operator.OrgId,
UserBaseId: 0,
Status: 1,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ...
... ... @@ -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
}
... ...
... ... @@ -166,6 +166,8 @@ type (
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
OrgIds []int64 `json:"orgIds"`
// 共创模式状态,1启用,2禁用
Status int32 `json:"status"`
//模式编码列表
CooperationModeNumbers []string `cname:"模式编码列表" json:"cooperationModeNumbers,omitempty"`
}
... ...
... ... @@ -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 {
... ...
... ... @@ -317,6 +317,8 @@ type (
type (
ReqUserAccessMenus struct {
UserId int `json:"userId"`
// 当前登录组织orgId
OrgId int64 `cname:"当前登录组织Id" json:"orgId"`
// 菜单类别 web app
MenuCategory string `cname:"菜单类别 web app" json:"menuCategory,omitempty"`
// 返回所有不可以用的菜单
... ...