作者 yangfu

个人统计修改 、 分红明细修改

... ... @@ -21,6 +21,10 @@ func (repository *CooperationContractUndertakerDao) Find(queryOptions map[string
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
cooperationContractUndertakers := make([]*domain.CooperationContractUndertaker, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractUndertakerModels), queryOptions)
//if distinctColumnContractNumber, ok := queryOptions["distinctColumnContractNumber"]; ok && distinctColumnContractNumber.(int) != 0 {
// query.ColumnExpr("distinct cooperation_contract_number")
// query.ColumnExpr("cooperation_contract_undertaker_id")
//}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
... ...
... ... @@ -51,32 +51,31 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId
}
// 2.相关合约统计
cooperationContractRelevantRepository, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId,
"limit": 1})
contractInfo, err := ptr.PersonCooperationContractStatistics(map[string]interface{}{
"orgId": orgId,
"userBaseId": userBaseId,
})
if err != nil {
return nil, err
}
// 3.个人分红统计
//creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
//var allDividends = &CreditAccountStatisticsResponse{}
//if err := creditAccountDao.DividendsStatistics(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}, allDividends); err != nil {
//cooperationContractRelevantRepository, _ := dao.NewCooperationContractUndertakerDao(ptr.transactionContext)
//cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId,
// "limit": 100,"distinctColumnContractNumber":1})
//if err != nil {
// return nil, err
//}
//allDividends.Accounting = allDividends.Total - allDividends.Accounted
// 3.个人分红统计
creditAccountDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
var allDividends float64
if allDividends, err = creditAccountDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}); err != nil {
return nil, err
}
//allDividends.Accounting = allDividends.Total - allDividends.Accounted
var ret = &cooperationCompanyStatisticsResponse{
OrgId: orgId,
CooperationProjectCount: cooperationProjectCount,
CooperationContractCount: cooperationContractCount,
CooperationContractCount: int64(contractInfo.ContractSum),
DividendsIncome: utils.Round(allDividends, 2),
}
return ret, nil
... ... @@ -96,10 +95,11 @@ type cooperationCompanyStatisticsResponse struct {
}
// 个人-用户合约统计
func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(queryOptions map[string]interface{}) (interface{}, error) {
func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(queryOptions map[string]interface{}) (*ContractSum, error) {
// 参数验证
var request = struct {
UserBaseId int64 `json:"userBaseId" valid:"Required"`
OrgId int64 `json:"orgId"`
}{}
if err := LoadQueryObject(queryOptions, &request); err != nil {
return nil, err
... ... @@ -112,10 +112,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que
return nil, nil
}
var response = struct {
ContractSum int `json:"contractSum"`
ContractStoppedSum int `json:"contractStoppedSum"`
}{}
var response = &ContractSum{}
if len(contractUndertakers) == 0 {
return response, nil
}
... ... @@ -128,6 +125,11 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que
return response, nil
}
type ContractSum struct {
ContractSum int `json:"contractSum"`
ContractStoppedSum int `json:"contractStoppedSum"`
}
func (ptr *CooperationStatisticsService) cooperationContractCount(contractIds []int64, status int) int {
var total int
var contract = new(models.CooperationContract)
... ...
... ... @@ -299,6 +299,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s
creditAccountRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
queryOptions["orgId"] = contract.Org.OrgId
queryOptions["isCanceled"] = false
_, creditAccounts, err := creditAccountRepository.Find(queryOptions)
if err != nil {
return res, err
... ...