|
@@ -75,8 +75,9 @@ func (rg *RegisterController) List(c *gin.Context) {
|
|
pars = append(pars, req.RegisterStatus)
|
|
pars = append(pars, req.RegisterStatus)
|
|
}
|
|
}
|
|
// 套餐筛选
|
|
// 套餐筛选
|
|
- if req.ServiceType != 0 {
|
|
|
|
- registerIds, e := fms.GetContractRegisterIdsByTempId(req.ServiceType)
|
|
|
|
|
|
+ if req.ServiceTypes != "" {
|
|
|
|
+ serviceTypes := strings.Split(req.ServiceTypes, ",")
|
|
|
|
+ registerIds, e := fms.GetContractRegisterIdsByTempId(serviceTypes)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailMsg("获取失败", "获取合同登记IDs失败, Err: "+e.Error(), c)
|
|
resp.FailMsg("获取失败", "获取合同登记IDs失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|
|
@@ -242,9 +243,11 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
ob.ContractSource = req.ContractSource
|
|
ob.ContractSource = req.ContractSource
|
|
ob.CompanyName = req.CompanyName
|
|
ob.CompanyName = req.CompanyName
|
|
ob.ActualCompanyName = req.ActualCompanyName
|
|
ob.ActualCompanyName = req.ActualCompanyName
|
|
- ob.ProductId = req.ProductId
|
|
|
|
|
|
+ ob.ProductIds = req.ProductIds
|
|
ob.SellerId = req.SellerId
|
|
ob.SellerId = req.SellerId
|
|
ob.SellerName = req.SellerName
|
|
ob.SellerName = req.SellerName
|
|
|
|
+ ob.RaiSellerId = req.RaiSellerId
|
|
|
|
+ ob.RaiSellerName = req.RaiSellerName
|
|
ob.ContractType = req.ContractType
|
|
ob.ContractType = req.ContractType
|
|
ob.ContractAmount = req.ContractAmount
|
|
ob.ContractAmount = req.ContractAmount
|
|
ob.CurrencyUnit = req.CurrencyUnit
|
|
ob.CurrencyUnit = req.CurrencyUnit
|
|
@@ -265,15 +268,22 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
ob.RegisterStatus = fms.ContractRegisterStatusComplete
|
|
ob.RegisterStatus = fms.ContractRegisterStatusComplete
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 新增套餐金额详情内容
|
|
|
|
+ serviceAmountMap := make(map[int]float64)
|
|
|
|
+ serviceAmountList, e := fmsService.HandleContractServiceAmount(req.ServiceAmount, serviceAmountMap, req.CurrencyUnit)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "新增合同套餐金额信息失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
// 套餐信息
|
|
// 套餐信息
|
|
- serviceList, e := fmsService.HandleContractServiceAndDetail(req.ProductId, req.Services, true)
|
|
|
|
|
|
+ serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// 新增合同及套餐
|
|
// 新增合同及套餐
|
|
- if e = fms.CreateContractRegisterAndServices(ob, serviceList); e != nil {
|
|
|
|
|
|
+ if e = fms.CreateContractRegisterAndServices(ob, serviceList, serviceAmountList); e != nil {
|
|
resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
|
|
resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -370,11 +380,12 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
originHasPayment := item.HasPayment
|
|
originHasPayment := item.HasPayment
|
|
|
|
|
|
updateCols := []string{
|
|
updateCols := []string{
|
|
- "ContractCode", "RelateContractCode", "CrmContractId", "ContractSource", "CompanyName", "ActualCompanyName",
|
|
|
|
|
|
+ "ProductIds","ContractCode", "RelateContractCode", "CrmContractId", "ContractSource", "CompanyName", "ActualCompanyName",
|
|
"SellerId", "SellerName", "ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime",
|
|
"SellerId", "SellerName", "ContractType", "ContractAmount", "StartDate", "EndDate", "SignDate", "AgreedPayTime",
|
|
"ContractStatus", "RegisterStatus", "Remark", "ServiceRemark", "HasPayment", "NewCompany", "ModifyTime",
|
|
"ContractStatus", "RegisterStatus", "Remark", "ServiceRemark", "HasPayment", "NewCompany", "ModifyTime",
|
|
}
|
|
}
|
|
nowTime := time.Now().Local()
|
|
nowTime := time.Now().Local()
|
|
|
|
+ item.ProductIds = req.ProductIds
|
|
item.ContractCode = req.ContractCode
|
|
item.ContractCode = req.ContractCode
|
|
item.RelateContractCode = req.RelateContractCode
|
|
item.RelateContractCode = req.RelateContractCode
|
|
item.CrmContractId = req.CrmContractId
|
|
item.CrmContractId = req.CrmContractId
|
|
@@ -383,6 +394,8 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
item.ActualCompanyName = req.ActualCompanyName
|
|
item.ActualCompanyName = req.ActualCompanyName
|
|
item.SellerId = req.SellerId
|
|
item.SellerId = req.SellerId
|
|
item.SellerName = req.SellerName
|
|
item.SellerName = req.SellerName
|
|
|
|
+ item.RaiSellerId = req.RaiSellerId
|
|
|
|
+ item.RaiSellerName = req.RaiSellerName
|
|
item.ContractType = req.ContractType
|
|
item.ContractType = req.ContractType
|
|
item.ContractAmount = req.ContractAmount
|
|
item.ContractAmount = req.ContractAmount
|
|
item.StartDate = startDate
|
|
item.StartDate = startDate
|
|
@@ -455,16 +468,23 @@ func (rg *RegisterController) Edit(c *gin.Context) {
|
|
logRemark = fmt.Sprintf("金额单位由%s修改为%s\n%s", item.CurrencyUnit, req.CurrencyUnit, logRemark)
|
|
logRemark = fmt.Sprintf("金额单位由%s修改为%s\n%s", item.CurrencyUnit, req.CurrencyUnit, logRemark)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 新增套餐金额详情内容
|
|
|
|
+ serviceAmountMap := make(map[int]float64)
|
|
|
|
+ serviceAmountList, e := fmsService.HandleContractServiceAmount(req.ServiceAmount, serviceAmountMap, req.CurrencyUnit)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("操作失败", "新增合同套餐金额信息失败, Err: "+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
// 套餐信息
|
|
// 套餐信息
|
|
- serviceList, e := fmsService.HandleContractServiceAndDetail(req.ProductId, req.Services, true)
|
|
|
|
|
|
+ serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// 更新合同登记、套餐、开票到款
|
|
// 更新合同登记、套餐、开票到款
|
|
- if e = fms.UpdateContractRegister(item, updateCols, serviceList, invoiceList, invoiceUpdateCols, invoiceHandleType); e != nil {
|
|
|
|
|
|
+ if e = fms.UpdateContractRegister(item, updateCols, serviceList, invoiceList, invoiceUpdateCols, invoiceHandleType, serviceAmountList); e != nil {
|
|
resp.FailMsg("操作失败", "更新合同及套餐失败, Err: "+e.Error(), c)
|
|
resp.FailMsg("操作失败", "更新合同及套餐失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -949,8 +969,9 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
cond += ` AND register_status = ?`
|
|
cond += ` AND register_status = ?`
|
|
pars = append(pars, req.RegisterStatus)
|
|
pars = append(pars, req.RegisterStatus)
|
|
}
|
|
}
|
|
- if req.ServiceType != 0 {
|
|
|
|
- registerIds, e := fms.GetContractRegisterIdsByTempId(req.ServiceType)
|
|
|
|
|
|
+ if req.ServiceTypes != "" {
|
|
|
|
+ serviceTypes := strings.Split(req.ServiceTypes, ",")
|
|
|
|
+ registerIds, e := fms.GetContractRegisterIdsByTempId(serviceTypes)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailMsg("获取失败", "获取合同登记IDs失败, Err: "+e.Error(), c)
|
|
resp.FailMsg("获取失败", "获取合同登记IDs失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|
|
@@ -995,7 +1016,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
permissionNameIdMap[permissionList[i].PermissionName] = permissionList[i].ChartPermissionId
|
|
permissionNameIdMap[permissionList[i].PermissionName] = permissionList[i].ChartPermissionId
|
|
}
|
|
}
|
|
|
|
|
|
- // 获取套餐服务
|
|
|
|
|
|
+ // 获取所有FICC套餐服务
|
|
serviceList, e := fms.GetContractServiceTemplateMapByProductId(crm.CompanyProductFicc)
|
|
serviceList, e := fms.GetContractServiceTemplateMapByProductId(crm.CompanyProductFicc)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailData("获取套餐服务失败", "Err:"+e.Error(), c)
|
|
resp.FailData("获取套餐服务失败", "Err:"+e.Error(), c)
|
|
@@ -1010,6 +1031,47 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
}
|
|
}
|
|
otherServiceLen := len(otherService)
|
|
otherServiceLen := len(otherService)
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // 获取所有权益套餐服务
|
|
|
|
+ raiServiceList, e := fms.GetContractServiceTemplateMapByProductId(crm.CompanyProductRai)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailData("获取权益套餐服务失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 除大小套餐外的其他套餐(下面的导出需要以此动态处理)
|
|
|
|
+ raiOtherService := make([]*fms.ContractServiceTemplateItem, 0)
|
|
|
|
+ for i := range raiServiceList {
|
|
|
|
+ //获取二级套餐
|
|
|
|
+ secondServiceList, e := fms.GetContractServiceTemplateMapByParentId(raiServiceList[i].ServiceTemplateId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailData("获取二级权益套餐服务失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(secondServiceList) > 0 {
|
|
|
|
+ for _, sv := range secondServiceList {
|
|
|
|
+ //获取三级套餐
|
|
|
|
+ thirdServiceList, e := fms.GetContractServiceTemplateMapByParentId(sv.ServiceTemplateId)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailData("获取三级权益套餐服务失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if len(thirdServiceList) > 0 {
|
|
|
|
+ for _, tv := range thirdServiceList {
|
|
|
|
+ raiOtherService = append(raiOtherService, tv)
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ raiOtherService = append(raiOtherService, sv)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ raiOtherService = append(raiOtherService, raiServiceList[i])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ otherServiceLen += len(raiOtherService)
|
|
|
|
+
|
|
|
|
+ //套餐金额map
|
|
|
|
+ serviceAmountMap := make(map[int]map[int]*fms.ContractServiceAmount)
|
|
|
|
+
|
|
// 套餐/开票/到款列表
|
|
// 套餐/开票/到款列表
|
|
serviceMap := make(map[int][]*fms.ContractService)
|
|
serviceMap := make(map[int][]*fms.ContractService)
|
|
serviceChartPermissionsMap := make(map[int][]int)
|
|
serviceChartPermissionsMap := make(map[int][]int)
|
|
@@ -1044,6 +1106,18 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 获取合同的套餐金额信息
|
|
|
|
+ serviceAmountList, e := fms.GetContractServiceAmountByContractRegisterIds(registerIds)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailData("获取合同的套餐金额信息失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ for _, v := range serviceAmountList {
|
|
|
|
+ if _, ok := serviceAmountMap[v.ContractRegisterId]; !ok {
|
|
|
|
+ serviceAmountMap[v.ContractRegisterId] = make(map[int]*fms.ContractServiceAmount)
|
|
|
|
+ }
|
|
|
|
+ serviceAmountMap[v.ContractRegisterId][v.ProductId] = v
|
|
|
|
+ }
|
|
// 获取开票/到款详情, 并取最大的开票/到款数(用于动态扩展第二列表头)
|
|
// 获取开票/到款详情, 并取最大的开票/到款数(用于动态扩展第二列表头)
|
|
ci := new(fms.ContractInvoice)
|
|
ci := new(fms.ContractInvoice)
|
|
invoiceList, e := ci.List(csCond, csPars, "")
|
|
invoiceList, e := ci.List(csCond, csPars, "")
|
|
@@ -1100,76 +1174,149 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
}
|
|
}
|
|
|
|
|
|
// 1行表头
|
|
// 1行表头
|
|
|
|
+ hInt := 0
|
|
titleRow := sheet.AddRow()
|
|
titleRow := sheet.AddRow()
|
|
titleRow.SetHeight(40)
|
|
titleRow.SetHeight(40)
|
|
- // 1行1列-右合并两格
|
|
|
|
|
|
+ // 1行1列-右合并两格, 下合并1行
|
|
cell1 := titleRow.AddCell()
|
|
cell1 := titleRow.AddCell()
|
|
- cell1.HMerge = 3
|
|
|
|
|
|
+ cell1.HMerge = 4
|
|
|
|
+ cell1.VMerge = 1
|
|
cell1.SetString("FICC客户签约表")
|
|
cell1.SetString("FICC客户签约表")
|
|
cell1.SetStyle(style)
|
|
cell1.SetStyle(style)
|
|
// 右增两列空白格用于第一列合并, 否则后续单元格合并会有问题
|
|
// 右增两列空白格用于第一列合并, 否则后续单元格合并会有问题
|
|
titleRow.AddCell().SetString("")
|
|
titleRow.AddCell().SetString("")
|
|
titleRow.AddCell().SetString("")
|
|
titleRow.AddCell().SetString("")
|
|
titleRow.AddCell().SetString("")
|
|
titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ hInt += 5
|
|
|
|
|
|
// 1行2列
|
|
// 1行2列
|
|
cell2 := titleRow.AddCell()
|
|
cell2 := titleRow.AddCell()
|
|
|
|
+ cell2.VMerge = 1
|
|
cell2.SetString("FICC大套餐")
|
|
cell2.SetString("FICC大套餐")
|
|
cell2.SetStyle(style)
|
|
cell2.SetStyle(style)
|
|
-
|
|
|
|
|
|
+ hInt ++
|
|
// 1行3列-右合并小套餐数
|
|
// 1行3列-右合并小套餐数
|
|
if permissionLen >= 1 {
|
|
if permissionLen >= 1 {
|
|
cell3 := titleRow.AddCell()
|
|
cell3 := titleRow.AddCell()
|
|
|
|
+ hInt ++
|
|
cell3.HMerge = permissionLen - 1
|
|
cell3.HMerge = permissionLen - 1
|
|
|
|
+ cell3.VMerge = 1
|
|
cell3.SetString("FICC小套餐")
|
|
cell3.SetString("FICC小套餐")
|
|
cell3.SetStyle(style)
|
|
cell3.SetStyle(style)
|
|
// 同上右增单元格小套餐数-1的空白单元格用于合并
|
|
// 同上右增单元格小套餐数-1的空白单元格用于合并
|
|
for i := 0; i < permissionLen-1; i++ {
|
|
for i := 0; i < permissionLen-1; i++ {
|
|
titleRow.AddCell().SetString("")
|
|
titleRow.AddCell().SetString("")
|
|
|
|
+ hInt ++
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for i := range otherService {
|
|
for i := range otherService {
|
|
cellOther := titleRow.AddCell()
|
|
cellOther := titleRow.AddCell()
|
|
|
|
+ cellOther.VMerge = 1
|
|
|
|
+ hInt ++
|
|
cellOther.SetString(otherService[i].Title)
|
|
cellOther.SetString(otherService[i].Title)
|
|
cellOther.SetStyle(style)
|
|
cellOther.SetStyle(style)
|
|
}
|
|
}
|
|
|
|
|
|
- // 第二行表头
|
|
|
|
|
|
+ //权益大套餐
|
|
|
|
+ cell4 := titleRow.AddCell()
|
|
|
|
+ cell4.HMerge = 1
|
|
|
|
+ cell4.VMerge = 1
|
|
|
|
+ cell4.SetString("权益大套餐")
|
|
|
|
+ cell4.SetStyle(style)
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ hInt +=2
|
|
|
|
+
|
|
|
|
+ //权益分行业套餐
|
|
|
|
+ cell5 := titleRow.AddCell()
|
|
|
|
+ cell5.HMerge = 8
|
|
|
|
+ cell5.SetString("权益分行业套餐")
|
|
|
|
+ cell5.SetStyle(style)
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+ titleRow.AddCell().SetString("")
|
|
|
|
+
|
|
|
|
+ //第二行,前面几个单元格用于第一行的合并
|
|
titleRow2 := sheet.AddRow()
|
|
titleRow2 := sheet.AddRow()
|
|
- titleRow2.SetHeight(60)
|
|
|
|
- row2Title := make([]string, 0)
|
|
|
|
- row2Title = append(row2Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n续约-0\n新增-1\n代付-2\n补充协议-3", "销售", "FICC大套餐")
|
|
|
|
|
|
+ titleRow2.SetHeight(30)
|
|
|
|
+ for i:= 0; i<hInt;i++ {
|
|
|
|
+ titleRow2.AddCell().SetString("")
|
|
|
|
+ }
|
|
|
|
+ //权益分行业套餐
|
|
|
|
+ row2Cell1 := titleRow2.AddCell()
|
|
|
|
+ row2Cell1.HMerge = 1
|
|
|
|
+ row2Cell1.SetString("医药")
|
|
|
|
+ row2Cell1.SetStyle(style)
|
|
|
|
+ titleRow2.AddCell().SetString("")
|
|
|
|
+
|
|
|
|
+ row2Cell2 := titleRow2.AddCell()
|
|
|
|
+ row2Cell2.HMerge = 1
|
|
|
|
+ row2Cell2.SetString("消费")
|
|
|
|
+ row2Cell2.SetStyle(style)
|
|
|
|
+ titleRow2.AddCell().SetString("")
|
|
|
|
+
|
|
|
|
+ row2Cell3 := titleRow2.AddCell()
|
|
|
|
+ row2Cell3.HMerge = 1
|
|
|
|
+ row2Cell3.SetString("科技")
|
|
|
|
+ row2Cell3.SetStyle(style)
|
|
|
|
+ titleRow2.AddCell().SetString("")
|
|
|
|
+
|
|
|
|
+ row2Cell4 := titleRow2.AddCell()
|
|
|
|
+ row2Cell4.HMerge = 1
|
|
|
|
+ row2Cell4.SetString("智造")
|
|
|
|
+ row2Cell4.SetStyle(style)
|
|
|
|
+ titleRow2.AddCell().SetString("")
|
|
|
|
+
|
|
|
|
+ row2Cell5 := titleRow2.AddCell()
|
|
|
|
+ row2Cell5.SetString("策略")
|
|
|
|
+ row2Cell5.SetStyle(style)
|
|
|
|
+
|
|
|
|
+ // 第三行表头
|
|
|
|
+ titleRow3 := sheet.AddRow()
|
|
|
|
+ titleRow3.SetHeight(60)
|
|
|
|
+ row3Title := make([]string, 0)
|
|
|
|
+ row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n续约-0\n新增-1\n代付-2\n补充协议-3", "FICC销售", "权益销售", "FICC大套餐")
|
|
for i := range permissionList {
|
|
for i := range permissionList {
|
|
- row2Title = append(row2Title, permissionList[i].PermissionName)
|
|
|
|
|
|
+ row3Title = append(row3Title, permissionList[i].PermissionName)
|
|
}
|
|
}
|
|
|
|
|
|
// 其他套餐
|
|
// 其他套餐
|
|
for i := range otherService {
|
|
for i := range otherService {
|
|
- row2Title = append(row2Title, otherService[i].Title)
|
|
|
|
|
|
+ row3Title = append(row3Title, otherService[i].Title)
|
|
}
|
|
}
|
|
- row2Title = append(row2Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "金额单位", "约定付款时间", "签订日", "合同状态",
|
|
|
|
|
|
+ // 权益三级套餐
|
|
|
|
+ for i := range raiOtherService {
|
|
|
|
+ row3Title = append(row3Title, raiOtherService[i].Title)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ row3Title = append(row3Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "金额单位", "FICC套餐总金额", "权益套餐总金额", "约定付款时间", "签订日", "合同状态",
|
|
"合同编号", "合规备注")
|
|
"合同编号", "合规备注")
|
|
|
|
|
|
// 设置表头
|
|
// 设置表头
|
|
- for i := range row2Title {
|
|
|
|
- v := titleRow2.AddCell()
|
|
|
|
- v.SetString(row2Title[i])
|
|
|
|
|
|
+ for i := range row3Title {
|
|
|
|
+ v := titleRow3.AddCell()
|
|
|
|
+ v.SetString(row3Title[i])
|
|
v.SetStyle(style)
|
|
v.SetStyle(style)
|
|
}
|
|
}
|
|
|
|
|
|
// 第二行表头-开票/收款(动态添加)
|
|
// 第二行表头-开票/收款(动态添加)
|
|
- invoiceTitle := []string{"开票日", "开票金额", "销售", "备注"}
|
|
|
|
|
|
+ invoiceTitle := []string{"开票日", "开票金额", "套餐类型", "销售", "备注"}
|
|
for i := 0; i < maxInvoice; i++ {
|
|
for i := 0; i < maxInvoice; i++ {
|
|
n := i + 1
|
|
n := i + 1
|
|
for ii := range invoiceTitle {
|
|
for ii := range invoiceTitle {
|
|
- c := titleRow2.AddCell()
|
|
|
|
|
|
+ c := titleRow3.AddCell()
|
|
t := fmt.Sprintf("%s%d", invoiceTitle[ii], n)
|
|
t := fmt.Sprintf("%s%d", invoiceTitle[ii], n)
|
|
c.SetString(t)
|
|
c.SetString(t)
|
|
c.SetStyle(style)
|
|
c.SetStyle(style)
|
|
- row2Title = append(row2Title, t)
|
|
|
|
|
|
+ row3Title = append(row3Title, t)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- paymentTitle := []string{"到款日", "到款金额", "备注"}
|
|
|
|
|
|
+ paymentTitle := []string{"到款日", "到款金额", "套餐类型", "备注"}
|
|
for i := 0; i < maxPayment; i++ {
|
|
for i := 0; i < maxPayment; i++ {
|
|
n := i + 1
|
|
n := i + 1
|
|
for ii := range paymentTitle {
|
|
for ii := range paymentTitle {
|
|
@@ -1177,13 +1324,13 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
t := fmt.Sprintf("%s%d", paymentTitle[ii], n)
|
|
t := fmt.Sprintf("%s%d", paymentTitle[ii], n)
|
|
c.SetString(t)
|
|
c.SetString(t)
|
|
c.SetStyle(style)
|
|
c.SetStyle(style)
|
|
- row2Title = append(row2Title, t)
|
|
|
|
|
|
+ row3Title = append(row3Title, t)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 此处取第二行标题NameKeyMap, 后面的动态匹配
|
|
// 此处取第二行标题NameKeyMap, 后面的动态匹配
|
|
row2NameKeyMap := make(map[string]int)
|
|
row2NameKeyMap := make(map[string]int)
|
|
- for i := range row2Title {
|
|
|
|
- row2NameKeyMap[row2Title[i]] = i
|
|
|
|
|
|
+ for i := range row3Title {
|
|
|
|
+ row2NameKeyMap[row3Title[i]] = i
|
|
}
|
|
}
|
|
|
|
|
|
newCompanyMap := map[int]string{0: "1", 1: "0"}
|
|
newCompanyMap := map[int]string{0: "1", 1: "0"}
|
|
@@ -1202,15 +1349,17 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
dataRow.AddCell().SetString(newCompanyMap[v.NewCompany])
|
|
dataRow.AddCell().SetString(newCompanyMap[v.NewCompany])
|
|
dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.ContractType]))
|
|
dataRow.AddCell().SetString(fmt.Sprint(contractTMap[v.ContractType]))
|
|
dataRow.AddCell().SetString(v.SellerName)
|
|
dataRow.AddCell().SetString(v.SellerName)
|
|
|
|
+ dataRow.AddCell().SetString(v.RaiSellerName)
|
|
|
|
|
|
// 大套餐
|
|
// 大套餐
|
|
k += 1
|
|
k += 1
|
|
- col4Name := row2Title[k]
|
|
|
|
|
|
+ col4Name := row3Title[k]
|
|
svList := serviceMap[v.ContractRegisterId]
|
|
svList := serviceMap[v.ContractRegisterId]
|
|
col4 := ""
|
|
col4 := ""
|
|
if svList != nil && len(svList) > 0 {
|
|
if svList != nil && len(svList) > 0 {
|
|
for isv := range svList {
|
|
for isv := range svList {
|
|
if svList[isv].Title == col4Name {
|
|
if svList[isv].Title == col4Name {
|
|
|
|
+ // todo 判断权益套餐权限时会有问题,需要同时判断父级name
|
|
col4 = "是"
|
|
col4 = "是"
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -1222,7 +1371,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
serviceChartPermissionIds := serviceChartPermissionsMap[v.ContractRegisterId]
|
|
serviceChartPermissionIds := serviceChartPermissionsMap[v.ContractRegisterId]
|
|
for i := 0; i < permissionLen; i++ {
|
|
for i := 0; i < permissionLen; i++ {
|
|
k += 1
|
|
k += 1
|
|
- colName := row2Title[k]
|
|
|
|
|
|
+ colName := row3Title[k]
|
|
chartPermissionId := permissionNameIdMap[colName]
|
|
chartPermissionId := permissionNameIdMap[colName]
|
|
if utils.InArray(chartPermissionId, serviceChartPermissionIds) {
|
|
if utils.InArray(chartPermissionId, serviceChartPermissionIds) {
|
|
dataRow.AddCell().SetString("是")
|
|
dataRow.AddCell().SetString("是")
|
|
@@ -1234,7 +1383,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
// 除大小套餐外的其他套餐(处理方式其实跟上面的大套餐一样, 只是中间隔了小套餐按照顺序要这么处理=_=!)
|
|
// 除大小套餐外的其他套餐(处理方式其实跟上面的大套餐一样, 只是中间隔了小套餐按照顺序要这么处理=_=!)
|
|
for i := 0; i < otherServiceLen; i++ {
|
|
for i := 0; i < otherServiceLen; i++ {
|
|
k += 1
|
|
k += 1
|
|
- otherColName := row2Title[k]
|
|
|
|
|
|
+ otherColName := row3Title[k]
|
|
otherCol := ""
|
|
otherCol := ""
|
|
if svList != nil && len(svList) > 0 {
|
|
if svList != nil && len(svList) > 0 {
|
|
for isv := range svList {
|
|
for isv := range svList {
|
|
@@ -1248,11 +1397,15 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
}
|
|
}
|
|
|
|
|
|
// 其他信息
|
|
// 其他信息
|
|
|
|
+ ficcAmount, _ := serviceAmountMap[v.ContractRegisterId][crm.CompanyProductFicc]
|
|
|
|
+ raiAmount, _ := serviceAmountMap[v.ContractRegisterId][crm.CompanyProductRai]
|
|
dataRow.AddCell().SetString(v.ServiceRemark) // 套餐备注
|
|
dataRow.AddCell().SetString(v.ServiceRemark) // 套餐备注
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.StartDate)) // 开始时间
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.StartDate)) // 开始时间
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.EndDate)) // 到期时间
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.EndDate)) // 到期时间
|
|
dataRow.AddCell().SetString(fmt.Sprint("¥", v.ContractAmount)) // 2022年合同金额
|
|
dataRow.AddCell().SetString(fmt.Sprint("¥", v.ContractAmount)) // 2022年合同金额
|
|
dataRow.AddCell().SetString(v.CurrencyUnit) // 货币单位
|
|
dataRow.AddCell().SetString(v.CurrencyUnit) // 货币单位
|
|
|
|
+ dataRow.AddCell().SetString(fmt.Sprint("¥", ficcAmount.ServiceAmount)) // FICC套餐总金额
|
|
|
|
+ dataRow.AddCell().SetString(fmt.Sprint("¥", raiAmount.ServiceAmount)) // 权益套餐总金额
|
|
dataRow.AddCell().SetString(v.AgreedPayTime) // 约定付款时间
|
|
dataRow.AddCell().SetString(v.AgreedPayTime) // 约定付款时间
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.SignDate)) // 签订日
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", v.SignDate)) // 签订日
|
|
dataRow.AddCell().SetString(fms.ContractStatusKeyNameMap[v.ContractStatus]) // 合同状态
|
|
dataRow.AddCell().SetString(fms.ContractStatusKeyNameMap[v.ContractStatus]) // 合同状态
|
|
@@ -1267,6 +1420,8 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
if ivList != nil && ivList[ia] != nil {
|
|
if ivList != nil && ivList[ia] != nil {
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", ivList[ia].InvoiceDate)) // 开票日
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", ivList[ia].InvoiceDate)) // 开票日
|
|
dataRow.AddCell().SetString(fmt.Sprint(ivList[ia].OriginAmount)) // 开票金额
|
|
dataRow.AddCell().SetString(fmt.Sprint(ivList[ia].OriginAmount)) // 开票金额
|
|
|
|
+ // todo 开票中的套餐类型
|
|
|
|
+ dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString(ivList[ia].SellerName) // 销售名称
|
|
dataRow.AddCell().SetString(ivList[ia].SellerName) // 销售名称
|
|
dataRow.AddCell().SetString(ivList[ia].Remark) // 开票备注
|
|
dataRow.AddCell().SetString(ivList[ia].Remark) // 开票备注
|
|
continue
|
|
continue
|
|
@@ -1277,6 +1432,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
|
|
+ dataRow.AddCell().SetString("")
|
|
}
|
|
}
|
|
pyList := paymentMap[v.ContractRegisterId]
|
|
pyList := paymentMap[v.ContractRegisterId]
|
|
pyListLen := len(pyList)
|
|
pyListLen := len(pyList)
|
|
@@ -1285,6 +1441,8 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
if pyList != nil && pyList[ib] != nil {
|
|
if pyList != nil && pyList[ib] != nil {
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", pyList[ib].InvoiceDate)) // 收款日
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", pyList[ib].InvoiceDate)) // 收款日
|
|
dataRow.AddCell().SetString(fmt.Sprint(pyList[ib].OriginAmount)) // 收款金额
|
|
dataRow.AddCell().SetString(fmt.Sprint(pyList[ib].OriginAmount)) // 收款金额
|
|
|
|
+ //todo 到款的套餐类型
|
|
|
|
+ dataRow.AddCell().SetString("") // 套餐类型
|
|
dataRow.AddCell().SetString(pyList[ib].Remark) // 收款备注
|
|
dataRow.AddCell().SetString(pyList[ib].Remark) // 收款备注
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -1293,6 +1451,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
dataRow.AddCell().SetString("")
|
|
|
|
+ dataRow.AddCell().SetString("")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1613,10 +1772,38 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
serviceTempNameMap := make(map[string]*fms.ContractServiceTemplate)
|
|
serviceTempNameMap := make(map[string]*fms.ContractServiceTemplate)
|
|
|
|
+ serviceTempFullNameMap := make(map[string]*fms.ContractServiceTemplate)
|
|
|
|
+ serviceTempIdMap := make(map[int]*fms.ContractServiceTemplate)
|
|
for i := range serviceTempList {
|
|
for i := range serviceTempList {
|
|
|
|
+ serviceTempIdMap[serviceTempList[i].ServiceTemplateId] = serviceTempList[i]
|
|
serviceTempNameMap[serviceTempList[i].Title] = serviceTempList[i]
|
|
serviceTempNameMap[serviceTempList[i].Title] = serviceTempList[i]
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ for i := range serviceTempList {
|
|
|
|
+ fullName := serviceTempList[i].Title
|
|
|
|
+ if serviceTempList[i].Pid > 0 {
|
|
|
|
+ parentItem := serviceTempIdMap[serviceTempList[i].Pid]
|
|
|
|
+ fullName += "_"+parentItem.Title
|
|
|
|
+ if parentItem.Pid > 0 {
|
|
|
|
+ fullName += "_"+serviceTempIdMap[parentItem.Pid].Title
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ serviceTempFullNameMap[fullName] = serviceTempList[i]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //权益行业套餐名称
|
|
|
|
+ raiIndustryMap := map[int]string{
|
|
|
|
+ 36:"医药",
|
|
|
|
+ 37:"医药",
|
|
|
|
+ 38:"消费",
|
|
|
|
+ 39:"消费",
|
|
|
|
+ 40:"科技",
|
|
|
|
+ 41:"科技",
|
|
|
|
+ 42:"智造",
|
|
|
|
+ 43:"智造",
|
|
|
|
+ 44:"策略",
|
|
|
|
+ }
|
|
|
|
+
|
|
// 获取货币列表及汇率(汇率为导入日的汇率)
|
|
// 获取货币列表及汇率(汇率为导入日的汇率)
|
|
rateList, e := fmsService.GetTodayCurrencyRateList()
|
|
rateList, e := fmsService.GetTodayCurrencyRateList()
|
|
if e != nil {
|
|
if e != nil {
|
|
@@ -1658,8 +1845,8 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
// 遍历行读取
|
|
// 遍历行读取
|
|
maxRow := sheet.MaxRow
|
|
maxRow := sheet.MaxRow
|
|
for i := 0; i < maxRow; i++ {
|
|
for i := 0; i < maxRow; i++ {
|
|
- // 第二行开始读取表头
|
|
|
|
- if i == 1 {
|
|
|
|
|
|
+ // 第三行开始读取表头
|
|
|
|
+ if i == 2 {
|
|
row := sheet.Row(i)
|
|
row := sheet.Row(i)
|
|
cells := row.Cells
|
|
cells := row.Cells
|
|
for k, cell := range cells {
|
|
for k, cell := range cells {
|
|
@@ -1671,35 +1858,41 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
resp.Fail("【客户名称】列名称有误, 请参考模板导入", c)
|
|
resp.Fail("【客户名称】列名称有误, 请参考模板导入", c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if k == 1 {
|
|
|
|
|
|
+ continue
|
|
|
|
+ } else if k == 1 {
|
|
if !strings.Contains(text, "新客户") {
|
|
if !strings.Contains(text, "新客户") {
|
|
resp.Fail("【新客户】列名称有误, 请参考模板导入", c)
|
|
resp.Fail("【新客户】列名称有误, 请参考模板导入", c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if k == 2 {
|
|
|
|
|
|
+ continue
|
|
|
|
+ } else if k == 2 {
|
|
if !strings.Contains(text, "合同类型") {
|
|
if !strings.Contains(text, "合同类型") {
|
|
resp.Fail("【合同类型】列名称有误, 请参考模板导入", c)
|
|
resp.Fail("【合同类型】列名称有误, 请参考模板导入", c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if k == 3 {
|
|
|
|
- if text != "销售" {
|
|
|
|
- resp.Fail("【销售】列名称有误, 请参考模板导入", c)
|
|
|
|
|
|
+ continue
|
|
|
|
+ } else if k == 3 {
|
|
|
|
+ if text != "FICC销售" {
|
|
|
|
+ resp.Fail("【FICC销售】列名称有误, 请参考模板导入", c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if k == 4 {
|
|
|
|
|
|
+ continue
|
|
|
|
+ } else if k == 4 {
|
|
|
|
+ if text != "权益销售" {
|
|
|
|
+ resp.Fail("【权益销售】列名称有误, 请参考模板导入", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ } else if k == 5 {
|
|
if text != "FICC大套餐" {
|
|
if text != "FICC大套餐" {
|
|
resp.Fail("【FICC大套餐】列名称有误, 请参考模板导入", c)
|
|
resp.Fail("【FICC大套餐】列名称有误, 请参考模板导入", c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ continue
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- // 数据行
|
|
|
|
- if i >= 2 {
|
|
|
|
|
|
+ }else if i >= 3 {
|
|
|
|
+ // 数据行
|
|
row := sheet.Row(i)
|
|
row := sheet.Row(i)
|
|
cells := row.Cells
|
|
cells := row.Cells
|
|
|
|
|
|
@@ -1707,6 +1900,8 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
rowRegister := new(fms.ContractRegister)
|
|
rowRegister := new(fms.ContractRegister)
|
|
// 套餐
|
|
// 套餐
|
|
rowServices := make([]*fms.ContractService, 0)
|
|
rowServices := make([]*fms.ContractService, 0)
|
|
|
|
+ // 套餐金额
|
|
|
|
+ rowServiceAmount := make([]*fms.ContractServiceAmount, 0)
|
|
// 开票/到款
|
|
// 开票/到款
|
|
rowInvoices := make([]*fms.ContractInvoice, 0)
|
|
rowInvoices := make([]*fms.ContractInvoice, 0)
|
|
for ir := 0; ir < invoiceMax; ir++ {
|
|
for ir := 0; ir < invoiceMax; ir++ {
|
|
@@ -1719,6 +1914,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
// 小套餐权限
|
|
// 小套餐权限
|
|
rowChartPermissionIdArr := make([]string, 0)
|
|
rowChartPermissionIdArr := make([]string, 0)
|
|
|
|
|
|
|
|
+ productIds := make(map[int]struct{})
|
|
isSkip := false
|
|
isSkip := false
|
|
for k, cell := range cells {
|
|
for k, cell := range cells {
|
|
v := utils.TrimStr(cell.String())
|
|
v := utils.TrimStr(cell.String())
|
|
@@ -1753,23 +1949,39 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- // 销售
|
|
|
|
|
|
+ // FICC销售
|
|
if k == 3 {
|
|
if k == 3 {
|
|
- if v == "" {
|
|
|
|
- resp.Fail(fmt.Sprintf("第%d行销售名称不可为空, 请按模板导入", i+1), c)
|
|
|
|
|
|
+ if v != "" {
|
|
|
|
+ /*resp.Fail(fmt.Sprintf("第%d行销售名称不可为空, 请按模板导入", i+1), c)
|
|
|
|
+ return*/
|
|
|
|
+ sellerItem := sellerMap[v]
|
|
|
|
+ if sellerItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ rowRegister.SellerId = sellerItem.SellerId
|
|
|
|
+ rowRegister.SellerName = sellerItem.SellerName
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 权益销售
|
|
|
|
+ if k == 4 {
|
|
|
|
+ if v == "" && rowRegister.SellerName == "" {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第FICC销售名称和权益销售名称不可都为空, 请按模板导入", i+1), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
sellerItem := sellerMap[v]
|
|
sellerItem := sellerMap[v]
|
|
if sellerItem == nil {
|
|
if sellerItem == nil {
|
|
- resp.Fail(fmt.Sprintf("第%d行销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
|
|
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行权益销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- rowRegister.SellerId = sellerItem.SellerId
|
|
|
|
- rowRegister.SellerName = sellerItem.SellerName
|
|
|
|
|
|
+ rowRegister.RaiSellerId = sellerItem.SellerId
|
|
|
|
+ rowRegister.RaiSellerName = sellerItem.SellerName
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// FICC大套餐
|
|
// FICC大套餐
|
|
- if k == 4 {
|
|
|
|
|
|
+ if k == 5 {
|
|
if v == "是" {
|
|
if v == "是" {
|
|
tempItem := serviceTempNameMap[titleMap[k]]
|
|
tempItem := serviceTempNameMap[titleMap[k]]
|
|
if tempItem == nil {
|
|
if tempItem == nil {
|
|
@@ -1786,19 +1998,21 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
cs.Set()
|
|
cs.Set()
|
|
rowServices = append(rowServices, cs)
|
|
rowServices = append(rowServices, cs)
|
|
|
|
+ productIds[crm.CompanyProductFicc] = struct{}{}
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// FICC小套餐
|
|
// FICC小套餐
|
|
- if k >= 5 && k <= 25 {
|
|
|
|
|
|
+ if k >= 6 && k <= 26 {
|
|
// 小套餐权限
|
|
// 小套餐权限
|
|
if v == "是" {
|
|
if v == "是" {
|
|
rowChartPermissionIdArr = append(rowChartPermissionIdArr, strconv.Itoa(chartPermissionNameIdMap[titleMap[k]]))
|
|
rowChartPermissionIdArr = append(rowChartPermissionIdArr, strconv.Itoa(chartPermissionNameIdMap[titleMap[k]]))
|
|
|
|
+ productIds[crm.CompanyProductFicc] = struct{}{}
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 其他类型套餐
|
|
// 其他类型套餐
|
|
- if k >= 26 && k <= 32 {
|
|
|
|
|
|
+ if k >= 27 && k <= 33 {
|
|
if v == "是" {
|
|
if v == "是" {
|
|
tempItem := serviceTempNameMap[titleMap[k]]
|
|
tempItem := serviceTempNameMap[titleMap[k]]
|
|
if tempItem == nil {
|
|
if tempItem == nil {
|
|
@@ -1815,16 +2029,135 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
cs.Set()
|
|
cs.Set()
|
|
rowServices = append(rowServices, cs)
|
|
rowServices = append(rowServices, cs)
|
|
|
|
+ productIds[crm.CompanyProductFicc] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ // todo 权益行业套餐
|
|
|
|
+ if k >=34 && k<=44 {
|
|
|
|
+ if v == "是" {
|
|
|
|
+ // 权益大套餐
|
|
|
|
+ if k <= 35 {
|
|
|
|
+ //新增
|
|
|
|
+ parentName := "权益大套餐"
|
|
|
|
+ tempItem := serviceTempNameMap[titleMap[k]]
|
|
|
|
+ if tempItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ cs := &fms.ContractService{
|
|
|
|
+ ProductId: crm.CompanyProductFicc,
|
|
|
|
+ ServiceTemplateId: tempItem.ServiceTemplateId,
|
|
|
|
+ Title: tempItem.Title,
|
|
|
|
+ Value: tempItem.Value,
|
|
|
|
+ TableValue: tempItem.TableValue,
|
|
|
|
+ ChartPermissionId: tempItem.ChartPermissionId,
|
|
|
|
+ }
|
|
|
|
+ rowServices = append(rowServices, cs)
|
|
|
|
+
|
|
|
|
+ tempItem = serviceTempNameMap[parentName]
|
|
|
|
+ if tempItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ cs = &fms.ContractService{
|
|
|
|
+ ProductId: crm.CompanyProductRai,
|
|
|
|
+ ServiceTemplateId: tempItem.ServiceTemplateId,
|
|
|
|
+ Title: tempItem.Title,
|
|
|
|
+ Value: tempItem.Value,
|
|
|
|
+ TableValue: tempItem.TableValue,
|
|
|
|
+ ChartPermissionId: tempItem.ChartPermissionId,
|
|
|
|
+ }
|
|
|
|
+ rowServices = append(rowServices, cs)
|
|
|
|
+ } else {
|
|
|
|
+ rootName := "行业套餐"
|
|
|
|
+ // 新增三条套餐信息
|
|
|
|
+ parentName, _ := raiIndustryMap[k]
|
|
|
|
+ childName := titleMap[k]
|
|
|
|
+ fullName := childName+"_"+parentName+"_"+rootName
|
|
|
|
+ if fullName != "" {
|
|
|
|
+ //增加三级权限
|
|
|
|
+ tempItem := serviceTempFullNameMap[fullName]
|
|
|
|
+ if tempItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ cs := &fms.ContractService{
|
|
|
|
+ ProductId: crm.CompanyProductRai,
|
|
|
|
+ ServiceTemplateId: tempItem.ServiceTemplateId,
|
|
|
|
+ Title: tempItem.Title,
|
|
|
|
+ Value: tempItem.Value,
|
|
|
|
+ TableValue: tempItem.TableValue,
|
|
|
|
+ ChartPermissionId: tempItem.ChartPermissionId,
|
|
|
|
+ }
|
|
|
|
+ rowServices = append(rowServices, cs)
|
|
|
|
+
|
|
|
|
+ //增加二级权限
|
|
|
|
+ tempItem = serviceTempFullNameMap[parentName+"_"+rootName]
|
|
|
|
+ if tempItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ cs = &fms.ContractService{
|
|
|
|
+ ProductId: crm.CompanyProductRai,
|
|
|
|
+ ServiceTemplateId: tempItem.ServiceTemplateId,
|
|
|
|
+ Title: tempItem.Title,
|
|
|
|
+ Value: tempItem.Value,
|
|
|
|
+ TableValue: tempItem.TableValue,
|
|
|
|
+ ChartPermissionId: tempItem.ChartPermissionId,
|
|
|
|
+ }
|
|
|
|
+ rowServices = append(rowServices, cs)
|
|
|
|
+
|
|
|
|
+ //增加一级权限
|
|
|
|
+ tempItem = serviceTempFullNameMap[rootName]
|
|
|
|
+ if tempItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ cs = &fms.ContractService{
|
|
|
|
+ ProductId: crm.CompanyProductRai,
|
|
|
|
+ ServiceTemplateId: tempItem.ServiceTemplateId,
|
|
|
|
+ Title: tempItem.Title,
|
|
|
|
+ Value: tempItem.Value,
|
|
|
|
+ TableValue: tempItem.TableValue,
|
|
|
|
+ ChartPermissionId: tempItem.ChartPermissionId,
|
|
|
|
+ }
|
|
|
|
+ rowServices = append(rowServices, cs)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ productIds[crm.CompanyProductRai] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ // 权益研选等套餐
|
|
|
|
+ if k >= 45 && k<=49 {
|
|
|
|
+ if v == "是" {
|
|
|
|
+ tempItem := serviceTempNameMap[titleMap[k]]
|
|
|
|
+ if tempItem == nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行套餐名称不匹配, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ cs := &fms.ContractService{
|
|
|
|
+ ProductId: crm.CompanyProductRai,
|
|
|
|
+ ServiceTemplateId: tempItem.ServiceTemplateId,
|
|
|
|
+ Title: tempItem.Title,
|
|
|
|
+ Value: tempItem.Value,
|
|
|
|
+ TableValue: tempItem.TableValue,
|
|
|
|
+ ChartPermissionId: tempItem.ChartPermissionId,
|
|
|
|
+ }
|
|
|
|
+ cs.Set()
|
|
|
|
+ rowServices = append(rowServices, cs)
|
|
|
|
+ productIds[crm.CompanyProductRai] = struct{}{}
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 套餐备注
|
|
// 套餐备注
|
|
- if k == 33 {
|
|
|
|
|
|
+ if k == 50 {
|
|
rowRegister.ServiceRemark = v
|
|
rowRegister.ServiceRemark = v
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 开始时间/到期时间
|
|
// 开始时间/到期时间
|
|
- if k == 34 {
|
|
|
|
|
|
+ if k == 51 {
|
|
// 转换失败可能是因为格式为Excel日期格式, 读取出来会是一串数字, 将其转换成日期字符串再处理
|
|
// 转换失败可能是因为格式为Excel日期格式, 读取出来会是一串数字, 将其转换成日期字符串再处理
|
|
va := cell.Value
|
|
va := cell.Value
|
|
if va == "" {
|
|
if va == "" {
|
|
@@ -1848,7 +2181,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
rowRegister.StartDate = startDate
|
|
rowRegister.StartDate = startDate
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- if k == 35 {
|
|
|
|
|
|
+ if k == 52 {
|
|
va := cell.Value
|
|
va := cell.Value
|
|
if va == "" {
|
|
if va == "" {
|
|
resp.Fail(fmt.Sprintf("第%d行到期时间不可为空, 请按模板导入", i+1), c)
|
|
resp.Fail(fmt.Sprintf("第%d行到期时间不可为空, 请按模板导入", i+1), c)
|
|
@@ -1871,7 +2204,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 合同金额
|
|
// 合同金额
|
|
- if k == 36 {
|
|
|
|
|
|
+ if k == 53 {
|
|
amountStr := v
|
|
amountStr := v
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
if e != nil {
|
|
if e != nil {
|
|
@@ -1882,7 +2215,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 金额单位
|
|
// 金额单位
|
|
- if k == 37 {
|
|
|
|
|
|
+ if k == 54 {
|
|
rate := rateMap[v]
|
|
rate := rateMap[v]
|
|
if rate <= 0 {
|
|
if rate <= 0 {
|
|
resp.Fail(fmt.Sprintf("第%d行金额单位有误, 请按模板导入", i+1), c)
|
|
resp.Fail(fmt.Sprintf("第%d行金额单位有误, 请按模板导入", i+1), c)
|
|
@@ -1892,13 +2225,51 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
rowRegister.RMBRate = rate
|
|
rowRegister.RMBRate = rate
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ // todo FICC套餐总金额
|
|
|
|
+ if k == 55 {
|
|
|
|
+ amountStr := v
|
|
|
|
+ amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行FICC套餐总金额有误, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if amount > 0 {
|
|
|
|
+ tmp := &fms.ContractServiceAmount{
|
|
|
|
+ ProductId: crm.CompanyProductFicc,
|
|
|
|
+ ServiceAmount: amount,
|
|
|
|
+ CurrencyUnit: rowRegister.CurrencyUnit,
|
|
|
|
+ TimeBase: base.TimeBase{},
|
|
|
|
+ }
|
|
|
|
+ rowServiceAmount = append(rowServiceAmount, tmp)
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ // todo 权益套餐总金额
|
|
|
|
+ if k == 56 {
|
|
|
|
+ amountStr := v
|
|
|
|
+ amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行权益套餐总金额有误, 请按模板导入", i+1), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if amount > 0 {
|
|
|
|
+ tmp := &fms.ContractServiceAmount{
|
|
|
|
+ ProductId: crm.CompanyProductRai,
|
|
|
|
+ ServiceAmount: amount,
|
|
|
|
+ CurrencyUnit: rowRegister.CurrencyUnit,
|
|
|
|
+ TimeBase: base.TimeBase{},
|
|
|
|
+ }
|
|
|
|
+ rowServiceAmount = append(rowServiceAmount, tmp)
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
// 约定付款日期
|
|
// 约定付款日期
|
|
- if k == 38 {
|
|
|
|
|
|
+ if k == 57 {
|
|
rowRegister.AgreedPayTime = v
|
|
rowRegister.AgreedPayTime = v
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 签订日
|
|
// 签订日
|
|
- if k == 39 {
|
|
|
|
|
|
+ if k == 58 {
|
|
va := cell.Value
|
|
va := cell.Value
|
|
if va == "" {
|
|
if va == "" {
|
|
continue
|
|
continue
|
|
@@ -1920,7 +2291,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 合同状态
|
|
// 合同状态
|
|
- if k == 40 {
|
|
|
|
|
|
+ if k == 59 {
|
|
rowRegister.ContractStatus = fms.ContractStatusNameKeyMap[v]
|
|
rowRegister.ContractStatus = fms.ContractStatusNameKeyMap[v]
|
|
if rowRegister.ContractStatus == 0 {
|
|
if rowRegister.ContractStatus == 0 {
|
|
resp.Fail(fmt.Sprintf("第%d行合同状态不匹配, 请按模板导入", i+1), c)
|
|
resp.Fail(fmt.Sprintf("第%d行合同状态不匹配, 请按模板导入", i+1), c)
|
|
@@ -1929,7 +2300,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 合同编号
|
|
// 合同编号
|
|
- if k == 41 {
|
|
|
|
|
|
+ if k == 60 {
|
|
rowContractCode := v
|
|
rowContractCode := v
|
|
if rowContractCode == "" {
|
|
if rowContractCode == "" {
|
|
resp.Fail(fmt.Sprintf("第%d行合同编号不可为空, 请按模板导入", i+1), c)
|
|
resp.Fail(fmt.Sprintf("第%d行合同编号不可为空, 请按模板导入", i+1), c)
|
|
@@ -1944,12 +2315,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 合规备注
|
|
// 合规备注
|
|
- if k == 42 {
|
|
|
|
|
|
+ if k == 61 {
|
|
rowRegister.Remark = v
|
|
rowRegister.Remark = v
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 开票列表
|
|
// 开票列表
|
|
- k2 := 42
|
|
|
|
|
|
+ k2 := 62
|
|
for ir := 0; ir < invoiceMax; ir++ {
|
|
for ir := 0; ir < invoiceMax; ir++ {
|
|
n := ir + 1
|
|
n := ir + 1
|
|
// 开票日
|
|
// 开票日
|
|
@@ -1996,6 +2367,13 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ // todo 开票套餐类型
|
|
|
|
+ k2 += 1
|
|
|
|
+ if k == k2 {
|
|
|
|
+ if v != "" {
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
// 开票销售
|
|
// 开票销售
|
|
k2 += 1
|
|
k2 += 1
|
|
if k == k2 {
|
|
if k == k2 {
|
|
@@ -2075,6 +2453,16 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // todo 到款套餐类型
|
|
|
|
+ k2 += 1
|
|
|
|
+ if k == k2 {
|
|
|
|
+ if v != "" {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
// 备注
|
|
// 备注
|
|
k2 += 1
|
|
k2 += 1
|
|
if k == k2 {
|
|
if k == k2 {
|
|
@@ -2140,7 +2528,11 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 新增登记、套餐、开票到款信息
|
|
// 新增登记、套餐、开票到款信息
|
|
- newId, e := fms.CreateImportContractRegister(rowRegister, rowServices, rowInvoiceList)
|
|
|
|
|
|
+ for proId, _ := range productIds {
|
|
|
|
+ rowRegister.ProductIds += strconv.Itoa(proId)+","
|
|
|
|
+ }
|
|
|
|
+ rowRegister.ProductIds = strings.Trim(rowRegister.ProductIds, ",")
|
|
|
|
+ newId, e := fms.CreateImportContractRegister(rowRegister, rowServices, rowInvoiceList, rowServiceAmount)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailData(fmt.Sprintf("第%d行导入失败", i+1), "新增导入登记失败, Err: "+e.Error(), c)
|
|
resp.FailData(fmt.Sprintf("第%d行导入失败", i+1), "新增导入登记失败, Err: "+e.Error(), c)
|
|
return
|
|
return
|