|
@@ -25,8 +25,8 @@ import (
|
|
|
type SellerController struct{}
|
|
|
|
|
|
// GroupInvoiceList
|
|
|
-// @Title 销售组开票统计列表
|
|
|
-// @Description 销售组开票统计列表
|
|
|
+// @Title 销售组开票统计列表-弃用
|
|
|
+// @Description 销售组开票统计列表-弃用
|
|
|
// @Param StartDate query string false "开始日期"
|
|
|
// @Param EndDate query string false "结束日期"
|
|
|
// @Param SortField query int false "排序字段: 1-开票金额; 2-组别占比"
|
|
@@ -429,6 +429,388 @@ func (ct *SellerController) InvoiceList(c *gin.Context) {
|
|
|
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 := ``
|
|
|
+ //pars1 := make([]interface{}, 0)
|
|
|
+ //historyPars1 := make([]interface{}, 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.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
|
|
|
+ //dataList := make([]*fms.IncomeSummaryItem, 0)
|
|
|
+ //historydataList := make([]*fms.IncomeSummaryItem, 0)
|
|
|
+
|
|
|
+ //timeNow, _ := time.Parse("2006-01", time.Now().Format("2006-01"))
|
|
|
+
|
|
|
+ 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 `
|
|
|
+ }
|
|
|
+
|
|
|
+ //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 := 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)
|
|
|
+ //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)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //dataList = append(dataList, results...)
|
|
|
+ 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
|
|
|
+
|
|
|
+ //var amountTotal float64
|
|
|
+ results, e = fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //dataList = append(dataList, results...)
|
|
|
+ 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) {
|
|
|
+ //全部走新查询
|
|
|
+ //fmt.Println("新查询")
|
|
|
+ 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)
|
|
|
+ //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)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //dataList = append(dataList, results...)
|
|
|
+ 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) {
|
|
|
+ //全部走旧查询
|
|
|
+ //fmt.Println("旧查询")
|
|
|
+ //fmt.Println("st:",st)
|
|
|
+ //fmt.Println("ed:",ed)
|
|
|
+ if st != "" && ed != "" {
|
|
|
+ histrtyCond += ` AND (invoice_time BETWEEN ? AND ? )`
|
|
|
+ historyPars = append(historyPars, st, ed)
|
|
|
+ }
|
|
|
+ //fmt.Println("st:",st)
|
|
|
+ //fmt.Println("ed:",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
|
|
|
+ //dataList = append(dataList, results...)
|
|
|
+ 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("partAccumulate:",partAccumulate)
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
|
+
|
|
|
+ // 是否导出
|
|
|
+ //if req.IsExport == 1 {
|
|
|
+ // ExportIncomeList(c, incomeList.DataList)
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ page.SetTotal(int64(len(list)))
|
|
|
+ baseData := new(base.BaseData)
|
|
|
+ baseData.SetPage(page)
|
|
|
+ baseData.SetList(respList)
|
|
|
+ resp.OkData("获取成功", baseData, c)
|
|
|
+}
|
|
|
+
|
|
|
// ExportInvoiceList 导出销售开票统计列表
|
|
|
func ExportInvoiceList(c *gin.Context, list []*fms.CensusSellerInvoiceItem, req fms.CensusSellerInvoiceListReq) {
|
|
|
// 生成Excel文件
|
|
@@ -494,6 +876,16 @@ func ExportInvoiceList(c *gin.Context, list []*fms.CensusSellerInvoiceItem, req
|
|
|
http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
|
|
|
}
|
|
|
|
|
|
+// GroupInvoiceList
|
|
|
+// @Title 销售组开票统计列表
|
|
|
+// @Description 销售组开票统计列表
|
|
|
+// @Param StartDate query string false "开始日期"
|
|
|
+// @Param EndDate query string false "结束日期"
|
|
|
+// @Param SortField query int false "排序字段: 1-开票金额; 2-组别占比"
|
|
|
+// @Param SortType query int false "排序方式: 1-正序; 2-倒序"
|
|
|
+// @Param IsExport query int false "是否导出: 0-否; 1-是"
|
|
|
+// @Success 200 {object} fms.CensusSellerGroupInvoiceItem
|
|
|
+// @router /census/seller/group_invoice_list [get]
|
|
|
func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
var req fms.CensusSellerGroupInvoiceListReq
|
|
|
if e := c.BindQuery(&req); e != nil {
|
|
@@ -616,7 +1008,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
//}
|
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
return
|
|
|
}
|
|
|
//dataList = append(dataList, results...)
|
|
@@ -633,11 +1025,10 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
accumulate += amountTotal
|
|
|
|
|
|
-
|
|
|
//var amountTotal float64
|
|
|
results, e = fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
return
|
|
|
}
|
|
|
//dataList = append(dataList, results...)
|
|
@@ -683,7 +1074,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
//}
|
|
|
results, e := fms.GetContractSummaryIncomeAmount(amountCond, amountPars)
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
return
|
|
|
}
|
|
|
//dataList = append(dataList, results...)
|
|
@@ -715,7 +1106,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
var amountTotal float64
|
|
|
results, e := fms.GetIncomeHistory(histrtyCond, historyPars)
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取汇总数据失败, Err: %s", e.Error()), c)
|
|
|
return
|
|
|
}
|
|
|
var amountSum float64
|
|
@@ -731,7 +1122,6 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
amountTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", amountSum), 64)
|
|
|
accumulate += amountTotal
|
|
|
|
|
|
-
|
|
|
//fmt.Println("partAccumulate:",partAccumulate)
|
|
|
}
|
|
|
|
|
@@ -743,10 +1133,10 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
} else if req.SellerType == 2 {
|
|
|
departmentId = crm.RaiSellerDepartmentId
|
|
|
} else if req.SellerType == 0 {
|
|
|
- resp.FailMsg("查询错误","请选择正确的销售类型", c)
|
|
|
+ resp.FailMsg("查询错误", "请选择正确的销售类型", c)
|
|
|
return
|
|
|
} else {
|
|
|
- resp.FailMsg("查询错误","请选择正确的销售类型", c)
|
|
|
+ resp.FailMsg("查询错误", "请选择正确的销售类型", c)
|
|
|
return
|
|
|
}
|
|
|
groupCond := ` department_id = %d AND parent_id = 0 `
|
|
@@ -755,7 +1145,7 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
groupOB := new(crm.SysGroup)
|
|
|
groupList, e := groupOB.List(groupCond, groupPars)
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("查询错误",fmt.Sprintf("获取组别列表失败, Err: %s", e.Error()), c)
|
|
|
+ resp.FailMsg("查询错误", fmt.Sprintf("获取组别列表失败, Err: %s", e.Error()), c)
|
|
|
return
|
|
|
}
|
|
|
//total := len(groupList)
|
|
@@ -775,10 +1165,10 @@ func (this *SellerController) GroupInvoiceListV2(c *gin.Context) {
|
|
|
newRate = newRate.Mul(mulNum).Round(2)
|
|
|
finalRate, _ := newRate.Float64()
|
|
|
|
|
|
- amuont,_ := strconv.ParseFloat(fmt.Sprintf("%.2f", v), 64)
|
|
|
+ amuont, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", v), 64)
|
|
|
|
|
|
groupName := ""
|
|
|
- if groupItem ,ok := groupMap[k]; ok {
|
|
|
+ if groupItem, ok := groupMap[k]; ok {
|
|
|
groupName = groupItem.GroupName
|
|
|
}
|
|
|
list = append(list, &fms.CensusSellerGroupInvoiceItem{
|