切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
5 years ago
提交
0e8ad47e86219616d4082867fcacc4a604a756c5
1 个父辈
1f4ad298
校验订单编号的唯一性
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
26 行增加
和
5 行删除
pkg/application/order/service/order.go
pkg/infrastructure/dao/pg_order_dao.go
pkg/infrastructure/repository/pg_order_repository.go
pkg/application/order/service/order.go
查看文件 @
0e8ad47
...
...
@@ -132,6 +132,14 @@ func (service OrderService) CreateOrder(command command.CreateOrderCommand) erro
transactionContext
.
RollbackTransaction
()
}()
orderDao
,
_
:=
factory
.
CreateOrderDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
ok
,
err
:=
orderDao
.
OrderCodeIsExist
(
command
.
OrderCode
,
0
)
if
err
!=
nil
{
return
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
ok
{
return
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
"订单编号已存在"
)
}
var
PartnerInfoRepository
domain
.
PartnerInfoRepository
if
PartnerInfoRepository
,
err
=
factory
.
CreatePartnerInfoRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
...
...
@@ -210,6 +218,14 @@ func (service OrderService) UpdateOrderPurpose(command command.UpdateOrderComman
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
orderDao
,
_
:=
factory
.
CreateOrderDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
ok
,
err
:=
orderDao
.
OrderCodeIsExist
(
command
.
OrderCode
,
command
.
Id
)
if
err
!=
nil
{
return
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
ok
{
return
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
"订单编号已存在"
)
}
var
(
orderRepository
domain
.
OrderRepository
orderData
*
domain
.
Order
...
...
@@ -318,6 +334,14 @@ func (service OrderService) UpdateOrderReal(command command.UpdateOrderRealComma
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
orderDao
,
_
:=
factory
.
CreateOrderDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
ok
,
err
:=
orderDao
.
OrderCodeIsExist
(
command
.
OrderCode
,
command
.
Id
)
if
err
!=
nil
{
return
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
ok
{
return
lib
.
ThrowError
(
lib
.
BUSINESS_ERROR
,
"订单编号已存在"
)
}
var
(
orderRepository
domain
.
OrderRepository
orderData
*
domain
.
Order
...
...
pkg/infrastructure/dao/pg_order_dao.go
查看文件 @
0e8ad47
...
...
@@ -28,11 +28,11 @@ func (dao *OrderDao) Update(options map[string]interface{}) (err error) {
return
}
func
(
dao
*
OrderDao
)
OrderCodeIsExist
(
code
string
,
orderType
int
)
(
bool
,
error
)
{
func
(
dao
*
OrderDao
)
OrderCodeIsExist
(
code
string
,
notId
int64
)
(
bool
,
error
)
{
tx
:=
dao
.
transactionContext
.
PgDd
ok
,
err
:=
tx
.
Model
(
new
(
models
.
Order
))
.
Where
(
"order_code=?"
,
code
)
.
Where
(
"
order_type=?"
,
orderType
)
.
Where
(
"
id<>?"
,
notId
)
.
Exists
()
return
ok
,
err
}
...
...
pkg/infrastructure/repository/pg_order_repository.go
查看文件 @
0e8ad47
...
...
@@ -70,9 +70,6 @@ func (repository OrderRepository) Save(orderInfo *domain.Order) error {
PartnerId
:
orderInfo
.
PartnerInfo
.
Id
,
PartnerBonusPercent
:
orderInfo
.
PartnerBonusPercent
,
SalesmanBonusPercent
:
orderInfo
.
SalesmanBonusPercent
,
// CreateAt: orderInfo.CreateAt,
// UpdateAt: orderInfo.UpdateAt,
// LastViewTime: orderInfo.LastViewTime,
}
if
m
.
Id
==
0
{
err
=
tx
.
Insert
(
m
)
...
...
请
注册
或
登录
后发表评论