|
@@ -28,7 +28,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte |
|
@@ -28,7 +28,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte |
28
|
if _, ok := queryOptions["limit"]; ok {
|
28
|
if _, ok := queryOptions["limit"]; ok {
|
29
|
queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
|
29
|
queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
|
30
|
}
|
30
|
}
|
31
|
- sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods
|
31
|
+ sql := fmt.Sprintf(`select order_good_name good_name,sum(coalesce(order_good_amount,0)) good_amount from order_goods
|
32
|
where company_id=? and org_id = ? and deleted_at is null %v
|
32
|
where company_id=? and org_id = ? and deleted_at is null %v
|
33
|
GROUP BY order_good_name
|
33
|
GROUP BY order_good_name
|
34
|
order by good_amount desc
|
34
|
order by good_amount desc
|
|
@@ -46,9 +46,14 @@ order by good_amount desc |
|
@@ -46,9 +46,14 @@ order by good_amount desc |
46
|
func (dao *OrderGoodDao) CooperationCompanyModeStatistics(queryOptions map[string]interface{}) ([]*domain.CooperationModeStatisticsDto, error) {
|
46
|
func (dao *OrderGoodDao) CooperationCompanyModeStatistics(queryOptions map[string]interface{}) ([]*domain.CooperationModeStatisticsDto, error) {
|
47
|
tx := dao.transactionContext.PgTx
|
47
|
tx := dao.transactionContext.PgTx
|
48
|
var goods []*domain.CooperationModeStatisticsDto
|
48
|
var goods []*domain.CooperationModeStatisticsDto
|
49
|
- sql := fmt.Sprintf(`select count(0) cooperation_people,sum(a.actually_paid_amount) dividends_estimate,b.cooperation_mode_number,sum(good_amount_count) order_amount
|
|
|
50
|
-from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
|
|
|
51
|
-where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.deleted_at is null and b.status = 1
|
49
|
+ // sql := fmt.Sprintf(`select count(0) cooperation_people,sum(a.actually_paid_amount) dividends_estimate,b.cooperation_mode_number,sum(good_amount_count) order_amount
|
|
|
50
|
+ //from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
|
|
|
51
|
+ //where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.deleted_at is null and b.status = 1
|
|
|
52
|
+ //group by b.cooperation_mode_number
|
|
|
53
|
+ //`)
|
|
|
54
|
+ sql := fmt.Sprintf(`select count(DISTINCT dividends_user->>'userId') cooperation_people,sum(a.dividends_amount) dividends_estimate,b.cooperation_mode_number
|
|
|
55
|
+from dividends_estimates a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
|
|
|
56
|
+where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.is_canceled is null and a.deleted_at is null and b.status = 1
|
52
|
group by b.cooperation_mode_number
|
57
|
group by b.cooperation_mode_number
|
53
|
`)
|
58
|
`)
|
54
|
_, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
|
59
|
_, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
|
|
@@ -67,6 +72,7 @@ func (dao *OrderGoodDao) CooperationUserModeStatistics(queryOptions map[string]i |
|
@@ -67,6 +72,7 @@ func (dao *OrderGoodDao) CooperationUserModeStatistics(queryOptions map[string]i |
67
|
query.ColumnExpr("sum(actually_paid_amount) settlement_amount")
|
72
|
query.ColumnExpr("sum(actually_paid_amount) settlement_amount")
|
68
|
query.ColumnExpr("a.cooperation_mode_number cooperation_mode_number")
|
73
|
query.ColumnExpr("a.cooperation_mode_number cooperation_mode_number")
|
69
|
query.Join("inner join cooperation_contracts as a").JoinOn("a.cooperation_contract_number = credit_account.cooperation_contract_number")
|
74
|
query.Join("inner join cooperation_contracts as a").JoinOn("a.cooperation_contract_number = credit_account.cooperation_contract_number")
|
|
|
75
|
+ //query.Join("inner join cooperation_contracts as a").JoinOn("a.cooperation_contract_number = credit_account.cooperation_contract_number")
|
70
|
if v, ok := queryOptions["userId"]; ok && v.(int64) > 0 {
|
76
|
if v, ok := queryOptions["userId"]; ok && v.(int64) > 0 {
|
71
|
query.Where(fmt.Sprintf(`credit_account.participator->>'userId'='%v' `, v))
|
77
|
query.Where(fmt.Sprintf(`credit_account.participator->>'userId'='%v' `, v))
|
72
|
}
|
78
|
}
|