ziwen 2 лет назад
Родитель
Сommit
98b720d613
3 измененных файлов с 93 добавлено и 42 удалено
  1. 3 1
      controller/contract/pre_register.go
  2. 69 40
      controller/contract/register.go
  3. 21 1
      models/fms/contract_register.go

+ 3 - 1
controller/contract/pre_register.go

@@ -459,6 +459,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 	}
 
 	invoiceList := make([]*fms.ContractInvoice, 0)
+	ppList := make([]*fms.ContractPreRegister, 0)
 	for _, r := range req.List {
 		// 货币及汇率
 		rateList, e := fmsService.GetTodayCurrencyRateList()
@@ -587,13 +588,14 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
 		}
 
 		invoiceList = append(invoiceList, v)
+		ppList = append(ppList, pp)
 	}
 	invoiceUpdateCols := []string{
 		"CurrencyUnit", "OriginAmount", "Amount", "InvoiceDate", "AdminId", "AdminName", "Remark",
 		"ServiceProductId", "StartDate", "EndDate", "ModifyTime",
 	}
 	// 更新合同登记、套餐、开票到款
-	if e = fms.UpdateContractPreRegister(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols, req.DelInvoiceIds, req.DelPreRegisterIds); e != nil {
+	if e = fms.UpdateContractPreRegister(ob, updateCols, serviceList, invoiceList, invoiceUpdateCols, req.DelInvoiceIds, req.DelPreRegisterIds, ppList); e != nil {
 		resp.FailMsg("操作失败", "更新合同及套餐失败, Err: "+e.Error(), c)
 		return
 	}

+ 69 - 40
controller/contract/register.go

@@ -1555,9 +1555,9 @@ func (rg *RegisterController) Export(c *gin.Context) {
 	// 1行1列-右合并两格, 下合并1行
 	cell1 := titleRow.AddCell()
 	if req.ListParam == 0 {
-		cell1.HMerge = 8
+		cell1.HMerge = 9
 	} else {
-		cell1.HMerge = 7
+		cell1.HMerge = 9
 	}
 
 	cell1.VMerge = 1
@@ -1571,7 +1571,8 @@ func (rg *RegisterController) Export(c *gin.Context) {
 	titleRow.AddCell().SetString("")
 	titleRow.AddCell().SetString("")
 	titleRow.AddCell().SetString("")
-	hInt += 8
+	titleRow.AddCell().SetString("")
+	hInt += 9
 
 	if req.ListParam == 0 {
 		//如果是全部的话要多一格
@@ -1681,7 +1682,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
 	row3Title := make([]string, 0)
 	row3TitleParent := make([]string, 0)
 	row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n0-自付合同\n1-代付合同",
-		"合同子类型\n续约-0\n新签-1\n补充协议-2", "代付方", "关联主合同(补充协议)", "关联合同(代付合同)")
+		"合同子类型\n续约-0\n新签-1\n补充协议-2", "合同所属方", "代付方" ,"关联主合同(补充协议)", "关联合同(代付合同)")
 	if req.ListParam == 0 {
 		row3Title = append(row3Title, "FICC销售", "权益销售", "FICC大套餐")
 		for i := range permissionList {
@@ -1790,6 +1791,15 @@ func (rg *RegisterController) Export(c *gin.Context) {
 		dataRow.AddCell().SetString(newCompanyMap[v.NewCompany])
 		dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.HasPayment]))
 		dataRow.AddCell().SetString(fmt.Sprint(contractSubTMap[v.ContractType]))
+		if v.HasPayment == 1 {
+			if v.HasInvoice == 1 {
+				dataRow.AddCell().SetString("1")
+			} else {
+				dataRow.AddCell().SetString("0")
+			}
+		} else {
+			dataRow.AddCell().SetString("")
+		}
 		dataRow.AddCell().SetString(v.ActualPayCompanies)
 		dataRow.AddCell().SetString(v.RelateContractMainCode)
 		dataRow.AddCell().SetString(v.RelateContractCode)
@@ -1804,9 +1814,9 @@ func (rg *RegisterController) Export(c *gin.Context) {
 
 
 		if req.ListParam != 0 {
-			k += 9
-		} else {
 			k += 10
+		} else {
+			k += 11
 		}
 		// 大套餐
 		col4Name := row3Title[k]
@@ -2302,15 +2312,15 @@ func (rg *RegisterController) Import(c *gin.Context) {
 
 	//权益行业套餐名称
 	raiIndustryMap := map[int]string{
-		42: "医药",
 		43: "医药",
-		44: "消费",
+		44: "医药",
 		45: "消费",
-		46: "科技",
+		46: "消费",
 		47: "科技",
-		48: "智造",
+		48: "科技",
 		49: "智造",
-		50: "策略",
+		50: "智造",
+		51: "策略",
 	}
 
 	// 获取货币列表及汇率(汇率为导入日的汇率)
@@ -2391,36 +2401,42 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						}
 						continue
 					} else if k == 4 {
+						if !strings.Contains(text, "合同所属方") {
+							resp.Fail("【合同所属方】列名称有误, 请参考模板导入", c)
+							return
+						}
+						continue
+					} else if k == 5 {
 						if text != "代付方" {
 							resp.Fail("【代付方】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 5 {
-						if !strings.Contains(text, "关联主合同") {
+					} else if k == 6 {
+						if !strings.Contains(text, "关联主合同(补充协议)") {
 							resp.Fail("【关联主合同】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 6 {
+					} else if k == 7 {
 						if !strings.Contains(text, "关联合同") {
 							resp.Fail("【关联合同】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 7 {
+					} else if k == 8 {
 						if text != "FICC销售" {
 							resp.Fail("【FICC销售】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 8 {
+					} else if k == 9 {
 						if text != "权益销售" {
 							resp.Fail("【权益销售】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 9 {
+					} else if k == 10 {
 						if text != "FICC大套餐" {
 							resp.Fail("【FICC大套餐】列名称有误, 请参考模板导入", c)
 							return
@@ -2497,19 +2513,32 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					if k == 4 {
-						rowRegister.ActualPayCompanies = v
+						if rowRegister.HasPayment == 1{
+							if v == "0" {
+								//所属方为实际使用方,不走开票到款流程
+								rowRegister.HasInvoice = 0
+							} else if v == "1" {
+								rowRegister.HasInvoice = 1
+							}
+						} else {
+							rowRegister.HasInvoice = 1
+						}
 						continue
 					}
 					if k == 5 {
-						rowRegister.RelateContractMainCode = v
+						rowRegister.ActualPayCompanies = v
 						continue
 					}
 					if k == 6 {
+						rowRegister.RelateContractMainCode = v
+						continue
+					}
+					if k == 7 {
 						rowRegister.RelateContractCode = v
 						continue
 					}
 					// FICC销售
-					if k == 7 {
+					if k == 8 {
 						if v != "" {
 							/*resp.Fail(fmt.Sprintf("第%d行销售名称不可为空, 请按模板导入", i+1), c)
 							return*/
@@ -2525,7 +2554,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 					}
 
 					// 权益销售
-					if k == 8 {
+					if k == 9 {
 						if v == "" && rowRegister.SellerName == "" {
 							resp.Fail(fmt.Sprintf("第FICC销售名称和权益销售名称不可都为空, 请按模板导入", i+1), c)
 							return
@@ -2540,7 +2569,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// FICC大套餐
-					if k == 9 {
+					if k == 10 {
 						if v == "是" {
 							tempItem := serviceTempNameMap[titleMap[k]]
 							if tempItem == nil {
@@ -2562,7 +2591,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// FICC小套餐
-					if k >= 10 && k <= 30 {
+					if k >= 11 && k <= 31 {
 						// 小套餐权限
 						if v == "是" {
 							rowChartPermissionIdArr = append(rowChartPermissionIdArr, strconv.Itoa(chartPermissionNameIdMap[titleMap[k]]))
@@ -2571,7 +2600,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 其他类型套餐
-					if k >= 31 && k <= 37 {
+					if k >= 32 && k <= 38 {
 						if v == "是" {
 							tempItem := serviceTempNameMap[titleMap[k]]
 							if tempItem == nil {
@@ -2592,10 +2621,10 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						}
 						continue
 					}
-					if k >= 38 && k <= 48 {
+					if k >= 39 && k <= 49 {
 						if v == "是" {
 							// 权益大套餐
-							if k <= 41 {
+							if k <= 42 {
 								//新增
 								parentName := "权益大套餐"
 								tempItem := serviceTempNameMap[titleMap[k]]
@@ -2692,7 +2721,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 权益研选等套餐
-					if k >= 49 && k <= 53 {
+					if k >= 50 && k <= 54 {
 						if v == "是" {
 							tempItem := serviceTempNameMap[titleMap[k]]
 							if tempItem == nil {
@@ -2714,12 +2743,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 套餐备注
-					if k == 54 {
+					if k == 55 {
 						rowRegister.ServiceRemark = v
 						continue
 					}
 					// 开始时间/到期时间
-					if k == 57 {
+					if k == 58 {
 						// 转换失败可能是因为格式为Excel日期格式, 读取出来会是一串数字, 将其转换成日期字符串再处理
 						va := cell.Value
 						if va == "" {
@@ -2743,7 +2772,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						rowRegister.StartDate = startDate
 						continue
 					}
-					if k == 58 {
+					if k == 59 {
 						va := cell.Value
 						if va == "" {
 							resp.Fail(fmt.Sprintf("第%d行到期时间不可为空, 请按模板导入", i+1), c)
@@ -2766,7 +2795,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合同金额
-					if k == 59 {
+					if k == 60 {
 						amountStr := v
 						amount, e := strconv.ParseFloat(amountStr, 64)
 						if e != nil {
@@ -2777,7 +2806,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 金额单位
-					if k == 60 {
+					if k == 61 {
 						rate := rateMap[v]
 						if rate <= 0 {
 							resp.Fail(fmt.Sprintf("第%d行金额单位有误, 请按模板导入", i+1), c)
@@ -2788,7 +2817,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// FICC 套餐总金额
-					if k == 61 {
+					if k == 62 {
 						amountStr := v
 						amount, e := strconv.ParseFloat(amountStr, 64)
 						if e != nil {
@@ -2807,7 +2836,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 权益套餐总金额
-					if k == 62 {
+					if k == 63 {
 						amountStr := v
 						amount, e := strconv.ParseFloat(amountStr, 64)
 						if e != nil {
@@ -2826,12 +2855,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 约定付款日期
-					if k == 63 {
+					if k == 64 {
 						rowRegister.AgreedPayTime = v
 						continue
 					}
 					// 签订日
-					if k == 64 {
+					if k == 65 {
 						va := cell.Value
 						if va == "" {
 							continue
@@ -2853,7 +2882,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合同状态
-					if k == 65 {
+					if k == 66 {
 						rowRegister.ContractStatus = fms.ContractStatusNameKeyMap[v]
 						if rowRegister.ContractStatus == 0 {
 							resp.Fail(fmt.Sprintf("第%d行合同状态不匹配, 请按模板导入", i+1), c)
@@ -2862,7 +2891,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合同编号
-					if k == 66 {
+					if k == 67 {
 						rowContractCode := v
 						if rowContractCode == "" {
 							resp.Fail(fmt.Sprintf("第%d行合同编号不可为空, 请按模板导入", i+1), c)
@@ -2877,12 +2906,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合规备注
-					if k == 67 {
+					if k == 68 {
 						rowRegister.Remark = v
 						continue
 					}
 					// 开票列表
-					k2 := 67
+					k2 := 68
 					for ir := 0; ir < invoiceMax; ir++ {
 						n := ir + 1
 						// 开票日

+ 21 - 1
models/fms/contract_register.go

@@ -1,6 +1,7 @@
 package fms
 
 import (
+	"fmt"
 	"hongze/fms_api/global"
 	"hongze/fms_api/models/base"
 	"hongze/fms_api/utils"
@@ -562,7 +563,7 @@ type CheckContractNameResp struct {
 
 // UpdateContractPreRegister 更新合同预登记
 func UpdateContractPreRegister(item *ContractRegister, updateCols []string, serviceDetail []*ContractServiceAndDetail,
-	invoiceList []*ContractInvoice, invoiceUpdateCols []string, delInvoiceIds, delPreRegisterIds []int) (err error) {
+	invoiceList []*ContractInvoice, invoiceUpdateCols []string, delInvoiceIds, delPreRegisterIds []int, ppList []*ContractPreRegister) (err error) {
 	tx := global.DEFAULT_MYSQL.Begin()
 	defer func() {
 		if err != nil {
@@ -619,6 +620,25 @@ func UpdateContractPreRegister(item *ContractRegister, updateCols []string, serv
 				err = e
 				return
 			}
+			if len(ppList) > 0 {
+				pp := &ContractPreRegister{
+					PreRegisterId: invoiceList[i].PreRegisterId,
+				}
+				fmt.Println("PreRegisterId:", pp.PreRegisterId)
+				fmt.Println("invoiceList[i].ContractInvoiceId:", invoiceList[i].ContractInvoiceId)
+				ppUpdateCols := make([]string, 0)
+				if invoiceList[i].InvoiceType == 3 {
+					pp.InvoiceId = invoiceList[i].ContractInvoiceId
+					ppUpdateCols = append(ppUpdateCols, "InvoiceId")
+				} else {
+					pp.ArriveId = invoiceList[i].ContractInvoiceId
+					ppUpdateCols = append(ppUpdateCols, "ArriveId")
+				}
+				if e := pp.Update(ppUpdateCols); e != nil {
+					err = e
+					return
+				}
+			}
 		} else {
 			if e := tx.Model(invoiceList[i]).Select(invoiceUpdateCols).Updates(invoiceList[i]).Error; e != nil {
 				err = e