作者 tangxuhui

数据结构调整

... ... @@ -13,7 +13,7 @@ type EnableCooperationContractCommand struct {
// 共创合约ID
CooperationContractId []string `json:"cooperationContractId" valid:"Required"`
// 暂停和恢复的状态
Status int `json:"status,omitempty"`
Status int `json:"status"` //暂停或恢复合约动作,1恢复,2暂停
}
func (enableCooperationContractCommand *EnableCooperationContractCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -49,11 +49,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
underTakers := []allied_creation_cooperation.Undertaker{}
for _, v := range createCooperationContractCommand.Undertakers {
u := allied_creation_cooperation.Undertaker{
RelevantId: v.UndertakerId,
UserId: v.UserId,
ReferrerId: v.RerferrerId,
SalesmanId: v.SalesmanId,
Attachment: v.Attachment,
UndertakerId: v.UndertakerId,
UserId: v.UserId,
ReferrerId: v.RerferrerId,
SalesmanId: v.SalesmanId,
Attachment: v.Attachment,
}
underTakers = append(underTakers, u)
}
... ... @@ -85,8 +85,15 @@ func (cooperationContractService *CooperationContractService) EnableCooperationC
if err := enableCooperationContractCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
return nil, nil
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(enableCooperationContractCommand.Operator)
_, err := creationCooperationGateway.CooperationContractsBatchOperate(allied_creation_cooperation.ReqCooperationContractsBatchOperate{
CooperationContractIds: enableCooperationContractCommand.CooperationContractId,
Action: enableCooperationContractCommand.Status,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return enableCooperationContractCommand, nil
}
// 返回共创合约详情
... ... @@ -165,11 +172,11 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
underTakers := []allied_creation_cooperation.Undertaker{}
for _, v := range updateCooperationContractCommand.Undertakers {
u := allied_creation_cooperation.Undertaker{
RelevantId: v.UndertakerId,
UserId: v.UserId,
ReferrerId: v.RerferrerId,
SalesmanId: v.SalesmanId,
Attachment: v.Attachment,
UndertakerId: v.UndertakerId,
UserId: v.UserId,
ReferrerId: v.RerferrerId,
SalesmanId: v.SalesmanId,
Attachment: v.Attachment,
}
underTakers = append(underTakers, u)
}
... ...
... ... @@ -228,3 +228,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationContractGet(param Req
err = gateway.GetResponseData(result, &data)
return &data, err
}
// CooperationContractsBatchOperate 暂停恢复合约
func (gateway HttplibAlliedCreationCooperation) CooperationContractsBatchOperate(param ReqCooperationContractsBatchOperate) (*DataCooperationContractsBatchOperate, error) {
url := gateway.baseUrL + "/cooperation-contracts/batch-operate"
method := "POST"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:返回共创合约详情。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回共创合约详情失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回共创合约详情失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:返回共创合约详情。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回共创合约详情:%w", err)
}
var data DataCooperationContractsBatchOperate
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -144,11 +144,11 @@ type (
//合约承接方
Undertaker struct {
RelevantId int `json:"relevantId,string"`
UserId int `json:"userId,string"` //承接人用户id
ReferrerId int `json:"referrerId,string"` //推荐人用户id
SalesmanId int `json:"salesmanId,string"` //关联业务员id
Attachment []domain.Attachment `json:"attachment"`
UndertakerId int `json:"undertakerId,string"`
UserId int `json:"userId,string"` //承接人用户id
ReferrerId int `json:"referrerId,string"` //推荐人用户id
SalesmanId int `json:"salesmanId,string"` //关联业务员id
Attachment []domain.Attachment `json:"attachment"`
}
ReqCooperationContractAdd struct {
... ... @@ -191,10 +191,10 @@ type (
MoneyIncentivesRules []MoneyIncentivesRule `json:"moneyIncentivesRules"`
Undertakers []Undertaker `json:"undertakers"` // 承接方列表 // 业绩分红激励规则列表
RelevantIds []string `json:"relevantIds"` //关联业务员
CompanyId int `json:"companyId,string"`
OrgId int `json:"orgId,string"` // 组织机构ID
UserId int ` json:"userId,string"` // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserBaseId int `json:"userBaseId,string" ` // 用户基础数据id
CompanyId int `json:"-"`
OrgId int `json:"-"` // 组织机构ID
UserId int ` json:"-"` // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserBaseId int `json:"-" ` // 用户基础数据id
}
DataCooperationContractUpdate struct {
... ... @@ -266,3 +266,12 @@ type (
UndertakerTypesUncheckedAvailable []int `json:"undertakerTypesUncheckedAvailable"`
}
)
//批量恢复或暂停合约
type (
ReqCooperationContractsBatchOperate struct {
CooperationContractIds []string `json:"cooperationContractIds"`
Action int `json:"action"` //暂停或恢复合约动作,1恢复,2暂停
}
DataCooperationContractsBatchOperate []interface{}
)
... ...
... ... @@ -118,12 +118,6 @@ type (
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Attachment []domain.Attachment `json:"attachment"`
DepartmentId int `json:"departmentId,string"`
// 组织机构ID
// OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
//UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
//UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
}
DataCooperationProjectUpdate struct {
... ...