...
|
...
|
@@ -9,6 +9,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -90,6 +91,30 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
organization = data
|
|
|
}
|
|
|
|
|
|
// 共创合约DAO初始化
|
|
|
var cooperationContractDao *dao.CooperationContractDao
|
|
|
if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationContractDao = value
|
|
|
}
|
|
|
// 生成共创合约编号
|
|
|
contractNumber, err2 := cooperationContractDao.GenerateContractNumber()
|
|
|
if err2 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
// 校验共创合约编号是否唯一
|
|
|
numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{
|
|
|
"companyId": createCooperationContractCommand.CompanyId,
|
|
|
"orgId": createCooperationContractCommand.OrgId,
|
|
|
"cooperationContractNumber": contractNumber,
|
|
|
})
|
|
|
if !numberAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创合约异常")
|
|
|
}
|
|
|
|
|
|
// 获取承接人
|
|
|
var undertakers []*domain.Undertaker
|
|
|
for _, undertaker := range createCooperationContractCommand.Undertakers {
|
...
|
...
|
@@ -122,7 +147,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
undertakers = append(undertakers, &domain.Undertaker{
|
|
|
UndertakerId: 0,
|
|
|
UserId: undertakerDomain.UserId,
|
|
|
CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationContractNumber: contractNumber,
|
|
|
UserBaseId: undertakerDomain.UserBaseId,
|
|
|
Org: undertakerDomain.Org,
|
|
|
Orgs: undertakerDomain.Orgs,
|
...
|
...
|
@@ -150,7 +175,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
}
|
|
|
relevantPeople = append(relevantPeople, &domain.Relevant{
|
|
|
RelevantId: 0,
|
|
|
CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationContractNumber: contractNumber,
|
|
|
UserId: relevantDomain.UserId,
|
|
|
UserBaseId: relevantDomain.UserBaseId,
|
|
|
Org: relevantDomain.Org,
|
...
|
...
|
@@ -169,7 +194,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
for _, dividendsIncentivesRule := range createCooperationContractCommand.DividendsIncentivesRules {
|
|
|
dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{
|
|
|
DividendsIncentivesRuleId: 0,
|
|
|
CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationContractNumber: contractNumber,
|
|
|
ReferrerPercentage: dividendsIncentivesRule.ReferrerPercentage,
|
|
|
SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
|
|
|
DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
|
...
|
...
|
@@ -189,7 +214,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
for _, moneyIncentivesRule := range createCooperationContractCommand.MoneyIncentivesRules {
|
|
|
moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{
|
|
|
MoneyIncentivesRuleId: 0,
|
|
|
CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationContractNumber: contractNumber,
|
|
|
MoneyIncentivesAmount: float64(moneyIncentivesRule.MoneyIncentivesAmount),
|
|
|
MoneyIncentivesStage: int64(moneyIncentivesRule.MoneyIncentivesStage),
|
|
|
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
|
...
|
...
|
@@ -224,7 +249,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
newCooperationContract := &domain.CooperationContract{
|
|
|
CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
|
|
|
CooperationContractName: createCooperationContractCommand.CooperationContractName,
|
|
|
CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationContractNumber: contractNumber,
|
|
|
CooperationContractUndertakerTypes: createCooperationContractCommand.CooperationContractUndertakerTypes,
|
|
|
CooperationContractSponsor: sponsor,
|
|
|
CooperationMode: cooperationMode,
|
...
|
...
|
|