Browse Source

修改BUG等;部分商城功能

zhou.xiaoning 4 years ago
parent
commit
85bb61ab48
11 changed files with 852 additions and 75 deletions
  1. 50 43
      config/config.xml
  2. 78 0
      controllers/hsby/hsby.go
  3. 4 2
      controllers/search/goodsSearch.go
  4. 1 16
      controllers/wrtrade/wrTrade.go
  5. 182 0
      docs/docs.go
  6. 182 0
      docs/swagger.json
  7. 133 0
      docs/swagger.yaml
  8. 10 7
      models/goods.go
  9. 184 7
      models/hsby.go
  10. 26 0
      models/wr.go
  11. 2 0
      routers/router.go

+ 50 - 43
config/config.xml

@@ -1,45 +1,52 @@
 <?xml version="1.0" encoding="utf-8"?>
+
 <Configuration xmlns:http="http://www.w3.org/2001/XMLSchema-instance">
-  <WebSetting>
-    <ListenAddress value="0.0.0.0:8280"/>
-    <DebugMode value="1"/>
-  </WebSetting>
-  <LogSetting>
-    <LogPath value="log"/>
-    <LogLevel value="5"/>
-  </LogSetting>
-  <DbSetting>
-    <DbDriver value="oci8"/>
-    <DbAddress value="192.168.21.24"/>
-    <DbName value="orcl"/>
-    <DbPort value="1521"/>
-    <DbUser value="HSBY"/>
-    <DbPwd value="muchinfo"/>
-  </DbSetting>
-  <RedisSetting>
-    <Address value="192.168.21.71"/>
-    <Port value="6379"/>
-    <Timeout value="3"/>
-    <ConnNum value="1"/>
-    <DbNum value="0"/>
-    <Pwd value=""/>
-  </RedisSetting>
-  <MqSetting>
-    <Url value="amqp://mtp:muchinfo@192.168.21.71:5672/mtp"/>
-    <Exchange value="entry"/>
-  </MqSetting>
-  <MongoDBSetting>
-    <HostName value="192.168.21.71"/>
-    <Port value="27017"/>
-    <DBName value="HistoryQuote"/>
-    <Username value="mtp"/>
-    <Password value="MuchInfo"/>
-  </MongoDBSetting>
-  <MySQLSetting>
-    <Host value="192.168.21.71"/>
-    <Port value="3306"/>
-    <DBName value="historyquote"/>
-    <Username value="mtp"/>
-    <Password value="Much@info^123"/>
-  </MySQLSetting>
-</Configuration>
+    <WebSetting>
+        <ListenAddress value="0.0.0.0:8080"/>
+        <DebugMode value="1"/>
+    </WebSetting>
+
+    <LogSetting>
+        <LogPath value="log"/>
+        <LogLevel value="5"/>
+    </LogSetting>
+
+    <DbSetting>
+        <DbDriver  value="oci8"/>
+        <DbAddress value="192.168.31.117"/>
+        <DbName    value="orcl"/>
+        <DbPort    value="1521"/>
+        <DbUser    value="mtp2_test82"/>
+        <DbPwd     value="muchinfo"/>
+    </DbSetting>
+
+    <RedisSetting>
+        <Address   value="192.168.30.182"/>
+        <Port      value="5007"/>
+        <Timeout   value="3"/>
+        <ConnNum   value="1"/>
+        <DbNum     value="0"/>
+        <Pwd       value=""/>
+    </RedisSetting>
+
+    <MqSetting>
+        <Url       value="amqp://guest:guest@192.168.30.182:5020/test"/>
+        <Exchange  value="entry"/>
+    </MqSetting>
+
+    <MongoDBSetting>
+        <HostName   value="192.168.30.182"/>
+        <Port       value="5025"/>
+        <DBName     value="HistoryQuote"/>
+        <Username   value="quote_test01"/>
+        <Password   value="123456"/>
+    </MongoDBSetting>
+
+    <MySQLSetting>
+        <Host       value="192.168.30.113"/>
+        <Port       value="3306"/>
+        <DBName     value="historyquote_test82"/>
+        <Username   value="quote_test82"/>
+        <Password   value="123456"/>
+    </MySQLSetting>
+</Configuration>

+ 78 - 0
controllers/hsby/hsby.go

@@ -1039,3 +1039,81 @@ func QueryHsbyMarkets(c *gin.Context) {
 	logger.GetLogger().Debugln("QueryHsbyMarkets successed: %v", markets)
 	appG.Response(http.StatusOK, e.SUCCESS, markets)
 }
+
+// QueryHsbyMarketGoodsesReq 查询特卖商品列表(三级商城)列表请求参数
+type QueryHsbyMarketGoodsesReq struct {
+	app.PageInfo
+	MarketIDs  string `form:"marketIDs" binding:"required"`
+	AccountID  int    `form:"accountID"`
+	CategoryID int    `form:"categoryID"`
+}
+
+// QueryHsbyMarketGoodses 查询特卖商品列表(三级商城)
+// @Summary 查询特卖商品列表(三级商城)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param page query int false "页码"
+// @Param pagesize query int false "每页条数"
+// @Param marketIDs query string true "市场ID列表,格式:1,2,3"
+// @Param accountID query int false "资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。"
+// @Param categoryID query int false "类别ID"
+// @Success 200 {object} models.HsbyMarketGoods
+// @Failure 500 {object} app.Response
+// @Router /HSBY/QueryHsbyMarketGoodses [get]
+// @Tags 定制【海商报业】
+func QueryHsbyMarketGoodses(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryHsbyMarketGoodsesReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("QueryHsbyMarketGoodses failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 获取数据
+	goodses, err := models.GetHsbyMarketGoodses(req.MarketIDs, req.AccountID, req.CategoryID)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryHsbyMarketGoodses failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 排序
+	sort.Slice(goodses, func(i int, j int) bool {
+		return goodses[i].Hotindex > goodses[j].Hotindex
+	})
+
+	// 分页
+	total := len(goodses)
+	if req.PageSize > 0 {
+		rstByPage := make([]models.HsbyMarketGoods, 0)
+		// 开始上标
+		start := req.Page * req.PageSize
+		// 结束下标
+		end := start + req.PageSize
+
+		if start <= len(goodses) {
+			// 判断结束下标是否越界
+			if end > len(goodses) {
+				end = len(goodses)
+			}
+			rstByPage = goodses[start:end]
+		} else {
+			rstByPage = goodses[0:0]
+		}
+
+		goodses = rstByPage
+	}
+
+	// 查询成功返回
+	if req.PageSize > 0 {
+		logger.GetLogger().Debugln("QueryHsbyMarketGoodses successed: %v", goodses)
+		appG.ResponseByPage(http.StatusOK, e.SUCCESS, goodses, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: total})
+	} else {
+		logger.GetLogger().Debugln("QueryHsbyMarketGoodses successed: %v", goodses)
+		appG.Response(http.StatusOK, e.SUCCESS, goodses)
+	}
+}

+ 4 - 2
controllers/search/goodsSearch.go

@@ -12,7 +12,8 @@ import (
 
 // GoodsesReq 检索商品信息请求参数
 type GoodsesReq struct {
-	Content string `form:"content" binding:"required"`
+	Content    string `form:"content" binding:"required"`
+	TradeModes string `form:"tradeModes"`
 }
 
 // Goodses 检索商品信息
@@ -20,6 +21,7 @@ type GoodsesReq struct {
 // @Description 说明:使用检索内容模糊匹配商品代码和商品名称
 // @Produce json
 // @Param content query string true "检索内容"
+// @Param tradeModes query string false "交易模式,格式:1,2,3"
 // @Success 200 {object} models.SearchGoods
 // @Failure 500 {object} app.Response
 // @Router /Search/SearchGoodses [get]
@@ -35,7 +37,7 @@ func Goodses(c *gin.Context) {
 		return
 	}
 
-	searchGoodses, err := models.SearchGoodses(req.Content)
+	searchGoodses, err := models.SearchGoodses(req.Content, req.TradeModes)
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("Goodses failed: %s", err.Error())

+ 1 - 16
controllers/wrtrade/wrTrade.go

@@ -13,21 +13,6 @@ import (
 	"github.com/gin-gonic/gin"
 )
 
-// Wrcategory 仓单分类表
-type Wrcategory struct {
-	Categoryid       int64                  `json:"categoryid"  xorm:"'CATEGORYID'" binding:"required"` // 类别ID(SEQ_WRCATEGORY)
-	Categoryname     string                 `json:"categoryname"  xorm:"'CATEGORYNAME'"`                // 类别名称
-	Parentcategoryid int64                  `json:"parentcategoryid"  xorm:"'PARENTCATEGORYID'"`        // 父类别ID
-	Categorydesc     string                 `json:"categorydesc"  xorm:"'CATEGORYDESC'"`                // 类别描述
-	Iconurl          string                 `json:"iconurl"  xorm:"'ICONURL'"`                          // 图标地址
-	Deliverygoods    []models.Deliverygoods // 所包含现货种类信息
-}
-
-// TableName is WRCATEGORY
-func (Wrcategory) TableName() string {
-	return "WRCATEGORY"
-}
-
 // GetAllDeliveryGoods 获取带仓单分类的种类信息
 // @Summary 获取带仓单分类的种类信息
 // @Produce json
@@ -70,7 +55,7 @@ func GetAllDeliveryGoods(c *gin.Context) {
 
 	// SELECT w.categoryid,w.categoryname,w.parentcategoryid,w.categorydesc,w.iconurl FROM WRCategory w START WITH Categoryid in (2,2,4) CONNECT BY PRIOR ParentCategoryID = Categoryid;
 	// 查询当前所有品种信息
-	var wrcategorys []Wrcategory
+	var wrcategorys []models.Wrcategory
 	if err := engine.SQL("SELECT w.categoryid,w.categoryname,w.parentcategoryid,w.categorydesc,w.iconurl FROM WRCategory w START WITH Categoryid in (?) CONNECT BY PRIOR ParentCategoryID = Categoryid", ids).Find(&wrcategorys); err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("GetAllDeliveryGoods failed: %s", err.Error())

+ 182 - 0
docs/docs.go

@@ -1552,6 +1552,69 @@ var doc = `{
                 }
             }
         },
+        "/HSBY/QueryHsbyMarketGoodses": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "查询特卖商品列表(三级商城)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场ID列表,格式:1,2,3",
+                        "name": "marketIDs",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。",
+                        "name": "accountID",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "类别ID",
+                        "name": "categoryID",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.HsbyMarketGoods"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyMarkets": {
             "get": {
                 "security": [
@@ -2879,6 +2942,12 @@ var doc = `{
                         "name": "content",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "交易模式,格式:1,2,3",
+                        "name": "tradeModes",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -6740,10 +6809,119 @@ var doc = `{
                 }
             }
         },
+        "models.HsbyMarketGoods": {
+            "type": "object",
+            "required": [
+                "accountid",
+                "buyorsell",
+                "goodscode",
+                "goodsid",
+                "goodsname",
+                "marketid",
+                "orderid",
+                "orderqty",
+                "trademode"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "账户ID[报价币种]",
+                    "type": "integer"
+                },
+                "agreeunit": {
+                    "description": "合约单位",
+                    "type": "number"
+                },
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "cancelqty": {
+                    "description": "撤单数量",
+                    "type": "integer"
+                },
+                "categoryid": {
+                    "description": "类别ID(WRCATEGORY)",
+                    "type": "integer"
+                },
+                "currency": {
+                    "description": "货币",
+                    "type": "string"
+                },
+                "currencysign": {
+                    "description": "货币符号",
+                    "type": "string"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "hascoupon": {
+                    "description": "是否可用优惠卷",
+                    "type": "boolean"
+                },
+                "hotindex": {
+                    "description": "景点热度",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "orderid": {
+                    "description": "委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "orderprice": {
+                    "description": "委托价格",
+                    "type": "number"
+                },
+                "orderqty": {
+                    "description": "委托数量",
+                    "type": "integer"
+                },
+                "orderstatus": {
+                    "description": "委托状态 - 1: 委托请求 2:待冻结 3:委托成功 4: 委托失败 5:配对成功 6: 已撤销 7:部分成交 8:已成交 9:部成部撤 10:成交失败 11:已拒绝 12:经过摘牌(先摘后挂专用-先摘后挂已摘过) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤 16:成交失败违约(荷兰式竞拍专用)",
+                    "type": "integer"
+                },
+                "picurls": {
+                    "description": "介绍图片[多张用逗号分隔]",
+                    "type": "string"
+                },
+                "quoteminunit": {
+                    "description": "行情最小变动单位 [整数,报价小数位一起使用]",
+                    "type": "integer"
+                },
+                "trademode": {
+                    "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
+                    "type": "integer"
+                },
+                "tradeqty": {
+                    "description": "成交数量",
+                    "type": "integer"
+                },
+                "videourls": {
+                    "description": "介绍视频[多张用逗号分隔]",
+                    "type": "string"
+                }
+            }
+        },
         "models.HsbyMarketInfo": {
             "type": "object",
             "required": [
                 "marketid",
+                "marketstatus",
                 "trademode"
             ],
             "properties": {
@@ -6755,6 +6933,10 @@ var doc = `{
                     "description": "市场名称",
                     "type": "string"
                 },
+                "marketstatus": {
+                    "description": "生效状态(ValidStatus枚举): 1:待生效 2:正常 3:注销",
+                    "type": "integer"
+                },
                 "trademode": {
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"

+ 182 - 0
docs/swagger.json

@@ -1536,6 +1536,69 @@
                 }
             }
         },
+        "/HSBY/QueryHsbyMarketGoodses": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "定制【海商报业】"
+                ],
+                "summary": "查询特卖商品列表(三级商城)",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "市场ID列表,格式:1,2,3",
+                        "name": "marketIDs",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。",
+                        "name": "accountID",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "类别ID",
+                        "name": "categoryID",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/models.HsbyMarketGoods"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/QueryHsbyMarkets": {
             "get": {
                 "security": [
@@ -2863,6 +2926,12 @@
                         "name": "content",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "交易模式,格式:1,2,3",
+                        "name": "tradeModes",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -6724,10 +6793,119 @@
                 }
             }
         },
+        "models.HsbyMarketGoods": {
+            "type": "object",
+            "required": [
+                "accountid",
+                "buyorsell",
+                "goodscode",
+                "goodsid",
+                "goodsname",
+                "marketid",
+                "orderid",
+                "orderqty",
+                "trademode"
+            ],
+            "properties": {
+                "accountid": {
+                    "description": "账户ID[报价币种]",
+                    "type": "integer"
+                },
+                "agreeunit": {
+                    "description": "合约单位",
+                    "type": "number"
+                },
+                "buyorsell": {
+                    "description": "买卖 - 0:买 1:卖",
+                    "type": "integer"
+                },
+                "cancelqty": {
+                    "description": "撤单数量",
+                    "type": "integer"
+                },
+                "categoryid": {
+                    "description": "类别ID(WRCATEGORY)",
+                    "type": "integer"
+                },
+                "currency": {
+                    "description": "货币",
+                    "type": "string"
+                },
+                "currencysign": {
+                    "description": "货币符号",
+                    "type": "string"
+                },
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
+                    "type": "string"
+                },
+                "goodsid": {
+                    "description": "商品ID",
+                    "type": "integer"
+                },
+                "goodsname": {
+                    "description": "商品名称",
+                    "type": "string"
+                },
+                "hascoupon": {
+                    "description": "是否可用优惠卷",
+                    "type": "boolean"
+                },
+                "hotindex": {
+                    "description": "景点热度",
+                    "type": "integer"
+                },
+                "marketid": {
+                    "description": "市场ID",
+                    "type": "integer"
+                },
+                "orderid": {
+                    "description": "委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
+                    "type": "string"
+                },
+                "orderprice": {
+                    "description": "委托价格",
+                    "type": "number"
+                },
+                "orderqty": {
+                    "description": "委托数量",
+                    "type": "integer"
+                },
+                "orderstatus": {
+                    "description": "委托状态 - 1: 委托请求 2:待冻结 3:委托成功 4: 委托失败 5:配对成功 6: 已撤销 7:部分成交 8:已成交 9:部成部撤 10:成交失败 11:已拒绝 12:经过摘牌(先摘后挂专用-先摘后挂已摘过) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤 16:成交失败违约(荷兰式竞拍专用)",
+                    "type": "integer"
+                },
+                "picurls": {
+                    "description": "介绍图片[多张用逗号分隔]",
+                    "type": "string"
+                },
+                "quoteminunit": {
+                    "description": "行情最小变动单位 [整数,报价小数位一起使用]",
+                    "type": "integer"
+                },
+                "trademode": {
+                    "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
+                    "type": "integer"
+                },
+                "tradeqty": {
+                    "description": "成交数量",
+                    "type": "integer"
+                },
+                "videourls": {
+                    "description": "介绍视频[多张用逗号分隔]",
+                    "type": "string"
+                }
+            }
+        },
         "models.HsbyMarketInfo": {
             "type": "object",
             "required": [
                 "marketid",
+                "marketstatus",
                 "trademode"
             ],
             "properties": {
@@ -6739,6 +6917,10 @@
                     "description": "市场名称",
                     "type": "string"
                 },
+                "marketstatus": {
+                    "description": "生效状态(ValidStatus枚举): 1:待生效 2:正常 3:注销",
+                    "type": "integer"
+                },
                 "trademode": {
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"

+ 133 - 0
docs/swagger.yaml

@@ -2392,6 +2392,91 @@ definitions:
     - marketid
     - trademode
     type: object
+  models.HsbyMarketGoods:
+    properties:
+      accountid:
+        description: 账户ID[报价币种]
+        type: integer
+      agreeunit:
+        description: 合约单位
+        type: number
+      buyorsell:
+        description: 买卖 - 0:买 1:卖
+        type: integer
+      cancelqty:
+        description: 撤单数量
+        type: integer
+      categoryid:
+        description: 类别ID(WRCATEGORY)
+        type: integer
+      currency:
+        description: 货币
+        type: string
+      currencysign:
+        description: 货币符号
+        type: string
+      decimalplace:
+        description: 报价小数位
+        type: integer
+      goodscode:
+        description: 商品代码(内部)
+        type: string
+      goodsid:
+        description: 商品ID
+        type: integer
+      goodsname:
+        description: 商品名称
+        type: string
+      hascoupon:
+        description: 是否可用优惠卷
+        type: boolean
+      hotindex:
+        description: 景点热度
+        type: integer
+      marketid:
+        description: 市场ID
+        type: integer
+      orderid:
+        description: 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+        type: string
+      orderprice:
+        description: 委托价格
+        type: number
+      orderqty:
+        description: 委托数量
+        type: integer
+      orderstatus:
+        description: 委托状态 - 1: 委托请求 2:待冻结 3:委托成功 4: 委托失败 5:配对成功 6: 已撤销 7:部分成交 8:已成交
+          9:部成部撤 10:成交失败 11:已拒绝 12:经过摘牌(先摘后挂专用-先摘后挂已摘过) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤
+          16:成交失败违约(荷兰式竞拍专用)
+        type: integer
+      picurls:
+        description: 介绍图片[多张用逗号分隔]
+        type: string
+      quoteminunit:
+        description: 行情最小变动单位 [整数,报价小数位一起使用]
+        type: integer
+      trademode:
+        description: 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式
+          21:竞拍-大宗式 22:受托竞价
+        type: integer
+      tradeqty:
+        description: 成交数量
+        type: integer
+      videourls:
+        description: 介绍视频[多张用逗号分隔]
+        type: string
+    required:
+    - accountid
+    - buyorsell
+    - goodscode
+    - goodsid
+    - goodsname
+    - marketid
+    - orderid
+    - orderqty
+    - trademode
+    type: object
   models.HsbyMarketInfo:
     properties:
       marketid:
@@ -2401,12 +2486,16 @@ definitions:
       marketname:
         description: 市场名称
         type: string
+      marketstatus:
+        description: '生效状态(ValidStatus枚举): 1:待生效 2:正常 3:注销'
+        type: integer
       trademode:
         description: 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式
           21:竞拍-大宗式 22:受托竞价
         type: integer
     required:
     - marketid
+    - marketstatus
     - trademode
     type: object
   models.HsbyMyGoods:
@@ -5998,6 +6087,46 @@ paths:
       summary: 查询二级市场(挂牌点选)商品信息详情
       tags:
       - 定制【海商报业】
+  /HSBY/QueryHsbyMarketGoodses:
+    get:
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      - description: 市场ID列表,格式:1,2,3
+        in: query
+        name: marketIDs
+        required: true
+        type: string
+      - description: 资金账户,主要用于判断商品是否有可用的优惠卷;如未登录可不传。
+        in: query
+        name: accountID
+        type: integer
+      - description: 类别ID
+        in: query
+        name: categoryID
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/models.HsbyMarketGoods'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 查询特卖商品列表(三级商城)
+      tags:
+      - 定制【海商报业】
   /HSBY/QueryHsbyMarkets:
     get:
       produces:
@@ -6836,6 +6965,10 @@ paths:
         name: content
         required: true
         type: string
+      - description: 交易模式,格式:1,2,3
+        in: query
+        name: tradeModes
+        type: string
       produces:
       - application/json
       responses:

+ 10 - 7
models/goods.go

@@ -146,16 +146,19 @@ type SearchGoods struct {
 }
 
 // SearchGoodses 检索商品信息的方法
-func SearchGoodses(content string) ([]SearchGoods, error) {
+func SearchGoodses(content, tradeModes string) ([]SearchGoods, error) {
 	engine := db.GetEngine()
 
 	searchGoodses := make([]SearchGoods, 0)
-	if err := engine.Table("GOODS").
-		Select(`GOODS.*, 
-				MARKET.MARKETNAME, MARKET.TRADEMODE`).
-		Join("INNER", "MARKET", "MARKET.MARKETID = GOODS.MARKETID").
-		Where(fmt.Sprintf("GOODS.GOODSCODE like '%%%s%%' or GOODS.GOODSNAME like '%%%s%%'", content, content)).
-		Find(&searchGoodses); err != nil {
+	session := engine.Table("GOODS G").
+		Select(`G.*, 
+				M.MARKETNAME, M.TRADEMODE`).
+		Join("INNER", "MARKET M", "M.MARKETID = G.MARKETID").
+		Where(fmt.Sprintf("G.GOODSCODE like '%%%s%%' or G.GOODSNAME like '%%%s%%'", content, content))
+	if len(tradeModes) > 0 {
+		session = session.And(fmt.Sprintf("M.TRADEMODE in (%s)", tradeModes))
+	}
+	if err := session.Find(&searchGoodses); err != nil {
 		return nil, err
 	}
 

+ 184 - 7
models/hsby.go

@@ -7,6 +7,7 @@ import (
 	"mtp2_if/db"
 	"mtp2_if/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -25,6 +26,8 @@ type Hsbygoodsex struct {
 	Memberratio    float64   `json:"memberratio"  xorm:"'MEMBERRATIO'"`            // 会员货款比例 [71]
 	Videourls      string    `json:"videourls"  xorm:"'VIDEOURLS'"`                // 介绍视频[多张用逗号分隔]
 	Picurls        string    `json:"picurls"  xorm:"'PICURLS'"`                    // 介绍图片[多张用逗号分隔]
+	Goodsprice     float64   `json:"goodsprice"  xorm:"'GOODSPRICE'"`              // 商品价格
+	Categoryid     int32     `json:"categoryid"  xorm:"'CATEGORYID'"`              // 类别ID(WRCATEGORY)
 }
 
 // TableName is HSBY_GOODSEX
@@ -77,6 +80,52 @@ func (Tradepayorder) TableName() string {
 	return "TRADE_PAYORDER"
 }
 
+// Coupontype 优惠券类型表
+type Coupontype struct {
+	Coupontypeid    int32     `json:"coupontypeid"  xorm:"'COUPONTYPEID'" binding:"required"` // 优惠券类型ID - SEQ_COUPONTYPE
+	Areauserid      int64     `json:"areauserid"  xorm:"'AREAUSERID'"`                        // 所属机构
+	Couponname      string    `json:"couponname"  xorm:"'COUPONNAME'"`                        // 优惠券名称
+	Couponcategroy  int32     `json:"couponcategroy"  xorm:"'COUPONCATEGROY'"`                // 种类 - 1:现金券 2:折扣券 3:折扣券(单张)
+	Conditionvalue  float64   `json:"conditionvalue"  xorm:"'CONDITIONVALUE'"`                // 条件阈值(可为0)
+	Couponvalue     float64   `json:"couponvalue"  xorm:"'COUPONVALUE'"`                      // 面值[1:现金券 - 抵扣值 2:折扣券-折扣值]
+	Limitedflag     int32     `json:"limitedflag"  xorm:"'LIMITEDFLAG'"`                      // 是否指定商品 - 0:不限 1:限制
+	Limitedgoodsids string    `json:"limitedgoodsids"  xorm:"'LIMITEDGOODSIDS'"`              // 指定商品IDs[逗号分隔,前后加逗号]
+	Isgeneral       int32     `json:"isgeneral"  xorm:"'ISGENERAL'"`                          // 是否通用券 - 0:否 1:是
+	Userscope       string    `json:"userscope"  xorm:"'USERSCOPE'"`                          // 卖家范围(用户ID,逗号分隔,前后加逗号) [IsGeneral =0时使用]
+	Qty             int64     `json:"qty"  xorm:"'QTY'"`                                      // 数量
+	Curqty          int64     `json:"curqty"  xorm:"'CURQTY'"`                                // 剩余数量
+	Createtime      time.Time `json:"createtime"  xorm:"'CREATETIME'"`                        // 创建时间
+	Creatorid       int64     `json:"creatorid"  xorm:"'CREATORID'"`                          // 创建人
+	Modifierid      int64     `json:"modifierid"  xorm:"'MODIFIERID'"`                        // 修改人
+	Modifytime      time.Time `json:"modifytime"  xorm:"'MODIFYTIME'"`                        // 修改时间
+	Usedqty         int64     `json:"usedqty"  xorm:"'USEDQTY'"`                              // 使用量
+	Isvalid         int32     `json:"isvalid"  xorm:"'ISVALID'"`                              // 是否有效 - 0:无效 1:有效
+	Expiredqty      int64     `json:"expiredqty"  xorm:"'EXPIREDQTY'"`                        // 失效量
+}
+
+// TableName is COUPONTYPE
+func (Coupontype) TableName() string {
+	return "COUPONTYPE"
+}
+
+// Couponposition 优惠券头寸表 - 导历史(期末为0的清除)
+type Couponposition struct {
+	Accountid     int64 `json:"accountid"  xorm:"'ACCOUNTID'" binding:"required"`       // 资金账户ID
+	Coupontypeid  int32 `json:"coupontypeid"  xorm:"'COUPONTYPEID'" binding:"required"` // 优惠券类型ID
+	Userid        int64 `json:"userid"  xorm:"'USERID'"`                                // 用户ID
+	Oriqty        int64 `json:"oriqty"  xorm:"'ORIQTY'"`                                // 期初数量
+	Orifreezeqty  int64 `json:"orifreezeqty"  xorm:"'ORIFREEZEQTY'"`                    // 期初冻结数量
+	Curqty        int64 `json:"curqty"  xorm:"'CURQTY'"`                                // 期末数量
+	Curfreezeqty  int64 `json:"curfreezeqty"  xorm:"'CURFREEZEQTY'"`                    // 期末冻结数量
+	Todayincrease int64 `json:"todayincrease"  xorm:"'TODAYINCREASE'"`                  // 今日增加
+	Todaydecrease int64 `json:"todaydecrease"  xorm:"'TODAYDECREASE'"`                  // 今日减少
+}
+
+// TableName is COUPONPOSITION
+func (Couponposition) TableName() string {
+	return "COUPONPOSITION"
+}
+
 // HsbyTopGoods 热卖商品(二级市场挂牌点选)
 type HsbyTopGoods struct {
 	Goodsid      int64   `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID(自增ID SEQ_GOODS)
@@ -112,6 +161,7 @@ func GetHsbyTopGoodses(marketIDs string, descProvinceID, descCityID int) ([]Hsby
 
 	topGoodses := make([]HsbyTopGoods, 0)
 	// 获取挂牌商品信息,以及扩展表信息
+	// 与商城不一样的是,挂牌点选以商品表作为主表,同一商品可有多个委托单
 	session := engine.Table("GOODS").
 		Select(`GOODS.*, 
 				HSBY_GOODSEX.HOTINDEX, HSBY_GOODSEX.VIDEOURLS, HSBY_GOODSEX.PICURLS, 
@@ -848,7 +898,7 @@ func GetHsbySellMyTradeDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 		Join("LEFT", "ENUMDICITEM", "GOODS.CURRENCYID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'currency'").
 		Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_TRADEDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO", "HSBY_SUPPLIERINFO.VENDORID = HSBY_GOODSEX.VENDORID").
-		Where(fmt.Sprintf(`TRADE_TRADEDETAIL.BUYORSELL = 1 
+		Where(fmt.Sprintf(`TRADE_TRADEDETAIL.BUYORSELL = 1 and TRADE_TRADEDETAIL.TRADETYPE = 1
 						   and TRADE_TRADEDETAIL.ACCOUNTID in (%s)`, accountIDs)).
 		And(fmt.Sprintf("TRADE_TRADEDETAIL.MARKETID in (%s)", marketIDs)).Find(&curOrders); err != nil {
 		return nil, err
@@ -874,7 +924,7 @@ func GetHsbySellMyTradeDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 		Join("LEFT", "ENUMDICITEM", "GOODS.CURRENCYID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'currency'").
 		Join("LEFT", "MARKET", "MARKET.MARKETID = HIS_TRADE_TRADEDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO", "HSBY_SUPPLIERINFO.VENDORID = HSBY_GOODSEX.VENDORID").
-		Where(fmt.Sprintf(`HIS_TRADE_TRADEDETAIL.BUYORSELL = 1 and HIS_TRADE_TRADEDETAIL.ISVALIDDATA = 1 
+		Where(fmt.Sprintf(`HIS_TRADE_TRADEDETAIL.BUYORSELL = 1 and HIS_TRADE_TRADEDETAIL.TRADETYPE = 1 and HIS_TRADE_TRADEDETAIL.ISVALIDDATA = 1 
 						   and HIS_TRADE_TRADEDETAIL.ACCOUNTID in (%s)`, accountIDs)).
 		And(fmt.Sprintf("HIS_TRADE_TRADEDETAIL.MARKETID in (%s)", marketIDs)).Find(&hisOrders); err != nil {
 		return nil, err
@@ -1075,7 +1125,7 @@ func GetHsbyBuyMyTradeDetails(accountIDs string) ([]HsbyBuyMyTradeDetail, error)
 		Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_TRADEDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO HS1", "HS1.VENDORID = HG1.VENDORID").
 		Join("LEFT", "HSBY_SUPPLIERINFO HS2", "HS2.VENDORID = HG2.VENDORID").
-		Where(fmt.Sprintf(`TRADE_TRADEDETAIL.BUYORSELL = 0 
+		Where(fmt.Sprintf(`TRADE_TRADEDETAIL.BUYORSELL = 0 and TRADE_TRADEDETAIL.TRADETYPE = 1
 						   and TRADE_TRADEDETAIL.ACCOUNTID in (%s)`, accountIDs)).
 		And(fmt.Sprintf("TRADE_TRADEDETAIL.MARKETID in (%s)", marketIDs)).Find(&curOrders); err != nil {
 		return nil, err
@@ -1103,7 +1153,7 @@ func GetHsbyBuyMyTradeDetails(accountIDs string) ([]HsbyBuyMyTradeDetail, error)
 		Join("LEFT", "MARKET", "MARKET.MARKETID = HIS_TRADE_TRADEDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO HS1", "HS1.VENDORID = HG1.VENDORID").
 		Join("LEFT", "HSBY_SUPPLIERINFO HS2", "HS2.VENDORID = HG2.VENDORID").
-		Where(fmt.Sprintf(`HIS_TRADE_TRADEDETAIL.BUYORSELL = 0 and HIS_TRADE_TRADEDETAIL.ISVALIDDATA = 1 
+		Where(fmt.Sprintf(`HIS_TRADE_TRADEDETAIL.BUYORSELL = 0 and HIS_TRADE_TRADEDETAIL.TRADETYPE = 1 and HIS_TRADE_TRADEDETAIL.ISVALIDDATA = 1 
 						   and HIS_TRADE_TRADEDETAIL.ACCOUNTID in (%s)`, accountIDs)).
 		And(fmt.Sprintf("HIS_TRADE_TRADEDETAIL.MARKETID in (%s)", marketIDs)).Find(&hisOrders); err != nil {
 		return nil, err
@@ -1206,9 +1256,10 @@ func GetHsbyBuyMyPayOrders(accountIDs string, buyOrderID, sellOrderID int) ([]Hs
 
 // HsbyMarketInfo 海商报业相关市场信息
 type HsbyMarketInfo struct {
-	Marketid   int32  `json:"marketid"  xorm:"'MARKETID'" binding:"required"`   // 市场ID正常5位,前三位固定:两位表示交易模式, 一位表示交易属性(1:收益权,2:所有权) 其它特殊市场:0-系统 1-交割服务 2-账户服务3-履约服务 4-仓单服务 5-积分服务 6-银行服务
-	Marketname string `json:"marketname"  xorm:"'MARKETNAME'"`                  // 市场名称
-	Trademode  int32  `json:"trademode"  xorm:"'TRADEMODE'" binding:"required"` // 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
+	Marketid     int32  `json:"marketid"  xorm:"'MARKETID'" binding:"required"`         // 市场ID正常5位,前三位固定:两位表示交易模式, 一位表示交易属性(1:收益权,2:所有权) 其它特殊市场:0-系统 1-交割服务 2-账户服务3-履约服务 4-仓单服务 5-积分服务 6-银行服务
+	Marketname   string `json:"marketname"  xorm:"'MARKETNAME'"`                        // 市场名称
+	Trademode    int32  `json:"trademode"  xorm:"'TRADEMODE'" binding:"required"`       // 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
+	Marketstatus int32  `json:"marketstatus"  xorm:"'MARKETSTATUS'" binding:"required"` // 生效状态(ValidStatus枚举): 1:待生效 2:正常 3:注销
 }
 
 // GetHsbyMarketInfos 获取海商报业相关市场信息
@@ -1297,3 +1348,129 @@ func GetHsbySellCollectionOrders(accountIDs string) ([]HsbySellCollectionOrder,
 
 	return orders, nil
 }
+
+// HsbyMarketGoods 特卖商城商品(三级市场商场)
+type HsbyMarketGoods struct {
+	Orderid     string  `json:"orderid"  xorm:"'ORDERIDSTR'" binding:"required"`  // 委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
+	Marketid    int32   `json:"marketid"  xorm:"'MARKETID'" binding:"required"`   // 市场ID
+	Goodsid     int32   `json:"goodsid"  xorm:"'GOODSID'" binding:"required"`     // 商品ID
+	Accountid   int64   `json:"accountid"  xorm:"'ACCOUNTID'" binding:"required"` // 账户ID[报价币种]
+	Buyorsell   int32   `json:"buyorsell"  xorm:"'BUYORSELL'" binding:"required"` // 买卖 - 0:买 1:卖
+	Orderprice  float64 `json:"orderprice"  xorm:"'ORDERPRICE'"`                  // 委托价格
+	Orderqty    int64   `json:"orderqty"  xorm:"'ORDERQTY'" binding:"required"`   // 委托数量
+	Tradeqty    int64   `json:"tradeqty"  xorm:"'TRADEQTY'"`                      // 成交数量
+	Cancelqty   int64   `json:"cancelqty"  xorm:"'CANCELQTY'"`                    // 撤单数量
+	Orderstatus int32   `json:"orderstatus"  xorm:"'ORDERSTATUS'"`                // 委托状态 - 1: 委托请求 2:待冻结 3:委托成功 4: 委托失败 5:配对成功 6: 已撤销 7:部分成交 8:已成交 9:部成部撤 10:成交失败 11:已拒绝 12:经过摘牌(先摘后挂专用-先摘后挂已摘过) 13:冻结成功(通道交易专用) 14:通道已撤 15:通道部成部撤 16:成交失败违约(荷兰式竞拍专用)
+
+	Goodscode    string  `json:"goodscode"  xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
+	Goodsname    string  `json:"goodsname"  xorm:"'GOODSNAME'" binding:"required"` // 商品名称
+	Decimalplace int64   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`              // 报价小数位
+	Quoteminunit int64   `json:"quoteminunit"  xorm:"'QUOTEMINUNIT'"`              // 行情最小变动单位 [整数,报价小数位一起使用]
+	Agreeunit    float64 `json:"agreeunit"  xorm:"'AGREEUNIT'"`                    // 合约单位
+
+	Hotindex   int32  `json:"hotindex"  xorm:"'HOTINDEX'"`     // 景点热度
+	Videourls  string `json:"videourls"  xorm:"'VIDEOURLS'"`   // 介绍视频[多张用逗号分隔]
+	Picurls    string `json:"picurls"  xorm:"'PICURLS'"`       // 介绍图片[多张用逗号分隔]
+	Categoryid int32  `json:"categoryid"  xorm:"'CATEGORYID'"` // 类别ID(WRCATEGORY)
+
+	Currency     string `json:"currency" xorm:"'CURRENCY'"`         // 货币
+	Currencysign string `json:"currencysign" xorm:"'CURRENCYSIGN'"` // 货币符号
+
+	Trademode int32 `json:"trademode"  xorm:"'TRADEMODE'" binding:"required"` // 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
+
+	HasCoupon bool `json:"hascoupon" xorm:"-"` // 是否可用优惠卷
+}
+
+// GetHsbyMarketGoodses 获取商城商品列表(三级商城)
+func GetHsbyMarketGoodses(marketIDs string, accountID, categoryID int) ([]HsbyMarketGoods, error) {
+	engine := db.GetEngine()
+
+	orders := make([]HsbyMarketGoods, 0)
+	// 与挂牌点选不一样的是商城是以委托单为主表;已经卖完的委托单不显示
+	session := engine.Table("TRADE_ORDERDETAIL T").
+		Select(`to_char(T.ORDERID) ORDERIDSTR, T.*, 
+				G.GOODSCODE, G.GOODSNAME, G.DECIMALPLACE, G.QUOTEMINUNIT, G.AGREEUNIT, 
+				GX.HOTINDEX, GX.VIDEOURLS, GX.PICURLS, GX.CATEGORYID,  
+				ENUMDICITEM.ENUMDICNAME CURRENCY, ENUMDICITEM.PARAM2 CURRENCYSIGN, 
+				M.TRADEMODE`).
+		Join("LEFT", "GOODS G", "G.GOODSID = T.GOODSID").
+		Join("LEFT", "HSBY_GOODSEX GX", "GX.GOODSID = T.GOODSID").
+		Join("LEFT", "ENUMDICITEM E", "E.ENUMITEMNAME = G.CURRENCYID and E.ENUMDICCODE = 'currency'").
+		Join("LEFT", "MARKET M", "M.MARKETID = T.MARKETID").
+		Where(fmt.Sprintf("T.MARKETID in (%s)", marketIDs)).
+		And("T.ORDERSTATUS in (3,7) and T.BUYORSELL = 1 and (T.ORDERQTY - T.TRADEQTY - T.CANCELQTY) > 0")
+	if categoryID != 0 {
+		session = session.And("GX.CATEGORYID = ?", categoryID)
+	}
+	if err := session.Find(&orders); err != nil {
+		return nil, err
+	}
+
+	// 获取当前账户的优惠卷
+	type myCouponPosition struct {
+		Accountid    int64 `json:"accountid"  xorm:"'ACCOUNTID'" binding:"required"`       // 资金账户ID
+		Coupontypeid int32 `json:"coupontypeid"  xorm:"'COUPONTYPEID'" binding:"required"` // 优惠券类型ID
+		Curqty       int64 `json:"curqty"  xorm:"'CURQTY'"`                                // 期末数量
+		Curfreezeqty int64 `json:"curfreezeqty"  xorm:"'CURFREEZEQTY'"`                    // 期末冻结数量
+
+		Limitedflag     int32  `json:"limitedflag"  xorm:"'LIMITEDFLAG'"`         // 是否指定商品 - 0:不限 1:限制
+		Limitedgoodsids string `json:"limitedgoodsids"  xorm:"'LIMITEDGOODSIDS'"` // 指定商品IDs[逗号分隔,前后加逗号]
+		Isgeneral       int32  `json:"isgeneral"  xorm:"'ISGENERAL'"`             // 是否通用券 - 0:否 1:是
+		Userscope       string `json:"userscope"  xorm:"'USERSCOPE'"`             // 卖家范围(用户ID,逗号分隔,前后加逗号) [IsGeneral =0时使用]
+	}
+	myCouponPositions := make([]myCouponPosition, 0)
+	if accountID != 0 {
+		if err := engine.Table("COUPONPOSITION C").
+			Select(`C.ACCOUNTID, C.COUPONTYPEID, C.CURQTY, C.CURFREEZEQTY,
+				CT.LIMITEDFLAG, CT.LIMITEDGOODSIDS, CT.ISGENERAL, CT.USERSCOPE`).
+			Join("INNER", "COUPONTYPE CT", "CT.COUPONTYPEID = C.COUPONTYPEID").
+			Where("C.ACCOUNTID = ?", accountID).Find(&myCouponPositions); err != nil {
+			return nil, err
+		}
+	}
+
+	// 是否有优惠卷可用
+	if len(orders) > 0 && len(myCouponPositions) > 0 {
+		for _, coupon := range myCouponPositions {
+			if coupon.Limitedflag == 0 && coupon.Isgeneral == 1 {
+				// 有不指定商品的通用卷则所有委托单都可以用卷
+				for i := range orders {
+					order := &orders[i]
+					order.HasCoupon = true
+				}
+				break
+			} else {
+				for i := range orders {
+					order := &orders[i]
+					tmpGoodsID := fmt.Sprintf(",%d,", order.Goodsid)
+					tmpAccountID := fmt.Sprintf(",%d,", order.Accountid)
+
+					// 优惠卷是否可用于商品
+					isRightGoods := false
+					if coupon.Limitedflag == 0 {
+						isRightGoods = true
+					} else {
+						if strings.Contains(coupon.Limitedgoodsids, tmpGoodsID) {
+							isRightGoods = true
+						}
+					}
+					// 优惠卷是否可用于卖家
+					isRightAccount := false
+					if coupon.Isgeneral == 1 {
+						isRightAccount = true
+					} else {
+						if strings.Contains(coupon.Userscope, tmpAccountID) {
+							isRightAccount = true
+						}
+					}
+
+					if isRightGoods && isRightAccount {
+						order.HasCoupon = true
+					}
+				}
+			}
+		}
+	}
+
+	return orders, nil
+}

+ 26 - 0
models/wr.go

@@ -0,0 +1,26 @@
+package models
+
+// 仓单服务
+
+import "time"
+
+// Wrcategory 现货分类表
+type Wrcategory struct {
+	Categoryid       int32     `json:"categoryid"  xorm:"'CATEGORYID'" binding:"required"` // 类别ID(SEQ_WRCATEGORY)
+	Categoryname     string    `json:"categoryname"  xorm:"'CATEGORYNAME'"`                // 类别名称
+	Parentcategoryid int32     `json:"parentcategoryid"  xorm:"'PARENTCATEGORYID'"`        // 父类别ID
+	Categorydesc     string    `json:"categorydesc"  xorm:"'CATEGORYDESC'"`                // 类别描述
+	Isvalid          int32     `json:"isvalid"  xorm:"'ISVALID'"`                          // 是否有效 - 0:无效 1:有效
+	Iconurl          string    `json:"iconurl"  xorm:"'ICONURL'"`                          // 图标地址
+	Creatorid        int64     `json:"creatorid"  xorm:"'CREATORID'"`                      // 创建人
+	Createtime       time.Time `json:"createtime"  xorm:"'CREATETIME'"`                    // 创建时间
+	Updatorid        int64     `json:"updatorid"  xorm:"'UPDATORID'"`                      // 更新人
+	Updatetime       time.Time `json:"updatetime"  xorm:"'UPDATETIME'"`                    // 更新时间
+	Orderindex       int32     `json:"orderindex"  xorm:"'ORDERINDEX'"`                    // 顺序
+	Areauserid       int64     `json:"areauserid"  xorm:"'AREAUSERID'"`                    // 所属机构
+}
+
+// TableName is WRCATEGORY
+func (Wrcategory) TableName() string {
+	return "WRCATEGORY"
+}

+ 2 - 0
routers/router.go

@@ -264,6 +264,8 @@ func InitRouter() *gin.Engine {
 		hsbyR.GET("/QueryMyCollectionOrders", hsby.QueryMyCollectionOrders)
 		// 查询海商报业相关市场信息
 		hsbyR.GET("/QueryHsbyMarkets", hsby.QueryHsbyMarkets)
+		// 查询特卖商品列表(三级商城)
+		hsbyR.GET("/QueryHsbyMarketGoodses", hsby.QueryHsbyMarketGoodses)
 	}
 
 	return r