作者 陈志颖

feat:共创合约模型和仓储调整

1 package domain 1 package domain
2 2
3 -import "time" 3 +import (
  4 + "time"
  5 +)
4 6
5 // CooperationContract 共创项目合约实体 7 // CooperationContract 共创项目合约实体
6 type CooperationContract struct { 8 type CooperationContract struct {
@@ -30,6 +32,10 @@ type CooperationContract struct { @@ -30,6 +32,10 @@ type CooperationContract struct {
30 Company *Company `json:"company"` 32 Company *Company `json:"company"`
31 // 操作人 33 // 操作人
32 Operator *User `json:"operator"` 34 Operator *User `json:"operator"`
  35 + // 分红激励规则
  36 + DividendsIncentivesRules []*DividendsIncentivesRule `json:"dividendsIncentivesRules"`
  37 + // 金额激励规则
  38 + MoneyIncentivesRules []*MoneyIncentivesRule `json:"moneyIncentivesRules"`
33 // 操作时间 39 // 操作时间
34 OperateTime time.Time `json:"operateTime"` 40 OperateTime time.Time `json:"operateTime"`
35 // 创建时间 41 // 创建时间
@@ -17,8 +17,8 @@ type ContractUndertakerFeedback struct { @@ -17,8 +17,8 @@ type ContractUndertakerFeedback struct {
17 CooperationContractNumber string `comment:"共创合约编号"` 17 CooperationContractNumber string `comment:"共创合约编号"`
18 // 共创合约承接人 18 // 共创合约承接人
19 ContractUndertaker *domain.User `comment:"共创合约承接人"` 19 ContractUndertaker *domain.User `comment:"共创合约承接人"`
20 - // 共创模式  
21 - CooperationMode *domain.CooperationMode `comment:"共创模式"` 20 + // 共创模式编号
  21 + CooperationModeNumber string `comment:"共创模式编号"`
22 // 数据所属组织机构 22 // 数据所属组织机构
23 Org *domain.Org `comment:"数据所属组织机构"` 23 Org *domain.Org `comment:"数据所属组织机构"`
24 // 公司 24 // 公司
@@ -26,7 +26,7 @@ type CooperationApplication struct { @@ -26,7 +26,7 @@ type CooperationApplication struct {
26 // 共创申请时间 26 // 共创申请时间
27 CooperationApplyTime time.Time `comment:"共创申请时间"` 27 CooperationApplyTime time.Time `comment:"共创申请时间"`
28 // 共创项目编号 28 // 共创项目编号
29 - CooperationProject *domain.CooperationProject `comment:"共创项目编号"` 29 + CooperationProjectNumber string `comment:"共创项目编号"`
30 // 数据所属组织机构 30 // 数据所属组织机构
31 Org *domain.Org `comment:"数据所属组织机构"` 31 Org *domain.Org `comment:"数据所属组织机构"`
32 // 公司 32 // 公司
@@ -23,8 +23,8 @@ type CooperationContract struct { @@ -23,8 +23,8 @@ type CooperationContract struct {
23 CooperationContractUndertakerType []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"` 23 CooperationContractUndertakerType []int32 `comment:"共创合约承接对象,1员工,2共创用户,3公开" pg:",array"`
24 // 共创合约发起人 24 // 共创合约发起人
25 CooperationContractSponsor *domain.User `comment:"共创合约发起人"` 25 CooperationContractSponsor *domain.User `comment:"共创合约发起人"`
26 - // 共创模式或者合伙模式  
27 - CooperationMode *domain.CooperationMode `comment:"共创模式或者合伙模式"` 26 + // 共创模式编号
  27 + CooperationModeNumber string `comment:"共创模式编号"`
28 // 合约状态,1启用,2禁用 28 // 合约状态,1启用,2禁用
29 Status int32 `comment:"合约状态,1启用,2禁用"` 29 Status int32 `comment:"合约状态,1启用,2禁用"`
30 // 数据所属组织机构 30 // 数据所属组织机构
1 package models 1 package models
2 2
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 + "time"
  6 +)
  7 +
3 type DividendsOrder struct { 8 type DividendsOrder struct {
4 tableName string `comment:"分红订单实体" pg:"dividends_orders,alias:dividends_order"` 9 tableName string `comment:"分红订单实体" pg:"dividends_orders,alias:dividends_order"`
5 // 分红订单ID 10 // 分红订单ID
@@ -11,7 +16,7 @@ type DividendsOrder struct { @@ -11,7 +16,7 @@ type DividendsOrder struct {
11 // 分红订单金额 16 // 分红订单金额
12 DividendsOrderAmount float64 `comment:"分红订单金额"` 17 DividendsOrderAmount float64 `comment:"分红订单金额"`
13 // 订单业务员 18 // 订单业务员
14 - OrderSalesman *User `comment:"订单业务员"` 19 + OrderSalesman *domain.User `comment:"订单业务员"`
15 // 订单产生时间 20 // 订单产生时间
16 OrderTime time.Time `comment:"订单产生时间"` 21 OrderTime time.Time `comment:"订单产生时间"`
17 // 分红订单分红时间 22 // 分红订单分红时间
@@ -19,13 +24,13 @@ type DividendsOrder struct { @@ -19,13 +24,13 @@ type DividendsOrder struct {
19 // 分红订单分红状态,1待分红,2已分红,3部分分红 24 // 分红订单分红状态,1待分红,2已分红,3部分分红
20 DividendStatus int32 `comment:"分红订单分红状态,1待分红,2已分红,3部分分红"` 25 DividendStatus int32 `comment:"分红订单分红状态,1待分红,2已分红,3部分分红"`
21 // 区域 26 // 区域
22 - Region *RegionInfo `comment:"区域"` 27 + Region *domain.RegionInfo `comment:"区域"`
23 // 客户姓名 28 // 客户姓名
24 CustomerName string `comment:"客户姓名"` 29 CustomerName string `comment:"客户姓名"`
25 // 数据所属组织机构 30 // 数据所属组织机构
26 - Org *Org `comment:"数据所属组织机构"` 31 + Org *domain.Org `comment:"数据所属组织机构"`
27 // 公司 32 // 公司
28 - Company *Company `comment:"公司"` 33 + Company *domain.Company `comment:"公司"`
29 // 创建时间 34 // 创建时间
30 CreatedAt time.Time `comment:"创建时间"` 35 CreatedAt time.Time `comment:"创建时间"`
31 // 删除时间 36 // 删除时间
@@ -35,5 +40,5 @@ type DividendsOrder struct { @@ -35,5 +40,5 @@ type DividendsOrder struct {
35 // 操作时间 40 // 操作时间
36 OperateTime time.Time `comment:"操作时间"` 41 OperateTime time.Time `comment:"操作时间"`
37 // 操作人 42 // 操作人
38 - Operator *User `comment:"操作人"` 43 + Operator *domain.User `comment:"操作人"`
39 } 44 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type MoneyIncentivesRule struct { 8 type MoneyIncentivesRule struct {
9 tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"` 9 tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"`
10 // 金额激励规则ID 10 // 金额激励规则ID
11 - MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"` 11 + MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk:money_incentives_rule_id"`
12 // 关联的共创合约编号 12 // 关联的共创合约编号
13 CooperationContractNumber string `comment:"关联的共创合约编号"` 13 CooperationContractNumber string `comment:"关联的共创合约编号"`
14 // 激励金额 14 // 激励金额
@@ -5,18 +5,33 @@ import ( @@ -5,18 +5,33 @@ import (
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
6 ) 6 )
7 7
8 -func TransformToContractUndertakerFeedbackDomainModelFromPgModels(contractUndertakerFeedbackModel *models.ContractUndertakerFeedback) (*domain.ContractUndertakerFeedback, error) { 8 +func TransformToContractUndertakerFeedbackDomainModelFromPgModels(
  9 + contractUndertakerFeedbackModel *models.ContractUndertakerFeedback,
  10 + cooperationMode *models.CooperationMode) (*domain.ContractUndertakerFeedback, error) {
9 return &domain.ContractUndertakerFeedback{ 11 return &domain.ContractUndertakerFeedback{
10 FeedbackId: contractUndertakerFeedbackModel.FeedbackId, 12 FeedbackId: contractUndertakerFeedbackModel.FeedbackId,
11 FeedbackAttachment: contractUndertakerFeedbackModel.FeedbackAttachment, 13 FeedbackAttachment: contractUndertakerFeedbackModel.FeedbackAttachment,
12 FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent, 14 FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent,
13 CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber, 15 CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber,
14 ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker, 16 ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker,
15 - CooperationMode: contractUndertakerFeedbackModel.CooperationMode,  
16 - Org: contractUndertakerFeedbackModel.Org,  
17 - Company: contractUndertakerFeedbackModel.Company,  
18 - UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,  
19 - DeletedAt: contractUndertakerFeedbackModel.DeletedAt,  
20 - CreatedAt: contractUndertakerFeedbackModel.CreatedAt, 17 + CooperationMode: &domain.CooperationMode{
  18 + CooperationModeId: cooperationMode.CooperationModeId,
  19 + CooperationModeNumber: cooperationMode.CooperationModeNumber,
  20 + CooperationModeName: cooperationMode.CooperationModeName,
  21 + Status: cooperationMode.Status,
  22 + Org: cooperationMode.Org,
  23 + Company: cooperationMode.Company,
  24 + Remarks: cooperationMode.Remarks,
  25 + Operator: cooperationMode.Operator,
  26 + OperateTime: cooperationMode.OperateTime,
  27 + UpdatedAt: cooperationMode.UpdatedAt,
  28 + DeletedAt: cooperationMode.DeletedAt,
  29 + CreatedAt: cooperationMode.CreatedAt,
  30 + },
  31 + Org: contractUndertakerFeedbackModel.Org,
  32 + Company: contractUndertakerFeedbackModel.Company,
  33 + UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,
  34 + DeletedAt: contractUndertakerFeedbackModel.DeletedAt,
  35 + CreatedAt: contractUndertakerFeedbackModel.CreatedAt,
21 }, nil 36 }, nil
22 } 37 }
@@ -5,7 +5,9 @@ import ( @@ -5,7 +5,9 @@ import (
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
6 ) 6 )
7 7
8 -func TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplicationModel *models.CooperationApplication) (*domain.CooperationApplication, error) { 8 +func TransformToCooperationApplicationDomainModelFromPgModels(
  9 + cooperationApplicationModel *models.CooperationApplication,
  10 + cooperationProject *models.CooperationProject) (*domain.CooperationApplication, error) {
9 return &domain.CooperationApplication{ 11 return &domain.CooperationApplication{
10 CooperationApplicationId: cooperationApplicationModel.CooperationApplicationId, 12 CooperationApplicationId: cooperationApplicationModel.CooperationApplicationId,
11 CooperationApplicationApplicant: cooperationApplicationModel.CooperationApplicationApplicant, 13 CooperationApplicationApplicant: cooperationApplicationModel.CooperationApplicationApplicant,
@@ -16,11 +18,28 @@ func TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplica @@ -16,11 +18,28 @@ func TransformToCooperationApplicationDomainModelFromPgModels(cooperationApplica
16 CooperationApplicationVerifyDescription: cooperationApplicationModel.CooperationApplicationVerifyDescription, 18 CooperationApplicationVerifyDescription: cooperationApplicationModel.CooperationApplicationVerifyDescription,
17 CooperationApplicationVerifyTime: cooperationApplicationModel.CooperationApplicationVerifyTime, 19 CooperationApplicationVerifyTime: cooperationApplicationModel.CooperationApplicationVerifyTime,
18 CooperationApplyTime: cooperationApplicationModel.CooperationApplyTime, 20 CooperationApplyTime: cooperationApplicationModel.CooperationApplyTime,
19 - CooperationProject: cooperationApplicationModel.CooperationProject,  
20 - Org: cooperationApplicationModel.Org,  
21 - Company: cooperationApplicationModel.Company,  
22 - CreatedAt: cooperationApplicationModel.CreatedAt,  
23 - DeletedAt: cooperationApplicationModel.DeletedAt,  
24 - UpdatedAt: cooperationApplicationModel.UpdatedAt, 21 + CooperationProject: &domain.CooperationProject{
  22 + CooperationProjectId: cooperationProject.CooperationProjectId,
  23 + CooperationProjectNumber: cooperationProject.CooperationProjectNumber,
  24 + CooperationProjectDescription: cooperationProject.CooperationProjectDescription,
  25 + CooperationProjectName: cooperationProject.CooperationProjectName,
  26 + CooperationProjectPublishTime: cooperationProject.CooperationProjectPublishTime,
  27 + CooperationProjectPublisher: cooperationProject.CooperationProjectPublisher,
  28 + CooperationProjectSponsor: cooperationProject.CooperationProjectSponsor,
  29 + CooperationProjectUndertakerType: cooperationProject.CooperationProjectUndertakerType,
  30 + Org: cooperationProject.Org,
  31 + Company: cooperationProject.Company,
  32 + Operator: cooperationProject.Operator,
  33 + OperateTime: cooperationProject.OperateTime,
  34 + Status: cooperationProject.Status,
  35 + UpdatedAt: cooperationProject.UpdatedAt,
  36 + DeletedAt: cooperationProject.DeletedAt,
  37 + CreatedAt: cooperationProject.CreatedAt,
  38 + },
  39 + Org: cooperationApplicationModel.Org,
  40 + Company: cooperationApplicationModel.Company,
  41 + CreatedAt: cooperationApplicationModel.CreatedAt,
  42 + DeletedAt: cooperationApplicationModel.DeletedAt,
  43 + UpdatedAt: cooperationApplicationModel.UpdatedAt,
25 }, nil 44 }, nil
26 } 45 }
@@ -5,7 +5,51 @@ import ( @@ -5,7 +5,51 @@ import (
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
6 ) 6 )
7 7
8 -func TransformToCooperationContractDomainModelFromPgModels(cooperationContractModel *models.CooperationContract) (*domain.CooperationContract, error) { 8 +func TransformToCooperationContractDomainModelFromPgModels(
  9 + cooperationContractModel *models.CooperationContract,
  10 + cooperationMode *models.CooperationMode,
  11 + dividendsIncentivesRules []*models.DividendsIncentivesRule,
  12 + moneyIncentivesRules []*models.MoneyIncentivesRule) (*domain.CooperationContract, error) {
  13 +
  14 + var dividendsIncentivesRulesDomain []*domain.DividendsIncentivesRule
  15 + for _, rule := range dividendsIncentivesRules {
  16 + dividendsIncentivesRulesDomain = append(dividendsIncentivesRulesDomain, &domain.DividendsIncentivesRule{
  17 + DividendsIncentivesRuleId: rule.DividendsIncentivesRuleId,
  18 + CooperationContractNumber: rule.CooperationContractNumber,
  19 + ReferrerPercentage: rule.ReferrerPercentage,
  20 + SalesmanPercentage: rule.SalesmanPercentage,
  21 + DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage,
  22 + DividendsIncentivesStage: rule.DividendsIncentivesStage,
  23 + DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd,
  24 + DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart,
  25 + Org: rule.Org,
  26 + Company: rule.Company,
  27 + UpdatedAt: rule.UpdatedAt,
  28 + DeletedAt: rule.DeletedAt,
  29 + CreatedAt: rule.CreatedAt,
  30 + })
  31 + }
  32 +
  33 + var moneyIncentivesRulesDomain []*domain.MoneyIncentivesRule
  34 + for _, rule := range moneyIncentivesRules {
  35 + moneyIncentivesRulesDomain = append(moneyIncentivesRulesDomain, &domain.MoneyIncentivesRule{
  36 + MoneyIncentivesRuleId: rule.MoneyIncentivesRuleId,
  37 + CooperationContractNumber: rule.CooperationContractNumber,
  38 + MoneyIncentivesAmount: rule.MoneyIncentivesAmount,
  39 + MoneyIncentivesStage: rule.MoneyIncentivesStage,
  40 + MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd,
  41 + MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart,
  42 + MoneyIncentivesTime: rule.MoneyIncentivesTime,
  43 + ReferrerPercentage: rule.ReferrerPercentage,
  44 + SalesmanPercentage: rule.SalesmanPercentage,
  45 + Org: rule.Org,
  46 + Company: rule.Company,
  47 + UpdatedAt: rule.UpdatedAt,
  48 + DeletedAt: rule.DeletedAt,
  49 + CreatedAt: rule.CreatedAt,
  50 + })
  51 + }
  52 +
9 return &domain.CooperationContract{ 53 return &domain.CooperationContract{
10 CooperationContractId: cooperationContractModel.CooperationContractId, 54 CooperationContractId: cooperationContractModel.CooperationContractId,
11 CooperationContractDescription: cooperationContractModel.CooperationContractDescription, 55 CooperationContractDescription: cooperationContractModel.CooperationContractDescription,
@@ -15,14 +59,29 @@ func TransformToCooperationContractDomainModelFromPgModels(cooperationContractMo @@ -15,14 +59,29 @@ func TransformToCooperationContractDomainModelFromPgModels(cooperationContractMo
15 CooperationContractSalesman: cooperationContractModel.CooperationContractSalesman, 59 CooperationContractSalesman: cooperationContractModel.CooperationContractSalesman,
16 CooperationContractUndertakerType: cooperationContractModel.CooperationContractUndertakerType, 60 CooperationContractUndertakerType: cooperationContractModel.CooperationContractUndertakerType,
17 CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor, 61 CooperationContractSponsor: cooperationContractModel.CooperationContractSponsor,
18 - CooperationMode: cooperationContractModel.CooperationMode,  
19 - Status: cooperationContractModel.Status,  
20 - Org: cooperationContractModel.Org,  
21 - Company: cooperationContractModel.Company,  
22 - Operator: cooperationContractModel.Operator,  
23 - OperateTime: cooperationContractModel.OperateTime,  
24 - CreatedAt: cooperationContractModel.CreatedAt,  
25 - DeletedAt: cooperationContractModel.DeletedAt,  
26 - UpdatedAt: cooperationContractModel.UpdatedAt, 62 + CooperationMode: &domain.CooperationMode{
  63 + CooperationModeId: cooperationMode.CooperationModeId,
  64 + CooperationModeNumber: cooperationMode.CooperationModeNumber,
  65 + CooperationModeName: cooperationMode.CooperationModeName,
  66 + Status: cooperationMode.Status,
  67 + Org: cooperationMode.Org,
  68 + Company: cooperationMode.Company,
  69 + Remarks: cooperationMode.Remarks,
  70 + Operator: cooperationMode.Operator,
  71 + OperateTime: cooperationMode.OperateTime,
  72 + UpdatedAt: cooperationMode.UpdatedAt,
  73 + DeletedAt: cooperationMode.DeletedAt,
  74 + CreatedAt: cooperationMode.CreatedAt,
  75 + },
  76 + DividendsIncentivesRules: dividendsIncentivesRulesDomain,
  77 + MoneyIncentivesRules: moneyIncentivesRulesDomain,
  78 + Status: cooperationContractModel.Status,
  79 + Org: cooperationContractModel.Org,
  80 + Company: cooperationContractModel.Company,
  81 + Operator: cooperationContractModel.Operator,
  82 + OperateTime: cooperationContractModel.OperateTime,
  83 + CreatedAt: cooperationContractModel.CreatedAt,
  84 + DeletedAt: cooperationContractModel.DeletedAt,
  85 + UpdatedAt: cooperationContractModel.UpdatedAt,
27 }, nil 86 }, nil
28 } 87 }
1 -package services 1 +package adaptor
2 2
3 type UserAdaptor struct { 3 type UserAdaptor struct {
4 } 4 }
1 -package services 1 +package adaptor
2 2
3 type UserInMenuAdaptor struct { 3 type UserInMenuAdaptor struct {
4 } 4 }
1 -package services 1 +package adaptor
2 2
3 type UserInOrganizationAdaptor struct { 3 type UserInOrganizationAdaptor struct {
4 } 4 }