Преглед изворни кода

查客户资料增加昵称字段
增加查现货损益报表接口

zou.yingbin пре 4 година
родитељ
комит
f05d41507a
9 измењених фајлова са 6529 додато и 8396 уклоњено
  1. 38 0
      controllers/ermcp/qryReport.go
  2. 1737 2496
      docs/docs.go
  3. 1737 2496
      docs/swagger.json
  4. 2869 3389
      docs/swagger.yaml
  5. 8 15
      models/ermcp.go
  6. 9 0
      models/ermcpCommon.go
  7. 127 0
      models/ermcpReport.go
  8. 3 0
      models/ermcpUser.go
  9. 1 0
      routers/router.go

+ 38 - 0
controllers/ermcp/qryReport.go

@@ -229,3 +229,41 @@ func QryReportMonthSpotDetail(c *gin.Context) {
 		BeginDate: t1, EndDate: t2}
 	a.DoGetDataEx(&m)
 }
+
+// QueryReportAreaSpotPLReq
+type QueryReportAreaSpotPLReq struct {
+	USERID           int64  `form:"userid" binding:"required"`    // 用户id
+	WRSTANDARDID     int64  `form:"wrstandardid"`                 // 现货商品ID
+	SPOTGOODSBRANDID int32  `form:"spotgoodsbrandid"`             // 品牌ID
+	SPOTGOODSMODELID int32  `form:"spotgoodsmodelid"`             // 型号ID
+	QUERYTYPE        int32  `form:"querytype" binding:"required"` // 查询类型 1-日报表(或明细) 2-月报表(或明细)
+	QUERYDATE        string `form:"querydate" binding:"required"` // 查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)
+}
+
+// QryReportAreaSpotPL
+// @Summary 查询现货损益报表(现货损益报表)
+// @Produce json
+// @Security ApiKeyAuth
+// @Param userid query int true "用户ID"
+// @Param querytype query int true "查询类型 1-日报表 2-月报表"
+// @Param querydate query string true "查询日期(格式 日报表YYYYMMDD, 月报表YYYYMM)"
+// @Param wrstandardid query int false "现货商品ID"
+// @Param spotgoodsbrandid query int false "品牌ID"
+// @Param spotgoodsmodelid query int false "型号ID"
+// @Success 200 {array} models.ErmcpReportAreaSpotPL
+// @Failure 500 {object} app.Response
+// @Router /Ermcp/QryReportAreaSpotPL [get]
+// @Tags 企业风险管理(app)
+func QryReportAreaSpotPL(c *gin.Context) {
+	a := app.GinUtils{Gin: app.Gin{C: c}}
+	req := QueryReportAreaSpotPLReq{}
+	a.DoBindReq(&req)
+	if QueryDate(req.QUERYDATE).IsNumberic(req.QUERYTYPE) {
+		m := models.ErmcpReportAreaSpotPL{AREAUSERID: req.USERID, WRSTANDARDID: req.WRSTANDARDID,
+			SPOTGOODSBRANDID: req.SPOTGOODSBRANDID, SPOTGOODSMODELID: req.SPOTGOODSMODELID,
+			ReportDate: req.QUERYDATE, ReportType: req.QUERYTYPE}
+		a.DoGetDataI(&m)
+	} else {
+		a.Gin.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+	}
+}

Разлика између датотеке није приказан због своје велике величине
+ 1737 - 2496
docs/docs.go


Разлика између датотеке није приказан због своје велике величине
+ 1737 - 2496
docs/swagger.json


Разлика између датотеке није приказан због своје велике величине
+ 2869 - 3389
docs/swagger.yaml


+ 8 - 15
models/ermcp.go

@@ -295,7 +295,7 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		"       t.pricedamount + t.ReckonAdjustAmount as LoanAmount" +
 		"  from ermcp_spotcontract t" +
 		"  left join useraccount u" +
-		"    on t.%v = u.userid" +
+		"    on t.userid = u.userid" +
 		"  left join deliverygoods g" +
 		"    on t.deliverygoodsid = g.deliverygoodsid" +
 		"  left join goods g2" +
@@ -314,32 +314,25 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
 		str += fmt.Sprintf(" and t.SpotContractId=%v", r.SpotContractId)
 	}
 
+	var orderBy string
 	var status string
 	if 1 == nQueryType {
 		// 全部
 		status = "2,3"
-		str = str + " order by t.audittime desc"
+		orderBy = " order by t.audittime desc"
 	} else if 2 == nQueryType {
 		// 待点价
 		status = "2"
-		str = str + "  and t.qty - t.pricedqty > 0 and t.pricetype !=1 " +
-			"order by unpricedqty desc, t.audittime desc"
+		str = str + " and t.qty - t.pricedqty > 0 and t.pricetype !=1 "
+		orderBy = " order by unpricedqty desc, t.audittime desc"
 	} else {
 		// 履约
 		status = "2"
-		str = str + " order by t.audittime desc"
+		orderBy = " order by t.audittime desc"
 	}
 
-	var usrId string
-
-	switch nContractType {
-	case 1: // 采购
-		usrId = "buyuserid"
-	case -1: // 销售
-		usrId = "selluserid"
-	}
-
-	sqlId := fmt.Sprintf(str, usrId, status, nContractType, r.UserID)
+	str += orderBy
+	sqlId := fmt.Sprintf(str, status, nContractType, r.UserID)
 
 	return sqlId
 }

+ 9 - 0
models/ermcpCommon.go

@@ -12,6 +12,15 @@ import (
 	"mtp2_if/utils"
 )
 
+type ReportType int
+
+const (
+	_ ReportType = iota
+
+	RTypeDay   // 日报表
+	RTypeMonth // 月报表
+)
+
 // IErmcp 通用接口
 type IErmcp interface {
 	calc()                           // 相关计算和数据处理

+ 127 - 0
models/ermcpReport.go

@@ -561,3 +561,130 @@ func (r *ErmcpReportMonSpot) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// ErmcpReportAreaSpotPL 现货损益日/月表
+type ErmcpReportAreaSpotPL struct {
+	AREAUSERID            int64   `json:"areauserid"  xorm:"'AREAUSERID'"`                       // 所属机构
+	WRSTANDARDID          int64   `json:"wrstandardid"  xorm:"'WRSTANDARDID'"`                   // 现货商品ID
+	SPOTGOODSMODELID      int32   `json:"spotgoodsmodelid"  xorm:"'SPOTGOODSMODELID'"`           // 现货品类ID
+	SPOTGOODSBRANDID      int32   `json:"spotgoodsbrandid"  xorm:"'SPOTGOODSBRANDID'"`           // 现货品牌ID
+	ORIBUYQTY             float64 `json:"oribuyqty"  xorm:"'ORIBUYQTY'"`                         // 期初采购总量
+	ORIBUYAMOUNT          float64 `json:"oribuyamount"  xorm:"'ORIBUYAMOUNT'"`                   // 期初采购总额
+	ORISELLQTY            float64 `json:"orisellqty"  xorm:"'ORISELLQTY'"`                       // 期初销售总量
+	ORISELLAMOUNT         float64 `json:"orisellamount"  xorm:"'ORISELLAMOUNT'"`                 // 期初销售总额
+	ORIQTY                float64 `json:"oriqty"  xorm:"'ORIQTY'"`                               // 期初量
+	ORIAVERAGEPRICE       float64 `json:"oriaverageprice"  xorm:"'ORIAVERAGEPRICE'"`             // 期初均价
+	ORIAMOUNT             float64 `json:"oriamount"  xorm:"'ORIAMOUNT'"`                         // 期初额
+	TODAYBUYQTY           float64 `json:"todaybuyqty"  xorm:"'TODAYBUYQTY'"`                     // 今日采购量(采购增量)
+	TODAYBUYAMOUNT        float64 `json:"todaybuyamount"  xorm:"'TODAYBUYAMOUNT'"`               // 今日采购额
+	TODAYBUYAVERAGEPRICE  float64 `json:"todaybuyaverageprice"  xorm:"'TODAYBUYAVERAGEPRICE'"`   // 今日采购均价(采购均价)
+	TODAYSELLQTY          float64 `json:"todaysellqty"  xorm:"'TODAYSELLQTY'"`                   // 今日销售量(销售增量)
+	TODAYSELLAMOUNT       float64 `json:"todaysellamount"  xorm:"'TODAYSELLAMOUNT'"`             // 今日销售额
+	TODAYSELLAVERAGEPRICE float64 `json:"todaysellaverageprice"  xorm:"'TODAYSELLAVERAGEPRICE'"` // 今日销售均价(销售均价)
+	CURBUYQTY             float64 `json:"curbuyqty"  xorm:"'CURBUYQTY'"`                         // 期末采购总量
+	CURBUYAMOUNT          float64 `json:"curbuyamount"  xorm:"'CURBUYAMOUNT'"`                   // 期末采购总额(采购额)
+	CURSELLQTY            float64 `json:"cursellqty"  xorm:"'CURSELLQTY'"`                       // 期末销售总量
+	CURSELLAMOUNT         float64 `json:"cursellamount"  xorm:"'CURSELLAMOUNT'"`                 // 期末销售总额(销售额)
+	CURQTY                float64 `json:"curqty"  xorm:"'CURQTY'"`                               // 期末量
+	CURAVERAGEPRICE       float64 `json:"curaverageprice"  xorm:"'CURAVERAGEPRICE'"`             // 期末均价
+	CURAMOUNT             float64 `json:"curamount"  xorm:"'CURAMOUNT'"`                         // 期末额
+	CURSPOTPRICE          float64 `json:"curspotprice"  xorm:"'CURSPOTPRICE'"`                   // 参考市价
+	CURMARKETVALUE        float64 `json:"curmarketvalue"  xorm:"'CURMARKETVALUE'"`               // 参考市值
+	ACTUALPL              float64 `json:"actualpl"  xorm:"'ACTUALPL'"`                           // 实际损益
+	FLOATPL               float64 `json:"floatpl"  xorm:"'FLOATPL'"`                             // 浮动损益
+	UPDATETIME            string  `json:"updatetime"  xorm:"'UPDATETIME'"`                       // 更新时间
+	WRSTANDARDCODE        string  `json:"wrstandardcode"  xorm:"'WRSTANDARDCODE'"`               // 现货商品代码
+	WRSTANDARDNAME        string  `json:"wrstandardname"  xorm:"'WRSTANDARDNAME'"`               // 现货商品名称
+	UNITID                int32   `json:"unitid"  xorm:"'UNITID'"`                               // 现货商品单位id
+	BRANDNAME             string  `json:"brandname"  xorm:"'BRANDNAME'"`                         // 品牌名称
+	MODELNAME             string  `json:"modelname"  xorm:"'MODELNAME'"`                         // 品类名称
+	GBUNITID              int32   `json:"gbunitid"  xorm:"'GBUNITID'"`                           // 品类单位id
+
+	ENUMDICNAME   string `json:"enumdicname"`   // 现货商品单位名称
+	GBENUMDICNAME string `json:"gbenumdicname"` // 品类单位名称
+
+	ReportType int32  `json:"-"` // 报表类型 1-日报表 2-月报表
+	ReportDate string `json:"-"` // 格式 日报表(YYYYMMDD) 月报表(YYYYMM)
+}
+
+func (r *ErmcpReportAreaSpotPL) calc() {
+	r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
+	r.GBENUMDICNAME = mtpcache.GetEnumDicitemName(r.GBUNITID)
+}
+
+func (r *ErmcpReportAreaSpotPL) buildSql() string {
+	var sqlId utils.SQLVal = "SELECT t.AREAUSERID," +
+		"       t.WRSTANDARDID," +
+		"       t.SPOTGOODSMODELID," +
+		"       t.SPOTGOODSBRANDID," +
+		"       t.ORIBUYQTY," +
+		"       t.ORIBUYAMOUNT," +
+		"       t.ORISELLQTY," +
+		"       t.ORISELLAMOUNT," +
+		"       t.ORIQTY," +
+		"       t.ORIAVERAGEPRICE," +
+		"       t.ORIAMOUNT," +
+		"       t.TODAYBUYQTY," +
+		"       t.TODAYBUYAMOUNT," +
+		"       t.TODAYBUYAVERAGEPRICE," +
+		"       t.TODAYSELLQTY," +
+		"       t.TODAYSELLAMOUNT," +
+		"       t.TODAYSELLAVERAGEPRICE," +
+		"       t.CURBUYQTY," +
+		"       t.CURBUYAMOUNT," +
+		"       t.CURSELLQTY," +
+		"       t.CURSELLAMOUNT," +
+		"       t.CURQTY," +
+		"       t.CURAVERAGEPRICE," +
+		"       t.CURAMOUNT," +
+		"       t.CURSPOTPRICE," +
+		"       t.CURMARKETVALUE," +
+		"       t.ACTUALPL," +
+		"       t.FLOATPL," +
+		"       to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
+		"       w.wrstandardcode," +
+		"       w.wrstandardname," +
+		"       w.unitid," +
+		"       gb.brandname," +
+		"       gm.modelname," +
+		"       gm.unitid gbunitid" +
+		"  FROM %v t" +
+		"  left join wrstandard w" +
+		"    on t.wrstandardid = w.wrstandardid" +
+		"  left join spotgoodsbrand gb" +
+		"    on t.spotgoodsbrandid = gb.brandid" +
+		"  left join spotgoodsmodel gm" +
+		"    on t.spotgoodsmodelid = gm.modelid" +
+		" WHERE 1 = 1"
+	sqlId.And("t.AREAUSERID", r.AREAUSERID)
+	if r.ReportType == 1 {
+		// 日报表
+		sqlId.FormatParam("RECKON_ERMCP_AREASPOTPL")
+		sqlId.And("t.reckondate", r.ReportDate)
+	} else {
+		// 月报表
+		sqlId.FormatParam("REPORT_ERMCP_AREASPOTPL")
+		sqlId.And("t.cycletype", 1)
+		sqlId.And("t.cycletime", r.ReportDate)
+	}
+	if r.WRSTANDARDID > 0 {
+		sqlId.And("t.wrstandardid", r.WRSTANDARDID)
+	}
+	if r.SPOTGOODSBRANDID > 0 {
+		sqlId.And("t.spotgoodsbrandid", r.SPOTGOODSBRANDID)
+	}
+	if r.SPOTGOODSMODELID > 0 {
+		sqlId.And("t.spotgoodsmodelid", r.SPOTGOODSMODELID)
+	}
+	return sqlId.String()
+}
+
+// GetDataEx 获取现货损益日(月)报表
+func (r *ErmcpReportAreaSpotPL) GetDataEx() (interface{}, error) {
+	sData := make([]ErmcpReportAreaSpotPL, 0)
+	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	for i := range sData {
+		sData[i].calc()
+	}
+	return sData, err
+}

+ 3 - 0
models/ermcpUser.go

@@ -38,6 +38,7 @@ type ErmcpUserModel struct {
 	CREATETIME        string `json:"createtime"  xorm:"'CREATETIME'"`               // 创建时间
 	MODIFYTIME        string `json:"modifytime"  xorm:"'MODIFYTIME'"`               // 修改时间
 	AUDITTIME         string `json:"audittime"  xorm:"'AUDITTIME'"`                 // 审核时间
+	NICKNAME          string `json:"nickname"  xorm:"'NICKNAME'"`                   // 昵称
 }
 
 func (r *ErmcpUserModel) buildWskhSql(accStatus string) string {
@@ -45,6 +46,7 @@ func (r *ErmcpUserModel) buildWskhSql(accStatus string) string {
 		"       t.memberareaid      MEMBERUSERID," +
 		"       t.USERINFOTYPE," +
 		"       t.CUSTOMERNAME," +
+		"       t.NICKNAME," +
 		"       t.CARDTYPE," +
 		"       e.enumdicname       CARDTYPENAME," +
 		"       t.CARDNUM," +
@@ -78,6 +80,7 @@ func (r *ErmcpUserModel) buildSql(accStatus string) string {
 		"       t.memberuserid," +
 		"       u.USERINFOTYPE," +
 		"       u.CUSTOMERNAME," +
+		"       u.NICKNAME," +
 		"       u.CARDTYPEID        CARDTYPE," +
 		"       e.enumdicname       CARDTYPENAME," +
 		"       u.CARDNUM," +

+ 1 - 0
routers/router.go

@@ -361,6 +361,7 @@ func InitRouter() *gin.Engine {
 		ermcpR.GET("/QryReportDaySpotDetail", ermcp.QryReportDaySpotDetail)
 		ermcpR.GET("/QryReportMonthSpot", ermcp.QryReportMonthSpot)
 		ermcpR.GET("/QryReportMonthSpotDetail", ermcp.QryReportMonthSpotDetail)
+		ermcpR.GET("/QryReportAreaSpotPL", ermcp.QryReportAreaSpotPL)
 		ermcpR.GET("/QueryExposureHedgePositionDetail", ermcp.QueryExposureHedgePositionDetail)
 		ermcpR.GET("/QueryPendingAuditInfo", ermcp.QueryPendingAuditInfo)
 		ermcpR.GET("/QueryWarehouseInfo", ermcp.QueryWarehouseInfo)

Неке датотеке нису приказане због велике количине промена