正在显示
7 个修改的文件
包含
46 行增加
和
5 行删除
| @@ -11,7 +11,7 @@ import ( | @@ -11,7 +11,7 @@ import ( | ||
| 11 | // CancelDividendsEstimateCommand 取消分红预算 | 11 | // CancelDividendsEstimateCommand 取消分红预算 |
| 12 | type CancelDividendsEstimateCommand struct { | 12 | type CancelDividendsEstimateCommand struct { |
| 13 | // 承接人分红预算记录ID | 13 | // 承接人分红预算记录ID |
| 14 | - DividendsEstimateId string `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"` | 14 | + DividendsEstimateId int64 `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"` |
| 15 | // 公司ID,通过集成REST上下文获取 | 15 | // 公司ID,通过集成REST上下文获取 |
| 16 | CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | 16 | CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` |
| 17 | // 组织机构ID | 17 | // 组织机构ID |
| @@ -20,6 +20,8 @@ type CancelDividendsEstimateCommand struct { | @@ -20,6 +20,8 @@ type CancelDividendsEstimateCommand struct { | ||
| 20 | UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` | 20 | UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` |
| 21 | // 用户基础数据id | 21 | // 用户基础数据id |
| 22 | UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"` | 22 | UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"` |
| 23 | + // 状态 | ||
| 24 | + IsCanceled bool `cname:"是否取消" json:"isCanceled,omitempty"` | ||
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) Valid(validation *validation.Validation) { | 27 | func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) Valid(validation *validation.Validation) { |
| @@ -169,10 +169,36 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | @@ -169,10 +169,36 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat | ||
| 169 | defer func() { | 169 | defer func() { |
| 170 | _ = transactionContext.RollbackTransaction() | 170 | _ = transactionContext.RollbackTransaction() |
| 171 | }() | 171 | }() |
| 172 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
| 173 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
| 174 | + "transactionContext": transactionContext, | ||
| 175 | + }); err != nil { | ||
| 176 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 177 | + } else { | ||
| 178 | + dividendsEstimateRepository = value | ||
| 179 | + } | ||
| 180 | + dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": cancelDividendsEstimateCommand.DividendsEstimateId}) | ||
| 181 | + if err != nil { | ||
| 182 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 183 | + } | ||
| 184 | + if dividendsEstimate == nil { | ||
| 185 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelDividendsEstimateCommand.DividendsEstimateId, 10))) | ||
| 186 | + } | ||
| 187 | + // TODO 校验是否能够取消 | ||
| 188 | + | ||
| 189 | + // 设置取消状态 | ||
| 190 | + cancelDividendsEstimateCommand.IsCanceled = true | ||
| 191 | + if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(cancelDividendsEstimateCommand)); err != nil { | ||
| 192 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 193 | + } | ||
| 194 | + if dividendsEstimate, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil { | ||
| 195 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 196 | + } else { | ||
| 172 | if err := transactionContext.CommitTransaction(); err != nil { | 197 | if err := transactionContext.CommitTransaction(); err != nil { |
| 173 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 198 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 174 | } | 199 | } |
| 175 | - return nil, nil | 200 | + return dividendsEstimate, nil |
| 201 | + } | ||
| 176 | } | 202 | } |
| 177 | 203 | ||
| 178 | // BatchCancelDividendsEstimate 批量取消分红预算单 | 204 | // BatchCancelDividendsEstimate 批量取消分红预算单 |
| @@ -46,6 +46,8 @@ type DividendsEstimate struct { | @@ -46,6 +46,8 @@ type DividendsEstimate struct { | ||
| 46 | Operator *User `json:"operator"` | 46 | Operator *User `json:"operator"` |
| 47 | // 操作时间 | 47 | // 操作时间 |
| 48 | OperateTime time.Time `json:"operateTime"` | 48 | OperateTime time.Time `json:"operateTime"` |
| 49 | + // 取消状态 | ||
| 50 | + IsCanceled bool `json:"isCanceled"` | ||
| 49 | // 创建时间 | 51 | // 创建时间 |
| 50 | CreatedAt time.Time `json:"createdAt"` | 52 | CreatedAt time.Time `json:"createdAt"` |
| 51 | // 删除时间 | 53 | // 删除时间 |
| @@ -94,5 +96,8 @@ func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{}) | @@ -94,5 +96,8 @@ func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{}) | ||
| 94 | if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok { | 96 | if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok { |
| 95 | dividendsEstimate.CooperationContractNumber = cooperationProjectNumber.(string) | 97 | dividendsEstimate.CooperationContractNumber = cooperationProjectNumber.(string) |
| 96 | } | 98 | } |
| 99 | + if isCanceled, ok := data["isCanceled"]; ok { | ||
| 100 | + dividendsEstimate.IsCanceled = isCanceled.(bool) | ||
| 101 | + } | ||
| 97 | return nil | 102 | return nil |
| 98 | } | 103 | } |
| @@ -37,6 +37,8 @@ type DividendsEstimate struct { | @@ -37,6 +37,8 @@ type DividendsEstimate struct { | ||
| 37 | Operator *domain.User `comment:"操作人"` | 37 | Operator *domain.User `comment:"操作人"` |
| 38 | // 操作时间 | 38 | // 操作时间 |
| 39 | OperateTime time.Time `comment:"操作时间"` | 39 | OperateTime time.Time `comment:"操作时间"` |
| 40 | + // 取消状态 | ||
| 41 | + IsCanceled bool `comment:"取消状态"` | ||
| 40 | // 创建时间 | 42 | // 创建时间 |
| 41 | CreatedAt time.Time `comment:"创建时间"` | 43 | CreatedAt time.Time `comment:"创建时间"` |
| 42 | // 删除时间 | 44 | // 删除时间 |
| @@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel | @@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel | ||
| 22 | Company: dividendsEstimateModel.Company, | 22 | Company: dividendsEstimateModel.Company, |
| 23 | Operator: dividendsEstimateModel.Operator, | 23 | Operator: dividendsEstimateModel.Operator, |
| 24 | OperateTime: dividendsEstimateModel.OperateTime, | 24 | OperateTime: dividendsEstimateModel.OperateTime, |
| 25 | + IsCanceled: dividendsEstimateModel.IsCanceled, | ||
| 25 | CreatedAt: dividendsEstimateModel.CreatedAt, | 26 | CreatedAt: dividendsEstimateModel.CreatedAt, |
| 26 | DeletedAt: dividendsEstimateModel.DeletedAt, | 27 | DeletedAt: dividendsEstimateModel.DeletedAt, |
| 27 | UpdatedAt: dividendsEstimateModel.UpdatedAt, | 28 | UpdatedAt: dividendsEstimateModel.UpdatedAt, |
| @@ -42,6 +42,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -42,6 +42,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
| 42 | "company", | 42 | "company", |
| 43 | "operator", | 43 | "operator", |
| 44 | "operate_time", | 44 | "operate_time", |
| 45 | + "is_canceled", | ||
| 45 | "created_at", | 46 | "created_at", |
| 46 | "deleted_at", | 47 | "deleted_at", |
| 47 | "updated_at", | 48 | "updated_at", |
| @@ -76,6 +77,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -76,6 +77,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
| 76 | ÷ndsEstimate.Company, | 77 | ÷ndsEstimate.Company, |
| 77 | ÷ndsEstimate.Operator, | 78 | ÷ndsEstimate.Operator, |
| 78 | ÷ndsEstimate.OperateTime, | 79 | ÷ndsEstimate.OperateTime, |
| 80 | + ÷ndsEstimate.IsCanceled, | ||
| 79 | ÷ndsEstimate.CreatedAt, | 81 | ÷ndsEstimate.CreatedAt, |
| 80 | ÷ndsEstimate.DeletedAt, | 82 | ÷ndsEstimate.DeletedAt, |
| 81 | ÷ndsEstimate.UpdatedAt, | 83 | ÷ndsEstimate.UpdatedAt, |
| @@ -96,8 +98,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -96,8 +98,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
| 96 | dividendsEstimate.Company, | 98 | dividendsEstimate.Company, |
| 97 | dividendsEstimate.Operator, | 99 | dividendsEstimate.Operator, |
| 98 | dividendsEstimate.OperateTime, | 100 | dividendsEstimate.OperateTime, |
| 101 | + dividendsEstimate.IsCanceled, | ||
| 99 | dividendsEstimate.CreatedAt, | 102 | dividendsEstimate.CreatedAt, |
| 100 | - dividendsEstimate.DeletedAt, | 103 | + nil, |
| 101 | dividendsEstimate.UpdatedAt, | 104 | dividendsEstimate.UpdatedAt, |
| 102 | ); err != nil { | 105 | ); err != nil { |
| 103 | return dividendsEstimate, err | 106 | return dividendsEstimate, err |
| @@ -120,6 +123,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -120,6 +123,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
| 120 | ÷ndsEstimate.Company, | 123 | ÷ndsEstimate.Company, |
| 121 | ÷ndsEstimate.Operator, | 124 | ÷ndsEstimate.Operator, |
| 122 | ÷ndsEstimate.OperateTime, | 125 | ÷ndsEstimate.OperateTime, |
| 126 | + ÷ndsEstimate.IsCanceled, | ||
| 123 | ÷ndsEstimate.CreatedAt, | 127 | ÷ndsEstimate.CreatedAt, |
| 124 | ÷ndsEstimate.DeletedAt, | 128 | ÷ndsEstimate.DeletedAt, |
| 125 | ÷ndsEstimate.UpdatedAt, | 129 | ÷ndsEstimate.UpdatedAt, |
| @@ -140,8 +144,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -140,8 +144,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
| 140 | dividendsEstimate.Company, | 144 | dividendsEstimate.Company, |
| 141 | dividendsEstimate.Operator, | 145 | dividendsEstimate.Operator, |
| 142 | dividendsEstimate.OperateTime, | 146 | dividendsEstimate.OperateTime, |
| 147 | + dividendsEstimate.IsCanceled, | ||
| 143 | dividendsEstimate.CreatedAt, | 148 | dividendsEstimate.CreatedAt, |
| 144 | - dividendsEstimate.DeletedAt, | 149 | + nil, |
| 145 | dividendsEstimate.UpdatedAt, | 150 | dividendsEstimate.UpdatedAt, |
| 146 | dividendsEstimate.Identify(), | 151 | dividendsEstimate.Identify(), |
| 147 | ); err != nil { | 152 | ); err != nil { |
| @@ -81,7 +81,7 @@ func (controller *DividendsEstimateController) CancelDividendsEstimate() { | @@ -81,7 +81,7 @@ func (controller *DividendsEstimateController) CancelDividendsEstimate() { | ||
| 81 | cancelDividendsEstimateCommand.OrgId = header.OrgId | 81 | cancelDividendsEstimateCommand.OrgId = header.OrgId |
| 82 | cancelDividendsEstimateCommand.UserId = header.UserId | 82 | cancelDividendsEstimateCommand.UserId = header.UserId |
| 83 | cancelDividendsEstimateCommand.UserBaseId = header.UserBaseId | 83 | cancelDividendsEstimateCommand.UserBaseId = header.UserBaseId |
| 84 | - dividendsEstimateId := controller.GetString(":dividendsEstimateId") | 84 | + dividendsEstimateId, _ := controller.GetInt64(":dividendsEstimateId") |
| 85 | cancelDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId | 85 | cancelDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId |
| 86 | data, err := dividendsEstimateService.CancelDividendsEstimate(cancelDividendsEstimateCommand) | 86 | data, err := dividendsEstimateService.CancelDividendsEstimate(cancelDividendsEstimateCommand) |
| 87 | controller.Response(data, err) | 87 | controller.Response(data, err) |
-
请 注册 或 登录 后发表评论