Browse Source

fix: 接口完善

hsun 2 years ago
parent
commit
94d47f62fc

+ 7 - 7
controller/census/invoice_payment.go

@@ -29,9 +29,9 @@ type InvoicePaymentController struct{}
 // @Param   StartDate		query	string	false	"合同开始日期"
 // @Param   EndDate			query	string	false	"合同结束日期"
 // @Param   TimeType		query	int		false	"时间类型: 1-开票时间; 2-到款时间"
-// @Param   HasInvoice		query	int		false	"已开票"
-// @Param   HasPayment		query	int		false	"已到款"
-// @Param   IsExport		query	int		false	"是否导出"
+// @Param   HasInvoice		query	int		false	"是否已开票: 0-否; 1-是"
+// @Param   HasPayment		query	int		false	"是否已到款: 0-否; 1-是"
+// @Param   IsExport		query	int		false	"是否导出: 0-否; 1-是"
 // @Success 200 {object} fms.ContractRegisterItem
 // @router /census/invoice_payment/list [get]
 func (ct *InvoicePaymentController) List(c *gin.Context) {
@@ -48,10 +48,10 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
 
 	cond := `1 = 1`
 	pars := make([]interface{}, 0)
-	// 合同编号/客户姓名/销售/实际使用方
+	// 合同编号/客户姓名/销售
 	if req.Keyword != "" {
 		kw := "%" + req.Keyword + "%"
-		cond += ` b.company_name LIKE ? OR a.seller_name LIKE ?`
+		cond += ` AND b.company_name LIKE ? OR a.seller_name LIKE ?`
 		pars = append(pars, kw, kw)
 	}
 	if req.SellGroupId > 0 {
@@ -66,7 +66,7 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
 			return
 		}
 		if len(registerIds) > 0 {
-			cond += ` AND contract_register_id IN ?`
+			cond += ` AND b.contract_register_id IN ?`
 			pars = append(pars, registerIds)
 		} else {
 			cond += ` AND 1 = 2`
@@ -76,7 +76,7 @@ func (ct *InvoicePaymentController) List(c *gin.Context) {
 	if req.TimeType > 0 && req.StartDate != "" && req.EndDate != "" {
 		st := fmt.Sprint(req.StartDate, " 00:00:00")
 		ed := fmt.Sprint(req.EndDate, " 23:59:59")
-		cond += ` a.invoice_type = ? AND (invoice_time BETWEEN ? AND ?)`
+		cond += ` AND a.invoice_type = ? AND (a.invoice_time BETWEEN ? AND ?)`
 		pars = append(pars, req.TimeType, st, ed)
 	}
 	// 已开票

+ 5 - 0
controller/contract/register.go

@@ -1911,7 +1911,12 @@ func (rg *RegisterController) Import(c *gin.Context) {
 									resp.Fail(fmt.Sprintf("第%d行到款金额%d有误, 请按模板导入", i+1, n), c)
 									return
 								}
+								// 付款方式
+								dayDiff := rowRegister.EndDate.Sub(rowRegister.StartDate).Hours() / 24
+								contractAmount := rowRegister.ContractAmount
+								payType := fmsService.CalculateContractPaymentType(amount, contractAmount, dayDiff)
 								rowPayments[ir].Amount = amount
+								rowPayments[ir].PayType = payType
 							}
 							continue
 						}

+ 4 - 2
models/fms/contract_invoice.go

@@ -245,8 +245,8 @@ type InvoicePaymentCensusListReq struct {
 	StartDate   string `json:"start_date" form:"start_date" binding:"omitempty,datetime=2006-01-02" description:"开始日期"`
 	EndDate     string `json:"end_date" form:"end_date" binding:"omitempty,datetime=2006-01-02" description:"结束日期"`
 	TimeType    int    `json:"time_type" form:"time_type" description:"时间类型: 1-开票时间; 2-到款时间"`
-	HasInvoice  int    `json:"has_invoice" form:"has_invoice" description:"已开票"`
-	HasPayment  int    `json:"has_payment" form:"has_payment" description:"已到款"`
+	HasInvoice  int    `json:"has_invoice" form:"has_invoice" description:"是否已开票: 0-否; 1-是"`
+	HasPayment  int    `json:"has_payment" form:"has_payment" description:"是否已到款: 0-否; 1-是"`
 	IsExport    int    `json:"is_export" form:"is_export" description:"是否导出: 0-否; 1-是"`
 	base.PageReq
 }
@@ -259,6 +259,7 @@ func GetInvoicePaymentCensusPageList(page base.IPage, condition string, pars []i
 		Where("a.is_deleted = 0 AND b.is_deleted = 0").
 		Where(condition, pars...).
 		Group("b.contract_register_id")
+	//query.Count(&count)
 	if len(page.GetOrderItemsString()) > 0 {
 		query = query.Order(page.GetOrderItemsString())
 	}
@@ -268,6 +269,7 @@ func GetInvoicePaymentCensusPageList(page base.IPage, condition string, pars []i
 	}
 	// 计数
 	queryCount := global.DEFAULT_MYSQL.Table("contract_invoice AS a").
+		Select("b.contract_register_id").
 		Joins("JOIN contract_register AS b ON a.contract_register_id = b.contract_register_id").
 		Where("a.is_deleted = 0 AND b.is_deleted = 0").
 		Where(condition, pars...).

+ 2 - 0
models/fms/contract_register.go

@@ -126,6 +126,7 @@ type ContractRegisterItem struct {
 	Remark             string  `json:"remark" description:"备注信息"`
 	ServiceRemark      string  `json:"service_remark" description:"套餐备注信息"`
 	HasPayment         int     `json:"has_payment" description:"是否有代付: 0-无; 1-有"`
+	NewCompany         int     `json:"new_company" description:"是否为新客户: 0-否; 1-是"`
 	CreateTime         string  `json:"create_time" description:"登记时间"`
 }
 
@@ -353,6 +354,7 @@ func formatContractRegister2Item(item *ContractRegister) (formatItem *ContractRe
 	formatItem.Remark = item.Remark
 	formatItem.ServiceRemark = item.ServiceRemark
 	formatItem.HasPayment = item.HasPayment
+	formatItem.NewCompany = item.NewCompany
 	formatItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, item.CreateTime)
 	return
 }

+ 2 - 0
services/fms/invoice_payment.go

@@ -108,6 +108,7 @@ func MergeInvoiceList2InvoicePaymentCensusInfo(invoiceList []*fms.ContractInvoic
 			v.InvoiceAmount = invoiceList[i].Amount
 			v.SellerId = invoiceList[i].SellerId
 			v.SellerName = invoiceList[i].SellerName
+			v.SellerGroupId = invoiceList[i].SellerGroupId
 			v.SellerGroupName = invoiceList[i].SellerGroupName
 			// 直接取对应键的到款列表
 			if i+1 <= paymentLen {
@@ -143,6 +144,7 @@ func MergeInvoiceList2InvoicePaymentCensusInfo(invoiceList []*fms.ContractInvoic
 					v.InvoiceAmount = invoiceItem.Amount
 					v.SellerId = invoiceItem.SellerId
 					v.SellerName = invoiceItem.SellerName
+					v.SellerGroupId = invoiceList[i].SellerGroupId
 					v.SellerGroupName = invoiceList[i].SellerGroupName
 				}
 			}