...
|
...
|
@@ -28,7 +28,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte |
|
|
if _, ok := queryOptions["limit"]; ok {
|
|
|
queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
|
|
|
}
|
|
|
sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods
|
|
|
sql := fmt.Sprintf(`select order_good_name good_name,sum(coalesce(order_good_amount,0)) good_amount from order_goods
|
|
|
where company_id=? and org_id = ? and deleted_at is null %v
|
|
|
GROUP BY order_good_name
|
|
|
order by good_amount desc
|
...
|
...
|
@@ -46,9 +46,14 @@ order by good_amount desc |
|
|
func (dao *OrderGoodDao) CooperationCompanyModeStatistics(queryOptions map[string]interface{}) ([]*domain.CooperationModeStatisticsDto, error) {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
var goods []*domain.CooperationModeStatisticsDto
|
|
|
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
|
|
|
from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
|
|
|
where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.deleted_at is null and b.status = 1
|
|
|
// 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
|
|
|
//from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
|
|
|
//where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.deleted_at is null and b.status = 1
|
|
|
//group by b.cooperation_mode_number
|
|
|
//`)
|
|
|
sql := fmt.Sprintf(`select count(DISTINCT dividends_user->>'userId') cooperation_people,sum(a.dividends_amount) dividends_estimate,b.cooperation_mode_number
|
|
|
from dividends_estimates a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
|
|
|
where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.is_canceled is null and a.deleted_at is null and b.status = 1
|
|
|
group by b.cooperation_mode_number
|
|
|
`)
|
|
|
_, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
|
...
|
...
|
@@ -67,6 +72,7 @@ func (dao *OrderGoodDao) CooperationUserModeStatistics(queryOptions map[string]i |
|
|
query.ColumnExpr("sum(actually_paid_amount) settlement_amount")
|
|
|
query.ColumnExpr("a.cooperation_mode_number cooperation_mode_number")
|
|
|
query.Join("inner join cooperation_contracts as a").JoinOn("a.cooperation_contract_number = credit_account.cooperation_contract_number")
|
|
|
//query.Join("inner join cooperation_contracts as a").JoinOn("a.cooperation_contract_number = credit_account.cooperation_contract_number")
|
|
|
if v, ok := queryOptions["userId"]; ok && v.(int64) > 0 {
|
|
|
query.Where(fmt.Sprintf(`credit_account.participator->>'userId'='%v' `, v))
|
|
|
}
|
...
|
...
|
|