package utils

import "github.com/break/junhong_cmp_fiber/internal/model"

func CalculateCostPrice(allocation *model.ShopSeriesAllocation, orderAmount int64) int64 {
	if allocation.BaseCommissionMode == model.CommissionModeFixed {
		return orderAmount - allocation.BaseCommissionValue
	} else if allocation.BaseCommissionMode == model.CommissionModePercent {
		commission := orderAmount * allocation.BaseCommissionValue / 1000
		return orderAmount - commission
	}
	return orderAmount
}
