Browse Source

Merge branch 'seller_census'

zwxi 1 year ago
parent
commit
42da6721a5
2 changed files with 78 additions and 75 deletions
  1. 61 60
      controller/census/seller.go
  2. 17 15
      models/fms/contract_invoice.go

+ 61 - 60
controller/census/seller.go

@@ -17,6 +17,7 @@ import (
 	"net/http"
 	"sort"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -564,16 +565,16 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 				amountPars = append(amountPars, 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 ?)`
-			//	amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
-			//	amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
-			//} else {
-			//	amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
-			//	amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
-			//	amountPars = append(amountPars, st, ed, st, ed)
-			//}
+			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 ?)`
+				amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
+				amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
+			} else {
+				amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
+				amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
+				amountPars = append(amountPars, st, ed, st, ed)
+			}
 			results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
 			if e != nil {
 				resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
@@ -648,16 +649,16 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 				amountCond += ` AND IF ( a.invoice_id = 0, d.seller_group_id, b.seller_group_id ) IN (?) `
 				amountPars = append(amountPars, 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 ?)`
-			//	amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
-			//	amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
-			//} else {
-			//	amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
-			//	amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
-			//	amountPars = append(amountPars, st, ed, st, ed)
-			//}
+			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 ?)`
+				amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
+				amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
+			} else {
+				amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
+				amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
+				amountPars = append(amountPars, st, ed, st, ed)
+			}
 			results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
 			if e != nil {
 				resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
@@ -746,16 +747,16 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
 				amountCond += ` AND IF ( a.invoice_id = 0, d.seller_group_id, b.seller_group_id ) IN (?) `
 				amountPars = append(amountPars, 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 ?)`
-			//	amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
-			//	amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
-			//} else {
-			//	amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
-			//	amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
-			//	amountPars = append(amountPars, st, ed, st, ed)
-			//}
+			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 ?)`
+				amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
+				amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
+			} else {
+				amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
+				amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
+				amountPars = append(amountPars, st, ed, st, ed)
+			}
 			results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
 			if e != nil {
 				resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
@@ -1077,16 +1078,16 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
 			amountCond := `a.id IN ? `
 			amountPars := make([]interface{}, 0)
 			amountPars = append(amountPars, summaryIds)
-			//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 ?)`
-			//	amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
-			//	amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
-			//} else {
-			//	amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
-			//	amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
-			//	amountPars = append(amountPars, st, ed, st, ed)
-			//}
+			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 ?)`
+				amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
+				amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
+			} else {
+				amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
+				amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
+				amountPars = append(amountPars, st, ed, st, ed)
+			}
 			results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
 			if e != nil {
 				resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
@@ -1142,16 +1143,16 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
 			amountCond := `a.id IN ? `
 			amountPars := make([]interface{}, 0)
 			amountPars = append(amountPars, summaryIds)
-			//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 ?)`
-			//	amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
-			//	amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
-			//} else {
-			//	amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
-			//	amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
-			//	amountPars = append(amountPars, st, ed, st, ed)
-			//}
+			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 ?)`
+				amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
+				amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
+			} else {
+				amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
+				amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
+				amountPars = append(amountPars, st, ed, st, ed)
+			}
 			results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
 			if e != nil {
 				resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
@@ -1223,16 +1224,16 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
 			amountCond := `a.id IN ? `
 			amountPars := make([]interface{}, 0)
 			amountPars = append(amountPars, summaryIds)
-			//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 ?)`
-			//	amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
-			//	amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
-			//} else {
-			//	amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
-			//	amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
-			//	amountPars = append(amountPars, st, ed, st, ed)
-			//}
+			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 ?)`
+				amountCond += `OR ( d.seller_id IN ? AND  a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?)) `
+				amountPars = append(amountPars, sellerIds, st, ed, sellerIds, st, ed)
+			} else {
+				amountCond += ` AND ((a.invoice_id <> 0 AND b.invoice_time BETWEEN ? AND ?)`
+				amountCond += `OR (a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time BETWEEN ? AND ?))`
+				amountPars = append(amountPars, st, ed, st, ed)
+			}
 			results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
 			if e != nil {
 				resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)

+ 17 - 15
models/fms/contract_invoice.go

@@ -397,13 +397,14 @@ type UpdatePaymentPayTypeReq struct {
 
 // CensusSellerGroupInvoiceListReq 销售组开票统计列表请求体
 type CensusSellerGroupInvoiceListReq 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:"结束日期"`
-	SortField  int    `json:"sort_field" form:"sort_field" description:"排序字段: 1-开票金额; 2-组别占比"`
-	SortType   int    `json:"sort_type" form:"sort_type" description:"排序方式: 1-正序; 2-倒序"`
-	IsExport   int    `json:"is_export" form:"is_export" description:"是否导出: 0-否; 1-是"`
-	SellerType int    `json:"seller_type" form:"seller_type" description:"销售类型:1ficc销售,2权益销售"`
+	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:"结束日期"`
+	SortField   int    `json:"sort_field" form:"sort_field" description:"排序字段: 1-开票金额; 2-组别占比"`
+	SortType    int    `json:"sort_type" form:"sort_type" description:"排序方式: 1-正序; 2-倒序"`
+	IsExport    int    `json:"is_export" form:"is_export" description:"是否导出: 0-否; 1-是"`
+	SellerType  int    `json:"seller_type" form:"seller_type" description:"销售类型:1ficc销售,2权益销售"`
 	CompanyType int    `json:"company_type" form:"company_type" description:"客户类型 0全部 1新客户 2老客户"`
+	SellerIds   string `json:"seller_ids" form:"seller_ids" description:"销售IDs"`
 	base.PageReq
 }
 
@@ -443,14 +444,15 @@ func GetCensusSellerGroupInvoicePageList(page base.IPage, condition, outCond str
 
 // CensusSellerInvoiceListReq 销售开票统计列表请求体
 type CensusSellerInvoiceListReq struct {
-	GroupId    int    `json:"group_id" form:"group_id" description:"销售组别ID"`
-	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:"结束日期"`
-	SortField  int    `json:"sort_field" form:"sort_field" description:"排序字段: 1-开票金额; 2-小组占比; 3-全员占比"`
-	SortType   int    `json:"sort_type" form:"sort_type" description:"排序方式: 1-正序; 2-倒序"`
-	IsExport   int    `json:"is_export" form:"is_export" description:"是否导出: 0-否; 1-是"`
-	SellerType int    `json:"seller_type" form:"seller_type" description:"销售类型:1ficc销售,2权益销售"`
-	ShowResign bool   `json:"show_resign" form:"show_resign" description:"是否显示离职销售"`
+	GroupId     int    `json:"group_id" form:"group_id" description:"销售组别ID"`
+	SellerIds   string `json:"seller_ids" form:"seller_ids" description:"销售IDs"`
+	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:"结束日期"`
+	SortField   int    `json:"sort_field" form:"sort_field" description:"排序字段: 1-开票金额; 2-小组占比; 3-全员占比"`
+	SortType    int    `json:"sort_type" form:"sort_type" description:"排序方式: 1-正序; 2-倒序"`
+	IsExport    int    `json:"is_export" form:"is_export" description:"是否导出: 0-否; 1-是"`
+	SellerType  int    `json:"seller_type" form:"seller_type" description:"销售类型:1ficc销售,2权益销售"`
+	ShowResign  bool   `json:"show_resign" form:"show_resign" description:"是否显示离职销售"`
 	CompanyType int    `json:"company_type" form:"company_type" description:"客户类型 0全部 1新客户 2老客户"`
 	base.PageReq
 }
@@ -818,4 +820,4 @@ func GetInvoiceCountByRegisterId(registerId int) (total int64, err error) {
 	err = global.DEFAULT_MYSQL.Table("contract_invoice as a ").
 		Where("is_deleted = 0 AND contract_register_id = ?", registerId).Count(&total).Error
 	return
-}
+}