...
|
...
|
@@ -119,21 +119,21 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que |
|
|
if len(contractUndertakers) == 0 {
|
|
|
return response, nil
|
|
|
}
|
|
|
var numbers []string
|
|
|
var contractIds []int64
|
|
|
for i := range contractUndertakers {
|
|
|
numbers = append(numbers, contractUndertakers[i].CooperationContractNumber)
|
|
|
contractIds = append(contractIds, contractUndertakers[i].CooperationContractId)
|
|
|
}
|
|
|
response.ContractSum = ptr.cooperationContractCount(numbers, 0)
|
|
|
response.ContractStoppedSum = ptr.cooperationContractCount(numbers, 2)
|
|
|
response.ContractSum = ptr.cooperationContractCount(contractIds, 0)
|
|
|
response.ContractStoppedSum = ptr.cooperationContractCount(contractIds, 2)
|
|
|
return response, nil
|
|
|
}
|
|
|
|
|
|
func (ptr *CooperationStatisticsService) cooperationContractCount(numbers []string, status int) int {
|
|
|
func (ptr *CooperationStatisticsService) cooperationContractCount(contractIds []int64, status int) int {
|
|
|
var total int
|
|
|
var contract = new(models.CooperationContract)
|
|
|
query := ptr.transactionContext.PgDd.Model(contract)
|
|
|
query.ColumnExpr("count(*) total")
|
|
|
query.Where("cooperation_contract_number in (?)", pg.In(numbers))
|
|
|
query.Where("cooperation_contract_id in (?)", pg.In(contractIds))
|
|
|
if status > 0 {
|
|
|
query.Where("status =? ", status)
|
|
|
}
|
...
|
...
|
|