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

+ 1 - 1
controller/contract/register.go

@@ -3903,7 +3903,7 @@ func (rg *RegisterController) CheckContractDuplicate(c *gin.Context) {
 
 	// 是否存在相同合同名称的登记
 	//处理重复公司名日期等重复的开票到款记录
-	dupList, e := fms.GetDuplicateContractInvoiceDetailItemList(req.CompanyName, req.StartDate, req.EndDate, req.ContractType, req.HasPayment)
+	dupList, e := fms.GetDuplicateContractInvoiceDetailItemListForSupplement(req.CompanyName, req.StartDate, req.EndDate, req.ContractType, req.HasPayment)
 	if e != nil {
 		resp.FailMsg("操作失败", "查询重复合同失败, Err: "+e.Error(), c)
 		return

+ 17 - 1
models/fms/contract_invoice.go

@@ -645,7 +645,7 @@ type DupInvoice struct {
 // GetDuplicateContractInvoiceDetailItemList 预登记列表详情用-获取开票到款列表
 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 ").
+		Select(" a.*,GROUP_CONCAT(DISTINCT 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) AND b.contract_type=? AND b.has_payment=?", companyName, startDate, endDate), contractType, hasPayment).
@@ -721,3 +721,19 @@ type NotPaymentCensusInfo struct {
 	ServiceProductId  int                                 `json:"service_product_id" description:"套餐类型:1ficc套餐,2权益套餐"`
 	UnitName          string                              `json:"unit_name" description:"单位名称"`
 }
+
+// GetDuplicateContractInvoiceDetailItemList 补录合同用-获取开票到款列表
+func GetDuplicateContractInvoiceDetailItemListForSupplement(companyName, startDate, endDate string, contractType, hasPayment int) (list []*DupInvoice, err error) {
+	err = global.DEFAULT_MYSQL.Table("contract_invoice as a ").
+		Select(" a.*,GROUP_CONCAT(DISTINCT 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 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
+	if err != nil {
+		return
+	}
+	return
+}