money_incentives_rule.go 3.7 KB
package domain

import "time"

// 金额激励规则实体
type MoneyIncentivesRule struct {
	// 金额激励规则ID
	MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"`
	// 关联的共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 激励金额
	MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
	// 金额激励阶段,阶段返回时需要转换为中文数字
	MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string"`
	// 金额激励阶段有效期结束
	MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"`
	// 金额激励阶段有效期开始
	MoneyIncentivesStageStart time.Time `json:"moneyIncentivesStageStart"`
	// 金额激励规则时间
	MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`
	// 推荐人抽成比例
	ReferrerPercentage float64 `json:"referrerPercentage"`
	// 业务员抽成比例
	SalesmanPercentage float64 `json:"salesmanPercentage"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
}

type MoneyIncentivesRuleRepository interface {
	Save(moneyIncentivesRule *MoneyIncentivesRule) (*MoneyIncentivesRule, error)
	Remove(moneyIncentivesRule *MoneyIncentivesRule) (*MoneyIncentivesRule, error)
	FindOne(queryOptions map[string]interface{}) (*MoneyIncentivesRule, error)
	Find(queryOptions map[string]interface{}) (int64, []*MoneyIncentivesRule, error)
}

func (moneyIncentivesRule *MoneyIncentivesRule) Identify() interface{} {
	if moneyIncentivesRule.MoneyIncentivesRuleId == 0 {
		return nil
	}
	return moneyIncentivesRule.MoneyIncentivesRuleId
}

func (moneyIncentivesRule *MoneyIncentivesRule) Update(data map[string]interface{}) error {
	if moneyIncentivesRuleId, ok := data["moneyIncentivesRuleId"]; ok {
		moneyIncentivesRule.MoneyIncentivesRuleId = moneyIncentivesRuleId.(int64)
	}
	if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
		moneyIncentivesRule.CooperationContractNumber = cooperationContractNumber.(string)
	}
	if moneyIncentivesAmount, ok := data["moneyIncentivesAmount"]; ok {
		moneyIncentivesRule.MoneyIncentivesAmount = moneyIncentivesAmount.(float64)
	}
	if moneyIncentivesStage, ok := data["moneyIncentivesStage"]; ok {
		moneyIncentivesRule.MoneyIncentivesStage = moneyIncentivesStage.(int64)
	}
	if moneyIncentivesStageEnd, ok := data["moneyIncentivesStageEnd"]; ok {
		moneyIncentivesRule.MoneyIncentivesStageEnd = moneyIncentivesStageEnd.(time.Time)
	}
	if moneyIncentivesStageStart, ok := data["moneyIncentivesStageStart"]; ok {
		moneyIncentivesRule.MoneyIncentivesStageStart = moneyIncentivesStageStart.(time.Time)
	}
	if moneyIncentivesTime, ok := data["moneyIncentivesTime"]; ok {
		moneyIncentivesRule.MoneyIncentivesTime = moneyIncentivesTime.(time.Time)
	}
	if referrerPercentage, ok := data["referrerPercentage"]; ok {
		moneyIncentivesRule.ReferrerPercentage = referrerPercentage.(float64)
	}
	if salesmanPercentage, ok := data["salesmanPercentage"]; ok {
		moneyIncentivesRule.SalesmanPercentage = salesmanPercentage.(float64)
	}
	if orgId, ok := data["orgId"]; ok {
		moneyIncentivesRule.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		moneyIncentivesRule.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		moneyIncentivesRule.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		moneyIncentivesRule.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		moneyIncentivesRule.Org.Company.CompanyName = companyName.(string)
	}
	return nil
}