...
|
...
|
@@ -17,7 +17,7 @@ func (dao *OrderDao) OrderStatics(option *domain.OrderStaticQuery) (count int, a |
|
|
order := new(models.Order)
|
|
|
q := tx.Model(order)
|
|
|
q.ColumnExpr("count(*) count")
|
|
|
q.ColumnExpr("sum(order_amount) total_order_amount")
|
|
|
q.ColumnExpr("sum(order_actual_amount) total_order_amount")
|
|
|
if option.PartnerId > 0 {
|
|
|
q.Where(`"order".partner_id =?`, option.PartnerId)
|
|
|
}
|
...
|
...
|
@@ -37,6 +37,38 @@ func (dao *OrderDao) OrderStatics(option *domain.OrderStaticQuery) (count int, a |
|
|
return
|
|
|
}
|
|
|
|
|
|
//分红订单
|
|
|
func (dao *OrderDao) DividendOrders(option *domain.DividendOrdersQueryOption) (count int, orders []*models.Order, err error) {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
q := tx.Model(&orders)
|
|
|
q.Column(`order.id`, `order.order_code`, `order.order_actual_amount`, `order.partner_bonus_percent`)
|
|
|
q.Where(`"order".order_status >=?`, domain.OrderStatusDeliverSome) //已经发货
|
|
|
if option.StartTime > 0 {
|
|
|
q.Where(`"order".delivery_time >=?`, time.Unix(option.StartTime/1000, 0))
|
|
|
}
|
|
|
if option.EndTime > 0 {
|
|
|
q.Where(`"order".delivery_time <?`, time.Unix(option.EndTime/1000, 0))
|
|
|
}
|
|
|
if option.DividendAction == 0 { //累计分红
|
|
|
if option.DetailAction == 0 { //已收明细
|
|
|
q.Join(`JOIN order_payment as a ON a.order_id="order".id`)
|
|
|
q.Where(`"a".bonus_status=?`, domain.BonusPaid)
|
|
|
} else if option.DetailAction == 1 { //未收明细
|
|
|
q.Where(`"order".order_actual_amount>"order".order_payment_amount`, domain.BonusWaitPay)
|
|
|
}
|
|
|
} else if option.DividendAction == 1 { //分红支出
|
|
|
q.Where(`"order".order_amount>"order".order_actual_amount`)
|
|
|
}
|
|
|
if option.Limit > 0 {
|
|
|
q.Limit(option.Limit)
|
|
|
}
|
|
|
if option.Offset > 0 {
|
|
|
q.Offset(option.Offset)
|
|
|
}
|
|
|
count, err = q.Distinct().SelectAndCount()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func NewOrderDao(transactionContext *transaction.TransactionContext) (*OrderDao, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|