Procházet zdrojové kódy

修改我的闲置BUG

zhou.xiaoning před 5 roky
rodič
revize
12693c1528
5 změnil soubory, kde provedl 146 přidání a 119 odebrání
  1. 3 5
      controllers/hsby/hsby.go
  2. 34 30
      docs/docs.go
  3. 34 30
      docs/swagger.json
  4. 29 24
      docs/swagger.yaml
  5. 46 30
      models/hsby.go

+ 3 - 5
controllers/hsby/hsby.go

@@ -944,8 +944,7 @@ func QueryMyPayOrders(c *gin.Context) {
 // QueryMyCollectionOrdersReq 我的闲置中收款信息查询请求参数
 type QueryMyCollectionOrdersReq struct {
 	app.PageInfo
-	SellOrderID   int `form:"sellOrderID" binding:"required"`
-	SellAccountID int `form:"sellAccountID" binding:"required"`
+	AccountIDs string `form:"accountIDs" binding:"required"`
 }
 
 // QueryMyCollectionOrders 我的闲置中收款信息查询
@@ -954,8 +953,7 @@ type QueryMyCollectionOrdersReq struct {
 // @Security ApiKeyAuth
 // @Param page query int false "页码"
 // @Param pagesize query int false "每页条数"
-// @Param sellOrderID query int true "卖方委托单号"
-// @Param sellAccountID query int true "卖方资金账户"
+// @Param accountIDs query string true "资金账户,格式:1,2,3"
 // @Success 200 {object} models.HsbySellCollectionOrder
 // @Failure 500 {object} app.Response
 // @Router /HSBY/QueryMyCollectionOrders [get]
@@ -972,7 +970,7 @@ func QueryMyCollectionOrders(c *gin.Context) {
 	}
 
 	// 获取数据
-	orders, err := models.GetHsbySellCollectionOrders(req.SellOrderID, req.SellAccountID)
+	orders, err := models.GetHsbySellCollectionOrders(req.AccountIDs)
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("QueryMyCollectionOrders failed: %s", err.Error())

+ 34 - 30
docs/docs.go

@@ -1971,16 +1971,9 @@ var doc = `{
                         "in": "query"
                     },
                     {
-                        "type": "integer",
-                        "description": "卖方委托单号",
-                        "name": "sellOrderID",
-                        "in": "query",
-                        "required": true
-                    },
-                    {
-                        "type": "integer",
-                        "description": "卖方资金账户",
-                        "name": "sellAccountID",
+                        "type": "string",
+                        "description": "资金账户,格式:1,2,3",
+                        "name": "accountIDs",
                         "in": "query",
                         "required": true
                     }
@@ -7188,7 +7181,10 @@ var doc = `{
         "models.HsbySellCollectionOrder": {
             "type": "object",
             "required": [
-                "tradeid"
+                "goodscode",
+                "goodsname",
+                "tradeid",
+                "trademode"
             ],
             "properties": {
                 "agreeunit": {
@@ -7211,16 +7207,20 @@ var doc = `{
                     "description": "货币符号",
                     "type": "string"
                 },
-                "customername": {
-                    "description": "客户名称(企业名称),已脱敏",
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
                     "type": "string"
                 },
                 "goodsid": {
                     "description": "商品ID",
                     "type": "integer"
                 },
-                "goodunit": {
-                    "description": "报价单位",
+                "goodsname": {
+                    "description": "商品名称",
                     "type": "string"
                 },
                 "marketid": {
@@ -7247,6 +7247,10 @@ var doc = `{
                     "description": "付款时间",
                     "type": "string"
                 },
+                "picurls": {
+                    "description": "商品介绍图片[多张用逗号分隔]",
+                    "type": "string"
+                },
                 "sellaccountid": {
                     "description": "卖方账号ID[报价币种]",
                     "type": "integer"
@@ -7271,6 +7275,10 @@ var doc = `{
                     "description": "成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
                     "type": "string"
                 },
+                "trademode": {
+                    "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
+                    "type": "integer"
+                },
                 "tradeprice": {
                     "description": "成交价格",
                     "type": "number"
@@ -7291,7 +7299,7 @@ var doc = `{
                 "goodsname",
                 "marketid",
                 "orderid",
-                "qty",
+                "orderqty",
                 "time",
                 "trademode"
             ],
@@ -7304,14 +7312,14 @@ var doc = `{
                     "description": "合约单位",
                     "type": "number"
                 },
-                "amount": {
-                    "description": "金额 = 价格 * 数量 * 合约单位",
-                    "type": "number"
-                },
                 "buyorsell": {
                     "description": "买卖 - 0:买 1:卖",
                     "type": "integer"
                 },
+                "cancelqty": {
+                    "description": "撤单数量",
+                    "type": "integer"
+                },
                 "currencysign": {
                     "description": "货币符号",
                     "type": "string"
@@ -7340,12 +7348,12 @@ var doc = `{
                     "description": "单号(发布中 - 委托单号;已完成 - 成交单号)",
                     "type": "string"
                 },
-                "ordertype": {
-                    "description": "单据类型:0 - 发布中, 1 - 已完成",
+                "orderqty": {
+                    "description": "委托数量",
                     "type": "integer"
                 },
-                "payedcount": {
-                    "description": "已付款数量",
+                "ordertype": {
+                    "description": "单据类型:0 - 发布中, 1 - 已完成",
                     "type": "integer"
                 },
                 "picurls": {
@@ -7356,10 +7364,6 @@ var doc = `{
                     "description": "价格",
                     "type": "number"
                 },
-                "qty": {
-                    "description": "数量",
-                    "type": "integer"
-                },
                 "time": {
                     "description": "时间",
                     "type": "string"
@@ -7368,8 +7372,8 @@ var doc = `{
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"
                 },
-                "unPayCount": {
-                    "description": "待付款数量",
+                "tradeqty": {
+                    "description": "成交数量",
                     "type": "integer"
                 },
                 "vendorname": {

+ 34 - 30
docs/swagger.json

@@ -1955,16 +1955,9 @@
                         "in": "query"
                     },
                     {
-                        "type": "integer",
-                        "description": "卖方委托单号",
-                        "name": "sellOrderID",
-                        "in": "query",
-                        "required": true
-                    },
-                    {
-                        "type": "integer",
-                        "description": "卖方资金账户",
-                        "name": "sellAccountID",
+                        "type": "string",
+                        "description": "资金账户,格式:1,2,3",
+                        "name": "accountIDs",
                         "in": "query",
                         "required": true
                     }
@@ -7172,7 +7165,10 @@
         "models.HsbySellCollectionOrder": {
             "type": "object",
             "required": [
-                "tradeid"
+                "goodscode",
+                "goodsname",
+                "tradeid",
+                "trademode"
             ],
             "properties": {
                 "agreeunit": {
@@ -7195,16 +7191,20 @@
                     "description": "货币符号",
                     "type": "string"
                 },
-                "customername": {
-                    "description": "客户名称(企业名称),已脱敏",
+                "decimalplace": {
+                    "description": "报价小数位",
+                    "type": "integer"
+                },
+                "goodscode": {
+                    "description": "商品代码(内部)",
                     "type": "string"
                 },
                 "goodsid": {
                     "description": "商品ID",
                     "type": "integer"
                 },
-                "goodunit": {
-                    "description": "报价单位",
+                "goodsname": {
+                    "description": "商品名称",
                     "type": "string"
                 },
                 "marketid": {
@@ -7231,6 +7231,10 @@
                     "description": "付款时间",
                     "type": "string"
                 },
+                "picurls": {
+                    "description": "商品介绍图片[多张用逗号分隔]",
+                    "type": "string"
+                },
                 "sellaccountid": {
                     "description": "卖方账号ID[报价币种]",
                     "type": "integer"
@@ -7255,6 +7259,10 @@
                     "description": "成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)",
                     "type": "string"
                 },
+                "trademode": {
+                    "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
+                    "type": "integer"
+                },
                 "tradeprice": {
                     "description": "成交价格",
                     "type": "number"
@@ -7275,7 +7283,7 @@
                 "goodsname",
                 "marketid",
                 "orderid",
-                "qty",
+                "orderqty",
                 "time",
                 "trademode"
             ],
@@ -7288,14 +7296,14 @@
                     "description": "合约单位",
                     "type": "number"
                 },
-                "amount": {
-                    "description": "金额 = 价格 * 数量 * 合约单位",
-                    "type": "number"
-                },
                 "buyorsell": {
                     "description": "买卖 - 0:买 1:卖",
                     "type": "integer"
                 },
+                "cancelqty": {
+                    "description": "撤单数量",
+                    "type": "integer"
+                },
                 "currencysign": {
                     "description": "货币符号",
                     "type": "string"
@@ -7324,12 +7332,12 @@
                     "description": "单号(发布中 - 委托单号;已完成 - 成交单号)",
                     "type": "string"
                 },
-                "ordertype": {
-                    "description": "单据类型:0 - 发布中, 1 - 已完成",
+                "orderqty": {
+                    "description": "委托数量",
                     "type": "integer"
                 },
-                "payedcount": {
-                    "description": "已付款数量",
+                "ordertype": {
+                    "description": "单据类型:0 - 发布中, 1 - 已完成",
                     "type": "integer"
                 },
                 "picurls": {
@@ -7340,10 +7348,6 @@
                     "description": "价格",
                     "type": "number"
                 },
-                "qty": {
-                    "description": "数量",
-                    "type": "integer"
-                },
                 "time": {
                     "description": "时间",
                     "type": "string"
@@ -7352,8 +7356,8 @@
                     "description": "交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价",
                     "type": "integer"
                 },
-                "unPayCount": {
-                    "description": "待付款数量",
+                "tradeqty": {
+                    "description": "成交数量",
                     "type": "integer"
                 },
                 "vendorname": {

+ 29 - 24
docs/swagger.yaml

@@ -2740,14 +2740,17 @@ definitions:
       currencysign:
         description: 货币符号
         type: string
-      customername:
-        description: 客户名称(企业名称),已脱敏
+      decimalplace:
+        description: 报价小数位
+        type: integer
+      goodscode:
+        description: 商品代码(内部)
         type: string
       goodsid:
         description: 商品ID
         type: integer
-      goodunit:
-        description: 报价单位
+      goodsname:
+        description: 商品名称
         type: string
       marketid:
         description: 市场ID
@@ -2767,6 +2770,9 @@ definitions:
       paytime:
         description: 付款时间
         type: string
+      picurls:
+        description: 商品介绍图片[多张用逗号分隔]
+        type: string
       sellaccountid:
         description: 卖方账号ID[报价币种]
         type: integer
@@ -2785,6 +2791,10 @@ definitions:
       tradeid:
         description: 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
         type: string
+      trademode:
+        description: 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式
+          21:竞拍-大宗式 22:受托竞价
+        type: integer
       tradeprice:
         description: 成交价格
         type: number
@@ -2792,7 +2802,10 @@ definitions:
         description: 成交数量
         type: integer
     required:
+    - goodscode
+    - goodsname
     - tradeid
+    - trademode
     type: object
   models.HsbySellMyDetail:
     properties:
@@ -2802,12 +2815,12 @@ definitions:
       agreeunit:
         description: 合约单位
         type: number
-      amount:
-        description: 金额 = 价格 * 数量 * 合约单位
-        type: number
       buyorsell:
         description: 买卖 - 0:买 1:卖
         type: integer
+      cancelqty:
+        description: 撤单数量
+        type: integer
       currencysign:
         description: 货币符号
         type: string
@@ -2829,21 +2842,18 @@ definitions:
       orderid:
         description: 单号(发布中 - 委托单号;已完成 - 成交单号)
         type: string
+      orderqty:
+        description: 委托数量
+        type: integer
       ordertype:
         description: 单据类型:0 - 发布中, 1 - 已完成
         type: integer
-      payedcount:
-        description: 已付款数量
-        type: integer
       picurls:
         description: 介绍图片[多张用逗号分隔]
         type: string
       price:
         description: 价格
         type: number
-      qty:
-        description: 数量
-        type: integer
       time:
         description: 时间
         type: string
@@ -2851,8 +2861,8 @@ definitions:
         description: 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式
           21:竞拍-大宗式 22:受托竞价
         type: integer
-      unPayCount:
-        description: 待付款数量
+      tradeqty:
+        description: 成交数量
         type: integer
       vendorname:
         description: 供应商名称
@@ -2865,7 +2875,7 @@ definitions:
     - goodsname
     - marketid
     - orderid
-    - qty
+    - orderqty
     - time
     - trademode
     type: object
@@ -6245,16 +6255,11 @@ paths:
         in: query
         name: pagesize
         type: integer
-      - description: 卖方委托单号
+      - description: 资金账户,格式:1,2,3
         in: query
-        name: sellOrderID
-        required: true
-        type: integer
-      - description: 卖方资金账户
-        in: query
-        name: sellAccountID
+        name: accountIDs
         required: true
-        type: integer
+        type: string
       produces:
       - application/json
       responses:

+ 46 - 30
models/hsby.go

@@ -732,9 +732,10 @@ type HsbySellMyDetail struct {
 	Accountid int64     `json:"accountid"  xorm:"'ACCOUNTID'" binding:"required"` // 账户ID[报价币种]
 	Buyorsell int32     `json:"buyorsell"  xorm:"'BUYORSELL'" binding:"required"` // 买卖 - 0:买 1:卖
 	Price     float64   `json:"price"  xorm:"'PRICE'"`                            // 价格
-	Qty       int64     `json:"qty"  xorm:"'QTY'" binding:"required"`             // 数量
 	Time      time.Time `json:"time"  xorm:"'TIME'" binding:"required"`           // 时间
-	Amount    float64   `json:"amount" xorm:"'AMOUNT'"`                           // 金额 = 价格 * 数量 * 合约单位
+	Orderqty  int64     `json:"orderqty"  xorm:"'ORDERQTY'" binding:"required"`   // 委托数量
+	Tradeqty  int64     `json:"tradeqty"  xorm:"'TRADEQTY'"`                      // 成交数量
+	Cancelqty int64     `json:"cancelqty"  xorm:"'CANCELQTY'"`                    // 撤单数量
 
 	Goodscode    string  `json:"goodscode"  xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
 	Goodsname    string  `json:"goodsname"  xorm:"'GOODSNAME'" binding:"required"` // 商品名称
@@ -750,9 +751,6 @@ type HsbySellMyDetail struct {
 	Vendorname string `json:"vendorname"  xorm:"'VENDORNAME'"` // 供应商名称
 
 	OrderType int32 `json:"ordertype" xorm:"'ORDERTYPE'"` // 单据类型:0 - 发布中, 1 - 已完成
-
-	PayedCount int `json:"payedcount" xorm:"PAYEDCOUNT"` // 已付款数量
-	UnPayCount int `json:"unPayCount" xorm:"UNPAYCOUNT"` // 待付款数量
 }
 
 // GetHsbySellMyOrderDetails 获取"我的闲置 - 发布中"单据信息
@@ -784,22 +782,19 @@ func GetHsbySellMyOrderDetails(accountIDs string) ([]HsbySellMyDetail, error) {
 	session := engine.Table("TRADE_ORDERDETAIL").
 		Select(`to_char(TRADE_ORDERDETAIL.ORDERID) ORDERID, 
 				TRADE_ORDERDETAIL.MARKETID, TRADE_ORDERDETAIL.GOODSID, TRADE_ORDERDETAIL.ACCOUNTID, TRADE_ORDERDETAIL.BUYORSELL,
-				TRADE_ORDERDETAIL.ORDERPRICE PRICE, TRADE_ORDERDETAIL.ORDERQTY QTY, TRADE_ORDERDETAIL.ORDERTIME TIME, 
-				(TRADE_ORDERDETAIL.ORDERPRICE * TRADE_ORDERDETAIL.ORDERQTY * GOODS.AGREEUNIT) AMOUNT, 
+				TRADE_ORDERDETAIL.ORDERPRICE PRICE, TRADE_ORDERDETAIL.ORDERTIME TIME, 
+				TRADE_ORDERDETAIL.ORDERQTY, TRADE_ORDERDETAIL.TRADEQTY, TRADE_ORDERDETAIL.CANCELQTY,
 				GOODS.GOODSCODE, GOODS.GOODSNAME, GOODS.DECIMALPLACE, GOODS.AGREEUNIT, 
 				HSBY_GOODSEX.PICURLS, 
 				MARKET.TRADEMODE, 
 				ENUMDICITEM.PARAM2 CURRENCYSIGN, 
 				HSBY_SUPPLIERINFO.VENDORNAME, 
-				0 ORDERTYPE, 
-				(select count(TR1.TRADEID) from TRADE_PAYORDER TR1 where TR1.PAYFLAG = 2 and TR1.TRADEID = TD.TRADEID) PAYEDCOUNT, 
-				(select count(TR2.TRADEID) from TRADE_PAYORDER TR2 where TR2.PAYFLAG = 1 and TR2.TRADEID = TD.TRADEID) UNPAYCOUNT`).
+				0 ORDERTYPE`).
 		Join("LEFT", "GOODS", "GOODS.GOODSID = TRADE_ORDERDETAIL.GOODSID").
 		Join("LEFT", "HSBY_GOODSEX", "HSBY_GOODSEX.GOODSID = GOODS.GOODSID").
 		Join("LEFT", "ENUMDICITEM", "GOODS.CURRENCYID = ENUMDICITEM.ENUMITEMNAME and ENUMDICITEM.ENUMDICCODE = 'currency'").
 		Join("LEFT", "MARKET", "MARKET.MARKETID = TRADE_ORDERDETAIL.MARKETID").
 		Join("LEFT", "HSBY_SUPPLIERINFO", "HSBY_SUPPLIERINFO.VENDORID = HSBY_GOODSEX.VENDORID").
-		Join("LEFT", "TRADE_TRADEDETAIL TD", "TD.ORDERID = TRADE_ORDERDETAIL.ORDERID").
 		Where(fmt.Sprintf(`TRADE_ORDERDETAIL.BUYORSELL = 1 and TRADE_ORDERDETAIL.LISTINGSELECTTYPE = 1 and (TRADE_ORDERDETAIL.ORDERSTATUS = 3 or TRADE_ORDERDETAIL.ORDERSTATUS = 7) 
 						   and TRADE_ORDERDETAIL.ACCOUNTID in (%s)`, accountIDs)).
 		And(fmt.Sprintf("TRADE_ORDERDETAIL.MARKETID in (%s)", marketIDs))
@@ -1120,7 +1115,7 @@ func GetHsbyBuyMyTradeDetails(accountIDs string) ([]HsbyBuyMyTradeDetail, error)
 	return orders, nil
 }
 
-// HsbyBuyMyPayOrder "我的订单 - 待付款"单据信息(一二级市场成交单和待付款信息)
+// HsbyBuyMyPayOrder "我的订单 - 待付款"单据信息(一二级市场待付款信息)
 type HsbyBuyMyPayOrder struct {
 	Tradeid        string    `json:"tradeid"  xorm:"'TRADEIDSTR'" binding:"required"` // 成交单号(101+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)
 	Tradedate      string    `json:"tradedate"  xorm:"'TRADEDATE'"`                   // 交易日(yyyyMMdd)
@@ -1249,33 +1244,54 @@ type HsbySellCollectionOrder struct {
 	Tradeqty       int64     `json:"tradeqty"  xorm:"'TRADEQTY'"`                     // 成交数量
 	Payamount      float64   `json:"payamount"  xorm:"'PAYAMOUNT'"`                   // 支付金额 = TradeAmount + TradeCharge - OffAmount
 
-	Customername string `json:"customername"  xorm:"'CUSTOMERNAME'"` // 客户名称(企业名称),已脱敏
+	Goodscode    string  `json:"goodscode"  xorm:"'GOODSCODE'" binding:"required"` // 商品代码(内部)
+	Goodsname    string  `json:"goodsname"  xorm:"'GOODSNAME'" binding:"required"` // 商品名称
+	Decimalplace int64   `json:"decimalplace"  xorm:"'DECIMALPLACE'"`              // 报价小数位
+	Agreeunit    float64 `json:"agreeunit"  xorm:"'AGREEUNIT'"`                    // 合约单位
 
-	Currencysign string `json:"currencysign" xorm:"CURRENCYSIGN"` // 货币符号
-	Goodunit     string `json:"goodunit"  xorm:"GOODUNIT"`        // 报价单位
+	Picurls string `json:"picurls"  xorm:"'PICURLS'"` // 商品介绍图片[多张用逗号分隔]
 
-	Agreeunit float64 `json:"agreeunit"  xorm:"'AGREEUNIT'"` // 合约单位
+	Trademode uint32 `json:"trademode"  xorm:"'TRADEMODE'" binding:"required"` // 交易模式 - 10:做市 13:竞价 15:通道交易 16:挂牌点选 17:仓单贸易 18:期权 19:竞拍-降价式 20:竞拍-竞价式 21:竞拍-大宗式 22:受托竞价
+
+	Currencysign string `json:"currencysign" xorm:"'CURRENCYSIGN'"` // 货币符号
 }
 
-// GetHsbySellCollectionOrders 获取我的闲置中收款信息
-func GetHsbySellCollectionOrders(sellOrderID, sellAccountID int) ([]HsbySellCollectionOrder, error) {
+// GetHsbySellCollectionOrders 获取我的闲置中待收款信息
+func GetHsbySellCollectionOrders(accountIDs string) ([]HsbySellCollectionOrder, error) {
+	// 获取市场信息
+	markets, err := GetMarkets()
+	if err != nil {
+		return nil, err
+	}
+
 	engine := db.GetEngine()
+	marketIDs := ""
+	// 默认取 TradeMode = 16
+	for _, v := range markets {
+		if v.Trademode == 16 {
+			if len(marketIDs) == 0 {
+				marketIDs = strconv.Itoa(int(v.Marketid))
+			} else {
+				marketIDs += "," + strconv.Itoa(int(v.Marketid))
+			}
+		}
+	}
 
 	orders := make([]HsbySellCollectionOrder, 0)
-	if err := engine.Table("TRADE_PAYORDER TP").
+	session := engine.Table("TRADE_PAYORDER TP").
 		Select(`to_char(TP.TRADEID) TRADEIDSTR, to_char(TP.BUYORDERID) BUYORDERIDSTR, to_char(TP.SELLORDERID) SELLORDERIDSTR, TP.*,
-				substr(U.CUSTOMERNAME,0,1)||'****' as CUSTOMERNAME,
-				E1.PARAM2 CURRENCYSIGN,
-				E1.ENUMDICNAME GOODUNIT,
-				G.AGREEUNIT`).
-		Join("LEFT", "TAACCOUNT TA", "TA.ACCOUNTID = TP.SELLACCOUNTID").
-		Join("LEFT", "USERINFO U", "U.USERID = TA.RELATEDUSERID").
+				G.GOODSCODE, G.GOODSNAME, G.DECIMALPLACE, G.AGREEUNIT, 
+				HG.PICURLS, 
+				M.TRADEMODE, 
+				E.PARAM2 CURRENCYSIGN`).
 		Join("LEFT", "GOODS G", "G.GOODSID = TP.GOODSID").
-		Join("LEFT", "ENUMDICITEM E1", "E1.ENUMITEMNAME = G.CURRENCYID and E1.ENUMDICCODE = 'currency'").
-		Join("LEFT", "ENUMDICITEM E2", "E2.ENUMITEMNAME = G.GOODUNITID and E2.ENUMDICCODE = 'goodsunit'").
-		Where("TP.PAYFLAG in (1,2) and TP.SELLORDERID = ?", sellOrderID).
-		And("TP.SELLACCOUNTID = ?", sellAccountID).
-		Find(&orders); err != nil {
+		Join("LEFT", "HSBY_GOODSEX HG", "HG.GOODSID = G.GOODSID").
+		Join("LEFT", "ENUMDICITEM E", "G.CURRENCYID = E.ENUMITEMNAME and E.ENUMDICCODE = 'currency'").
+		Join("LEFT", "MARKET M", "M.MARKETID = TP.MARKETID").
+		Join("LEFT", "HSBY_SUPPLIERINFO HS", "HS.VENDORID = HG.VENDORID").
+		Where(fmt.Sprintf(`TP.PAYFLAG = 1 and TP.SELLACCOUNTID in (%s)`, accountIDs)).
+		And(fmt.Sprintf("TP.MARKETID in (%s)", marketIDs))
+	if err := session.Find(&orders); err != nil {
 		return nil, err
 	}