作者 陈志颖

feat:共创合约承接人列表仓储xiugai

... ... @@ -26,6 +26,8 @@ type CooperationApplication struct {
CooperationProject *CooperationProject `json:"cooperationProject"`
// 数据所属组织机构
Org *Org `json:"org"`
// 是否被取消标志位
IsCanceled bool `json:"isCanceled"`
// 公司
Company *Company `json:"company"`
// 创建时间
... ...
... ... @@ -22,6 +22,8 @@ type CooperationProject struct {
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"`
// 数据所属组织机构
Org *Org `json:"org"`
// 图片附件
Attachment *Attachment `json:"attachment"`
// 公司
Company *Company `json:"company"`
// 操作人
... ... @@ -161,14 +163,5 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{}
if status, ok := data["status"]; ok {
cooperationProject.Status = status.(int32)
}
if updatedAt, ok := data["updatedAt"]; ok {
cooperationProject.UpdatedAt = updatedAt.(time.Time)
}
if deletedAt, ok := data["deletedAt"]; ok {
cooperationProject.DeletedAt = deletedAt.(time.Time)
}
if createdAt, ok := data["createdAt"]; ok {
cooperationProject.CreatedAt = createdAt.(time.Time)
}
return nil
}
... ...
... ... @@ -18,6 +18,10 @@ type Undertaker struct {
UserInfo *UserInfo `json:"userInfo"`
// 用户类型,1员工,2共创用户,3公开
UserType int32 `json:"userType"`
// 推荐人
Referrer *Referrer `json:"referrer"`
// 关联业务员
Salesman *Salesman `json:"salesman"`
// 状态
Status int32 `json:"status"`
// 公司
... ...
... ... @@ -29,6 +29,8 @@ type CooperationApplication struct {
CooperationProjectNumber string `comment:"共创项目编号"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 是否被取消标志位
IsCanceled bool `comment:"是否被取消标志位"`
// 公司
Company *domain.Company `comment:"公司"`
// 创建时间
... ...
... ... @@ -11,8 +11,32 @@ type CooperationContractUndertaker struct {
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:"pk:cooperation_contract_undertaker_id"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 共创合约承接人
Undertaker *domain.Undertaker `comment:"共创合约承接人"`
// 共创合约承接人uid
UserId int64 `comment:"共创合约承接人uid"`
// 用户基础数据id
UserBaseId int64 `comment:"用户基础数据id"`
// 所属组织机构
Org *domain.Org `comment:"所属组织机构"`
// 关联的组织机构
Orgs []*domain.Org `comment:"关联的组织机构"`
// 用户所属部门
Department *domain.Department `comment:"用户所属部门"`
// 用户角色
Role *domain.Role `comment:"用户角色"`
// 用户信息
UserInfo *domain.UserInfo `comment:"用户信息"`
// 用户类型
UserType int32 `comment:"用户类型"`
// 推荐人
Referrer *domain.Referrer `comment:"推荐人"`
// 关联的业务员
Salesman *domain.Salesman `comment:"关联的业务员"`
// 人员状态
Status int32 `comment:"人员状态"`
// 公司信息
Company *domain.Company `comment:"公司信息"`
// 合同附件
ContractAttachment []*domain.Attachment `comment:"合约附件"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 更新时间
... ...
... ... @@ -36,10 +36,11 @@ func TransformToCooperationApplicationDomainModelFromPgModels(
DeletedAt: cooperationProject.DeletedAt,
CreatedAt: cooperationProject.CreatedAt,
},
Org: cooperationApplicationModel.Org,
Company: cooperationApplicationModel.Company,
CreatedAt: cooperationApplicationModel.CreatedAt,
DeletedAt: cooperationApplicationModel.DeletedAt,
UpdatedAt: cooperationApplicationModel.UpdatedAt,
Org: cooperationApplicationModel.Org,
IsCanceled: cooperationApplicationModel.IsCanceled,
Company: cooperationApplicationModel.Company,
CreatedAt: cooperationApplicationModel.CreatedAt,
DeletedAt: cooperationApplicationModel.DeletedAt,
UpdatedAt: cooperationApplicationModel.UpdatedAt,
}, nil
}
... ...
... ... @@ -9,9 +9,23 @@ func TransformToCooperationContractUndertakerDomainModelFromPgModels(cooperation
return &domain.CooperationContractUndertaker{
CooperationContractUndertakerId: cooperationContractUndertakerModel.CooperationContractUndertakerId,
CooperationContractNumber: cooperationContractUndertakerModel.CooperationContractNumber,
Undertaker: cooperationContractUndertakerModel.Undertaker,
CreatedAt: cooperationContractUndertakerModel.CreatedAt,
UpdatedAt: cooperationContractUndertakerModel.UpdatedAt,
DeletedAt: cooperationContractUndertakerModel.DeletedAt,
Undertaker: &domain.Undertaker{
UserId: cooperationContractUndertakerModel.UserId,
UserBaseId: cooperationContractUndertakerModel.UserBaseId,
Org: cooperationContractUndertakerModel.Org,
Orgs: cooperationContractUndertakerModel.Orgs,
Department: cooperationContractUndertakerModel.Department,
Role: cooperationContractUndertakerModel.Role,
UserInfo: cooperationContractUndertakerModel.UserInfo,
UserType: cooperationContractUndertakerModel.UserType,
Referrer: cooperationContractUndertakerModel.Referrer,
Salesman: cooperationContractUndertakerModel.Salesman,
Status: cooperationContractUndertakerModel.Status,
Company: cooperationContractUndertakerModel.Company,
ContractAttachment: cooperationContractUndertakerModel.ContractAttachment,
},
CreatedAt: cooperationContractUndertakerModel.CreatedAt,
UpdatedAt: cooperationContractUndertakerModel.UpdatedAt,
DeletedAt: cooperationContractUndertakerModel.DeletedAt,
}, nil
}
... ...
... ... @@ -54,7 +54,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
if _, err := tx.QueryOne(
pg.Scan(
&contractUndertakerFeedback.FeedbackId,
pg.Array(&contractUndertakerFeedback.FeedbackAttachment),
&contractUndertakerFeedback.FeedbackAttachment,
&contractUndertakerFeedback.FeedbackContent,
&contractUndertakerFeedback.CooperationContractNumber,
&contractUndertakerFeedback.ContractUndertaker,
... ... @@ -67,7 +67,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
),
fmt.Sprintf("INSERT INTO contract_undertaker_feedbacks (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
contractUndertakerFeedback.FeedbackId,
pg.Array(contractUndertakerFeedback.FeedbackAttachment),
contractUndertakerFeedback.FeedbackAttachment,
contractUndertakerFeedback.FeedbackContent,
contractUndertakerFeedback.CooperationContractNumber,
contractUndertakerFeedback.ContractUndertaker,
... ... @@ -84,7 +84,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
if _, err := tx.QueryOne(
pg.Scan(
&contractUndertakerFeedback.FeedbackId,
pg.Array(&contractUndertakerFeedback.FeedbackAttachment),
&contractUndertakerFeedback.FeedbackAttachment,
&contractUndertakerFeedback.FeedbackContent,
&contractUndertakerFeedback.CooperationContractNumber,
&contractUndertakerFeedback.ContractUndertaker,
... ... @@ -97,7 +97,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
),
fmt.Sprintf("UPDATE contract_undertaker_feedbacks SET %s WHERE contract_undertaker_feedback_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
contractUndertakerFeedback.FeedbackId,
pg.Array(contractUndertakerFeedback.FeedbackAttachment),
contractUndertakerFeedback.FeedbackAttachment,
contractUndertakerFeedback.FeedbackContent,
contractUndertakerFeedback.CooperationContractNumber,
contractUndertakerFeedback.ContractUndertaker,
... ...
... ... @@ -37,6 +37,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
"cooperation_apply_time",
"cooperation_project",
"org",
"isCanceled",
"company",
"created_at",
"deleted_at",
... ... @@ -68,6 +69,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
&cooperationApplication.CooperationApplyTime,
&cooperationApplication.CooperationProject,
&cooperationApplication.Org,
&cooperationApplication.IsCanceled,
&cooperationApplication.Company,
&cooperationApplication.CreatedAt,
&cooperationApplication.DeletedAt,
... ... @@ -76,7 +78,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
fmt.Sprintf("INSERT INTO cooperation_applications (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
cooperationApplication.CooperationApplicationId,
cooperationApplication.CooperationApplicationApplicant,
pg.Array(cooperationApplication.CooperationApplicationAttachment),
cooperationApplication.CooperationApplicationAttachment,
cooperationApplication.CooperationApplicationDescription,
cooperationApplication.CooperationApplicationStatus,
cooperationApplication.CooperationApplicationVerifier,
... ... @@ -85,6 +87,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
cooperationApplication.CooperationApplyTime,
cooperationApplication.CooperationProject,
cooperationApplication.Org,
cooperationApplication.IsCanceled,
cooperationApplication.Company,
cooperationApplication.CreatedAt,
cooperationApplication.DeletedAt,
... ... @@ -97,7 +100,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
pg.Scan(
&cooperationApplication.CooperationApplicationId,
&cooperationApplication.CooperationApplicationApplicant,
pg.Array(&cooperationApplication.CooperationApplicationAttachment),
&cooperationApplication.CooperationApplicationAttachment,
&cooperationApplication.CooperationApplicationDescription,
&cooperationApplication.CooperationApplicationStatus,
&cooperationApplication.CooperationApplicationVerifier,
... ... @@ -106,6 +109,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
&cooperationApplication.CooperationApplyTime,
&cooperationApplication.CooperationProject,
&cooperationApplication.Org,
&cooperationApplication.IsCanceled,
&cooperationApplication.Company,
&cooperationApplication.CreatedAt,
&cooperationApplication.DeletedAt,
... ... @@ -114,7 +118,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
fmt.Sprintf("UPDATE cooperation_applications SET %s WHERE cooperation_application_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
cooperationApplication.CooperationApplicationId,
cooperationApplication.CooperationApplicationApplicant,
pg.Array(cooperationApplication.CooperationApplicationAttachment),
cooperationApplication.CooperationApplicationAttachment,
cooperationApplication.CooperationApplicationDescription,
cooperationApplication.CooperationApplicationStatus,
cooperationApplication.CooperationApplicationVerifier,
... ... @@ -123,6 +127,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
cooperationApplication.CooperationApplyTime,
cooperationApplication.CooperationProject,
cooperationApplication.Org,
cooperationApplication.IsCanceled,
cooperationApplication.Company,
cooperationApplication.CreatedAt,
cooperationApplication.DeletedAt,
... ...
... ... @@ -28,7 +28,16 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac
sqlBuildFields := []string{
"cooperation_contract_relevant_id",
"cooperation_contract_number",
"relevant",
"user_id",
"user_base_id",
"org",
"orgs",
"department",
"role",
"user_info",
"user_type",
"status",
"company",
"updated_at",
"deleted_at",
"created_at",
... ... @@ -50,7 +59,16 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac
pg.Scan(
&cooperationContractRelevant.CooperationContractRelevantId,
&cooperationContractRelevant.CooperationContractNumber,
&cooperationContractRelevant.Relevant,
&cooperationContractRelevant.Relevant.UserId,
&cooperationContractRelevant.Relevant.UserBaseId,
&cooperationContractRelevant.Relevant.Org,
&cooperationContractRelevant.Relevant.Orgs,
&cooperationContractRelevant.Relevant.Department,
&cooperationContractRelevant.Relevant.Role,
&cooperationContractRelevant.Relevant.UserInfo,
&cooperationContractRelevant.Relevant.UserType,
&cooperationContractRelevant.Relevant.Status,
&cooperationContractRelevant.Relevant.Company,
&cooperationContractRelevant.UpdatedAt,
&cooperationContractRelevant.DeletedAt,
&cooperationContractRelevant.CreatedAt,
... ... @@ -58,7 +76,16 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac
fmt.Sprintf("INSERT INTO cooperation_contract_relevants (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
cooperationContractRelevant.CooperationContractRelevantId,
cooperationContractRelevant.CooperationContractNumber,
cooperationContractRelevant.Relevant,
&cooperationContractRelevant.Relevant.UserId,
&cooperationContractRelevant.Relevant.UserBaseId,
&cooperationContractRelevant.Relevant.Org,
&cooperationContractRelevant.Relevant.Orgs,
&cooperationContractRelevant.Relevant.Department,
&cooperationContractRelevant.Relevant.Role,
&cooperationContractRelevant.Relevant.UserInfo,
&cooperationContractRelevant.Relevant.UserType,
&cooperationContractRelevant.Relevant.Status,
&cooperationContractRelevant.Relevant.Company,
cooperationContractRelevant.UpdatedAt,
cooperationContractRelevant.DeletedAt,
cooperationContractRelevant.CreatedAt,
... ... @@ -70,7 +97,16 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac
pg.Scan(
&cooperationContractRelevant.CooperationContractRelevantId,
&cooperationContractRelevant.CooperationContractNumber,
&cooperationContractRelevant.Relevant,
&cooperationContractRelevant.Relevant.UserId,
&cooperationContractRelevant.Relevant.UserBaseId,
&cooperationContractRelevant.Relevant.Org,
&cooperationContractRelevant.Relevant.Orgs,
&cooperationContractRelevant.Relevant.Department,
&cooperationContractRelevant.Relevant.Role,
&cooperationContractRelevant.Relevant.UserInfo,
&cooperationContractRelevant.Relevant.UserType,
&cooperationContractRelevant.Relevant.Status,
&cooperationContractRelevant.Relevant.Company,
&cooperationContractRelevant.UpdatedAt,
&cooperationContractRelevant.DeletedAt,
&cooperationContractRelevant.CreatedAt,
... ... @@ -78,7 +114,16 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac
fmt.Sprintf("UPDATE cooperation_contract_relevants SET %s WHERE cooperation_contract_relevant_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
cooperationContractRelevant.CooperationContractRelevantId,
cooperationContractRelevant.CooperationContractNumber,
cooperationContractRelevant.Relevant,
cooperationContractRelevant.Relevant.UserId,
cooperationContractRelevant.Relevant.UserBaseId,
cooperationContractRelevant.Relevant.Org,
cooperationContractRelevant.Relevant.Orgs,
cooperationContractRelevant.Relevant.Department,
cooperationContractRelevant.Relevant.Role,
cooperationContractRelevant.Relevant.UserInfo,
cooperationContractRelevant.Relevant.UserType,
cooperationContractRelevant.Relevant.Status,
cooperationContractRelevant.Relevant.Company,
cooperationContractRelevant.UpdatedAt,
cooperationContractRelevant.DeletedAt,
cooperationContractRelevant.CreatedAt,
... ...
... ... @@ -9,6 +9,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"time"
)
... ... @@ -127,7 +128,19 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
for _, undertaker := range cooperationContract.Undertakers {
undertakersModel = append(undertakersModel, &models.CooperationContractUndertaker{
CooperationContractNumber: cooperationContract.CooperationContractNumber,
Undertaker: undertaker,
UserId: undertaker.UserId,
UserBaseId: undertaker.UserBaseId,
Org: undertaker.Org,
Orgs: undertaker.Orgs,
Department: undertaker.Department,
Role: undertaker.Role,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
Referrer: undertaker.Referrer,
Salesman: undertaker.Salesman,
Status: undertaker.Status,
Company: undertaker.Company,
ContractAttachment: undertaker.ContractAttachment,
CreatedAt: time.Time{},
UpdatedAt: time.Time{},
DeletedAt: time.Now(),
... ... @@ -224,20 +237,26 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
return cooperationContract, err
}
// TODO 更新相关人
// 更新相关人
// 查找相关人列表
var cooperationContractRelevantFetched []*models.CooperationContractRelevant
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantFetched)
var cooperationContractRelevantModelsFetched []*models.CooperationContractRelevant
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModelsFetched)
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
return nil, err
}
// 提取相关人id
var cooperationContractRelevantIdsFetched []int64
for _, cooperationContractRelevant := range cooperationContractRelevantModelsFetched {
cooperationContractRelevantIdsFetched = append(cooperationContractRelevantIdsFetched, cooperationContractRelevant.CooperationContractRelevantId)
}
// 待更新相关人
var cooperationContractRelevantPeopleToUpdate []*domain.Relevant
// 待添加相关人
var cooperationContractRelevantPeopleToAdd []*domain.Relevant
for _, relevant := range cooperationContract.RelevantPeople {
if relevant.RelevantId != 0 {
cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant)
... ... @@ -246,49 +265,67 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
// 待删除相关人,对比待更新的和数据库已有的
//var cooperationContractRelevantModelsDelete []*models.CooperationContractRelevant // 待删除的相关人
//var cooperationContractRelevantModelsCreate []*models.CooperationContractRelevant // 待增加的相关人
var relevantIdsHave []int64
var relevantIdsModify []int64
//var relevantIdsUpdate []int64
// 待更新相关人id数组
for _, cooperationContractRelevantModel := range cooperationContractRelevantFetched {
relevantIdsHave = append(relevantIdsHave, cooperationContractRelevantModel.CooperationContractRelevantId)
// 将待添加的相关人领域模型转换为数据模型
var cooperationContractRelevantPeopleToAddModels []*models.CooperationContractRelevant
for _, relevantDomain := range cooperationContractRelevantPeopleToAdd {
cooperationContractRelevantPeopleToAddModels = append(cooperationContractRelevantPeopleToAddModels, &models.CooperationContractRelevant{
CooperationContractNumber: relevantDomain.CooperationContractNumber,
UserId: relevantDomain.UserId,
UserBaseId: relevantDomain.UserBaseId,
Org: relevantDomain.Org,
Orgs: relevantDomain.Orgs,
Department: relevantDomain.Department,
Role: relevantDomain.Role,
UserInfo: relevantDomain.UserInfo,
UserType: relevantDomain.UserType,
Status: relevantDomain.Status,
Company: relevantDomain.Company,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
})
}
// 添加相关人
if _, err := tx.Model(&cooperationContractRelevantPeopleToAddModels).Insert(); err != nil {
return nil, err
}
for _, cooperationContractRelevantDomain := range cooperationContract.RelevantPeople {
relevantIdsModify = append(relevantIdsModify, cooperationContractRelevantDomain.RelevantId)
// 待更新或者删除的ids
var cooperationContractRelevantPeopleToUpdateOrDeleteIds []int64
for _, cooperationContractRelevantPersonToUpdate := range cooperationContractRelevantPeopleToUpdate {
cooperationContractRelevantPeopleToUpdateOrDeleteIds = append(cooperationContractRelevantPeopleToUpdateOrDeleteIds, cooperationContractRelevantPersonToUpdate.RelevantId)
}
// 待更新的相关人
//relevantIdsUpdate := utils.Intersect(relevantIdsHave, relevantIdsModify)
// 待更新的相关人id
relevantIdsToUpdate := utils.Intersect(cooperationContractRelevantIdsFetched, cooperationContractRelevantPeopleToUpdateOrDeleteIds)
var relevantModelsToUpdate []*models.CooperationContractRelevant
for _, id := range relevantIdsToUpdate {
for _, relevantModel := range cooperationContractRelevantModelsFetched {
if relevantModel.CooperationContractRelevantId == id {
relevantModelsToUpdate = append(relevantModelsToUpdate, relevantModel)
}
}
}
if _, err := tx.Model(&relevantModelsToUpdate).WherePK().Update(); err != nil {
return nil, err
}
var relevantPeopleModelUpdate []*models.CooperationContractRelevant
for _, cooperationContractRelevantDomain := range cooperationContract.RelevantPeople {
relevantPeopleModelUpdate = append(relevantPeopleModelUpdate, &models.CooperationContractRelevant{
CooperationContractRelevantId: cooperationContractRelevantDomain.RelevantId,
CooperationContractNumber: cooperationContractRelevantDomain.CooperationContractNumber,
UserId: cooperationContractRelevantDomain.UserId,
UserBaseId: cooperationContractRelevantDomain.UserBaseId,
Org: cooperationContractRelevantDomain.Org,
Orgs: cooperationContractRelevantDomain.Orgs,
Department: cooperationContractRelevantDomain.Department,
Role: cooperationContractRelevantDomain.Role,
UserInfo: cooperationContractRelevantDomain.UserInfo,
UserType: cooperationContractRelevantDomain.UserType,
Status: cooperationContractRelevantDomain.Status,
Company: cooperationContractRelevantDomain.Company,
UpdatedAt: time.Now(),
DeletedAt: time.Time{},
CreatedAt: time.Time{},
})
// 待删除的相关人id
relevantIdsToDelete := utils.Difference(cooperationContractRelevantIdsFetched, cooperationContractRelevantPeopleToUpdateOrDeleteIds)
var relevantModelsToDelete []*models.CooperationContractRelevant
for _, id := range relevantIdsToDelete {
for _, relevantModel := range cooperationContractRelevantModelsFetched {
if relevantModel.CooperationContractRelevantId == id {
relevantModelsToDelete = append(relevantModelsToDelete, relevantModel)
}
}
}
if _, err := tx.Model(&relevantModelsToDelete).WherePK().Delete(); err != nil {
return nil, err
}
//TODO 更新承接人
// 获取承接人列表
var cooperationContractUndertakersFetched []*models.CooperationContractUndertaker
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakersFetched)
... ... @@ -297,6 +334,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
//TODO 更新分红激励规则
// 获取分红激励规则列表
var dividendsIncentivesRulesFetched []*models.DividendsIncentivesRule
dividendsIncentivesRuleQuery := tx.Model(&dividendsIncentivesRulesFetched)
... ... @@ -305,6 +343,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
//TODO 更新金额激励规则
// 获取金额激励规则列表
var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRulesFetched)
... ...
... ... @@ -28,7 +28,19 @@ func (repository *CooperationContractUndertakerRepository) Save(cooperationContr
sqlBuildFields := []string{
"cooperation_contract_undertaker_id",
"cooperation_contract_number",
"undertaker",
"user_id",
"user_base_id",
"org",
"orgs",
"department",
"role",
"user_info",
"user_type",
"referrer",
"salesman",
"status",
"company",
"contract_attachment",
"created_at",
"updated_at",
"deleted_at",
... ... @@ -50,7 +62,19 @@ func (repository *CooperationContractUndertakerRepository) Save(cooperationContr
pg.Scan(
&cooperationContractUndertaker.CooperationContractUndertakerId,
&cooperationContractUndertaker.CooperationContractNumber,
&cooperationContractUndertaker.Undertaker,
&cooperationContractUndertaker.Undertaker.UserId,
&cooperationContractUndertaker.Undertaker.UserBaseId,
&cooperationContractUndertaker.Undertaker.Org,
&cooperationContractUndertaker.Undertaker.Orgs,
&cooperationContractUndertaker.Undertaker.Department,
&cooperationContractUndertaker.Undertaker.Role,
&cooperationContractUndertaker.Undertaker.UserInfo,
&cooperationContractUndertaker.Undertaker.UserType,
&cooperationContractUndertaker.Undertaker.Referrer,
&cooperationContractUndertaker.Undertaker.Salesman,
&cooperationContractUndertaker.Undertaker.Status,
&cooperationContractUndertaker.Undertaker.Company,
&cooperationContractUndertaker.Undertaker.ContractAttachment,
&cooperationContractUndertaker.CreatedAt,
&cooperationContractUndertaker.UpdatedAt,
&cooperationContractUndertaker.DeletedAt,
... ... @@ -58,7 +82,19 @@ func (repository *CooperationContractUndertakerRepository) Save(cooperationContr
fmt.Sprintf("INSERT INTO cooperation_contract_undertakers (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
cooperationContractUndertaker.CooperationContractUndertakerId,
cooperationContractUndertaker.CooperationContractNumber,
cooperationContractUndertaker.Undertaker,
&cooperationContractUndertaker.Undertaker.UserId,
&cooperationContractUndertaker.Undertaker.UserBaseId,
&cooperationContractUndertaker.Undertaker.Org,
&cooperationContractUndertaker.Undertaker.Orgs,
&cooperationContractUndertaker.Undertaker.Department,
&cooperationContractUndertaker.Undertaker.Role,
&cooperationContractUndertaker.Undertaker.UserInfo,
&cooperationContractUndertaker.Undertaker.UserType,
&cooperationContractUndertaker.Undertaker.Referrer,
&cooperationContractUndertaker.Undertaker.Salesman,
&cooperationContractUndertaker.Undertaker.Status,
&cooperationContractUndertaker.Undertaker.Company,
&cooperationContractUndertaker.Undertaker.ContractAttachment,
cooperationContractUndertaker.CreatedAt,
cooperationContractUndertaker.UpdatedAt,
cooperationContractUndertaker.DeletedAt,
... ... @@ -70,7 +106,19 @@ func (repository *CooperationContractUndertakerRepository) Save(cooperationContr
pg.Scan(
&cooperationContractUndertaker.CooperationContractUndertakerId,
&cooperationContractUndertaker.CooperationContractNumber,
&cooperationContractUndertaker.Undertaker,
&cooperationContractUndertaker.Undertaker.UserId,
&cooperationContractUndertaker.Undertaker.UserBaseId,
&cooperationContractUndertaker.Undertaker.Org,
&cooperationContractUndertaker.Undertaker.Orgs,
&cooperationContractUndertaker.Undertaker.Department,
&cooperationContractUndertaker.Undertaker.Role,
&cooperationContractUndertaker.Undertaker.UserInfo,
&cooperationContractUndertaker.Undertaker.UserType,
&cooperationContractUndertaker.Undertaker.Referrer,
&cooperationContractUndertaker.Undertaker.Salesman,
&cooperationContractUndertaker.Undertaker.Status,
&cooperationContractUndertaker.Undertaker.Company,
&cooperationContractUndertaker.Undertaker.ContractAttachment,
&cooperationContractUndertaker.CreatedAt,
&cooperationContractUndertaker.UpdatedAt,
&cooperationContractUndertaker.DeletedAt,
... ... @@ -78,7 +126,19 @@ func (repository *CooperationContractUndertakerRepository) Save(cooperationContr
fmt.Sprintf("UPDATE cooperation_contract_undertakers SET %s WHERE cooperation_contract_undertaker_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
cooperationContractUndertaker.CooperationContractUndertakerId,
cooperationContractUndertaker.CooperationContractNumber,
cooperationContractUndertaker.Undertaker,
cooperationContractUndertaker.Undertaker.UserId,
cooperationContractUndertaker.Undertaker.UserBaseId,
cooperationContractUndertaker.Undertaker.Org,
cooperationContractUndertaker.Undertaker.Orgs,
cooperationContractUndertaker.Undertaker.Department,
cooperationContractUndertaker.Undertaker.Role,
cooperationContractUndertaker.Undertaker.UserInfo,
cooperationContractUndertaker.Undertaker.UserType,
cooperationContractUndertaker.Undertaker.Referrer,
cooperationContractUndertaker.Undertaker.Salesman,
cooperationContractUndertaker.Undertaker.Status,
cooperationContractUndertaker.Undertaker.Company,
cooperationContractUndertaker.Undertaker.ContractAttachment,
cooperationContractUndertaker.CreatedAt,
cooperationContractUndertaker.UpdatedAt,
cooperationContractUndertaker.DeletedAt,
... ...
... ... @@ -26,7 +26,7 @@ func (repository *MoneyIncentivesRuleRepository) nextIdentify() (int64, error) {
}
func (repository *MoneyIncentivesRuleRepository) Save(moneyIncentivesRule *domain.MoneyIncentivesRule) (*domain.MoneyIncentivesRule, error) {
sqlBuildFields := []string{
"money_icentives_rule_id",
"money_incentives_rule_id",
"cooperation_contract_number",
"money_incentives_amount",
"money_incentives_stage",
... ...