zhou.xiaoning 3 лет назад
Родитель
Сommit
078f139394
2 измененных файлов с 25 добавлено и 19 удалено
  1. 14 13
      controllers/ferroalloy/trade.go
  2. 11 6
      models/ferroalloy.go

+ 14 - 13
controllers/ferroalloy/trade.go

@@ -11,12 +11,12 @@ import (
 // @Summary  查询我的订单-采购订单
 // @Produce  json
 // @Security ApiKeyAuth
-// @Param    userid       query    int true  "用户ID"
+// @Param    userid    query    int true  "用户ID"
 // @Param    type     query    int false "类型 - 0:未完成 1:已完成"
-// @Param    page         query    int false "页码"
-// @Param    pagesize     query    int false "每页条数"
+// @Param    page      query    int false "页码"
+// @Param    pagesize  query    int false "每页条数"
 // @Success  200      {array}  models.Thjpurchasetradedetail
-// @Failure  500          {object} app.Response
+// @Failure  500       {object} app.Response
 // @Router   /Ferroalloy/QueryTHJPurchaseTradeDetail [get]
 // @Tags     铁合金
 func QueryTHJPurchaseTradeDetail(c *gin.Context) {
@@ -30,12 +30,12 @@ func QueryTHJPurchaseTradeDetail(c *gin.Context) {
 // @Summary  获取我的推广-交易数据
 // @Produce  json
 // @Security ApiKeyAuth
-// @Param    userid   query    int    true  "用户ID"
+// @Param    userid       query    int true  "用户ID"
 // @Param    marketid query    int true  "市场ID 采购-64201 供求-65201"
-// @Param    page     query    int    false "页码"
-// @Param    pagesize query    int    false "每页条数"
+// @Param    page         query    int false "页码"
+// @Param    pagesize     query    int false "每页条数"
 // @Success  200      {array}  models.THJTradeData
-// @Failure  500      {object} app.Response
+// @Failure  500          {object} app.Response
 // @Router   /Ferroalloy/QueryTHJTradeData [get]
 // @Tags     铁合金
 func QueryTHJTradeData(c *gin.Context) {
@@ -46,13 +46,14 @@ func QueryTHJTradeData(c *gin.Context) {
 }
 
 // QueryTHJPurchaseTransferOrder
-// @Summary  查询我的订单-转让订单
+// @Summary  查询我的订单-转让/受让订单
 // @Produce  json
 // @Security ApiKeyAuth
-// @Param    userid   query    int true  "用户ID"
-// @Param    page     query    int false "页码"
-// @Param    pagesize query    int false "每页条数"
-// @Success  200      {array}  models.Thjpurchasetransfer
+// @Param    userid   query    int    true  "用户ID"
+// @Param    ordertype query    int true  "类型 - 1:转让 2:受让"
+// @Param    page     query    int    false "页码"
+// @Param    pagesize query    int    false "每页条数"
+// @Success  200       {array}  models.Thjpurchasetransfer
 // @Failure  500      {object} app.Response
 // @Router   /Ferroalloy/QueryTHJPurchaseTransferOrder [get]
 // @Tags     铁合金

+ 11 - 6
models/ferroalloy.go

@@ -1231,7 +1231,8 @@ type Thjpurchasetransfer struct {
 	TRANSFERSTATUS           int32   `json:"transferstatus" xorm:"TRANSFERSTATUS"`                     // 转让状态 - 1:挂牌中 2:已撤销 3:处理中 4:已转让
 	HANDLESTATUS             int32   `json:"handlestatus" xorm:"HANDLESTATUS"`                         // 处理状态
 
-	USERID int64 `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
+	USERID    int64 `json:"-" xorm:"-" form:"userid" binding:"required"`    // 用户ID
+	ORDERTYPE int   `json:"-" xorm:"-" form:"ordertype" binding:"required"` // 类型 - 1:转让 2:受让
 
 	PageEx `xorm:"extends"` // 页码信息
 }
@@ -1273,9 +1274,13 @@ func (r *Thjpurchasetransfer) buildSql() string {
 	from THJ_PurchaseTransfer t
 	inner join THJ_PurchaseTradeDetail p on t.wrtradedetailid = p.wrtradedetailid
 	inner join wrstandard wr on t.wrstandardid = wr.wrstandardid
-	where t.selluserid = %v and t.transferstatus = 1
+	where %v and t.transferstatus = 1
 `
-	sqlId.FormatParam(r.USERID)
+	param := fmt.Sprintf("t.selluserid = %v", r.USERID)
+	if r.ORDERTYPE == 2 {
+		param = fmt.Sprintf("t.buyuserid = %v", r.USERID)
+	}
+	sqlId.FormatParam(param)
 
 	sqlId.Page(r.Page, r.PageSize)
 	return sqlId.String()
@@ -1314,13 +1319,13 @@ func (r *PromotionIncome) buildSql() string {
 	select 
 		substr(t.reckondate, 0, 6) PROFITMONTH,
 		t.WRSTANDARDID,
-		wr.WRSTANDARDCODE
+		wr.WRSTANDARDCODE,
 		wr.WRSTANDARDNAME,
 		sum(t.profitamount) SUMAMOUNT
 	from THJ_Reckon_ProfitSum t
 	left join wrstandard wr on t.wrstandardid = wr.wrstandardid
 	where t.userid = %v and %v
-	group by substr(t.reckondate, 0, 6), t.wrstandardid, wr.wrstandardname
+	group by substr(t.reckondate, 0, 6), t.wrstandardid, wr.WRSTANDARDCODE, wr.wrstandardname
 	order by substr(t.reckondate, 0, 6) desc, t.wrstandardid, wr.wrstandardname
 `
 	param := "1=1"
@@ -1367,7 +1372,7 @@ func (r *PromotionIncomeDetail) calc() {
 func (r *PromotionIncomeDetail) buildSql() string {
 	var sqlId utils.SQLVal = `
 	select 
-		to_char(t.TRADETIME,'yyyy-mm-dd hh24:mi:ss) TRADETIME', 
+		to_char(t.TRADETIME,'yyyy-mm-dd hh24:mi:ss') TRADETIME, 
 		wr.WRSTANDARDID,
 		wr.WRSTANDARDCODE,
 		wr.WRSTANDARDNAME,