Procházet zdrojové kódy

1.查询仓单委托单、议价单增加日期筛选
2.查询入库审核取品类单位名称
3.更新pc_menu.json

zou.yingbin před 4 roky
rodič
revize
3a5c428945
7 změnil soubory, kde provedl 506 přidání a 86 odebrání
  1. 114 2
      config/pc_menu.json
  2. 4 0
      controllers/wrTrade2/qryWrTrade.go
  3. 68 28
      docs/docs.go
  4. 68 28
      docs/swagger.json
  5. 48 20
      docs/swagger.yaml
  6. 5 5
      models/ermcp3.go
  7. 199 3
      models/wrTrade2.go

+ 114 - 2
config/pc_menu.json

@@ -1118,6 +1118,62 @@
 										"children": []
 									}
 								]
+							},
+							{
+								"code": "warehouse_receipt_trade_designate",
+								"title": "指定挂牌",
+								"sort": 1,
+								"type": 1,
+								"rulekey": "",
+								"isshow": true,
+								"url": "",
+								"remark": "",
+								"children": [
+									{
+										"code": "warehouse_receipt_trade_designate_post_buying",
+										"title": "挂牌求购",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									},
+									{
+										"code": "warehouse_receipt_trade_designate_delisting",
+										"title": "摘牌",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									},
+									{
+										"code": "warehouse_receipt_trade_designate_bargain_delisting",
+										"title": "议价摘牌",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									},
+									{
+										"code": "warehouse_receipt_trade_designate_detail",
+										"title": "详情",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									}
+								]
 							}
 						]
 					},
@@ -1368,6 +1424,62 @@
 										"children": []
 									}
 								]
+							},
+							{
+								"code": "warehouse_pre_sale_designate",
+								"title": "指定挂牌",
+								"sort": 1,
+								"type": 1,
+								"rulekey": "",
+								"isshow": true,
+								"url": "",
+								"remark": "",
+								"children": [
+									{
+										"code": "warehouse_pre_sale_designate_post_buying",
+										"title": "挂牌求购",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									},
+									{
+										"code": "warehouse_pre_sale_designate_delisting",
+										"title": "摘牌",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									},
+									{
+										"code": "warehouse_pre_sale_designate_bargain_delisting",
+										"title": "议价摘牌",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									},
+									{
+										"code": "warehouse_pre_sale_designate_detail",
+										"title": "详情",
+										"sort": 1,
+										"type": 2,
+										"rulekey": "",
+										"isshow": true,
+										"url": "",
+										"remark": "",
+										"children": []
+									}
+								]
 							}
 						]
 					},
@@ -1498,7 +1610,7 @@
 								"sort": 1,
 								"type": 1,
 								"rulekey": "search_spot_warrant_protocol_specified_record",
-								"isshow": true,
+								"isshow": false,
 								"url": "",
 								"remark": "",
 								"children": []
@@ -1554,7 +1666,7 @@
 								"sort": 1,
 								"type": 1,
 								"rulekey": "search_pre_sale_warehouse_receipt_protocol_specified_record",
-								"isshow": true,
+								"isshow": false,
 								"url": "",
 								"remark": "",
 								"children": []

+ 4 - 0
controllers/wrTrade2/qryWrTrade.go

@@ -122,6 +122,8 @@ func QueryWrPosition(c *gin.Context) {
 // @Param userid query int true "用户id"
 // @Param marketid query int false "仓单贸易市场id"
 // @Param haswr query int true "0:仓单预售 1:仓单贸易"
+// @Param begindate query string false "开始交易日(yyyymmdd)"
+// @Param enddate query string false "结束交易日(yyyymmdd)"
 // @Success 200 {array} models.WrOrderDetail
 // @Failure 500 {object} app.Response
 // @Router /WrTrade2/QueryWrOrderDetail [get]
@@ -594,6 +596,8 @@ func QueryPermancePlanTmp(c *gin.Context) {
 // @Param matchuserid query int false "挂牌方id(查对方议价时,填写此项)"
 // @Param wrtradeorderid query int false "关联委托单id"
 // @Param haswr query int true "0:仓单预售 1:仓单贸易"
+// @Param begindate query string false "开始交易日(yyyymmdd)"
+// @Param enddate query string false "结束交易日(yyyymmdd)"
 // @Success 200 {array} models.WRTradeBargainApply
 // @Failure 500 {object} app.Response
 // @Router /WrTrade2/QueryWrTradeBargainApply [get]

+ 68 - 28
docs/docs.go

@@ -13257,6 +13257,18 @@ var doc = `{
                         "name": "haswr",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -13727,6 +13739,18 @@ var doc = `{
                         "name": "haswr",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -32000,6 +32024,13 @@ var doc = `{
         "models.TBGoodsGroup": {
             "type": "object",
             "properties": {
+                "GDLST": {
+                    "description": "商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBGoods"
+                    }
+                },
                 "convertratio": {
                     "description": "折算系数",
                     "type": "number"
@@ -32016,13 +32047,6 @@ var doc = `{
                     "description": "交易所名称",
                     "type": "string"
                 },
-                "gdlst": {
-                    "description": "商品列表",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBGoods"
-                    }
-                },
                 "goodsgroupid": {
                     "description": "商品组ID(自增ID)",
                     "type": "integer"
@@ -32040,6 +32064,20 @@ var doc = `{
         "models.TBMiddleGoods": {
             "type": "object",
             "properties": {
+                "GPLST": {
+                    "description": "期货品种列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBGoodsGroup"
+                    }
+                },
+                "WDLST": {
+                    "description": "商品信息列表(现货品类)",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBWrstandard"
+                    }
+                },
                 "areauserid": {
                     "description": "机构用户ID",
                     "type": "integer"
@@ -32052,13 +32090,6 @@ var doc = `{
                     "description": "套保品种单位id",
                     "type": "integer"
                 },
-                "gplst": {
-                    "description": "期货品种列表",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBGoodsGroup"
-                    }
-                },
                 "middlegoodscode": {
                     "description": "套保品种代码",
                     "type": "string"
@@ -32078,13 +32109,6 @@ var doc = `{
                 "needhedgeratio": {
                     "description": "套保比率",
                     "type": "number"
-                },
-                "wdlst": {
-                    "description": "商品信息列表(现货品类)",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBWrstandard"
-                    }
                 }
             }
         },
@@ -33389,6 +33413,10 @@ var doc = `{
                     "description": "申请时间(议价时间)",
                     "type": "string"
                 },
+                "begindate": {
+                    "description": "开始交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "buyorsell": {
                     "description": "买卖(挂牌类型) - 0:买 1:卖",
                     "type": "integer"
@@ -33421,6 +33449,10 @@ var doc = `{
                     "description": "交收月",
                     "type": "string"
                 },
+                "enddate": {
+                    "description": "结束交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -34827,6 +34859,10 @@ var doc = `{
                     "description": "挂牌金额 = 委托数量 * 固定价或升贴水",
                     "type": "number"
                 },
+                "begindate": {
+                    "description": "开始交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "buyorsell": {
                     "description": "买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)",
                     "type": "integer"
@@ -34863,6 +34899,10 @@ var doc = `{
                     "description": "交收月",
                     "type": "string"
                 },
+                "enddate": {
+                    "description": "结束交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -36835,6 +36875,13 @@ var doc = `{
         "models.XHMiddleGoods": {
             "type": "object",
             "properties": {
+                "GPLST": {
+                    "description": "期货品种列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBGoodsGroup"
+                    }
+                },
                 "convertratio": {
                     "description": "拆算系数",
                     "type": "number"
@@ -36851,13 +36898,6 @@ var doc = `{
                     "description": "单位名称",
                     "type": "string"
                 },
-                "gplst": {
-                    "description": "期货品种列表",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBGoodsGroup"
-                    }
-                },
                 "middlegoodscode": {
                     "description": "套保品种代码",
                     "type": "string"

+ 68 - 28
docs/swagger.json

@@ -13241,6 +13241,18 @@
                         "name": "haswr",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -13711,6 +13723,18 @@
                         "name": "haswr",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "开始交易日(yyyymmdd)",
+                        "name": "begindate",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "结束交易日(yyyymmdd)",
+                        "name": "enddate",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -31984,6 +32008,13 @@
         "models.TBGoodsGroup": {
             "type": "object",
             "properties": {
+                "GDLST": {
+                    "description": "商品列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBGoods"
+                    }
+                },
                 "convertratio": {
                     "description": "折算系数",
                     "type": "number"
@@ -32000,13 +32031,6 @@
                     "description": "交易所名称",
                     "type": "string"
                 },
-                "gdlst": {
-                    "description": "商品列表",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBGoods"
-                    }
-                },
                 "goodsgroupid": {
                     "description": "商品组ID(自增ID)",
                     "type": "integer"
@@ -32024,6 +32048,20 @@
         "models.TBMiddleGoods": {
             "type": "object",
             "properties": {
+                "GPLST": {
+                    "description": "期货品种列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBGoodsGroup"
+                    }
+                },
+                "WDLST": {
+                    "description": "商品信息列表(现货品类)",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBWrstandard"
+                    }
+                },
                 "areauserid": {
                     "description": "机构用户ID",
                     "type": "integer"
@@ -32036,13 +32074,6 @@
                     "description": "套保品种单位id",
                     "type": "integer"
                 },
-                "gplst": {
-                    "description": "期货品种列表",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBGoodsGroup"
-                    }
-                },
                 "middlegoodscode": {
                     "description": "套保品种代码",
                     "type": "string"
@@ -32062,13 +32093,6 @@
                 "needhedgeratio": {
                     "description": "套保比率",
                     "type": "number"
-                },
-                "wdlst": {
-                    "description": "商品信息列表(现货品类)",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBWrstandard"
-                    }
                 }
             }
         },
@@ -33373,6 +33397,10 @@
                     "description": "申请时间(议价时间)",
                     "type": "string"
                 },
+                "begindate": {
+                    "description": "开始交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "buyorsell": {
                     "description": "买卖(挂牌类型) - 0:买 1:卖",
                     "type": "integer"
@@ -33405,6 +33433,10 @@
                     "description": "交收月",
                     "type": "string"
                 },
+                "enddate": {
+                    "description": "结束交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -34811,6 +34843,10 @@
                     "description": "挂牌金额 = 委托数量 * 固定价或升贴水",
                     "type": "number"
                 },
+                "begindate": {
+                    "description": "开始交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "buyorsell": {
                     "description": "买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)",
                     "type": "integer"
@@ -34847,6 +34883,10 @@
                     "description": "交收月",
                     "type": "string"
                 },
+                "enddate": {
+                    "description": "结束交易日(yyyymmdd)",
+                    "type": "string"
+                },
                 "enumdicname": {
                     "description": "单位名称",
                     "type": "string"
@@ -36819,6 +36859,13 @@
         "models.XHMiddleGoods": {
             "type": "object",
             "properties": {
+                "GPLST": {
+                    "description": "期货品种列表",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.TBGoodsGroup"
+                    }
+                },
                 "convertratio": {
                     "description": "拆算系数",
                     "type": "number"
@@ -36835,13 +36882,6 @@
                     "description": "单位名称",
                     "type": "string"
                 },
-                "gplst": {
-                    "description": "期货品种列表",
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/models.TBGoodsGroup"
-                    }
-                },
                 "middlegoodscode": {
                     "description": "套保品种代码",
                     "type": "string"

+ 48 - 20
docs/swagger.yaml

@@ -13337,6 +13337,11 @@ definitions:
     type: object
   models.TBGoodsGroup:
     properties:
+      GDLST:
+        description: 商品列表
+        items:
+          $ref: '#/definitions/models.TBGoods'
+        type: array
       convertratio:
         description: 折算系数
         type: number
@@ -13349,11 +13354,6 @@ definitions:
       exexchangename:
         description: 交易所名称
         type: string
-      gdlst:
-        description: 商品列表
-        items:
-          $ref: '#/definitions/models.TBGoods'
-        type: array
       goodsgroupid:
         description: 商品组ID(自增ID)
         type: integer
@@ -13366,6 +13366,16 @@ definitions:
     type: object
   models.TBMiddleGoods:
     properties:
+      GPLST:
+        description: 期货品种列表
+        items:
+          $ref: '#/definitions/models.TBGoodsGroup'
+        type: array
+      WDLST:
+        description: 商品信息列表(现货品类)
+        items:
+          $ref: '#/definitions/models.TBWrstandard'
+        type: array
       areauserid:
         description: 机构用户ID
         type: integer
@@ -13375,11 +13385,6 @@ definitions:
       goodsunitid:
         description: 套保品种单位id
         type: integer
-      gplst:
-        description: 期货品种列表
-        items:
-          $ref: '#/definitions/models.TBGoodsGroup'
-        type: array
       middlegoodscode:
         description: 套保品种代码
         type: string
@@ -13395,11 +13400,6 @@ definitions:
       needhedgeratio:
         description: 套保比率
         type: number
-      wdlst:
-        description: 商品信息列表(现货品类)
-        items:
-          $ref: '#/definitions/models.TBWrstandard'
-        type: array
     type: object
   models.TBWrstandard:
     properties:
@@ -14364,6 +14364,9 @@ definitions:
       applytime:
         description: 申请时间(议价时间)
         type: string
+      begindate:
+        description: 开始交易日(yyyymmdd)
+        type: string
       buyorsell:
         description: 买卖(挂牌类型) - 0:买 1:卖
         type: integer
@@ -14388,6 +14391,9 @@ definitions:
       deliverymonth:
         description: 交收月
         type: string
+      enddate:
+        description: 结束交易日(yyyymmdd)
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -15426,6 +15432,9 @@ definitions:
       amount:
         description: 挂牌金额 = 委托数量 * 固定价或升贴水
         type: number
+      begindate:
+        description: 开始交易日(yyyymmdd)
+        type: string
       buyorsell:
         description: 买卖 - 0:买 1:卖(挂牌类型 买为采购 卖为销售)
         type: integer
@@ -15453,6 +15462,9 @@ definitions:
       deliverymonth:
         description: 交收月
         type: string
+      enddate:
+        description: 结束交易日(yyyymmdd)
+        type: string
       enumdicname:
         description: 单位名称
         type: string
@@ -16911,6 +16923,11 @@ definitions:
     type: object
   models.XHMiddleGoods:
     properties:
+      GPLST:
+        description: 期货品种列表
+        items:
+          $ref: '#/definitions/models.TBGoodsGroup'
+        type: array
       convertratio:
         description: 拆算系数
         type: number
@@ -16923,11 +16940,6 @@ definitions:
       enumdicname:
         description: 单位名称
         type: string
-      gplst:
-        description: 期货品种列表
-        items:
-          $ref: '#/definitions/models.TBGoodsGroup'
-        type: array
       middlegoodscode:
         description: 套保品种代码
         type: string
@@ -27296,6 +27308,14 @@ paths:
         name: haswr
         required: true
         type: integer
+      - description: 开始交易日(yyyymmdd)
+        in: query
+        name: begindate
+        type: string
+      - description: 结束交易日(yyyymmdd)
+        in: query
+        name: enddate
+        type: string
       produces:
       - application/json
       responses:
@@ -27593,6 +27613,14 @@ paths:
         name: haswr
         required: true
         type: integer
+      - description: 开始交易日(yyyymmdd)
+        in: query
+        name: begindate
+        type: string
+      - description: 结束交易日(yyyymmdd)
+        in: query
+        name: enddate
+        type: string
       produces:
       - application/json
       responses:

+ 5 - 5
models/ermcp3.go

@@ -1513,7 +1513,7 @@ func (r *Ermcp3AreaStockApply) buildSql() string {
 		"       t.AUDITTRADEDATE," +
 		"       w.wrstandardname," +
 		"       w.wrstandardcode," +
-		"       g.goodsunitid unitid," +
+		"       w.unitid," +
 		"       gb.dgfactoryitemvalue brandname," +
 		"       h.warehousename," +
 		"       h.warehousecode," +
@@ -2594,7 +2594,7 @@ type XHMiddleGoods struct {
 	UNITID          int64   `json:"unitid"  xorm:"'UNITID'"`                      // 单位id
 	GOODSGROUPID    int64   `json:"-"  xorm:"'GOODSGROUPID'"`                     // 关联期货商品组id
 
-	GPLST []TBGoodsGroup // 期货品种列表
+	GPLST []TBGoodsGroup `json:"GPLST"` // 期货品种列表
 }
 
 func (r *XHMiddleGoods) calc() {
@@ -2669,8 +2669,8 @@ type TBMiddleGoods struct {
 	ENUMDICNAME        string  `json:"enumdicname"  xorm:"'ENUMDICNAME'"`                          // 单位名称
 	GOODSUNITID        int32   `json:"goodsunitid"  xorm:"'GOODSUNITID'"`                          // 套保品种单位id
 
-	GPLST []TBGoodsGroup // 期货品种列表
-	WDLST []TBWrstandard // 商品信息列表(现货品类)
+	GPLST []TBGoodsGroup `json:"GPLST"` // 期货品种列表
+	WDLST []TBWrstandard `json:"WDLST"` // 商品信息列表(现货品类)
 }
 
 func (r *TBMiddleGoods) calc() {
@@ -2755,7 +2755,7 @@ type TBGoodsGroup struct {
 	EXEXCHANGECODE   string    `json:"exexchangecode"  xorm:"'EXEXCHANGECODE'"` // 交易所代码
 	EXEXCHANGENAME   string    `json:"exexchangename"  xorm:"'EXEXCHANGENAME'"` // 交易所名称
 	ENUMDICNAME      string    `json:"enumdicname"  xorm:"'ENUMDICNAME'"`       // 单位名称
-	GDLST            []TBGoods // 商品列表
+	GDLST            []TBGoods `json:"GDLST"`                                   // 商品列表
 }
 
 func (r *TBGoodsGroup) calc() {

+ 199 - 3
models/wrTrade2.go

@@ -662,6 +662,9 @@ type WrOrderDetail struct {
 
 	FUTUSHOW string   `json:"futushow"` // 期货合约/升贴水
 	AMOUNT   SFLOAT64 `json:"amount"`   // 挂牌金额 = 委托数量 * 固定价或升贴水
+
+	BEGINDATE string `json:"begindate" form:"begindate"` // 开始交易日(yyyymmdd)
+	ENDDATE   string `json:"enddate" form:"enddate"`     // 结束交易日(yyyymmdd)
 }
 
 func (r *WrOrderDetail) calc() {
@@ -786,10 +789,113 @@ select t.HASWR,
 	return sqlId.String()
 }
 
+func (r *WrOrderDetail) buildSqlHis() 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'),
+mr as (
+select q.wrtradeorderid, wm_concat(u.userid||' '||u.accountname) matchusername from wrtrade_matchdetail q 
+left join useraccount u on q.matchuserid=u.userid
+group by q.wrtradeorderid
+)
+select t.HASWR,
+       to_char(t.validtime,'yyyy-mm-dd hh24:mi:ss') validtime,
+       to_char(t.WRTRADEORDERID) WRTRADEORDERID,
+       t.TRADEDATE,
+       t.DELIVERYMONTH,
+       t.WRTRADETYPE,
+       t.BUYORSELL,
+       t.MARKETID,
+       t.USERID,
+       t.ORDERQTY,
+       t.TRADEQTY,
+       t.CANCELQTY,
+       t.WRPRICETYPE,
+       t.FIXEDPRICE,
+       t.PRICEMOVE,
+       t.TRADEPRICE,
+       to_char(t.ORDERTIME, 'yyyy-mm-dd hh24:mi:ss') ORDERTIME,
+       t.WRTRADEORDERSTATUS,
+       t.marginvalue,
+       t.freezemargin,
+       t.delistminqty,
+       t.canbargain,
+       t.canpart,
+       t.allfriendsflag,
+       t.isspecified,
+       t.accountid,
+       t.performancetemplateid,
+       c.GOODSID,
+       c.GOODSCODE,
+       c.pricemove FUTUPRICEMOVE,
+       g.goodsname,
+       mr.matchusername,
+       ta.accountname taname,
+       to_char(b.ladingbillid) 	ladingbillid,
+       b.subnum,
+       k.*
+  from his_wrtrade_orderdetail t
+  left join wrtrade_goodsconfig c
+    on t.wrtradeorderid = c.wrtradeorderid
+  left join wrtrade_orderdetaillb b on t.wrtradeorderid=b.wrtradeorderid
+  left join goods g
+    on c.goodsid = g.goodsid
+  left join tmp k
+    on t.wrfactortypeid = k.wrfactortypeid
+  left join mr
+    on t.wrtradeorderid = mr.wrtradeorderid
+  left join taaccount ta
+    on t.accountid = ta.accountid
+ where t.WRTRADETYPE = 1 and t.WRTRADEORDERSTATUS not in(2)
+`
+	sqlId.And("t.USERID", r.USERID)
+	sqlId.And("t.haswr", r.HASWR)
+	sqlId.AndEx("t.marketid", r.MARKETID, r.MARKETID > 0)
+	// 格式 yyyymmdd
+	if len(r.BEGINDATE) > 0 {
+		sqlId.JoinFormat(" and t.TRADEDATE >= '%v'", r.BEGINDATE)
+	}
+
+	if len(r.ENDDATE) > 0 {
+		sqlId.JoinFormat(" and t.TRADEDATE <= '%v'", r.ENDDATE)
+	}
+	sqlId.Join(" order by t.ORDERTIME desc")
+	sqlId.Page(r.Page, r.PageSize)
+	return sqlId.String()
+}
+
 // GetDataByPage 获取仓单贸易委托单
 func (r *WrOrderDetail) GetDataByPage() (interface{}, error, int, int, int) {
+	var sqlId string
+	// 如果指定了开始日期或结束日期, 刚查历史
+	if r.BEGINDATE != "" || r.ENDDATE != "" {
+		sqlId = r.buildSqlHis()
+	} else {
+		sqlId = r.buildSql()
+	}
 	sData := make([]WrOrderDetail, 0)
-	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	err := db.GetEngine().SQL(sqlId).Find(&sData)
 	total := 0
 	for i := range sData {
 		sData[i].calc()
@@ -3422,7 +3528,9 @@ type WRTradeBargainApply struct {
 	TEMPLATENAME   string   `json:"templatename"  xorm:"'TEMPLATENAME'"`                         // 履约方式(履约模板名称)
 	Wr2FactorType  `xorm:"extends"`
 
-	HASWR int32 `json:"-" form:"haswr"` // 0-仓单预售 1-仓单贸易
+	HASWR     int32  `json:"-" form:"haswr"`             // 0-仓单预售 1-仓单贸易
+	BEGINDATE string `json:"begindate" form:"begindate"` // 开始交易日(yyyymmdd)
+	ENDDATE   string `json:"enddate" form:"enddate"`     // 结束交易日(yyyymmdd)
 }
 
 func (r *WRTradeBargainApply) calc() {
@@ -3510,10 +3618,98 @@ SELECT to_char(t.WRBARGAINID) WRBARGAINID,
 	return sqlId.String()
 }
 
+// buildSqlHis 查历史
+func (r *WRTradeBargainApply) buildSqlHis() 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,
+       t.MARKETID,
+       t.USERID,
+       t.ACCOUNTID,
+       t.BUYORSELL,
+       t.APPLYQTY,
+       t.APPLYPRICE,
+       t.APPLYSTATUS,
+       t.HANDLESTATUS,
+       to_char(t.APPLYTIME, 'yyyy-mm-dd hh24:mi:ss') APPLYTIME,
+       t.APPLYREMARK,
+       t.CONFIRMUSERID,
+       to_char(t.CONFIRMTIME, 'yyyy-mm-dd hh24:mi:ss') CONFIRMTIME,
+       t.CONFIRMREMARK,
+       t.REFPRICE,
+       t.RETCODE,
+       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 HIS_WRTRADE_BARGAINAPPLY t
+  LEFT JOIN USERACCOUNT u on t.userid=u.userid
+  LEFT JOIN USERACCOUNT u2 on t.matchuserid=u2.userid
+  LEFT JOIN HIS_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.userid", r.USERID, r.USERID > 0)
+	sqlId.AndEx("t.matchuserid", r.MATCHUSERID, r.MATCHUSERID > 0)
+	sqlId.AndEx("t.WRTRADEORDERID", r.WRTRADEORDERID, r.WRTRADEORDERID != "")
+	sqlId.And("o.haswr", r.HASWR)
+
+	// 格式 yyyymmdd
+	if len(r.BEGINDATE) > 0 {
+		sqlId.JoinFormat(" and t.TRADEDATE >= '%v'", r.BEGINDATE)
+	}
+
+	if len(r.ENDDATE) > 0 {
+		sqlId.JoinFormat(" and t.TRADEDATE <= '%v'", r.ENDDATE)
+	}
+
+	return sqlId.String()
+}
+
 // GetDataEx 获取议价单
 func (r *WRTradeBargainApply) GetDataEx() (interface{}, error) {
+	var sqlId string
+	// 如果指定了开始日期或结束日期, 刚查历史
+	if r.BEGINDATE != "" || r.ENDDATE != "" {
+		sqlId = r.buildSqlHis()
+	} else {
+		sqlId = r.buildSql()
+	}
+
 	sData := make([]WRTradeBargainApply, 0)
-	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	err := db.GetEngine().SQL(sqlId).Find(&sData)
 	for i := range sData {
 		sData[i].calc()
 	}