作者 tangxuhui

更新

  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type CreateCooperationContractCommand struct {
  10 + CooperationContract struct {
  11 + CooperationContractId int `json:"cooperationContractId,string"`
  12 + // 共创合约描述
  13 + Description string `json:"Description"`
  14 + // 共创合约编号
  15 + CooperationContractNumber string `json:"cooperationContractNumber"`
  16 + // 共创项目编号,
  17 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  18 + // 共创合约发起部门编码
  19 + DepartmentId string `json:"departmentId"`
  20 + // 共创合约承接对象,1员工,2共创用户,3公开
  21 + CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`
  22 + // 共创合约名称
  23 + CooperationContractName string `json:"cooperationContractName"`
  24 + // 共创模式编码,手动输入,唯一确定
  25 + CooperationModeNumber string `json:"cooperationModeNumber"`
  26 + // 共创合约发起人uid
  27 + SponsorUserId string `json:"sponsorUserId"`
  28 + } `json:"cooperationContract"`
  29 +
  30 + // 业绩分红激励规则列表
  31 + DividendsIncentivesRules []struct {
  32 + // 关联的项目合约编号
  33 + CooperationContractNumber string `json:"cooperationContractNumber"`
  34 + // 推荐人抽成比例
  35 + ReferrerPercentage float64 `json:"referrerPercentage"`
  36 + // 业务员抽成比例
  37 + SalesmanPercentage float64 `json:"salesmanPercentage"`
  38 + // 分红规则激励百分点
  39 + DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`
  40 + // 分红规则激励阶段,
  41 + DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string,"`
  42 + // 分红规则激励阶段结束
  43 + DividendsIncentivesStageEnd int `json:"dividendsIncentivesStageEnd"`
  44 + // 分红规则激励阶段开始
  45 + DividendsIncentivesStageStart int `json:"dividendsIncentivesStageStart"`
  46 + } `json:"dividendsIncentivesRules"`
  47 + // 金额激励规则列表
  48 + MoneyIncentivesRules []struct {
  49 + // 金额激励规则ID
  50 + MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string,"`
  51 + // 关联的共创合约编号
  52 + CooperationContractNumber string `json:"cooperationContractNumber"`
  53 + // 激励金额
  54 + MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
  55 + // 金额激励阶段,
  56 + MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string,"`
  57 + // 金额激励规则时间
  58 + MoneyIncentivesTime int `json:"moneyIncentivesTime"`
  59 + // 推荐人抽成比例
  60 + ReferrerPercentage float64 `json:"referrerPercentage"`
  61 + // 业务员抽成比例
  62 + SalesmanPercentage float64 `json:"salesmanPercentage"`
  63 + } `json:"moneyIncentivesRules"`
  64 +
  65 + // 关联用户id
  66 + RelationUser []int `json:"relationUser"`
  67 + //承接人列表
  68 + ContractUndertaker []struct {
  69 + HasReferrer bool `json:"hasReferrer"`
  70 + HasSalesman bool `json:"hasSalesman"`
  71 + UsersId int `json:"usersId,string,"`
  72 + ReferrerUser struct {
  73 + UserId int `json:"userId,string,"`
  74 + } `json:"referrerUser"`
  75 + SalesmanUser struct {
  76 + UserId int `json:"userId"`
  77 + } `json:"salesmanUser"`
  78 + Attachment []struct {
  79 + Name string `json:"name"`
  80 + Type string `json:"type"`
  81 + Url string `json:"url"`
  82 + FileSize int `json:"fileSize"`
  83 + } `json:"attachment"`
  84 + } `json:"contractUndertaker"`
  85 +}
  86 +
  87 +func (createCooperationContractCommand *CreateCooperationContractCommand) Valid(validation *validation.Validation) {
  88 + validation.SetError("CustomValid", "未实现的自定义认证")
  89 +}
  90 +
  91 +func (createCooperationContractCommand *CreateCooperationContractCommand) ValidateCommand() error {
  92 + valid := validation.Validation{}
  93 + b, err := valid.Valid(createCooperationContractCommand)
  94 + if err != nil {
  95 + return err
  96 + }
  97 + if !b {
  98 + for _, validErr := range valid.Errors {
  99 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  100 + }
  101 + }
  102 + return nil
  103 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type EnableCooperationContractCommand struct {
  10 + // 共创合约ID
  11 + CooperationContractId []string `json:"cooperationContractId" valid:"Required"`
  12 + // 暂停和恢复的状态
  13 + Status int `json:"status,omitempty"`
  14 +}
  15 +
  16 +func (enableCooperationContractCommand *EnableCooperationContractCommand) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (enableCooperationContractCommand *EnableCooperationContractCommand) ValidateCommand() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(enableCooperationContractCommand)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/beego/beego/v2/core/validation"
  8 +)
  9 +
  10 +type UpdateCooperationContractCommand struct {
  11 + CooperationContract struct {
  12 + CooperationContractId int `json:"cooperationContractId,string"`
  13 + // 共创合约描述
  14 + Description string `json:"Description"`
  15 + // 共创合约编号
  16 + CooperationContractNumber string `json:"cooperationContractNumber"`
  17 + // 共创项目编号,
  18 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  19 + // 共创合约发起部门编码
  20 + DepartmentId string `json:"departmentId"`
  21 + // 共创合约承接对象,1员工,2共创用户,3公开
  22 + CooperationContractUndertakerType []int `json:"cooperationContractUndertakerType"`
  23 + // 共创合约名称
  24 + CooperationContractName string `json:"cooperationContractName"`
  25 + // 共创模式编码,手动输入,唯一确定
  26 + CooperationModeNumber string `json:"cooperationModeNumber"`
  27 + // 共创合约发起人uid
  28 + SponsorUserId string `json:"sponsorUserId"`
  29 + } `json:"cooperationContract"`
  30 +
  31 + // 业绩分红激励规则列表
  32 + DividendsIncentivesRules []struct {
  33 + // 关联的项目合约编号
  34 + CooperationContractNumber string `json:"cooperationContractNumber"`
  35 + // 推荐人抽成比例
  36 + ReferrerPercentage float64 `json:"referrerPercentage"`
  37 + // 业务员抽成比例
  38 + SalesmanPercentage float64 `json:"salesmanPercentage"`
  39 + // 分红规则激励百分点
  40 + DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`
  41 + // 分红规则激励阶段,
  42 + DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string,"`
  43 + // 分红规则激励阶段结束
  44 + DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"`
  45 + // 分红规则激励阶段开始
  46 + DividendsIncentivesStageStart time.Time `json:"dividendsIncentivesStageStart"`
  47 + } `json:"dividendsIncentivesRules"`
  48 + // 金额激励规则列表
  49 + MoneyIncentivesRules []struct {
  50 + // 金额激励规则ID
  51 + MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string,"`
  52 + // 关联的共创合约编号
  53 + CooperationContractNumber string `json:"cooperationContractNumber"`
  54 + // 激励金额
  55 + MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
  56 + // 金额激励阶段,
  57 + MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string,"`
  58 + // 金额激励规则时间
  59 + MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`
  60 + // 推荐人抽成比例
  61 + ReferrerPercentage float64 `json:"referrerPercentage"`
  62 + // 业务员抽成比例
  63 + SalesmanPercentage float64 `json:"salesmanPercentage"`
  64 + } `json:"moneyIncentivesRules"`
  65 +
  66 + // 关联用户id
  67 + RelationUser []int `json:"relationUser"`
  68 + //承接人列表
  69 + ContractUndertaker []struct {
  70 + HasReferrer bool `json:"hasReferrer"`
  71 + HasSalesman bool `json:"hasSalesman"`
  72 + UsersId int `json:"usersId,string,"`
  73 + ReferrerUser struct {
  74 + UserId int `json:"userId,string,"`
  75 + } `json:"referrerUser"`
  76 + SalesmanUser struct {
  77 + UserId int `json:"userId"`
  78 + } `json:"salesmanUser"`
  79 + Attachment []struct {
  80 + Name string `json:"name"`
  81 + Type string `json:"type"`
  82 + Url string `json:"url"`
  83 + FileSize int `json:"fileSize"`
  84 + } `json:"attachment"`
  85 + } `json:"contractUndertaker"`
  86 +}
  87 +
  88 +func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {
  89 + validation.SetError("CustomValid", "未实现的自定义认证")
  90 +}
  91 +
  92 +func (updateCooperationContractCommand *UpdateCooperationContractCommand) ValidateCommand() error {
  93 + valid := validation.Validation{}
  94 + b, err := valid.Valid(updateCooperationContractCommand)
  95 + if err != nil {
  96 + return err
  97 + }
  98 + if !b {
  99 + for _, validErr := range valid.Errors {
  100 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  101 + }
  102 + }
  103 + return nil
  104 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type GetCooperationContractQuery struct {
  10 + // 共创合约ID
  11 + CooperationContractId int64 `json:"cooperationContractId" valid:"Required"`
  12 +}
  13 +
  14 +func (getCooperationContractQuery *GetCooperationContractQuery) Valid(validation *validation.Validation) {
  15 +
  16 +}
  17 +
  18 +func (getCooperationContractQuery *GetCooperationContractQuery) ValidateQuery() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(getCooperationContractQuery)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 +)
  8 +
  9 +type ListCooperationContractQuery struct {
  10 + // 查询偏离量
  11 + PageNumber int `json:"pageNumber"`
  12 + // 查询限制
  13 + PageSize int `json:"pageSize" valid:"Required"`
  14 +}
  15 +
  16 +func (listCooperationContractQuery *ListCooperationContractQuery) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (listCooperationContractQuery *ListCooperationContractQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(listCooperationContractQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/query"
  7 +)
  8 +
  9 +// 共创合约管理
  10 +type CooperationContractService struct {
  11 +}
  12 +
  13 +// 创建共创合约管理
  14 +func (cooperationContractService *CooperationContractService) CreateCooperationContract(createCooperationContractCommand *command.CreateCooperationContractCommand) (interface{}, error) {
  15 + if err := createCooperationContractCommand.ValidateCommand(); err != nil {
  16 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  17 + }
  18 + return nil, nil
  19 +}
  20 +
  21 +// 暂停恢复共创合约
  22 +func (cooperationContractService *CooperationContractService) EnableCooperationContract(enableCooperationContractCommand *command.EnableCooperationContractCommand) (interface{}, error) {
  23 + if err := enableCooperationContractCommand.ValidateCommand(); err != nil {
  24 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  25 + }
  26 +
  27 + return nil, nil
  28 +}
  29 +
  30 +// 返回共创合约管理
  31 +func (cooperationContractService *CooperationContractService) GetCooperationContract(getCooperationContractQuery *query.GetCooperationContractQuery) (interface{}, error) {
  32 + if err := getCooperationContractQuery.ValidateQuery(); err != nil {
  33 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  34 + }
  35 + return nil, nil
  36 +}
  37 +
  38 +// 返回共创合约管理列表
  39 +func (cooperationContractService *CooperationContractService) ListCooperationContract(listCooperationContractQuery *query.ListCooperationContractQuery) (interface{}, error) {
  40 + if err := listCooperationContractQuery.ValidateQuery(); err != nil {
  41 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  42 + }
  43 + return nil, nil
  44 +}
  45 +
  46 +// 更新共创合约管理
  47 +func (cooperationContractService *CooperationContractService) UpdateCooperationContract(updateCooperationContractCommand *command.UpdateCooperationContractCommand) (interface{}, error) {
  48 + if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
  49 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  50 + }
  51 + return nil, nil
  52 +}
  53 +
  54 +func NewCooperationContractService(options map[string]interface{}) *CooperationContractService {
  55 + newCooperationContractService := &CooperationContractService{}
  56 + return newCooperationContractService
  57 +}
1 package allied_creation_cooperation 1 package allied_creation_cooperation
2 2
  3 +import "time"
  4 +
3 //创建共创合约 5 //创建共创合约
4 type ( 6 type (
5 ReqCooperationContractAdd struct { 7 ReqCooperationContractAdd struct {
  8 + // 共创合约描述
  9 + CooperationContractDescription string ` json:"cooperationContractDescription"`
  10 + // 共创合约编号
  11 + CooperationContractNumber string ` json:"cooperationContractNumber"`
  12 + // 共创项目编号,
  13 + CooperationProjectNumber string `json:"cooperationProjectNumber" `
  14 + // 共创合约发起部门编码
  15 + DepartmentNumber string `json:"departmentNumber"`
  16 + // 共创合约承接对象,1员工,2共创用户,3公开
  17 + CooperationContractUndertakerType []int ` json:"cooperationContractUndertakerType"`
  18 + // 共创合约名称
  19 + CooperationContractName string `json:"cooperationContractName"`
  20 + // 共创模式编码,手动输入,唯一确定
  21 + CooperationModeNumber string ` json:"cooperationModeNumber"`
  22 + // 共创合约发起人uid
  23 + SponsorUid string `json:"sponsorUid,omitempty"`
  24 + // 业绩分红激励规则列表
  25 + DividendsIncentivesRules []struct {
  26 + // 关联的项目合约编号
  27 + CooperationContractNumber string `json:"cooperationContractNumber"`
  28 + // 推荐人抽成比例
  29 + ReferrerPercentage float64 `json:"referrerPercentage"`
  30 + // 业务员抽成比例
  31 + SalesmanPercentage float64 `json:"salesmanPercentage"`
  32 + // 分红规则激励百分点
  33 + DividendsIncentivesPercentage float64 `json:"dividendsIncentivesPercentage"`
  34 + // 分红规则激励阶段,阶段返回时需要转换为中文数字
  35 + DividendsIncentivesStage int64 `json:"dividendsIncentivesStage,string"`
  36 + // 分红规则激励阶段结束
  37 + DividendsIncentivesStageEnd time.Time `json:"dividendsIncentivesStageEnd"`
  38 + // 分红规则激励阶段开始
  39 + DividendsIncentivesStageStart time.Time `json:"dividendsIncentivesStageStart"`
  40 + } `json:"dividendsIncentivesRules"`
  41 + // 金额激励规则列表
  42 + MoneyIncentivesRules []struct {
  43 + // 金额激励规则ID
  44 + MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"`
  45 + // 关联的共创合约编号
  46 + CooperationContractNumber string `json:"cooperationContractNumber"`
  47 + // 激励金额
  48 + MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
  49 + // 金额激励阶段,阶段返回时需要转换为中文数字
  50 + MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string"`
  51 + // 金额激励阶段有效期结束
  52 + MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"`
  53 + // 金额激励阶段有效期开始
  54 + MoneyIncentivesStageStart time.Time `json:"moneyIncentivesStageStart"`
  55 + // 金额激励规则时间
  56 + MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`
  57 + // 推荐人抽成比例
  58 + ReferrerPercentage float64 `json:"referrerPercentage"`
  59 + // 业务员抽成比例
  60 + SalesmanPercentage float64 `json:"salesmanPercentage"`
  61 + } `json:"moneyIncentivesRules"`
  62 + // 承接方列表
  63 + Undertakers []struct {
  64 + UserId int64 `json:"userId,string"`
  65 + // 用户基本id
  66 + UserBaseId int64 `json:"userBaseId,string"`
  67 + // 用户所属组织机构
  68 + Org struct {
  69 + // 组织机构ID
  70 + OrgId int64 `json:"orgId,string"`
  71 + // 组织名称
  72 + OrgName string `json:"orgName"`
  73 + }
  74 + } `json:"undertakers"`
  75 + // 相关人列表
  76 + // RelevantPeople []*domain.Relevant `cname:"相关人列表" json:"relevantPeople,omitempty"`
  77 + // 公司ID,通过集成REST上下文获取
  78 + // CompanyId int64 ` json:"companyId,string" `
  79 + // 组织机构ID
  80 + // OrgId int64 `json:"orgId,string" `
  81 + // 用户ID,
  82 + // UserId int64 `json:"userId,string" `
6 } 83 }
7 84
8 DataCooperationContractAdd struct { 85 DataCooperationContractAdd struct {