ziwen 1 年之前
父节点
当前提交
018b0ad469
共有 2 个文件被更改,包括 15 次插入11 次删除
  1. 13 9
      controller/contract/register.go
  2. 2 2
      models/fms/contract_invoice.go

+ 13 - 9
controller/contract/register.go

@@ -423,7 +423,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
 		//	sellerMap[sellerList[i].SellerId] = sellerList[i]
 		//}
 		//处理重复公司名日期等重复的开票到款记录
-		dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate)
+		dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate, req.ContractType, req.HasPayment)
 		if e != nil {
 			err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
 			return
@@ -693,7 +693,7 @@ func (rg *RegisterController) Add(c *gin.Context) {
 			return
 		}
 		//处理重复公司名日期等重复的开票到款记录
-		dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate)
+		dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(ob.CompanyName, req.StartDate, req.EndDate, req.ContractType, req.HasPayment)
 		if e != nil {
 			err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
 			return
@@ -3577,7 +3577,7 @@ func (rg *RegisterController) Import(c *gin.Context) {
 
 				//处理重复公司名日期等重复的开票到款记录
 				sellerItemMap := make(map[int]*crm.SellerAdminWithGroupTeam)
-				dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(rowRegister.CompanyName, rowRegister.StartDate.Format(utils.FormatDate), rowRegister.EndDate.Format(utils.FormatDate))
+				dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(rowRegister.CompanyName, rowRegister.StartDate.Format(utils.FormatDate), rowRegister.EndDate.Format(utils.FormatDate), rowRegister.ContractType, rowRegister.HasPayment)
 				if e != nil {
 					err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
 					return
@@ -3862,7 +3862,7 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
 	existPars := make([]interface{}, 0)
 	if req.CompanyName != "" {
 		// 是否存在相同的合同名称的登记
-		existCond = ` company_name = ?`
+		existCond = ` a.company_name = ?`
 		existPars = append(existPars, req.CompanyName)
 	}
 
@@ -3879,9 +3879,9 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
 			return
 		}
 		if existCond != "" {
-			existCond += ` AND (start_date =? and end_date=?)`
+			existCond += ` AND (a.start_date =? and a.end_date=?)`
 		} else {
-			existCond = ` start_date = ? and end_date=?`
+			existCond = ` a.start_date = ? and a.end_date=?`
 		}
 
 		existPars = append(existPars, startDate, endDate)
@@ -3891,6 +3891,10 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
 		resp.Fail("请输入合同名称或者合同有效期", c)
 		return
 	}
+
+	existCond = ` AND a.contract_type = ? AND a.has_payment`
+	existPars = append(existPars, req.CompanyName, req.HasPayment)
+
 	data := fms.CheckContractDuplicateResp{
 		Exist: 0,
 	}
@@ -3940,10 +3944,10 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
 		templateIdStr := strings.Join(ids, ",")
 
 		for _, v := range dupList {
-			if serviceIds, ok := serviceIdMap[v.ContractRegisterId]; ok{
-				if serviceIds == templateIdStr{
+			if serviceIds, ok := serviceIdMap[v.ContractRegisterId]; ok {
+				if serviceIds == templateIdStr {
 					data.Exist = 1
-					if _, ok2 := typeIdMap[v.ContractRegisterId]; ok2{
+					if _, ok2 := typeIdMap[v.ContractRegisterId]; ok2 {
 						data.Type = 1
 					}
 				}

+ 2 - 2
models/fms/contract_invoice.go

@@ -643,12 +643,12 @@ type DupInvoice struct {
 }
 
 // GetDuplicateContractInvoiceDetailItemList 预登记列表详情用-获取开票到款列表
-func GetDuplicateContractInvoiceDetailItemList(companyName, startDate, endDate string) (list []*DupInvoice, err error) {
+func GetDuplicateContractInvoiceDetailItemList(companyName, startDate, endDate string, contractType, hasPayment int) (list []*DupInvoice, err error) {
 	err = global.DEFAULT_MYSQL.Table("contract_invoice as a ").
 		Select(" a.*,GROUP_CONCAT(c.service_template_id ORDER BY c.service_template_id ) AS template_ids ").
 		Joins(" JOIN contract_register as b ON a.contract_register_id = b.contract_register_id ").
 		Joins("JOIN contract_service AS c ON a.contract_register_id = c.contract_register_id").
-		Where(fmt.Sprintf("a.is_deleted = 0 AND b.company_name = '%s' AND b.start_date= '%s' AND b.end_date= '%s' AND b.is_deleted=0 AND (a.invoice_type=3 OR a.invoice_type=4) ", companyName, startDate, endDate)).
+		Where(fmt.Sprintf("a.is_deleted = 0 AND b.company_name = '%s' AND b.start_date= '%s' AND b.end_date= '%s' AND b.is_deleted=0 AND (a.invoice_type=3 OR a.invoice_type=4) AND b.contract_type=? AND b.has_payment=?", companyName, startDate, endDate), contractType, hasPayment).
 		Group("a.contract_register_id").
 		Order("a.contract_invoice_id ASC").
 		Find(&list).Error