ziwen il y a 1 an
Parent
commit
d323aa0eb8
1 fichiers modifiés avec 35 ajouts et 29 suppressions
  1. 35 29
      controller/contract/register.go

+ 35 - 29
controller/contract/register.go

@@ -421,8 +421,31 @@ func (rg *RegisterController) Add(c *gin.Context) {
 		for i := range sellerList {
 			sellerMap[sellerList[i].SellerId] = sellerList[i]
 		}
+		//处理重复公司名日期等重复的开票到款记录
+		dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate)
+		if e != nil {
+			err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
+			return
+		}
+		//先遍历一遍拿到开票销售信息
+		for _, ppItem := range dupList {
+			if ppItem.ContractRegisterId != req.ContractRegisterId {
+				j := 0
+				if ppItem.InvoiceType == 3 {
+					sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
+						SellerId:   ppItem.SellerId,
+						SellerName: ppItem.SellerName,
+						GroupId:    ppItem.SellerGroupId,
+						GroupName:  ppItem.SellerGroupName,
+						TeamId:     ppItem.SellerTeamId,
+						TeamName:   ppItem.SellerTeamName,
+					}
+					j++
+				}
+			}
+		}
 		for _, ppItem := range invoiceList {
-			j := 0
+			j,k := 0,0
 			v := &fms.ContractInvoice{
 				ContractRegisterId: ob.ContractRegisterId,
 				ContractCode:       ob.ContractCode,
@@ -444,7 +467,9 @@ func (rg *RegisterController) Add(c *gin.Context) {
 				StartDate:          ppItem.StartDate,
 				EndDate:            ppItem.EndDate,
 			}
+
 			if ppItem.InvoiceType == 3 {
+				v.InvoiceType = 1
 				sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
 					SellerId:   ppItem.SellerId,
 					SellerName: ppItem.SellerName,
@@ -454,13 +479,17 @@ func (rg *RegisterController) Add(c *gin.Context) {
 					TeamName:   ppItem.SellerTeamName,
 				}
 				j++
-			}
-
-
-			if ppItem.InvoiceType == 3 {
-				v.InvoiceType = 1
 			} else if ppItem.InvoiceType == 4 {
 				v.InvoiceType = 2
+				if sellerItem, ok := sellerItemMap[k]; ok {
+					v.SellerId = sellerItem.SellerId
+					v.SellerName = sellerItem.SellerName
+					v.SellerGroupId = sellerItem.GroupId
+					v.SellerGroupName = sellerItem.GroupName
+					v.SellerTeamId = sellerItem.TeamId
+					v.SellerTeamName = sellerItem.TeamName
+				}
+				k++
 			}
 			v.Set()
 			// 到款登记-付款方式
@@ -501,29 +530,6 @@ func (rg *RegisterController) Add(c *gin.Context) {
 			}
 		}
 
-		//处理重复公司名日期等重复的开票到款记录
-		dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate)
-		if e != nil {
-			err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
-			return
-		}
-		//先遍历一遍拿到开票销售信息
-		for _, ppItem := range dupList {
-			if ppItem.ContractRegisterId != req.ContractRegisterId {
-				j := 0
-				if ppItem.InvoiceType == 3 {
-					sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
-						SellerId:   ppItem.SellerId,
-						SellerName: ppItem.SellerName,
-						GroupId:    ppItem.SellerGroupId,
-						GroupName:  ppItem.SellerGroupName,
-						TeamId:     ppItem.SellerTeamId,
-						TeamName:   ppItem.SellerTeamName,
-					}
-					j++
-				}
-			}
-		}
 		for _, ppItem := range dupList {
 			if ppItem.ContractRegisterId != req.ContractRegisterId {
 				j := 0