|
|
@@ -119,39 +119,51 @@ func (r *ErmcpSpotContractModel) GetData(nQueryType int32) ([]ErmcpSpotContractM
|
|
|
|
|
|
// 风险管理合同(对应采购和销售菜单)
|
|
|
type ErmcpModel struct {
|
|
|
- UserID int64 `json:"userid" xorm:"'UserID'"` // 用户ID
|
|
|
- SpotContractId string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 合同ID
|
|
|
- AccountId string `json:"accountid" xorm:"'ACCOUNTID'"` // 账户ID
|
|
|
- AccountName string `json:"accountname" xorm:"'ACCOUNTNAME'"` // 账户名称
|
|
|
- DeliveryGoodsId int `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品ID
|
|
|
- DeliveryGoodsCode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
|
|
|
- DeliveryGoodsName string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
|
|
|
- SpotGoodsdesc string `json:"spotgoodsdesc" xorm:"'SPOTGOODSDESC'"` // 商品型号(商品规格)
|
|
|
- GoodsId int `json:"goodsid" xorm:"'GOODSID'"` // 点价商品ID
|
|
|
- Goodscode string `json:"goodscode" xorm:"'GOODSCODE'"` // 点价商品代码
|
|
|
- Pricemove float64 `json:"pricemove" xorm:"'PRICEMOVE'"` // 升贴水
|
|
|
- Qty float64 `json:"qty" xorm:"'QTY'"` // 合同量
|
|
|
- UnpricedQty float64 `json:"unpricedqty" xorm:"'UNPRICEDQTY'"` // 未定价量
|
|
|
- PricedQty float64 `json:"pricedqty" xorm:"'PRICEDQTY'"` // 已定价量
|
|
|
- UnsureQty float64 `json:"unsureqty" xorm:"'UNSUREQTY'"` // 未确定量
|
|
|
- PayAmount float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 已收付额(收款或付款)
|
|
|
- UnpayAmount float64 `json:"unpayamount" xorm:"'UNPAYAMOUNT'"` // 待支收额(支付或收款)
|
|
|
- InvoiceAmount float64 `json:"invoiceamount" xorm:"'INVOICEAMOUNT'"` // 已开票额
|
|
|
- DaikaiAmount float64 `json:"daikaiamount" xorm:"'DAIKAIAMOUNT'"` // 待开票额
|
|
|
- StartDate string `json:"startdate" xorm:"'STARTDATE'"` // 点价开始日
|
|
|
- EndDate string `json:"enddate" xorm:"'ENDDATE'"` // 点价结束日
|
|
|
- DeliveryStartDate string `json:"deliverystartdate" xorm:"'DELIVERYSTARTDATE'"` // 交割开始日
|
|
|
- DeliveryendDate string `json:"deliveryenddate" xorm:"'DELIVERYENDDATE'"` // 交割结束日
|
|
|
- Convertfactor float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数
|
|
|
- EnumdicName string `json:"enumdicname" xorm:"'ENUMDICNAME'"` // 单位名称
|
|
|
- Contracctstatus uint `json:"contracctstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
|
|
|
- PriceType int `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
|
|
|
- ProductType int `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
|
|
|
- Contracttype float64 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 合同类型 1-采购, -1-销售
|
|
|
- Pricedamount float64 `json:"pricedamount" xorm:"'PRICEDAMOUNT'"` // 已定价额
|
|
|
- PricedAvg float64 `json:"pricedavg" xorm:"'PRICEDAVG'"` // 已点均价
|
|
|
- Margin float64 `json:"margin" xorm:"'MARGIN'"` // 保证金
|
|
|
- Remark string `json:"remark" xorm:"'Remark'"` // 备注
|
|
|
+ UserID int64 `json:"userid" xorm:"'UserID'"` // 用户ID
|
|
|
+ SpotContractId string `json:"spotcontractid" xorm:"'SPOTCONTRACTID'"` // 合同ID
|
|
|
+ AccountId string `json:"accountid" xorm:"'ACCOUNTID'"` // 账户ID
|
|
|
+ AccountName string `json:"accountname" xorm:"'ACCOUNTNAME'"` // 账户名称
|
|
|
+ DeliveryGoodsId int `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货商品ID
|
|
|
+ DeliveryGoodsCode string `json:"deliverygoodscode" xorm:"'DELIVERYGOODSCODE'"` // 现货商品代码
|
|
|
+ DeliveryGoodsName string `json:"deliverygoodsname" xorm:"'DELIVERYGOODSNAME'"` // 现货商品名称
|
|
|
+ SpotGoodsdesc string `json:"spotgoodsdesc" xorm:"'SPOTGOODSDESC'"` // 商品型号(商品规格)
|
|
|
+ GoodsId int `json:"goodsid" xorm:"'GOODSID'"` // 点价商品ID
|
|
|
+ Goodscode string `json:"goodscode" xorm:"'GOODSCODE'"` // 点价商品代码
|
|
|
+ Pricemove float64 `json:"pricemove" xorm:"'PRICEMOVE'"` // 升贴水
|
|
|
+ Qty float64 `json:"qty" xorm:"'QTY'"` // 合同量
|
|
|
+ UnpricedQty float64 `json:"unpricedqty" xorm:"'UNPRICEDQTY'"` // 未定价量
|
|
|
+ PricedQty float64 `json:"pricedqty" xorm:"'PRICEDQTY'"` // 已定价量
|
|
|
+ UnsureQty float64 `json:"unsureqty" xorm:"'UNSUREQTY'"` // 未确定量
|
|
|
+ PayAmount float64 `json:"payamount" xorm:"'PAYAMOUNT'"` // 已收付额(收款或付款)
|
|
|
+ UnpayAmount float64 `json:"unpayamount" xorm:"'UNPAYAMOUNT'"` // 待支收额(支付或收款)
|
|
|
+ InvoiceAmount float64 `json:"invoiceamount" xorm:"'INVOICEAMOUNT'"` // 已开票额
|
|
|
+ DaikaiAmount float64 `json:"daikaiamount" xorm:"'DAIKAIAMOUNT'"` // 待开票额
|
|
|
+ StartDate string `json:"startdate" xorm:"'STARTDATE'"` // 点价开始日
|
|
|
+ EndDate string `json:"enddate" xorm:"'ENDDATE'"` // 点价结束日
|
|
|
+ DeliveryStartDate string `json:"deliverystartdate" xorm:"'DELIVERYSTARTDATE'"` // 交割开始日
|
|
|
+ DeliveryendDate string `json:"deliveryenddate" xorm:"'DELIVERYENDDATE'"` // 交割结束日
|
|
|
+ Convertfactor float64 `json:"convertfactor" xorm:"'CONVERTFACTOR'"` // 标仓系数
|
|
|
+ EnumdicName string `json:"enumdicname" xorm:"'ENUMDICNAME'"` // 单位名称
|
|
|
+ Contracctstatus uint `json:"contracctstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
|
|
|
+ PriceType int `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
|
|
|
+ ProductType int `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
|
|
|
+ Contracttype float64 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 合同类型 1-采购, -1-销售
|
|
|
+ Pricedamount float64 `json:"pricedamount" xorm:"'PRICEDAMOUNT'"` // 已定价额
|
|
|
+ PricedAvg float64 `json:"pricedavg" xorm:"'PRICEDAVG'"` // 已点均价
|
|
|
+ Margin float64 `json:"margin" xorm:"'MARGIN'"` // 保证金
|
|
|
+ Remark string `json:"remark" xorm:"'Remark'"` // 备注
|
|
|
+ ReckonRealQty float64 `json:"reckonrealqty" xorm:"'ReckonRealQty'"` // 已确定量
|
|
|
+ ReckonOtherAmount float64 `json:"reckonotheramount" xorm:"'ReckonOtherAmount'"` // 其它费用
|
|
|
+ ReckonAdjustAmount float64 `json:"reckonadjustamount" xorm:"'ReckonAdjustAmount'"` // 调整金额
|
|
|
+ Price float64 `json:"price" xorm:"'Price'"` // 价格
|
|
|
+ LoanAmount float64 `json:"loanamount" xorm:"'LoanAmount'"` // 贷款总额=已定价额+调整金额
|
|
|
+ Contractno string `json:"contractno" xorm:"'Contractno'"` // 合同编号
|
|
|
+ TotalAmount float64 `json:"totalamount" xorm:"'-'"` // 合计总额
|
|
|
+ ReckonedAmount float64 `json:"reckonedamount" xorm:"'ReckonedAmount'"` // 已收付额(已确定额)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *ErmcpModel) calc() {
|
|
|
+ r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount - r.ReckonedAmount
|
|
|
}
|
|
|
|
|
|
// 组装查询的sql
|
|
|
@@ -196,7 +208,13 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
|
|
|
" e.enumdicname," +
|
|
|
" t.contracttype," +
|
|
|
" t.pricedamount," +
|
|
|
- " case when t.pricedqty > 0 then t.pricedamount/t.pricedqty else 0 end pricedAvg" +
|
|
|
+ " case when t.pricedqty > 0 then t.pricedamount/t.pricedqty else 0 end pricedAvg," +
|
|
|
+ " t.ReckonRealQty," +
|
|
|
+ " t.ReckonOtherAmount," +
|
|
|
+ " t.ReckonAdjustAmount," +
|
|
|
+ " t.Price," +
|
|
|
+ " t.ReckonedAmount," +
|
|
|
+ " t.pricedamount + t.ReckonAdjustAmount as LoanAmount" +
|
|
|
" from ermcp_spotcontract t" +
|
|
|
" left join taaccount ta" +
|
|
|
" on t.%v = ta.userid" +
|
|
|
@@ -251,5 +269,8 @@ func (r *ErmcpModel) GetData(contractType, nQueryType int32) ([]ErmcpModel, erro
|
|
|
logger.GetLogger().Errorf("ermcp query fail:%v", err)
|
|
|
return sData, err
|
|
|
}
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
return sData, nil
|
|
|
}
|