作者 唐旭辉

更新:1、取消校验订单号的唯一性;2、订单号,发单号去除首尾空格

... ... @@ -181,11 +181,11 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
//检查order_code是否重复
if ok, err := orderBaseDao.OrderCodeExist(cmd.OrderCode); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
} else if ok {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在")
}
// if ok, err := orderBaseDao.OrderCodeExist(cmd.OrderCode); err != nil {
// return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
// } else if ok {
// return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在")
// }
//检查delivery_code是否重复
if len(cmd.DeliveryCode) > 0 {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode); err != nil {
... ... @@ -352,11 +352,11 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
//检查order_code是否重复
if ok, err := orderBaseDao.OrderCodeExist(cmd.OrderCode, cmd.Id); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
} else if ok {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在")
}
// if ok, err := orderBaseDao.OrderCodeExist(cmd.OrderCode, cmd.Id); err != nil {
// return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
// } else if ok {
// return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在")
// }
//检查delivery_code是否重复
if len(cmd.DeliveryCode) > 0 {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.Id); err != nil {
... ...
... ... @@ -5,6 +5,7 @@ import (
"fmt"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
... ... @@ -181,7 +182,10 @@ type postPurposeOrderDetail struct {
Product []postOrderGood `json:"product"`
}
func (postData postPurposeOrderDetail) Valid() error {
func (postData *postPurposeOrderDetail) Valid() error {
postData.OrderId = strings.TrimSpace(postData.OrderId)
postData.BuyerName = strings.TrimSpace(postData.BuyerName)
postData.OrderDist = strings.TrimSpace(postData.OrderDist)
if len(postData.OrderId) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单编号必填")
}
... ... @@ -217,7 +221,8 @@ type postOrderGood struct {
PartnerRatio float64 `json:"partnerRatio"`
}
func (postData postOrderGood) Valid() error {
func (postData *postOrderGood) Valid() error {
postData.ProductName = strings.TrimSpace(postData.ProductName)
lenProductName := utf8.RuneCountInString(postData.ProductName)
if lenProductName == 0 {
return lib.ThrowError(lib.ARG_ERROR, "商品名称必填")
... ... @@ -256,6 +261,7 @@ func (c *OrderInfoController) UpdateOrderPurpose() {
c.ResponseError(errors.New("json数据解析失败"))
return
}
if err := param.Valid(); err != nil {
c.ResponseError(err)
return
... ... @@ -332,7 +338,8 @@ type postOrderPurposeDelivery struct {
ProductDetail []postOrderGood `json:"productDetail"`
}
func (postData postOrderPurposeDelivery) Valid() error {
func (postData *postOrderPurposeDelivery) Valid() error {
postData.ShipmentsId = strings.TrimSpace(postData.ShipmentsId)
lenShipmentsId := utf8.RuneCountInString(postData.ShipmentsId)
if lenShipmentsId == 0 {
return lib.ThrowError(lib.ARG_ERROR, "发货单号必填")
... ... @@ -544,6 +551,7 @@ type postRealOrderDetail struct {
}
func (postData postRealOrderDetail) Valid() error {
postData.ShipmentsId = strings.TrimSpace(postData.ShipmentsId)
if len(postData.ShipmentsId) == 0 {
return lib.ThrowError(lib.ARG_ERROR, "订单的发货单号必填")
}
... ...
... ... @@ -23,6 +23,7 @@ require (
github.com/mattn/go-sqlite3 v1.10.0
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/pkg/errors v0.8.0 // indirect
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d // indirect
... ...