|
@@ -21,6 +21,7 @@ import (
|
|
|
"net/http"
|
|
|
"os"
|
|
|
"path"
|
|
|
+ "sort"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -381,8 +382,13 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "获取合同套餐详情失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ // 合同有效时长(计算付款方式)
|
|
|
+ dayDiff := ob.EndDate.Sub(ob.StartDate).Hours() / 24
|
|
|
// 新增合同及套餐
|
|
|
+ logList := make([]*fms.ContractRegisterLog, 0)
|
|
|
+
|
|
|
+ //是否补录合同
|
|
|
+ sellerItemMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
if req.Supplement == 1 {
|
|
|
//新增到款信息
|
|
|
if ob.HasInvoice == 0 {
|
|
@@ -405,8 +411,6 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "获取合同开票到款列表失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- // 合同有效时长(计算付款方式)
|
|
|
- dayDiff := ob.EndDate.Sub(ob.StartDate).Hours() / 24
|
|
|
|
|
|
// 获取销售分组信息
|
|
|
sellerList, e := crmService.GetSellerDepartmentListWithGroupAndTeam()
|
|
@@ -418,8 +422,48 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
for i := range sellerList {
|
|
|
sellerMap[sellerList[i].SellerId] = sellerList[i]
|
|
|
}
|
|
|
- logList := make([]*fms.ContractRegisterLog, 0)
|
|
|
+ //处理重复公司名日期等重复的开票到款记录
|
|
|
+ dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate)
|
|
|
+ if e != nil {
|
|
|
+ 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 nDupList {
|
|
|
+ if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
+ j := 0
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ GroupId: ppItem.SellerGroupId,
|
|
|
+ GroupName: ppItem.SellerGroupName,
|
|
|
+ TeamId: ppItem.SellerTeamId,
|
|
|
+ TeamName: ppItem.SellerTeamName,
|
|
|
+ }
|
|
|
+ j++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, ppItem := range invoiceList {
|
|
|
+ j,k := 0,0
|
|
|
v := &fms.ContractInvoice{
|
|
|
ContractRegisterId: ob.ContractRegisterId,
|
|
|
ContractCode: ob.ContractCode,
|
|
@@ -441,10 +485,29 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
StartDate: ppItem.StartDate,
|
|
|
EndDate: ppItem.EndDate,
|
|
|
}
|
|
|
+
|
|
|
if ppItem.InvoiceType == 3 {
|
|
|
v.InvoiceType = 1
|
|
|
+ sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ GroupId: ppItem.SellerGroupId,
|
|
|
+ GroupName: ppItem.SellerGroupName,
|
|
|
+ TeamId: ppItem.SellerTeamId,
|
|
|
+ TeamName: ppItem.SellerTeamName,
|
|
|
+ }
|
|
|
+ j++
|
|
|
} else if ppItem.InvoiceType == 4 {
|
|
|
v.InvoiceType = 2
|
|
|
+ if sellerItem, ok := sellerItemMap[k]; ok {
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
+ }
|
|
|
+ k++
|
|
|
}
|
|
|
v.Set()
|
|
|
// 到款登记-付款方式
|
|
@@ -457,7 +520,10 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
opData = string(opDataByte)
|
|
|
- opType := fms.ContractRegisterOpTypePreInvoice
|
|
|
+ opType := fms.ContractRegisterOpTypePrePay
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ opType = fms.ContractRegisterOpTypePreInvoice
|
|
|
+ }
|
|
|
newAmount := decimal.NewFromFloat(0).Round(2)
|
|
|
a := decimal.NewFromFloat(v.Amount).Round(2)
|
|
|
newAmount = newAmount.Add(a)
|
|
@@ -484,6 +550,106 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ for _, ppItem := range nDupList {
|
|
|
+ if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
+ j := 0
|
|
|
+ v := &fms.ContractInvoice{
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
+ ContractCode: ob.ContractCode,
|
|
|
+ Amount: ppItem.Amount,
|
|
|
+ OriginAmount: ppItem.OriginAmount,
|
|
|
+ CurrencyUnit: ppItem.CurrencyUnit,
|
|
|
+ InvoiceDate: ppItem.InvoiceDate,
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ SellerGroupId: ppItem.SellerGroupId,
|
|
|
+ SellerGroupName: ppItem.SellerGroupName,
|
|
|
+ SellerTeamId: ppItem.SellerTeamId,
|
|
|
+ SellerTeamName: ppItem.SellerTeamName,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.RealName,
|
|
|
+ Remark: ppItem.Remark,
|
|
|
+ ServiceProductId: ppItem.ServiceProductId,
|
|
|
+ IsPrePay: 1,
|
|
|
+ StartDate: ppItem.StartDate,
|
|
|
+ EndDate: ppItem.EndDate,
|
|
|
+ }
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ v.InvoiceType = 1
|
|
|
+ } else if ppItem.InvoiceType == 4 {
|
|
|
+ v.InvoiceType = 2
|
|
|
+ if sellerItem, ok := sellerItemMap[j]; ok {
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
+ }
|
|
|
+ j++
|
|
|
+ }
|
|
|
+ v.Set()
|
|
|
+ // 到款登记-付款方式
|
|
|
+ v.PayType = fmsService.CalculateContractPaymentType(ppItem.Amount, ob.ContractAmount, dayDiff)
|
|
|
+
|
|
|
+ // 新增的记录
|
|
|
+ opData := ""
|
|
|
+ opDataByte, e := json.Marshal(req)
|
|
|
+ if e != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ opData = string(opDataByte)
|
|
|
+ opType := fms.ContractRegisterOpTypePrePay
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ opType = fms.ContractRegisterOpTypePreInvoice
|
|
|
+ }
|
|
|
+ newAmount := decimal.NewFromFloat(0).Round(2)
|
|
|
+ a := decimal.NewFromFloat(v.Amount).Round(2)
|
|
|
+ newAmount = newAmount.Add(a)
|
|
|
+ ia, _ := newAmount.Round(2).Float64()
|
|
|
+ logList = append(logList, &fms.ContractRegisterLog{
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.RealName,
|
|
|
+ OpData: opData,
|
|
|
+ OpType: opType,
|
|
|
+ CreateTime: nowTime,
|
|
|
+ AmountRemark: fmt.Sprint("新增", fms.ContractInvoiceKeyNameMap[opType], "金额", ia, "元"),
|
|
|
+ })
|
|
|
+
|
|
|
+ if e := v.Create(); e != nil {
|
|
|
+ resp.FailData("日期格式有误", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //最后删除预到款记录
|
|
|
+ e = ppItem.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除预到款记录失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ppOB := new(fms.ContractPreRegister)
|
|
|
+ items, e := ppOB.FetchByRegisterId(ppItem.ContractRegisterId)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.Fail("预登记记录不存在或已被删除", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("获取预登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, item := range items {
|
|
|
+ e = item.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除预登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
ppOB := new(fms.ContractPreRegister)
|
|
|
items, e := ppOB.FetchByRegisterId(req.ContractRegisterId)
|
|
|
if e != nil {
|
|
@@ -526,6 +692,151 @@ func (rg *RegisterController) Add(c *gin.Context) {
|
|
|
resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+ //处理重复公司名日期等重复的开票到款记录
|
|
|
+ dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate)
|
|
|
+ if e != nil {
|
|
|
+ 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 nDupList {
|
|
|
+ j := 0
|
|
|
+ if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ GroupId: ppItem.SellerGroupId,
|
|
|
+ GroupName: ppItem.SellerGroupName,
|
|
|
+ TeamId: ppItem.SellerTeamId,
|
|
|
+ TeamName: ppItem.SellerTeamName,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ j++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, ppItem := range nDupList {
|
|
|
+ j := 0
|
|
|
+ if ppItem.ContractRegisterId != req.ContractRegisterId {
|
|
|
+ v := &fms.ContractInvoice{
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
+ ContractCode: ob.ContractCode,
|
|
|
+ Amount: ppItem.Amount,
|
|
|
+ OriginAmount: ppItem.OriginAmount,
|
|
|
+ CurrencyUnit: ppItem.CurrencyUnit,
|
|
|
+ InvoiceDate: ppItem.InvoiceDate,
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ SellerGroupId: ppItem.SellerGroupId,
|
|
|
+ SellerGroupName: ppItem.SellerGroupName,
|
|
|
+ SellerTeamId: ppItem.SellerTeamId,
|
|
|
+ SellerTeamName: ppItem.SellerTeamName,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.RealName,
|
|
|
+ Remark: ppItem.Remark,
|
|
|
+ ServiceProductId: ppItem.ServiceProductId,
|
|
|
+ IsPrePay: 1,
|
|
|
+ StartDate: ppItem.StartDate,
|
|
|
+ EndDate: ppItem.EndDate,
|
|
|
+ }
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ v.InvoiceType = 1
|
|
|
+ } else if ppItem.InvoiceType == 4 {
|
|
|
+ v.InvoiceType = 2
|
|
|
+ if sellerItem, ok := sellerItemMap[j]; ok{
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
+
|
|
|
+ j++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v.Set()
|
|
|
+ // 到款登记-付款方式
|
|
|
+ v.PayType = fmsService.CalculateContractPaymentType(ppItem.Amount, ob.ContractAmount, dayDiff)
|
|
|
+
|
|
|
+ // 新增的记录
|
|
|
+ opData := ""
|
|
|
+ opDataByte, e := json.Marshal(req)
|
|
|
+ if e != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ opData = string(opDataByte)
|
|
|
+ opType := fms.ContractRegisterOpTypePrePay
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ opType = fms.ContractRegisterOpTypePreInvoice
|
|
|
+ }
|
|
|
+ newAmount := decimal.NewFromFloat(0).Round(2)
|
|
|
+ a := decimal.NewFromFloat(v.Amount).Round(2)
|
|
|
+ newAmount = newAmount.Add(a)
|
|
|
+ ia, _ := newAmount.Round(2).Float64()
|
|
|
+ logList = append(logList, &fms.ContractRegisterLog{
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.RealName,
|
|
|
+ OpData: opData,
|
|
|
+ OpType: opType,
|
|
|
+ CreateTime: nowTime,
|
|
|
+ AmountRemark: fmt.Sprint("新增", fms.ContractInvoiceKeyNameMap[opType], "金额", ia, "元"),
|
|
|
+ })
|
|
|
+
|
|
|
+ if e := v.Create(); e != nil {
|
|
|
+ resp.FailData("日期格式有误", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //最后删除预到款记录
|
|
|
+ e = ppItem.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除预到款记录失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ppOB := new(fms.ContractPreRegister)
|
|
|
+ items, e := ppOB.FetchByRegisterId(ppItem.ContractRegisterId)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.Fail("预登记记录不存在或已被删除", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("获取预登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, item := range items {
|
|
|
+ e = item.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除预登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 操作日志
|
|
|
+ go func() {
|
|
|
+ logOB := new(fms.ContractRegisterLog)
|
|
|
+ if e := logOB.AddInBatches(logList); e != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }()
|
|
|
}
|
|
|
|
|
|
// 操作日志
|
|
@@ -962,11 +1273,11 @@ func (rg *RegisterController) Detail(c *gin.Context) {
|
|
|
result.InvoiceList = make([]*fms.ContractInvoiceItem, 0)
|
|
|
result.PaymentList = make([]*fms.ContractInvoiceItem, 0)
|
|
|
for i := range invoiceList {
|
|
|
- if invoiceList[i].InvoiceType == fms.ContractInvoiceTypeMake || invoiceList[i].InvoiceType == fms.ContractInvoiceTypePreMake{
|
|
|
+ if invoiceList[i].InvoiceType == fms.ContractInvoiceTypeMake || invoiceList[i].InvoiceType == fms.ContractInvoiceTypePreMake {
|
|
|
result.InvoiceList = append(result.InvoiceList, invoiceList[i])
|
|
|
continue
|
|
|
}
|
|
|
- if invoiceList[i].InvoiceType == fms.ContractInvoiceTypePay || invoiceList[i].InvoiceType == fms.ContractInvoiceTypePrePay{
|
|
|
+ if invoiceList[i].InvoiceType == fms.ContractInvoiceTypePay || invoiceList[i].InvoiceType == fms.ContractInvoiceTypePrePay {
|
|
|
result.PaymentList = append(result.PaymentList, invoiceList[i])
|
|
|
}
|
|
|
}
|
|
@@ -1091,6 +1402,7 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
|
|
|
noChangeInvoiceIds := make([]int, 0)
|
|
|
newInvoice := make([]*fms.ContractInvoice, 0)
|
|
|
+ sellerMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
if len(req.AmountList) > 0 {
|
|
|
// 合同有效时长(计算付款方式)
|
|
|
dayDiff := item.EndDate.Sub(item.StartDate).Hours() / 24
|
|
@@ -1101,7 +1413,6 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
resp.FailData("获取销售失败", "Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- sellerMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
for i := range sellerList {
|
|
|
sellerMap[sellerList[i].SellerId] = sellerList[i]
|
|
|
}
|
|
@@ -1155,10 +1466,6 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
resp.Fail("销售信息异常", c)
|
|
|
return
|
|
|
}
|
|
|
- if req.AmountList[i].ServiceProductId == crm.CompanyProductFicc && sellerItem.DepartmentId != crm.SellerDepartmentId {
|
|
|
- resp.Fail("销售类型和所选套餐类型不一致", c)
|
|
|
- return
|
|
|
- }
|
|
|
if req.AmountList[i].ServiceProductId == crm.CompanyProductRai && sellerItem.DepartmentId != crm.RaiSellerDepartmentId {
|
|
|
resp.Fail("销售类型和所选套餐类型不一致", c)
|
|
|
return
|
|
@@ -1172,6 +1479,21 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
}
|
|
|
// 到款登记-付款方式
|
|
|
if req.InvoiceType == fms.ContractInvoiceTypePay {
|
|
|
+ sellerItem := sellerMap[req.AmountList[i].SellerId]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.AmountList[i].ServiceProductId == crm.CompanyProductRai && sellerItem.DepartmentId != crm.RaiSellerDepartmentId {
|
|
|
+ resp.Fail("销售类型和所选套餐类型不一致", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
v.PayType = fmsService.CalculateContractPaymentType(req.AmountList[i].Amount, item.ContractAmount, dayDiff)
|
|
|
}
|
|
|
newInvoice = append(newInvoice, v)
|
|
@@ -1244,6 +1566,33 @@ func (rg *RegisterController) Invoice(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ //如果是开票,强制修改到款记录的销售
|
|
|
+ if len(newInvoice) > 0 && req.InvoiceType == fms.ContractInvoiceTypeMake {
|
|
|
+ invoiceItem, err := fms.GetContractInvoiceByRegisterIdAndType(req.ContractRegisterId)
|
|
|
+ if err != nil && err != utils.ErrNoRow {
|
|
|
+ resp.FailMsg("获取到款数据失败", "获取到款数据失败, Err: "+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if err == nil {
|
|
|
+ sellerItem := sellerMap[newInvoice[0].SellerId]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ invoiceItem.SellerId = sellerItem.SellerId
|
|
|
+ invoiceItem.SellerName = sellerItem.SellerName
|
|
|
+ invoiceItem.SellerGroupId = sellerItem.GroupId
|
|
|
+ invoiceItem.SellerGroupName = sellerItem.GroupName
|
|
|
+ invoiceItem.SellerTeamId = sellerItem.TeamId
|
|
|
+ invoiceItem.SellerTeamName = sellerItem.TeamName
|
|
|
+ e = invoiceItem.Update([]string{"SellerId", "SellerName", "SellerGroupId", "SellerGroupName", "SellerTeamId", "SellerTeamName"})
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("更新到款销售失败", "更新到款销售失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// todo 判断是否符合均分金额的条件,如果符合,需要生成金额分配记录表
|
|
|
if req.InvoiceType == fms.ContractInvoiceTypePay {
|
|
|
err = fmsService.CalculatePaymentServiceAmount(req.ContractRegisterId)
|
|
@@ -1682,7 +2031,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
row3Title := make([]string, 0)
|
|
|
row3TitleParent := make([]string, 0)
|
|
|
row3Title = append(row3Title, "客户名称", "新客户\n0-是\n1-否", "合同类型\n0-自付合同\n1-代付合同",
|
|
|
- "合同子类型\n续约-0\n新签-1\n补充协议-2", "合同所属方", "代付方" ,"关联主合同(补充协议)", "关联合同(代付合同)")
|
|
|
+ "合同子类型\n续约-0\n新签-1\n补充协议-2", "合同所属方", "代付方", "关联主合同(补充协议)", "关联合同(代付合同)")
|
|
|
if req.ListParam == 0 {
|
|
|
row3Title = append(row3Title, "FICC销售", "权益销售", "FICC大套餐")
|
|
|
for i := range permissionList {
|
|
@@ -1756,7 +2105,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
row3Title = append(row3Title, t)
|
|
|
}
|
|
|
}
|
|
|
- paymentTitle := []string{"到款日", "到款金额", "套餐类型", "备注"}
|
|
|
+ paymentTitle := []string{"到款日", "到款金额", "套餐类型", "销售", "备注"}
|
|
|
for i := 0; i < maxPayment; i++ {
|
|
|
n := i + 1
|
|
|
for ii := range paymentTitle {
|
|
@@ -1803,16 +2152,15 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
dataRow.AddCell().SetString(v.ActualPayCompanies)
|
|
|
dataRow.AddCell().SetString(v.RelateContractMainCode)
|
|
|
dataRow.AddCell().SetString(v.RelateContractCode)
|
|
|
- if req.ListParam == 0{
|
|
|
+ if req.ListParam == 0 {
|
|
|
dataRow.AddCell().SetString(v.SellerName)
|
|
|
dataRow.AddCell().SetString(v.RaiSellerName)
|
|
|
- } else if req.ListParam == 1{
|
|
|
+ } else if req.ListParam == 1 {
|
|
|
dataRow.AddCell().SetString(v.SellerName)
|
|
|
} else {
|
|
|
dataRow.AddCell().SetString(v.RaiSellerName)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if req.ListParam != 0 {
|
|
|
k += 10
|
|
|
} else {
|
|
@@ -1879,13 +2227,13 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
dataRow.AddCell().SetString(v.CurrencyUnit) // 货币单位
|
|
|
if ficcAmount != nil {
|
|
|
dataRow.AddCell().SetString(fmt.Sprint("¥", ficcAmount.ServiceAmount)) // FICC套餐总金额
|
|
|
- if raiAmount == nil{
|
|
|
- dataRow.AddCell().SetString("") // 权益套餐总金额
|
|
|
+ if raiAmount == nil {
|
|
|
+ dataRow.AddCell().SetString("") // 权益套餐总金额
|
|
|
}
|
|
|
}
|
|
|
if raiAmount != nil {
|
|
|
- if ficcAmount == nil{
|
|
|
- dataRow.AddCell().SetString("") // 权益套餐总金额
|
|
|
+ if ficcAmount == nil {
|
|
|
+ dataRow.AddCell().SetString("") // 权益套餐总金额
|
|
|
}
|
|
|
dataRow.AddCell().SetString(fmt.Sprint("¥", raiAmount.ServiceAmount)) // FICC套餐总金额
|
|
|
}
|
|
@@ -1928,6 +2276,7 @@ func (rg *RegisterController) Export(c *gin.Context) {
|
|
|
dataRow.AddCell().SetString(utils.TimeTransferString("2006/01/02", pyList[ib].InvoiceDate)) // 收款日
|
|
|
dataRow.AddCell().SetString(fmt.Sprint(pyList[ib].OriginAmount)) // 收款金额
|
|
|
dataRow.AddCell().SetString(serviceProductIdMap[pyList[ib].ServiceProductId]) // 套餐类型
|
|
|
+ dataRow.AddCell().SetString(pyList[ib].SellerName) // 销售名称
|
|
|
dataRow.AddCell().SetString(pyList[ib].Remark) // 收款备注
|
|
|
continue
|
|
|
}
|
|
@@ -2223,7 +2572,8 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
resp.Fail("请上传Excel文件", c)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ claims, _ := c.Get("adminInfo")
|
|
|
+ adminInfo := claims.(*system.SysAdmin)
|
|
|
uploadDir := "static/xls"
|
|
|
err = os.MkdirAll(uploadDir, 766)
|
|
|
if err != nil {
|
|
@@ -2244,7 +2594,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
resp.FailData("打开文件失败", "Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ logList := make([]*fms.ContractRegisterLog, 0)
|
|
|
// 获取所有已登记,根据合同编号去重
|
|
|
contractCodeArr := make([]string, 0)
|
|
|
registerOB := new(fms.ContractRegister)
|
|
@@ -2371,6 +2721,8 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
for _, sheet := range xlFile.Sheets {
|
|
|
// 遍历行读取
|
|
|
maxRow := sheet.MaxRow
|
|
|
+ fmt.Println("maxRow", maxRow)
|
|
|
+ var dayDiff float64
|
|
|
for i := 0; i < maxRow; i++ {
|
|
|
// 第三行开始读取表头
|
|
|
if i == 2 {
|
|
@@ -2479,11 +2831,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
v := utils.TrimStr(cell.String())
|
|
|
// 客户名称
|
|
|
if k == 0 {
|
|
|
- if v == "" {
|
|
|
+ //pool_474 客户名称保留空格
|
|
|
+ if cell.String() == "" {
|
|
|
resp.Fail(fmt.Sprintf("第%d行客户名称不可为空, 请按模板导入", i+1), c)
|
|
|
return
|
|
|
}
|
|
|
- rowRegister.CompanyName = v
|
|
|
+ rowRegister.CompanyName = cell.String()
|
|
|
continue
|
|
|
}
|
|
|
// 是否新客户
|
|
@@ -2517,7 +2870,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
if k == 4 {
|
|
|
- if rowRegister.HasPayment == 1{
|
|
|
+ if rowRegister.HasPayment == 1 {
|
|
|
if v == "0" {
|
|
|
//所属方为实际使用方,不走开票到款流程
|
|
|
rowRegister.HasInvoice = 0
|
|
@@ -2823,11 +3176,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
// FICC 套餐总金额
|
|
|
if k == 62 {
|
|
|
amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行FICC套餐总金额有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
+ amount, _ := strconv.ParseFloat(amountStr, 64)
|
|
|
if amount > 0 {
|
|
|
tmp := &fms.ContractServiceAmount{
|
|
|
ProductId: crm.CompanyProductFicc,
|
|
@@ -2842,11 +3191,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
// 权益套餐总金额
|
|
|
if k == 63 {
|
|
|
amountStr := v
|
|
|
- amount, e := strconv.ParseFloat(amountStr, 64)
|
|
|
- if e != nil {
|
|
|
- resp.Fail(fmt.Sprintf("第%d行权益套餐总金额有误, 请按模板导入", i+1), c)
|
|
|
- return
|
|
|
- }
|
|
|
+ amount, _ := strconv.ParseFloat(amountStr, 64)
|
|
|
if amount > 0 {
|
|
|
tmp := &fms.ContractServiceAmount{
|
|
|
ProductId: crm.CompanyProductRai,
|
|
@@ -3046,7 +3391,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
// 付款方式
|
|
|
- dayDiff := rowRegister.EndDate.Sub(rowRegister.StartDate).Hours() / 24
|
|
|
+ dayDiff = rowRegister.EndDate.Sub(rowRegister.StartDate).Hours() / 24
|
|
|
contractAmount := rowRegister.ContractAmount
|
|
|
payType := fmsService.CalculateContractPaymentType(amount, contractAmount, dayDiff)
|
|
|
rowPayments[ir].PayType = payType
|
|
@@ -3073,6 +3418,25 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ // 到款销售
|
|
|
+ k2 += 1
|
|
|
+ if k == k2 {
|
|
|
+ if v != "" {
|
|
|
+ sellerItem := sellerMap[v]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail(fmt.Sprintf("第%d行到款销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ rowPayments[ir].SellerId = sellerItem.SellerId
|
|
|
+ rowPayments[ir].SellerName = sellerItem.SellerName
|
|
|
+ rowPayments[ir].SellerGroupId = sellerItem.GroupId
|
|
|
+ rowPayments[ir].SellerGroupName = sellerItem.GroupName
|
|
|
+ rowPayments[ir].SellerTeamId = sellerItem.TeamId
|
|
|
+ rowPayments[ir].SellerTeamName = sellerItem.TeamName
|
|
|
+ }
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
// 备注
|
|
|
k2 += 1
|
|
|
if k == k2 {
|
|
@@ -3147,13 +3511,163 @@ func (rg *RegisterController) Import(c *gin.Context) {
|
|
|
resp.FailData(fmt.Sprintf("第%d行导入失败", i+1), "新增导入登记失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ //处理重复公司名日期等重复的开票到款记录
|
|
|
+ sellerItemMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
+ dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(rowRegister.CompanyName, rowRegister.StartDate.Format(utils.FormatDate), rowRegister.EndDate.Format(utils.FormatDate))
|
|
|
+ if e != nil {
|
|
|
+ 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
|
|
|
+ if ppItem.ContractRegisterId != newId {
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ sellerItemMap[j] = &crm.SellerAdminWithGroupTeam{
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ GroupId: ppItem.SellerGroupId,
|
|
|
+ GroupName: ppItem.SellerGroupName,
|
|
|
+ TeamId: ppItem.SellerTeamId,
|
|
|
+ TeamName: ppItem.SellerTeamName,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ j++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, ppItem := range dupList {
|
|
|
+ j := 0
|
|
|
+ if ppItem.ContractRegisterId != newId {
|
|
|
+ v := &fms.ContractInvoice{
|
|
|
+ ContractRegisterId: newId,
|
|
|
+ ContractCode: rowRegister.ContractCode,
|
|
|
+ Amount: ppItem.Amount,
|
|
|
+ OriginAmount: ppItem.OriginAmount,
|
|
|
+ CurrencyUnit: ppItem.CurrencyUnit,
|
|
|
+ InvoiceDate: ppItem.InvoiceDate,
|
|
|
+ SellerId: ppItem.SellerId,
|
|
|
+ SellerName: ppItem.SellerName,
|
|
|
+ SellerGroupId: ppItem.SellerGroupId,
|
|
|
+ SellerGroupName: ppItem.SellerGroupName,
|
|
|
+ SellerTeamId: ppItem.SellerTeamId,
|
|
|
+ SellerTeamName: ppItem.SellerTeamName,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.RealName,
|
|
|
+ Remark: ppItem.Remark,
|
|
|
+ ServiceProductId: ppItem.ServiceProductId,
|
|
|
+ IsPrePay: 1,
|
|
|
+ StartDate: ppItem.StartDate,
|
|
|
+ EndDate: ppItem.EndDate,
|
|
|
+ }
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ v.InvoiceType = 1
|
|
|
+ } else if ppItem.InvoiceType == 4 {
|
|
|
+ v.InvoiceType = 2
|
|
|
+ if sellerItem, ok := sellerItemMap[j]; ok{
|
|
|
+ v.SellerId = sellerItem.SellerId
|
|
|
+ v.SellerName = sellerItem.SellerName
|
|
|
+ v.SellerGroupId = sellerItem.GroupId
|
|
|
+ v.SellerGroupName = sellerItem.GroupName
|
|
|
+ v.SellerTeamId = sellerItem.TeamId
|
|
|
+ v.SellerTeamName = sellerItem.TeamName
|
|
|
+
|
|
|
+ j++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v.Set()
|
|
|
+ // 到款登记-付款方式
|
|
|
+ v.PayType = fmsService.CalculateContractPaymentType(ppItem.Amount, rowRegister.ContractAmount, dayDiff)
|
|
|
+
|
|
|
+ // 新增的记录
|
|
|
+ opData := ""
|
|
|
+ //opDataByte, e := json.Marshal(req)
|
|
|
+ if e != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //opData = string(opDataByte)
|
|
|
+ opType := fms.ContractRegisterOpTypePrePay
|
|
|
+ if ppItem.InvoiceType == 3 {
|
|
|
+ opType = fms.ContractRegisterOpTypePreInvoice
|
|
|
+ }
|
|
|
+ newAmount := decimal.NewFromFloat(0).Round(2)
|
|
|
+ a := decimal.NewFromFloat(v.Amount).Round(2)
|
|
|
+ newAmount = newAmount.Add(a)
|
|
|
+ ia, _ := newAmount.Round(2).Float64()
|
|
|
+ logList = append(logList, &fms.ContractRegisterLog{
|
|
|
+ ContractRegisterId: newId,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.RealName,
|
|
|
+ OpData: opData,
|
|
|
+ OpType: opType,
|
|
|
+ CreateTime: time.Now().Local(),
|
|
|
+ AmountRemark: fmt.Sprint("新增", fms.ContractInvoiceKeyNameMap[opType], "金额", ia, "元"),
|
|
|
+ })
|
|
|
+
|
|
|
+ if e := v.Create(); e != nil {
|
|
|
+ resp.FailData("日期格式有误", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //最后删除预到款记录
|
|
|
+ e = ppItem.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除预到款记录失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ppOB := new(fms.ContractPreRegister)
|
|
|
+ items, e := ppOB.FetchByRegisterId(ppItem.ContractRegisterId)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.Fail("预登记记录不存在或已被删除", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("获取预登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, item := range items {
|
|
|
+ e = item.Delete()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("删除预登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 自动分配套餐金额
|
|
|
go fmsService.CalculatePaymentServiceAmount(newId)
|
|
|
newIds = append(newIds, newId)
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 操作日志
|
|
|
+ go func() {
|
|
|
+ logOB := new(fms.ContractRegisterLog)
|
|
|
+ if e := logOB.AddInBatches(logList); e != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
resp.Ok("操作成功", c)
|
|
|
}
|
|
|
|
|
@@ -3265,3 +3779,104 @@ func (rg *RegisterController) CheckContractName(c *gin.Context) {
|
|
|
resp.OkData("查询成功", data, c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// CheckContract
|
|
|
+// @Title 货币单位列表
|
|
|
+// @Description 货币单位列表
|
|
|
+// @Success 200 {object} fms.CheckContractNameResp
|
|
|
+// @router /contract/register/check_contract_duplicate [post]
|
|
|
+func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
|
|
|
+ var req fms.CheckContractDuplicateReq
|
|
|
+ if e := c.ShouldBind(&req); e != nil {
|
|
|
+ err, ok := e.(validator.ValidationErrors)
|
|
|
+ if !ok {
|
|
|
+ resp.FailData("参数解析失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailData("参数解析失败", err.Translate(global.Trans), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ existCond := ""
|
|
|
+ existPars := make([]interface{}, 0)
|
|
|
+ if req.CompanyName != "" {
|
|
|
+ // 是否存在相同的合同名称的登记
|
|
|
+ existCond = ` company_name = ?`
|
|
|
+ existPars = append(existPars, req.CompanyName)
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
+ // 日期校验
|
|
|
+ startDate, e := time.ParseInLocation(utils.FormatDate, req.StartDate, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("合同开始日期格式有误", "合同开始日期格式有误, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ endDate, e := time.ParseInLocation(utils.FormatDate, req.EndDate, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("合同结束日期格式有误", "合同结束日期格式有误, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if existCond != "" {
|
|
|
+ existCond += ` AND (start_date =? and end_date=?)`
|
|
|
+ } else {
|
|
|
+ existCond = ` start_date = ? and end_date=?`
|
|
|
+ }
|
|
|
+
|
|
|
+ existPars = append(existPars, startDate, endDate)
|
|
|
+ }
|
|
|
+
|
|
|
+ if existCond == "" {
|
|
|
+ resp.Fail("请输入合同名称或者合同有效期", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data := fms.CheckContractDuplicateResp{
|
|
|
+ Exist: 0,
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否存在相同合同名称的登记
|
|
|
+ list, e := fms.CheckContractDuplicate(existCond, existPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("操作失败", "查询重复合同失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ registerIds := make([]int, 0)
|
|
|
+ for i := range list {
|
|
|
+ registerIds = append(registerIds, list[i].ContractRegisterId)
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
+}
|