|
|
@@ -394,6 +394,7 @@ type WrPosition struct {
|
|
|
WRPOSITIONNO string `json:"wrpositionno"` // 仓单编号
|
|
|
|
|
|
QueryType int32 `json:"querytype" form:"querytype"` // 查询类型 1-现货汇总 2-库存汇总(订单汇总)
|
|
|
+ HASWR int32 `json:"haswr" form:"haswr"` // 是否有仓单-卖方 - 0:无仓单 1:有仓单
|
|
|
}
|
|
|
|
|
|
func (r *WrPosition) calc() {
|
|
|
@@ -443,7 +444,7 @@ func (r *WrPosition) buildSql1() string {
|
|
|
" on t.wrfactortypeid = w.wrfactortypeid" +
|
|
|
" left join wrstandard wd" +
|
|
|
" on w.wrstandardid = wd.wrstandardid" +
|
|
|
- " where t.wruserid = %v)," +
|
|
|
+ " where 1=1 %v)," +
|
|
|
"hld as" +
|
|
|
" (select k.deliverygoodsid," +
|
|
|
" k.wrtypename," +
|
|
|
@@ -470,7 +471,14 @@ func (r *WrPosition) buildSql1() string {
|
|
|
" left join enumdicitem e" +
|
|
|
" on e.enumitemname = wd.unitid" +
|
|
|
" and e.enumdiccode = 'goodsunit'"
|
|
|
- sqlId.FormatParam(r.WRUSERID)
|
|
|
+ var param utils.SQLVal
|
|
|
+ param.And("t.wruserid", r.WRUSERID)
|
|
|
+ if r.HASWR == 0 {
|
|
|
+ param.Join(" and t.CREDITTOTALQTY > 0")
|
|
|
+ } else {
|
|
|
+ param.Join(" and t.TOTALQTY > 0")
|
|
|
+ }
|
|
|
+ sqlId.FormatParam(param.String())
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|
|
|
@@ -505,6 +513,8 @@ func (r *WrPosition) buildSql3() string {
|
|
|
" dg.deliverygoodsname," +
|
|
|
" wd.wrstandardcode," +
|
|
|
" wd.wrstandardname," +
|
|
|
+ " h.warehousecode," +
|
|
|
+ " h.warehousename," +
|
|
|
" e.enumdicname" +
|
|
|
" FROM WRPOSITION t" +
|
|
|
" LEFT JOIN WRFACTORTYPE w" +
|
|
|
@@ -513,11 +523,17 @@ func (r *WrPosition) buildSql3() string {
|
|
|
" on t.deliverygoodsid = dg.deliverygoodsid" +
|
|
|
" LEFT JOIN WRSTANDARD wd" +
|
|
|
" on w.wrstandardid = wd.wrstandardid" +
|
|
|
+ " left join warehouseinfo h on w.warehouseid=h.autoid" +
|
|
|
" left join enumdicitem e" +
|
|
|
" on e.enumitemname = wd.unitid" +
|
|
|
" and e.enumdiccode = 'goodsunit'" +
|
|
|
" WHERE 1 = 1"
|
|
|
sqlId.And("t.WRUSERID", r.WRUSERID)
|
|
|
+ if r.HASWR == 0 {
|
|
|
+ sqlId.Join(" and t.CREDITTOTALQTY > 0")
|
|
|
+ } else {
|
|
|
+ sqlId.Join(" and t.TOTALQTY > 0")
|
|
|
+ }
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|
|
|
@@ -528,6 +544,7 @@ func (r *WrPosition) GetDataEx() (interface{}, error) {
|
|
|
for i := range sData {
|
|
|
sData[i].calc()
|
|
|
sData[i].QueryType = r.QueryType
|
|
|
+ sData[i].HASWR = r.HASWR
|
|
|
}
|
|
|
// 查履约中的数量
|
|
|
if len(sData) > 0 {
|
|
|
@@ -1380,7 +1397,7 @@ func (r *WrPerformanPlanSum) buildSql_XHHZ() string {
|
|
|
" sum(k.qty) qty" +
|
|
|
" from tmp k" +
|
|
|
" group by k.selluserid, k.deliverygoodsid, k.wrstandardid, k.wrtypename"
|
|
|
- sqlId.FormatParam(r.USERID, r.USERID)
|
|
|
+ sqlId.FormatParam(r.USERID)
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|