...
|
...
|
@@ -186,7 +186,9 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( |
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
err error
|
|
|
)
|
|
|
|
|
|
if err = cmd.Valid(); err != nil {
|
|
|
return nil, lib.ThrowError(lib.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -232,7 +234,15 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( |
|
|
} else if ok {
|
|
|
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在")
|
|
|
}
|
|
|
|
|
|
//检查货品数据
|
|
|
var goodMap = map[string]int{}
|
|
|
for i := range cmd.Goods {
|
|
|
goodname := cmd.Goods[i].GoodName
|
|
|
if _, ok := goodMap[goodname]; ok {
|
|
|
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单中货品重复已存在")
|
|
|
}
|
|
|
goodMap[goodname] = 1
|
|
|
}
|
|
|
newOrder := &domain.OrderBase{
|
|
|
OrderType: cmd.OrderType, OrderCode: cmd.OrderCode,
|
|
|
DeliveryCode: cmd.DeliveryCode,
|
...
|
...
|
@@ -435,6 +445,15 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) |
|
|
} else if ok {
|
|
|
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在")
|
|
|
}
|
|
|
//检查货品数据
|
|
|
var goodMap = map[string]int{}
|
|
|
for i := range cmd.Goods {
|
|
|
goodname := cmd.Goods[i].GoodName
|
|
|
if _, ok := goodMap[goodname]; ok {
|
|
|
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单中货品重复已存在")
|
|
|
}
|
|
|
goodMap[goodname] = 1
|
|
|
}
|
|
|
//获取旧的订单中的商品
|
|
|
oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
|
|
|
OrderId: cmd.Id,
|
...
|
...
|
|