|
@@ -1010,7 +1010,9 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
}
|
|
}
|
|
|
|
|
|
// todo 判断是否符合均分金额的条件,如果符合,需要生成金额分配记录表
|
|
// todo 判断是否符合均分金额的条件,如果符合,需要生成金额分配记录表
|
|
|
|
+ if req.InvoiceType == fms.ContractInvoiceTypePay {
|
|
|
|
|
|
|
|
+ }
|
|
// 新增的记录
|
|
// 新增的记录
|
|
if len(newInvoice) > 0 {
|
|
if len(newInvoice) > 0 {
|
|
newAmount := decimal.NewFromFloat(0).Round(2)
|
|
newAmount := decimal.NewFromFloat(0).Round(2)
|
|
@@ -1162,38 +1164,33 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
// 获取所有权益套餐服务
|
|
// 获取所有权益套餐服务
|
|
- raiServiceList, e := fms.GetContractServiceTemplateMapByProductId(crm.CompanyProductRai)
|
|
|
|
|
|
+ raiServiceList, e := fms.GetContractServiceTemplateAllByProductId(crm.CompanyProductRai)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailData("获取权益套餐服务失败", "Err:"+e.Error(), c)
|
|
resp.FailData("获取权益套餐服务失败", "Err:"+e.Error(), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ raiServiceIdMap := make(map[int]*fms.ContractServiceTemplateItem)
|
|
|
|
+ for i := range raiServiceList {
|
|
|
|
+ raiServiceIdMap[raiServiceList[i].ServiceTemplateId] = raiServiceList[i]
|
|
|
|
+ }
|
|
|
|
+
|
|
// 除大小套餐外的其他套餐(下面的导出需要以此动态处理)
|
|
// 除大小套餐外的其他套餐(下面的导出需要以此动态处理)
|
|
raiOtherService := make([]*fms.ContractServiceTemplateItem, 0)
|
|
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)
|
|
|
|
- }
|
|
|
|
|
|
+ raiServiceNotShowMap := make(map[int]struct{})
|
|
|
|
+ for _, v := range raiServiceList {
|
|
|
|
+ if v.Pid > 0 && raiServiceIdMap[v.Pid].Pid > 0 {
|
|
|
|
+ raiServiceNotShowMap[v.Pid] = struct{}{}
|
|
|
|
+ raiServiceNotShowMap[raiServiceIdMap[v.Pid].Pid] = struct{}{}
|
|
|
|
+ }else if v.Pid > 0 {
|
|
|
|
+ raiServiceNotShowMap[v.Pid] = struct{}{}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for _, v := range raiServiceList {
|
|
|
|
+ if _, ok := raiServiceNotShowMap[v.ServiceTemplateId]; !ok {
|
|
|
|
+ if v.Pid > 0 {
|
|
|
|
+ v.ParentTitle = raiServiceIdMap[v.Pid].Title
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- raiOtherService = append(raiOtherService, raiServiceList[i])
|
|
|
|
|
|
+ raiOtherService = append(raiOtherService, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
otherServiceLen += len(raiOtherService)
|
|
otherServiceLen += len(raiOtherService)
|
|
@@ -1202,7 +1199,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
serviceAmountMap := make(map[int]map[int]*fms.ContractServiceAmount)
|
|
serviceAmountMap := make(map[int]map[int]*fms.ContractServiceAmount)
|
|
|
|
|
|
// 套餐/开票/到款列表
|
|
// 套餐/开票/到款列表
|
|
- serviceMap := make(map[int][]*fms.ContractService)
|
|
|
|
|
|
+ serviceMap := make(map[int][]*fms.ContractServiceWithParentTitle)
|
|
serviceChartPermissionsMap := make(map[int][]int)
|
|
serviceChartPermissionsMap := make(map[int][]int)
|
|
invoiceMap := make(map[int][]*fms.ContractInvoice)
|
|
invoiceMap := make(map[int][]*fms.ContractInvoice)
|
|
paymentMap := make(map[int][]*fms.ContractInvoice)
|
|
paymentMap := make(map[int][]*fms.ContractInvoice)
|
|
@@ -1210,11 +1207,11 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
maxPayment := 0
|
|
maxPayment := 0
|
|
if len(registerIds) > 0 {
|
|
if len(registerIds) > 0 {
|
|
// 获取套餐信息
|
|
// 获取套餐信息
|
|
- csCond := `contract_register_id IN ?`
|
|
|
|
|
|
+ csCond := `cv.contract_register_id IN ?`
|
|
csPars := make([]interface{}, 0)
|
|
csPars := make([]interface{}, 0)
|
|
csPars = append(csPars, registerIds)
|
|
csPars = append(csPars, registerIds)
|
|
cs := new(fms.ContractService)
|
|
cs := new(fms.ContractService)
|
|
- serviceList, e := cs.List(csCond, csPars)
|
|
|
|
|
|
+ serviceList, e := cs.ListWithWithParentTitle(csCond, csPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailData("获取合同套餐列表失败", "Err:"+e.Error(), c)
|
|
resp.FailData("获取合同套餐列表失败", "Err:"+e.Error(), c)
|
|
return
|
|
return
|
|
@@ -1222,7 +1219,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
for i := range serviceList {
|
|
for i := range serviceList {
|
|
cid := serviceList[i].ContractRegisterId
|
|
cid := serviceList[i].ContractRegisterId
|
|
if serviceMap[cid] == nil {
|
|
if serviceMap[cid] == nil {
|
|
- serviceMap[cid] = make([]*fms.ContractService, 0)
|
|
|
|
|
|
+ serviceMap[cid] = make([]*fms.ContractServiceWithParentTitle, 0)
|
|
}
|
|
}
|
|
serviceMap[cid] = append(serviceMap[cid], serviceList[i])
|
|
serviceMap[cid] = append(serviceMap[cid], serviceList[i])
|
|
// 小套餐权限
|
|
// 小套餐权限
|
|
@@ -1249,6 +1246,9 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
}
|
|
}
|
|
// 获取开票/到款详情, 并取最大的开票/到款数(用于动态扩展第二列表头)
|
|
// 获取开票/到款详情, 并取最大的开票/到款数(用于动态扩展第二列表头)
|
|
ci := new(fms.ContractInvoice)
|
|
ci := new(fms.ContractInvoice)
|
|
|
|
+ csCond = `contract_register_id IN ?`
|
|
|
|
+ csPars = make([]interface{}, 0)
|
|
|
|
+ csPars = append(csPars, registerIds)
|
|
invoiceList, e := ci.List(csCond, csPars, "")
|
|
invoiceList, e := ci.List(csCond, csPars, "")
|
|
if e != nil {
|
|
if e != nil {
|
|
resp.FailData("获取开票/到款列表失败", "Err:"+e.Error(), c)
|
|
resp.FailData("获取开票/到款列表失败", "Err:"+e.Error(), c)
|
|
@@ -1284,6 +1284,10 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ serviceProductIdMap := map[int]string{
|
|
|
|
+ 1:"FICC套餐",
|
|
|
|
+ 2:"权益套餐",
|
|
|
|
+ }
|
|
// 生成Excel文件
|
|
// 生成Excel文件
|
|
xlsxFile := xlsx.NewFile()
|
|
xlsxFile := xlsx.NewFile()
|
|
style := xlsx.NewStyle()
|
|
style := xlsx.NewStyle()
|
|
@@ -1409,6 +1413,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
titleRow3 := sheet.AddRow()
|
|
titleRow3 := sheet.AddRow()
|
|
titleRow3.SetHeight(60)
|
|
titleRow3.SetHeight(60)
|
|
row3Title := make([]string, 0)
|
|
row3Title := make([]string, 0)
|
|
|
|
+ row3TitleParent := make([]string, 0)
|
|
row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n续约-0\n新增-1\n代付-2\n补充协议-3", "FICC销售", "权益销售", "FICC大套餐")
|
|
row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n续约-0\n新增-1\n代付-2\n补充协议-3", "FICC销售", "权益销售", "FICC大套餐")
|
|
for i := range permissionList {
|
|
for i := range permissionList {
|
|
row3Title = append(row3Title, permissionList[i].PermissionName)
|
|
row3Title = append(row3Title, permissionList[i].PermissionName)
|
|
@@ -1418,9 +1423,18 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
for i := range otherService {
|
|
for i := range otherService {
|
|
row3Title = append(row3Title, otherService[i].Title)
|
|
row3Title = append(row3Title, otherService[i].Title)
|
|
}
|
|
}
|
|
|
|
+ // 定义二级套餐名称
|
|
|
|
+ for i:= range row3Title {
|
|
|
|
+ row3TitleParent = append(row3TitleParent, row3Title[i])
|
|
|
|
+ }
|
|
// 权益三级套餐
|
|
// 权益三级套餐
|
|
for i := range raiOtherService {
|
|
for i := range raiOtherService {
|
|
row3Title = append(row3Title, raiOtherService[i].Title)
|
|
row3Title = append(row3Title, raiOtherService[i].Title)
|
|
|
|
+ if raiOtherService[i].ParentTitle != "" {
|
|
|
|
+ row3TitleParent = append(row3TitleParent, raiOtherService[i].ParentTitle)
|
|
|
|
+ }else{
|
|
|
|
+ row3TitleParent = append(row3TitleParent, raiOtherService[i].Title)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
row3Title = append(row3Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "金额单位", "FICC套餐总金额", "权益套餐总金额", "约定付款时间", "签订日", "合同状态",
|
|
row3Title = append(row3Title, "套餐备注", "开始时间", "到期时间", "2022年合同金额", "金额单位", "FICC套餐总金额", "权益套餐总金额", "约定付款时间", "签订日", "合同状态",
|
|
@@ -1449,7 +1463,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
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 {
|
|
- c := titleRow2.AddCell()
|
|
|
|
|
|
+ c := titleRow3.AddCell()
|
|
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)
|
|
@@ -1488,7 +1502,6 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
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
|
|
}
|
|
}
|
|
@@ -1517,8 +1530,16 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
if svList != nil && len(svList) > 0 {
|
|
if svList != nil && len(svList) > 0 {
|
|
for isv := range svList {
|
|
for isv := range svList {
|
|
if svList[isv].Title == otherColName {
|
|
if svList[isv].Title == otherColName {
|
|
- otherCol = "是"
|
|
|
|
- break
|
|
|
|
|
|
+ // 判断权益套餐权限时,需要同时判断父级name
|
|
|
|
+ if otherColName == "主观" || otherColName == "客观" {
|
|
|
|
+ if row3TitleParent[k] == svList[isv].ParentTitle {
|
|
|
|
+ otherCol = "是"
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ otherCol = "是"
|
|
|
|
+ break
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1549,8 +1570,7 @@ 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(serviceProductIdMap[ivList[ia].ServiceProductId]) // 套餐类型
|
|
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
|
|
@@ -1570,8 +1590,7 @@ 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(serviceProductIdMap[pyList[ib].ServiceProductId]) // 套餐类型
|
|
dataRow.AddCell().SetString(pyList[ib].Remark) // 收款备注
|
|
dataRow.AddCell().SetString(pyList[ib].Remark) // 收款备注
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -1665,6 +1684,13 @@ func (rg *RegisterController) InvoiceList(c *gin.Context) {
|
|
pars = append(pars, req.ServiceProductId)
|
|
pars = append(pars, req.ServiceProductId)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 销售
|
|
|
|
+ if req.SellerIds != "" {
|
|
|
|
+ sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
|
+ cond += ` AND (seller_id in (?))`
|
|
|
|
+ pars = append(pars, sellerIds)
|
|
|
|
+ }
|
|
|
|
+
|
|
// 货币列表
|
|
// 货币列表
|
|
currencyOB := new(fms.CurrencyUnit)
|
|
currencyOB := new(fms.CurrencyUnit)
|
|
currencyCond := `enable = 1`
|
|
currencyCond := `enable = 1`
|
|
@@ -2184,7 +2210,6 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- // todo 权益行业套餐
|
|
|
|
if k >=34 && k<=44 {
|
|
if k >=34 && k<=44 {
|
|
if v == "是" {
|
|
if v == "是" {
|
|
// 权益大套餐
|
|
// 权益大套餐
|
|
@@ -2376,7 +2401,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
rowRegister.RMBRate = rate
|
|
rowRegister.RMBRate = rate
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- // todo FICC套餐总金额
|
|
|
|
|
|
+ // FICC 套餐总金额
|
|
if k == 55 {
|
|
if k == 55 {
|
|
amountStr := v
|
|
amountStr := v
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
@@ -2395,7 +2420,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- // todo 权益套餐总金额
|
|
|
|
|
|
+ // 权益套餐总金额
|
|
if k == 56 {
|
|
if k == 56 {
|
|
amountStr := v
|
|
amountStr := v
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
amount, e := strconv.ParseFloat(amountStr, 64)
|
|
@@ -2471,7 +2496,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
// 开票列表
|
|
// 开票列表
|
|
- k2 := 62
|
|
|
|
|
|
+ k2 := 61
|
|
for ir := 0; ir < invoiceMax; ir++ {
|
|
for ir := 0; ir < invoiceMax; ir++ {
|
|
n := ir + 1
|
|
n := ir + 1
|
|
// 开票日
|
|
// 开票日
|
|
@@ -2518,10 +2543,18 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- // todo 开票套餐类型
|
|
|
|
|
|
+ // 开票套餐类型
|
|
k2 += 1
|
|
k2 += 1
|
|
if k == k2 {
|
|
if k == k2 {
|
|
if v != "" {
|
|
if v != "" {
|
|
|
|
+ if v == "FICC套餐" {
|
|
|
|
+ rowInvoices[ir].ServiceProductId = crm.CompanyProductFicc
|
|
|
|
+ }else if v == "权益套餐"{
|
|
|
|
+ rowInvoices[ir].ServiceProductId = crm.CompanyProductRai
|
|
|
|
+ }else{
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行开票套餐类型%d:%s有误, 请按模板导入", i+1, n, v), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
@@ -2605,11 +2638,18 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
|
|
- // todo 到款套餐类型
|
|
|
|
|
|
+ // 到款套餐类型
|
|
k2 += 1
|
|
k2 += 1
|
|
if k == k2 {
|
|
if k == k2 {
|
|
if v != "" {
|
|
if v != "" {
|
|
-
|
|
|
|
|
|
+ if v == "FICC套餐" {
|
|
|
|
+ rowPayments[ir].ServiceProductId = crm.CompanyProductFicc
|
|
|
|
+ }else if v == "权益套餐"{
|
|
|
|
+ rowPayments[ir].ServiceProductId = crm.CompanyProductRai
|
|
|
|
+ }else{
|
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行到款套餐类型%d:%s有误, 请按模板导入", i+1, n, v), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|