|
@@ -11,6 +11,7 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"mtp2_if/db"
|
|
"mtp2_if/db"
|
|
|
"mtp2_if/logger"
|
|
"mtp2_if/logger"
|
|
|
|
|
+ "mtp2_if/mtpcache"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// 现货合同结构(对应现货合同菜单)
|
|
// 现货合同结构(对应现货合同菜单)
|
|
@@ -147,7 +148,7 @@ type ErmcpModel struct {
|
|
|
Contracctstatus uint `json:"contracctstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
|
|
Contracctstatus uint `json:"contracctstatus" xorm:"'CONTRACTSTATUS'"` // 合同状态- 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
|
|
|
PriceType int `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
|
|
PriceType int `json:"pricetype" xorm:"'PRICETYPE'"` // 定价类型 - 1:一口价 2:点价 3:暂定价
|
|
|
ProductType int `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
|
|
ProductType int `json:"producttype" xorm:"'PRODUCTTYPE'"` // 产品类型 - 1:标准仓单 2:等标 3:非标
|
|
|
- Contracttype float64 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 合同类型 1-采购, -1-销售
|
|
|
|
|
|
|
+ Contracttype int32 `json:"contracttype" xorm:"'CONTRACTTYPE'"` // 合同类型 1-采购, -1-销售
|
|
|
Pricedamount float64 `json:"pricedamount" xorm:"'PRICEDAMOUNT'"` // 已定价额
|
|
Pricedamount float64 `json:"pricedamount" xorm:"'PRICEDAMOUNT'"` // 已定价额
|
|
|
PricedAvg float64 `json:"pricedavg" xorm:"'PRICEDAVG'"` // 已点均价
|
|
PricedAvg float64 `json:"pricedavg" xorm:"'PRICEDAVG'"` // 已点均价
|
|
|
Margin float64 `json:"margin" xorm:"'MARGIN'"` // 保证金
|
|
Margin float64 `json:"margin" xorm:"'MARGIN'"` // 保证金
|
|
@@ -160,10 +161,19 @@ type ErmcpModel struct {
|
|
|
Contractno string `json:"contractno" xorm:"'Contractno'"` // 合同编号
|
|
Contractno string `json:"contractno" xorm:"'Contractno'"` // 合同编号
|
|
|
TotalAmount float64 `json:"totalamount" xorm:"'-'"` // 合计总额
|
|
TotalAmount float64 `json:"totalamount" xorm:"'-'"` // 合计总额
|
|
|
ReckonedAmount float64 `json:"reckonedamount" xorm:"'ReckonedAmount'"` // 已收付额(已确定额)
|
|
ReckonedAmount float64 `json:"reckonedamount" xorm:"'ReckonedAmount'"` // 已收付额(已确定额)
|
|
|
|
|
+ BUYUSERID int64 `json:"-" xorm:"'BUYUSERID'"` //采购方ID
|
|
|
|
|
+ SELLUSERID int64 `json:"-" xorm:"'SELLUSERID'"` //销售方ID
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (r *ErmcpModel) calc() {
|
|
func (r *ErmcpModel) calc() {
|
|
|
r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount - r.ReckonedAmount
|
|
r.TotalAmount = r.LoanAmount + r.ReckonOtherAmount - r.ReckonedAmount
|
|
|
|
|
+ if r.Contracttype == 1 {
|
|
|
|
|
+ //采购合同, 取销售方名称
|
|
|
|
|
+ r.AccountName = mtpcache.GetUserNameByUserId(r.SELLUSERID)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //销售合同, 取采购方名称
|
|
|
|
|
+ r.AccountName = mtpcache.GetUserNameByUserId(r.BUYUSERID)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 组装查询的sql
|
|
// 组装查询的sql
|
|
@@ -175,6 +185,8 @@ func (r *ErmcpModel) buildSql(nContractType, nQueryType int32) string {
|
|
|
" t.goodsid," +
|
|
" t.goodsid," +
|
|
|
" t.pricemove," +
|
|
" t.pricemove," +
|
|
|
" t.userid," +
|
|
" t.userid," +
|
|
|
|
|
+ " t.BUYUSERID," +
|
|
|
|
|
+ " t.SELLUSERID," +
|
|
|
" t.qty," +
|
|
" t.qty," +
|
|
|
" t.qty - t.pricedqty unpricedqty," +
|
|
" t.qty - t.pricedqty unpricedqty," +
|
|
|
" t.pricedqty," +
|
|
" t.pricedqty," +
|