| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /**
- * @Author: zou.yingbin
- * @Create : 2021/2/25 13:32
- * @Modify : 2021/2/25 13:32
- */
- package models
- import (
- "fmt"
- "mtp2_if/db"
- )
- // 待审核信息
- type ErmcpPendingAudit struct {
- UserQty int64 `json:"userqty" xorm:"'UserQty'"` // 待审核数量: 用户
- SpotContractQty int64 `json:"spotcontractqty" xorm:"'SpotContractQty'"` // 待审核数量: 现货合同
- HedgePlanQty int64 `json:"hedgeplanqty" xorm:"'HedgePlanQty'"` // 待审核数量: 套保计划
- BusinessDjQty int64 `json:"businessdjqty" xorm:"'BusinessDjQty'"` // 待审核数量: 点价
- BusinessJsQty int64 `json:"businessjsqty" xorm:"'BusinessJsQty'"` // 待审核数量: 结算
- BusinessKxQty int64 `json:"businesskxqty" xorm:"'BusinessKxQty'"` // 待审核数量: 款项
- BusinessFpQty int64 `json:"businessfpqty" xorm:"'BusinessFpQty'"` // 待审核数量: 发票
- UserId int64 `json:"-"` // 所属用户id
- }
- type ErmcpPendingAuditQty struct {
- CntType int64 `json:"CntType" xorm:"'CntType'"` // 类型 1-用户 2-合同 3-套保 4-点价申请 5-结算 6-款项 7-发票
- CntQty int64 `json:"CntQty" xorm:"'CntQty'"` // 数量
- }
- func (r *ErmcpPendingAudit) buildSql() string {
- var sqlId = "select 1 as cnttype, count(1) cntqty from wskh_userinfo t where t.memberareaid = %v and t.userstate in(2,4)" +
- " union all " +
- "select 2, count(1) SpotContractQty from ermcp_spotcontract t where t.userid = %v and t.contractstatus = 1" +
- " union all " +
- "select 3, count(1) HedgePlanQty from ermcp_hedgeplan t where t.areauserid = %v and t.hedgeplanstatus = 1" +
- " union all " +
- "select 4, count(1) BusinessDjQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=1" +
- " union all " +
- "select 5, count(1) BusinessJsQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=2" +
- " union all " +
- "select 6, count(1) BusinessKxQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=3" +
- " union all " +
- "select 7, count(1) BusinessFpQty from ermcp_contractoperateapply t where t.userid = %v and t.applystatus = 1 and t.operateapplytype=4"
- sqlId = fmt.Sprintf(sqlId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId, r.UserId)
- return sqlId
- }
- func (r *ErmcpPendingAudit) GetDataEx() (interface{}, error) {
- rspData := make([]ErmcpPendingAudit, 0)
- sData := make([]ErmcpPendingAuditQty, 0)
- err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
- if err == nil {
- var v ErmcpPendingAudit
- for _, d := range sData {
- // 类型 1-用户 2-合同 3-套保 4-点价申请 5-结算 6-款项 7-发票
- switch d.CntType {
- case 1:
- v.UserQty = d.CntQty
- case 2:
- v.SpotContractQty = d.CntQty
- case 3:
- v.HedgePlanQty = d.CntQty
- case 4:
- v.BusinessDjQty = d.CntQty
- case 5:
- v.BusinessJsQty = d.CntQty
- case 6:
- v.BusinessFpQty = d.CntQty
- case 7:
- v.BusinessFpQty = d.CntQty
- }
- }
- rspData = append(rspData, v)
- }
- return rspData, err
- }
|