瀏覽代碼

fix: 代付合同

hsun 2 年之前
父節點
當前提交
07ae330c18
共有 3 個文件被更改,包括 126 次插入7 次删除
  1. 117 0
      controller/contract/register.go
  2. 5 3
      controller/crm/contract.go
  3. 4 4
      models/crm/contract.go

+ 117 - 0
controller/contract/register.go

@@ -1321,3 +1321,120 @@ func (rg *RegisterController) InvoiceExport(c *gin.Context) {
 	c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
 	http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
 }
+
+
+// Import
+// @Title 合同登记-导入
+// @Description 合同登记-导入
+// @Success 200 string "操作成功"
+// @router /contract/register/import [post]
+func (rg *RegisterController) Import(c *gin.Context) {
+	//h, err := c.FormFile("File")
+	//if err != nil {
+	//	resp.FailData("获取文件失败", "Err:"+err.Error(), c)
+	//	return
+	//}
+	//ext := path.Ext(h.Filename)
+	//if ext != ".xlsx" && ext != ".xls" {
+	//	resp.Fail("请上传Excel文件", c)
+	//	return
+	//}
+	//
+	//uploadDir := "static/xls"
+	//err = os.MkdirAll(uploadDir, 766)
+	//if err != nil {
+	//	resp.FailData("存储目录创建失败", "Err:"+err.Error(), c)
+	//	return
+	//}
+	//uploadPath := uploadDir + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + h.Filename
+	//err = c.SaveUploadedFile(h, uploadPath)
+	//if err != nil {
+	//	resp.FailData("保存本地文件失败", "Err:"+err.Error(), c)
+	//	return
+	//}
+	//defer func() {
+	//	_ = os.Remove(uploadPath)
+	//}()
+	//xlFile, err := xlsx.OpenFile(uploadPath)
+	//if err != nil {
+	//	resp.FailData("打开文件失败", "Err:"+err.Error(), c)
+	//	return
+	//}
+	//
+	//// TODO:获取所有已登记,根据合同编号去重
+	//
+	//// TODO:获取所有销售名称
+	//
+	//// TODO:获取所有套餐
+	//
+	//// TODO:获取chartPermissionMap
+	//
+	//titleMap := make(map[int]string)
+	//for _, sheet := range xlFile.Sheets {
+	//	// 遍历行读取
+	//	maxRow := sheet.MaxRow
+	//	for i := 0; i < maxRow; i++ {
+	//		// 第二行开始读取表头
+	//		if i == 1 {
+	//			row := sheet.Row(i)
+	//			cells := row.Cells
+	//			for k, cell := range cells {
+	//				text := cell.String()
+	//				titleMap[k] = text
+	//				// 只检验前面部分表头
+	//				if k == 0 {
+	//					if text != "客户名称" {
+	//						resp.Fail("匹配失败, 请按模板导入", c)
+	//						return
+	//					}
+	//				}
+	//				if k == 1 {
+	//					if !strings.Contains(text, "续约") {
+	//						resp.Fail("匹配失败, 请按模板导入", c)
+	//						return
+	//					}
+	//				}
+	//				if k == 2 {
+	//					if text != "销售" {
+	//						resp.Fail("匹配失败, 请按模板导入", c)
+	//						return
+	//					}
+	//				}
+	//				if k == 3 {
+	//					if text != "FICC大套餐" {
+	//						resp.Fail("匹配失败, 请按模板导入", c)
+	//						return
+	//					}
+	//				}
+	//			}
+	//		}
+	//		// 数据行
+	//		if i >= 2 {
+	//			row := sheet.Row(i)
+	//			cells := row.Cells
+	//			var userName, countryCode, mobile, companyName string
+	//			for k, cell := range cells {
+	//				if k == 0 {
+	//					userName = utils.TrimStr(cell.String())
+	//				}
+	//				if k == 1 {
+	//					countryCode = utils.TrimStr(cell.String())
+	//				}
+	//				if k == 2 {
+	//					mobile = utils.TrimStr(cell.String())
+	//				}
+	//				if k == 3 {
+	//					companyName = utils.TrimStr(cell.String())
+	//				}
+	//			}
+	//
+	//		}
+	//	}
+	//}
+
+	// TODO:新增登记
+
+	// TODO:新增套餐
+
+	// TODO:新增开票/到款信息
+}

+ 5 - 3
controller/crm/contract.go

@@ -79,15 +79,17 @@ func (rg *ContractController) SearchList(c *gin.Context) {
 			return
 		}
 		for i := range payList {
-			payCompanyMap[payList[i].PayOnBehalfContractId] = payList[i].CompanyName
-			payContractCodeMap[payList[i].PayOnBehalfContractId] = payList[i].ContractCode
+			payCompanyMap[payList[i].PaymentOnBehalfContractId] = payList[i].CompanyName
+			payContractCodeMap[payList[i].PaymentOnBehalfContractId] = payList[i].ContractCode
 		}
 	}
 
 	respList := make([]*crm.ContractSearchListResp, 0)
 	for i := range list {
+		contractType := list[i].ContractType
 		contractTypeKey := crm.ContractTypeFmsMap[list[i].ContractType]
 		if list[i].ContractBusinessType == "代付合同" {
+			contractType = "代付合同"
 			contractTypeKey = fms.ContractTypeAgentPay
 		}
 
@@ -101,7 +103,7 @@ func (rg *ContractController) SearchList(c *gin.Context) {
 			SellerId:        list[i].SellerId,
 			SellerName:      list[i].SellerName,
 			ContractTypeKey: contractTypeKey,
-			ContractType:    list[i].ContractType,
+			ContractType:    contractType,
 			Price:           list[i].Price,
 			StartDate:       utils.TimeTransferString(utils.FormatDate, list[i].StartDate),
 			EndDate:         utils.TimeTransferString(utils.FormatDate, list[i].EndDate),

+ 4 - 4
models/crm/contract.go

@@ -93,10 +93,10 @@ type ContractSearchListResp struct {
 
 // PayCompanyRelation 代付合同
 type PayCompanyRelation struct {
-	ContractId            int    `description:"代付合同ID"`
-	ContractCode          string `description:"代付合同编号"`
-	CompanyName           string `description:"代付方名称"`
-	PayOnBehalfContractId int    `description:"实际使用方合同ID"`
+	ContractId                int    `description:"代付合同ID"`
+	ContractCode              string `description:"代付合同编号"`
+	CompanyName               string `description:"代付方名称"`
+	PaymentOnBehalfContractId int    `description:"实际使用方合同ID"`
 }
 
 // GetPayCompanyByContractIds 通过合同IDs获取代付客户信息