Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/partnermg into dev
正在显示
4 个修改的文件
包含
87 行增加
和
18 行删除
@@ -10,6 +10,8 @@ import ( | @@ -10,6 +10,8 @@ import ( | ||
10 | type UpdatePartnerInfoCommand struct { | 10 | type UpdatePartnerInfoCommand struct { |
11 | // 合伙人Id | 11 | // 合伙人Id |
12 | Id int64 `json:"id"` | 12 | Id int64 `json:"id"` |
13 | + // 合伙人姓名 | ||
14 | + PartnerName string `json:"partnerName"` | ||
13 | // 状态(1:启用或者0:禁用) | 15 | // 状态(1:启用或者0:禁用) |
14 | Status int `json:"status"` | 16 | Status int `json:"status"` |
15 | // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) | 17 | // 合伙类别 (1.研发合伙人 2.业务合伙人 3.事业) |
@@ -33,7 +35,6 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error { | @@ -33,7 +35,6 @@ func (command *UpdatePartnerInfoCommand) ValidateCommand() error { | ||
33 | if command.RegionInfo == nil { | 35 | if command.RegionInfo == nil { |
34 | return lib.ThrowError(lib.ARG_ERROR, "区域必填") | 36 | return lib.ThrowError(lib.ARG_ERROR, "区域必填") |
35 | } | 37 | } |
36 | - | ||
37 | if command.Id == 0 { | 38 | if command.Id == 0 { |
38 | return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误") | 39 | return lib.ThrowError(lib.ARG_ERROR, "合伙人id错误") |
39 | } | 40 | } |
@@ -45,6 +45,9 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | @@ -45,6 +45,9 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | ||
45 | //检查账号是否存在 | 45 | //检查账号是否存在 |
46 | var ( | 46 | var ( |
47 | partnerInfoDao *dao.PartnerInfoDao | 47 | partnerInfoDao *dao.PartnerInfoDao |
48 | + partnerInfoRepository domain.PartnerInfoRepository | ||
49 | + categoryRepository domain.PartnerCategoryRepository | ||
50 | + categories []domain.PartnerCategory | ||
48 | ) | 51 | ) |
49 | if partnerInfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{ | 52 | if partnerInfoDao, err = factory.CreatePartnerInfoDao(map[string]interface{}{ |
50 | "transactionContext": transactionContext, | 53 | "transactionContext": transactionContext, |
@@ -60,20 +63,6 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | @@ -60,20 +63,6 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | ||
60 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "账号已存在") | 63 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "账号已存在") |
61 | } | 64 | } |
62 | 65 | ||
63 | - // 编号去重 | ||
64 | - for _, partnerCategory := range cmd.PartnerCategory { | ||
65 | - if ok, err := partnerInfoDao.PartnerCodeExist(partnerCategory.Id, partnerCategory.Code, cmd.CompanyId, 0); err != nil { | ||
66 | - return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
67 | - } else if ok { | ||
68 | - return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙类型"+""+"编号"+partnerCategory.Code+"已存在") | ||
69 | - } | ||
70 | - } | ||
71 | - | ||
72 | - var ( | ||
73 | - partnerInfoRepository domain.PartnerInfoRepository | ||
74 | - categoryRepository domain.PartnerCategoryRepository | ||
75 | - categories []domain.PartnerCategory | ||
76 | - ) | ||
77 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 66 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ |
78 | "transactionContext": transactionContext, | 67 | "transactionContext": transactionContext, |
79 | }); err != nil { | 68 | }); err != nil { |
@@ -85,6 +74,40 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | @@ -85,6 +74,40 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | ||
85 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 74 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
86 | } | 75 | } |
87 | 76 | ||
77 | + // 获取所有合伙人类型 | ||
78 | + var categoryMap = make(map[int64]string) | ||
79 | + _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ | ||
80 | + Ids: []int64{}, | ||
81 | + }) | ||
82 | + if err != nil { | ||
83 | + e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) | ||
84 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
85 | + } | ||
86 | + if len(categories) > 0 { | ||
87 | + for _, category := range categories { | ||
88 | + categoryMap[category.Id] = category.Name | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + // id去重 | ||
93 | + num := make(map[int64]bool) | ||
94 | + for _, partnerCategory := range cmd.PartnerCategory { | ||
95 | + if !num[partnerCategory.Id] { | ||
96 | + num[partnerCategory.Id] = true | ||
97 | + } else { | ||
98 | + return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙类型不能重复") | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | + // 编号去重 | ||
103 | + for _, partnerCategory := range cmd.PartnerCategory { | ||
104 | + if ok, err := partnerInfoDao.PartnerCodeExist(partnerCategory.Id, partnerCategory.Code, cmd.CompanyId, 0); err != nil { | ||
105 | + return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
106 | + } else if ok { | ||
107 | + return nil, lib.ThrowError(lib.BUSINESS_ERROR, categoryMap[partnerCategory.Id]+"编号"+partnerCategory.Code+"已存在") | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
88 | var ids []int64 | 111 | var ids []int64 |
89 | for _, partnerCategory := range cmd.PartnerCategory { | 112 | for _, partnerCategory := range cmd.PartnerCategory { |
90 | ids = append(ids, partnerCategory.Id) | 113 | ids = append(ids, partnerCategory.Id) |
@@ -260,12 +283,37 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd | @@ -260,12 +283,37 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd | ||
260 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 283 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
261 | } | 284 | } |
262 | 285 | ||
286 | + // 获取合伙人类型 | ||
287 | + var categoryMap = make(map[int64]string) | ||
288 | + _, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{ | ||
289 | + Ids: []int64{}, | ||
290 | + }) | ||
291 | + if err != nil { | ||
292 | + e := fmt.Sprintf("获取合伙人分类数据失败:%s", err) | ||
293 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
294 | + } | ||
295 | + if len(categories) > 0 { | ||
296 | + for _, category := range categories { | ||
297 | + categoryMap[category.Id] = category.Name | ||
298 | + } | ||
299 | + } | ||
300 | + | ||
301 | + // id去重 | ||
302 | + num := make(map[int64]bool) | ||
303 | + for _, partnerCategory := range cmd.PartnerCategory { | ||
304 | + if !num[partnerCategory.Id] { | ||
305 | + num[partnerCategory.Id] = true | ||
306 | + } else { | ||
307 | + return lib.ThrowError(lib.BUSINESS_ERROR, "合伙类型不能重复") | ||
308 | + } | ||
309 | + } | ||
310 | + | ||
263 | // 编号去重 | 311 | // 编号去重 |
264 | for _, partnerCategory := range cmd.PartnerCategory { | 312 | for _, partnerCategory := range cmd.PartnerCategory { |
265 | if ok, err := partnerInfoDao.PartnerCodeExist(partnerCategory.Id, partnerCategory.Code, cmd.CompanyId, cmd.Id); err != nil { | 313 | if ok, err := partnerInfoDao.PartnerCodeExist(partnerCategory.Id, partnerCategory.Code, cmd.CompanyId, cmd.Id); err != nil { |
266 | return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 314 | return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
267 | } else if ok { | 315 | } else if ok { |
268 | - return lib.ThrowError(lib.BUSINESS_ERROR, "编号"+partnerCategory.Code+"已存在") | 316 | + return lib.ThrowError(lib.BUSINESS_ERROR, categoryMap[partnerCategory.Id]+"编号"+partnerCategory.Code+"已存在") |
269 | } | 317 | } |
270 | } | 318 | } |
271 | 319 | ||
@@ -301,6 +349,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd | @@ -301,6 +349,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd | ||
301 | return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作") | 349 | return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作") |
302 | } | 350 | } |
303 | 351 | ||
352 | + partnerInfo.Partner.PartnerName = cmd.PartnerName | ||
304 | partnerInfo.Salesman = cmd.Salesman | 353 | partnerInfo.Salesman = cmd.Salesman |
305 | partnerInfo.Status = cmd.Status | 354 | partnerInfo.Status = cmd.Status |
306 | partnerInfo.RegionInfo = *cmd.RegionInfo | 355 | partnerInfo.RegionInfo = *cmd.RegionInfo |
@@ -411,7 +460,7 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | @@ -411,7 +460,7 @@ func (PartnerInfoService *PartnerInfoService) ListPartnerInfo(listPartnerInfoQue | ||
411 | 460 | ||
412 | /** | 461 | /** |
413 | * @Author SteveChan | 462 | * @Author SteveChan |
414 | - * @Description //TODO 移除合伙人 | 463 | + * @Description // 移除合伙人 |
415 | * @Date 16:40 2020/12/29 | 464 | * @Date 16:40 2020/12/29 |
416 | * @Param | 465 | * @Param |
417 | * @return | 466 | * @return |
@@ -432,6 +481,8 @@ func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(cmd command.Remo | @@ -432,6 +481,8 @@ func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(cmd command.Remo | ||
432 | 481 | ||
433 | var ( | 482 | var ( |
434 | partnerInfoRepository domain.PartnerInfoRepository | 483 | partnerInfoRepository domain.PartnerInfoRepository |
484 | + orderBaseRepository domain.OrderBaseRepository | ||
485 | + orders []domain.OrderBase | ||
435 | ) | 486 | ) |
436 | 487 | ||
437 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | 488 | if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ |
@@ -440,7 +491,19 @@ func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(cmd command.Remo | @@ -440,7 +491,19 @@ func (PartnerInfoService *PartnerInfoService) RemovePartnerInfo(cmd command.Remo | ||
440 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 491 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
441 | } | 492 | } |
442 | 493 | ||
494 | + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
495 | + "transactionContext": transactionContext, | ||
496 | + }); err != nil { | ||
497 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
498 | + } | ||
499 | + | ||
443 | // 判断合伙人是否有业务数据 | 500 | // 判断合伙人是否有业务数据 |
501 | + orders, _, err = orderBaseRepository.Find(domain.OrderBaseFindQuery{ | ||
502 | + PartnerId: cmd.Id, | ||
503 | + }) | ||
504 | + if len(orders) > 0 { | ||
505 | + return lib.ThrowError(lib.BUSINESS_ERROR, "该合伙人有业务数据,不可删除!") | ||
506 | + } | ||
444 | 507 | ||
445 | if err = partnerInfoRepository.Remove(cmd.Id); err != nil { | 508 | if err = partnerInfoRepository.Remove(cmd.Id); err != nil { |
446 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 509 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -106,6 +106,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { | @@ -106,6 +106,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { | ||
106 | //用与适配前端定义的数据结构 | 106 | //用与适配前端定义的数据结构 |
107 | type Parameter struct { | 107 | type Parameter struct { |
108 | ID int64 `json:"id"` | 108 | ID int64 `json:"id"` |
109 | + PartnerName string `json:"partnerName"` | ||
109 | PartnerType []*domain.PartnerCategory `json:"partnerType"` | 110 | PartnerType []*domain.PartnerCategory `json:"partnerType"` |
110 | Area string `json:"area"` | 111 | Area string `json:"area"` |
111 | State int `json:"state"` | 112 | State int `json:"state"` |
@@ -132,6 +133,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { | @@ -132,6 +133,7 @@ func (c *PartnerInfoController) UpdatePartnerInfo() { | ||
132 | companyId := c.GetUserCompany() | 133 | companyId := c.GetUserCompany() |
133 | cmd := partnerInfoCmd.UpdatePartnerInfoCommand{ | 134 | cmd := partnerInfoCmd.UpdatePartnerInfoCommand{ |
134 | Id: param.ID, | 135 | Id: param.ID, |
136 | + PartnerName: param.PartnerName, | ||
135 | Status: param.State, | 137 | Status: param.State, |
136 | PartnerCategory: param.PartnerType, | 138 | PartnerCategory: param.PartnerType, |
137 | CooperateTime: cooperateTime, | 139 | CooperateTime: cooperateTime, |
@@ -216,7 +218,7 @@ func (c *PartnerInfoController) GetPartnerInfo() { | @@ -216,7 +218,7 @@ func (c *PartnerInfoController) GetPartnerInfo() { | ||
216 | 218 | ||
217 | /** | 219 | /** |
218 | * @Author SteveChan | 220 | * @Author SteveChan |
219 | - * @Description //TODO 移除合伙人 | 221 | + * @Description // 移除合伙人 |
220 | * @Date 15:31 2020/12/29 | 222 | * @Date 15:31 2020/12/29 |
221 | * @Param | 223 | * @Param |
222 | * @return | 224 | * @return |
@@ -357,6 +359,9 @@ func (c *PartnerInfoController) ListPartnerInfo() { | @@ -357,6 +359,9 @@ func (c *PartnerInfoController) ListPartnerInfo() { | ||
357 | } | 359 | } |
358 | resp = append(resp, m) | 360 | resp = append(resp, m) |
359 | } | 361 | } |
362 | + if len(resp) == 0 { | ||
363 | + resp = []map[string]interface{}{} | ||
364 | + } | ||
360 | c.ResponsePageList(resp, count, param.PageNumber) | 365 | c.ResponsePageList(resp, count, param.PageNumber) |
361 | return | 366 | return |
362 | } | 367 | } |
tags
0 → 100644
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论