|
|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
* @Author: zou.yingbin
|
|
|
* @Create : 2020/12/2 9:17
|
|
|
-* @Modify : 2020/12/2 9:17
|
|
|
+* @Modify : 2020/12/10 10:45
|
|
|
*/
|
|
|
|
|
|
// 查询待审核的合同
|
|
|
@@ -61,17 +61,17 @@ func (r *AuditContractModel) GetData(accountIDs string, contractType int32) ([]A
|
|
|
|
|
|
// 待审核合同(回购)
|
|
|
type AutditContractHGModel struct {
|
|
|
- SpotContractId string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'" binding:"required"` // 合同ID
|
|
|
- MatchCustomerName string `json:"matchcustomername" xorm:"'MATCHCUSTOMERNAME'" binding:"required"` // 销售方ID
|
|
|
- MatchAccountId string `json:"matchaccountid" xorm:"'MATCHACCOUNTID'"` // 业务员ID
|
|
|
- AccountId string `json:"accountid" xorm:"'ACCOUNTID'"` // 交易员ID
|
|
|
- CustomerName string `json:"customername" xorm:"'CUSTOMERNAME'"` // 采购方ID
|
|
|
- WrstandardName string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 商品名称
|
|
|
- Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 商品代码
|
|
|
- ApplyStatus uint32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 状态
|
|
|
- EnumdicName string `json:"enumdicname" xorm:"'ENUMDICNAME'"` // 单位名称
|
|
|
- ContractQty float64 `json:"contractqty" xorm:"'CONTRACTQTY'"` // 合同量
|
|
|
- SignDate string `json:"signdate" xorm:"'SIGNDATE'"` // 签订日期
|
|
|
+ SpotContractId string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'" binding:"required"` // 合同ID
|
|
|
+ MatchCustomerName string `json:"matchcustomername" xorm:"'MATCHCUSTOMERNAME'" binding:"required"` // 销售方ID
|
|
|
+ MatchAccountId string `json:"matchaccountid" xorm:"'MATCHACCOUNTID'"` // 业务员ID
|
|
|
+ AccountId string `json:"accountid" xorm:"'ACCOUNTID'"` // 交易员ID
|
|
|
+ CustomerName string `json:"customername" xorm:"'CUSTOMERNAME'"` // 采购方ID
|
|
|
+ WrstandardName string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 商品名称
|
|
|
+ Wrstandardcode string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 商品代码
|
|
|
+ ApplyStatus uint32 `json:"applystatus" xorm:"'APPLYSTATUS'"` // 状态
|
|
|
+ EnumdicName string `json:"enumdicname" xorm:"'ENUMDICNAME'"` // 单位名称
|
|
|
+ ContractQty float64 `json:"contractqty" xorm:"'CONTRACTQTY'"` // 合同量
|
|
|
+ SignDate string `json:"signdate" xorm:"'SIGNDATE'"` // 签订日期
|
|
|
}
|
|
|
|
|
|
func (r *AutditContractHGModel) buildSql(accountIDs string) string {
|
|
|
@@ -102,13 +102,72 @@ func (r *AutditContractHGModel) buildSql(accountIDs string) string {
|
|
|
return fmt.Sprintf(sqlId, accountIDs)
|
|
|
}
|
|
|
|
|
|
+// 从数据库获取待审核合同
|
|
|
func (r *AutditContractHGModel) GetData(accountIDs string) ([]AutditContractHGModel, error) {
|
|
|
sAC := make([]AutditContractHGModel, 0)
|
|
|
e := db.GetEngine()
|
|
|
s := e.SQL(r.buildSql(accountIDs))
|
|
|
- if err := s.Find(&sAC); err != nil{
|
|
|
+ if err := s.Find(&sAC); err != nil {
|
|
|
logger.GetLogger().Errorf("query hg pending contract fail:%v", err)
|
|
|
return sAC, err
|
|
|
}
|
|
|
return sAC, nil
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+// 待审核基差贸易业务
|
|
|
+type PendingAuditBizModel struct {
|
|
|
+ BizID string `json:"bizid" xorm:"'BIZID'"` // 业务ID
|
|
|
+ AccountID string `json:"accountid" xorm:"'ACCOUNTID'"` // 现货账户
|
|
|
+ Type int32 `json:"type" xorm:"'TYPE'"` // 业务类型,1-期现套利,2-仓单回购,3-现货贸易
|
|
|
+ BizName string `json:"bizname" xorm:"'BIZNAME'"` // 业务名称
|
|
|
+ AreaName string `json:"areaname" xorm:"'AREANAME'"` // 所属部门
|
|
|
+ Status int32 `json:"status" xorm:"'STATUS'"` // 状态,0:待审核 1:审核通过 2:审核中 3:审核失败 4已撤销 5:审核拒绝
|
|
|
+}
|
|
|
+
|
|
|
+func (r *PendingAuditBizModel) buildSql(accIDs string) string {
|
|
|
+ sqlId := "select t.*, u.accountname AreaName" +
|
|
|
+ " from (select spottradeid BizID," +
|
|
|
+ " spottradename BizName," +
|
|
|
+ " spotaccountid AccountID," +
|
|
|
+ " 3 as Type," +
|
|
|
+ " areauserid userId," +
|
|
|
+ " applystatus Status" +
|
|
|
+ " from erms2_spottradeapply" +
|
|
|
+ " union all" +
|
|
|
+ " select wrrcontractid BizID," +
|
|
|
+ " wrrcontractname BizName," +
|
|
|
+ " accountid," +
|
|
|
+ " 2 as Type," +
|
|
|
+ " areauserid userId," +
|
|
|
+ " applystatus Status" +
|
|
|
+ " from erms2_wrrapply t" +
|
|
|
+ " union all" +
|
|
|
+ " select a.asapplyid BizID," +
|
|
|
+ " a.asname BizName," +
|
|
|
+ " b.accountid," +
|
|
|
+ " 1 as Type," +
|
|
|
+ " a.userid," +
|
|
|
+ " a.applystatus Status" +
|
|
|
+ " from erms2_asapply a" +
|
|
|
+ " inner join erms2_asaccount b" +
|
|
|
+ " on a.asapplyid = b.asapplyid" +
|
|
|
+ " and b.taaccountbiztype = 1) t" +
|
|
|
+ " left join useraccount u" +
|
|
|
+ " on t.userId = u.userid" +
|
|
|
+ " where t.Status in (0, 2, 5) and t.accountid in(%v)"
|
|
|
+
|
|
|
+ return fmt.Sprintf(sqlId, accIDs)
|
|
|
+}
|
|
|
+
|
|
|
+// 从数据库获取待审核基差贸易业务
|
|
|
+func (r *PendingAuditBizModel) GetData(accIDs string) ([]PendingAuditBizModel, error) {
|
|
|
+ sRet := make([]PendingAuditBizModel, 0)
|
|
|
+ e := db.GetEngine()
|
|
|
+ s := e.SQL(r.buildSql(accIDs))
|
|
|
+ if err := s.Find(&sRet); err != nil {
|
|
|
+ logger.GetLogger().Errorf("query pending biz fail: %v", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return sRet, nil
|
|
|
+}
|