Jelajahi Sumber

Merge branch 'pool_677' into debug

ziwen 1 tahun lalu
induk
melakukan
fb8cfc3e3d

+ 14 - 2
controller/census/invoice_payment.go

@@ -2454,6 +2454,18 @@ func ExportNotInvoiceCensusList(c *gin.Context, results *fms.NotInvoicePaymentCe
 		return
 	}
 
+	// 前三行-开票金额合计
+	rowA := sheet.AddRow()
+	cellAA := rowA.AddCell()
+	cellAA.SetString(fmt.Sprintf("未开票合计金额(换算后):%.2f(元)", results.NotInvoiceTotal))
+	rowBData := "未开票金额:"
+	for _, v := range results.NotInvoiceCurrencyTotal {
+		rowBData += fmt.Sprintf("%s%.2f(%s)  ", v.Name, v.Amount, v.UnitName)
+	}
+	rowB := sheet.AddRow()
+	rowB.AddCell().SetString(rowBData)
+	sheet.AddRow()
+
 	// 数据表头
 	rowTitle := []string{"序号", "客户名称", "合同编号", "合同开始时间", "合同结束时间", "合同金额", "金额单位", "未开票金额", "套餐类型", "销售", "销售组别", "销售类型"}
 	titleRow := sheet.AddRow()
@@ -2648,7 +2660,7 @@ func ExportNotPaymentCensusList(c *gin.Context, results *fms.NotInvoicePaymentCe
 	// 前三行-开票金额合计
 	rowA := sheet.AddRow()
 	cellAA := rowA.AddCell()
-	cellAA.SetString(fmt.Sprintf("开票未到款合计金额(换算后):%.2f(元)", results.InvoiceTotal))
+	cellAA.SetString(fmt.Sprintf("开票未到款合计金额(换算后):%.2f(元)", results.NotPaymentTotal))
 	rowBData := "开票未到款金额:"
 	for _, v := range results.NotPaymentCurrencyTotal {
 		rowBData += fmt.Sprintf("%s%.2f(%s)  ", v.Name, v.Amount, v.UnitName)
@@ -2703,7 +2715,7 @@ func ExportNotPaymentCensusList(c *gin.Context, results *fms.NotInvoicePaymentCe
 		for _, v2 := range v.InvoicePaymentList {
 			rowData := []string{
 				v2.InvoiceDate,               // 开票日
-				fmt.Sprint(v2.InvoiceAmount), // 开票金额
+				fmt.Sprint(v2.NotPaymentAmount), // 开票金额
 				v2.UnitName,                  // 开票金额
 				v2.SellerName,                // 销售
 				v2.SellerGroupName,           // 组别

+ 1 - 1
controller/contract/pre_register.go

@@ -863,7 +863,7 @@ func (rg *PreRegisterController) Detail(c *gin.Context) {
 	}
 
 	if req.DetailType == 1 {
-		dupList, e := fms.GetDuplicateContractInvoiceDetailItemListWithType(nItme.CompanyName, nItme.StartDate, nItme.EndDate)
+		dupList, e := fms.GetDuplicateContractInvoiceDetailItemListWithType(nItme.CompanyName, nItme.StartDate, nItme.EndDate, req.ContractType, req.HasPayment)
 		if e != nil {
 			err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
 			return

+ 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
@@ -697,7 +697,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
@@ -3590,7 +3590,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
@@ -3882,7 +3882,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)
 	}
 
@@ -3899,9 +3899,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)
@@ -3911,6 +3911,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,
 	}
@@ -3960,10 +3964,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
 					}
 				}

+ 6 - 4
models/fms/contract_invoice.go

@@ -614,13 +614,15 @@ func (c *ContractInvoice) FetchByRegisterId(registerId int) (items []*ContractIn
 }
 
 // GetDuplicateContractInvoiceDetailItemListWithType 预登记列表详情用-获取开票到款列表
-func GetDuplicateContractInvoiceDetailItemListWithType(companyName, startDate, endDate string) (itemList []*ContractInvoiceDetailItem, err error) {
+func GetDuplicateContractInvoiceDetailItemListWithType(companyName, startDate, endDate string,contractType, hasPayment int) (itemList []*ContractInvoiceDetailItem, err error) {
 	list := make([]*InvoiceDetailItem, 0)
 	err = global.DEFAULT_MYSQL.Table("contract_invoice as a ").
 		Select(" a.*,IF(p.seller_id > 0, 1, 0) AS has_invoice_seller  ").
 		Joins(" JOIN contract_register as b ON a.contract_register_id = b.contract_register_id ").
 		Joins("JOIN contract_pre_register AS p ON p.invoice_id = a.contract_invoice_id OR p.arrive_id = a.contract_invoice_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).
 		Order("a.contract_invoice_id ASC").
 		Find(&list).Error
 	if err != nil {
@@ -641,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

+ 2 - 0
models/fms/contract_pre_register.go

@@ -227,6 +227,8 @@ type PreRegisterDetailReq struct {
 	InvoiceId          int `gorm:"column:invoice_id" json:"invoice_id" description:"开票ID"`
 	ArriveId           int `gorm:"column:arrive_id" json:"arrive_id" description:"到款ID"`
 	DetailType         int `json:"detail_type" description:"请求类型"`
+	ContractType       int `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"`
+	HasPayment         int `json:"has_payment" description:"是否有代付: 0-无; 1-有"`
 }
 
 // ContractPreRegisterDetail 预登记详情

+ 6 - 4
models/fms/contract_register.go

@@ -909,10 +909,12 @@ func UpdateSupplementContractPreRegister(item *ContractRegister, serviceAmountLi
 }
 
 type CheckContractDuplicateReq struct {
-	CompanyName string                  `json:"company_name" form:"company_name" description:"客户名称"`
-	StartDate   string                  `json:"start_date" form:"start_date" description:"合同开始日期"`
-	EndDate     string                  `json:"end_date" form:"end_date" description:"合同结束日期"`
-	Services    []ContractServiceAddReq `json:"services" description:"服务套餐内容"`
+	CompanyName  string                  `json:"company_name" form:"company_name" description:"客户名称"`
+	StartDate    string                  `json:"start_date" form:"start_date" description:"合同开始日期"`
+	EndDate      string                  `json:"end_date" form:"end_date" description:"合同结束日期"`
+	ContractType int                     `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"`
+	HasPayment   int                     `json:"has_payment" description:"是否有代付: 0-无; 1-有"`
+	Services     []ContractServiceAddReq `json:"services" description:"服务套餐内容"`
 }
 
 func CheckContractDuplicate(condition string, pars []interface{}) (list []*ContractRegister, err error) {