package cmb

import (
	"context"
	"voucher/internal/biz/bo"
	"voucher/internal/biz/vo"
	"voucher/internal/pkg/uid"
)

func (v *Cmb) Order(ctx context.Context, req *bo.OrderCreateReqBo, product *bo.ProductBo) (orderNo string, err error) {

	orderNo, err = v.GenerateMixRepo.GeneratorString(ctx, uid.Order)
	if err != nil {
		return
	}

	o := &bo.OrderBo{
		OrderNo:     orderNo,
		OutBizNo:    req.OutBizNo,
		ProductNo:   req.ProductNo,
		Account:     req.Account,
		AppID:       req.AppID,
		MerchantNo:  product.MchId,
		Channel:     product.Channel,
		BatchNo:     product.BatchNo,
		NotifyUrl:   v.bc.Cmb.NotifyUrl,
		AccountType: vo.OrderAccountTypeOpenId,
		Type:        vo.OrderTypeCmb,
		Status:      vo.OrderStatusWait,
	}

	if _, err = v.OrderRepo.Create(ctx, o); err != nil {
		return
	}

	return
}

func (v *Cmb) Query(ctx context.Context, productNo string) (reps *bo.OrderCreateRepBo, err error) {
	return
}

func (v *Cmb) Notify(ctx context.Context, order *bo.OrderBo) (err error) {
	return
}
