update_cooperation_contract.go 3.7 KB
package command

import (
	"fmt"

	"github.com/beego/beego/v2/core/validation"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)

type UpdateCooperationContractCommand struct {
	//操作人
	Operator            domain.Operator `json:"-"`
	CooperationContract struct {
		CooperationContractId int `json:"cooperationContractId,string"`
		// 共创合约描述
		CooperationContractDescription string `json:"cooperationContractDescription"`
		// 共创合约编号
		CooperationContractNumber string `json:"cooperationContractNumber"`
		// 共创项目编号,
		CooperationProjectNumber string `json:"cooperationProjectNumber"`
		// 共创合约发起部门id
		DepartmentId string `json:"departmentId"`
		// 共创合约承接对象,1员工,2共创用户,3公开
		CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`
		// 共创合约名称
		CooperationContractName string `json:"cooperationContractName"`
		// 共创模式编码,
		CooperationModeNumber string `json:"cooperationModeNumber"`
		// 共创合约发起人uid
		SponsorUserId string `json:"sponsorUserId"`
	} `json:"cooperationContract"`
	// 业绩分红激励规则列表
	DividendsIncentivesRules []struct {
		DividendsIncentivesRuleId string `json:"dividendsIncentivesRuleId"`
		// 关联的项目合约编号
		CooperationContractNumber string `json:"cooperationContractNumber"`
		// 推荐人抽成比例
		ReferrerPercentage float64 `json:"referrerPercentage"`
		// 业务员抽成比例
		SalesmanPercentage float64 `json:"salesmanPercentage"`
		// 分红规则激励百分点
		DividendsPercentage float64 `json:"dividendsPercentage"`
		// 分红规则激励阶段,
		DividendsStage int `json:"dividendsStage"`
		// 分红规则激励阶段结束
		DividendsStageEnd int `json:"dividendsStageEnd"`
		// 分红规则激励阶段开始
		DividendsStageStart int    `json:"dividendsStageStart"`
		Remarks             string `json:"remarks"`
	} `json:"dividendsIncentivesRules"`
	// 金额激励规则列表
	MoneyIncentivesRules []struct {
		// 金额激励规则ID
		MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string,"`
		// 关联的共创合约编号
		CooperationContractNumber string `json:"cooperationContractNumber"`
		// 激励金额
		MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
		// 金额激励阶段
		MoneyIncentivesStage int `json:"moneyIncentivesStage"`
		// 金额激励规则时间
		MoneyIncentivesTime int `json:"moneyIncentivesTime"`
		// 推荐人抽成比例
		ReferrerPercentage float64 `json:"referrerPercentage"`
		// 业务员抽成比例
		SalesmanPercentage float64 `json:"salesmanPercentage"`
		Remarks            string  `json:"remarks"`
	} `json:"moneyIncentivesRules"`
	// 承接方列表
	Undertakers []struct {
		UndertakerId int                 `json:"undertakerId,string"` //承接人列表id
		UserId       int                 `json:"userId,string"`       //用户id
		RerferrerId  int                 `json:"rerferrerId,string"`  //推荐人用户id
		SalesmanId   int                 `json:"salesmanId,string"`   //关联业务员id
		Attachment   []domain.Attachment `json:"attachment"`
	} `json:"undertakers"`
	//关联业务员
	RelevantIds []string `json:"relevantIds"`
}

func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {

}

func (updateCooperationContractCommand *UpdateCooperationContractCommand) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(updateCooperationContractCommand)
	if err != nil {
		return err
	}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}