Browse Source

Merge branch 'fms_2.7' into debug

ziwen 1 year ago
parent
commit
ff51875506
2 changed files with 26 additions and 4 deletions
  1. 19 0
      controller/contract/register.go
  2. 7 4
      models/fms/invoice_payment_summary.go

+ 19 - 0
controller/contract/register.go

@@ -3103,6 +3103,25 @@ func (rg *RegisterController) Import(c *gin.Context) {
 							continue
 						}
 
+						// 到款销售
+						k2 += 1
+						if k == k2 {
+							if v != "" {
+								sellerItem := sellerMap[v]
+								if sellerItem == nil {
+									resp.Fail(fmt.Sprintf("第%d行到款销售名称与系统销售不匹配, 请核对名称后导入", i+1), c)
+									return
+								}
+								rowPayments[ir].SellerId = sellerItem.SellerId
+								rowPayments[ir].SellerName = sellerItem.SellerName
+								rowPayments[ir].SellerGroupId = sellerItem.GroupId
+								rowPayments[ir].SellerGroupName = sellerItem.GroupName
+								rowPayments[ir].SellerTeamId = sellerItem.TeamId
+								rowPayments[ir].SellerTeamName = sellerItem.TeamName
+							}
+							continue
+						}
+
 						// 备注
 						k2 += 1
 						if k == k2 {

+ 7 - 4
models/fms/invoice_payment_summary.go

@@ -174,10 +174,13 @@ func GetContractSummaryInvoicePaymentAmount(condition string, pars []interface{}
 	joinCond := ` (a.invoice_id = b.contract_invoice_id OR a.payment_id = b.contract_invoice_id) `
 
 	query := global.DEFAULT_MYSQL.Table("invoice_payment_summary AS a").
-		Select("IFNULL(SUM(b.amount),0)").
-		Joins(fmt.Sprintf("JOIN contract_invoice AS b ON %s AND b.is_deleted = 0 ", joinCond)).
-		Where(condition, pars...)
-	err = query.Find(&amountTotal).Error
+		Select("b.amount").
+		Joins(fmt.Sprintf(" JOIN contract_invoice AS b ON %s AND b.is_deleted = 0 ", joinCond)).
+		Where(condition, pars...).Group("id")
+	nq := global.DEFAULT_MYSQL.Table("(?) AS e", query).
+		Select(" IFNULL( SUM( e.amount ), 0 ) ")
+
+	err = nq.Find(&amountTotal).Error
 	return
 }