|
@@ -2,6 +2,7 @@ package service |
|
@@ -2,6 +2,7 @@ package service |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/utils"
|
5
|
|
6
|
|
6
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"github.com/linmadan/egglib-go/core/application"
|
7
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
|
8
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
|
|
@@ -238,7 +239,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI |
|
@@ -238,7 +239,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI |
238
|
|
239
|
|
239
|
/**
|
240
|
/**
|
240
|
* @Author SteveChan
|
241
|
* @Author SteveChan
|
241
|
- * @Description // 更新合伙人
|
242
|
+ * @Description //TODO 更新合伙人,判断合伙类型是否有业务数据
|
242
|
* @Date 00:07 2020/12/30
|
243
|
* @Date 00:07 2020/12/30
|
243
|
* @Param
|
244
|
* @Param
|
244
|
* @return
|
245
|
* @return
|
|
@@ -261,7 +262,9 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
@@ -261,7 +262,9 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
261
|
var (
|
262
|
var (
|
262
|
partnerInfoRepository domain.PartnerInfoRepository
|
263
|
partnerInfoRepository domain.PartnerInfoRepository
|
263
|
categoryRepository domain.PartnerCategoryRepository
|
264
|
categoryRepository domain.PartnerCategoryRepository
|
|
|
265
|
+ orderBaseRepository domain.OrderBaseRepository
|
264
|
categories []domain.PartnerCategory
|
266
|
categories []domain.PartnerCategory
|
|
|
267
|
+ orders []domain.OrderBase
|
265
|
partnerInfoDao *dao.PartnerInfoDao
|
268
|
partnerInfoDao *dao.PartnerInfoDao
|
266
|
)
|
269
|
)
|
267
|
|
270
|
|
|
@@ -283,6 +286,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
@@ -283,6 +286,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
283
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
286
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
284
|
}
|
287
|
}
|
285
|
|
288
|
|
|
|
289
|
+ if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
|
|
|
290
|
+ "transactionContext": transactionContext,
|
|
|
291
|
+ }); err != nil {
|
|
|
292
|
+ return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
293
|
+ }
|
|
|
294
|
+
|
286
|
// 获取合伙人类型
|
295
|
// 获取合伙人类型
|
287
|
var categoryMap = make(map[int64]string)
|
296
|
var categoryMap = make(map[int64]string)
|
288
|
_, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
|
297
|
_, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
|
|
@@ -349,6 +358,34 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
@@ -349,6 +358,34 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
349
|
return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作")
|
358
|
return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作")
|
350
|
}
|
359
|
}
|
351
|
|
360
|
|
|
|
361
|
+ partnerCategoryInfos := partnerInfo.PartnerCategoryInfos
|
|
|
362
|
+
|
|
|
363
|
+ //判断相应合伙类型下是否有订单数据
|
|
|
364
|
+ var notInPartnerCategoryInfos []int64
|
|
|
365
|
+ var categoryIdsQuery []int64
|
|
|
366
|
+ var categoryIdsCmd []int64
|
|
|
367
|
+ for _, partnerCategory := range partnerCategoryInfos {
|
|
|
368
|
+ categoryIdsQuery = append(categoryIdsQuery, partnerCategory.Id)
|
|
|
369
|
+ }
|
|
|
370
|
+ for _, category := range categories {
|
|
|
371
|
+ categoryIdsCmd = append(categoryIdsCmd, category.Id)
|
|
|
372
|
+ }
|
|
|
373
|
+ for _, v := range categoryIdsQuery {
|
|
|
374
|
+ if !utils.IsContainInt(categoryIdsCmd, v) {
|
|
|
375
|
+ notInPartnerCategoryInfos = append(notInPartnerCategoryInfos, v)
|
|
|
376
|
+ }
|
|
|
377
|
+ }
|
|
|
378
|
+ if len(notInPartnerCategoryInfos) > 0 {
|
|
|
379
|
+ orders, _, err = orderBaseRepository.Find(domain.OrderBaseFindQuery{
|
|
|
380
|
+ PartnerId: cmd.Id,
|
|
|
381
|
+ CompanyId: cmd.CompanyId,
|
|
|
382
|
+ PartnerCategoryIds: notInPartnerCategoryInfos,
|
|
|
383
|
+ })
|
|
|
384
|
+ if len(orders) > 0 {
|
|
|
385
|
+ return lib.ThrowError(lib.BUSINESS_ERROR, "该合伙类型下有业务数据,不可删除!")
|
|
|
386
|
+ }
|
|
|
387
|
+ }
|
|
|
388
|
+
|
352
|
partnerInfo.Partner.PartnerName = cmd.PartnerName
|
389
|
partnerInfo.Partner.PartnerName = cmd.PartnerName
|
353
|
partnerInfo.Salesman = cmd.Salesman
|
390
|
partnerInfo.Salesman = cmd.Salesman
|
354
|
partnerInfo.Status = cmd.Status
|
391
|
partnerInfo.Status = cmd.Status
|
|
@@ -372,7 +409,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
@@ -372,7 +409,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
372
|
// e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err)
|
409
|
// e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err)
|
373
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
|
410
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
|
374
|
// }
|
411
|
// }
|
375
|
- transactionContext.CommitTransaction()
|
412
|
+ _ = transactionContext.CommitTransaction()
|
376
|
return
|
413
|
return
|
377
|
}
|
414
|
}
|
378
|
|
415
|
|