|
@@ -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:新增开票/到款信息
|
|
|
+}
|