...
|
...
|
@@ -16,7 +16,6 @@ import ( |
|
|
"reflect"
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -347,7 +346,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
|
|
|
rowCnt++
|
|
|
nullCell := make([]interface{}, 0)
|
|
|
var myRow []string
|
|
|
var myRow *domain.FailReturnedInfo
|
|
|
t := reflect.TypeOf(dividendsReturnedOrder)
|
|
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
|
|
for k := 0; k < t.NumField(); k++ {
|
...
|
...
|
@@ -361,11 +360,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
}
|
|
|
}
|
|
|
if nullFlag {
|
|
|
s := strconv.Itoa(i + 1)
|
|
|
b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
|
|
|
myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息
|
|
|
myRow = append(myRow, s) // 行号
|
|
|
myRow = append(myRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
//s := strconv.Itoa(i + 1)
|
|
|
//b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
|
|
|
myRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "必填项为空",
|
|
|
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
|
|
|
}
|
|
|
nullCellError = append(nullCellError, myRow)
|
|
|
nullFlag = false
|
|
|
}
|
...
|
...
|
@@ -384,24 +384,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
|
|
|
// 单元格类型校验
|
|
|
typeError := make([]interface{}, 0)
|
|
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
|
|
|
var myRow []string
|
|
|
for _, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
|
|
|
var myRow *domain.FailReturnedInfo
|
|
|
t := reflect.TypeOf(dividendsReturnedOrder)
|
|
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
|
|
for k := 0; k < t.NumField(); k++ { // 列
|
|
|
r := strconv.Itoa(i + 1)
|
|
|
col := strconv.Itoa(k + 1)
|
|
|
|
|
|
switch k {
|
|
|
case 3: // 退货日期校验
|
|
|
{
|
|
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
|
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
|
|
if !ok {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货日期格式错误,请输入正确的退货日期") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow *domain.FailReturnedInfo
|
|
|
tmpRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "退货日期格式错误,请输入正确的退货日期",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -410,10 +408,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
|
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
|
|
if !ok {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列订单日期格式错误,请输入正确的订单日期") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow *domain.FailReturnedInfo
|
|
|
tmpRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "订单日期格式错误,请输入正确的订单日期",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -422,18 +421,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
//参数类型转换
|
|
|
orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
|
|
|
if err != nil {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量格式错误,退货数量必须整数") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow *domain.FailReturnedInfo
|
|
|
tmpRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "退货数量格式错误,退货数量必须整数",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
// 正负判断
|
|
|
if orderGoodQuantity < 0 {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量必须大于0,请重新填写") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow *domain.FailReturnedInfo
|
|
|
tmpRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "退货数量必须大于0,请重新填写",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -442,19 +443,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
// 参数类型转换
|
|
|
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
|
|
|
if typeErr != nil {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格格式错误,退货价格必须为数字类型") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow *domain.FailReturnedInfo
|
|
|
tmpRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "退货价格格式错误,退货价格必须为数字类型",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
|
|
|
// 长度校验
|
|
|
if univalent >= 1e16 {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
|
|
|
tmpRow = append(tmpRow, r) // 行号
|
|
|
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
|
|
var tmpRow *domain.FailReturnedInfo
|
|
|
tmpRow = &domain.FailReturnedInfo{
|
|
|
FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
myRow = tmpRow
|
|
|
}
|
|
|
}
|
...
|
...
|
|