|
|
@@ -13,6 +13,7 @@ import (
|
|
|
projSrv "dashoo.cn/micro/app/service/proj"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/gogf/gf/frame/g"
|
|
|
"github.com/gogf/gf/os/gtime"
|
|
|
"github.com/gogf/gf/util/gconv"
|
|
|
)
|
|
|
@@ -131,15 +132,15 @@ func (s *HomeService) getNumStatisticsData(id int64, params *map[string]interfac
|
|
|
return gconv.String(count), err
|
|
|
|
|
|
case 10004: //当月新增客户数量(维度:月)
|
|
|
- count, err := customerDao.DataScope(s.Ctx, "sales_id").WhereGTE(customerDao.C.CreatedTime, monthStart).WhereLTE(customerDao.C.CreatedTime, monthEnd).Count("id")
|
|
|
+ count, err := customerDao.DataScope(s.Ctx, "sales_id").WhereGTE(customerDao.C.CreatedTime, monthStart).WhereLTE(customerDao.C.CreatedTime, monthEnd).CountColumn("id")
|
|
|
return gconv.String(count), err
|
|
|
|
|
|
case 10005: //当月新增项目数量(维度:月)
|
|
|
- count, err := businessDao.DataScope(s.Ctx, "sale_id").WhereGTE(businessDao.C.CreatedTime, monthStart).WhereLTE(businessDao.C.CreatedTime, monthEnd).Count("id")
|
|
|
+ count, err := businessDao.DataScope(s.Ctx, "sale_id").WhereGTE(businessDao.C.CreatedTime, monthStart).WhereLTE(businessDao.C.CreatedTime, monthEnd).CountColumn("id")
|
|
|
return gconv.String(count), err
|
|
|
|
|
|
case 10006: //当月新增合同数量(维度:月)
|
|
|
- count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).Count("id")
|
|
|
+ count, err := contractDao.DataScope(s.Ctx, "incharge_id").WhereGTE(contractDao.C.CreatedTime, monthStart).WhereLTE(contractDao.C.CreatedTime, monthEnd).CountColumn("id")
|
|
|
return gconv.String(count), err
|
|
|
|
|
|
case 10007: //当月签约合同金额(维度:月)
|
|
|
@@ -193,3 +194,49 @@ func (s *HomeService) getNumStatisticsData(id int64, params *map[string]interfac
|
|
|
}
|
|
|
return "", nil
|
|
|
}
|
|
|
+
|
|
|
+// QueryWechatHomeNumReportData 获取微信首页个人看板数据
|
|
|
+func (s *HomeService) QueryWechatHomeNumReportData(req *home.SearchWechatNumReportDataReq) (resp *home.SearchWechatNumReportDataRes, err error) {
|
|
|
+ customerDao := custDao.NewCustCustomerDao(s.Tenant).DataScope(s.Ctx, "sales_id")
|
|
|
+ businessDao := projDao.NewProjBusinessDao(s.Tenant).DataScope(s.Ctx, "sales_id")
|
|
|
+ taskHandleDao := platDao.NewPlatTaskHandleDao(s.Tenant).M
|
|
|
+ currentTime := gtime.Now()
|
|
|
+ monthStart := currentTime.StartOfMonth()
|
|
|
+ monthEnd := currentTime.EndOfMonth()
|
|
|
+ weekStart := currentTime.StartOfWeek()
|
|
|
+ weekEnd := currentTime.EndOfWeek()
|
|
|
+
|
|
|
+ if req.ViewInterval == "week" {
|
|
|
+ customerDao = customerDao.WhereGTE("created_time", weekStart).WhereLTE("created_time", weekEnd)
|
|
|
+ businessDao = businessDao.WhereGTE("created_time", weekStart).WhereLTE("created_time", weekEnd)
|
|
|
+ taskHandleDao = taskHandleDao.WhereGTE("created_time", weekStart).WhereLTE("created_time", weekEnd)
|
|
|
+ }
|
|
|
+ if req.ViewInterval == "month" {
|
|
|
+ customerDao = customerDao.WhereGTE("created_time", monthStart).WhereLTE("created_time", monthEnd)
|
|
|
+ businessDao = businessDao.WhereGTE("created_time", monthStart).WhereLTE("created_time", monthEnd)
|
|
|
+ taskHandleDao = taskHandleDao.WhereGTE("created_time", monthStart).WhereLTE("created_time", monthEnd)
|
|
|
+ }
|
|
|
+ taskHandleDao = taskHandleDao.Where(platDao.PlatTaskHandle.C.TaskStatus, "10").
|
|
|
+ Where(fmt.Sprintf("main_user_id=%v OR FIND_IN_SET(%v, owner_user_id)", s.GetCxtUserId(), s.GetCxtUserId()))
|
|
|
+
|
|
|
+ // 新增客户数量
|
|
|
+ newCustomerCount, err := customerDao.CountColumn("id")
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(err)
|
|
|
+ }
|
|
|
+ // 新增项目数量
|
|
|
+ newBusinessCount, err := businessDao.CountColumn("id")
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(err)
|
|
|
+ }
|
|
|
+ // 未处理督办事项
|
|
|
+ newTaskCount, err := taskHandleDao.CountColumn("task_id")
|
|
|
+ if err != nil {
|
|
|
+ g.Log().Error(err)
|
|
|
+ }
|
|
|
+ resp = new(home.SearchWechatNumReportDataRes)
|
|
|
+ resp.NewCustomer = newCustomerCount
|
|
|
+ resp.NewBusiness = newBusinessCount
|
|
|
+ resp.NewTask = newTaskCount
|
|
|
+ return resp, nil
|
|
|
+}
|