作者 yangfu

合约分红列表、详情

... ... @@ -33,8 +33,10 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS
})
var res interface{}
switch contractStatisticsQuery.Action {
case domain_service.ContractDividends:
case domain_service.SearchContractDividends:
res, err = statisticsService.SearchContractDividends(contractStatisticsQuery.QueryOptions)
case domain_service.GetContractDividends:
res, err = statisticsService.GetContractDividends(contractStatisticsQuery.QueryOptions)
}
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -6,11 +6,13 @@ import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
"time"
)
const (
ContractDividends = "ContractDividends"
// 合约分红列表查询
SearchContractDividends = "SearchContractDividends"
// 获取分红合约详情
GetContractDividends = "GetContractDividends"
)
// CooperationStatisticsService 共创统计服务
... ... @@ -20,6 +22,8 @@ type CooperationStatisticsService struct {
/***** 1.合约分红模块 *****/
/*1.1 分红合约搜索*/
// 分红合约搜索
//
// queryOptions 查询参数
... ... @@ -53,7 +57,7 @@ func (svr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
CooperationContractName: item.CooperationContractName,
CooperationContractNumber: item.CooperationContractNumber,
Status: item.Status,
CreatedAt: item.CreatedAt,
CreatedAt: item.CreatedAt.Unix() * 1000,
}
results = append(results, resultItem)
numbers = append(numbers, item.CooperationContractNumber)
... ... @@ -109,7 +113,7 @@ func (svr *CooperationStatisticsService) getContractsDividendsEstimate(numbers [
if len(numbers) == 0 {
return resMap, nil
}
_, err := svr.transactionContext.PgDd.Query(estimates, `select cooperation_contract_number,sum(dividends_amount) dividends_amount from dividends_estimates
_, err := svr.transactionContext.PgDd.Query(&estimates, `select cooperation_contract_number,sum(dividends_amount) dividends_amount from dividends_estimates
where cooperation_contract_number in (?)
group by cooperation_contract_number
`, pg.In(numbers))
... ... @@ -137,7 +141,7 @@ type searchContractDividendsResult struct {
// 分红订单金额
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
CreatedAt int64 `json:"createdAt"`
}
func NewCooperationStatisticsService(transactionContext *pgTransaction.TransactionContext) (*CooperationStatisticsService, error) {
... ... @@ -149,3 +153,43 @@ func NewCooperationStatisticsService(transactionContext *pgTransaction.Transacti
}, nil
}
}
/*1.2 分红合约详情*/
// 分红合约搜索
//
// queryOptions 查询参数
// 按组织
// - companyId
// - orgId
// 按个人
// - userBaseId
func (svr *CooperationStatisticsService) GetContractDividends(queryOptions map[string]interface{}) (interface{}, error) {
// 1.合约详情
contractRepository, _ := repository.NewCooperationContractRepository(svr.transactionContext)
if _, ok := queryOptions["contractId"]; !ok {
return nil, fmt.Errorf("合约ID(contractId)不能为空")
}
var res = make(map[string]interface{})
contract, err := contractRepository.FindOne(map[string]interface{}{"cooperationContractId": queryOptions["contractId"]})
if err != nil {
return nil, err
}
res["cooperationContract"] = map[string]interface{}{
"cooperationContractDescription": contract.CooperationContractDescription,
"cooperationContractId": contract.CooperationContractId,
"cooperationContractName": contract.CooperationContractName,
"cooperationContractNumber": contract.CooperationContractNumber,
"createdAt": contract.CreatedAt.Unix() * 1000,
"status": contract.Status,
}
// 2.合约分红列表
if _, ok := queryOptions["userBaseId"]; ok {
} else if _, ok := queryOptions["orgId"]; ok {
}
res["dividends"] = []struct{}{}
return res, nil
}
... ...