package order

import (
	"github.com/beego/beego/v2/client/orm"
	"github.com/beego/beego/v2/core/logs"
	"time"
)

type OrderSettleInfo struct {
	Id               int
	PayProductCode   string
	PayProductName   string
	PayTypeCode      string
	RoadUid          string
	PayTypeName      string
	MerchantUid      string
	MerchantName     string
	MerchantOrderId  string
	BankOrderId      string
	SettleAmount     float64
	IsAllowSettle    string
	IsCompleteSettle string
	UpdateTime       time.Time
	CreateTime       time.Time
}

const ORDER_SETTLE_INFO = "order_settle_info"

func GetOrderSettleListByParams(params map[string]string) []OrderSettleInfo {
	o := orm.NewOrm()
	qs := o.QueryTable(ORDER_SETTLE_INFO)
	for k, v := range params {
		if len(v) > 0 {
			qs = qs.Filter(k, v)
		}
	}
	var orderSettleList []OrderSettleInfo
	if _, err := qs.Limit(-1).All(&orderSettleList); err != nil {
		logs.Error("get order settle list fail: ", err)
	}

	return orderSettleList
}
