pg_order_bestshop.go 808 字节
package dao

import (
	"fmt"

	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction"
)

type OrderBestshopDao struct {
	transactionContext *transaction.TransactionContext
}

func NewOrderBestshopDao(transactionContext *transaction.TransactionContext) (*OrderBestshopDao, error) {
	if transactionContext == nil {
		return nil, fmt.Errorf("transactionContext参数不能为nil")
	} else {
		return &OrderBestshopDao{
			transactionContext: transactionContext,
		}, nil
	}
}

func (dao OrderBestshopDao) OrderExist(orderCode string) (bool, error) {
	tx := dao.transactionContext.GetDB()
	m := models.OrderBestshop{}
	query := tx.Model(&m).Where("order_code=?", orderCode)
	ok, err := query.Exists()
	return ok, err
}