Pārlūkot izejas kodu

企业风管:查询合同增加交易主体字段

zou.yingbin 4 gadi atpakaļ
vecāks
revīzija
040f8658c2
4 mainītis faili ar 194 papildinājumiem un 135 dzēšanām
  1. 16 0
      docs/docs.go
  2. 16 0
      docs/swagger.json
  3. 12 0
      docs/swagger.yaml
  4. 150 135
      models/ermcp3.go

+ 16 - 0
docs/docs.go

@@ -18425,6 +18425,14 @@ var doc = `{
                     "description": "点价开始日期 [2:点价 3:暂定价]",
                     "type": "string"
                 },
+                "subjectid": {
+                    "description": "交易主体ID",
+                    "type": "string"
+                },
+                "subjectname": {
+                    "description": "交易主体名称",
+                    "type": "string"
+                },
                 "tradeuserid": {
                     "description": "交易员id",
                     "type": "integer"
@@ -20073,6 +20081,14 @@ var doc = `{
                     "description": "点价开始日",
                     "type": "string"
                 },
+                "subjectid": {
+                    "description": "交易主体ID",
+                    "type": "string"
+                },
+                "subjectname": {
+                    "description": "交易主体名称",
+                    "type": "string"
+                },
                 "totalamount": {
                     "description": "合计总额",
                     "type": "number"

+ 16 - 0
docs/swagger.json

@@ -18409,6 +18409,14 @@
                     "description": "点价开始日期 [2:点价 3:暂定价]",
                     "type": "string"
                 },
+                "subjectid": {
+                    "description": "交易主体ID",
+                    "type": "string"
+                },
+                "subjectname": {
+                    "description": "交易主体名称",
+                    "type": "string"
+                },
                 "tradeuserid": {
                     "description": "交易员id",
                     "type": "integer"
@@ -20057,6 +20065,14 @@
                     "description": "点价开始日",
                     "type": "string"
                 },
+                "subjectid": {
+                    "description": "交易主体ID",
+                    "type": "string"
+                },
+                "subjectname": {
+                    "description": "交易主体名称",
+                    "type": "string"
+                },
                 "totalamount": {
                     "description": "合计总额",
                     "type": "number"

+ 12 - 0
docs/swagger.yaml

@@ -3912,6 +3912,12 @@ definitions:
       startdate:
         description: 点价开始日期 [2:点价 3:暂定价]
         type: string
+      subjectid:
+        description: 交易主体ID
+        type: string
+      subjectname:
+        description: 交易主体名称
+        type: string
       tradeuserid:
         description: 交易员id
         type: integer
@@ -5138,6 +5144,12 @@ definitions:
       startdate:
         description: 点价开始日
         type: string
+      subjectid:
+        description: 交易主体ID
+        type: string
+      subjectname:
+        description: 交易主体名称
+        type: string
       totalamount:
         description: 合计总额
         type: number

+ 150 - 135
models/ermcp3.go

@@ -646,6 +646,8 @@ type Ermcp3Contract struct {
 	ACCOUNTID         string  `json:"accountid"  xorm:"'ACCOUNTID'"`                 // 期货账户id
 	BIZTYPE           int32   `json:"biztype"  xorm:"'BIZTYPE'"`                     // 业务类型 1-套保 2-套利
 	CURRENCYID        int32   `json:"currencyid"  xorm:"'CURRENCYID'"`               // 币种id
+	SUBJECTID         string  `json:"subjectid"  xorm:"'SUBJECTID'"`                 // 交易主体ID
+	SUBJECTNAME       string  `json:"subjectname"  xorm:"'SUBJECTNAME'"`             // 交易主体名称
 
 	SELLNICKNAME       string `json:"sellnickname"`       // 采购方昵称
 	BUYNICKNAME        string `json:"buynickname"`        // 销售方昵称
@@ -692,62 +694,68 @@ func (r *Ermcp3Contract) calc() {
 }
 
 func (r *Ermcp3Contract) buildSql() string {
-	var sqlId utils.SQLVal = "SELECT to_char(t.SPOTCONTRACTID) SPOTCONTRACTID," +
-		"       t.CONTRACTNO," +
-		"       t.CONTRACTTYPE," +
-		"       t.USERID," +
-		"       t.BUYUSERID," +
-		"       t.SELLUSERID," +
-		"       t.DELIVERYGOODSID," +
-		"       t.wrstandardid," +
-		"       t.PRODUCTTYPE," +
-		"       w.CONVERTFACTOR," +
-		"       t.SPOTGOODSDESC," +
-		"       t.PRICETYPE," +
-		"       t.QTY," +
-		"       t.PRICE," +
-		"       t.AMOUNT," +
-		"       to_char(t.DELIVERYSTARTDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYSTARTDATE," +
-		"       to_char(t.DELIVERYENDDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYENDDATE," +
-		"       t.GOODSID," +
-		"       t.PRICEMOVE," +
-		"       to_char(t.STARTDATE, 'yyyy-mm-dd hh24:mi:ss') STARTDATE," +
-		"       to_char(t.ENDDATE, 'yyyy-mm-dd hh24:mi:ss') ENDDATE," +
-		"       t.MARGIN," +
-		"       t.contractmargin," +
-		"       t.remark," +
-		"       t.auditremark," +
-		"       to_char(t.contractattachment) attachment," +
-		"       t.contractstatus," +
-		"       t.SPOTGOODSBRANDID," +
-		"       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
-		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
-		"       to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') updatetime," +
-		"       g.deliverygoodscode," +
-		"       g.deliverygoodsname," +
-		"       g2.goodscode," +
-		"       g2.goodsname," +
-		"       gb.dgfactoryitemvalue brandname," +
-		"       w.wrstandardname," +
-		"       w.wrstandardcode," +
-		"       w.unitid," +
-		"       t.tradeuserid," +
-		"       t.saleuserid," +
-		"       t.meruserid," +
-		"       t.currencyid," +
-		"       to_char(t.accountid) accountid," +
-		"       t.biztype" +
-		"  FROM ERMCP_SPOTCONTRACT t" +
-		"  left join deliverygoods g" +
-		"    on t.deliverygoodsid = g.deliverygoodsid" +
-		"  left join goods g2" +
-		"    on t.goodsid = g2.goodsid" +
-		"  left join DGFACTORYITEM gb" +
-		"    on t.spotgoodsbrandid = gb.dgfactoryitemid" +
-		"  left join wrstandard w" +
-		"    on t.wrstandardid = w.wrstandardid" +
-		"  left join loginaccount l on t.applyid=l.loginid" +
-		" where 1 = 1"
+	var sqlId utils.SQLVal = `
+SELECT to_char(t.SPOTCONTRACTID) SPOTCONTRACTID,
+       t.CONTRACTNO,
+       t.CONTRACTTYPE,
+       t.USERID,
+       t.BUYUSERID,
+       t.SELLUSERID,
+       t.DELIVERYGOODSID,
+       t.wrstandardid,
+       t.PRODUCTTYPE,
+       w.CONVERTFACTOR,
+       t.SPOTGOODSDESC,
+       t.PRICETYPE,
+       t.QTY,
+       t.PRICE,
+       t.AMOUNT,
+       to_char(t.DELIVERYSTARTDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYSTARTDATE,
+       to_char(t.DELIVERYENDDATE, 'yyyy-mm-dd hh24:mi:ss') DELIVERYENDDATE,
+       t.GOODSID,
+       t.PRICEMOVE,
+       to_char(t.STARTDATE, 'yyyy-mm-dd hh24:mi:ss') STARTDATE,
+       to_char(t.ENDDATE, 'yyyy-mm-dd hh24:mi:ss') ENDDATE,
+       t.MARGIN,
+       t.contractmargin,
+       t.remark,
+       t.auditremark,
+       to_char(t.contractattachment) attachment,
+       t.contractstatus,
+       t.SPOTGOODSBRANDID,
+       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime,
+       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime,
+       to_char(t.updatetime, 'yyyy-mm-dd hh24:mi:ss') updatetime,
+       g.deliverygoodscode,
+       g.deliverygoodsname,
+       g2.goodscode,
+       g2.goodsname,
+       gb.dgfactoryitemvalue brandname,
+       w.wrstandardname,
+       w.wrstandardcode,
+       w.unitid,
+       t.tradeuserid,
+       t.saleuserid,
+       t.meruserid,
+       t.currencyid,
+       to_char(t.accountid) accountid,
+       t.biztype,
+       to_char(t.subjectid) subjectid,
+       b.subjectname
+  FROM ERMCP_SPOTCONTRACT t
+  left join ermcp_pa_areasubject b on t.subjectid=b.subjectid
+  left join deliverygoods g
+    on t.deliverygoodsid = g.deliverygoodsid
+  left join goods g2
+    on t.goodsid = g2.goodsid
+  left join DGFACTORYITEM gb
+    on t.spotgoodsbrandid = gb.dgfactoryitemid
+  left join wrstandard w
+    on t.wrstandardid = w.wrstandardid
+  left join loginaccount l
+    on t.applyid = l.loginid
+ where 1 = 1
+`
 	sqlId.AndEx("t.SPOTCONTRACTID", r.SPOTCONTRACTID, len(r.SPOTCONTRACTID) > 0)
 	// 用户条件
 	sqlId.Join(fmt.Sprintf(" and %v in(t.userid, t.saleuserid, t.tradeuserid, t.meruserid, l.userid)", r.OwnUserId))
@@ -831,6 +839,8 @@ type Ermcp3SellBuyContract struct {
 	ACCOUNTID          string  `json:"accountid"  xorm:"'ACCOUNTID'"`                   // 期货账户id
 	BIZTYPE            int32   `json:"biztype"  xorm:"'BIZTYPE'"`                       // 业务类型 1-套保 2-套利
 	CURRENCYID         int32   `json:"currencyid"  xorm:"'CURRENCYID'"`                 // 币种id
+	SUBJECTID          string  `json:"subjectid"  xorm:"'SUBJECTID'"`                   // 交易主体ID
+	SUBJECTNAME        string  `json:"subjectname"  xorm:"'SUBJECTNAME'"`               // 交易主体名称
 
 	NICKNAME           string `json:"nickname"`           // 账户昵称
 	TRADEUSERLOGINCODE string `json:"tradeuserlogincode"` // 交易员登录代码
@@ -882,85 +892,90 @@ func (r *Ermcp3SellBuyContract) calc() {
 }
 
 func (r *Ermcp3SellBuyContract) buildSql() string {
-	var sqlId utils.SQLVal = "select t.contractno," +
-		"       to_char(t.SpotContractId) SpotContractId," +
-		"       t.deliverygoodsid," +
-		"       t.spotgoodsdesc," +
-		"       t.goodsid," +
-		"       t.pricemove," +
-		"       t.userid," +
-		"       t.BUYUSERID," +
-		"       t.SELLUSERID," +
-		"       t.qty," +
-		"       t.qty - t.pricedqty unpricedqty," +
-		"       t.pricedqty," +
-		"       (case" +
-		"         when t.pricetype = 3 then" +
-		"          t.qty - t.RECKONREALQTY" +
-		"         else" +
-		"          t.pricedqty - nvl(t.ReckonRealQty,0)" +
-		"       end) unsureqty," +
-		"       t.reckonedamount PayAmount," +
-		"       t.invoiceamount," +
-		"       (t.pricedamount + t.RECKONADJUSTAMOUNT -" +
-		"       t.invoiceamount) as daikaiAmount," +
-		"       to_char(t.startdate, 'yyyy-mm-dd hh24:mi:ss') startdate," +
-		"       to_char(t.enddate, 'yyyy-mm-dd hh24:mi:ss') enddate," +
-		"       to_char(t.deliverystartdate, 'yyyy-mm-dd hh24:mi:ss') deliverystartdate," +
-		"       to_char(t.deliveryenddate, 'yyyy-mm-dd hh24:mi:ss') deliveryenddate," +
-		"       wr.convertfactor," +
-		"       t.contractstatus," +
-		"       t.pricetype," +
-		"       t.producttype," +
-		"       t.contracttype," +
-		"       t.remark," +
-		"       to_char(t.contractattachment) attachment," +
-		"       t.margin," +
-		"       t.contractmargin," +
-		"       t.SPOTGOODSBRANDID," +
-		"       t.tradeuserid," +
-		"       t.saleuserid," +
-		"       t.meruserid," +
-		"       t.currencyid," +
-		"       t.biztype," +
-		"       g.deliverygoodscode," +
-		"       g.deliverygoodsname," +
-		"       wr.wrstandardid," +
-		"       wr.wrstandardname," +
-		"       wr.wrstandardcode," +
-		"       g2.goodscode," +
-		"       g2.goodsname," +
-		"       e.enumdicname," +
-		"       t.contracttype," +
-		"       t.pricedamount," +
-		"       case" +
-		"         when t.pricedqty > 0 then" +
-		"          (t.pricedamount) / t.pricedqty" +
-		"         else" +
-		"          0" +
-		"       end pricedAvg," +
-		"       t.ReckonRealQty," +
-		"       t.ReckonOtherAmount," +
-		"       t.ReckonAdjustAmount," +
-		"       t.Price," +
-		"       t.ReckonedAmount," +
-		"       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime," +
-		"       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime," +
-		"       t.pricedamount + t.ReckonAdjustAmount as LoanAmount," +
-		"       gb.dgfactoryitemvalue BRANDNAME" +
-		"  from ermcp_spotcontract t" +
-		"  left join deliverygoods g" +
-		"    on t.deliverygoodsid = g.deliverygoodsid" +
-		"  left join goods g2" +
-		"    on t.goodsid = g2.goodsid" +
-		"  left join wrstandard wr" +
-		"    on t.wrstandardid = wr.wrstandardid" +
-		"  left join DGFactoryItem gb" +
-		"    on t.spotgoodsbrandid = gb.dgfactoryitemid" +
-		"  left join enumdicitem e" +
-		"    on wr.unitid = e.enumitemname" +
-		"   and e.enumdiccode = 'goodsunit'" +
-		" where 1 = 1"
+	var sqlId utils.SQLVal = `
+
+select t.contractno,
+       to_char(t.SpotContractId) SpotContractId,
+       t.deliverygoodsid,
+       t.spotgoodsdesc,
+       t.goodsid,
+       t.pricemove,
+       t.userid,
+       t.BUYUSERID,
+       t.SELLUSERID,
+       t.qty,
+       t.qty - t.pricedqty unpricedqty,
+       t.pricedqty,
+       (case
+         when t.pricetype = 3 then
+          t.qty - t.RECKONREALQTY
+         else
+          t.pricedqty - nvl(t.ReckonRealQty, 0)
+       end) unsureqty,
+       t.reckonedamount PayAmount,
+       t.invoiceamount,
+       (t.pricedamount + t.RECKONADJUSTAMOUNT - t.invoiceamount) as daikaiAmount,
+       to_char(t.startdate, 'yyyy-mm-dd hh24:mi:ss') startdate,
+       to_char(t.enddate, 'yyyy-mm-dd hh24:mi:ss') enddate,
+       to_char(t.deliverystartdate, 'yyyy-mm-dd hh24:mi:ss') deliverystartdate,
+       to_char(t.deliveryenddate, 'yyyy-mm-dd hh24:mi:ss') deliveryenddate,
+       wr.convertfactor,
+       t.contractstatus,
+       t.pricetype,
+       t.producttype,
+       t.contracttype,
+       t.remark,
+       to_char(t.contractattachment) attachment,
+       t.margin,
+       t.contractmargin,
+       t.SPOTGOODSBRANDID,
+       t.tradeuserid,
+       t.saleuserid,
+       t.meruserid,
+       t.currencyid,
+       t.biztype,
+       g.deliverygoodscode,
+       g.deliverygoodsname,
+       wr.wrstandardid,
+       wr.wrstandardname,
+       wr.wrstandardcode,
+       g2.goodscode,
+       g2.goodsname,
+       e.enumdicname,
+       t.contracttype,
+       t.pricedamount,
+       case
+         when t.pricedqty > 0 then
+          (t.pricedamount) / t.pricedqty
+         else
+          0
+       end pricedAvg,
+       t.ReckonRealQty,
+       t.ReckonOtherAmount,
+       t.ReckonAdjustAmount,
+       t.Price,
+       t.ReckonedAmount,
+       to_char(t.audittime, 'yyyy-mm-dd hh24:mi:ss') audittime,
+       to_char(t.createtime, 'yyyy-mm-dd hh24:mi:ss') createtime,
+       t.pricedamount + t.ReckonAdjustAmount as LoanAmount,
+       gb.dgfactoryitemvalue BRANDNAME,
+       to_char(t.subjectid) subjectid,
+       b.subjectname
+  from ermcp_spotcontract t
+  left join ermcp_pa_areasubject b on t.subjectid=b.subjectid
+  left join deliverygoods g
+    on t.deliverygoodsid = g.deliverygoodsid
+  left join goods g2
+    on t.goodsid = g2.goodsid
+  left join wrstandard wr
+    on t.wrstandardid = wr.wrstandardid
+  left join DGFactoryItem gb
+    on t.spotgoodsbrandid = gb.dgfactoryitemid
+  left join enumdicitem e
+    on wr.unitid = e.enumitemname
+   and e.enumdiccode = 'goodsunit'
+ where 1 = 1
+`
 	sqlId.AndEx("t.userid", r.UserID, r.UserID > 0)
 	sqlId.AndEx("t.contracttype", r.Contracttype, r.Contracttype != 0)
 	sqlId.AndEx("t.SpotContractId", r.SpotContractId, len(r.SpotContractId) > 0)