ermcpPendingAuditInfo.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/2/25 13:32
  4. * @Modify : 2021/2/25 13:32
  5. */
  6. package models
  7. import (
  8. "fmt"
  9. "mtp2_if/db"
  10. )
  11. // ErmcpPendingAudit 待审核信息
  12. type ErmcpPendingAudit struct {
  13. UserQty int64 `json:"userqty" xorm:"'UserQty'"` // 待审核数量: 用户
  14. SpotContractQty int64 `json:"spotcontractqty" xorm:"'SpotContractQty'"` // 待审核数量: 现货合同
  15. HedgePlanQty int64 `json:"hedgeplanqty" xorm:"'HedgePlanQty'"` // 待审核数量: 套保计划
  16. BusinessDjQty int64 `json:"businessdjqty" xorm:"'BusinessDjQty'"` // 待审核数量: 点价
  17. BusinessJsQty int64 `json:"businessjsqty" xorm:"'BusinessJsQty'"` // 待审核数量: 结算
  18. BusinessKxQty int64 `json:"businesskxqty" xorm:"'BusinessKxQty'"` // 待审核数量: 款项
  19. BusinessFpQty int64 `json:"businessfpqty" xorm:"'BusinessFpQty'"` // 待审核数量: 发票
  20. UserId int64 `json:"-"` // 所属用户id
  21. }
  22. // ErmcpPendingAuditQty 待审核数量类型和计数
  23. type ErmcpPendingAuditQty struct {
  24. CntType int64 `json:"CntType" xorm:"'CntType'"` // 类型 1-用户 2-合同 3-套保 4-点价申请 5-结算 6-款项 7-发票
  25. CntQty int64 `json:"CntQty" xorm:"'CntQty'"` // 数量
  26. }
  27. func (r *ErmcpPendingAudit) buildSql() string {
  28. var sqlId = "select 1 as cnttype, count(1) cntqty from wskh_userinfo t where t.memberareaid = %v and t.userstate in(2,4)" +
  29. " union all " +
  30. "select 2, count(1) SpotContractQty from ermcp_spotcontract t where t.userid = %v and t.contractstatus = 1" +
  31. " union all " +
  32. "select 3, count(1) HedgePlanQty from ermcp_hedgeplan t where t.areauserid = %v and t.hedgeplanstatus = 1" +
  33. " union all " +
  34. "select 4, count(1) BusinessDjQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=1" +
  35. " union all " +
  36. "select 5, count(1) BusinessJsQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=2" +
  37. " union all " +
  38. "select 6, count(1) BusinessKxQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=3" +
  39. " union all " +
  40. "select 7, count(1) BusinessFpQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=4"
  41. sqlId = fmt.Sprintf(sqlId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId)
  42. return sqlId
  43. }
  44. // GetDataEx 获取小红点计数信息
  45. func (r *ErmcpPendingAudit) GetDataEx() (interface{}, error) {
  46. rspData := make([]ErmcpPendingAudit, 0)
  47. sData := make([]ErmcpPendingAuditQty, 0)
  48. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  49. if err == nil {
  50. var v ErmcpPendingAudit
  51. for _, d := range sData {
  52. // 类型 1-用户 2-合同 3-套保 4-点价申请 5-结算 6-款项 7-发票
  53. switch d.CntType {
  54. case 1:
  55. v.UserQty = d.CntQty
  56. case 2:
  57. v.SpotContractQty = d.CntQty
  58. case 3:
  59. v.HedgePlanQty = d.CntQty
  60. case 4:
  61. v.BusinessDjQty = d.CntQty
  62. case 5:
  63. v.BusinessJsQty = d.CntQty
  64. case 6:
  65. v.BusinessFpQty = d.CntQty
  66. case 7:
  67. v.BusinessFpQty = d.CntQty
  68. }
  69. }
  70. rspData = append(rspData, v)
  71. }
  72. return rspData, err
  73. }