zwxi 1 anno fa
parent
commit
f0ff098074
1 ha cambiato i file con 14 aggiunte e 1 eliminazioni
  1. 14 1
      controller/census/seller.go

+ 14 - 1
controller/census/seller.go

@@ -497,6 +497,7 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 		historyCond += ` AND new_company = 0 `
 	}
 
+	groupIds := make([]int, 0)
 	if req.GroupId > 0 {
 		// 筛选组别时, 查询当前组别的下级组(因为admin表存的group_id, 有三级的存的是子ID, 只有二级的存的才是父ID =_=!)
 		groupCond := `parent_id = ?`
@@ -508,7 +509,6 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 			resp.FailMsg("获取失败", "获取组别下级组列表失败, Err: "+e.Error(), c)
 			return
 		}
-		groupIds := make([]int, 0)
 		groupIds = append(groupIds, req.GroupId)
 		for i := range groupList {
 			groupIds = append(groupIds, groupList[i].GroupId)
@@ -559,6 +559,11 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 			amountCond := `a.id IN ? `
 			amountPars := make([]interface{}, 0)
 			amountPars = append(amountPars, summaryIds)
+			if len(groupIds) > 0 {
+				historyCond += ` AND AND IF ( a.invoice_id = 0, d.seller_group_id, b.seller_group_id ) IN (?) `
+				historyPars = append(historyPars, groupIds)
+			}
+
 			//if req.SellerIds != "" {
 			//	sellerIds := strings.Split(req.SellerIds, ",")
 			//	amountCond += ` AND (( b.seller_id IN ? AND a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
@@ -639,6 +644,10 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 			amountCond := `a.id IN ? `
 			amountPars := make([]interface{}, 0)
 			amountPars = append(amountPars, summaryIds)
+			if len(groupIds) > 0 {
+				historyCond += ` AND AND IF ( a.invoice_id = 0, d.seller_group_id, b.seller_group_id ) IN (?) `
+				historyPars = append(historyPars, groupIds)
+			}
 			//if req.SellerIds != "" {
 			//	sellerIds := strings.Split(req.SellerIds, ",")
 			//	amountCond += ` AND (( b.seller_id IN ? AND a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
@@ -733,6 +742,10 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 			amountCond := `a.id IN ? `
 			amountPars := make([]interface{}, 0)
 			amountPars = append(amountPars, summaryIds)
+			if len(groupIds) > 0 {
+				historyCond += ` AND AND IF ( a.invoice_id = 0, d.seller_group_id, b.seller_group_id ) IN (?) `
+				historyPars = append(historyPars, groupIds)
+			}
 			//if req.SellerIds != "" {
 			//	sellerIds := strings.Split(req.SellerIds, ",")
 			//	amountCond += ` AND (( b.seller_id IN ? AND a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`