...
|
...
|
@@ -5,6 +5,7 @@ import ( |
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
|
|
|
)
|
...
|
...
|
@@ -19,7 +20,6 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(createCooperationContractCommand.Operator)
|
|
|
|
|
|
rules1 := []allied_creation_cooperation.DividendsIncentivesRule{}
|
|
|
for _, v := range createCooperationContractCommand.DividendsIncentivesRules {
|
|
|
r := allied_creation_cooperation.DividendsIncentivesRule{
|
...
|
...
|
@@ -33,9 +33,43 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
}
|
|
|
rules1 = append(rules1, r)
|
|
|
}
|
|
|
// rules2 := []allied_creation_cooperation.MoneyIncentivesRule{}
|
|
|
|
|
|
_, err := creationCooperationGateway.CooperationContractAdd(allied_creation_cooperation.ReqCooperationContractAdd{})
|
|
|
rules2 := []allied_creation_cooperation.MoneyIncentivesRule{}
|
|
|
for _, v := range createCooperationContractCommand.MoneyIncentivesRules {
|
|
|
r := allied_creation_cooperation.MoneyIncentivesRule{
|
|
|
MoneyIncentivesRuleId: 0,
|
|
|
CooperationContractNumber: v.CooperationContractNumber,
|
|
|
MoneyIncentivesAmount: v.MoneyIncentivesAmount,
|
|
|
MoneyIncentivesStage: v.MoneyIncentivesStage,
|
|
|
MoneyIncentivesTime: time.Unix(int64(v.MoneyIncentivesTime), 0),
|
|
|
ReferrerPercentage: v.ReferrerPercentage,
|
|
|
SalesmanPercentage: v.SalesmanPercentage,
|
|
|
}
|
|
|
rules2 = append(rules2, r)
|
|
|
}
|
|
|
underTakers := []allied_creation_cooperation.Undertaker{}
|
|
|
for _, v := range createCooperationContractCommand.Undertakers {
|
|
|
u := allied_creation_cooperation.Undertaker{
|
|
|
UndertakerId: v.UndertakerId,
|
|
|
RerferrerId: v.RerferrerId,
|
|
|
SalesmanId: v.SalesmanId,
|
|
|
Attachment: v.Attachment,
|
|
|
}
|
|
|
underTakers = append(underTakers, u)
|
|
|
}
|
|
|
_, err := creationCooperationGateway.CooperationContractAdd(allied_creation_cooperation.ReqCooperationContractAdd{
|
|
|
MoneyIncentivesRules: rules2,
|
|
|
DividendsIncentivesRules: rules1,
|
|
|
Undertakers: underTakers,
|
|
|
RelevantIds: createCooperationContractCommand.RelevantIds,
|
|
|
CooperationContractDescription: createCooperationContractCommand.CooperationContractDescription,
|
|
|
CooperationContractNumber: createCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationProjectNumber: createCooperationContractCommand.CooperationProjectNumber,
|
|
|
DepartmentId: createCooperationContractCommand.DepartmentId,
|
|
|
CooperationContractUndertakerType: createCooperationContractCommand.CooperationContractUndertakerType,
|
|
|
CooperationContractName: createCooperationContractCommand.CooperationContractName,
|
|
|
CooperationModeNumber: createCooperationContractCommand.CooperationModeNumber,
|
|
|
SponsorUid: createCooperationContractCommand.SponsorUid,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -51,7 +85,7 @@ func (cooperationContractService *CooperationContractService) EnableCooperationC |
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
// 返回共创合约管理
|
|
|
// 返回共创合约详情
|
|
|
func (cooperationContractService *CooperationContractService) GetCooperationContract(getCooperationContractQuery *query.GetCooperationContractQuery) (interface{}, error) {
|
|
|
if err := getCooperationContractQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
...
|
...
|
@@ -67,17 +101,25 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont |
|
|
}
|
|
|
|
|
|
// 返回共创合约管理列表
|
|
|
func (cooperationContractService *CooperationContractService) ListCooperationContract(listCooperationContractQuery *query.ListCooperationContractQuery) (interface{}, error) {
|
|
|
func (cooperationContractService *CooperationContractService) ListCooperationContract(
|
|
|
listCooperationContractQuery *query.ListCooperationContractQuery) (int, interface{}, error) {
|
|
|
if err := listCooperationContractQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(listCooperationContractQuery.Operator)
|
|
|
result, err := creationCooperationGateway.CooperationContractSearch(allied_creation_cooperation.ReqCooperationContractSearch{})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
_ = result
|
|
|
return nil, nil
|
|
|
|
|
|
data := []dto.CooperationContractItem{}
|
|
|
|
|
|
for i := range result.Grid.List {
|
|
|
item := dto.ToCooperationContractItem(&result.Grid.List[i])
|
|
|
data = append(data, *item)
|
|
|
}
|
|
|
|
|
|
return result.Grid.Total, data, nil
|
|
|
}
|
|
|
|
|
|
// 更新共创合约管理
|
...
|
...
|
@@ -85,6 +127,61 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
|
if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(updateCooperationContractCommand.Operator)
|
|
|
rules1 := []allied_creation_cooperation.DividendsIncentivesRule{}
|
|
|
for _, v := range updateCooperationContractCommand.DividendsIncentivesRules {
|
|
|
r := allied_creation_cooperation.DividendsIncentivesRule{
|
|
|
CooperationContractNumber: v.CooperationContractNumber,
|
|
|
ReferrerPercentage: v.ReferrerPercentage,
|
|
|
SalesmanPercentage: v.SalesmanPercentage,
|
|
|
DividendsIncentivesPercentage: v.DividendsIncentivesPercentage,
|
|
|
DividendsIncentivesStage: v.DividendsIncentivesStage,
|
|
|
DividendsIncentivesStageEnd: time.Unix(int64(v.DividendsIncentivesStageEnd), 0),
|
|
|
DividendsIncentivesStageStart: time.Unix(int64(v.DividendsIncentivesStageStart), 0),
|
|
|
}
|
|
|
rules1 = append(rules1, r)
|
|
|
}
|
|
|
rules2 := []allied_creation_cooperation.MoneyIncentivesRule{}
|
|
|
for _, v := range updateCooperationContractCommand.MoneyIncentivesRules {
|
|
|
r := allied_creation_cooperation.MoneyIncentivesRule{
|
|
|
MoneyIncentivesRuleId: 0,
|
|
|
CooperationContractNumber: v.CooperationContractNumber,
|
|
|
MoneyIncentivesAmount: v.MoneyIncentivesAmount,
|
|
|
MoneyIncentivesStage: v.MoneyIncentivesStage,
|
|
|
MoneyIncentivesTime: time.Unix(int64(v.MoneyIncentivesTime), 0),
|
|
|
ReferrerPercentage: v.ReferrerPercentage,
|
|
|
SalesmanPercentage: v.SalesmanPercentage,
|
|
|
}
|
|
|
rules2 = append(rules2, r)
|
|
|
}
|
|
|
underTakers := []allied_creation_cooperation.Undertaker{}
|
|
|
for _, v := range updateCooperationContractCommand.Undertakers {
|
|
|
u := allied_creation_cooperation.Undertaker{
|
|
|
UndertakerId: v.UndertakerId,
|
|
|
RerferrerId: v.RerferrerId,
|
|
|
SalesmanId: v.SalesmanId,
|
|
|
Attachment: v.Attachment,
|
|
|
}
|
|
|
underTakers = append(underTakers, u)
|
|
|
}
|
|
|
_, err := creationCooperationGateway.CooperationContractUpdate(allied_creation_cooperation.ReqCooperationContractUpdate{
|
|
|
CooperationContractId: updateCooperationContractCommand.CooperationContractId,
|
|
|
MoneyIncentivesRules: rules2,
|
|
|
DividendsIncentivesRules: rules1,
|
|
|
Undertakers: underTakers,
|
|
|
RelevantIds: updateCooperationContractCommand.RelevantIds,
|
|
|
CooperationContractDescription: updateCooperationContractCommand.CooperationContractDescription,
|
|
|
CooperationContractNumber: updateCooperationContractCommand.CooperationContractNumber,
|
|
|
CooperationProjectNumber: updateCooperationContractCommand.CooperationProjectNumber,
|
|
|
DepartmentId: updateCooperationContractCommand.DepartmentId,
|
|
|
CooperationContractUndertakerType: updateCooperationContractCommand.CooperationContractUndertakerType,
|
|
|
CooperationContractName: updateCooperationContractCommand.CooperationContractName,
|
|
|
CooperationModeNumber: updateCooperationContractCommand.CooperationModeNumber,
|
|
|
SponsorUid: updateCooperationContractCommand.SponsorUid,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
}
|
|
|
|
...
|
...
|
|