sqlOperate.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package main
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "database/sql"
  5. "log"
  6. )
  7. // 新增动态
  8. func AddChangeRecord(tx *sql.Tx, clueId, positionId int64, changeField, changeType, newValue, oldValue, nowTime, BCPCID string, operatorId int64) int64 {
  9. if BCPCID == "" {
  10. BCPCID = common.GetRandom(32)
  11. }
  12. if tx == nil {
  13. return TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
  14. "clue_id": clueId,
  15. "position_id": positionId,
  16. "change_field": changeField,
  17. "change_type": changeType,
  18. "old_value": oldValue,
  19. "new_value": newValue,
  20. "createtime": nowTime,
  21. "BCPCID": BCPCID,
  22. "operator_id": operatorId,
  23. })
  24. }
  25. return TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
  26. "clue_id": clueId,
  27. "position_id": positionId,
  28. "change_field": changeField,
  29. "change_type": changeType,
  30. "old_value": oldValue,
  31. "new_value": newValue,
  32. "createtime": nowTime,
  33. "BCPCID": BCPCID,
  34. "operator_id": operatorId,
  35. })
  36. }
  37. // 通过职位id换人名
  38. func FindPositionToName(positionId int64) string {
  39. data := TiDb.SelectBySql(`select name from dwd_f_crm_personnel_management where resign = 0 and position_id = ? limit 1`, positionId)
  40. if data != nil && len(*data) > 0 {
  41. return common.ObjToString((*data)[0]["name"])
  42. }
  43. return ""
  44. }
  45. // 通过坐席号换人名
  46. func FindSeatNumberToName(seatNumber string) string {
  47. data := TiDb.SelectBySql(`select name from dwd_f_crm_personnel_management where resign = 0 and seat_number = ? limit 1`, seatNumber)
  48. if data != nil && len(*data) > 0 {
  49. return common.ObjToString((*data)[0]["name"])
  50. }
  51. return ""
  52. }
  53. // 锁定人变更
  54. func UpdateLockPositionId(clueId, lockPositionId int64) {
  55. ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{
  56. "id": clueId,
  57. }, map[string]interface{}{
  58. "lock_position_id": lockPositionId,
  59. })
  60. log.Println("锁定人信息修改:", clueId, lockPositionId, ok)
  61. return
  62. }
  63. // 锁定状态变更
  64. func UpdateLockStatus(clueId, lockStatus int64) {
  65. ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{
  66. "id": clueId,
  67. }, map[string]interface{}{
  68. "lock_status": lockStatus,
  69. })
  70. log.Println("锁定状态信息修改:", clueId, lockStatus, ok)
  71. return
  72. }