|
@@ -25,8 +25,8 @@ import (
|
|
type SellerController struct{}
|
|
type SellerController struct{}
|
|
|
|
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -429,6 +429,388 @@ func (ct *SellerController) InvoiceList(c *gin.Context) {
|
|
resp.OkData("获取成功", baseData, c)
|
|
resp.OkData("获取成功", baseData, c)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (this *SellerController) InvoiceListV2(c *gin.Context) {
|
|
|
|
+ var req fms.CensusSellerInvoiceListReq
|
|
|
|
+ if e := c.BindQuery(&req); e != nil {
|
|
|
|
+ err, ok := e.(validator.ValidationErrors)
|
|
|
|
+ if !ok {
|
|
|
|
+ resp.FailData("参数解析失败", "Err:"+e.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ resp.FailData("参数解析失败", err.Translate(global.Trans), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ page := new(base.Page)
|
|
|
|
+ page.SetPageSize(req.PageSize)
|
|
|
|
+ page.SetCurrent(req.Current)
|
|
|
|
+
|
|
|
|
+ if req.IsExport == 1 {
|
|
|
|
+ page.SetPageSize(10000)
|
|
|
|
+ page.SetCurrent(1)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ cond1 := ``
|
|
|
|
+ historyCond := ``
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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
|
|
|
|
+ } else if req.SellerType == 2 {
|
|
|
|
+ departmentId = crm.RaiSellerDepartmentId
|
|
|
|
+ } else if req.SellerType == 0 {
|
|
|
|
+ resp.Fail("请选择销售类型", c)
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ resp.Fail("请选择正确的销售类型", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var totalMoneySlice []float64
|
|
|
|
+ var reqStartDate, reqEndDate time.Time
|
|
|
|
+ historyTime, _ := time.Parse(utils.FormatDate, "2023-04-01")
|
|
|
|
+
|
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
|
+ st := fmt.Sprint(req.StartDate, "-01 00:00:00")
|
|
|
|
+ ed := fmt.Sprint(req.EndDate, "-01 23:59:59")
|
|
|
|
+ reqStartDate, _ = time.Parse(utils.FormatDateTime, st)
|
|
|
|
+ reqEndDate, _ = time.Parse(utils.FormatDateTime, ed)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var accumulate float64
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var prevStartDate string
|
|
|
|
+ var startDate, endDate string
|
|
|
|
+
|
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
|
+ startDate = reqStartDate.Format("2006-01")
|
|
|
|
+ prevStartDate = reqStartDate.Format("2006-01")
|
|
|
|
+ }
|
|
|
|
+ startDate = fmt.Sprint(startDate, "-01")
|
|
|
|
+ prevStartDate = fmt.Sprint(prevStartDate, "-01")
|
|
|
|
+ startDateTime, _ := time.Parse(utils.FormatDate, startDate)
|
|
|
|
+ endDateTime, _ := time.Parse(utils.FormatDate, endDate)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if req.StartDate != "" && req.EndDate != "" {
|
|
|
|
+ endDate = reqEndDate.Format("2006-01")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cond := `1 = 1`
|
|
|
|
+ histrtyCond := `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 `
|
|
|
|
+ } else if req.CompanyType == 2 {
|
|
|
|
+ cond += ` AND b.contract_type IN (2,3,4) `
|
|
|
|
+ histrtyCond += ` AND new_company = 0 `
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ st := fmt.Sprint(startDate, " 00:00:00")
|
|
|
|
+ ed := fmt.Sprint(endDate, " 23:59:59")
|
|
|
|
+ groupInvoiceMap := make(map[int]float64)
|
|
|
|
+ sellerInvoiceMap := make(map[int]float64)
|
|
|
|
+ sellerGroupMap := make(map[int]int)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if req.StartDate == "" && req.EndDate == "" {
|
|
|
|
+ summaryIds, e := fms.GetInvoicePaymentCensusSummaryDataIds(cond, pars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var amountTotal float64
|
|
|
|
+
|
|
|
|
+ if len(summaryIds) > 0 {
|
|
|
|
+ amountCond := `a.id IN ? `
|
|
|
|
+ amountPars := make([]interface{}, 0)
|
|
|
|
+ amountPars = append(amountPars, summaryIds)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var amountSum float64
|
|
|
|
+ for _, result := range results {
|
|
|
|
+ amountSum += result.Amount
|
|
|
|
+ fmt.Println("result.Amount:", result.Amount)
|
|
|
|
+ if _, ok := groupInvoiceMap[result.SellerGroupId]; ok {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerInvoiceMap[result.FinalSellerId]; ok {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerGroupMap[result.FinalSellerId]; !ok {
|
|
|
|
+ sellerGroupMap[result.FinalSellerId] = result.SellerGroupId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
|
+ accumulate += amountTotal
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ results, e = fms.GetIncomeHistory(histrtyCond, 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 {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerInvoiceMap[result.FinalSellerId]; ok {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerGroupMap[result.FinalSellerId]; !ok {
|
|
|
|
+ sellerGroupMap[result.FinalSellerId] = result.SellerGroupId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
|
+ accumulate += amountTotal
|
|
|
|
+ }
|
|
|
|
+ } else if startDateTime.After(historyTime) || startDateTime.Equal(historyTime) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if st != "" && ed != "" {
|
|
|
|
+ cond += ` AND ((c.invoice_time BETWEEN ? AND ?) or (d.invoice_time BETWEEN ? AND ?))`
|
|
|
|
+ pars = append(pars, st, ed, st, ed)
|
|
|
|
+ }
|
|
|
|
+ summaryIds, e := fms.GetInvoicePaymentCensusSummaryDataIds(cond, pars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var amountTotal float64
|
|
|
|
+
|
|
|
|
+ if len(summaryIds) > 0 {
|
|
|
|
+ amountCond := `a.id IN ? `
|
|
|
|
+ amountPars := make([]interface{}, 0)
|
|
|
|
+ amountPars = append(amountPars, summaryIds)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var amountSum float64
|
|
|
|
+ for _, result := range results {
|
|
|
|
+ amountSum += result.Amount
|
|
|
|
+ fmt.Println("result.Amount:", result.Amount)
|
|
|
|
+ if _, ok := groupInvoiceMap[result.SellerGroupId]; ok {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerInvoiceMap[result.FinalSellerId]; ok {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerGroupMap[result.FinalSellerId]; !ok {
|
|
|
|
+ sellerGroupMap[result.FinalSellerId] = result.SellerGroupId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
|
+ accumulate += amountTotal
|
|
|
|
+ }
|
|
|
|
+ } else if endDateTime.Before(historyTime) || endDateTime.Equal(historyTime) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if st != "" && ed != "" {
|
|
|
|
+ histrtyCond += ` AND (invoice_time BETWEEN ? AND ? )`
|
|
|
|
+ historyPars = append(historyPars, st, ed)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var amountTotal float64
|
|
|
|
+ results, e := fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var amountSum float64
|
|
|
|
+
|
|
|
|
+ for _, result := range results {
|
|
|
|
+ amountSum += result.Amount
|
|
|
|
+ if _, ok := groupInvoiceMap[result.SellerGroupId]; ok {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ groupInvoiceMap[result.SellerGroupId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerInvoiceMap[result.FinalSellerId]; ok {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] += result.Amount
|
|
|
|
+ } else {
|
|
|
|
+ sellerInvoiceMap[result.FinalSellerId] = result.Amount
|
|
|
|
+ }
|
|
|
|
+ if _, ok := sellerGroupMap[result.FinalSellerId]; !ok {
|
|
|
|
+ sellerGroupMap[result.FinalSellerId] = result.SellerGroupId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
|
+ accumulate += amountTotal
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 := ` department_id = %d `
|
|
|
|
+ adminCond = fmt.Sprintf(adminCond, departmentId)
|
|
|
|
+ adminList, e := adminOB.List(adminCond, adminPars)
|
|
|
|
+ if e != nil {
|
|
|
|
+ resp.FailMsg("获取失败", "获取销售列表失败, Err: "+e.Error(), c)
|
|
|
|
+ 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 {
|
|
|
|
+ if vv, ok := sellerInvoiceMap[v.AdminId]; ok {
|
|
|
|
+ rate := vv / accumulate
|
|
|
|
+ mulNum := decimal.NewFromFloat(100)
|
|
|
|
+ newRate := decimal.NewFromFloat(rate)
|
|
|
|
+ newRate = newRate.Mul(mulNum).Round(2)
|
|
|
|
+ finalRate, _ := newRate.Float64()
|
|
|
|
+
|
|
|
|
+ groupId := sellerGroupMap[v.AdminId]
|
|
|
|
+ groupRate := vv / groupInvoiceMap[groupId]
|
|
|
|
+ newGroupRate := decimal.NewFromFloat(groupRate)
|
|
|
|
+ newGroupRate = newGroupRate.Mul(mulNum).Round(2)
|
|
|
|
+ finalGroupRate, _ := newGroupRate.Float64()
|
|
|
|
+
|
|
|
|
+ amuont, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", vv), 64)
|
|
|
|
+
|
|
|
|
+ var sellerName, groupName string
|
|
|
|
+ if seller, ok := sellerMap[v.AdminId]; ok {
|
|
|
|
+ sellerName = seller.SellerName
|
|
|
|
+ groupName = seller.GroupName
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ list = append(list, &fms.CensusSellerInvoiceItem{
|
|
|
|
+ SellerId: v.AdminId,
|
|
|
|
+ SellerName: sellerName,
|
|
|
|
+ GroupId: groupId,
|
|
|
|
+ GroupName: groupName,
|
|
|
|
+ InvoiceAmount: amuont,
|
|
|
|
+ GroupRate: finalGroupRate,
|
|
|
|
+ SellerRate: finalRate,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var respList fms.CensusSellerList
|
|
|
|
+ respList = list
|
|
|
|
+
|
|
|
|
+ sort.Sort(respList)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ page.SetTotal(int64(len(list)))
|
|
|
|
+ baseData := new(base.BaseData)
|
|
|
|
+ baseData.SetPage(page)
|
|
|
|
+ baseData.SetList(respList)
|
|
|
|
+ resp.OkData("获取成功", baseData, c)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
func ExportInvoiceList(c *gin.Context, list []*fms.CensusSellerInvoiceItem, req fms.CensusSellerInvoiceListReq) {
|
|
func ExportInvoiceList(c *gin.Context, list []*fms.CensusSellerInvoiceItem, req fms.CensusSellerInvoiceListReq) {
|
|
|
|
|
|
@@ -494,6 +876,16 @@ func ExportInvoiceList(c *gin.Context, list []*fms.CensusSellerInvoiceItem, req
|
|
http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
|
|
http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
var req fms.CensusSellerGroupInvoiceListReq
|
|
var req fms.CensusSellerGroupInvoiceListReq
|
|
if e := c.BindQuery(&req); e != nil {
|
|
if e := c.BindQuery(&req); e != nil {
|
|
@@ -616,7 +1008,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
|
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -633,11 +1025,10 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
accumulate += amountTotal
|
|
accumulate += amountTotal
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
results, e = fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
results, e = fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -683,7 +1074,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
|
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -715,7 +1106,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
var amountTotal float64
|
|
var amountTotal float64
|
|
results, e := fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
results, e := fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
var amountSum float64
|
|
var amountSum float64
|
|
@@ -731,7 +1122,6 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
accumulate += amountTotal
|
|
accumulate += amountTotal
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -743,10 +1133,10 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
} else if req.SellerType == 2 {
|
|
} else if req.SellerType == 2 {
|
|
departmentId = crm.RaiSellerDepartmentId
|
|
departmentId = crm.RaiSellerDepartmentId
|
|
} else if req.SellerType == 0 {
|
|
} else if req.SellerType == 0 {
|
|
- resp.FailMsg("查询错误","请选择正确的销售类型", c)
|
|
+ resp.FailMsg("查询错误", "请选择正确的销售类型", c)
|
|
return
|
|
return
|
|
} else {
|
|
} else {
|
|
- resp.FailMsg("查询错误","请选择正确的销售类型", c)
|
|
+ resp.FailMsg("查询错误", "请选择正确的销售类型", c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
groupCond := ` department_id = %d AND parent_id = 0 `
|
|
groupCond := ` department_id = %d AND parent_id = 0 `
|
|
@@ -755,7 +1145,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
groupOB := new(crm.SysGroup)
|
|
groupOB := new(crm.SysGroup)
|
|
groupList, e := groupOB.List(groupCond, groupPars)
|
|
groupList, e := groupOB.List(groupCond, groupPars)
|
|
if e != nil {
|
|
if e != nil {
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取组别列表失败, Err: %s", e.Error()), c)
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取组别列表失败, Err: %s", e.Error()), c)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -775,10 +1165,10 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
newRate = newRate.Mul(mulNum).Round(2)
|
|
newRate = newRate.Mul(mulNum).Round(2)
|
|
finalRate, _ := newRate.Float64()
|
|
finalRate, _ := newRate.Float64()
|
|
|
|
|
|
- amuont,_ := strconv.ParseFloat(fmt.Sprintf("%.2f", v), 64)
|
|
+ amuont, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v), 64)
|
|
|
|
|
|
groupName := ""
|
|
groupName := ""
|
|
- if groupItem ,ok := groupMap[k]; ok {
|
|
+ if groupItem, ok := groupMap[k]; ok {
|
|
groupName = groupItem.GroupName
|
|
groupName = groupItem.GroupName
|
|
}
|
|
}
|
|
list = append(list, &fms.CensusSellerGroupInvoiceItem{
|
|
list = append(list, &fms.CensusSellerGroupInvoiceItem{
|