|
@@ -412,15 +412,15 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -412,15 +412,15 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
412
|
// 返回信息表头定义
|
412
|
// 返回信息表头定义
|
413
|
var tableHeader = map[string]interface{}{
|
413
|
var tableHeader = map[string]interface{}{
|
414
|
"failReason": "错误详情",
|
414
|
"failReason": "错误详情",
|
415
|
- "originalOrderNum": "来源单号",
|
|
|
416
|
- "dividendsReturnedCustomerName": "客户名称",
|
|
|
417
|
- "orderGoodName": "产品名称",
|
|
|
418
|
- "dividendsReturnedDate": "退货日期",
|
|
|
419
|
- "regionName": "订单日期",
|
|
|
420
|
- "orderGoodPrice": "订单区域",
|
|
|
421
|
- "orderGoodQuantity": "退货数量",
|
|
|
422
|
- "cooperationContractNumber": "退货价格",
|
|
|
423
|
- "orderTime": "项目合约编号",
|
415
|
+ "originalOrderNum": "来源单号", // 0
|
|
|
416
|
+ "dividendsReturnedCustomerName": "客户名称", // 1
|
|
|
417
|
+ "orderGoodName": "产品名称", // 2
|
|
|
418
|
+ "dividendsReturnedDate": "退货日期", // 3
|
|
|
419
|
+ "orderTime": "订单日期", // 4
|
|
|
420
|
+ "regionName": "订单区域", // 5
|
|
|
421
|
+ "orderGoodQuantity": "退货数量", // 6
|
|
|
422
|
+ "orderGoodPrice": "退货价格", // 7
|
|
|
423
|
+ "cooperationContractNumber": "项目合约编号", // 8
|
424
|
}
|
424
|
}
|
425
|
|
425
|
|
426
|
/***************************************************** 空文件校验 ***************************************************/
|
426
|
/***************************************************** 空文件校验 ***************************************************/
|
|
@@ -446,7 +446,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -446,7 +446,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
446
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
446
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
447
|
for k := 0; k < t.NumField(); k++ {
|
447
|
for k := 0; k < t.NumField(); k++ {
|
448
|
fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
|
448
|
fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
|
449
|
- if t.Field(k).Name != "RegionName" && t.Field(k).Name != "CooperationContractNumber" {
|
449
|
+ if t.Field(k).Name != "RegionName" {
|
450
|
if v.Field(k).Interface() == "" {
|
450
|
if v.Field(k).Interface() == "" {
|
451
|
col := strconv.Itoa(k + 1)
|
451
|
col := strconv.Itoa(k + 1)
|
452
|
nullCell = append(nullCell, col)
|
452
|
nullCell = append(nullCell, col)
|
|
@@ -581,10 +581,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -581,10 +581,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
581
|
var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
|
581
|
var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
|
582
|
|
582
|
|
583
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
|
583
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
|
584
|
- hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum))
|
584
|
+ hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.OrderTime))
|
585
|
hashString := hex.EncodeToString(hashValue[:])
|
585
|
hashString := hex.EncodeToString(hashValue[:])
|
586
|
if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
|
586
|
if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
|
587
|
-
|
|
|
588
|
// 订单日期时间格式转换
|
587
|
// 订单日期时间格式转换
|
589
|
timeValue, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.OrderTime, time.Local)
|
588
|
timeValue, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.OrderTime, time.Local)
|
590
|
if err != nil {
|
589
|
if err != nil {
|
|
@@ -600,7 +599,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -600,7 +599,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
600
|
timeValue2, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.DividendsReturnedDate, time.Local)
|
599
|
timeValue2, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.DividendsReturnedDate, time.Local)
|
601
|
if err != nil {
|
600
|
if err != nil {
|
602
|
tmpRow := &domain.FailReturnedInfo{
|
601
|
tmpRow := &domain.FailReturnedInfo{
|
603
|
- FailReason: "无效的订单日期",
|
602
|
+ FailReason: "无效的退货日期",
|
604
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
603
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
605
|
}
|
604
|
}
|
606
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
605
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
|
@@ -617,6 +616,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -617,6 +616,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
617
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
616
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
618
|
continue
|
617
|
continue
|
619
|
}
|
618
|
}
|
|
|
619
|
+
|
620
|
price, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodPrice, 64)
|
620
|
price, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodPrice, 64)
|
621
|
if err != nil {
|
621
|
if err != nil {
|
622
|
tmpRow := &domain.FailReturnedInfo{
|
622
|
tmpRow := &domain.FailReturnedInfo{
|
|
@@ -666,6 +666,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -666,6 +666,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
666
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
666
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
667
|
continue
|
667
|
continue
|
668
|
}
|
668
|
}
|
|
|
669
|
+
|
669
|
price, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodPrice, 64)
|
670
|
price, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodPrice, 64)
|
670
|
if err != nil {
|
671
|
if err != nil {
|
671
|
tmpRow := &domain.FailReturnedInfo{
|
672
|
tmpRow := &domain.FailReturnedInfo{
|
|
@@ -782,14 +783,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -782,14 +783,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
782
|
|
783
|
|
783
|
// 批量导入创建退货单
|
784
|
// 批量导入创建退货单
|
784
|
for i, dividendsReturnedOrder := range createDividendsReturnedOrderCommands {
|
785
|
for i, dividendsReturnedOrder := range createDividendsReturnedOrderCommands {
|
785
|
- // 生成退货订单号
|
|
|
786
|
- //dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber(map[string]interface{}{
|
|
|
787
|
- // "companyId": importDividendsReturnedOrderCommand.CompanyId,
|
|
|
788
|
- //})
|
|
|
789
|
- //if err != nil {
|
|
|
790
|
- // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
791
|
- //}
|
|
|
792
|
-
|
|
|
793
|
// 生成分红订单号
|
786
|
// 生成分红订单号
|
794
|
dividendsReturnedOrderNumber, err := dividendsReturnedOrder.GenerateSpecificDividendsReturnedOrderNumber(int64(count), time.Time{}, int64(i))
|
787
|
dividendsReturnedOrderNumber, err := dividendsReturnedOrder.GenerateSpecificDividendsReturnedOrderNumber(int64(count), time.Time{}, int64(i))
|
795
|
if err != nil {
|
788
|
if err != nil {
|
|
@@ -831,16 +824,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -831,16 +824,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
831
|
returnedTime := utils.TransformTimestampToTime(returnedTimeInt)
|
824
|
returnedTime := utils.TransformTimestampToTime(returnedTimeInt)
|
832
|
|
825
|
|
833
|
// 校验退货订单编号是否唯一
|
826
|
// 校验退货订单编号是否唯一
|
834
|
- numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
|
|
|
835
|
- "companyId": importDividendsReturnedOrderCommand.CompanyId,
|
|
|
836
|
- "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
|
|
|
837
|
- })
|
|
|
838
|
- if err3 != nil {
|
|
|
839
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
|
|
840
|
- }
|
|
|
841
|
- if !numberAvailable {
|
|
|
842
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
843
|
- }
|
827
|
+ //numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
|
|
|
828
|
+ // "companyId": importDividendsReturnedOrderCommand.CompanyId,
|
|
|
829
|
+ // "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
|
|
|
830
|
+ //})
|
|
|
831
|
+ //if err3 != nil {
|
|
|
832
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
|
|
833
|
+ //}
|
|
|
834
|
+ //if !numberAvailable {
|
|
|
835
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
836
|
+ //}
|
844
|
|
837
|
|
845
|
// 新增订单产品
|
838
|
// 新增订单产品
|
846
|
var orderGoods []*domain.OrderGood
|
839
|
var orderGoods []*domain.OrderGood
|
|
@@ -856,7 +849,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -856,7 +849,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
856
|
}
|
849
|
}
|
857
|
}
|
850
|
}
|
858
|
if !contractNumberExist {
|
851
|
if !contractNumberExist {
|
859
|
- orderGoodErrMap[dividendsReturnedOrder.OrderGoods[j].LineNumber] = "订单产品关联的共创合约不存在"
|
852
|
+ orderGoodErrMap[dividendsReturnedOrder.OrderGoods[j].LineNumber] = "退货单产品关联的共创合约不存在"
|
860
|
continue
|
853
|
continue
|
861
|
}
|
854
|
}
|
862
|
|
855
|
|
|
@@ -909,8 +902,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
@@ -909,8 +902,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
909
|
UpdatedAt: time.Time{},
|
902
|
UpdatedAt: time.Time{},
|
910
|
})
|
903
|
})
|
911
|
|
904
|
|
912
|
- // 计算分红订单金额
|
|
|
913
|
- dividendsReturnedOrderAmount = dividendsReturnedOrderAmount + orderGood.OrderGoodAmount
|
905
|
+ // 计算分红退货单金额
|
|
|
906
|
+ dividendsReturnedOrderAmount, _ = decimal.NewFromFloat(dividendsReturnedOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity))).Float64()
|
|
|
907
|
+ //dividendsReturnedOrderAmount + orderGood.OrderGoodAmount
|
914
|
}
|
908
|
}
|
915
|
|
909
|
|
916
|
if len(orderGoodErrMap) > 0 {
|
910
|
if len(orderGoodErrMap) > 0 {
|