ermcpPendingAuditInfo.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. // 待审核信息
  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. type ErmcpPendingAuditQty struct {
  23. CntType int64 `json:"CntType" xorm:"'CntType'"` // 类型 1-用户 2-合同 3-套保 4-点价申请 5-结算 6-款项 7-发票
  24. CntQty int64 `json:"CntQty" xorm:"'CntQty'"` // 数量
  25. }
  26. func (r *ErmcpPendingAudit) buildSql() string {
  27. var sqlId = "select 1 as cnttype, count(1) cntqty from wskh_userinfo t where t.memberareaid = %v and t.userstate in(2,4)" +
  28. " union all " +
  29. "select 2, count(1) SpotContractQty from ermcp_spotcontract t where t.userid = %v and t.contractstatus = 1" +
  30. " union all " +
  31. "select 3, count(1) HedgePlanQty from ermcp_hedgeplan t where t.areauserid = %v and t.hedgeplanstatus = 1" +
  32. " union all " +
  33. "select 4, count(1) BusinessDjQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=1" +
  34. " union all " +
  35. "select 5, count(1) BusinessJsQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=2" +
  36. " union all " +
  37. "select 6, count(1) BusinessKxQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=3" +
  38. " union all " +
  39. "select 7, count(1) BusinessFpQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=4"
  40. sqlId = fmt.Sprintf(sqlId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId)
  41. return sqlId
  42. }
  43. func (r *ErmcpPendingAudit) GetDataEx() (interface{}, error) {
  44. rspData := make([]ErmcpPendingAudit, 0)
  45. sData := make([]ErmcpPendingAuditQty, 0)
  46. err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
  47. if err == nil {
  48. var v ErmcpPendingAudit
  49. for _, d := range sData {
  50. // 类型 1-用户 2-合同 3-套保 4-点价申请 5-结算 6-款项 7-发票
  51. switch d.CntType {
  52. case 1:
  53. v.UserQty = d.CntQty
  54. case 2:
  55. v.SpotContractQty = d.CntQty
  56. case 3:
  57. v.HedgePlanQty = d.CntQty
  58. case 4:
  59. v.BusinessDjQty = d.CntQty
  60. case 5:
  61. v.BusinessJsQty = d.CntQty
  62. case 6:
  63. v.BusinessFpQty = d.CntQty
  64. case 7:
  65. v.BusinessFpQty = d.CntQty
  66. }
  67. }
  68. rspData = append(rspData, v)
  69. }
  70. return rspData, err
  71. }