|
@@ -232,8 +232,8 @@ func ExportGroupInvoiceList(c *gin.Context, list []*fms.CensusSellerGroupInvoice
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -449,13 +449,6 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
page.SetCurrent(1)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- cond1 := ``
|
|
|
- historyCond := ``
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -463,13 +456,7 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
|
|
- if req.CompanyType == 1 {
|
|
|
- cond1 += ` AND b.contract_type = 1 `
|
|
|
- historyCond += ` AND new_company = 1 `
|
|
|
- } else if req.CompanyType == 2 {
|
|
|
- cond1 += ` AND b.contract_type IN (2,3,4) `
|
|
|
- historyCond += ` AND new_company = 0 `
|
|
|
- }
|
|
|
+
|
|
|
var departmentId int
|
|
|
if req.SellerType == 1 {
|
|
|
departmentId = crm.SellerDepartmentId
|
|
@@ -496,10 +483,6 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
|
|
|
|
|
|
var accumulate float64
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
var prevStartDate string
|
|
|
var startDate, endDate string
|
|
@@ -518,17 +501,47 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
endDate = reqEndDate.Format("2006-01")
|
|
|
}
|
|
|
|
|
|
- cond := `1 = 1`
|
|
|
- histrtyCond := `1 = 1`
|
|
|
+ cond := ` 1 = 1 `
|
|
|
+ historyCond := ` 1=1 `
|
|
|
pars := make([]interface{}, 0)
|
|
|
historyPars := make([]interface{}, 0)
|
|
|
|
|
|
if req.CompanyType == 1 {
|
|
|
cond += ` AND b.contract_type = 1 `
|
|
|
- histrtyCond += ` AND new_company = 1 `
|
|
|
+ historyCond += ` AND new_company = 1 `
|
|
|
} else if req.CompanyType == 2 {
|
|
|
cond += ` AND b.contract_type IN (2,3,4) `
|
|
|
- histrtyCond += ` AND new_company = 0 `
|
|
|
+ historyCond += ` AND new_company = 0 `
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.GroupId > 0 {
|
|
|
+
|
|
|
+ groupCond := `parent_id = ?`
|
|
|
+ groupPars := make([]interface{}, 0)
|
|
|
+ groupPars = append(groupPars, req.GroupId)
|
|
|
+ groupOB := new(crm.SysGroup)
|
|
|
+ groupList, e := groupOB.List(groupCond, groupPars)
|
|
|
+ if e != nil {
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ cond += ` AND c.seller_group_id IN (?) AND d.seller_group_id IN (?)`
|
|
|
+ pars = append(pars, groupIds, groupIds)
|
|
|
+ historyCond += ` AND group_id IN (?) `
|
|
|
+ historyPars = append(historyPars, groupIds)
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CompanyType == 1 {
|
|
|
+ cond += ` AND b.contract_type = 1 `
|
|
|
+ historyCond += ` AND new_company = 1 `
|
|
|
+ } else if req.CompanyType == 2 {
|
|
|
+ cond += ` AND b.contract_type IN (2,3,4) `
|
|
|
+ historyCond += ` AND new_company = 0 `
|
|
|
}
|
|
|
|
|
|
|
|
@@ -600,13 +613,11 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
accumulate += amountTotal
|
|
|
|
|
|
-
|
|
|
- results, e = fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
+ results, e = fms.GetIncomeHistory(historyCond, historyPars)
|
|
|
if e != nil {
|
|
|
resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
for _, result := range results {
|
|
|
amountSum += result.Amount
|
|
|
if _, ok := groupInvoiceMap[result.SellerGroupId]; ok {
|
|
@@ -688,14 +699,14 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
|
|
|
|
|
|
if st != "" && ed != "" {
|
|
|
- histrtyCond += ` AND (invoice_time BETWEEN ? AND ? )`
|
|
|
+ historyCond += ` AND (invoice_time BETWEEN ? AND ? )`
|
|
|
historyPars = append(historyPars, st, ed)
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var amountTotal float64
|
|
|
- results, e := fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
+ results, e := fms.GetIncomeHistory(historyCond, historyPars)
|
|
|
if e != nil {
|
|
|
resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
return
|