pg_order_service.go 1.1 KB
package domainService

import (
	coreDomain "github.com/linmadan/egglib-go/core/domain"
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain/event"
	"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction"
)

type OrderServices struct {
	coreDomain.BaseEventPublisher
	transactionContext *transaction.TransactionContext
}

//UpdateOrderGoodData 修改订单中的货品数据
func (serve OrderServices) UpdateOrderGoodData(orderId int64, goodId int64, adminId int64, updateData map[string]string) error {
	var err error
	//TODO数据更新操作
	//事件发布
	modifyEvent := event.OrderGoodModify{
		OrderId:        orderId,
		GoodId:         goodId,
		AdminId:        adminId,
		UpdateGoodData: updateData,
	}
	if err = serve.Publish(modifyEvent); err != nil {
		return err
	}
	return nil
}

//PayOrderGoodBonus 支付订单中货品的分红
func (serve OrderServices) PayOrderGoodBonus(orderId int64, goodId int64, adminId int64) error {
	var err error
	//TODO
	payEvent := event.PayOrderGoodBonus{
		OrderId: orderId,
		GoodId:  goodId,
		AdminId: adminId,
	}
	if err = serve.Publish(payEvent); err != nil {
		return err
	}
	return nil
}