ziwen 2 жил өмнө
parent
commit
7546feea02

+ 33 - 16
controller/contract/pre_register.go

@@ -146,7 +146,7 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
 	}
 
 	var currencyUnit string
-	if len(req.List) > 0{
+	if len(req.List) > 0 {
 		currencyUnit = req.List[0].CurrencyUnit
 	}
 	// 获取销售分组信息
@@ -385,11 +385,10 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 	}
 
 	var currencyUnit string
-	if len(req.List) > 0{
+	if len(req.List) > 0 {
 		currencyUnit = req.List[0].CurrencyUnit
 	}
 
-
 	// 获取销售分组信息
 	sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
 	if e != nil {
@@ -456,7 +455,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 	}
 	updateCols := []string{
 		"ProductIds", "CompanyName", "SellerId", "SellerName", "StartDate", "EndDate",
-		"RaiSellerId", "RaiSellerName", "ModifyTime","CurrencyUnit",
+		"RaiSellerId", "RaiSellerName", "ModifyTime", "CurrencyUnit",
 	}
 
 	invoiceList := make([]*fms.ContractInvoice, 0)
@@ -551,6 +550,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 				return
 			}
 
+			pp.InvoiceId = v.ContractInvoiceId
 			pp.SellerId = sellerItem.SellerId
 			pp.SellerName = sellerItem.SellerName
 			pp.SellerGroupId = sellerItem.GroupId
@@ -558,15 +558,16 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 			pp.SellerTeamId = sellerItem.TeamId
 			pp.SellerTeamName = sellerItem.TeamName
 			ppUpdateCols = append(ppUpdateCols, "InvoiceDate", "Amount", "OriginAmount", "SellerId",
-				"SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName")
+				"SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName", "InvoiceId")
 		} else {
 			//到款
 			pp.ArriveRemark = r.Remark
 			pp.ArriveDate = registerDate
+			pp.ArriveId = v.ContractRegisterId
 			pp.ArriveOriginAmount = r.Amount
 			a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.ArriveOriginAmount/rate), 64)
 			pp.ArriveAmount = a
-			ppUpdateCols = append(ppUpdateCols, "CurrencyUnit", "ArriveDate", "ArriveAmount", "ArriveOriginAmount")
+			ppUpdateCols = append(ppUpdateCols, "CurrencyUnit", "ArriveDate", "ArriveAmount", "ArriveOriginAmount", "ArriveId")
 		}
 
 		if pp.PreRegisterId == 0 {
@@ -577,7 +578,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 			v.PreRegisterId = pp.PreRegisterId
 		} else {
 			ppUpdateCols = append(ppUpdateCols,
-				"CurrencyUnit", "CompanyName", "Remark", "ArriveRemark","InvoiceTime","ArriveTime",
+				"CurrencyUnit", "CompanyName", "Remark", "ArriveRemark", "InvoiceTime", "ArriveTime",
 				"ServiceProductId", "CurrencyUnit", "StartDate", "EndDate", "ModifyTime")
 			if e = pp.Update(ppUpdateCols); e != nil {
 				resp.FailMsg("操作失败", "更新预登记记录失败, Err: "+e.Error(), c)
@@ -747,9 +748,23 @@ func (rg *PreRegisterController) Detail(c *gin.Context) {
 	if nItme.EndDate == "0001-01-01" {
 		nItme.EndDate = ""
 	}
-	cond := `contract_register_id = ? AND invoice_type = ? `
+
+	cond := ``
 	pars := make([]interface{}, 0)
-	pars = append(pars, req.ContractRegisterId, req.InvoiceType)
+
+	if req.InvoiceId == 0 && req.ArriveId == 0 {
+		cond = `contract_register_id = ? AND invoice_type = ? `
+		pars = append(pars, req.ContractRegisterId, req.InvoiceType)
+	} else {
+		cond = `contract_register_id = ? AND invoice_type = ?  AND contract_invoice_id =? `
+		pars = append(pars, req.ContractRegisterId, req.InvoiceType)
+	}
+
+	if req.InvoiceType == 4 {
+		pars = append(pars, req.ArriveId)
+	} else {
+		pars = append(pars, req.InvoiceId)
+	}
 	list, e := fms.GetContractInvoiceDetailItemList(cond, pars)
 	if e != nil {
 		err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
@@ -946,6 +961,7 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
 	invoiceUpdateCols := make([]string, 0)
 	invoiceHandleType := 0
 	invoiceList := make([]*fms.ContractInvoice, 0)
+	ppList := make([]*fms.ContractPreRegister, 0)
 	for _, r := range req.List {
 		// 货币及汇率
 		rateList, e := fmsService.GetTodayCurrencyRateList()
@@ -1024,7 +1040,7 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
 		//预登记列表
 		ppUpdateCols := make([]string, 0)
 		pp := &fms.ContractPreRegister{
-			PreRegisterId:      req.PreRegisterId,
+			PreRegisterId:      r.PreRegisterId,
 			ContractRegisterId: ob.ContractRegisterId,
 			CompanyName:        req.CompanyName,
 			InvoiceType:        req.RegisterType,
@@ -1042,7 +1058,6 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
 		if pp.InvoiceType == fms.ContractInvoiceTypePreMake {
 			//开票走开票字段
 			pp.Remark = r.Remark
-			pp.InvoiceId = v.ContractInvoiceId
 			pp.InvoiceDate = registerDate
 			pp.OriginAmount = r.Amount
 			a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.OriginAmount/rate), 64)
@@ -1061,7 +1076,7 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
 			pp.SellerTeamId = sellerItem.TeamId
 			pp.SellerTeamName = sellerItem.TeamName
 			ppUpdateCols = append(ppUpdateCols, "InvoiceDate", "Amount", "OriginAmount", "SellerId",
-				"SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName")
+				"SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName", "Remark")
 		} else {
 			//到款
 			pp.ArriveRemark = r.Remark
@@ -1069,18 +1084,20 @@ func (rg *PreRegisterController) Save(c *gin.Context) {
 			pp.ArriveOriginAmount = r.Amount
 			a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.ArriveOriginAmount/rate), 64)
 			pp.ArriveAmount = a
-			ppUpdateCols = append(ppUpdateCols, "CurrencyUnit", "ArriveDate", "ArriveAmount", "ArriveOriginAmount")
+			ppUpdateCols = append(ppUpdateCols, "ArriveRemark", "CurrencyUnit", "ArriveDate", "ArriveAmount", "ArriveOriginAmount")
 		}
 
 		ppUpdateCols = append(ppUpdateCols,
-			"CompanyName", "AdminId", "AdminName", "Remark",
-			"ServiceProductId", "CurrencyUnit", "StartDate", "EndDate", "ModifyTime")
+			"CompanyName", "AdminId", "AdminName", "ServiceProductId",
+			"CurrencyUnit", "StartDate", "EndDate", "ModifyTime")
+
 		if e = pp.Update(ppUpdateCols); e != nil {
 			resp.FailMsg("操作失败", "更新预登记记录失败, Err: "+e.Error(), c)
 			return
 		}
+		ppList = append(ppList, pp)
 	}
-	if e = fms.UpdateContractRegisterPre(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols, invoiceHandleType); e != nil {
+	if e = fms.UpdateContractRegisterPre(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols, invoiceHandleType, ppList); e != nil {
 		resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
 		return
 	}

+ 157 - 99
controller/contract/register.go

@@ -72,7 +72,7 @@ func (rg *RegisterController) List(c *gin.Context) {
 		for _, v := range typeSlices {
 			if v[:1] == "0" {
 				//自付
-				if v[1:] == "1"{
+				if v[1:] == "1" {
 					newCond += ` (contract_type = 1 AND has_payment=0) `
 				} else if v[1:] == "2" {
 					newCond += ` (contract_type = 2 AND has_payment=0) `
@@ -81,7 +81,7 @@ func (rg *RegisterController) List(c *gin.Context) {
 				}
 			} else {
 				//代付
-				if v[1:] == "1"{
+				if v[1:] == "1" {
 					newCond += ` (contract_type = 1 AND has_payment=1) `
 				} else if v[1:] == "2" {
 					newCond += ` (contract_type = 2 AND has_payment=1) `
@@ -92,7 +92,7 @@ func (rg *RegisterController) List(c *gin.Context) {
 			newCond += " OR "
 		}
 		newCond = strings.TrimRight(newCond, "OR ")
-		cond += " AND " + "(" +newCond + ")"
+		cond += " AND " + "(" + newCond + ")"
 	}
 	if req.RegisterStatus != 0 {
 		cond += ` AND register_status = ?`
@@ -1309,7 +1309,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
 		for _, v := range typeSlices {
 			if v[:1] == "0" {
 				//自付
-				if v[1:] == "1"{
+				if v[1:] == "1" {
 					newCond += ` (contract_type = 1 AND has_payment=0) `
 				} else if v[1:] == "2" {
 					newCond += ` (contract_type = 2 AND has_payment=0) `
@@ -1318,7 +1318,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
 				}
 			} else {
 				//代付
-				if v[1:] == "1"{
+				if v[1:] == "1" {
 					newCond += ` (contract_type = 1 AND has_payment=1) `
 				} else if v[1:] == "2" {
 					newCond += ` (contract_type = 2 AND has_payment=1) `
@@ -1329,7 +1329,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
 			newCond += " OR "
 		}
 		newCond = strings.TrimRight(newCond, "OR ")
-		cond += " AND " + "(" +newCond + ")"
+		cond += " AND " + "(" + newCond + ")"
 	}
 	if req.RegisterStatus != 0 {
 		cond += ` AND register_status = ?`
@@ -1550,25 +1550,41 @@ func (rg *RegisterController) Export(c *gin.Context) {
 	titleRow.SetHeight(40)
 	// 1行1列-右合并两格, 下合并1行
 	cell1 := titleRow.AddCell()
-	cell1.HMerge = 4
+	if req.ListParam == 0 {
+		cell1.HMerge = 8
+	} else {
+		cell1.HMerge = 7
+	}
+
 	cell1.VMerge = 1
-	cell1.SetString("FICC客户签约表")
+	cell1.SetString("客户签约表")
 	cell1.SetStyle(style)
 	// 右增两列空白格用于第一列合并, 否则后续单元格合并会有问题
 	titleRow.AddCell().SetString("")
 	titleRow.AddCell().SetString("")
 	titleRow.AddCell().SetString("")
 	titleRow.AddCell().SetString("")
-	hInt += 5
+	titleRow.AddCell().SetString("")
+	titleRow.AddCell().SetString("")
+	titleRow.AddCell().SetString("")
+	hInt += 8
 
+	if req.ListParam == 0 {
+		//如果是全部的话要多一格
+		titleRow.AddCell().SetString("")
+		hInt += 1
+	}
 	// 1行2列
-	cell2 := titleRow.AddCell()
-	cell2.VMerge = 1
-	cell2.SetString("FICC大套餐")
-	cell2.SetStyle(style)
-	hInt++
+	if req.ListParam != 2 {
+		cell2 := titleRow.AddCell()
+		cell2.VMerge = 1
+		cell2.SetString("FICC大套餐")
+		cell2.SetStyle(style)
+		hInt++
+	}
+
 	// 1行3列-右合并小套餐数
-	if permissionLen >= 1 {
+	if permissionLen >= 1 && req.ListParam != 2 {
 		cell3 := titleRow.AddCell()
 		hInt++
 		cell3.HMerge = permissionLen - 1
@@ -1581,36 +1597,41 @@ func (rg *RegisterController) Export(c *gin.Context) {
 			hInt++
 		}
 	}
-	for i := range otherService {
-		cellOther := titleRow.AddCell()
-		cellOther.VMerge = 1
-		hInt++
-		cellOther.SetString(otherService[i].Title)
-		cellOther.SetStyle(style)
-	}
-
-	//权益大套餐
-	cell4 := titleRow.AddCell()
-	cell4.HMerge = 1
-	cell4.VMerge = 1
-	cell4.SetString("权益大套餐")
-	cell4.SetStyle(style)
-	titleRow.AddCell().SetString("")
-	hInt += 2
 
-	//权益分行业套餐
-	cell5 := titleRow.AddCell()
-	cell5.HMerge = 8
-	cell5.SetString("权益分行业套餐")
-	cell5.SetStyle(style)
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
-	titleRow.AddCell().SetString("")
+	if req.ListParam != 2 {
+		for i := range otherService {
+			cellOther := titleRow.AddCell()
+			cellOther.VMerge = 1
+			hInt++
+			cellOther.SetString(otherService[i].Title)
+			cellOther.SetStyle(style)
+		}
+	}
+
+	if req.ListParam != 1 {
+		//权益大套餐
+		cell4 := titleRow.AddCell()
+		cell4.HMerge = 1
+		cell4.VMerge = 1
+		cell4.SetString("权益大套餐")
+		cell4.SetStyle(style)
+		titleRow.AddCell().SetString("")
+		hInt += 2
+
+		//权益分行业套餐
+		cell5 := titleRow.AddCell()
+		cell5.HMerge = 8
+		cell5.SetString("权益分行业套餐")
+		cell5.SetStyle(style)
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+		titleRow.AddCell().SetString("")
+	}
 
 	//第二行,前面几个单元格用于第一行的合并
 	titleRow2 := sheet.AddRow()
@@ -1618,65 +1639,98 @@ func (rg *RegisterController) Export(c *gin.Context) {
 	for i := 0; i < hInt; i++ {
 		titleRow2.AddCell().SetString("")
 	}
-	//权益分行业套餐
-	row2Cell1 := titleRow2.AddCell()
-	row2Cell1.HMerge = 1
-	row2Cell1.SetString("医药")
-	row2Cell1.SetStyle(style)
-	titleRow2.AddCell().SetString("")
-
-	row2Cell2 := titleRow2.AddCell()
-	row2Cell2.HMerge = 1
-	row2Cell2.SetString("消费")
-	row2Cell2.SetStyle(style)
-	titleRow2.AddCell().SetString("")
-
-	row2Cell3 := titleRow2.AddCell()
-	row2Cell3.HMerge = 1
-	row2Cell3.SetString("科技")
-	row2Cell3.SetStyle(style)
-	titleRow2.AddCell().SetString("")
-
-	row2Cell4 := titleRow2.AddCell()
-	row2Cell4.HMerge = 1
-	row2Cell4.SetString("智造")
-	row2Cell4.SetStyle(style)
-	titleRow2.AddCell().SetString("")
-
-	row2Cell5 := titleRow2.AddCell()
-	row2Cell5.SetString("策略")
-	row2Cell5.SetStyle(style)
+
+	if req.ListParam != 1 {
+		//权益分行业套餐
+		row2Cell1 := titleRow2.AddCell()
+		row2Cell1.HMerge = 1
+		row2Cell1.SetString("医药")
+		row2Cell1.SetStyle(style)
+		titleRow2.AddCell().SetString("")
+
+		row2Cell2 := titleRow2.AddCell()
+		row2Cell2.HMerge = 1
+		row2Cell2.SetString("消费")
+		row2Cell2.SetStyle(style)
+		titleRow2.AddCell().SetString("")
+
+		row2Cell3 := titleRow2.AddCell()
+		row2Cell3.HMerge = 1
+		row2Cell3.SetString("科技")
+		row2Cell3.SetStyle(style)
+		titleRow2.AddCell().SetString("")
+
+		row2Cell4 := titleRow2.AddCell()
+		row2Cell4.HMerge = 1
+		row2Cell4.SetString("智造")
+		row2Cell4.SetStyle(style)
+		titleRow2.AddCell().SetString("")
+
+		row2Cell5 := titleRow2.AddCell()
+		row2Cell5.SetString("策略")
+		row2Cell5.SetStyle(style)
+	}
 
 	// 第三行表头
 	titleRow3 := sheet.AddRow()
 	titleRow3.SetHeight(60)
 	row3Title := make([]string, 0)
 	row3TitleParent := make([]string, 0)
-	row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n续约-0\n新增-1\n代付-2\n补充协议-3", "FICC销售", "权益销售", "FICC大套餐")
-	for i := range permissionList {
-		row3Title = append(row3Title, permissionList[i].PermissionName)
-	}
-
-	// 其他套餐
-	for i := range otherService {
-		row3Title = append(row3Title, otherService[i].Title)
-	}
-	// 定义二级套餐名称
-	for i := range row3Title {
-		row3TitleParent = append(row3TitleParent, row3Title[i])
-	}
-	// 权益三级套餐
-	for i := range raiOtherService {
-		row3Title = append(row3Title, raiOtherService[i].Title)
-		if raiOtherService[i].ParentTitle != "" {
-			row3TitleParent = append(row3TitleParent, raiOtherService[i].ParentTitle)
-		} else {
-			row3TitleParent = append(row3TitleParent, raiOtherService[i].Title)
+	row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n0-自付合同\n1-代付合同",
+		"合同子类型\n续约-0\n新签-1\n补充协议-2", "代付方", "关联主合同(补充协议)", "关联合同(代付合同)")
+	if req.ListParam == 0 {
+		row3Title = append(row3Title, "FICC销售", "权益销售", "FICC大套餐")
+		for i := range permissionList {
+			row3Title = append(row3Title, permissionList[i].PermissionName)
+		}
+		// 其他套餐
+		for i := range otherService {
+			row3Title = append(row3Title, otherService[i].Title)
+		}
+		// 定义二级套餐名称
+		for i := range row3Title {
+			row3TitleParent = append(row3TitleParent, row3Title[i])
+		}
+		// 权益三级套餐
+		for i := range raiOtherService {
+			row3Title = append(row3Title, raiOtherService[i].Title)
+			if raiOtherService[i].ParentTitle != "" {
+				row3TitleParent = append(row3TitleParent, raiOtherService[i].ParentTitle)
+			} else {
+				row3TitleParent = append(row3TitleParent, raiOtherService[i].Title)
+			}
+		}
+	} else if req.ListParam == 1 {
+		row3Title = append(row3Title, "FICC销售", "FICC大套餐")
+		for i := range permissionList {
+			row3Title = append(row3Title, permissionList[i].PermissionName)
+		}
+		// 其他套餐
+		for i := range otherService {
+			row3Title = append(row3Title, otherService[i].Title)
+		}
+		// 定义二级套餐名称
+		for i := range row3Title {
+			row3TitleParent = append(row3TitleParent, row3Title[i])
+		}
+	} else {
+		row3Title = append(row3Title, "权益销售")
+		// 权益三级套餐
+		for i := range raiOtherService {
+			row3Title = append(row3Title, raiOtherService[i].Title)
+			if raiOtherService[i].ParentTitle != "" {
+				row3TitleParent = append(row3TitleParent, raiOtherService[i].ParentTitle)
+			} else {
+				row3TitleParent = append(row3TitleParent, raiOtherService[i].Title)
+			}
 		}
 	}
 
-	row3Title = append(row3Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "金额单位", "FICC套餐总金额", "权益套餐总金额", "约定付款时间", "签订日", "合同状态",
-		"合同编号", "合规备注")
+	row3Title = append(row3Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "金额单位")
+	if req.ListParam == 0 {
+		row3Title = append(row3Title, "FICC套餐总金额", "权益套餐总金额")
+	}
+	row3Title = append(row3Title, "约定付款时间", "签订日", "合同状态", "合同编号", "合规备注")
 
 	// 设置表头
 	for i := range row3Title {
@@ -1716,10 +1770,13 @@ func (rg *RegisterController) Export(c *gin.Context) {
 
 	newCompanyMap := map[int]string{0: "1", 1: "0"}
 	contractTMap := map[int]int{
-		fms.ContractTypeNew:      1,
-		fms.ContractTypeRenew:    0,
-		fms.ContractTypeAgentPay: 2, // 代付合同
-		fms.ContractTypePlus:     3, // 补充协议
+		fms.ContractTypeSelf:   0,
+		fms.ContractTypebehalf: 1,
+	}
+	contractSubTMap := map[int]int{
+		fms.NewContractTypeNew:   0,
+		fms.NewContractTypeRenew: 1,
+		fms.NewContractTypePlus:  2, // 代付合同
 	}
 	for _, v := range list {
 		k := -1 // 套餐匹配用
@@ -1728,7 +1785,8 @@ func (rg *RegisterController) Export(c *gin.Context) {
 		k += 4
 		dataRow.AddCell().SetString(v.CompanyName)
 		dataRow.AddCell().SetString(newCompanyMap[v.NewCompany])
-		dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.ContractType]))
+		dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.HasPayment]))
+		dataRow.AddCell().SetString(fmt.Sprint(contractSubTMap[v.ContractType]))
 		dataRow.AddCell().SetString(v.SellerName)
 		dataRow.AddCell().SetString(v.RaiSellerName)
 

+ 11 - 2
models/fms/constants.go

@@ -31,8 +31,8 @@ const (
 	// 合同登记开票类型
 	ContractInvoiceTypeMake    = 1 // 开票登记
 	ContractInvoiceTypePay     = 2 // 到款登记
-	ContractInvoiceTypePreMake  = 3 // 开票预登记
-	ContractInvoiceTypePrePay = 4 // 到款预登记
+	ContractInvoiceTypePreMake = 3 // 开票预登记
+	ContractInvoiceTypePrePay  = 4 // 到款预登记
 
 	// 到款登记付款方式
 	ContractPaymentPayTypeYear     = 1 // 年付
@@ -41,6 +41,15 @@ const (
 	ContractPaymentPayTypeOther    = 4 // 次付
 	ContractPaymentPayTypeAbnormal = 5 // 异常
 
+	// 2.5 新合同类型
+	ContractTypeSelf   = 0 // 自付
+	ContractTypebehalf = 1 // 代付
+
+	// 2.5 子合同类型
+	NewContractTypeNew      = 0 // 新签
+	NewContractTypeRenew    = 1 // 续约
+	NewContractTypePlus     = 4 // 补充协议
+
 	// 基础货币代码(人民币)
 	BaseCurrencyCode = "CNY"
 )

+ 3 - 0
models/fms/contract_pre_register.go

@@ -198,6 +198,9 @@ type ContractPreRegisterList struct {
 type PreRegisterDetailReq struct {
 	ContractRegisterId int `json:"contract_register_id" form:"contract_register_id" binding:"required,gte=1"`
 	InvoiceType        int `gorm:"column:invoice_type" json:"invoice_type" description:"类型: 1-开票登记; 2-到款登记;3-开票预登记;4-到款预登记"`
+	PreRegisterId      int `gorm:"column:pre_register_id" json:"pre_register_id" description:"预登记ID"`
+	InvoiceId          int `gorm:"column:invoice_id" json:"invoice_id" description:"开票ID"`
+	ArriveId           int `gorm:"column:arrive_id" json:"arrive_id" description:"到款ID"`
 }
 
 // ContractPreRegisterDetail 预登记详情

+ 18 - 1
models/fms/contract_register.go

@@ -646,7 +646,7 @@ func UpdateContractPreRegister(item *ContractRegister, updateCols []string, serv
 
 // UpdateContractRegister 预登记保存和更新
 func UpdateContractRegisterPre(item *ContractRegister, updateCols []string, serviceDetail []*ContractServiceAndDetail,
-	invoiceList []*ContractInvoice, invoiceUpdateCols []string, invoiceHandleType int) (err error) {
+	invoiceList []*ContractInvoice, invoiceUpdateCols []string, invoiceHandleType int, ppList []*ContractPreRegister) (err error) {
 	tx := global.DEFAULT_MYSQL.Begin()
 	defer func() {
 		if err != nil {
@@ -718,6 +718,23 @@ func UpdateContractRegisterPre(item *ContractRegister, updateCols []string, serv
 				err = e
 				return
 			}
+			if len(ppList) > 0 {
+				pp := &ContractPreRegister{
+					PreRegisterId: ppList[0].PreRegisterId,
+				}
+				ppUpdateCols := make([]string,0)
+				if v.InvoiceType == 3{
+					pp.InvoiceId = v.ContractInvoiceId
+					ppUpdateCols = append(ppUpdateCols, "InvoiceId")
+				}else {
+					pp.ArriveId = v.ContractInvoiceId
+					ppUpdateCols =  append(ppUpdateCols, "ArriveId")
+				}
+				if e := pp.Update(ppUpdateCols); e != nil {
+					err = e
+					return
+				}
+			}
 		}
 	}
 	if invoiceHandleType == 1 {