...
|
...
|
@@ -2,6 +2,7 @@ package service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/utils"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
|
...
|
...
|
@@ -238,7 +239,7 @@ func (PartnerInfoService *PartnerInfoService) GetPartnerInfo(q query.GetPartnerI |
|
|
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description // 更新合伙人
|
|
|
* @Description //TODO 更新合伙人,判断合伙类型是否有业务数据
|
|
|
* @Date 00:07 2020/12/30
|
|
|
* @Param
|
|
|
* @return
|
...
|
...
|
@@ -261,7 +262,9 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
|
var (
|
|
|
partnerInfoRepository domain.PartnerInfoRepository
|
|
|
categoryRepository domain.PartnerCategoryRepository
|
|
|
orderBaseRepository domain.OrderBaseRepository
|
|
|
categories []domain.PartnerCategory
|
|
|
orders []domain.OrderBase
|
|
|
partnerInfoDao *dao.PartnerInfoDao
|
|
|
)
|
|
|
|
...
|
...
|
@@ -283,6 +286,12 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 获取合伙人类型
|
|
|
var categoryMap = make(map[int64]string)
|
|
|
_, categories, err = categoryRepository.Find(domain.PartnerCategoryFindQuery{
|
...
|
...
|
@@ -349,6 +358,34 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
|
return lib.ThrowError(lib.BUSINESS_ERROR, "异常操作")
|
|
|
}
|
|
|
|
|
|
partnerCategoryInfos := partnerInfo.PartnerCategoryInfos
|
|
|
|
|
|
//判断相应合伙类型下是否有订单数据
|
|
|
var notInPartnerCategoryInfos []int64
|
|
|
var categoryIdsQuery []int64
|
|
|
var categoryIdsCmd []int64
|
|
|
for _, partnerCategory := range partnerCategoryInfos {
|
|
|
categoryIdsQuery = append(categoryIdsQuery, partnerCategory.Id)
|
|
|
}
|
|
|
for _, category := range categories {
|
|
|
categoryIdsCmd = append(categoryIdsCmd, category.Id)
|
|
|
}
|
|
|
for _, v := range categoryIdsQuery {
|
|
|
if !utils.IsContainInt(categoryIdsCmd, v) {
|
|
|
notInPartnerCategoryInfos = append(notInPartnerCategoryInfos, v)
|
|
|
}
|
|
|
}
|
|
|
if len(notInPartnerCategoryInfos) > 0 {
|
|
|
orders, _, err = orderBaseRepository.Find(domain.OrderBaseFindQuery{
|
|
|
PartnerId: cmd.Id,
|
|
|
CompanyId: cmd.CompanyId,
|
|
|
PartnerCategoryIds: notInPartnerCategoryInfos,
|
|
|
})
|
|
|
if len(orders) > 0 {
|
|
|
return lib.ThrowError(lib.BUSINESS_ERROR, "该合伙类型下有业务数据,不可删除!")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
partnerInfo.Partner.PartnerName = cmd.PartnerName
|
|
|
partnerInfo.Salesman = cmd.Salesman
|
|
|
partnerInfo.Status = cmd.Status
|
...
|
...
|
@@ -372,7 +409,7 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd |
|
|
// e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err)
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
|
|
|
// }
|
|
|
transactionContext.CommitTransaction()
|
|
|
_ = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
|