Browse Source

feature:小程序首页统计,登录、工作流报错修改

ZZH-wl 2 years ago
parent
commit
f49db0461f

+ 1 - 1
opms_admin/app/service/sys_login_log.go

@@ -93,7 +93,7 @@ func (s *LoginLogService) Create(ctx context.Context, userName string, loginErr
 	msg := "登录成功"
 	if loginErr != nil {
 		status = "20"
-		msg = err.Error()
+		msg = loginErr.Error()
 	}
 	loginData := &model.SysLogin{
 		UserName:      userName,

+ 1 - 1
opms_admin/app/service/sys_user.go

@@ -44,7 +44,7 @@ func (s *UserService) Login(username, password string) (*request.UserInfo, error
 		return nil, myerrors.TipsError("系统异常")
 	}
 	if sysUserInfo == nil {
-		return nil, myerrors.TipsError("账号或密码错误,或已限制登录")
+		return nil, myerrors.TipsError("账号错误或已限制登录")
 	}
 	// 验证密码
 	if utils.EncryptPassword(password, sysUserInfo.UserSalt) != sysUserInfo.Password {

+ 1 - 0
opms_admin/config/config.toml

@@ -11,6 +11,7 @@
     path   = "./log/websocket"
     level  = "all"
     stdout = false
+    rotateBackupLimit = 1
 
 # 微服务注册中心配置
 [service_registry]

+ 17 - 0
opms_parent/app/handler/home/home.go

@@ -72,3 +72,20 @@ func (h *HomeHandler) GetHomeDataReportData(ctx context.Context, req *model.Sear
 	rsp.Data = resp
 	return nil
 }
+
+// GetWechatHomeNumReportData 获取微信首页个人看板数据
+// Swagger:Home 首页 获取微信首页个人看板数据
+func (h *HomeHandler) GetWechatHomeNumReportData(ctx context.Context, req *model.SearchWechatNumReportDataReq, rsp *comm_def.CommonMsg) error {
+	svc, err := service.NewHomeService(ctx)
+	if err != nil {
+		return err
+	}
+	resp, err := svc.QueryWechatHomeNumReportData(req)
+	if err != nil {
+		return err
+	}
+	rsp.Code = 200
+	rsp.Msg = "查询成功"
+	rsp.Data = resp
+	return nil
+}

+ 10 - 0
opms_parent/app/model/home/home.go

@@ -53,3 +53,13 @@ type DataReportResponse struct {
 	DataReportConfig
 	Data interface{} `json:"data"`
 }
+
+type SearchWechatNumReportDataReq struct {
+	ViewInterval string `json:"viewInterval"   v:"required#查看范围不能为空"` //查看范围
+}
+
+type SearchWechatNumReportDataRes struct {
+	NewCustomer int `json:"newCustomer"` // 新增客户数量
+	NewBusiness int `json:"newBusiness"` // 新增项目数量
+	NewTask     int `json:"newTask"`     // 未处理督办事项
+}

+ 50 - 3
opms_parent/app/service/home/home.go

@@ -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
+}

+ 1 - 1
opms_parent/app/service/workflow/work_flow.go

@@ -55,7 +55,7 @@ func (s *workflowService) StartProcessInstance(bizCode, bizType, remark string,
 		flow.OriginatorUserId = utils.String(s.GetCxtUserDingtalkUid())
 	}
 	if flow.DeptId == nil {
-		flow.DeptId = utils.Int64(435711466)
+		flow.DeptId = utils.Int64(gconv.Int64(s.GetCxtUserDeptId()))
 	}
 	g.Log().Info("搜索值", flow)
 	// 调用钉钉接口