切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
5 years ago
提交
643c683e6883c60163a73298676f203f54d30929
1 个父辈
794be1de
更新:新增 接受订单数据时进行参数检验
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
32 行增加
和
2 行删除
pkg/port/beego/controllers/order_info_controlller.go
pkg/port/beego/controllers/order_info_controlller.go
查看文件 @
643c683
...
...
@@ -3,8 +3,10 @@ package controllers
import
(
"errors"
"fmt"
"regexp"
"strconv"
"time"
"unicode/utf8"
"github.com/astaxie/beego/logs"
orderCmd
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/command"
...
...
@@ -192,6 +194,9 @@ func (postData postPurposeOrderDetail) Valid() error {
if
len
(
postData
.
OrderDist
)
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"订单区域必填"
)
}
if
len
(
postData
.
Product
)
>
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"货品列表必填"
)
}
if
len
(
postData
.
Product
)
>
50
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"货品列表最多50项"
)
}
...
...
@@ -213,9 +218,29 @@ type postOrderGood struct {
}
func
(
postData
postOrderGood
)
Valid
()
error
{
if
len
(
postData
.
ProductName
)
==
0
{
lenProductName
:=
utf8
.
RuneCountInString
(
postData
.
ProductName
)
if
lenProductName
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"商品名称必填"
)
}
if
lenProductName
>=
50
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"商品名称最多50位"
)
}
if
postData
.
OrderNum
>=
1e16
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"商品数量最多16位"
)
}
if
postData
.
Univalence
>=
1e16
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"商品单价最多16位"
)
}
if
postData
.
PartnerRatio
>
100
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人分红比例超额"
)
}
partnerRatio
:=
fmt
.
Sprint
(
postData
.
PartnerRatio
)
regexpStr
:=
`^(100|[1-9]\d|\d)(.\d{1,2})$`
ok
:=
regexp
.
MustCompile
(
regexpStr
)
.
MatchString
(
partnerRatio
)
if
!
ok
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"合伙人分红比例精确到小数点2位"
)
}
return
nil
}
...
...
@@ -308,9 +333,14 @@ type postOrderPurposeDelivery struct {
}
func
(
postData
postOrderPurposeDelivery
)
Valid
()
error
{
if
len
(
postData
.
ShipmentsId
)
==
0
{
lenShipmentsId
:=
utf8
.
RuneCountInString
(
postData
.
ShipmentsId
)
if
lenShipmentsId
==
0
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"发货单号必填"
)
}
if
lenShipmentsId
>
50
{
return
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
"发货单号最多50位"
)
}
for
i
:=
range
postData
.
ProductDetail
{
if
err
:=
postData
.
ProductDetail
[
i
]
.
Valid
();
err
!=
nil
{
return
err
...
...
请
注册
或
登录
后发表评论