作者 陈志颖

fix:修复共创合约编辑必填项问题

@@ -12,9 +12,9 @@ type UpdateCooperationContractCommand struct { @@ -12,9 +12,9 @@ type UpdateCooperationContractCommand struct {
12 // 共创合约id 12 // 共创合约id
13 CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"` 13 CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"`
14 // 共创合约描述 14 // 共创合约描述
15 - CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` 15 + CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription"`
16 // 共创项目编号 16 // 共创项目编号
17 - CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"` 17 + CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber"`
18 // 部门ID 18 // 部门ID
19 DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"` 19 DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"`
20 // 共创合约承接对象,1员工,2共创用户,3公开 20 // 共创合约承接对象,1员工,2共创用户,3公开
@@ -24,6 +24,8 @@ type OrderGoods struct { @@ -24,6 +24,8 @@ type OrderGoods struct {
24 CooperationContractNumber string `json:"cooperationContractNumber"` 24 CooperationContractNumber string `json:"cooperationContractNumber"`
25 // 订单产品费用 25 // 订单产品费用
26 OrderGoodExpense float64 `json:"orderGoodExpense"` 26 OrderGoodExpense float64 `json:"orderGoodExpense"`
  27 + //行号-错误信息返回
  28 + LineNumber int `json:"lineNumber"`
27 } 29 }
28 30
29 type CreateDividendsOrderCommand struct { 31 type CreateDividendsOrderCommand struct {
@@ -13,6 +13,7 @@ import ( @@ -13,6 +13,7 @@ import (
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
15 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 15 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
  16 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
16 "reflect" 17 "reflect"
17 "regexp" 18 "regexp"
18 "strconv" 19 "strconv"
@@ -308,7 +309,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -308,7 +309,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
308 rowCnt++ 309 rowCnt++
309 nullCell := make([]interface{}, 0) 310 nullCell := make([]interface{}, 0)
310 //var myRow []string 311 //var myRow []string
311 - var myRow interface{}  
312 t := reflect.TypeOf(dividendsOrder) 312 t := reflect.TypeOf(dividendsOrder)
313 v := reflect.ValueOf(dividendsOrder) 313 v := reflect.ValueOf(dividendsOrder)
314 for k := 0; k < t.NumField(); k++ { 314 for k := 0; k < t.NumField(); k++ {
@@ -322,19 +322,10 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -322,19 +322,10 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
322 } 322 }
323 } 323 }
324 if nullFlag { 324 if nullFlag {
325 - s := strconv.Itoa(i + 1)  
326 - myRow = map[string]interface{}{  
327 - "failReason": "第" + s + "行订单日期格式错误,请输入正确的订单日期",  
328 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
329 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
330 - "orderGoodName": dividendsOrder.OrderGoodName,  
331 - "orderTime": dividendsOrder.OrderTime,  
332 - "regionName": dividendsOrder.RegionName,  
333 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
334 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
335 - "expense": dividendsOrder.Expense,  
336 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 325 + myRow := &domain.FailInfo{
  326 + FailReason: "订单日期格式错误,请输入正确的订单日期",
337 } 327 }
  328 + myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i]
338 nullCellError = append(nullCellError, myRow) 329 nullCellError = append(nullCellError, myRow)
339 nullFlag = false 330 nullFlag = false
340 } 331 }
@@ -354,32 +345,22 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -354,32 +345,22 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
354 // 单元格类型校验 345 // 单元格类型校验
355 typeError := make([]interface{}, 0) 346 typeError := make([]interface{}, 0)
356 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { // 行 347 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { // 行
357 - var myRow interface{}  
358 - //var myRow []string 348 + var myRow []*domain.FailInfo
359 t := reflect.TypeOf(dividendsOrder) 349 t := reflect.TypeOf(dividendsOrder)
360 v := reflect.ValueOf(dividendsOrder) 350 v := reflect.ValueOf(dividendsOrder)
361 for k := 0; k < t.NumField(); k++ { // 列 351 for k := 0; k < t.NumField(); k++ { // 列
362 r := strconv.Itoa(i + 1) 352 r := strconv.Itoa(i + 1)
363 - //col := strconv.Itoa(k + 1)  
364 switch k { 353 switch k {
365 case 3: // 订单日期校验 354 case 3: // 订单日期校验
366 { 355 {
367 regexpStr := `(\d{4})/(\d{2})/(\d{2})` 356 regexpStr := `(\d{4})/(\d{2})/(\d{2})`
368 ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface())) 357 ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
369 if !ok { 358 if !ok {
370 - tmpRow := map[string]interface{}{  
371 - "failReason": "第" + r + "行订单日期格式错误,请输入正确的订单日期",  
372 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
373 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
374 - "orderGoodName": dividendsOrder.OrderGoodName,  
375 - "orderTime": dividendsOrder.OrderTime,  
376 - "regionName": dividendsOrder.RegionName,  
377 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
378 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
379 - "expense": dividendsOrder.Expense,  
380 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 359 + tmpRow := &domain.FailInfo{
  360 + FailReason: "订单日期格式错误,请输入正确的订单日期",
381 } 361 }
382 - myRow = tmpRow 362 + tmpRow.ImportDividendsOrderData = &dividendsOrder
  363 + myRow = append(myRow, tmpRow)
383 } 364 }
384 } 365 }
385 case 5: // 产品数量校验 366 case 5: // 产品数量校验
@@ -387,35 +368,19 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -387,35 +368,19 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
387 //参数类型转换 368 //参数类型转换
388 orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64) 369 orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
389 if err != nil { 370 if err != nil {
390 - tmpRow := map[string]interface{}{  
391 - "failReason": "第" + r + "行产品数量格式错误,产品数量必须整数",  
392 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
393 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
394 - "orderGoodName": dividendsOrder.OrderGoodName,  
395 - "orderTime": dividendsOrder.OrderTime,  
396 - "regionName": dividendsOrder.RegionName,  
397 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
398 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
399 - "expense": dividendsOrder.Expense,  
400 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 371 + tmpRow := &domain.FailInfo{
  372 + FailReason: "行产品数量格式错误,产品数量必须整数",
401 } 373 }
402 - myRow = tmpRow 374 + tmpRow.ImportDividendsOrderData = &dividendsOrder
  375 + myRow = append(myRow, tmpRow)
403 } 376 }
404 // 正负判断 377 // 正负判断
405 if orderGoodQuantity < 0 { 378 if orderGoodQuantity < 0 {
406 - tmpRow := map[string]interface{}{  
407 - "failReason": "第" + r + "行产品数量必须大于0,请重新填写",  
408 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
409 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
410 - "orderGoodName": dividendsOrder.OrderGoodName,  
411 - "orderTime": dividendsOrder.OrderTime,  
412 - "regionName": dividendsOrder.RegionName,  
413 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
414 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
415 - "expense": dividendsOrder.Expense,  
416 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 379 + tmpRow := &domain.FailInfo{
  380 + FailReason: "产品数量必须大于0,请重新填写",
417 } 381 }
418 - myRow = tmpRow 382 + tmpRow.ImportDividendsOrderData = &dividendsOrder
  383 + myRow = append(myRow, tmpRow)
419 } 384 }
420 } 385 }
421 case 6: // 产品价格校验 386 case 6: // 产品价格校验
@@ -423,37 +388,21 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -423,37 +388,21 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
423 // 参数类型转换 388 // 参数类型转换
424 univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64) 389 univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
425 if typeErr != nil { 390 if typeErr != nil {
426 - tmpRow := map[string]interface{}{  
427 - "failReason": "第" + r + "行产品价格格式错误,产品价格必须为数字类型",  
428 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
429 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
430 - "orderGoodName": dividendsOrder.OrderGoodName,  
431 - "orderTime": dividendsOrder.OrderTime,  
432 - "regionName": dividendsOrder.RegionName,  
433 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
434 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
435 - "expense": dividendsOrder.Expense,  
436 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 391 + tmpRow := &domain.FailInfo{
  392 + FailReason: "产品价格格式错误,产品价格必须为数字类型",
437 } 393 }
438 - myRow = tmpRow 394 + tmpRow.ImportDividendsOrderData = &dividendsOrder
  395 + myRow = append(myRow, tmpRow)
439 } 396 }
440 397
441 // 长度校验 398 // 长度校验
442 if univalent >= 1e16 { 399 if univalent >= 1e16 {
443 - tmpRow := map[string]interface{}{  
444 - "failReason": "第" + r + "行产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数",  
445 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
446 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
447 - "orderGoodName": dividendsOrder.OrderGoodName,  
448 - "orderTime": dividendsOrder.OrderTime,  
449 - "regionName": dividendsOrder.RegionName,  
450 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
451 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
452 - "expense": dividendsOrder.Expense,  
453 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 400 + tmpRow := &domain.FailInfo{
  401 + FailReason: "第" + r + "行产品价格超过最大限制,产品价格小数点前面不能超过十六位数字,并保留两位小数",
454 } 402 }
  403 + tmpRow.ImportDividendsOrderData = &dividendsOrder
455 // 错误行数据 404 // 错误行数据
456 - myRow = tmpRow 405 + myRow = append(myRow, tmpRow)
457 } 406 }
458 } 407 }
459 case 7: // 费用校验 408 case 7: // 费用校验
@@ -462,36 +411,22 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -462,36 +411,22 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
462 // 参数类型转换 411 // 参数类型转换
463 univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64) 412 univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
464 if typeErr != nil { 413 if typeErr != nil {
465 - tmpRow := map[string]interface{}{  
466 - "failReason": "第" + r + "行费用格式错误,费用必须为数字类型",  
467 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
468 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
469 - "orderGoodName": dividendsOrder.OrderGoodName,  
470 - "orderTime": dividendsOrder.OrderTime,  
471 - "regionName": dividendsOrder.RegionName,  
472 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
473 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
474 - "expense": dividendsOrder.Expense,  
475 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 414 + tmpRow := &domain.FailInfo{
  415 + FailReason: "第" + r + "行费用格式错误,费用必须为数字类型",
476 } 416 }
477 - myRow = tmpRow 417 + tmpRow.ImportDividendsOrderData = &dividendsOrder
  418 + myRow = append(myRow, tmpRow)
  419 + log.Logger.Info("费用类型错误", map[string]interface{}{
  420 + "tmpRow": tmpRow,
  421 + })
478 } 422 }
479 -  
480 // 长度校验 423 // 长度校验
481 if univalent >= 1e16 { 424 if univalent >= 1e16 {
482 - tmpRow := map[string]interface{}{  
483 - "failReason": "第" + r + "行费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数",  
484 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
485 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
486 - "orderGoodName": dividendsOrder.OrderGoodName,  
487 - "orderTime": dividendsOrder.OrderTime,  
488 - "regionName": dividendsOrder.RegionName,  
489 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
490 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
491 - "expense": dividendsOrder.Expense,  
492 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 425 + tmpRow := &domain.FailInfo{
  426 + FailReason: "第" + r + "行费用超过最大限制,费用小数点前面不能超过十六位数字,并保留两位小数",
493 } 427 }
494 - myRow = tmpRow 428 + tmpRow.ImportDividendsOrderData = &dividendsOrder
  429 + myRow = append(myRow, tmpRow)
495 } 430 }
496 } 431 }
497 } 432 }
@@ -524,19 +459,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -524,19 +459,11 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
524 // 订单日期时间格式转换 459 // 订单日期时间格式转换
525 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local) 460 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
526 if err != nil { 461 if err != nil {
527 - s := strconv.Itoa(i + 1)  
528 - tmpRow := map[string]interface{}{  
529 - "failReason": "第" + s + "行无效的订单日期",  
530 - "originalOrderNum": dividendsOrder.OriginalOrderNum,  
531 - "dividendsCustomerName": dividendsOrder.DividendsCustomerName,  
532 - "orderGoodName": dividendsOrder.OrderGoodName,  
533 - "orderTime": dividendsOrder.OrderTime,  
534 - "regionName": dividendsOrder.RegionName,  
535 - "orderGoodQuantity": dividendsOrder.OrderGoodQuantity,  
536 - "orderGoodPrice": dividendsOrder.OrderGoodPrice,  
537 - "expense": dividendsOrder.Expense,  
538 - "cooperationContractNumber": dividendsOrder.CooperationContractNumber, 462 + //s := strconv.Itoa(i + 1)
  463 + tmpRow := &domain.FailInfo{
  464 + FailReason: "无效的订单日期",
539 } 465 }
  466 + tmpRow.ImportDividendsOrderData = &dividendsOrder
540 aggregateErrorList = append(aggregateErrorList, tmpRow) 467 aggregateErrorList = append(aggregateErrorList, tmpRow)
541 break 468 break
542 } 469 }
@@ -659,36 +586,20 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -659,36 +586,20 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
659 for _, errorData := range errorDataList { 586 for _, errorData := range errorDataList {
660 if len(errorData.GoodLine) == 0 { // 订单错误 587 if len(errorData.GoodLine) == 0 { // 订单错误
661 for _, line := range errorData.LineNumbers { 588 for _, line := range errorData.LineNumbers {
662 - s := strconv.Itoa(line + 1)  
663 - tmpRow := map[string]interface{}{  
664 - "failReason": "第" + s + "行数据校验错误:" + errorData.Error.Error(),  
665 - "originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,  
666 - "dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,  
667 - "orderGoodName": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodName,  
668 - "orderTime": importDividendsOrderCommand.DividendsOrderData[line].OrderTime,  
669 - "regionName": importDividendsOrderCommand.DividendsOrderData[line].RegionName,  
670 - "orderGoodQuantity": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodQuantity,  
671 - "orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,  
672 - "expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,  
673 - "cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber, 589 + //s := strconv.Itoa(line + 1)
  590 + tmpRow := &domain.FailInfo{
  591 + FailReason: "数据校验错误:" + errorData.Error.Error(),
674 } 592 }
  593 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[line]
675 failureDataList = append(failureDataList, tmpRow) 594 failureDataList = append(failureDataList, tmpRow)
676 } 595 }
677 } else if len(errorData.GoodLine) > 0 { // 订单产品错误 596 } else if len(errorData.GoodLine) > 0 { // 订单产品错误
678 for line := range errorData.GoodLine { 597 for line := range errorData.GoodLine {
679 - s := strconv.Itoa(line + 1)  
680 - tmpRow := map[string]interface{}{  
681 - "failReason": "第" + s + "行订单产品信息错误:" + errorData.Error.Error(),  
682 - "originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,  
683 - "dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,  
684 - "orderGoodName": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodName,  
685 - "orderTime": importDividendsOrderCommand.DividendsOrderData[line].OrderTime,  
686 - "regionName": importDividendsOrderCommand.DividendsOrderData[line].RegionName,  
687 - "orderGoodQuantity": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodQuantity,  
688 - "orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,  
689 - "expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,  
690 - "cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber, 598 + //s := strconv.Itoa(line + 1)
  599 + tmpRow := &domain.FailInfo{
  600 + FailReason: "订单产品信息错误:" + errorData.Error.Error(),
691 } 601 }
  602 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[line]
692 failureDataList = append(failureDataList, tmpRow) 603 failureDataList = append(failureDataList, tmpRow)
693 } 604 }
694 } 605 }
@@ -736,15 +647,18 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -736,15 +647,18 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
736 // 新增订单产品 647 // 新增订单产品
737 var orderGoods []*domain.OrderGood 648 var orderGoods []*domain.OrderGood
738 var dividendsOrderAmount float64 649 var dividendsOrderAmount float64
739 - for _, orderGood := range dividendsOrder.OrderGoods { 650 + orderGoodErrMap := make(map[int]interface{}, 0)
  651 + for i, orderGood := range dividendsOrder.OrderGoods {
740 // 校验共创合约是否合法 652 // 校验共创合约是否合法
741 - contractNumberExist, _ := cooperationContractDao.CheckContractNumberExist(map[string]interface{}{  
742 - "companyId": importDividendsOrderCommand.CompanyId,  
743 - "orgId": importDividendsOrderCommand.OrgId,  
744 - "cooperationContractNumber": orderGood.CooperationContractNumber,  
745 - })  
746 - if !contractNumberExist {  
747 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创合约编号不存在") 653 + if orderGood.CooperationContractNumber != "" {
  654 + contractNumberExist, _ := cooperationContractDao.CheckContractNumberExist(map[string]interface{}{
  655 + "companyId": importDividendsOrderCommand.CompanyId,
  656 + "orgId": importDividendsOrderCommand.OrgId,
  657 + "cooperationContractNumber": orderGood.CooperationContractNumber,
  658 + })
  659 + if !contractNumberExist {
  660 + orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("共创合约编号不存在:%s", err))
  661 + }
748 } 662 }
749 663
750 orderGoods = append(orderGoods, &domain.OrderGood{ 664 orderGoods = append(orderGoods, &domain.OrderGood{
@@ -767,6 +681,15 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -767,6 +681,15 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
767 // 计算分红订单金额 681 // 计算分红订单金额
768 dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount 682 dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
769 } 683 }
  684 + if len(orderGoodErrMap) > 0 {
  685 + row := &domain.ImportInfo{
  686 + Error: application.ThrowError(application.BUSINESS_ERROR, "共创合约不存在"),
  687 + LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
  688 + GoodLine: orderGoodErrMap, // 错误产品行号记录
  689 + }
  690 + errorDataList = append(errorDataList, row)
  691 + continue
  692 + }
770 693
771 // 订单时间转换 694 // 订单时间转换
772 orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64) 695 orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
@@ -817,7 +740,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -817,7 +740,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
817 } 740 }
818 741
819 // 错误报告处理 742 // 错误报告处理
820 - if len(errorDataList) <= 0 { 743 + if len(errorDataList) <= 0 { // 成功返回
821 if err3 := transactionContext.CommitTransaction(); err3 != nil { 744 if err3 := transactionContext.CommitTransaction(); err3 != nil {
822 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) 745 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
823 } 746 }
@@ -825,45 +748,29 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -825,45 +748,29 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
825 if successDataCount == int64(rowCnt) { 748 if successDataCount == int64(rowCnt) {
826 return map[string]interface{}{ 749 return map[string]interface{}{
827 "successCount": successDataCount, 750 "successCount": successDataCount,
828 - "fail": nil, 751 + "fail": map[string]interface{}{},
829 }, nil 752 }, nil
830 } 753 }
831 - } else { 754 + } else { // 失败返回
832 successDataCount = 0 755 successDataCount = 0
833 // 错误记录处理 756 // 错误记录处理
834 for _, errorData := range errorDataList { 757 for _, errorData := range errorDataList {
835 if len(errorData.GoodLine) == 0 { // 订单错误 758 if len(errorData.GoodLine) == 0 { // 订单错误
836 for _, line := range errorData.LineNumbers { 759 for _, line := range errorData.LineNumbers {
837 - s := strconv.Itoa(line + 1)  
838 - tmpRow := map[string]interface{}{  
839 - "failReason": "第" + s + "行订单数据新增错误:" + errorData.Error.Error(),  
840 - "originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,  
841 - "dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,  
842 - "orderGoodName": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodName,  
843 - "orderTime": importDividendsOrderCommand.DividendsOrderData[line].OrderTime,  
844 - "regionName": importDividendsOrderCommand.DividendsOrderData[line].RegionName,  
845 - "orderGoodQuantity": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodQuantity,  
846 - "orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,  
847 - "expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,  
848 - "cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber, 760 + //s := strconv.Itoa(line + 1)
  761 + tmpRow := &domain.FailInfo{
  762 + FailReason: "订单数据新增错误:" + errorData.Error.Error(),
849 } 763 }
  764 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[line]
850 failureDataList = append(failureDataList, tmpRow) 765 failureDataList = append(failureDataList, tmpRow)
851 } 766 }
852 } else if len(errorData.GoodLine) > 0 { // 订单产品错误 767 } else if len(errorData.GoodLine) > 0 { // 订单产品错误
853 for line := range errorData.GoodLine { 768 for line := range errorData.GoodLine {
854 - s := strconv.Itoa(line + 1)  
855 - tmpRow := map[string]interface{}{  
856 - "failReason": "第" + s + "行订单数据新增错误:" + errorData.Error.Error(),  
857 - "originalOrderNum": importDividendsOrderCommand.DividendsOrderData[line].OriginalOrderNum,  
858 - "dividendsCustomerName": importDividendsOrderCommand.DividendsOrderData[line].DividendsCustomerName,  
859 - "orderGoodName": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodName,  
860 - "orderTime": importDividendsOrderCommand.DividendsOrderData[line].OrderTime,  
861 - "regionName": importDividendsOrderCommand.DividendsOrderData[line].RegionName,  
862 - "orderGoodQuantity": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodQuantity,  
863 - "orderGoodPrice": importDividendsOrderCommand.DividendsOrderData[line].OrderGoodPrice,  
864 - "expense": importDividendsOrderCommand.DividendsOrderData[line].Expense,  
865 - "cooperationContractNumber": importDividendsOrderCommand.DividendsOrderData[line].CooperationContractNumber, 769 + //s := strconv.Itoa(line + 1)
  770 + tmpRow := &domain.FailInfo{
  771 + FailReason: "订单数据新增错误:" + errorData.Error.Error(),
866 } 772 }
  773 + tmpRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[line]
867 failureDataList = append(failureDataList, tmpRow) 774 failureDataList = append(failureDataList, tmpRow)
868 } 775 }
869 } 776 }
1 package domain 1 package domain
2 2
3 import ( 3 import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
4 "time" 5 "time"
5 ) 6 )
6 7
@@ -52,9 +53,24 @@ type DividendsOrder struct { @@ -52,9 +53,24 @@ type DividendsOrder struct {
52 53
53 // ImportInfo 导入错误信息 54 // ImportInfo 导入错误信息
54 type ImportInfo struct { 55 type ImportInfo struct {
55 - Error error  
56 - LineNumbers []int  
57 - GoodLine map[int]interface{} 56 + Error error `json:"error"`
  57 + LineNumbers []int `json:"lineNumbers"`
  58 + GoodLine map[int]interface{} `json:"goodLine"`
  59 +}
  60 +
  61 +// FailInfo 返回的失败信息
  62 +type FailInfo struct {
  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
58 } 74 }
59 75
60 type DividendsOrderRepository interface { 76 type DividendsOrderRepository interface {
@@ -255,6 +255,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -255,6 +255,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
255 if offsetLimitFlag { 255 if offsetLimitFlag {
256 query.SetOffsetAndLimit(20) 256 query.SetOffsetAndLimit(20)
257 } 257 }
  258 + query.Where("is_canceled = ?", false)
258 query.SetOrderDirect("cooperation_application_id", "DESC") 259 query.SetOrderDirect("cooperation_application_id", "DESC")
259 if count, err := query.SelectAndCount(); err != nil { 260 if count, err := query.SelectAndCount(); err != nil {
260 return 0, cooperationApplications, err 261 return 0, cooperationApplications, err