|
|
@@ -1203,3 +1203,192 @@ func (r *THJPurchaseTradeDetailReq) GetData() (rsp *THJPurchaseTradeDetailRsp, e
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// Thjpurchasetransfer 铁合金采购协议表
|
|
|
+type Thjpurchasetransfer struct {
|
|
|
+ TRANSFERID int64 `json:"transferid" xorm:"TRANSFERID"` // 协议转让ID(332+Unix秒时间戳(10位)+xxxxxx)
|
|
|
+ WRTRADEDETAILID int64 `json:"wrtradedetailid" xorm:"WRTRADEDETAILID"` // 采购成交单ID(321+Unix秒时间戳(10位)+xxxxxx)
|
|
|
+ PRESALEAPPLYID int64 `json:"presaleapplyid" xorm:"PRESALEAPPLYID"` // 预售申请ID(184+Unix秒时间戳(10位)+xxxxxx)
|
|
|
+ TRADEDATE string `json:"tradedate" xorm:"TRADEDATE"` // 交易日(yyyyMMdd)
|
|
|
+ WRFACTORTYPEID int64 `json:"wrfactortypeid" xorm:"WRFACTORTYPEID"` // 仓单要素类型ID
|
|
|
+ DELIVERYGOODSID int32 `json:"deliverygoodsid" xorm:"DELIVERYGOODSID"` // 现货品种ID
|
|
|
+ WRSTANDARDID int32 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 现货商品ID
|
|
|
+ WAREHOUSEID int64 `json:"warehouseid" xorm:"WAREHOUSEID"` // 仓库ID
|
|
|
+ MARKETID int32 `json:"marketid" xorm:"MARKETID"` // 市场ID(固定为(64202)
|
|
|
+ SELLUSERID int64 `json:"selluserid" xorm:"SELLUSERID"` // 卖方用户ID
|
|
|
+ SELLACCOUNTID int64 `json:"sellaccountid" xorm:"SELLACCOUNTID"` // 卖方账号ID
|
|
|
+ TRANSFERQTY int64 `json:"transferqty" xorm:"TRANSFERQTY"` // 数量
|
|
|
+ TRANSFERPRICE float64 `json:"transferprice" xorm:"TRANSFERPRICE"` // 转让价格
|
|
|
+ TRANSFERAMOUNT float64 `json:"transferamount" xorm:"TRANSFERAMOUNT"` // 转让金额
|
|
|
+ REMARK string `json:"remark" xorm:"REMARK"` // 备注
|
|
|
+ BUYUSERID int64 `json:"buyuserid" xorm:"BUYUSERID"` // 买方用户ID
|
|
|
+ BUYACCOUNTID int64 `json:"buyaccountid" xorm:"BUYACCOUNTID"` // 买方账号ID
|
|
|
+ CONTRACTADDR string `json:"contractaddr" xorm:"CONTRACTADDR"` // 协议转让合同地址
|
|
|
+ SELLCHARGEALGORITHM int32 `json:"sellchargealgorithm" xorm:"SELLCHARGEALGORITHM"` // 卖方手续费收取方式 1:比率 2:固定
|
|
|
+ SELLCHARGEALGORITHMVALUE float64 `json:"sellchargealgorithmvalue" xorm:"SELLCHARGEALGORITHMVALUE"` // 手续费设置值(交易所部分)
|
|
|
+ SELLCHARGE float64 `json:"sellcharge" xorm:"SELLCHARGE"` // 卖方手续费值
|
|
|
+ TRANSFERTRADEDATE string `json:"transfertradedate" xorm:"TRANSFERTRADEDATE"` // 转让交易日
|
|
|
+ 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
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *Thjpurchasetransfer) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *Thjpurchasetransfer) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ select
|
|
|
+ wr.WRSTANDARDNAME,
|
|
|
+ p.TRADEPRICE,
|
|
|
+ p.PAYEDDEPOSIT,
|
|
|
+ t.TRANSFERID,
|
|
|
+ t.WRTRADEDETAILID,
|
|
|
+ t.PRESALEAPPLYID,
|
|
|
+ t.TRADEDATE,
|
|
|
+ t.WRFACTORTYPEID,
|
|
|
+ t.DELIVERYGOODSID,
|
|
|
+ t.WRSTANDARDID,
|
|
|
+ t.WAREHOUSEID,
|
|
|
+ t.MARKETID,
|
|
|
+ t.SELLUSERID,
|
|
|
+ t.SELLACCOUNTID,
|
|
|
+ t.TRANSFERQTY,
|
|
|
+ t.TRANSFERPRICE,
|
|
|
+ t.TRANSFERAMOUNT,
|
|
|
+ t.REMARK,
|
|
|
+ t.BUYUSERID,
|
|
|
+ t.BUYACCOUNTID,
|
|
|
+ t.CONTRACTADDR,
|
|
|
+ t.SELLCHARGEALGORITHM,
|
|
|
+ t.SELLCHARGEALGORITHMVALUE,
|
|
|
+ t.SELLCHARGE,
|
|
|
+ t.TRANSFERTRADEDATE,
|
|
|
+ t.TRANSFERSTATUS,
|
|
|
+ t.HANDLESTATUS
|
|
|
+ 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
|
|
|
+`
|
|
|
+ sqlId.FormatParam(r.USERID)
|
|
|
+
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *Thjpurchasetransfer) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]Thjpurchasetransfer, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ total := 0
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ total = sData[i].Total
|
|
|
+ }
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
+}
|
|
|
+
|
|
|
+type PromotionIncome struct {
|
|
|
+ PROFITMONTH string `json:"profitmonth" xorm:"PROFITMONTH"` // 时间
|
|
|
+ WRSTANDARDID int32 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 现货商品ID
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"WRSTANDARDCODE"` // 现货商品代码
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"WRSTANDARDNAME"` // 现货商品名称
|
|
|
+ SUMAMOUNT float64 `json:"sumamount" xorm:"SUMAMOUNT"` // 金额
|
|
|
+ PROFITSTATUS int32 `json:"profitstatus" xorm:"PROFITSTATUS"` // 状态 - 1:已支付 2:未支付
|
|
|
+
|
|
|
+ USERID int64 `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+func (r *PromotionIncome) calc() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func (r *PromotionIncome) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = `
|
|
|
+ select
|
|
|
+ substr(t.reckondate, 0, 6) PROFITMONTH,
|
|
|
+ t.WRSTANDARDID,
|
|
|
+ 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 t.profitstatus = 1
|
|
|
+ group by substr(t.reckondate, 0, 6), t.wrstandardid, wr.wrstandardname
|
|
|
+ order by substr(t.reckondate, 0, 6) desc, t.wrstandardid, wr.wrstandardname
|
|
|
+`
|
|
|
+ sqlId.FormatParam(r.USERID)
|
|
|
+
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *PromotionIncome) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]PromotionIncome, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ total := 0
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ total = sData[i].Total
|
|
|
+ }
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
+}
|
|
|
+
|
|
|
+type PromotionIncomeDetail struct {
|
|
|
+ TRADETIME string `json:"tradetime" xorm:"TRADETIME"` // 时间
|
|
|
+ WRSTANDARDID int64 `json:"wrstandardid" xorm:"WRSTANDARDID"` // 现货商品ID(自增 SEQ_GOODS 确保不重复)
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"WRSTANDARDCODE"` // 现货商品代码
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"WRSTANDARDNAME"` // 现货商品名称
|
|
|
+ MARKET string `json:"market" xorm:"MARKET"` // 市场
|
|
|
+ BUYORSELL string `json:"buyorsell" xorm:"BUYORSELL"` // 方向
|
|
|
+ PROFITROLETYPE string `json:"profitroletype" xorm:"PROFITROLETYPE"` // 级别
|
|
|
+ PROFITAMOUNT float64 `json:"profitamount" xorm:"PROFITAMOUNT"` // 金额
|
|
|
+
|
|
|
+ USERID int64 `json:"-" xorm:"-" form:"userid" binding:"required"` // 用户ID
|
|
|
+ MOUTH string `json:"-" xorm:"-" form:"mouth" binding:"required"` // 月份,格式:yyyymm
|
|
|
+
|
|
|
+ PageEx `xorm:"extends"` // 页码信息
|
|
|
+}
|
|
|
+
|
|
|
+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',
|
|
|
+ wr.WRSTANDARDID,
|
|
|
+ wr.WRSTANDARDCODE,
|
|
|
+ wr.WRSTANDARDNAME,
|
|
|
+ case t.marketid when 64201 then '采购' else '供求' end MARKET,
|
|
|
+ case t.buyorsell when 0 then '采购' else '销售' end BUYORSELL,
|
|
|
+ case t.profitroletype when 3 then '一级' else '二级' end PROFITROLETYPE,
|
|
|
+ t.PROFITAMOUNT
|
|
|
+ from THJ_Reckon_ProfitRecode t
|
|
|
+ left join wrstandard wr on t.wrstandardid = wr.wrstandardid
|
|
|
+ where substr(t.tradedate,0,6) = '%v' and t.userid = %v and t.profitroletype in (3,4)
|
|
|
+ order by t.tradeid desc
|
|
|
+`
|
|
|
+ sqlId.FormatParam(r.MOUTH, r.USERID)
|
|
|
+
|
|
|
+ sqlId.Page(r.Page, r.PageSize)
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+func (r *PromotionIncomeDetail) GetDataByPage() (interface{}, error, int, int, int) {
|
|
|
+ sData := make([]PromotionIncomeDetail, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ total := 0
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ total = sData[i].Total
|
|
|
+ }
|
|
|
+ return sData, err, r.Page, r.PageSize, total
|
|
|
+}
|