123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- package services
- import (
- "encoding/json"
- "eta/eta_api/models"
- excel3 "eta/eta_api/models/data_manage/excel"
- excelModel "eta/eta_api/models/data_manage/excel"
- "eta/eta_api/models/system"
- "eta/eta_api/services/data/data_manage_permission"
- "eta/eta_api/utils"
- "fmt"
- "time"
- )
- func UpdateExcelEditMark(excelInfoId, nowUserId, status int, nowUserName string) (ret models.MarkReportResp, err error) {
-
- key := fmt.Sprint(`crm:excel:edit:`, excelInfoId)
- opUserId, e := utils.Rc.RedisInt(key)
- var opUser models.MarkReportItem
- if e != nil {
- opUserInfoStr, tErr := utils.Rc.RedisString(key)
- if tErr == nil {
- tErr = json.Unmarshal([]byte(opUserInfoStr), &opUser)
- if tErr == nil {
- opUserId = opUser.AdminId
- }
- }
- }
- if opUserId > 0 && opUserId != nowUserId {
- editor := opUser.Editor
- if editor == "" {
-
- otherInfo, e := system.GetSysAdminById(opUserId)
- if e != nil {
- err = fmt.Errorf("查询其他编辑者信息失败")
- return
- }
- editor = otherInfo.RealName
- }
- ret.Status = 1
- ret.Msg = fmt.Sprintf("当前%s正在编辑中", editor)
- ret.Editor = editor
- return
- }
- if status == 1 {
- nowUser := &models.MarkReportItem{AdminId: nowUserId, Editor: nowUserName}
- bt, e := json.Marshal(nowUser)
- if e != nil {
- err = fmt.Errorf("格式化编辑者信息失败")
- return
- }
- if opUserId > 0 {
- utils.Rc.Do("SETEX", key, int64(300), string(bt))
- } else {
- utils.Rc.SetNX(key, string(bt), time.Second*60*3)
- }
- } else if status == 0 {
-
- _ = utils.Rc.Delete(key)
- }
- return
- }
- func GetTradeAnalysisTableOpButton(belongUserId, sysUserId int, roleTypeCode string, haveOperaAuth bool) (button excelModel.ExcelInfoDetailButton) {
-
-
-
-
-
- button.RefreshButton = true
- button.CopyButton = true
- button.DownloadButton = true
-
- if belongUserId == sysUserId || roleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
- button.OpButton = true
- button.DeleteButton = true
- }
- return
- }
- func GetBalanceExcelIdsByAdminId(adminId int, condition string, pars []interface{}, permissionEdbIdList, permissionClassifyIdList []int) (authIds []int, err error) {
-
- obj := new(excel3.ExcelWorker)
- existList, err := obj.GetBySysUserId(adminId)
- if err != nil {
-
-
- return
- }
- var excelIds []int
- newCondition := condition
- newPars := pars
- if len(existList) > 0 {
- for _, v := range existList {
- excelIds = append(excelIds, v.ExcelInfoId)
- }
- newCondition += fmt.Sprintf(` AND ( excel_info_id IN (%s) or sys_user_id = ?)`, utils.GetOrmInReplace(len(excelIds)))
- newPars = append(newPars, excelIds, adminId)
- } else {
- newCondition += ` AND sys_user_id = ? `
- newPars = append(newPars, adminId)
- }
-
- tmpList, e := excel3.GetNoContentExcelListByConditionNoPage(newCondition, newPars)
- if e != nil && e.Error() != utils.ErrNoRow() {
-
-
-
- return
- }
- classifyIdListTmp := make([]int, 0)
- for _, v := range tmpList {
- classifyIdListTmp = append(classifyIdListTmp, v.ExcelClassifyId)
- }
- classifyMap := make(map[int]*excel3.ExcelClassify)
-
- if len(classifyIdListTmp) > 0 {
- classifyListTmp, e := excel3.GetClassifyByIdList(classifyIdListTmp)
- if e != nil {
-
-
- return
- }
- for _, v := range classifyListTmp {
- classifyMap[v.ExcelClassifyId] = v
- }
- }
- excelIds = make([]int, 0)
- for _, v := range tmpList {
-
- if classifyInfo, ok := classifyMap[v.ExcelClassifyId]; ok {
- v.HaveOperaAuth = data_manage_permission.CheckExcelPermissionByPermissionIdList(v.IsJoinPermission, classifyInfo.IsJoinPermission, v.ExcelInfoId, v.ExcelClassifyId, permissionEdbIdList, permissionClassifyIdList)
- if v.HaveOperaAuth {
- excelIds = append(excelIds, v.ExcelInfoId)
- }
- }
- }
- authIds = excelIds
- return
- }
|