Browse Source

1.查交收明细增加单位、均价、仓库字段
2.查议价单接口修改

zou.yingbin 4 năm trước cách đây
mục cha
commit
54fdbc1f7b
5 tập tin đã thay đổi với 465 bổ sung85 xóa
  1. 3 1
      controllers/wrTrade2/qryWrTrade.go
  2. 117 7
      docs/docs.go
  3. 117 7
      docs/swagger.json
  4. 89 6
      docs/swagger.yaml
  5. 139 64
      models/wrTrade2.go

+ 3 - 1
controllers/wrTrade2/qryWrTrade.go

@@ -580,9 +580,11 @@ func QueryPermancePlanTmp(c *gin.Context) {
 
 // QueryWrTradeBargainApply
 // @Summary 查询议价单
+// @Description 1.页面 挂单/议价单, 只需传单号就行 2.页面 议价, 查的是作为摘牌方发起的议价单, 参数 userid=登录userid 3. 页面 议价/议价单, 和2类似, 但要指定单号 参数 userid, wrtradeorderid
 // @Produce json
 // @Security ApiKeyAuth
-// @Param wrtradeorderid query int true "关联委托单id"
+// @Param userid query int false "议价人id(摘牌方)"
+// @Param wrtradeorderid query int false "关联委托单id"
 // @Success 200 {array} models.WRTradeBargainApply
 // @Failure 500 {object} app.Response
 // @Router /WrTrade2/QueryWrTradeBargainApply [get]

+ 117 - 7
docs/docs.go

@@ -12482,6 +12482,7 @@ var doc = `{
                         "ApiKeyAuth": []
                     }
                 ],
+                "description": "1.页面 挂单/议价单, 只需传单号就行 2.页面 议价, 查的是作为摘牌方发起的议价单, 参数 userid=登录userid 3. 页面 议价/议价单, 和2类似, 但要指定单号 参数 userid, wrtradeorderid",
                 "produces": [
                     "application/json"
                 ],
@@ -12492,10 +12493,15 @@ var doc = `{
                 "parameters": [
                     {
                         "type": "integer",
+                        "description": "议价人id(摘牌方)",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
                         "description": "关联委托单id",
                         "name": "wrtradeorderid",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -30482,11 +30488,11 @@ var doc = `{
                     "type": "integer"
                 },
                 "applyprice": {
-                    "description": "申请价格",
+                    "description": "申请价格(议价价格)",
                     "type": "string"
                 },
                 "applyqty": {
-                    "description": "摘牌数量",
+                    "description": "摘牌数量(议价数量)",
                     "type": "number"
                 },
                 "applyremark": {
@@ -30494,15 +30500,15 @@ var doc = `{
                     "type": "string"
                 },
                 "applystatus": {
-                    "description": "申请状态 - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中",
+                    "description": "申请状态(议价状态) - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中",
                     "type": "integer"
                 },
                 "applytime": {
-                    "description": "申请时间",
+                    "description": "申请时间(议价时间)",
                     "type": "string"
                 },
                 "buyorsell": {
-                    "description": "买卖 - 0:买 1:卖",
+                    "description": "买卖(挂牌类型) - 0:买 1:卖",
                     "type": "integer"
                 },
                 "confirmremark": {
@@ -30517,14 +30523,66 @@ var doc = `{
                     "description": "确认人",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "deliverymonth": {
+                    "description": "交收月",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "fixedprice": {
+                    "description": "挂牌价格",
+                    "type": "number"
+                },
                 "handlestatus": {
                     "description": "处理状态",
                     "type": "integer"
                 },
+                "marginvalue": {
+                    "description": "履约保证金比例",
+                    "type": "number"
+                },
                 "marketid": {
                     "description": "市场ID",
                     "type": "integer"
                 },
+                "matchaccountid": {
+                    "description": "挂牌方资金账号",
+                    "type": "integer"
+                },
+                "matchuserid": {
+                    "description": "挂牌方用户id",
+                    "type": "integer"
+                },
+                "matchusername": {
+                    "description": "挂牌方用户名称(已脱敏)",
+                    "type": "string"
+                },
+                "minivalue": {
+                    "description": "现货商品最小变动值",
+                    "type": "integer"
+                },
+                "optioncompare": {
+                    "description": "选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较",
+                    "type": "string"
+                },
+                "orderqty": {
+                    "description": "挂牌数量",
+                    "type": "integer"
+                },
                 "refprice": {
                     "description": "参考价格",
                     "type": "string"
@@ -30533,6 +30591,10 @@ var doc = `{
                     "description": "委托返回代码",
                     "type": "integer"
                 },
+                "templatename": {
+                    "description": "履约方式(履约模板名称)",
+                    "type": "string"
+                },
                 "tradedate": {
                     "description": "交易日(yyyyMMdd)",
                     "type": "string"
@@ -30545,13 +30607,49 @@ var doc = `{
                     "description": "议价人名字(已脱敏)",
                     "type": "string"
                 },
+                "validtime": {
+                    "description": "有效期限",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
                 "wrbargainid": {
                     "description": "议价申请单ID(327+Unix秒时间戳(10位)+xxxxxx)",
                     "type": "string"
                 },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
                 "wrtradeorderid": {
                     "description": "关联委托单ID",
                     "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
                 }
             }
         },
@@ -30821,6 +30919,10 @@ var doc = `{
                     "description": "账号ID",
                     "type": "integer"
                 },
+                "averageprice": {
+                    "description": "交割均价 = 交割金额 / 交割数量",
+                    "type": "number"
+                },
                 "buyorsell": {
                     "description": "方向 -  0:买   1:卖",
                     "type": "integer"
@@ -30853,6 +30955,10 @@ var doc = `{
                     "description": "交收金额",
                     "type": "number"
                 },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
                 "matchaccountid": {
                     "description": "对手账号ID",
                     "type": "integer"
@@ -30901,6 +31007,10 @@ var doc = `{
                     "description": "用户名称",
                     "type": "string"
                 },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
                 "wrfactortypeid": {
                     "description": "仓单要素类型ID",
                     "type": "integer"

+ 117 - 7
docs/swagger.json

@@ -12466,6 +12466,7 @@
                         "ApiKeyAuth": []
                     }
                 ],
+                "description": "1.页面 挂单/议价单, 只需传单号就行 2.页面 议价, 查的是作为摘牌方发起的议价单, 参数 userid=登录userid 3. 页面 议价/议价单, 和2类似, 但要指定单号 参数 userid, wrtradeorderid",
                 "produces": [
                     "application/json"
                 ],
@@ -12476,10 +12477,15 @@
                 "parameters": [
                     {
                         "type": "integer",
+                        "description": "议价人id(摘牌方)",
+                        "name": "userid",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
                         "description": "关联委托单id",
                         "name": "wrtradeorderid",
-                        "in": "query",
-                        "required": true
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -30466,11 +30472,11 @@
                     "type": "integer"
                 },
                 "applyprice": {
-                    "description": "申请价格",
+                    "description": "申请价格(议价价格)",
                     "type": "string"
                 },
                 "applyqty": {
-                    "description": "摘牌数量",
+                    "description": "摘牌数量(议价数量)",
                     "type": "number"
                 },
                 "applyremark": {
@@ -30478,15 +30484,15 @@
                     "type": "string"
                 },
                 "applystatus": {
-                    "description": "申请状态 - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中",
+                    "description": "申请状态(议价状态) - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中",
                     "type": "integer"
                 },
                 "applytime": {
-                    "description": "申请时间",
+                    "description": "申请时间(议价时间)",
                     "type": "string"
                 },
                 "buyorsell": {
-                    "description": "买卖 - 0:买 1:卖",
+                    "description": "买卖(挂牌类型) - 0:买 1:卖",
                     "type": "integer"
                 },
                 "confirmremark": {
@@ -30501,14 +30507,66 @@
                     "description": "确认人",
                     "type": "integer"
                 },
+                "deliverygoodscode": {
+                    "description": "品种代码",
+                    "type": "string"
+                },
+                "deliverygoodsid": {
+                    "description": "品种ID",
+                    "type": "integer"
+                },
+                "deliverygoodsname": {
+                    "description": "品种名称",
+                    "type": "string"
+                },
+                "deliverymonth": {
+                    "description": "交收月",
+                    "type": "string"
+                },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
+                "fixedprice": {
+                    "description": "挂牌价格",
+                    "type": "number"
+                },
                 "handlestatus": {
                     "description": "处理状态",
                     "type": "integer"
                 },
+                "marginvalue": {
+                    "description": "履约保证金比例",
+                    "type": "number"
+                },
                 "marketid": {
                     "description": "市场ID",
                     "type": "integer"
                 },
+                "matchaccountid": {
+                    "description": "挂牌方资金账号",
+                    "type": "integer"
+                },
+                "matchuserid": {
+                    "description": "挂牌方用户id",
+                    "type": "integer"
+                },
+                "matchusername": {
+                    "description": "挂牌方用户名称(已脱敏)",
+                    "type": "string"
+                },
+                "minivalue": {
+                    "description": "现货商品最小变动值",
+                    "type": "integer"
+                },
+                "optioncompare": {
+                    "description": "选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较",
+                    "type": "string"
+                },
+                "orderqty": {
+                    "description": "挂牌数量",
+                    "type": "integer"
+                },
                 "refprice": {
                     "description": "参考价格",
                     "type": "string"
@@ -30517,6 +30575,10 @@
                     "description": "委托返回代码",
                     "type": "integer"
                 },
+                "templatename": {
+                    "description": "履约方式(履约模板名称)",
+                    "type": "string"
+                },
                 "tradedate": {
                     "description": "交易日(yyyyMMdd)",
                     "type": "string"
@@ -30529,13 +30591,49 @@
                     "description": "议价人名字(已脱敏)",
                     "type": "string"
                 },
+                "validtime": {
+                    "description": "有效期限",
+                    "type": "string"
+                },
+                "warehouseid": {
+                    "description": "仓库ID",
+                    "type": "integer"
+                },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
                 "wrbargainid": {
                     "description": "议价申请单ID(327+Unix秒时间戳(10位)+xxxxxx)",
                     "type": "string"
                 },
+                "wrfactortypeid": {
+                    "description": "仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)",
+                    "type": "string"
+                },
+                "wrfactortypename": {
+                    "description": "仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)",
+                    "type": "string"
+                },
+                "wrstandardcode": {
+                    "description": "现货商品代码",
+                    "type": "string"
+                },
+                "wrstandardid": {
+                    "description": "现货商品ID",
+                    "type": "integer"
+                },
+                "wrstandardname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
                 "wrtradeorderid": {
                     "description": "关联委托单ID",
                     "type": "string"
+                },
+                "wrtypename": {
+                    "description": "商品",
+                    "type": "string"
                 }
             }
         },
@@ -30805,6 +30903,10 @@
                     "description": "账号ID",
                     "type": "integer"
                 },
+                "averageprice": {
+                    "description": "交割均价 = 交割金额 / 交割数量",
+                    "type": "number"
+                },
                 "buyorsell": {
                     "description": "方向 -  0:买   1:卖",
                     "type": "integer"
@@ -30837,6 +30939,10 @@
                     "description": "交收金额",
                     "type": "number"
                 },
+                "enumdicname": {
+                    "description": "单位名称",
+                    "type": "string"
+                },
                 "matchaccountid": {
                     "description": "对手账号ID",
                     "type": "integer"
@@ -30885,6 +30991,10 @@
                     "description": "用户名称",
                     "type": "string"
                 },
+                "warehousename": {
+                    "description": "仓库名称",
+                    "type": "string"
+                },
                 "wrfactortypeid": {
                     "description": "仓单要素类型ID",
                     "type": "integer"

+ 89 - 6
docs/swagger.yaml

@@ -13259,22 +13259,22 @@ definitions:
         description: 摘牌资金账号
         type: integer
       applyprice:
-        description: 申请价格
+        description: 申请价格(议价价格)
         type: string
       applyqty:
-        description: 摘牌数量
+        description: 摘牌数量(议价数量)
         type: number
       applyremark:
         description: 申请备注
         type: string
       applystatus:
-        description: 申请状态 - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中
+        description: 申请状态(议价状态) - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中
         type: integer
       applytime:
-        description: 申请时间
+        description: 申请时间(议价时间)
         type: string
       buyorsell:
-        description: 买卖 - 0:买 1:卖
+        description: 买卖(挂牌类型) - 0:买 1:卖
         type: integer
       confirmremark:
         description: 确认备注
@@ -13285,18 +13285,60 @@ definitions:
       confirmuserid:
         description: 确认人
         type: integer
+      deliverygoodscode:
+        description: 品种代码
+        type: string
+      deliverygoodsid:
+        description: 品种ID
+        type: integer
+      deliverygoodsname:
+        description: 品种名称
+        type: string
+      deliverymonth:
+        description: 交收月
+        type: string
+      enumdicname:
+        description: 单位名称
+        type: string
+      fixedprice:
+        description: 挂牌价格
+        type: number
       handlestatus:
         description: 处理状态
         type: integer
+      marginvalue:
+        description: 履约保证金比例
+        type: number
       marketid:
         description: 市场ID
         type: integer
+      matchaccountid:
+        description: 挂牌方资金账号
+        type: integer
+      matchuserid:
+        description: 挂牌方用户id
+        type: integer
+      matchusername:
+        description: 挂牌方用户名称(已脱敏)
+        type: string
+      minivalue:
+        description: 现货商品最小变动值
+        type: integer
+      optioncompare:
+        description: 选择项比较串【{选择项ID}+{冒号}+选择项值 } ,逗号分隔,头尾加逗号】-- 所有选择项拼接,用于比较
+        type: string
+      orderqty:
+        description: 挂牌数量
+        type: integer
       refprice:
         description: 参考价格
         type: string
       retcode:
         description: 委托返回代码
         type: integer
+      templatename:
+        description: 履约方式(履约模板名称)
+        type: string
       tradedate:
         description: 交易日(yyyyMMdd)
         type: string
@@ -13306,12 +13348,39 @@ definitions:
       username:
         description: 议价人名字(已脱敏)
         type: string
+      validtime:
+        description: 有效期限
+        type: string
+      warehouseid:
+        description: 仓库ID
+        type: integer
+      warehousename:
+        description: 仓库名称
+        type: string
       wrbargainid:
         description: 议价申请单ID(327+Unix秒时间戳(10位)+xxxxxx)
         type: string
+      wrfactortypeid:
+        description: 仓单要素类型ID(212+Unix秒时间戳(10位)+xxxxxx)
+        type: string
+      wrfactortypename:
+        description: 仓单要素类型名称(选择项要素的名称合并显示,逗号分隔)
+        type: string
+      wrstandardcode:
+        description: 现货商品代码
+        type: string
+      wrstandardid:
+        description: 现货商品ID
+        type: integer
+      wrstandardname:
+        description: 商品名称
+        type: string
       wrtradeorderid:
         description: 关联委托单ID
         type: string
+      wrtypename:
+        description: 商品
+        type: string
     type: object
   models.Warehouseinfo:
     properties:
@@ -13508,6 +13577,9 @@ definitions:
       accountid:
         description: 账号ID
         type: integer
+      averageprice:
+        description: 交割均价 = 交割金额 / 交割数量
+        type: number
       buyorsell:
         description: 方向 -  0:买   1:卖
         type: integer
@@ -13532,6 +13604,9 @@ definitions:
       deliverytotalamount:
         description: 交收金额
         type: number
+      enumdicname:
+        description: 单位名称
+        type: string
       matchaccountid:
         description: 对手账号ID
         type: integer
@@ -13568,6 +13643,9 @@ definitions:
       username:
         description: 用户名称
         type: string
+      warehousename:
+        description: 仓库名称
+        type: string
       wrfactortypeid:
         description: 仓单要素类型ID
         type: integer
@@ -25312,11 +25390,16 @@ paths:
       - 仓单贸易v2
   /WrTrade2/QueryWrTradeBargainApply:
     get:
+      description: 1.页面 挂单/议价单, 只需传单号就行 2.页面 议价, 查的是作为摘牌方发起的议价单, 参数 userid=登录userid
+        3. 页面 议价/议价单, 和2类似, 但要指定单号 参数 userid, wrtradeorderid
       parameters:
+      - description: 议价人id(摘牌方)
+        in: query
+        name: userid
+        type: integer
       - description: 关联委托单id
         in: query
         name: wrtradeorderid
-        required: true
         type: integer
       produces:
       - application/json

+ 139 - 64
models/wrTrade2.go

@@ -2510,8 +2510,11 @@ type WrDeliveryDetail struct {
 	MATCHUSERNAME       string  `json:"matchusername"  xorm:"'MATCHUSERNAME'"`           // 对手方名称(仓单持有人)
 	TRADEDATE           string  `json:"tradedate"  xorm:"'TRADEDATE'"`                   // 交易日(yyyymmdd)
 	WRTYPENAME          string  `json:"wrtypename" xorm:"'WRTYPENAME'"`                  // 商品
+	WAREHOUSENAME       string  `json:"warehousename"  xorm:"'WAREHOUSENAME'"`           // 仓库名称
+	ENUMDICNAME         string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`               // 单位名称
 
 	XGOODSAMOUNT SFLOAT64 `json:"xgoodsamount"` // 合约金额 = 货款金额(DELIVERYAMOUNT) - 点价货款(P1GOODSREMAINAMOUNT)
+	AVERAGEPRICE SFLOAT64 `json:"averageprice"` // 交割均价 = 交割金额 / 交割数量
 }
 
 func (r *WrDeliveryDetail) calc() {
@@ -2519,51 +2522,64 @@ func (r *WrDeliveryDetail) calc() {
 	if r.WRTYPENAME != "" {
 		r.WRTYPENAME = strings.ReplaceAll(r.WRTYPENAME, ",", "-")
 	}
+	r.XGOODSAMOUNT.Set(r.DELIVERYAMOUNT - r.P1GOODSREMAINAMOUNT)
+	if r.DELIVERYQTY > 1e-8 {
+		r.AVERAGEPRICE.Set(r.DELIVERYTOTALAMOUNT / r.DELIVERYQTY)
+		r.AVERAGEPRICE.Round(3)
+	}
 }
 
 func (r *WrDeliveryDetail) buildSql() string {
-	var sqlId utils.SQLVal = "select t.xgoodsid," +
-		"       t.buyorsell," +
-		"       t.deliveryqty," +
-		"       t.xdeliverycloseqty," +
-		"       t.pdeliverycloseqty," +
-		"       t.deliveryamount," +
-		"       t.pdeliveryprice," +
-		"       t.p1goodsremainamount," +
-		"       t.deliverypricemove," +
-		"       t.deliverytotalamount," +
-		"       to_char(t.deliverytime, 'yyyy-mm hh24:mi:ss') deliverytime," +
-		"       t.deliverystatus," +
-		"       t.accountid," +
-		"       t.matchaccountid," +
-		"       t.tradedate," +
-		"       t.wrfactortypeid," +
-		"       g.goodscode xgoodscode," +
-		"       g.goodsname xgoodsname," +
-		"       t.pgoodsid," +
-		"       g2.goodscode pgoodscode," +
-		"       g2.goodsname pgoodsname," +
-		"       ta.accountname taaccountname," +
-		"       u.userid," +
-		"       u.accountname username," +
-		"       u2.accountname matchusername," +
-		"       wd.wrstandardname || w.wrfactortypename2 as WRTYPENAME" +
-		"  from deliverydetail t" +
-		"  left join goods g" +
-		"    on t.xgoodsid = g.goodsid" +
-		"  left join goods g2" +
-		"    on t.pgoodsid = g2.goodsid" +
-		"  left join taaccount ta" +
-		"    on t.accountid = ta.accountid" +
-		"  left join useraccount u" +
-		"    on ta.userid = u.userid" +
-		"  left join taaccount ta2" +
-		"    on t.accountid = ta2.accountid" +
-		"  left join useraccount u2" +
-		"    on ta2.userid = u2.userid" +
-		"  left join wrfactortype w on t.wrfactortypeid=w.wrfactortypeid" +
-		"  left join wrstandard wd on w.wrstandardid=wd.wrstandardid" +
-		" where 1 = 1"
+	var sqlId utils.SQLVal = `
+select t.xgoodsid,
+       t.buyorsell,
+       t.deliveryqty,
+       t.xdeliverycloseqty,
+       t.pdeliverycloseqty,
+       t.deliveryamount,
+       t.pdeliveryprice,
+       t.p1goodsremainamount,
+       t.deliverypricemove,
+       t.deliverytotalamount,
+       to_char(t.deliverytime, 'yyyy-mm hh24:mi:ss') deliverytime,
+       t.deliverystatus,
+       t.accountid,
+       t.matchaccountid,
+       t.tradedate,
+       t.wrfactortypeid,
+       g.goodscode xgoodscode,
+       g.goodsname xgoodsname,
+       t.pgoodsid,
+       g2.goodscode pgoodscode,
+       g2.goodsname pgoodsname,
+       ta.accountname taaccountname,
+       u.userid,
+       u.accountname username,
+       u2.accountname matchusername,
+       wd.wrstandardname || w.wrfactortypename2 as WRYPENAME,
+       h.warehousename,
+       e.enumdicname
+  from deliverydetail t
+  left join goods g
+    on t.xgoodsid = g.goodsid
+  left join goods g2
+    on t.pgoodsid = g2.goodsid
+  left join taaccount ta
+    on t.accountid = ta.accountid
+  left join useraccount u
+    on ta.userid = u.userid
+  left join taaccount ta2
+    on t.accountid = ta2.accountid
+  left join useraccount u2
+    on ta2.userid = u2.userid
+  left join wrfactortype w
+    on t.wrfactortypeid = w.wrfactortypeid
+  left join wrstandard wd
+    on w.wrstandardid = wd.wrstandardid
+  left join warehouseinfo h on w.warehouseid=h.autoid
+  left join enumdicitem e on wd.unitid=e.enumitemname and e.enumdiccode='goodsunit'
+ where 1 = 1
+`
 	sqlId.AndEx("u.userid", r.USERID, r.USERID > 0)
 	sqlId.AndEx("t.accountid", r.ACCOUNTID, r.ACCOUNTID > 0)
 	return sqlId.String()
@@ -3218,33 +3234,67 @@ func (r *WrPerformanceTemplateEx) GetDataEx() (interface{}, error) {
 
 // WRTradeBargainApply 议价单
 type WRTradeBargainApply struct {
-	WRBARGAINID    string  `json:"wrbargainid"  xorm:"WRBARGAINID" form:"wrbargainid"`          // 议价申请单ID(327+Unix秒时间戳(10位)+xxxxxx)
-	WRTRADEORDERID string  `json:"wrtradeorderid"  xorm:"WRTRADEORDERID" form:"wrtradeorderid"` // 关联委托单ID
-	TRADEDATE      string  `json:"tradedate"  xorm:"TRADEDATE" form:"tradedate"`                // 交易日(yyyyMMdd)
-	MARKETID       int64   `json:"marketid"  xorm:"MARKETID" form:"marketid"`                   // 市场ID
-	USERID         int64   `json:"userid"  xorm:"USERID" form:"userid"`                         // 摘牌人用户ID(议价人ID)
-	ACCOUNTID      int64   `json:"accountid"  xorm:"ACCOUNTID" form:"accountid"`                // 摘牌资金账号
-	BUYORSELL      int32   `json:"buyorsell"  xorm:"BUYORSELL"`                                 // 买卖 - 0:买 1:卖
-	APPLYQTY       float64 `json:"applyqty"  xorm:"APPLYQTY"`                                   // 摘牌数量
-	APPLYPRICE     string  `json:"applyprice"  xorm:"APPLYPRICE"`                               // 申请价格
-	APPLYSTATUS    int32   `json:"applystatus"  xorm:"APPLYSTATUS"`                             // 申请状态 - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中
-	HANDLESTATUS   int32   `json:"handlestatus"  xorm:"HANDLESTATUS"`                           // 处理状态
-	APPLYTIME      string  `json:"applytime"  xorm:"APPLYTIME"`                                 // 申请时间
-	APPLYREMARK    string  `json:"applyremark"  xorm:"APPLYREMARK"`                             // 申请备注
-	CONFIRMUSERID  int64   `json:"confirmuserid"  xorm:"CONFIRMUSERID" form:"confirmuserid"`    // 确认人
-	CONFIRMTIME    string  `json:"confirmtime"  xorm:"CONFIRMTIME"`                             // 确认时间
-	CONFIRMREMARK  string  `json:"confirmremark"  xorm:"CONFIRMREMARK"`                         // 确认备注
-	REFPRICE       string  `json:"refprice"  xorm:"REFPRICE"`                                   // 参考价格
-	RETCODE        int32   `json:"retcode"  xorm:"RETCODE"`                                     // 委托返回代码
-	USERNAME       string  `json:"username"  xorm:"'USERNAME'"`                                 // 议价人名字(已脱敏)
+	WRBARGAINID    string   `json:"wrbargainid"  xorm:"WRBARGAINID" form:"wrbargainid"`          // 议价申请单ID(327+Unix秒时间戳(10位)+xxxxxx)
+	WRTRADEORDERID string   `json:"wrtradeorderid"  xorm:"WRTRADEORDERID" form:"wrtradeorderid"` // 关联委托单ID
+	TRADEDATE      string   `json:"tradedate"  xorm:"TRADEDATE" form:"tradedate"`                // 交易日(yyyyMMdd)
+	MARKETID       int64    `json:"marketid"  xorm:"MARKETID" form:"marketid"`                   // 市场ID
+	USERID         int64    `json:"userid"  xorm:"USERID" form:"userid"`                         // 摘牌人用户ID(议价人ID)
+	ACCOUNTID      int64    `json:"accountid"  xorm:"ACCOUNTID" form:"accountid"`                // 摘牌资金账号
+	BUYORSELL      int32    `json:"buyorsell"  xorm:"BUYORSELL"`                                 // 买卖(挂牌类型) - 0:买 1:卖
+	APPLYQTY       float64  `json:"applyqty"  xorm:"APPLYQTY"`                                   // 摘牌数量(议价数量)
+	APPLYPRICE     string   `json:"applyprice"  xorm:"APPLYPRICE"`                               // 申请价格(议价价格)
+	APPLYSTATUS    int32    `json:"applystatus"  xorm:"APPLYSTATUS"`                             // 申请状态(议价状态) - 1:待确认 2:已确认 3:已拒绝 4:已撤销 5:系统撤销 6:处理失败 7:确认中
+	HANDLESTATUS   int32    `json:"handlestatus"  xorm:"HANDLESTATUS"`                           // 处理状态
+	APPLYTIME      string   `json:"applytime"  xorm:"APPLYTIME"`                                 // 申请时间(议价时间)
+	APPLYREMARK    string   `json:"applyremark"  xorm:"APPLYREMARK"`                             // 申请备注
+	CONFIRMUSERID  int64    `json:"confirmuserid"  xorm:"CONFIRMUSERID" form:"confirmuserid"`    // 确认人
+	CONFIRMTIME    string   `json:"confirmtime"  xorm:"CONFIRMTIME"`                             // 确认时间
+	CONFIRMREMARK  string   `json:"confirmremark"  xorm:"CONFIRMREMARK"`                         // 确认备注
+	REFPRICE       string   `json:"refprice"  xorm:"REFPRICE"`                                   // 参考价格
+	RETCODE        int32    `json:"retcode"  xorm:"RETCODE"`                                     // 委托返回代码
+	USERNAME       string   `json:"username"  xorm:"'USERNAME'"`                                 // 议价人名字(已脱敏)
+	MATCHUSERID    int64    `json:"matchuserid"  xorm:"'MATCHUSERID'" form:"matchuserid"`        // 挂牌方用户id
+	MATCHACCOUNTID int64    `json:"matchaccountid"  xorm:"'MATCHACCOUNTID'"`                     // 挂牌方资金账号
+	MATCHUSERNAME  string   `json:"matchusername"  xorm:"'MATCHUSERNAME'"`                       // 挂牌方用户名称(已脱敏)
+	ORDERQTY       int64    `json:"orderqty"  xorm:"'ORDERQTY'"`                                 // 挂牌数量
+	FIXEDPRICE     SFLOAT64 `json:"fixedprice"  xorm:"'FIXEDPRICE'"`                             // 挂牌价格
+	DELIVERYMONTH  string   `json:"deliverymonth"  xorm:"'DELIVERYMONTH'"`                       // 交收月
+	MARGINVALUE    SFLOAT64 `json:"marginvalue"  xorm:"'MARGINVALUE'"`                           // 履约保证金比例
+	VALIDTIME      string   `json:"validtime"  xorm:"'VALIDTIME'"`                               // 有效期限
+	TEMPLATENAME   string   `json:"templatename"  xorm:"'TEMPLATENAME'"`                         // 履约方式(履约模板名称)
+	Wr2FactorType  `xorm:"extends"`
 }
 
 func (r *WRTradeBargainApply) calc() {
 	r.USERNAME = EncryptByStar(r.USERNAME)
+	r.MATCHUSERNAME = EncryptByStar(r.MATCHUSERNAME)
 }
 
 func (r *WRTradeBargainApply) buildSql() string {
 	var sqlId utils.SQLVal = `
+with tmp as
+ (select to_char(t.wrfactortypeid) wrfactortypeid,
+         t.wrfactortypename2 wrfactortypename,
+         t.wrstandardid,
+         t.deliverygoodsid,
+         g.deliverygoodscode,
+         g.deliverygoodsname,
+         w.wrstandardcode,
+         w.wrstandardname,
+         h.warehousecode,
+         h.warehousename,
+         e.enumdicname,
+         w.wrstandardname || t.wrfactortypename2 as wrtypename
+    from wrfactortype t
+    left join deliverygoods g
+      on t.deliverygoodsid = g.deliverygoodsid
+    left join wrstandard w
+      on t.wrstandardid = w.wrstandardid
+    left join warehouseinfo h
+      on t.warehouseid = h.autoid
+    left join enumdicitem e
+      on w.unitid = e.enumitemname
+     and e.enumdiccode = 'goodsunit')
 SELECT to_char(t.WRBARGAINID) WRBARGAINID,
        to_char(t.WRTRADEORDERID) WRTRADEORDERID,
        t.TRADEDATE,
@@ -3263,12 +3313,37 @@ SELECT to_char(t.WRBARGAINID) WRBARGAINID,
        t.CONFIRMREMARK,
        t.REFPRICE,
        t.RETCODE,
-       u.accountname USERNAME
+       t.matchuserid,
+       t.matchaccountid,
+       u.accountname USERNAME,
+       u2.accountname matchusername,
+       o.orderqty,
+       o.fixedprice,
+       o.deliverymonth,
+       o.marginvalue,
+       to_char(o.validtime, 'yyyy-mm-dd hh24:mi:ss') validtime,
+       p.templatename,
+       tmp.*
   FROM WRTRADE_BARGAINAPPLY t
   LEFT JOIN USERACCOUNT u on t.userid=u.userid
- WHERE 1 = 1
+  LEFT JOIN USERACCOUNT u2 on t.matchuserid=u2.userid
+  LEFT JOIN WRTRADE_ORDERDETAIL o on t.wrtradeorderid=o.wrtradeorderid
+  LEFT JOIN tmp on o.wrfactortypeid=tmp.wrfactortypeid
+  LEFT JOIN PERFORMANCEPLANTEMPLATE p on o.performancetemplateid=p.autoid
+ WHERE 1 = 1 
 `
-	sqlId.AndEx("t.WRTRADEORDERID", r.WRTRADEORDERID, r.WRTRADEORDERID != "")
+	if r.USERID > 0 {
+		if r.WRTRADEORDERID != "" {
+			sqlId.And("t.userid", r.USERID)
+			sqlId.AndInterEx("t.wrtradeorderid", r.WRTRADEORDERID, true)
+		} else {
+			sqlId.And("t.userid", r.USERID)
+			sqlId.Join(" and t.APPLYTIME = (select max(APPLYTIME) from WRTRADE_BARGAINAPPLY where wrtradeorderid=t.wrtradeorderid)")
+		}
+	} else {
+		sqlId.AndEx("t.WRTRADEORDERID", r.WRTRADEORDERID, r.WRTRADEORDERID != "")
+	}
+
 	return sqlId.String()
 }