作者 tangxuhui

数据结构调整

@@ -13,7 +13,7 @@ type EnableCooperationContractCommand struct { @@ -13,7 +13,7 @@ type EnableCooperationContractCommand struct {
13 // 共创合约ID 13 // 共创合约ID
14 CooperationContractId []string `json:"cooperationContractId" valid:"Required"` 14 CooperationContractId []string `json:"cooperationContractId" valid:"Required"`
15 // 暂停和恢复的状态 15 // 暂停和恢复的状态
16 - Status int `json:"status,omitempty"` 16 + Status int `json:"status"` //暂停或恢复合约动作,1恢复,2暂停
17 } 17 }
18 18
19 func (enableCooperationContractCommand *EnableCooperationContractCommand) Valid(validation *validation.Validation) { 19 func (enableCooperationContractCommand *EnableCooperationContractCommand) Valid(validation *validation.Validation) {
@@ -49,7 +49,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -49,7 +49,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
49 underTakers := []allied_creation_cooperation.Undertaker{} 49 underTakers := []allied_creation_cooperation.Undertaker{}
50 for _, v := range createCooperationContractCommand.Undertakers { 50 for _, v := range createCooperationContractCommand.Undertakers {
51 u := allied_creation_cooperation.Undertaker{ 51 u := allied_creation_cooperation.Undertaker{
52 - RelevantId: v.UndertakerId, 52 + UndertakerId: v.UndertakerId,
53 UserId: v.UserId, 53 UserId: v.UserId,
54 ReferrerId: v.RerferrerId, 54 ReferrerId: v.RerferrerId,
55 SalesmanId: v.SalesmanId, 55 SalesmanId: v.SalesmanId,
@@ -85,8 +85,15 @@ func (cooperationContractService *CooperationContractService) EnableCooperationC @@ -85,8 +85,15 @@ func (cooperationContractService *CooperationContractService) EnableCooperationC
85 if err := enableCooperationContractCommand.ValidateCommand(); err != nil { 85 if err := enableCooperationContractCommand.ValidateCommand(); err != nil {
86 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 86 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
87 } 87 }
88 -  
89 - return nil, nil 88 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(enableCooperationContractCommand.Operator)
  89 + _, err := creationCooperationGateway.CooperationContractsBatchOperate(allied_creation_cooperation.ReqCooperationContractsBatchOperate{
  90 + CooperationContractIds: enableCooperationContractCommand.CooperationContractId,
  91 + Action: enableCooperationContractCommand.Status,
  92 + })
  93 + if err != nil {
  94 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  95 + }
  96 + return enableCooperationContractCommand, nil
90 } 97 }
91 98
92 // 返回共创合约详情 99 // 返回共创合约详情
@@ -165,7 +172,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -165,7 +172,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
165 underTakers := []allied_creation_cooperation.Undertaker{} 172 underTakers := []allied_creation_cooperation.Undertaker{}
166 for _, v := range updateCooperationContractCommand.Undertakers { 173 for _, v := range updateCooperationContractCommand.Undertakers {
167 u := allied_creation_cooperation.Undertaker{ 174 u := allied_creation_cooperation.Undertaker{
168 - RelevantId: v.UndertakerId, 175 + UndertakerId: v.UndertakerId,
169 UserId: v.UserId, 176 UserId: v.UserId,
170 ReferrerId: v.RerferrerId, 177 ReferrerId: v.RerferrerId,
171 SalesmanId: v.SalesmanId, 178 SalesmanId: v.SalesmanId,
@@ -228,3 +228,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationContractGet(param Req @@ -228,3 +228,34 @@ func (gateway HttplibAlliedCreationCooperation) CooperationContractGet(param Req
228 err = gateway.GetResponseData(result, &data) 228 err = gateway.GetResponseData(result, &data)
229 return &data, err 229 return &data, err
230 } 230 }
  231 +
  232 +// CooperationContractsBatchOperate 暂停恢复合约
  233 +func (gateway HttplibAlliedCreationCooperation) CooperationContractsBatchOperate(param ReqCooperationContractsBatchOperate) (*DataCooperationContractsBatchOperate, error) {
  234 + url := gateway.baseUrL + "/cooperation-contracts/batch-operate"
  235 + method := "POST"
  236 + req := gateway.CreateRequest(url, method)
  237 + log.Logger.Debug("向业务模块请求数据:返回共创合约详情。", map[string]interface{}{
  238 + "api": method + ":" + url,
  239 + "param": param,
  240 + })
  241 + req, err := req.JSONBody(param)
  242 + if err != nil {
  243 + return nil, fmt.Errorf("请求返回共创合约详情失败:%w", err)
  244 + }
  245 +
  246 + byteResult, err := req.Bytes()
  247 + if err != nil {
  248 + return nil, fmt.Errorf("获取返回共创合约详情失败:%w", err)
  249 + }
  250 + log.Logger.Debug("获取业务模块请求数据:返回共创合约详情。", map[string]interface{}{
  251 + "result": string(byteResult),
  252 + })
  253 + var result service_gateway.GatewayResponse
  254 + err = json.Unmarshal(byteResult, &result)
  255 + if err != nil {
  256 + return nil, fmt.Errorf("解析返回共创合约详情:%w", err)
  257 + }
  258 + var data DataCooperationContractsBatchOperate
  259 + err = gateway.GetResponseData(result, &data)
  260 + return &data, err
  261 +}
@@ -144,7 +144,7 @@ type ( @@ -144,7 +144,7 @@ type (
144 144
145 //合约承接方 145 //合约承接方
146 Undertaker struct { 146 Undertaker struct {
147 - RelevantId int `json:"relevantId,string"` 147 + UndertakerId int `json:"undertakerId,string"`
148 UserId int `json:"userId,string"` //承接人用户id 148 UserId int `json:"userId,string"` //承接人用户id
149 ReferrerId int `json:"referrerId,string"` //推荐人用户id 149 ReferrerId int `json:"referrerId,string"` //推荐人用户id
150 SalesmanId int `json:"salesmanId,string"` //关联业务员id 150 SalesmanId int `json:"salesmanId,string"` //关联业务员id
@@ -191,10 +191,10 @@ type ( @@ -191,10 +191,10 @@ type (
191 MoneyIncentivesRules []MoneyIncentivesRule `json:"moneyIncentivesRules"` 191 MoneyIncentivesRules []MoneyIncentivesRule `json:"moneyIncentivesRules"`
192 Undertakers []Undertaker `json:"undertakers"` // 承接方列表 // 业绩分红激励规则列表 192 Undertakers []Undertaker `json:"undertakers"` // 承接方列表 // 业绩分红激励规则列表
193 RelevantIds []string `json:"relevantIds"` //关联业务员 193 RelevantIds []string `json:"relevantIds"` //关联业务员
194 - CompanyId int `json:"companyId,string"`  
195 - OrgId int `json:"orgId,string"` // 组织机构ID  
196 - UserId int ` json:"userId,string"` // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员  
197 - UserBaseId int `json:"userBaseId,string" ` // 用户基础数据id 194 + CompanyId int `json:"-"`
  195 + OrgId int `json:"-"` // 组织机构ID
  196 + UserId int ` json:"-"` // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  197 + UserBaseId int `json:"-" ` // 用户基础数据id
198 } 198 }
199 199
200 DataCooperationContractUpdate struct { 200 DataCooperationContractUpdate struct {
@@ -266,3 +266,12 @@ type ( @@ -266,3 +266,12 @@ type (
266 UndertakerTypesUncheckedAvailable []int `json:"undertakerTypesUncheckedAvailable"` 266 UndertakerTypesUncheckedAvailable []int `json:"undertakerTypesUncheckedAvailable"`
267 } 267 }
268 ) 268 )
  269 +
  270 +//批量恢复或暂停合约
  271 +type (
  272 + ReqCooperationContractsBatchOperate struct {
  273 + CooperationContractIds []string `json:"cooperationContractIds"`
  274 + Action int `json:"action"` //暂停或恢复合约动作,1恢复,2暂停
  275 + }
  276 + DataCooperationContractsBatchOperate []interface{}
  277 +)
@@ -118,12 +118,6 @@ type ( @@ -118,12 +118,6 @@ type (
118 CooperationProjectDescription string `json:"cooperationProjectDescription"` 118 CooperationProjectDescription string `json:"cooperationProjectDescription"`
119 Attachment []domain.Attachment `json:"attachment"` 119 Attachment []domain.Attachment `json:"attachment"`
120 DepartmentId int `json:"departmentId,string"` 120 DepartmentId int `json:"departmentId,string"`
121 - // 组织机构ID  
122 - // OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`  
123 - // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员  
124 - //UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`  
125 - // 用户基础数据id  
126 - //UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`  
127 } 121 }
128 122
129 DataCooperationProjectUpdate struct { 123 DataCooperationProjectUpdate struct {