...
|
...
|
@@ -4,6 +4,7 @@ import ( |
|
|
"fmt"
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
"github.com/go-pg/pg/v10/orm"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
|
|
|
. "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
|
...
|
...
|
@@ -54,12 +55,31 @@ func (dao *PartnerInfoDao) PartnerStatic(queryOptions map[string]interface{}) (c |
|
|
return
|
|
|
}
|
|
|
|
|
|
//func(dao *PartnerInfoDao)PartnerCompanyInfo(queryOptions map[string]interface{})(values map[string]interface{},err error){
|
|
|
//// tx := dao.transactionContext.PgTx
|
|
|
//// m := new(models.PartnerInfo)
|
|
|
//// query := NewQuery(tx.Model(m), queryOptions)
|
|
|
//// query.SetWhere("status=?","status")
|
|
|
////}
|
|
|
func (dao *PartnerInfoDao) PartnerStatics(queryOptions map[string]interface{}) (statics []*domain.PartnerStatics, err error) {
|
|
|
tx := dao.transactionContext.PgDd
|
|
|
//m := new(models.PartnerInfo)
|
|
|
sql := fmt.Sprintf(`select A.*,
|
|
|
(B.amount1+C.amount2) amount,(B.bonus1+C.bonus2) bonus,(B.bonus_expense1 + C.bonus_expense2) bonus_expense
|
|
|
from
|
|
|
(
|
|
|
select * from partner_info
|
|
|
WHERE (id in (1,2))
|
|
|
)
|
|
|
A left join
|
|
|
(
|
|
|
SELECT partner_id,count(*) total1,sum(plan_order_amount) amount1, sum(plan_partner_bonus) bonus1, sum(partner_bonus_expense) bonus_expense1 FROM "order_base" AS "order_base"
|
|
|
WHERE (partner_id in (1,2)) and order_type =1
|
|
|
GROUP BY partner_id
|
|
|
) B on A."id" = B.partner_id
|
|
|
left join
|
|
|
(
|
|
|
select partner_info_id,count(*) total2,0 amount2, sum(bonus) bonus2, sum(bonus_expense) bonus_expense2 from business_bonus
|
|
|
WHERE (partner_info_id in (1,2)) and is_disable=1
|
|
|
GROUP BY partner_info_id
|
|
|
) C on A."id"= C."partner_info_id"`)
|
|
|
tx.Query(&statics, sql)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func NewPartnerInfoDao(transactionContext *transaction.TransactionContext) (*PartnerInfoDao, error) {
|
|
|
if transactionContext == nil {
|
...
|
...
|
|