|
@@ -449,18 +449,12 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
page.SetCurrent(1)
|
|
|
}
|
|
|
|
|
|
- //var departmentId int
|
|
|
- //if req.SellerType == 1 {
|
|
|
- // departmentId = crm.SellerDepartmentId
|
|
|
- //} else if req.SellerType == 2 {
|
|
|
- // departmentId = crm.RaiSellerDepartmentId
|
|
|
- //} else if req.SellerType == 0 {
|
|
|
- // resp.Fail("请选择销售类型", c)
|
|
|
- // return
|
|
|
- //} else {
|
|
|
- // resp.Fail("请选择正确的销售类型", c)
|
|
|
- // return
|
|
|
- //}
|
|
|
+ var departmentId int
|
|
|
+ if req.SellerType == 1 {
|
|
|
+ departmentId = crm.SellerDepartmentId
|
|
|
+ } else if req.SellerType == 2 {
|
|
|
+ departmentId = crm.RaiSellerDepartmentId
|
|
|
+ }
|
|
|
|
|
|
var totalMoneySlice []float64
|
|
|
historyTime, _ := time.Parse(utils.FormatDate, "2023-04-01")
|
|
@@ -490,13 +484,11 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
historyCond += ` AND new_company = 0 `
|
|
|
}
|
|
|
|
|
|
- if req.SellerIds != "" {
|
|
|
- sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
- //cond += ` AND (a.seller_id in ? ) `
|
|
|
- historyCond += ` AND (seller_id in ? ) `
|
|
|
- //pars = append(pars, sellerIds)
|
|
|
- historyPars = append(historyPars, sellerIds)
|
|
|
- }
|
|
|
+ //if req.SellerIds != "" {
|
|
|
+ // sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
+ // historyCond += ` AND (seller_id in ? ) `
|
|
|
+ // historyPars = append(historyPars, sellerIds)
|
|
|
+ //}
|
|
|
|
|
|
//groupIds := make([]int, 0)
|
|
|
//if req.GroupId > 0 {
|
|
@@ -520,26 +512,40 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
// historyPars = append(historyPars, groupIds)
|
|
|
//}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ // 获取销售分组信息
|
|
|
+ sellerList, e := crmService.GetSellerDepartmentListWithEnable()
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取销售失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ficcSellers := make([]string,0)
|
|
|
+ raiSellers := make([]string,0)
|
|
|
+ sellerMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
+ for i := range sellerList {
|
|
|
+ sellerMap[sellerList[i].SellerId] = sellerList[i]
|
|
|
+ if sellerList[i].DepartmentId == crm.SellerDepartmentId {
|
|
|
+ ficcSellers = append(ficcSellers, strconv.Itoa(sellerList[i].SellerId))
|
|
|
+ } else if sellerList[i].DepartmentId == crm.RaiSellerDepartmentId {
|
|
|
+ raiSellers = append(raiSellers, strconv.Itoa(sellerList[i].SellerId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ficcSellerIds := strings.Join(ficcSellers, ",")
|
|
|
+ raiSellerIds := strings.Join(raiSellers, ",")
|
|
|
+ sellerIds := ""
|
|
|
+
|
|
|
if req.CompanyType == 1 {
|
|
|
cond += ` AND b.contract_type = 1 `
|
|
|
historyCond += ` AND new_company = 1 `
|
|
|
+ sellerIds = ficcSellerIds
|
|
|
} else if req.CompanyType == 2 {
|
|
|
cond += ` AND b.contract_type IN (2,3,4) `
|
|
|
historyCond += ` AND new_company = 0 `
|
|
|
+ sellerIds = raiSellerIds
|
|
|
}
|
|
|
|
|
|
- //if req.SellerIds != "" {
|
|
|
- // sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
- // cond += ` AND (c.seller_id in ? OR d.seller_id in ?)`
|
|
|
- // pars = append(pars, sellerIds, sellerIds)
|
|
|
- // prevCond += ` AND (c.seller_id in ? OR d.seller_id in ?)`
|
|
|
- // prevPars = append(prevPars, sellerIds, sellerIds)
|
|
|
- // histrtyCond += ` AND seller_id in ? `
|
|
|
- // prevHistoryCond += ` AND seller_id in ? `
|
|
|
- // historyPars = append(historyPars, sellerIds)
|
|
|
- // prevHistoryPars = append(prevHistoryPars, sellerIds)
|
|
|
- //}
|
|
|
-
|
|
|
st := startDate
|
|
|
ed := endDate
|
|
|
groupInvoiceMap := make(map[int]float64)
|
|
@@ -565,8 +571,8 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
// amountPars = append(amountPars, groupIds)
|
|
|
//}
|
|
|
|
|
|
- if req.SellerIds != "" {
|
|
|
- sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
+ if req.SellerType != 0 {
|
|
|
+ //sellerIds := strings.Split(req.SellerIds, ",")
|
|
|
amountCond += ` AND (( b.seller_id IN ? AND a.invoice_id <> 0 AND b.invoice_time > "2023-04-01")`
|
|
|
amountCond += `OR ( d.seller_id IN ? AND a.payment_id <> 0 AND a.invoice_id = 0 AND d.invoice_time > "2023-04-01")) `
|
|
|
amountPars = append(amountPars, sellerIds, sellerIds)
|
|
@@ -649,8 +655,8 @@ 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, ",")
|
|
|
+ if req.SellerType != 0 {
|
|
|
+ //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)
|
|
@@ -747,8 +753,8 @@ 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, ",")
|
|
|
+ if req.SellerType != 0 {
|
|
|
+ //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)
|
|
@@ -815,22 +821,18 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
|
|
|
fmt.Println("totalMoneySlice:", len(totalMoneySlice))
|
|
|
|
|
|
- //if req.SellerType == 1 {
|
|
|
- // departmentId = crm.SellerDepartmentId
|
|
|
- //} else if req.SellerType == 2 {
|
|
|
- // departmentId = crm.RaiSellerDepartmentId
|
|
|
- //} else if req.SellerType == 0 {
|
|
|
- // resp.FailMsg("查询错误", "请选择正确的销售类型", c)
|
|
|
- // return
|
|
|
- //} else {
|
|
|
- // resp.FailMsg("查询错误", "请选择正确的销售类型", c)
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
adminOB := new(crm.Admin)
|
|
|
adminPars := make([]interface{}, 0)
|
|
|
adminCond := ` 1=1 `
|
|
|
- //adminCond = fmt.Sprintf(adminCond, departmentId)
|
|
|
+ if req.SellerType != 0 {
|
|
|
+ adminCond = ` AND department_id = ? `
|
|
|
+ adminPars = append(adminPars, departmentId)
|
|
|
+ }
|
|
|
+ if req.SellerIds != "" {
|
|
|
+ adminSellerIds := strings.Split(req.SellerIds, ",")
|
|
|
+ adminCond += ` AND admin_id IN (?) `
|
|
|
+ adminPars = append(adminPars, adminSellerIds)
|
|
|
+ }
|
|
|
|
|
|
if !req.ShowResign {
|
|
|
adminCond += ` AND enabled = 1 `
|
|
@@ -842,17 +844,6 @@ func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- // 获取销售分组信息
|
|
|
- sellerList, e := crmService.GetSellerDepartmentListWithEnable()
|
|
|
- if e != nil {
|
|
|
- resp.FailData("获取销售失败", "Err:"+e.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
- sellerMap := make(map[int]*crm.SellerAdminWithGroupTeam)
|
|
|
- for i := range sellerList {
|
|
|
- sellerMap[sellerList[i].SellerId] = sellerList[i]
|
|
|
- }
|
|
|
-
|
|
|
list := make([]*fms.CensusSellerInvoiceItem, 0)
|
|
|
|
|
|
for _, v := range adminList {
|