|
|
@@ -972,7 +972,7 @@ func (r *WrSpecialMatchOrder) buildSql() string {
|
|
|
" left join tmp k" +
|
|
|
" on t.wrfactortypeid = k.wrfactortypeid" +
|
|
|
" where t.WRTRADETYPE = 1" +
|
|
|
- " and t.isspecified = 1" +
|
|
|
+ " and t.isspecified in (1,2)" +
|
|
|
" and t.WRTRADEORDERSTATUS = 3"
|
|
|
sqlId.And("t.USERID", r.USERID)
|
|
|
sqlId.And("t.haswr", r.HASWR)
|
|
|
@@ -3589,3 +3589,310 @@ func (r *WrUserReceiptInfo) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
|
return sData, err
|
|
|
}
|
|
|
+
|
|
|
+// WrSiteColumnDetail 资讯
|
|
|
+type WrSiteColumnDetail struct {
|
|
|
+ ID int64 `json:"id" xorm:"ID" form:"id"` // ID(SEQ_SITE_COLUMNDETAIL)
|
|
|
+ COLUMNID int64 `json:"-" xorm:"COLUMNID" form:"columnid"` // 所属栏目
|
|
|
+ USERID int64 `json:"-" xorm:"USERID" form:"userid"` // 用户ID(默认为0, 核心为为机构用户ID)
|
|
|
+ TITLE string `json:"title" xorm:"TITLE"` // 标题
|
|
|
+ COVERIMAGE string `json:"coverimage" xorm:"COVERIMAGE"` // 封面图片
|
|
|
+ AUTHOR string `json:"-" xorm:"AUTHOR"` // 作者
|
|
|
+ BRIEF string `json:"brief" xorm:"BRIEF"` // 简介
|
|
|
+ CONTEXT string `json:"context" xorm:"CONTEXT"` // 内容
|
|
|
+ STATUS int32 `json:"-" xorm:"STATUS"` // 状态 - 1:暂存 10:待审核 20:审核通过 30:审核拒绝
|
|
|
+ ISTOP int32 `json:"istop" xorm:"ISTOP"` // 是否置顶 - 0:不置 1:置顶
|
|
|
+ HITS int64 `json:"-" xorm:"HITS"` // 点击数
|
|
|
+ PUBLISHDATE string `json:"publishdate" xorm:"PUBLISHDATE" form:"publishdate"` // 发布日期
|
|
|
+ CREAEDATE string `json:"creaedate" xorm:"CREAEDATE" form:"creaedate"` // 创建时间
|
|
|
+ CREATORID int64 `json:"-" xorm:"CREATORID" form:"creatorid"` // 创建人
|
|
|
+ UPDATEDATE string `json:"updatedate" xorm:"UPDATEDATE" form:"updatedate"` // 修改时间
|
|
|
+ MODIFIERID int64 `json:"-" xorm:"MODIFIERID" form:"modifierid"` // 操作人
|
|
|
+ ISSHOW int32 `json:"-" xorm:"ISSHOW"` // 是否展示 - 0:不展示 1:展示
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrSiteColumnDetail) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrSiteColumnDetail) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+SELECT t.ID,
|
|
|
+ t.COLUMNID,
|
|
|
+ t.USERID,
|
|
|
+ t.TITLE,
|
|
|
+ t.COVERIMAGE,
|
|
|
+ t.AUTHOR,
|
|
|
+ t.BRIEF,
|
|
|
+ t.CONTEXT,
|
|
|
+ t.STATUS,
|
|
|
+ t.ISTOP,
|
|
|
+ t.HITS,
|
|
|
+ to_char(t.PUBLISHDATE, 'yyyy-mm-dd hh24:mi:ss') PUBLISHDATE,
|
|
|
+ to_char(t.CREAEDATE, 'yyyy-mm-dd hh24:mi:ss') CREAEDATE,
|
|
|
+ t.CREATORID,
|
|
|
+ to_char(t.UPDATEDATE, 'yyyy-mm-dd hh24:mi:ss') UPDATEDATE,
|
|
|
+ t.MODIFIERID,
|
|
|
+ t.ISSHOW
|
|
|
+ FROM SITE_COLUMNDETAIL t
|
|
|
+ WHERE 1 = 1 and t.isshow = 1 and t.status = 20
|
|
|
+ order by t.istop desc, t.updatedate desc
|
|
|
+`
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataByPage 获取资讯
|
|
|
+func (r *WrSiteColumnDetail) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]WrSiteColumnDetail, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ if len(sData) > 0 {
|
|
|
+ r.Total = sData[0].Total
|
|
|
+ }
|
|
|
+ return sData, err, r.Page, r.PageSize, r.Total
|
|
|
+}
|
|
|
+
|
|
|
+// WrDeliveryGoodsSection 板块(分类)
|
|
|
+type WrDeliveryGoodsSection struct {
|
|
|
+ SECTIONID int64 `json:"sectionid" xorm:"SECTIONID" form:"sectionid"` // 版块ID (SEQ_DELIVERYGOODSSECTION) - 自增100开始, 前面ID预留给SectionType = 1的版块1 - 云融指数
|
|
|
+ SECTIONTYPE int32 `json:"sectiontype" xorm:"SECTIONTYPE"` // 版块类型 - 1:指数版块 2:普通版块
|
|
|
+ SECTIONNAME string `json:"sectionname" xorm:"SECTIONNAME"` // 版块名称
|
|
|
+ ORDERINDEX int32 `json:"orderindex" xorm:"ORDERINDEX"` // 排序
|
|
|
+ SHOWFLAG int32 `json:"-" xorm:"SHOWFLAG"` // 是否展示 - 0:不展示 1:展示
|
|
|
+ CREATORSRC int32 `json:"-" xorm:"CREATORSRC"` // 申请来源 - 1:管理端 2:终端 3:交易
|
|
|
+ CREATORID int64 `json:"-" xorm:"CREATORID" form:"creatorid"` // 创建人
|
|
|
+ CREATETIME string `json:"-" xorm:"CREATETIME"` // 创建时间
|
|
|
+ IMAGEPATH string `json:"imagepath" xorm:"IMAGEPATH"` // 图片地址
|
|
|
+
|
|
|
+ DGLst []WrDeliveryGoodsSectionConfig `json:"dglst"` // 板块商品列表
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrDeliveryGoodsSection) calc() {
|
|
|
+ r.DGLst = make([]WrDeliveryGoodsSectionConfig, 0)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrDeliveryGoodsSection) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+select t.sectionid,
|
|
|
+ t.sectiontype,
|
|
|
+ t.sectionname,
|
|
|
+ t.orderindex,
|
|
|
+ t.showflag,
|
|
|
+ t.creatorsrc,
|
|
|
+ t.creatorid,
|
|
|
+ to_char(t.createtime,'yyyy-mm-dd hh24:mi:ss') createtime,
|
|
|
+ t.imagepath
|
|
|
+ from DeliveryGoodsSection t
|
|
|
+ where t.sectiontype = 2
|
|
|
+ and t.showflag = 1
|
|
|
+ order by t.orderindex
|
|
|
+`
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取板块(分类)
|
|
|
+func (r *WrDeliveryGoodsSection) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]WrDeliveryGoodsSection, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ // 获取商品
|
|
|
+ m := WrDeliveryGoodsSectionConfig{}
|
|
|
+ if d, err := m.GetDataEx(); err == nil {
|
|
|
+ lst := d.([]WrDeliveryGoodsSectionConfig)
|
|
|
+ for i := range sData {
|
|
|
+ for _, v := range lst {
|
|
|
+ if sData[i].SECTIONID == v.SECTIONID {
|
|
|
+ sData[i].DGLst = append(sData[i].DGLst, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|
|
|
+
|
|
|
+// WrDeliveryGoodsSectionConfig 板块商品
|
|
|
+type WrDeliveryGoodsSectionConfig struct {
|
|
|
+ SECTIONID int64 `json:"-" xorm:"'SECTIONID'"` // 版块ID (SEQ_DELIVERYGOODSSECTION)
|
|
|
+ DELIVERYGOODSID int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID(SEQ_DELIVERYGOODS)
|
|
|
+ ORDERINDEX int32 `json:"orderindex" xorm:"'ORDERINDEX'"` // 排序
|
|
|
+ CREATORSRC int32 `json:"-" xorm:"'CREATORSRC'"` // 申请来源 - 1:管理端 2:终端 3:交易
|
|
|
+ CREATORID int32 `json:"-" xorm:"'CREATORID'"` // 创建人
|
|
|
+ CREATEDATE string `json:"-" xorm:"'CREATEDATE'"` // 创建时间
|
|
|
+ DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
|
|
|
+ DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrDeliveryGoodsSectionConfig) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrDeliveryGoodsSectionConfig) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+select t.sectionid,
|
|
|
+ t.deliverygoodsid,
|
|
|
+ t.orderindex,
|
|
|
+ t.creatorsrc,
|
|
|
+ t.creatorid,
|
|
|
+ to_char(t.createdate, 'yyyy-mm-dd hh24:mi:ss') createdate,
|
|
|
+ g.deliverygoodscode,
|
|
|
+ g.deliverygoodsname
|
|
|
+ from DeliveryGoodsSectionConfig t
|
|
|
+ inner join deliverygoods g
|
|
|
+ on t.deliverygoodsid = g.deliverygoodsid
|
|
|
+ inner join Deliverygoodssection s
|
|
|
+ on t.sectionid = s.sectionid
|
|
|
+ where t.sectionid = 1
|
|
|
+ and t.showflag = 1
|
|
|
+ and s.showflag = 1
|
|
|
+ and g.dgstatus = 1
|
|
|
+ order by t.sectionid, t.orderindex
|
|
|
+`
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取板块商品
|
|
|
+func (r *WrDeliveryGoodsSectionConfig) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]WrDeliveryGoodsSectionConfig, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|
|
|
+
|
|
|
+// WrSpotGroupTradeSum 指数
|
|
|
+type WrSpotGroupTradeSum struct {
|
|
|
+ RECKONDATE string `json:"reckondate" xorm:"'RECKONDATE'"` // 上个交易日(前1天交易日)
|
|
|
+ LASTRECKONDATE string `json:"lastreckondate" xorm:"'LASTRECKONDATE'"` // 上上个交易日(前2天交易日)
|
|
|
+ MARKETID int64 `json:"-" xorm:"'MARKETID'" form:"marketid"` // 市场id
|
|
|
+ TRADEQTY float64 `json:"-" xorm:"'TRADEQTY'"` // 成交量
|
|
|
+ TRADEAMOUNT float64 `json:"-" xorm:"'TRADEAMOUNT'"` // 成交额
|
|
|
+ LASTAVGPRICE float64 `json:"-" xorm:"'LASTAVGPRICE'"` // 上上个交易日价格(前2天价格)
|
|
|
+ TODAYAVGPRICE float64 `json:"-" xorm:"'TODAYAVGPRICE'"` // 上个交易日价格(前1天价格)
|
|
|
+ DELIVERYGOODSID int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID(SEQ_DELIVERYGOODS)
|
|
|
+ DELIVERYGOODSCODE string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货品种代码
|
|
|
+ DELIVERYGOODSNAME string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货品种名称
|
|
|
+ SECTIONID int64 `json:"-" xorm:"'SECTIONID'"` // 版块ID (SEQ_DELIVERYGOODSSECTION)
|
|
|
+ PRETRADEDATE string `json:"-" xorm:"'PRETRADEDATE'"` // 上个交易日(从marketid=0表中取的, 系统)
|
|
|
+
|
|
|
+ LASTAVGPRICE2 string `json:"lastavgprice"` // 上上个交易日价格(前2天价格)
|
|
|
+ TODAYAVGPRICE2 string `json:"todayavgprice"` // 上个交易日价格(前1天价格)
|
|
|
+ UPDOWN string `json:"updown"` // 涨跌
|
|
|
+ UPDOWNRATIO string `json:"updownratio"` // 涨幅(已格式化, 直接显示即可)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrSpotGroupTradeSum) calc() {
|
|
|
+ if r.LASTAVGPRICE < 1e-8 {
|
|
|
+ r.LASTAVGPRICE2 = "-"
|
|
|
+ }
|
|
|
+ if r.TODAYAVGPRICE < 1e-8 {
|
|
|
+ r.TODAYAVGPRICE2 = "-"
|
|
|
+ }
|
|
|
+ if r.TODAYAVGPRICE > 1e-8 && r.LASTAVGPRICE > 1e-8 {
|
|
|
+ // 涨跌
|
|
|
+ var diff SFLOAT64
|
|
|
+ diff.Set(r.TODAYAVGPRICE - r.LASTAVGPRICE)
|
|
|
+ r.UPDOWN = diff.Round(2).string()
|
|
|
+
|
|
|
+ // 涨幅
|
|
|
+ var k SFLOAT64
|
|
|
+ k.Set(diff.Float64() * 100 / r.TODAYAVGPRICE)
|
|
|
+ k.Round(2)
|
|
|
+ if k.Float64() > 1e-8 {
|
|
|
+ r.UPDOWNRATIO = "+" + k.string() + `%`
|
|
|
+ } else {
|
|
|
+ r.UPDOWNRATIO = "-" + k.string() + `%`
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ r.UPDOWN = "-"
|
|
|
+ r.UPDOWNRATIO = "-"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrSpotGroupTradeSum) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+with tmp as
|
|
|
+ (select k.reckondate,
|
|
|
+ k.marketid,
|
|
|
+ k.tradeqty,
|
|
|
+ k.tradeamount,
|
|
|
+ k.lastreckondate,
|
|
|
+ k.lastavgprice,
|
|
|
+ k.todayavgprice,
|
|
|
+ k.deliverygoodsid deliverygoodsid1
|
|
|
+ from reckon_spotgrouptradesum k
|
|
|
+ inner join marketrun m
|
|
|
+ on k.reckondate = m.pretradedate
|
|
|
+ and m.marketid = 0)
|
|
|
+select tmp.*,
|
|
|
+ t.sectionid,
|
|
|
+ g.deliverygoodsid,
|
|
|
+ g.deliverygoodscode,
|
|
|
+ g.deliverygoodsname
|
|
|
+ from DeliveryGoodsSectionConfig t
|
|
|
+ left join tmp
|
|
|
+ on t.deliverygoodsid = tmp.deliverygoodsid1
|
|
|
+ left join deliverygoods g
|
|
|
+ on t.deliverygoodsid = g.deliverygoodsid
|
|
|
+ where t.sectionid = 1
|
|
|
+ and t.showflag = 1
|
|
|
+ order by t.orderindex
|
|
|
+`
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取指数
|
|
|
+func (r *WrSpotGroupTradeSum) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]WrSpotGroupTradeSum, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|
|
|
+
|
|
|
+// WrSpotGroupTradeSumEx 指数(层级)
|
|
|
+type WrSpotGroupTradeSumEx struct {
|
|
|
+ RECKONDATE string `json:"reckondate" xorm:"'RECKONDATE'"` // 上个交易日(yyyymmdd)
|
|
|
+ PRERECKONDATE string `json:"prereckondate" xorm:"'PRERECKONDATE'"` // 上上个交易日(yyymmdd)
|
|
|
+ LST []WrSpotGroupTradeSum `json:"lst"` // 指数列表
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrSpotGroupTradeSumEx) calc() {
|
|
|
+ r.LST = make([]WrSpotGroupTradeSum, 0)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *WrSpotGroupTradeSumEx) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+select t.pretradedate RECKONDATE,
|
|
|
+ (select max(k.lastreckondate)
|
|
|
+ from reckon_spotgrouptradesum k
|
|
|
+ where k.reckondate = t.pretradedate) PRERECKONDATE
|
|
|
+ from marketrun t
|
|
|
+ where t.marketid = 0
|
|
|
+`
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取指数(层级)
|
|
|
+func (r *WrSpotGroupTradeSumEx) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]WrSpotGroupTradeSumEx, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ if err == nil && len(sData) > 0 {
|
|
|
+ m := WrSpotGroupTradeSum{}
|
|
|
+ if d, err := m.GetDataEx(); err == nil {
|
|
|
+ sData[0].LST = d.([]WrSpotGroupTradeSum)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return sData, err
|
|
|
+}
|