作者 yangfu

共创用户列表修改、合约数

... ... @@ -311,12 +311,11 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
var retMap = make([]interface{}, 0)
for i := range responses {
responses[i].CooperationTime = time.Now().Unix() * 1000
unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount
item := map[string]interface{}{
"dividendsOrderAmount": responses[i].DividendsOrderAmount,
"actuallyPaidAmount": responses[i].ActuallyPaidAmount,
"unPaidAmount": unPaidAmount,
"unPaidAmount": responses[i].UnPaidAmount,
"cooperationTime": time.Now().Unix() * 1000,
"participator": map[string]interface{}{
"userId": responses[i].UserId,
... ...
... ... @@ -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)
}
... ...