ziwen 2 years ago
parent
commit
a475c58b18
2 changed files with 10 additions and 10 deletions
  1. 7 7
      controller/contract/register.go
  2. 3 3
      models/fms/contract_invoice.go

+ 7 - 7
controller/contract/register.go

@@ -1791,38 +1791,38 @@ func (rg *RegisterController) InvoiceList(c *gin.Context) {
 		pars = append(pars, kw)
 		// 开票列表同时模糊查询销售名称
 		if req.InvoiceType == fms.ContractInvoiceTypeMake {
-			cond += ` AND (contract_code LIKE ? )`
+			cond += ` AND (a.contract_code LIKE ? )`
 			pars = append(pars, kw)
 		} else {
-			cond += ` AND contract_code LIKE ?`
+			cond += ` AND a.contract_code LIKE ?`
 			pars = append(pars, kw)
 		}
 	}
 	if req.StartDate != "" && req.EndDate != "" {
 		st := fmt.Sprint(req.StartDate, " 00:00:00")
 		ed := fmt.Sprint(req.EndDate, " 23:59:59")
-		cond += ` AND (invoice_time BETWEEN ? AND ?)`
+		cond += ` AND (a.invoice_time BETWEEN ? AND ?)`
 		pars = append(pars, st, ed)
 	}
 	if req.MinAmount > 0 {
-		cond += ` AND amount >= ?`
+		cond += ` AND a.amount >= ?`
 		pars = append(pars, req.MinAmount)
 	}
 	if req.MaxAmount > 0 {
-		cond += ` AND amount <= ?`
+		cond += ` AND a.amount <= ?`
 		pars = append(pars, req.MaxAmount)
 	}
 
 	// 套餐类型
 	if req.ServiceProductId > 0 {
-		cond += ` AND service_product_id = ?`
+		cond += ` AND a.service_product_id = ?`
 		pars = append(pars, req.ServiceProductId)
 	}
 
 	// 销售
 	if req.SellerIds != "" {
 		sellerIds := strings.Split(req.SellerIds, ",")
-		cond += ` AND (seller_id in (?))`
+		cond += ` AND (a.seller_id in (?))`
 		pars = append(pars, sellerIds)
 	}
 

+ 3 - 3
models/fms/contract_invoice.go

@@ -491,9 +491,9 @@ type InvoiceListCurrencySum struct {
 
 // GetInvoiceListCurrencySum 获取开票/到款分货币合计
 func GetInvoiceListCurrencySum(condition string, pars []interface{}, groupRule string) (results []*InvoiceListCurrencySum, err error) {
-	query := global.DEFAULT_MYSQL.Table("contract_invoice").
-		Select("currency_unit, invoice_type, SUM(amount) AS amount_total, SUM(origin_amount) AS origin_amount_total").
-		Where("is_deleted = 0").
+	query := global.DEFAULT_MYSQL.Table("contract_invoice AS a").
+		Select("a.currency_unit, a.invoice_type, SUM(a.amount) AS amount_total, SUM(a.origin_amount) AS origin_amount_total").
+		Where("a.is_deleted = 0").
 		Where(condition, pars...).
 		Group(groupRule)
 	err = query.Find(&results).Error