切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
陈志颖
4 years ago
提交
efc7419bb92085030fa4ff80888fc35507c99cde
2 个父辈
03665dac
9a71475c
合并分支 'dev' 到 'test'
fix:增加删除合伙人类型判断 查看合并请求
!46
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
67 行增加
和
12 行删除
pkg/application/partnerInfo/service/partner_info.go
pkg/domain/order_base.go
pkg/infrastructure/repository/pg_order_base_repository.go
pkg/infrastructure/utils/math.go
pkg/application/partnerInfo/service/partner_info.go
查看文件 @
efc7419
...
...
@@ -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
}
...
...
pkg/domain/order_base.go
查看文件 @
efc7419
...
...
@@ -308,13 +308,14 @@ type OrderBaseFindOneQuery struct {
}
type
OrderBaseFindQuery
struct
{
PartnerId
int64
OrderCode
string
DeliveryCode
string
Offset
int
Limit
int
OrderType
int
CompanyId
int64
PartnerId
int64
OrderCode
string
DeliveryCode
string
Offset
int
Limit
int
OrderType
int
CompanyId
int64
PartnerCategoryIds
[]
int64
}
// 导入错误信息
...
...
pkg/infrastructure/repository/pg_order_base_repository.go
查看文件 @
efc7419
...
...
@@ -2,6 +2,7 @@ package repository
import
(
"fmt"
"github.com/go-pg/pg/v10"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
...
...
@@ -84,9 +85,6 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
Remark
:
orderInfo
.
Remark
,
PartnerCategory
:
orderInfo
.
PartnerCategory
,
}
//if m.OrderType > 2 { // TODO 非平台自建订单,默认销售日期取订单创建日期
// m.SaleDate = orderInfo.CreateTime
//}
if
m
.
Id
==
0
{
_
,
err
=
tx
.
Model
(
m
)
.
Returning
(
"*"
)
.
...
...
@@ -124,6 +122,9 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery
if
queryOption
.
CompanyId
>
0
{
query
=
query
.
Where
(
"company_id=?"
,
queryOption
.
CompanyId
)
}
if
len
(
queryOption
.
PartnerCategoryIds
)
>
0
{
query
=
query
.
Where
(
`(order_base.partner_category->>'id')::int IN (?)`
,
pg
.
In
(
queryOption
.
PartnerCategoryIds
))
}
if
queryOption
.
Offset
>
-
1
{
query
=
query
.
Offset
(
queryOption
.
Offset
)
}
...
...
pkg/infrastructure/utils/math.go
查看文件 @
efc7419
...
...
@@ -47,3 +47,19 @@ func IsContain(items []string, item string) bool {
}
return
false
}
/**
* @Author SteveChan
* @Description //TODO
* @Date 23:34 2021/2/2
* @Param
* @return
**/
func
IsContainInt
(
items
[]
int64
,
item
int64
)
bool
{
for
_
,
eachItem
:=
range
items
{
if
eachItem
==
item
{
return
true
}
}
return
false
}
...
...
请
注册
或
登录
后发表评论