|
@@ -16,7 +16,6 @@ import ( |
|
@@ -16,7 +16,6 @@ import ( |
16
|
"reflect"
|
16
|
"reflect"
|
17
|
"regexp"
|
17
|
"regexp"
|
18
|
"strconv"
|
18
|
"strconv"
|
19
|
- "strings"
|
|
|
20
|
"time"
|
19
|
"time"
|
21
|
)
|
20
|
)
|
22
|
|
21
|
|
|
@@ -347,7 +346,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -347,7 +346,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
347
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
|
346
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
|
348
|
rowCnt++
|
347
|
rowCnt++
|
349
|
nullCell := make([]interface{}, 0)
|
348
|
nullCell := make([]interface{}, 0)
|
350
|
- var myRow []string
|
349
|
+ var myRow *domain.FailReturnedInfo
|
351
|
t := reflect.TypeOf(dividendsReturnedOrder)
|
350
|
t := reflect.TypeOf(dividendsReturnedOrder)
|
352
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
351
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
353
|
for k := 0; k < t.NumField(); k++ {
|
352
|
for k := 0; k < t.NumField(); k++ {
|
|
@@ -361,11 +360,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -361,11 +360,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
361
|
}
|
360
|
}
|
362
|
}
|
361
|
}
|
363
|
if nullFlag {
|
362
|
if nullFlag {
|
364
|
- s := strconv.Itoa(i + 1)
|
|
|
365
|
- b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
|
|
|
366
|
- myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息
|
|
|
367
|
- myRow = append(myRow, s) // 行号
|
|
|
368
|
- myRow = append(myRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
363
|
+ //s := strconv.Itoa(i + 1)
|
|
|
364
|
+ //b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
|
|
|
365
|
+ myRow = &domain.FailReturnedInfo{
|
|
|
366
|
+ FailReason: "必填项为空",
|
|
|
367
|
+ ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
|
|
|
368
|
+ }
|
369
|
nullCellError = append(nullCellError, myRow)
|
369
|
nullCellError = append(nullCellError, myRow)
|
370
|
nullFlag = false
|
370
|
nullFlag = false
|
371
|
}
|
371
|
}
|
|
@@ -384,24 +384,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -384,24 +384,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
384
|
|
384
|
|
385
|
// 单元格类型校验
|
385
|
// 单元格类型校验
|
386
|
typeError := make([]interface{}, 0)
|
386
|
typeError := make([]interface{}, 0)
|
387
|
- for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
|
|
|
388
|
- var myRow []string
|
387
|
+ for _, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
|
|
|
388
|
+ var myRow *domain.FailReturnedInfo
|
389
|
t := reflect.TypeOf(dividendsReturnedOrder)
|
389
|
t := reflect.TypeOf(dividendsReturnedOrder)
|
390
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
390
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
391
|
for k := 0; k < t.NumField(); k++ { // 列
|
391
|
for k := 0; k < t.NumField(); k++ { // 列
|
392
|
- r := strconv.Itoa(i + 1)
|
|
|
393
|
- col := strconv.Itoa(k + 1)
|
|
|
394
|
-
|
|
|
395
|
switch k {
|
392
|
switch k {
|
396
|
case 3: // 退货日期校验
|
393
|
case 3: // 退货日期校验
|
397
|
{
|
394
|
{
|
398
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
395
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
399
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
396
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
400
|
if !ok {
|
397
|
if !ok {
|
401
|
- var tmpRow []string
|
|
|
402
|
- tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货日期格式错误,请输入正确的退货日期") // 错误信息
|
|
|
403
|
- tmpRow = append(tmpRow, r) // 行号
|
|
|
404
|
- tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
398
|
+ var tmpRow *domain.FailReturnedInfo
|
|
|
399
|
+ tmpRow = &domain.FailReturnedInfo{
|
|
|
400
|
+ FailReason: "退货日期格式错误,请输入正确的退货日期",
|
|
|
401
|
+ ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
402
|
+ }
|
405
|
myRow = tmpRow
|
403
|
myRow = tmpRow
|
406
|
}
|
404
|
}
|
407
|
}
|
405
|
}
|
|
@@ -410,10 +408,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -410,10 +408,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
410
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
408
|
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
|
411
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
409
|
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
|
412
|
if !ok {
|
410
|
if !ok {
|
413
|
- var tmpRow []string
|
|
|
414
|
- tmpRow = append(tmpRow, "第"+r+"行第"+col+"列订单日期格式错误,请输入正确的订单日期") // 错误信息
|
|
|
415
|
- tmpRow = append(tmpRow, r) // 行号
|
|
|
416
|
- tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
411
|
+ var tmpRow *domain.FailReturnedInfo
|
|
|
412
|
+ tmpRow = &domain.FailReturnedInfo{
|
|
|
413
|
+ FailReason: "订单日期格式错误,请输入正确的订单日期",
|
|
|
414
|
+ ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
415
|
+ }
|
417
|
myRow = tmpRow
|
416
|
myRow = tmpRow
|
418
|
}
|
417
|
}
|
419
|
}
|
418
|
}
|
|
@@ -422,18 +421,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -422,18 +421,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
422
|
//参数类型转换
|
421
|
//参数类型转换
|
423
|
orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
|
422
|
orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
|
424
|
if err != nil {
|
423
|
if err != nil {
|
425
|
- var tmpRow []string
|
|
|
426
|
- tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量格式错误,退货数量必须整数") // 错误信息
|
|
|
427
|
- tmpRow = append(tmpRow, r) // 行号
|
|
|
428
|
- tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
424
|
+ var tmpRow *domain.FailReturnedInfo
|
|
|
425
|
+ tmpRow = &domain.FailReturnedInfo{
|
|
|
426
|
+ FailReason: "退货数量格式错误,退货数量必须整数",
|
|
|
427
|
+ ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
428
|
+ }
|
429
|
myRow = tmpRow
|
429
|
myRow = tmpRow
|
430
|
}
|
430
|
}
|
431
|
// 正负判断
|
431
|
// 正负判断
|
432
|
if orderGoodQuantity < 0 {
|
432
|
if orderGoodQuantity < 0 {
|
433
|
- var tmpRow []string
|
|
|
434
|
- tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量必须大于0,请重新填写") // 错误信息
|
|
|
435
|
- tmpRow = append(tmpRow, r) // 行号
|
|
|
436
|
- tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
433
|
+ var tmpRow *domain.FailReturnedInfo
|
|
|
434
|
+ tmpRow = &domain.FailReturnedInfo{
|
|
|
435
|
+ FailReason: "退货数量必须大于0,请重新填写",
|
|
|
436
|
+ ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
437
|
+ }
|
437
|
myRow = tmpRow
|
438
|
myRow = tmpRow
|
438
|
}
|
439
|
}
|
439
|
}
|
440
|
}
|
|
@@ -442,19 +443,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -442,19 +443,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
442
|
// 参数类型转换
|
443
|
// 参数类型转换
|
443
|
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
|
444
|
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
|
444
|
if typeErr != nil {
|
445
|
if typeErr != nil {
|
445
|
- var tmpRow []string
|
|
|
446
|
- tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格格式错误,退货价格必须为数字类型") // 错误信息
|
|
|
447
|
- tmpRow = append(tmpRow, r) // 行号
|
|
|
448
|
- tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
446
|
+ var tmpRow *domain.FailReturnedInfo
|
|
|
447
|
+ tmpRow = &domain.FailReturnedInfo{
|
|
|
448
|
+ FailReason: "退货价格格式错误,退货价格必须为数字类型",
|
|
|
449
|
+ ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
450
|
+ }
|
449
|
myRow = tmpRow
|
451
|
myRow = tmpRow
|
450
|
}
|
452
|
}
|
451
|
|
453
|
|
452
|
// 长度校验
|
454
|
// 长度校验
|
453
|
if univalent >= 1e16 {
|
455
|
if univalent >= 1e16 {
|
454
|
- var tmpRow []string
|
|
|
455
|
- tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
|
|
|
456
|
- tmpRow = append(tmpRow, r) // 行号
|
|
|
457
|
- tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
|
456
|
+ var tmpRow *domain.FailReturnedInfo
|
|
|
457
|
+ tmpRow = &domain.FailReturnedInfo{
|
|
|
458
|
+ FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数",
|
|
|
459
|
+ ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
460
|
+ }
|
458
|
myRow = tmpRow
|
461
|
myRow = tmpRow
|
459
|
}
|
462
|
}
|
460
|
}
|
463
|
}
|