소스 검색

修改BUG

Simon Zhou 5 년 전
부모
커밋
68d006a910
1개의 변경된 파일11개의 추가작업 그리고 15개의 파일을 삭제
  1. 11 15
      controllers/cptrade/cpTrade.go

+ 11 - 15
controllers/cptrade/cpTrade.go

@@ -8,7 +8,6 @@ import (
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
 	"net/http"
-	"strings"
 	"time"
 
 	"github.com/gin-gonic/gin"
@@ -418,21 +417,20 @@ func QueryPresaleGoodsEx(c *gin.Context) {
 			left join goods g on t.GoodsID = g.goodsid
 			left join enumdicitem e on g.goodunitid = e.enumitemname and e.enumdiccode = 'goodsunit'
 			where 1=1 `
-	s := engine.SQL(sql)
 	if req.GoodsID > 0 {
-		s = s.And("GoodsID=?", req.GoodsID)
+		sql += fmt.Sprintf(" and t.GoodsID = %d", req.GoodsID)
 	}
 	if req.MarketID > 0 {
-		s = s.And("MarketID=?", req.MarketID)
+		sql += fmt.Sprintf(" and t.MarketID = %d", req.MarketID)
 	}
 	if req.PresaleMode > 0 {
-		s = s.And("PresaleMode=?", req.PresaleMode)
+		sql += fmt.Sprintf(" and t.PresaleMode = %d", req.PresaleMode)
 	}
 	if len(req.GoodsIDs) > 0 {
 		// s = s.And("GoodsID in (?)", req.GoodsIDs)
-		s = s.In("GOODSID", strings.Split(req.GoodsIDs, ","))
+		sql += fmt.Sprintf(" and t.GoodsID in (%s)", req.GoodsIDs)
 	}
-	if err := s.Find(&datas); err != nil {
+	if err := engine.SQL(sql).Find(&datas); err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("QueryPresaleGoodsEx failed: %s", err.Error())
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
@@ -514,21 +512,19 @@ func QueryCPTradeMyBidInfos(c *gin.Context) {
 						from Trade_OrderDetail t
 						left join Trade_TradeDetail td on t.orderid = td.OrderID
 						left join goods g on t.goodsid = g.goodsid
-						left join enumdicitem e on g.goodunitid = e.enumitemname and e.enumdiccode = 'goodsunit'
-						where t.BuyOrSell = 0 and t.BuildType = 1 and t.PriceMode = 2 
-							and t.AccountID = %d`, req.AccountID)
-	s := engine.SQL(sql)
+						left join enumdicitem e on g.goodunitid = e.enumitemname and e.enumdiccode = 'goodsunit' 
+						where t.BuyOrSell = 0 and t.BuildType = 1 and t.PriceMode = 2 and t.AccountID = %d`, req.AccountID)
 	if req.GoodsID > 0 {
-		s = s.And("GoodsID=?", req.GoodsID)
+		sql += fmt.Sprintf(" and t.GoodsID = %d", req.GoodsID)
 	}
 	if req.MarketID > 0 {
-		s = s.And("MarketID=?", req.MarketID)
+		sql += fmt.Sprintf(" and t.MarketID = %d", req.MarketID)
 	} else {
 		// 如果没有传市场ID,则肯定查询预售一口价挂牌(40)和预售大宗竞拍(41)两个市场的数据
 		// FIXME: 目前暂时直接写死市场ID
-		s = s.In("MarketID", []string{"40201", "41201"})
+		sql += fmt.Sprintf(" and t.MarketID in (%s)", "40201,41201")
 	}
-	if err := s.Find(&datas); err != nil {
+	if err := engine.SQL(sql).Find(&datas); err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("QueryCPTradeMyBidInfos failed: %s", err.Error())
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)