1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package services
- import (
- "encoding/json"
- "eta/eta_mobile/models"
- "eta/eta_mobile/models/system"
- "eta/eta_mobile/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
- }
|