dividends_incentives_rule.go 3.4 KB
package domain

import (
	"time"
)

// DividendsIncentivesRule 金额激励规则实体
type DividendsIncentivesRule struct {
	// 分红规则ID
	DividendsIncentivesRuleId int64 `json:"dividendsIncentivesRuleId,string"`
	// 关联的项目合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 推荐人抽成比例
	ReferrerPercentage float64 `json:"referrerPercentage"`
	// 业务员抽成比例
	SalesmanPercentage float64 `json:"salesmanPercentage"`
	// 分红规则激励百分点
	DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`
	// 分红规则激励阶段,阶段返回时需要转换为中文数字
	DividendsIncentivesStage int32 `json:"dividendsIncentivesStage"`
	// 分红激励规则阶段中文表示
	DividendsIncentivesStageCN string `json:"dividendsIncentivesStageCN"`
	// 分红规则激励阶段结束
	DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"`
	// 分红规则激励阶段开始
	DividendsIncentivesStageStart time.Time `json:"dividendsIncentivesStageStart"`
	// 分红激励规则说明
	Remarks string `json:"remarks"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 更新时间
	UpdatedAt time.Time `json:"-"`
	// 删除时间
	DeletedAt time.Time `json:"-"`
	// 创建时间
	CreatedAt time.Time `json:"-"`
}

type DividendsIncentivesRuleRepository interface {
	Save(dividendsIncentivesRule *DividendsIncentivesRule) (*DividendsIncentivesRule, error)
	Remove(dividendsIncentivesRule *DividendsIncentivesRule) (*DividendsIncentivesRule, error)
	FindOne(queryOptions map[string]interface{}) (*DividendsIncentivesRule, error)
	Find(queryOptions map[string]interface{}) (int64, []*DividendsIncentivesRule, error)
}

func (dividendsIncentivesRule *DividendsIncentivesRule) Identify() interface{} {
	if dividendsIncentivesRule.DividendsIncentivesRuleId == 0 {
		return nil
	}
	return dividendsIncentivesRule.DividendsIncentivesRuleId
}

func (dividendsIncentivesRule *DividendsIncentivesRule) Update(data map[string]interface{}) error {
	if dividendsIncentivesRuleId, ok := data["dividendsIncentivesRuleId"]; ok {
		dividendsIncentivesRule.DividendsIncentivesRuleId = dividendsIncentivesRuleId.(int64)
	}
	if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
		dividendsIncentivesRule.CooperationContractNumber = cooperationContractNumber.(string)
	}
	if referrerPercentage, ok := data["referrerPercentage"]; ok {
		dividendsIncentivesRule.ReferrerPercentage = referrerPercentage.(float64)
	}
	if salesmanPercentage, ok := data["salesmanPercentage"]; ok {
		dividendsIncentivesRule.SalesmanPercentage = salesmanPercentage.(float64)
	}
	if dividendsIncentivesPercentage, ok := data["dividendsIncentivesPercentage"]; ok {
		dividendsIncentivesRule.DividendsIncentivesPercentage = dividendsIncentivesPercentage.(float64)
	}
	if dividendsIncentivesStage, ok := data["dividendsIncentivesStage"]; ok {
		dividendsIncentivesRule.DividendsIncentivesStage = dividendsIncentivesStage.(int32)
	}
	if dividendsIncentivesStageEnd, ok := data["dividendsIncentivesStageEnd"]; ok {
		dividendsIncentivesRule.DividendsIncentivesStageEnd = dividendsIncentivesStageEnd.(time.Time)
	}
	if dividendsIncentivesStageStart, ok := data["dividendsIncentivesStageStart"]; ok {
		dividendsIncentivesRule.DividendsIncentivesStageStart = dividendsIncentivesStageStart.(time.Time)
	}
	dividendsIncentivesRule.UpdatedAt = time.Now()
	return nil
}