ziwen 2 年之前
父节点
当前提交
7dd14a535f
共有 2 个文件被更改,包括 112 次插入58 次删除
  1. 110 56
      controller/contract/register.go
  2. 2 2
      models/fms/constants.go

+ 110 - 56
controller/contract/register.go

@@ -351,7 +351,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
 		"ContractCode", "RelateContractCode", "RelateContractMainCode", "CrmContractId", "ContractSource",
 		"ProductIds", "CompanyName", "SellerId", "SellerName", "StartDate", "EndDate",
 		"RaiSellerId", "RaiSellerName", "ModifyTime", "ContractType", "ContractAmount", "CurrencyUnit", "RMBRate",
-		"SignDate", "AgreedPayTime", "ContractStatus", "RegisterStatus", "Remark", "HasPayment","HasInvoice", "ActualPayCompanies",
+		"SignDate", "AgreedPayTime", "ContractStatus", "RegisterStatus", "Remark", "HasPayment", "HasInvoice", "ActualPayCompanies",
 	}
 	// 不需要开票到款的代付直接完成登记, 且不允许进行开票/到款登记
 	if req.HasInvoice == 0 || req.ContractStatus == fms.ContractStatusEnd {
@@ -657,7 +657,7 @@ func (rg *RegisterController) Edit(c *gin.Context) {
 	updateCols := []string{
 		"ProductIds", "ContractCode", "RelateContractCode", "CrmContractId", "ContractSource", "CompanyName",
 		"SellerId", "SellerName", "ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime", "RaiSellerId", "RaiSellerName",
-		"ContractStatus", "RegisterStatus", "Remark", "ServiceRemark", "HasPayment", "ModifyTime","HasInvoice","ActualPayCompanies",
+		"ContractStatus", "RegisterStatus", "Remark", "ServiceRemark", "HasPayment", "ModifyTime", "HasInvoice", "ActualPayCompanies",
 	}
 	nowTime := time.Now().Local()
 	item.ProductIds = req.ProductIds
@@ -1786,19 +1786,21 @@ func (rg *RegisterController) Export(c *gin.Context) {
 		k := -1 // 套餐匹配用
 		dataRow := sheet.AddRow()
 		dataRow.SetHeight(20)
-		k += 4
 		dataRow.AddCell().SetString(v.CompanyName)
 		dataRow.AddCell().SetString(newCompanyMap[v.NewCompany])
 		dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.HasPayment]))
 		dataRow.AddCell().SetString(fmt.Sprint(contractSubTMap[v.ContractType]))
-		dataRow.AddCell().SetString(v.ActualCompanyName)
-		dataRow.AddCell().SetString("")
-		dataRow.AddCell().SetString("")
+		dataRow.AddCell().SetString(v.ActualPayCompanies)
+		dataRow.AddCell().SetString(v.RelateContractMainCode)
+		dataRow.AddCell().SetString(v.RelateContractCode)
 		dataRow.AddCell().SetString(v.SellerName)
 		dataRow.AddCell().SetString(v.RaiSellerName)
 
+		if req.ListParam != 2 {
+
+		}
 		// 大套餐
-		k += 2
+		k += 10
 		col4Name := row3Title[k]
 		svList := serviceMap[v.ContractRegisterId]
 		col4 := ""
@@ -2293,15 +2295,15 @@ func (rg *RegisterController) Import(c *gin.Context) {
 
 	//权益行业套餐名称
 	raiIndustryMap := map[int]string{
-		36: "医药",
-		37: "医药",
-		38: "消费",
-		39: "消费",
-		40: "科技",
-		41: "科技",
-		42: "智造",
-		43: "智造",
-		44: "策略",
+		40: "医药",
+		41: "医药",
+		42: "消费",
+		43: "消费",
+		44: "科技",
+		45: "科技",
+		46: "智造",
+		48: "智造",
+		49: "策略",
 	}
 
 	// 获取货币列表及汇率(汇率为导入日的汇率)
@@ -2319,12 +2321,16 @@ func (rg *RegisterController) Import(c *gin.Context) {
 	newIds := make([]int, 0)
 	newCompanyArr := []string{"0", "1"}
 	newCompanyMap := map[string]int{"0": 1, "1": 0}
-	contractTypeArr := []string{"0", "1", "2", "3"}
-	contractTypeMap := map[string]int{
-		"0": fms.ContractTypeRenew,
-		"1": fms.ContractTypeNew,
-		"2": fms.ContractTypeAgentPay,
-		"3": fms.ContractTypePlus,
+	contractTypeArr := []string{"0", "1"}
+	contractTMap := map[string]int{
+		"0": fms.ContractTypeSelf,
+		"1": fms.ContractTypebehalf,
+	}
+	contractSubTypeArr := []string{"0", "1", "2"}
+	contractSubTMap := map[string]int{
+		"1": fms.NewContractTypeNew,
+		"0": fms.NewContractTypeRenew,
+		"2": fms.NewContractTypePlus,
 	}
 
 	// 更新登记状态
@@ -2372,18 +2378,42 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						}
 						continue
 					} else if k == 3 {
+						if !strings.Contains(text, "合同子类型") {
+							resp.Fail("【合同子类型】列名称有误, 请参考模板导入", c)
+							return
+						}
+						continue
+					} else if k == 4 {
+						if text != "代付方" {
+							resp.Fail("【代付方】列名称有误, 请参考模板导入", c)
+							return
+						}
+						continue
+					} else if k == 5 {
+						if !strings.Contains(text, "关联主合同") {
+							resp.Fail("【关联主合同】列名称有误, 请参考模板导入", c)
+							return
+						}
+						continue
+					} else if k == 6 {
+						if !strings.Contains(text, "关联合同") {
+							resp.Fail("【关联合同】列名称有误, 请参考模板导入", c)
+							return
+						}
+						continue
+					} else if k == 7 {
 						if text != "FICC销售" {
 							resp.Fail("【FICC销售】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 4 {
+					} else if k == 8 {
 						if text != "权益销售" {
 							resp.Fail("【权益销售】列名称有误, 请参考模板导入", c)
 							return
 						}
 						continue
-					} else if k == 5 {
+					} else if k == 9 {
 						if text != "FICC大套餐" {
 							resp.Fail("【FICC大套餐】列名称有误, 请参考模板导入", c)
 							return
@@ -2417,6 +2447,8 @@ func (rg *RegisterController) Import(c *gin.Context) {
 				productIds := make(map[int]struct{})
 				isSkip := false
 				for k, cell := range cells {
+					fmt.Println("k:", k)
+					fmt.Println("cell:", cell.Value)
 					v := utils.TrimStr(cell.String())
 					// 客户名称
 					if k == 0 {
@@ -2442,15 +2474,35 @@ func (rg *RegisterController) Import(c *gin.Context) {
 							resp.Fail(fmt.Sprintf("第%d行合同类型有误, 请按模板导入", i+1), c)
 							return
 						}
-						rowRegister.ContractType = contractTypeMap[v]
+						rowRegister.HasPayment = contractTMap[v]
+						continue
+					}
+					if k == 3 {
+						if !utils.InArrayByStr(contractSubTypeArr, v) {
+							resp.Fail(fmt.Sprintf("第%d行合同类型有误, 请按模板导入", i+1), c)
+							return
+						}
+						rowRegister.ContractType = contractSubTMap[v]
 						if rowRegister.ContractType == 0 {
-							resp.Fail(fmt.Sprintf("第%d行合同类型匹配有误, 请按模板导入", i+1), c)
+							resp.Fail(fmt.Sprintf("第%d行合同类型匹配有误, 请按模板导入", i+1), c)
 							return
 						}
 						continue
 					}
+					if k == 4 {
+						rowRegister.ActualPayCompanies = v
+						continue
+					}
+					if k == 5 {
+						rowRegister.RelateContractMainCode = v
+						continue
+					}
+					if k == 6 {
+						rowRegister.RelateContractCode = v
+						continue
+					}
 					// FICC销售
-					if k == 3 {
+					if k == 7 {
 						if v != "" {
 							/*resp.Fail(fmt.Sprintf("第%d行销售名称不可为空, 请按模板导入", i+1), c)
 							return*/
@@ -2466,7 +2518,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 					}
 
 					// 权益销售
-					if k == 4 {
+					if k == 8 {
 						if v == "" && rowRegister.SellerName == "" {
 							resp.Fail(fmt.Sprintf("第FICC销售名称和权益销售名称不可都为空, 请按模板导入", i+1), c)
 							return
@@ -2481,11 +2533,11 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// FICC大套餐
-					if k == 5 {
+					if k == 9 {
 						if v == "是" {
 							tempItem := serviceTempNameMap[titleMap[k]]
 							if tempItem == nil {
-								resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+								resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 								return
 							}
 							cs := &fms.ContractService{
@@ -2503,7 +2555,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// FICC小套餐
-					if k >= 6 && k <= 26 {
+					if k >= 10 && k <= 30 {
 						// 小套餐权限
 						if v == "是" {
 							rowChartPermissionIdArr = append(rowChartPermissionIdArr, strconv.Itoa(chartPermissionNameIdMap[titleMap[k]]))
@@ -2512,11 +2564,11 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 其他类型套餐
-					if k >= 27 && k <= 33 {
+					if k >= 31 && k <= 37 {
 						if v == "是" {
 							tempItem := serviceTempNameMap[titleMap[k]]
 							if tempItem == nil {
-								resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+								resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 								return
 							}
 							cs := &fms.ContractService{
@@ -2533,15 +2585,15 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						}
 						continue
 					}
-					if k >= 34 && k <= 44 {
+					if k >= 38 && k <= 48 {
 						if v == "是" {
 							// 权益大套餐
-							if k <= 35 {
+							if k <= 41 {
 								//新增
 								parentName := "权益大套餐"
 								tempItem := serviceTempNameMap[titleMap[k]]
 								if tempItem == nil {
-									resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+									resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 									return
 								}
 								cs := &fms.ContractService{
@@ -2556,7 +2608,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 
 								tempItem = serviceTempNameMap[parentName]
 								if tempItem == nil {
-									resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+									resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 									return
 								}
 								cs = &fms.ContractService{
@@ -2577,8 +2629,10 @@ func (rg *RegisterController) Import(c *gin.Context) {
 								if fullName != "" {
 									//增加三级权限
 									tempItem := serviceTempFullNameMap[fullName]
+									fmt.Println("fullName:", fullName)
+									fmt.Println("serviceTempFullNameMap:", serviceTempFullNameMap)
 									if tempItem == nil {
-										resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+										resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 										return
 									}
 									cs := &fms.ContractService{
@@ -2594,7 +2648,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 									//增加二级权限
 									tempItem = serviceTempFullNameMap[parentName+"_"+rootName]
 									if tempItem == nil {
-										resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+										resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 										return
 									}
 									cs = &fms.ContractService{
@@ -2610,7 +2664,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 									//增加一级权限
 									tempItem = serviceTempFullNameMap[rootName]
 									if tempItem == nil {
-										resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+										resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 										return
 									}
 									cs = &fms.ContractService{
@@ -2629,11 +2683,11 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 权益研选等套餐
-					if k >= 45 && k <= 49 {
+					if k >= 49 && k <= 53 {
 						if v == "是" {
 							tempItem := serviceTempNameMap[titleMap[k]]
 							if tempItem == nil {
-								resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
+								resp.Fail(fmt.Sprintf("第%d行%d列套餐名称不匹配, 请按模板导入", i+1, k+1), c)
 								return
 							}
 							cs := &fms.ContractService{
@@ -2651,16 +2705,16 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 套餐备注
-					if k == 50 {
+					if k == 54 {
 						rowRegister.ServiceRemark = v
 						continue
 					}
 					// 开始时间/到期时间
-					if k == 51 {
+					if k == 57 {
 						// 转换失败可能是因为格式为Excel日期格式, 读取出来会是一串数字, 将其转换成日期字符串再处理
 						va := cell.Value
 						if va == "" {
-							resp.Fail(fmt.Sprintf("第%d行开始时间不可为空, 请按模板导入", i+1), c)
+							resp.Fail(fmt.Sprintf("第%d行%d列开始时间不可为空, 请按模板导入", i+1, k+1), c)
 							return
 						}
 						startDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
@@ -2680,7 +2734,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						rowRegister.StartDate = startDate
 						continue
 					}
-					if k == 52 {
+					if k == 58 {
 						va := cell.Value
 						if va == "" {
 							resp.Fail(fmt.Sprintf("第%d行到期时间不可为空, 请按模板导入", i+1), c)
@@ -2703,7 +2757,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合同金额
-					if k == 53 {
+					if k == 59 {
 						amountStr := v
 						amount, e := strconv.ParseFloat(amountStr, 64)
 						if e != nil {
@@ -2714,7 +2768,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 金额单位
-					if k == 54 {
+					if k == 60 {
 						rate := rateMap[v]
 						if rate <= 0 {
 							resp.Fail(fmt.Sprintf("第%d行金额单位有误, 请按模板导入", i+1), c)
@@ -2725,7 +2779,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// FICC 套餐总金额
-					if k == 55 {
+					if k == 61 {
 						amountStr := v
 						amount, e := strconv.ParseFloat(amountStr, 64)
 						if e != nil {
@@ -2744,7 +2798,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 权益套餐总金额
-					if k == 56 {
+					if k == 62 {
 						amountStr := v
 						amount, e := strconv.ParseFloat(amountStr, 64)
 						if e != nil {
@@ -2763,12 +2817,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 约定付款日期
-					if k == 57 {
+					if k == 63 {
 						rowRegister.AgreedPayTime = v
 						continue
 					}
 					// 签订日
-					if k == 58 {
+					if k == 64 {
 						va := cell.Value
 						if va == "" {
 							continue
@@ -2790,7 +2844,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合同状态
-					if k == 59 {
+					if k == 65 {
 						rowRegister.ContractStatus = fms.ContractStatusNameKeyMap[v]
 						if rowRegister.ContractStatus == 0 {
 							resp.Fail(fmt.Sprintf("第%d行合同状态不匹配, 请按模板导入", i+1), c)
@@ -2799,7 +2853,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合同编号
-					if k == 60 {
+					if k == 66 {
 						rowContractCode := v
 						if rowContractCode == "" {
 							resp.Fail(fmt.Sprintf("第%d行合同编号不可为空, 请按模板导入", i+1), c)
@@ -2814,12 +2868,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
 						continue
 					}
 					// 合规备注
-					if k == 61 {
+					if k == 67 {
 						rowRegister.Remark = v
 						continue
 					}
 					// 开票列表
-					k2 := 61
+					k2 := 67
 					for ir := 0; ir < invoiceMax; ir++ {
 						n := ir + 1
 						// 开票日

+ 2 - 2
models/fms/constants.go

@@ -46,8 +46,8 @@ const (
 	ContractTypebehalf = 1 // 代付
 
 	// 2.5 子合同类型
-	NewContractTypeNew      = 0 // 新签
-	NewContractTypeRenew    = 1 // 续约
+	NewContractTypeNew      = 1 // 新签
+	NewContractTypeRenew    = 2 // 续约
 	NewContractTypePlus     = 4 // 补充协议
 
 	// 基础货币代码(人民币)