|
@@ -21,6 +21,7 @@ import (
|
|
|
"net/http"
|
|
|
"os"
|
|
|
"path"
|
|
|
+ "sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -427,8 +428,25 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ templateIds := make([]int, 0)
|
|
|
+ for _, detail := range serviceList {
|
|
|
+ templateIds = append(templateIds, detail.ServiceTemplateId)
|
|
|
+ }
|
|
|
+ sort.Ints(templateIds)
|
|
|
+ ids := make([]string, 0)
|
|
|
+ for _, id := range templateIds {
|
|
|
+ ids = append(ids, strconv.Itoa(id))
|
|
|
+ }
|
|
|
+ templateIdStr := strings.Join(ids, ",")
|
|
|
+ nDupList := make([]*fms.DupInvoice, 0)
|
|
|
+ for _, dup := range dupList {
|
|
|
+ if templateIdStr == dup.TemplateIds {
|
|
|
+ nDupList = append(nDupList, dup)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//先遍历一遍拿到开票销售信息
|
|
|
- for _, ppItem := range dupList {
|
|
|
+ for _, ppItem := range nDupList {
|
|
|
if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
j := 0
|
|
|
if ppItem.InvoiceType == 3 {
|
|
@@ -533,7 +551,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for _, ppItem := range dupList {
|
|
|
+ for _, ppItem := range nDupList {
|
|
|
if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
j := 0
|
|
|
v := &fms.ContractInvoice{
|
|
@@ -680,8 +698,24 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ templateIds := make([]int, 0)
|
|
|
+ for _, detail := range serviceList {
|
|
|
+ templateIds = append(templateIds, detail.ServiceTemplateId)
|
|
|
+ }
|
|
|
+ sort.Ints(templateIds)
|
|
|
+ ids := make([]string, 0)
|
|
|
+ for _, id := range templateIds {
|
|
|
+ ids = append(ids, strconv.Itoa(id))
|
|
|
+ }
|
|
|
+ templateIdStr := strings.Join(ids, ",")
|
|
|
+ nDupList := make([]*fms.DupInvoice, 0)
|
|
|
+ for _, dup := range dupList {
|
|
|
+ if templateIdStr == dup.TemplateIds {
|
|
|
+ nDupList = append(nDupList, dup)
|
|
|
+ }
|
|
|
+ }
|
|
|
//先遍历一遍拿到开票销售信息
|
|
|
- for _, ppItem := range dupList {
|
|
|
+ for _, ppItem := range nDupList {
|
|
|
j := 0
|
|
|
if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
if ppItem.InvoiceType == 3 {
|
|
@@ -697,7 +731,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
j++
|
|
|
}
|
|
|
}
|
|
|
- for _, ppItem := range dupList {
|
|
|
+ for _, ppItem := range nDupList {
|
|
|
j := 0
|
|
|
if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
v := &fms.ContractInvoice{
|
|
@@ -3485,6 +3519,22 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ templateIds := make([]int, 0)
|
|
|
+ for _, detail := range rowServices {
|
|
|
+ templateIds = append(templateIds, detail.ServiceTemplateId)
|
|
|
+ }
|
|
|
+ sort.Ints(templateIds)
|
|
|
+ ids := make([]string, 0)
|
|
|
+ for _, id := range templateIds {
|
|
|
+ ids = append(ids, strconv.Itoa(id))
|
|
|
+ }
|
|
|
+ templateIdStr := strings.Join(ids, ",")
|
|
|
+ nDupList := make([]*fms.DupInvoice, 0)
|
|
|
+ for _, dup := range dupList {
|
|
|
+ if templateIdStr == dup.TemplateIds {
|
|
|
+ nDupList = append(nDupList, dup)
|
|
|
+ }
|
|
|
+ }
|
|
|
//先遍历一遍拿到开票销售信息
|
|
|
for _, ppItem := range dupList {
|
|
|
j := 0
|
|
@@ -3774,19 +3824,14 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
|
|
|
|
|
|
existPars = append(existPars, startDate, endDate)
|
|
|
}
|
|
|
- if len(req.Services) > 0 {
|
|
|
- //serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
- //if e != nil {
|
|
|
- // resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
if existCond == "" {
|
|
|
resp.Fail("请输入合同名称或者合同有效期", c)
|
|
|
return
|
|
|
}
|
|
|
+ data := fms.CheckContractDuplicateResp{
|
|
|
+ Exist: 0,
|
|
|
+ }
|
|
|
|
|
|
// 是否存在相同合同名称的登记
|
|
|
list, e := fms.CheckContractDuplicate(existCond, existPars)
|
|
@@ -3794,12 +3839,44 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "查询重复合同失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- data := fms.CheckContractDuplicateResp{
|
|
|
- Exist: 0,
|
|
|
+
|
|
|
+ registerIds := make([]int, 0)
|
|
|
+ for i := range list {
|
|
|
+ registerIds = append(registerIds, list[i].ContractRegisterId)
|
|
|
}
|
|
|
- if len(list) > 0 {
|
|
|
- data.Exist = 1
|
|
|
+
|
|
|
+ idlist, e := fms.CheckContractServiceDuplicate(registerIds)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("操作失败", "查询重复合同套餐失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验套餐
|
|
|
+ if len(req.Services) > 0 {
|
|
|
+ serviceAmountMap := make(map[int]float64)
|
|
|
+ serviceList, e := fmsService.HandleContractServiceAndDetail(req.Services, true, serviceAmountMap)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ templateIds := make([]int, 0)
|
|
|
+ for _, detail := range serviceList {
|
|
|
+ templateIds = append(templateIds, detail.ServiceTemplateId)
|
|
|
+ }
|
|
|
+ sort.Ints(templateIds)
|
|
|
+ ids := make([]string, 0)
|
|
|
+ for _, id := range templateIds {
|
|
|
+ ids = append(ids, strconv.Itoa(id))
|
|
|
+ }
|
|
|
+ templateIdStr := strings.Join(ids, ",")
|
|
|
+
|
|
|
+ for _, s := range idlist {
|
|
|
+ if templateIdStr == *s {
|
|
|
+ data.Exist = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
resp.OkData("查询成功", data, c)
|
|
|
return
|
|
|
}
|