作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
@@ -297,7 +297,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -297,7 +297,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
297 } 297 }
298 298
299 // 必填项校验 299 // 必填项校验
300 - nullCellError := make([]interface{}, 0) 300 + nullCellError := make([]*domain.FailInfo, 0)
301 301
302 // 数据行计数 302 // 数据行计数
303 rowCnt := 0 303 rowCnt := 0
@@ -308,7 +308,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -308,7 +308,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
308 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { 308 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
309 rowCnt++ 309 rowCnt++
310 nullCell := make([]interface{}, 0) 310 nullCell := make([]interface{}, 0)
311 - //var myRow []string  
312 t := reflect.TypeOf(dividendsOrder) 311 t := reflect.TypeOf(dividendsOrder)
313 v := reflect.ValueOf(dividendsOrder) 312 v := reflect.ValueOf(dividendsOrder)
314 for k := 0; k < t.NumField(); k++ { 313 for k := 0; k < t.NumField(); k++ {
@@ -323,7 +322,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -323,7 +322,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
323 } 322 }
324 if nullFlag { 323 if nullFlag {
325 myRow := &domain.FailInfo{ 324 myRow := &domain.FailInfo{
326 - FailReason: "订单日期格式错误,请输入正确的订单日期", 325 + FailReason: "必填项为空",
327 } 326 }
328 myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i] 327 myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i]
329 nullCellError = append(nullCellError, myRow) 328 nullCellError = append(nullCellError, myRow)
@@ -459,7 +458,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -459,7 +458,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
459 // 订单日期时间格式转换 458 // 订单日期时间格式转换
460 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local) 459 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
461 if err != nil { 460 if err != nil {
462 - //s := strconv.Itoa(i + 1)  
463 tmpRow := &domain.FailInfo{ 461 tmpRow := &domain.FailInfo{
464 FailReason: "无效的订单日期", 462 FailReason: "无效的订单日期",
465 } 463 }
@@ -477,9 +475,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -477,9 +475,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
477 if err != nil { 475 if err != nil {
478 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 476 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
479 } 477 }
480 - expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)  
481 - if err != nil { 478 + var expense float64
  479 + if dividendsOrder.Expense != "" {
  480 + if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
482 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 481 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  482 + } else {
  483 + expense = expenseParse
  484 + }
483 } 485 }
484 486
485 // 初始化新建分红订单命令集 487 // 初始化新建分红订单命令集
@@ -518,9 +520,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -518,9 +520,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
518 if err != nil { 520 if err != nil {
519 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 521 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
520 } 522 }
521 - expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)  
522 - if err != nil { 523 + var expense float64
  524 + if dividendsOrder.Expense != "" {
  525 + if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
523 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 526 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  527 + } else {
  528 + expense = expenseParse
  529 + }
524 } 530 }
525 531
526 dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{ 532 dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{
@@ -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: &dividendsReturnedOrder,
  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: &dividendsReturnedOrder,
  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: &dividendsReturnedOrder,
  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: &dividendsReturnedOrder,
  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: &dividendsReturnedOrder,
  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: &dividendsReturnedOrder,
  460 + }
458 myRow = tmpRow 461 myRow = tmpRow
459 } 462 }
460 } 463 }
@@ -61,15 +61,6 @@ type ImportInfo struct { @@ -61,15 +61,6 @@ type ImportInfo struct {
61 // FailInfo 返回的失败信息 61 // FailInfo 返回的失败信息
62 type FailInfo struct { 62 type FailInfo struct {
63 FailReason string `json:"failReason"` 63 FailReason string `json:"failReason"`
64 - //OriginalOrderNum string `json:"originalOrderNum"`  
65 - //DividendsCustomerName string `json:"dividendsCustomerName"`  
66 - //OrderGoodName string `json:"orderGoodName"`  
67 - //OrderTime string `json:"orderTime"`  
68 - //RegionName string `json:"regionName"`  
69 - //OrderGoodQuantity string `json:"orderGoodQuantity"`  
70 - //OrderGoodPrice string `json:"orderGoodPrice"`  
71 - //Expense string `json:"expense"`  
72 - //CooperationContractNumber string `json:"cooperationContractNumber"`  
73 *command.ImportDividendsOrderData 64 *command.ImportDividendsOrderData
74 } 65 }
75 66
1 package domain 1 package domain
2 2
3 -import "time" 3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command"
  5 + "time"
  6 +)
4 7
5 // DividendsReturnedOrder 分红退货单实体 8 // DividendsReturnedOrder 分红退货单实体
6 type DividendsReturnedOrder struct { 9 type DividendsReturnedOrder struct {
@@ -46,6 +49,12 @@ type DividendsReturnedOrder struct { @@ -46,6 +49,12 @@ type DividendsReturnedOrder struct {
46 OperateTime time.Time `json:"operateTime"` 49 OperateTime time.Time `json:"operateTime"`
47 } 50 }
48 51
  52 +// FailReturnedInfo 返回的失败信息
  53 +type FailReturnedInfo struct {
  54 + FailReason string `json:"failReason"`
  55 + *command.ImportDividendsReturnedOrderData
  56 +}
  57 +
49 type DividendsReturnedOrderRepository interface { 58 type DividendsReturnedOrderRepository interface {
50 Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error) 59 Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
51 UpdateMany(dividendsReturnedOrder []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error) 60 UpdateMany(dividendsReturnedOrder []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)