Browse Source

feature(Bug):
1、修复因客户字段变更导致销售区域客户统计问题
2、修复数据库连接使用错误问题

ZZH-wl 2 years ago
parent
commit
a0dbce3d87

+ 4 - 3
opms_admin/app/model/sys_role.go

@@ -46,7 +46,8 @@ type StatusSetReq struct {
 
 // DataScopeReq 角色数据授权参数
 type DataScopeReq struct {
-	RoleId    uint   `p:"roleId" v:"required#角色ID不能为空"`
-	DataScope uint   `p:"dataScope" v:"required#权限范围不能为空"`
-	DeptIds   []uint `p:"deptIds"`
+	RoleId            uint   `p:"roleId" v:"required#角色ID不能为空"`
+	DataScope         uint   `p:"dataScope" v:"required#权限范围不能为空"`
+	DeptCheckStrictly string `p:"deptCheckStrictly"` // 部门树选择项是否关联显示
+	DeptIds           []uint `p:"deptIds"`
 }

+ 4 - 4
opms_admin/app/service/sys_role.go

@@ -190,14 +190,14 @@ func (s *RoleService) DeleteByIds(ids []int64) (err error) {
 }
 
 func (s *RoleService) UpdateRoleStatus(req *model.StatusSetReq) error {
-	_, err := s.Dao.Where(s.Dao.C.Id, req.RoleId).Data(s.Dao.C.Status, req.Status).Update()
+	_, err := s.Dao.WherePri(req.RoleId).Data(s.Dao.C.Status, req.Status).Update()
 	return err
 }
 
 // 设置角色数据权限
 func (s *RoleService) UpdateRoleDataScope(req *model.DataScopeReq) error {
 	err := s.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
-		_, err := s.Dao.TX(tx).Where("id", req.RoleId).Data(g.Map{"data_scope": req.DataScope}).Update()
+		_, err := s.Dao.TX(tx).WherePri(req.RoleId).Data(g.Map{s.Dao.C.DataScope: req.DataScope, s.Dao.C.DeptCheckStrictly: req.DeptCheckStrictly}).Update()
 		if err != nil {
 			return err
 		}
@@ -208,9 +208,9 @@ func (s *RoleService) UpdateRoleDataScope(req *model.DataScopeReq) error {
 			}
 			data := g.List{}
 			for _, deptId := range req.DeptIds {
-				data = append(data, g.Map{"role_id": req.RoleId, "dept_id": deptId})
+				data = append(data, g.Map{s.roleDeptDao.C.RoleId: req.RoleId, s.roleDeptDao.C.DeptId: deptId})
 			}
-			_, err = s.roleDeptDao.Data(data).Insert()
+			_, err = s.roleDeptDao.TX(tx).Data(data).Insert()
 			if err != nil {
 				return err
 			}

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

@@ -269,7 +269,7 @@ func (s *UserService) GetUserInfoById(id int, withPwd ...bool) (user *model.SysU
 
 func (s *UserService) CreateUser(req *model.AddUserReq) (err error) {
 	var tx *gdb.TX
-	tx, err = g.DB().Begin()
+	tx, err = s.Dao.DB.Begin()
 	if err != nil {
 		err = myerrors.TipsError("事务开启失败")
 		return
@@ -430,7 +430,7 @@ func (s *UserService) UpdateUser(req *model.EditUserReq) (err error) {
 		return
 	}
 	var tx *gdb.TX
-	tx, err = g.DB().Begin()
+	tx, err = s.Dao.DB.Begin()
 	//保存管理员信息
 	var userData *model.SysUser
 	err = s.Dao.Where("id", req.Id).Scan(&userData)
@@ -486,7 +486,7 @@ func (s *UserService) ChangeUserStatus(req *model.SysUserStatusReq) error {
 
 // DeleteUserByIds 删除用户信息
 func (s *UserService) DeleteUserByIds(ctx context.Context, ids []int64) error {
-	return g.DB().Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
+	return s.Dao.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error {
 		_, err := s.Dao.Ctx(ctx).TX(tx).Where(s.Dao.C.Id+" in(?)", ids).Delete()
 		//删除用户对应的岗位
 		//_, err = dao.SysUserPost.Ctx(ctx).TX(tx).Delete(dao.SysUserPost.C.UserId+" in (?)", ids)

+ 3 - 2
opms_libary/plugin/dingtalk/client_test.go

@@ -5,6 +5,7 @@ import (
 	"dashoo.cn/opms_libary/utils"
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/util/gconv"
 	"testing"
 )
 
@@ -12,9 +13,9 @@ func TestQuerySchemaByProcessCode(t *testing.T) {
 	client := NewClient()
 
 	w := client.GetWorkflow()
-	s, _ := w.QuerySchemaByProcessCode("PROC-7A5F6215-A8CF-4DD1-AB2C-5B1AB84C4E19")
+	s, _ := w.QuerySchemaByProcessCode("PROC-E5A8B695-A6AF-49CF-9909-9A31C33A1211")
 
-	fmt.Println(s)
+	fmt.Println(gconv.String(s))
 }
 
 func TestSign(t *testing.T) {

+ 3 - 3
opms_parent/app/service/base/base_sales_region_detail.go

@@ -47,7 +47,7 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 		districtList = append(districtList, v.CustProvinceId)
 	}
 	//CustModel := p.CustomerDao.M
-	CustModel := s.CustomerDao.M.Fields("count(*) as count,cust_dist_code").Where("cust_dist_code in (?)", districtList)
+	CustModel := s.CustomerDao.M.Fields("count(*) as count,cust_city_id").Where("cust_city_id in (?)", districtList)
 	if req.CustName != "" {
 		CustModel = CustModel.Where(s.CustomerDao.C.CustName+" like ?", "%"+req.CustName+"%")
 	}
@@ -58,11 +58,11 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 		CustModel = CustModel.Where(s.CustomerDao.C.CustIndustry+" like ?", "%"+req.CustIndustry+"%")
 	}
 
-	custDist, _ := CustModel.Group("cust_dist_code").All()
+	custDist, _ := CustModel.Group("cust_city_id").All()
 
 	for _, v := range RegionList {
 		for _, v3 := range custDist {
-			if v.CustProvinceId == gconv.Int(v3["cust_dist_code"]) {
+			if v.CustProvinceId == gconv.Int(v3["cust_city_id"]) {
 				v.Count = gconv.Int(v3["count"])
 			}
 		}