作者 yangfu

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

@@ -311,12 +311,11 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query @@ -311,12 +311,11 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
311 var retMap = make([]interface{}, 0) 311 var retMap = make([]interface{}, 0)
312 for i := range responses { 312 for i := range responses {
313 responses[i].CooperationTime = time.Now().Unix() * 1000 313 responses[i].CooperationTime = time.Now().Unix() * 1000
314 - unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount  
315 314
316 item := map[string]interface{}{ 315 item := map[string]interface{}{
317 "dividendsOrderAmount": responses[i].DividendsOrderAmount, 316 "dividendsOrderAmount": responses[i].DividendsOrderAmount,
318 "actuallyPaidAmount": responses[i].ActuallyPaidAmount, 317 "actuallyPaidAmount": responses[i].ActuallyPaidAmount,
319 - "unPaidAmount": unPaidAmount, 318 + "unPaidAmount": responses[i].UnPaidAmount,
320 "cooperationTime": time.Now().Unix() * 1000, 319 "cooperationTime": time.Now().Unix() * 1000,
321 "participator": map[string]interface{}{ 320 "participator": map[string]interface{}{
322 "userId": responses[i].UserId, 321 "userId": responses[i].UserId,
@@ -119,21 +119,21 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que @@ -119,21 +119,21 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que
119 if len(contractUndertakers) == 0 { 119 if len(contractUndertakers) == 0 {
120 return response, nil 120 return response, nil
121 } 121 }
122 - var numbers []string 122 + var contractIds []int64
123 for i := range contractUndertakers { 123 for i := range contractUndertakers {
124 - numbers = append(numbers, contractUndertakers[i].CooperationContractNumber) 124 + contractIds = append(contractIds, contractUndertakers[i].CooperationContractId)
125 } 125 }
126 - response.ContractSum = ptr.cooperationContractCount(numbers, 0)  
127 - response.ContractStoppedSum = ptr.cooperationContractCount(numbers, 2) 126 + response.ContractSum = ptr.cooperationContractCount(contractIds, 0)
  127 + response.ContractStoppedSum = ptr.cooperationContractCount(contractIds, 2)
128 return response, nil 128 return response, nil
129 } 129 }
130 130
131 -func (ptr *CooperationStatisticsService) cooperationContractCount(numbers []string, status int) int { 131 +func (ptr *CooperationStatisticsService) cooperationContractCount(contractIds []int64, status int) int {
132 var total int 132 var total int
133 var contract = new(models.CooperationContract) 133 var contract = new(models.CooperationContract)
134 query := ptr.transactionContext.PgDd.Model(contract) 134 query := ptr.transactionContext.PgDd.Model(contract)
135 query.ColumnExpr("count(*) total") 135 query.ColumnExpr("count(*) total")
136 - query.Where("cooperation_contract_number in (?)", pg.In(numbers)) 136 + query.Where("cooperation_contract_id in (?)", pg.In(contractIds))
137 if status > 0 { 137 if status > 0 {
138 query.Where("status =? ", status) 138 query.Where("status =? ", status)
139 } 139 }