|
@@ -1005,14 +1005,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
// 生成Excel文件
|
|
|
- //dir, err := os.Executable()
|
|
|
- //exPath := filepath.Dir(dir)
|
|
|
- //filePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
xlsxFile := xlsx.NewFile()
|
|
|
- //if err != nil {
|
|
|
- // resp.FailData("生成文件失败", "Err:"+err.Error(), c)
|
|
|
- // return
|
|
|
- //}
|
|
|
style := xlsx.NewStyle()
|
|
|
alignment := xlsx.Alignment{
|
|
|
Horizontal: "center",
|
|
@@ -1022,53 +1015,53 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
style.Alignment = alignment
|
|
|
style.ApplyAlignment = true
|
|
|
|
|
|
- sheet, err := xlsxFile.AddSheet("合同登记")
|
|
|
+ sheetName := "财务列表"
|
|
|
+ sheet, err := xlsxFile.AddSheet(sheetName)
|
|
|
if err != nil {
|
|
|
resp.FailData("新增Sheet失败", "Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- //_ = sheet.SetColWidth(0, 0, 60)
|
|
|
- //_ = sheet.SetColWidth(4, 10, 60)
|
|
|
+
|
|
|
// 1行表头
|
|
|
titleRow := sheet.AddRow()
|
|
|
titleRow.SetHeight(40)
|
|
|
// 1行1列-右合并两格
|
|
|
cell1 := titleRow.AddCell()
|
|
|
- cell1.HMerge = 2
|
|
|
- cell1.SetValue("FICC客户签约表 2022")
|
|
|
+ cell1.HMerge = 3
|
|
|
+ cell1.SetString("FICC客户签约表 2022")
|
|
|
cell1.SetStyle(style)
|
|
|
// 右增两列空白格用于第一列合并, 否则后续单元格合并会有问题
|
|
|
- titleRow.AddCell().SetValue("")
|
|
|
- titleRow.AddCell().SetValue("")
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
|
|
// 1行2列
|
|
|
cell2 := titleRow.AddCell()
|
|
|
- cell2.SetValue("FICC大套餐")
|
|
|
+ cell2.SetString("FICC大套餐")
|
|
|
cell2.SetStyle(style)
|
|
|
|
|
|
// 1行3列-右合并小套餐数
|
|
|
if permissionLen >= 1 {
|
|
|
cell3 := titleRow.AddCell()
|
|
|
cell3.HMerge = permissionLen - 1
|
|
|
- cell3.SetValue("FICC小套餐")
|
|
|
+ cell3.SetString("FICC小套餐")
|
|
|
cell3.SetStyle(style)
|
|
|
// 同上右增单元格小套餐数-1的空白单元格用于合并
|
|
|
for i := 0; i < permissionLen-1; i++ {
|
|
|
- titleRow.AddCell().SetValue("")
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
}
|
|
|
}
|
|
|
- cell4 := titleRow.AddCell()
|
|
|
- cell4.SetValue("市场策略")
|
|
|
- cell4.SetStyle(style)
|
|
|
- cell5 := titleRow.AddCell()
|
|
|
- cell5.SetValue("财富管理")
|
|
|
- cell5.SetStyle(style)
|
|
|
+ for i := range otherService {
|
|
|
+ cellOther := titleRow.AddCell()
|
|
|
+ cellOther.SetString(otherService[i].Title)
|
|
|
+ cellOther.SetStyle(style)
|
|
|
+ }
|
|
|
|
|
|
// 第二行表头
|
|
|
titleRow2 := sheet.AddRow()
|
|
|
titleRow2.SetHeight(60)
|
|
|
row2Title := make([]string, 0)
|
|
|
- row2Title = append(row2Title, "客户名称", "续约-0\n新增-1", "销售", "FICC大套餐")
|
|
|
+ row2Title = append(row2Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n续约-0\n新增-1\n代付-2\n补充协议-3", "销售", "FICC大套餐")
|
|
|
for i := range permissionList {
|
|
|
row2Title = append(row2Title, permissionList[i].PermissionName)
|
|
|
}
|
|
@@ -1077,40 +1070,38 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
for i := range otherService {
|
|
|
row2Title = append(row2Title, otherService[i].Title)
|
|
|
}
|
|
|
- row2Title = append(row2Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "约定付款时间", "签订日", "签订月",
|
|
|
- "合同状态", "合同编号", "备注")
|
|
|
+ row2Title = append(row2Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "约定付款时间", "签订日", "合同状态",
|
|
|
+ "合同编号", "合规备注")
|
|
|
|
|
|
// 设置表头
|
|
|
for i := range row2Title {
|
|
|
v := titleRow2.AddCell()
|
|
|
- v.SetValue(row2Title[i])
|
|
|
+ v.SetString(row2Title[i])
|
|
|
v.SetStyle(style)
|
|
|
}
|
|
|
|
|
|
// 第二行表头-开票/收款(动态添加)
|
|
|
+ invoiceTitle := []string{"开票日", "开票金额", "销售", "备注"}
|
|
|
for i := 0; i < maxInvoice; i++ {
|
|
|
n := i + 1
|
|
|
- c1 := titleRow2.AddCell()
|
|
|
- t1 := fmt.Sprintf("%s%d", "开票日", n)
|
|
|
- c1.SetValue(t1)
|
|
|
- c1.SetStyle(style)
|
|
|
- c2 := titleRow2.AddCell()
|
|
|
- t2 := fmt.Sprintf("%s%d", "开票金额", n)
|
|
|
- c2.SetValue(t2)
|
|
|
- c2.SetStyle(style)
|
|
|
- row2Title = append(row2Title, t1, t2)
|
|
|
+ for ii := range invoiceTitle {
|
|
|
+ c := titleRow2.AddCell()
|
|
|
+ t := fmt.Sprintf("%s%d", invoiceTitle[ii], n)
|
|
|
+ c.SetString(t)
|
|
|
+ c.SetStyle(style)
|
|
|
+ row2Title = append(row2Title, t)
|
|
|
+ }
|
|
|
}
|
|
|
+ paymentTitle := []string{"到款日", "到款金额", "备注"}
|
|
|
for i := 0; i < maxPayment; i++ {
|
|
|
n := i + 1
|
|
|
- c1 := titleRow2.AddCell()
|
|
|
- t1 := fmt.Sprintf("%s%d", "收款日", n)
|
|
|
- c1.SetValue(t1)
|
|
|
- c1.SetStyle(style)
|
|
|
- c2 := titleRow2.AddCell()
|
|
|
- t2 := fmt.Sprintf("%s%d", "收款金额", n)
|
|
|
- c2.SetValue(t2)
|
|
|
- c2.SetStyle(style)
|
|
|
- row2Title = append(row2Title, t1, t2)
|
|
|
+ for ii := range paymentTitle {
|
|
|
+ c := titleRow2.AddCell()
|
|
|
+ t := fmt.Sprintf("%s%d", paymentTitle[ii], n)
|
|
|
+ c.SetString(t)
|
|
|
+ c.SetStyle(style)
|
|
|
+ row2Title = append(row2Title, t)
|
|
|
+ }
|
|
|
}
|
|
|
// 此处取第二行标题NameKeyMap, 后面的动态匹配
|
|
|
row2NameKeyMap := make(map[string]int)
|
|
@@ -1118,6 +1109,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
row2NameKeyMap[row2Title[i]] = i
|
|
|
}
|
|
|
|
|
|
+ newCompanyMap := map[int]string{0: "1", 1: "0"}
|
|
|
contractTMap := map[int]int{
|
|
|
fms.ContractTypeNew: 1,
|
|
|
fms.ContractTypeRenew: 0,
|
|
@@ -1125,11 +1117,12 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
fms.ContractTypePlus: 3, // 补充协议
|
|
|
}
|
|
|
for _, v := range list {
|
|
|
- k := -1
|
|
|
+ k := -1 // 套餐匹配用
|
|
|
dataRow := sheet.AddRow()
|
|
|
dataRow.SetHeight(20)
|
|
|
- k += 3
|
|
|
+ k += 4
|
|
|
dataRow.AddCell().SetString(v.CompanyName)
|
|
|
+ dataRow.AddCell().SetString(newCompanyMap[v.NewCompany])
|
|
|
dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.ContractType]))
|
|
|
dataRow.AddCell().SetString(v.SellerName)
|
|
|
|
|
@@ -1177,32 +1170,6 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
dataRow.AddCell().SetString(otherCol)
|
|
|
}
|
|
|
|
|
|
- // 财富管理/市场策略
|
|
|
- k += 1
|
|
|
- col5Name := row2Title[k]
|
|
|
- col5 := ""
|
|
|
- if svList != nil && len(svList) > 0 {
|
|
|
- for isv := range svList {
|
|
|
- if svList[isv].Title == col5Name {
|
|
|
- col5 = "是"
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- dataRow.AddCell().SetString(col5)
|
|
|
- k += 1
|
|
|
- col6Name := row2Title[k]
|
|
|
- col6 := ""
|
|
|
- if svList != nil && len(svList) > 0 {
|
|
|
- for isv := range svList {
|
|
|
- if svList[isv].Title == col6Name {
|
|
|
- col6 = "是"
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- dataRow.AddCell().SetString(col6)
|
|
|
-
|
|
|
// 其他信息
|
|
|
dataRow.AddCell().SetString(v.ServiceRemark) // 套餐备注
|
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.StartDate)) // 开始时间
|
|
@@ -1210,10 +1177,9 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
dataRow.AddCell().SetString(fmt.Sprint("¥", v.ContractAmount)) // 2022年合同金额
|
|
|
dataRow.AddCell().SetString(v.AgreedPayTime) // 约定付款时间
|
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.SignDate)) // 签订日
|
|
|
- dataRow.AddCell().SetString(utils.TimeTransferString("2006/01", v.SignDate)) // 签订月
|
|
|
dataRow.AddCell().SetString(fms.ContractStatusKeyNameMap[v.ContractStatus]) // 合同状态
|
|
|
dataRow.AddCell().SetString(v.ContractCode) // 合同编号
|
|
|
- dataRow.AddCell().SetString(v.Remark) // 备注
|
|
|
+ dataRow.AddCell().SetString(v.Remark) // 合规备注
|
|
|
|
|
|
// 开票/到款信息
|
|
|
ivList := invoiceMap[v.ContractRegisterId]
|
|
@@ -1223,24 +1189,30 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
if ia < ivListLen {
|
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", ivList[ia].InvoiceDate)) // 开票日
|
|
|
dataRow.AddCell().SetString(fmt.Sprint(ivList[ia].Amount)) // 开票金额
|
|
|
+ dataRow.AddCell().SetString(ivList[ia].SellerName) // 销售名称
|
|
|
+ dataRow.AddCell().SetString(ivList[ia].Remark) // 开票备注
|
|
|
} else {
|
|
|
// 这里要把不够的填充为空
|
|
|
dataRow.AddCell().SetString("")
|
|
|
dataRow.AddCell().SetString("")
|
|
|
+ dataRow.AddCell().SetString("")
|
|
|
+ dataRow.AddCell().SetString("")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
pyList := paymentMap[v.ContractRegisterId]
|
|
|
pyListLen := len(pyList)
|
|
|
if pyList != nil && pyListLen > 0 {
|
|
|
- for ib := 0; ib < maxInvoice; ib++ {
|
|
|
+ for ib := 0; ib < maxPayment; ib++ {
|
|
|
if ib < pyListLen {
|
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", pyList[ib].InvoiceDate)) // 收款日
|
|
|
dataRow.AddCell().SetString(fmt.Sprint(pyList[ib].Amount)) // 收款金额
|
|
|
+ dataRow.AddCell().SetString(pyList[ib].Remark) // 收款备注
|
|
|
} else {
|
|
|
// 已经是最后的几列了其实可以不用填充空, 万一后面要加列此处还是填充上吧
|
|
|
dataRow.AddCell().SetString("")
|
|
|
dataRow.AddCell().SetString("")
|
|
|
+ dataRow.AddCell().SetString("")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1250,16 +1222,8 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
var buffer bytes.Buffer
|
|
|
_ = xlsxFile.Write(&buffer)
|
|
|
content := bytes.NewReader(buffer.Bytes())
|
|
|
- //err = xlsxFile.Save(filePath)
|
|
|
- //if err != nil {
|
|
|
- // resp.FailData("保存文件失败", "Err:"+err.Error(), c)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // _ = os.Remove(filePath)
|
|
|
- //}()
|
|
|
randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
|
|
|
- fileName := "财务列表_" + randStr + ".xlsx"
|
|
|
+ fileName := sheetName + randStr + ".xlsx"
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, fileName))
|
|
|
c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
@@ -1412,13 +1376,13 @@ func (rg *RegisterController) InvoiceExport(c *gin.Context) {
|
|
|
titleRow := sheet.AddRow()
|
|
|
titleRow.SetHeight(40)
|
|
|
cell1 := titleRow.AddCell()
|
|
|
- cell1.SetValue("合同编号")
|
|
|
+ cell1.SetString("合同编号")
|
|
|
cell1.SetStyle(style)
|
|
|
cell2 := titleRow.AddCell()
|
|
|
- cell2.SetValue("开票金额")
|
|
|
+ cell2.SetString("开票金额")
|
|
|
cell2.SetStyle(style)
|
|
|
cell3 := titleRow.AddCell()
|
|
|
- cell3.SetValue("开票日期")
|
|
|
+ cell3.SetString("开票日期")
|
|
|
cell3.SetStyle(style)
|
|
|
|
|
|
for _, v := range list {
|
|
@@ -1493,17 +1457,15 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
contractCodeArr = append(contractCodeArr, registerList[i].ContractCode)
|
|
|
}
|
|
|
|
|
|
- // 获取所有销售名称Map
|
|
|
- sellerNameIdMap := make(map[string]int)
|
|
|
- sellerCond := ``
|
|
|
- sellerPars := make([]interface{}, 0)
|
|
|
- sellerList, e := crm.GetCompanySellerByRoleCodes(sellerCond, sellerPars)
|
|
|
+ // 获取所有销售Map
|
|
|
+ sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
|
|
|
if e != nil {
|
|
|
resp.FailData("获取销售列表失败", "Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+ sellerMap := make(map[string]*crm.SellerAdminWithGroupTeam)
|
|
|
for i := range sellerList {
|
|
|
- sellerNameIdMap[sellerList[i].RealName] = sellerList[i].AdminId
|
|
|
+ sellerMap[sellerList[i].SellerName] = sellerList[i]
|
|
|
}
|
|
|
|
|
|
// 获取品种权限Map
|
|
@@ -1535,10 +1497,10 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
serviceTempNameMap[serviceTempList[i].Title] = serviceTempList[i]
|
|
|
}
|
|
|
|
|
|
- // TODO:导入开票信息时的销售信息以及导入到款信息时的付款方式信息
|
|
|
-
|
|
|
titleMap := make(map[int]string)
|
|
|
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,
|
|
@@ -1546,6 +1508,19 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
"2": fms.ContractTypeAgentPay,
|
|
|
"3": fms.ContractTypePlus,
|
|
|
}
|
|
|
+
|
|
|
+ // 更新登记状态
|
|
|
+ defer func() {
|
|
|
+ if len(newIds) > 0 {
|
|
|
+ go func() {
|
|
|
+ for i := range newIds {
|
|
|
+ fmsService.CheckContractRegisterAmount(newIds[i])
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ invoiceMax := 3
|
|
|
checkDate := time.Date(1900, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
for _, sheet := range xlFile.Sheets {
|
|
|
// 遍历行读取
|
|
@@ -1558,28 +1533,34 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
for k, cell := range cells {
|
|
|
text := cell.String()
|
|
|
titleMap[k] = text
|
|
|
- // 只检验前面部分表头
|
|
|
+ // 只检验前面部分表头, 后面很多动态列
|
|
|
if k == 0 {
|
|
|
if text != "客户名称" {
|
|
|
- resp.Fail("匹配失败, 请按模板导入", c)
|
|
|
+ resp.Fail("【客户名称】列名称有误, 请参考模板导入", c)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if k == 1 {
|
|
|
- if !strings.Contains(text, "续约") {
|
|
|
- resp.Fail("匹配失败, 请按模板导入", c)
|
|
|
+ if !strings.Contains(text, "新客户") {
|
|
|
+ resp.Fail("【新客户】列名称有误, 请参考模板导入", c)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if k == 2 {
|
|
|
- if text != "销售" {
|
|
|
- resp.Fail("匹配失败, 请按模板导入", c)
|
|
|
+ if !strings.Contains(text, "合同类型") {
|
|
|
+ resp.Fail("【合同类型】列名称有误, 请参考模板导入", c)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
if k == 3 {
|
|
|
+ if text != "销售" {
|
|
|
+ resp.Fail("【销售】列名称有误, 请参考模板导入", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if k == 4 {
|
|
|
if text != "FICC大套餐" {
|
|
|
- resp.Fail("匹配失败, 请按模板导入", c)
|
|
|
+ resp.Fail("【FICC大套餐】列名称有误, 请参考模板导入", c)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -1596,14 +1577,15 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
rowServices := make([]*fms.ContractService, 0)
|
|
|
// 开票/到款
|
|
|
rowInvoices := make([]*fms.ContractInvoice, 0)
|
|
|
-
|
|
|
+ for ir := 0; ir < invoiceMax; ir++ {
|
|
|
+ rowInvoices = append(rowInvoices, new(fms.ContractInvoice))
|
|
|
+ }
|
|
|
+ rowPayments := make([]*fms.ContractInvoice, 0)
|
|
|
+ for ir := 0; ir < invoiceMax; ir++ {
|
|
|
+ rowPayments = append(rowPayments, new(fms.ContractInvoice))
|
|
|
+ }
|
|
|
+ // 小套餐权限
|
|
|
rowChartPermissionIdArr := make([]string, 0)
|
|
|
- rowInvoice1 := new(fms.ContractInvoice)
|
|
|
- rowInvoice2 := new(fms.ContractInvoice)
|
|
|
- rowInvoice3 := new(fms.ContractInvoice)
|
|
|
- rowInvoice4 := new(fms.ContractInvoice)
|
|
|
- rowInvoice5 := new(fms.ContractInvoice)
|
|
|
- rowInvoice6 := new(fms.ContractInvoice)
|
|
|
|
|
|
isSkip := false
|
|
|
for k, cell := range cells {
|
|
@@ -1617,8 +1599,17 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
rowRegister.CompanyName = v
|
|
|
continue
|
|
|
}
|
|
|
- // 续约/新增
|
|
|
+ // 是否新客户
|
|
|
if k == 1 {
|
|
|
+ if !utils.InArrayByStr(newCompanyArr, v) {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行新客户有误, 请按模板导入", i+1), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rowRegister.NewCompany = newCompanyMap[v]
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 合同类型
|
|
|
+ if k == 2 {
|
|
|
if !utils.InArrayByStr(contractTypeArr, v) {
|
|
|
resp.Fail(fmt.Sprintf("第%d行合同类型有误, 请按模板导入", i+1), c)
|
|
|
return
|
|
@@ -1631,21 +1622,22 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 销售
|
|
|
- if k == 2 {
|
|
|
+ if k == 3 {
|
|
|
if v == "" {
|
|
|
resp.Fail(fmt.Sprintf("第%d行销售名称不可为空, 请按模板导入", i+1), c)
|
|
|
return
|
|
|
}
|
|
|
- rowRegister.SellerName = v
|
|
|
- rowRegister.SellerId = sellerNameIdMap[rowRegister.SellerName]
|
|
|
- if rowRegister.SellerId == 0 {
|
|
|
+ sellerItem := sellerMap[v]
|
|
|
+ if sellerItem == nil {
|
|
|
resp.Fail(fmt.Sprintf("第%d行销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
|
|
|
return
|
|
|
}
|
|
|
+ rowRegister.SellerId = sellerItem.SellerId
|
|
|
+ rowRegister.SellerName = sellerItem.SellerName
|
|
|
continue
|
|
|
}
|
|
|
// FICC大套餐
|
|
|
- if k == 3 {
|
|
|
+ if k == 4 {
|
|
|
if v == "是" {
|
|
|
tempItem := serviceTempNameMap[titleMap[k]]
|
|
|
if tempItem == nil {
|
|
@@ -1666,7 +1658,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// FICC小套餐
|
|
|
- if k >= 4 && k <= 23 {
|
|
|
+ if k >= 5 && k <= 25 {
|
|
|
// 小套餐权限
|
|
|
if v == "是" {
|
|
|
rowChartPermissionIdArr = append(rowChartPermissionIdArr, strconv.Itoa(chartPermissionNameIdMap[titleMap[k]]))
|
|
@@ -1674,7 +1666,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 其他类型套餐
|
|
|
- if k >= 24 && k <= 30 {
|
|
|
+ if k >= 26 && k <= 32 {
|
|
|
if v == "是" {
|
|
|
tempItem := serviceTempNameMap[titleMap[k]]
|
|
|
if tempItem == nil {
|
|
@@ -1695,12 +1687,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 套餐备注
|
|
|
- if k == 31 {
|
|
|
+ if k == 33 {
|
|
|
rowRegister.ServiceRemark = v
|
|
|
continue
|
|
|
}
|
|
|
// 开始时间/到期时间
|
|
|
- if k == 32 {
|
|
|
+ if k == 34 {
|
|
|
// 转换失败可能是因为格式为Excel日期格式, 读取出来会是一串数字, 将其转换成日期字符串再处理
|
|
|
va := cell.Value
|
|
|
if va == "" {
|
|
@@ -1724,7 +1716,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
rowRegister.StartDate = startDate
|
|
|
continue
|
|
|
}
|
|
|
- if k == 33 {
|
|
|
+ if k == 35 {
|
|
|
va := cell.Value
|
|
|
if va == "" {
|
|
|
resp.Fail(fmt.Sprintf("第%d行到期时间不可为空, 请按模板导入", i+1), c)
|
|
@@ -1747,7 +1739,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 合同金额
|
|
|
- if k == 34 {
|
|
|
+ if k == 36 {
|
|
|
amountStr := v
|
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
if e != nil {
|
|
@@ -1758,13 +1750,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 约定付款日期
|
|
|
- if k == 35 {
|
|
|
+ if k == 37 {
|
|
|
rowRegister.AgreedPayTime = v
|
|
|
continue
|
|
|
}
|
|
|
// 签订日
|
|
|
- // k == 32为签订月,可忽略
|
|
|
- if k == 36 {
|
|
|
+ if k == 38 {
|
|
|
va := cell.Value
|
|
|
if va == "" {
|
|
|
continue
|
|
@@ -1786,7 +1777,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 合同状态
|
|
|
- if k == 38 {
|
|
|
+ if k == 39 {
|
|
|
rowRegister.ContractStatus = fms.ContractStatusNameKeyMap[v]
|
|
|
if rowRegister.ContractStatus == 0 {
|
|
|
resp.Fail(fmt.Sprintf("第%d行合同状态不匹配, 请按模板导入", i+1), c)
|
|
@@ -1795,7 +1786,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
// 合同编号
|
|
|
- if k == 39 {
|
|
|
+ if k == 40 {
|
|
|
rowContractCode := v
|
|
|
if rowContractCode == "" {
|
|
|
resp.Fail(fmt.Sprintf("第%d行合同编号不可为空, 请按模板导入", i+1), c)
|
|
@@ -1809,210 +1800,129 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
rowRegister.ContractCode = rowContractCode
|
|
|
continue
|
|
|
}
|
|
|
- // 备注
|
|
|
- if k == 40 {
|
|
|
+ // 合规备注
|
|
|
+ if k == 41 {
|
|
|
rowRegister.Remark = v
|
|
|
continue
|
|
|
}
|
|
|
- // 开票日/开票金额
|
|
|
- if k == 41 {
|
|
|
- if v != "" {
|
|
|
- va := cell.Value
|
|
|
- invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
- if e != nil {
|
|
|
- d := utils.ConvertToFormatDay(va, "2006/01/02")
|
|
|
- invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
+ // 开票列表
|
|
|
+ k2 := 41
|
|
|
+ for ir := 0; ir < invoiceMax; ir++ {
|
|
|
+ n := ir + 1
|
|
|
+ // 开票日
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ va := cell.Value
|
|
|
+ invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票时间1格式转换有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
+ d := utils.ConvertToFormatDay(va, "2006/01/02")
|
|
|
+ invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行开票时间%d格式转换有误, 请按模板导入", i+1, n), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if invoiceDate.Before(checkDate) {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票时间1格式有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice1.InvoiceDate = invoiceDate
|
|
|
- rowInvoice1.ContractCode = rowRegister.ContractCode
|
|
|
- rowInvoice1.InvoiceType = fms.ContractInvoiceTypeMake
|
|
|
- }
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 42 && v != "" {
|
|
|
- amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票金额1有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice1.Amount = amount
|
|
|
- rowInvoices = append(rowInvoices, rowInvoice1)
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 43 {
|
|
|
- if v != "" {
|
|
|
- va := cell.Value
|
|
|
- invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
- if e != nil {
|
|
|
- d := utils.ConvertToFormatDay(va, "2006/01/02") //录入日期
|
|
|
- invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票时间2格式转换有误, 请按模板导入", i+1), c)
|
|
|
+ if invoiceDate.Before(checkDate) {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行开票时间%d格式有误, 请按模板导入", i+1, n), c)
|
|
|
return
|
|
|
}
|
|
|
+ rowInvoices[ir].InvoiceDate = invoiceDate
|
|
|
+ rowInvoices[ir].ContractCode = rowRegister.ContractCode
|
|
|
+ rowInvoices[ir].InvoiceType = fms.ContractInvoiceTypeMake
|
|
|
}
|
|
|
- if invoiceDate.Before(checkDate) {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票时间2格式有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice2.InvoiceDate = invoiceDate
|
|
|
- rowInvoice2.ContractCode = rowRegister.ContractCode
|
|
|
- rowInvoice2.InvoiceType = fms.ContractInvoiceTypeMake
|
|
|
- }
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 44 && v != "" {
|
|
|
- amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票金额2有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
+ continue
|
|
|
}
|
|
|
- rowInvoice2.Amount = amount
|
|
|
- rowInvoices = append(rowInvoices, rowInvoice2)
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 45 {
|
|
|
- if v != "" {
|
|
|
- va := cell.Value
|
|
|
- invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
- if e != nil {
|
|
|
- d := utils.ConvertToFormatDay(va, "2006/01/02") //录入日期
|
|
|
- invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
+ // 开票金额
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ amountStr := v
|
|
|
+ amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票时间3格式转换有误, 请按模板导入", i+1), c)
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行开票金额%d有误, 请按模板导入", i+1, n), c)
|
|
|
return
|
|
|
}
|
|
|
+ rowInvoices[ir].Amount = amount
|
|
|
}
|
|
|
- if invoiceDate.Before(checkDate) {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票时间3格式有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice3.InvoiceDate = invoiceDate
|
|
|
- rowInvoice3.ContractCode = rowRegister.ContractCode
|
|
|
- rowInvoice3.InvoiceType = fms.ContractInvoiceTypeMake
|
|
|
- }
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 46 && v != "" {
|
|
|
- amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行开票金额3有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
+ continue
|
|
|
}
|
|
|
- rowInvoice3.Amount = amount
|
|
|
- rowInvoices = append(rowInvoices, rowInvoice3)
|
|
|
- continue
|
|
|
- }
|
|
|
- // 收款日/收款金额
|
|
|
- if k == 47 {
|
|
|
- if v != "" {
|
|
|
- va := cell.Value
|
|
|
- invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
- if e != nil {
|
|
|
- d := utils.ConvertToFormatDay(va, "2006/01/02") //录入日期
|
|
|
- invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款时间1格式转换有误, 请按模板导入", i+1), c)
|
|
|
+ // 开票销售
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ sellerItem := sellerMap[v]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行开票销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
|
|
|
return
|
|
|
}
|
|
|
+ rowInvoices[ir].SellerId = sellerItem.SellerId
|
|
|
+ rowInvoices[ir].SellerName = sellerItem.SellerName
|
|
|
+ rowInvoices[ir].SellerGroupId = sellerItem.GroupId
|
|
|
+ rowInvoices[ir].SellerGroupName = sellerItem.GroupName
|
|
|
+ rowInvoices[ir].SellerTeamId = sellerItem.TeamId
|
|
|
+ rowInvoices[ir].SellerTeamName = sellerItem.TeamName
|
|
|
}
|
|
|
- if invoiceDate.Before(checkDate) {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款时间1格式有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice4.InvoiceDate = invoiceDate
|
|
|
- rowInvoice4.ContractCode = rowRegister.ContractCode
|
|
|
- rowInvoice4.InvoiceType = fms.ContractInvoiceTypePay
|
|
|
+ continue
|
|
|
}
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 48 && v != "" {
|
|
|
- amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款金额1有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
+ // 备注
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ rowInvoices[ir].Remark = v
|
|
|
+ }
|
|
|
+ continue
|
|
|
}
|
|
|
- rowInvoice4.Amount = amount
|
|
|
- rowInvoices = append(rowInvoices, rowInvoice4)
|
|
|
- continue
|
|
|
}
|
|
|
- if k == 49 {
|
|
|
- if v != "" {
|
|
|
- va := cell.Value
|
|
|
- invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
- if e != nil {
|
|
|
- d := utils.ConvertToFormatDay(va, "2006/01/02") //录入日期
|
|
|
- invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
+ // 到款列表
|
|
|
+ for ir := 0; ir < invoiceMax; ir++ {
|
|
|
+ n := ir + 1
|
|
|
+ // 到款日
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ va := cell.Value
|
|
|
+ invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款时间2格式转换有误, 请按模板导入", i+1), c)
|
|
|
+ d := utils.ConvertToFormatDay(va, "2006/01/02")
|
|
|
+ invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行到款时间%d格式转换有误, 请按模板导入", i+1, n), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if invoiceDate.Before(checkDate) {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行到款时间%d格式有误, 请按模板导入", i+1, n), c)
|
|
|
return
|
|
|
}
|
|
|
+ rowPayments[ir].InvoiceDate = invoiceDate
|
|
|
+ rowPayments[ir].ContractCode = rowRegister.ContractCode
|
|
|
+ rowPayments[ir].InvoiceType = fms.ContractInvoiceTypePay
|
|
|
}
|
|
|
- if invoiceDate.Before(checkDate) {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款时间2格式有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice5.InvoiceDate = invoiceDate
|
|
|
- rowInvoice5.ContractCode = rowRegister.ContractCode
|
|
|
- rowInvoice5.InvoiceType = fms.ContractInvoiceTypePay
|
|
|
- }
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 50 && v != "" {
|
|
|
- amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款金额2有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
+ continue
|
|
|
}
|
|
|
- rowInvoice5.Amount = amount
|
|
|
- rowInvoices = append(rowInvoices, rowInvoice5)
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 51 {
|
|
|
- if v != "" {
|
|
|
- va := cell.Value
|
|
|
- invoiceDate, e := time.ParseInLocation("2006/01/02", va, time.Local)
|
|
|
- if e != nil {
|
|
|
- d := utils.ConvertToFormatDay(va, "2006/01/02") //录入日期
|
|
|
- invoiceDate, e = time.ParseInLocation("2006/01/02", d, time.Local)
|
|
|
+ // 到款金额
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ amountStr := v
|
|
|
+ amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款时间3格式转换有误, 请按模板导入", i+1), c)
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行到款金额%d有误, 请按模板导入", i+1, n), c)
|
|
|
return
|
|
|
}
|
|
|
+ rowPayments[ir].Amount = amount
|
|
|
}
|
|
|
- if invoiceDate.Before(checkDate) {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款时间3格式有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
- rowInvoice6.InvoiceDate = invoiceDate
|
|
|
- rowInvoice6.ContractCode = rowRegister.ContractCode
|
|
|
- rowInvoice6.InvoiceType = fms.ContractInvoiceTypePay
|
|
|
+ continue
|
|
|
}
|
|
|
- continue
|
|
|
- }
|
|
|
- if k == 52 && v != "" {
|
|
|
- amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行收款金额3有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
+ // 备注
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ rowPayments[ir].Remark = v
|
|
|
+ }
|
|
|
+ continue
|
|
|
}
|
|
|
- rowInvoice6.Amount = amount
|
|
|
- rowInvoices = append(rowInvoices, rowInvoice6)
|
|
|
- continue
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2049,8 +1959,20 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
rowRegister.RegisterStatus = fms.ContractRegisterStatusIng
|
|
|
+ lastInvoices := make([]*fms.ContractInvoice, 0)
|
|
|
+ // 过滤信息不完整的开票到款
|
|
|
+ for l := range rowInvoices {
|
|
|
+ if rowInvoices[l].ContractCode != "" && rowInvoices[l].SellerId > 0 {
|
|
|
+ lastInvoices = append(lastInvoices, rowInvoices[l])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for l := range rowPayments {
|
|
|
+ if rowPayments[l].ContractCode != "" {
|
|
|
+ lastInvoices = append(lastInvoices, rowPayments[l])
|
|
|
+ }
|
|
|
+ }
|
|
|
// 新增登记、套餐、开票到款信息
|
|
|
- newId, e := fms.CreateImportContractRegister(rowRegister, rowServices, rowInvoices)
|
|
|
+ newId, e := fms.CreateImportContractRegister(rowRegister, rowServices, lastInvoices)
|
|
|
if e != nil {
|
|
|
resp.FailData(fmt.Sprintf("第%d行导入失败", i+1), "新增导入登记失败, Err: "+e.Error(), c)
|
|
|
return
|
|
@@ -2060,12 +1982,5 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 更新登记状态
|
|
|
- go func() {
|
|
|
- for i := range newIds {
|
|
|
- fmsService.CheckContractRegisterAmount(newIds[i])
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
resp.Ok("操作成功", c)
|
|
|
}
|