|
@@ -1045,6 +1045,8 @@ func (r *WrGoodsPerformanceStep) calc() {
|
|
|
switch r.STEPTYPEID {
|
|
switch r.STEPTYPEID {
|
|
|
case 1, 2, 98:
|
|
case 1, 2, 98:
|
|
|
r.STEPINFO = fmt.Sprintf("%v %v%%", r.STEPTYPENAME, r.STEPVALUE*100)
|
|
r.STEPINFO = fmt.Sprintf("%v %v%%", r.STEPTYPENAME, r.STEPVALUE*100)
|
|
|
|
|
+ case 92:
|
|
|
|
|
+ r.STEPINFO = r.STEPTYPENAME
|
|
|
default:
|
|
default:
|
|
|
if r.STEPVALUE == 0 {
|
|
if r.STEPVALUE == 0 {
|
|
|
r.STEPINFO = r.STEPTYPENAME
|
|
r.STEPINFO = r.STEPTYPENAME
|
|
@@ -1085,11 +1087,24 @@ func (r WrGoodsPerformanceStep) buildSqlByTmpId() string {
|
|
|
return sqlId.String()
|
|
return sqlId.String()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (r WrGoodsPerformanceStep) buildSqlAll() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = "select t.*, s.steptypename" +
|
|
|
|
|
+ " from PerformanceStepTemplate t" +
|
|
|
|
|
+ " inner join PerformanceStepType s" +
|
|
|
|
|
+ " on t.steptypeid = s.steptypeid" +
|
|
|
|
|
+ " where 1=1" +
|
|
|
|
|
+ " order by t.templateid, t.stepindex"
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (r *WrGoodsPerformanceStep) buildSql() string {
|
|
func (r *WrGoodsPerformanceStep) buildSql() string {
|
|
|
if r.TEMPLATEID != 0 {
|
|
if r.TEMPLATEID != 0 {
|
|
|
return r.buildSqlByTmpId()
|
|
return r.buildSqlByTmpId()
|
|
|
|
|
+ } else if r.WRSTANDARDID > 0 {
|
|
|
|
|
+ return r.buildSqlByWrstandard()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return r.buildSqlAll()
|
|
|
}
|
|
}
|
|
|
- return r.buildSqlByWrstandard()
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GetDataEx 获取商品履约步骤
|
|
// GetDataEx 获取商品履约步骤
|
|
@@ -1117,6 +1132,7 @@ type WrGoodsInfo struct {
|
|
|
HASWR int32 `json:"haswr" form:"haswr"` // 0:仓单预售 1:仓单贸易
|
|
HASWR int32 `json:"haswr" form:"haswr"` // 0:仓单预售 1:仓单贸易
|
|
|
LstItem []WrTypeItem `json:"lstitem"` // 商品信息项
|
|
LstItem []WrTypeItem `json:"lstitem"` // 商品信息项
|
|
|
LstStep []WrGoodsPerformanceStep `json:"lststep"` // 履约规则
|
|
LstStep []WrGoodsPerformanceStep `json:"lststep"` // 履约规则
|
|
|
|
|
+ TMPLATEID int64 `json:"-" form:"tmplateid"` // 履约模板id
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// GetDataEx 获取仓单商品信息(仓单要素列展开+履约计划步骤)
|
|
// GetDataEx 获取仓单商品信息(仓单要素列展开+履约计划步骤)
|
|
@@ -1131,7 +1147,12 @@ func (r *WrGoodsInfo) GetDataEx() (interface{}, error) {
|
|
|
a := sType[0]
|
|
a := sType[0]
|
|
|
|
|
|
|
|
// 获取履约规则
|
|
// 获取履约规则
|
|
|
- mStep := WrGoodsPerformanceStep{MARKETID: r.MARKETID, WRSTANDARDID: a.WRSTANDARDID, HASWR: r.HASWR}
|
|
|
|
|
|
|
+ mStep := WrGoodsPerformanceStep{}
|
|
|
|
|
+ if r.TMPLATEID > 0 {
|
|
|
|
|
+ mStep.TEMPLATEID = r.TMPLATEID
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mStep.MARKETID, mStep.WRSTANDARDID, mStep.HASWR = r.MARKETID, a.WRSTANDARDID, r.HASWR
|
|
|
|
|
+ }
|
|
|
if sStep, err := mStep.GetData(); err == nil && len(sStep) > 0 {
|
|
if sStep, err := mStep.GetData(); err == nil && len(sStep) > 0 {
|
|
|
v.LstStep = append(v.LstStep, sStep...)
|
|
v.LstStep = append(v.LstStep, sStep...)
|
|
|
}
|
|
}
|
|
@@ -3090,3 +3111,95 @@ func (r *WrFriendApply) GetDataEx() (interface{}, error) {
|
|
|
}
|
|
}
|
|
|
return sData, err
|
|
return sData, err
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// WrPerformanceTemplate 履约模板
|
|
|
|
|
+type WrPerformanceTemplate struct {
|
|
|
|
|
+ AUTOID int64 `json:"autoid" xorm:"AUTOID" form:"autoid"` // AutoID 模板id
|
|
|
|
|
+ USERID int64 `json:"userid" xorm:"USERID" form:"userid"` // 所属用户
|
|
|
|
|
+ TEMPLATENAME string `json:"templatename" xorm:"TEMPLATENAME"` // 模板名称
|
|
|
|
|
+ PAYMENTTYPE int32 `json:"paymenttype" xorm:"PAYMENTTYPE"` // 支付方式 - 1:冻结 2:扣款
|
|
|
|
|
+ CREATETIME string `json:"createtime" xorm:"CREATETIME"` // 创建时间
|
|
|
|
|
+ CREATORID int64 `json:"creatorid" xorm:"CREATORID" form:"creatorid"` // 创建人
|
|
|
|
|
+ TEMPLATETYPE int32 `json:"templatetype" xorm:"TEMPLATETYPE"` // 模板类型 - 0:通用 1:交割 2:仓单贸易 3:预售集采 7:竞拍-竞价式 8:竞拍-大宗式 9:荷兰式--失效枚举:4:竞拍-降价式 (无仓单) 5:挂牌期权 6:竞拍-降价式
|
|
|
|
|
+ TAKEMODE int32 `json:"takemode" xorm:"TAKEMODE"` // 提货方式 - 1:无 2:买方自提 3:卖方发货
|
|
|
|
|
+
|
|
|
|
|
+ FTTMPTYPE string `json:"-" form:"tmptype"` // 模板类型筛选
|
|
|
|
|
+ INCLUDEPUB int32 `json:"-" form:"includepub"` // 是否包含公共模板
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *WrPerformanceTemplate) calc() {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *WrPerformanceTemplate) buildSql() string {
|
|
|
|
|
+ var sqlId utils.SQLVal = "SELECT t.USERID," +
|
|
|
|
|
+ " t.AUTOID," +
|
|
|
|
|
+ " t.TEMPLATENAME," +
|
|
|
|
|
+ " t.PAYMENTTYPE," +
|
|
|
|
|
+ " to_char(t.CREATETIME, 'yyyy-mm-dd hh24:mi:ss') CREATETIME," +
|
|
|
|
|
+ " t.CREATORID," +
|
|
|
|
|
+ " t.TEMPLATETYPE," +
|
|
|
|
|
+ " t.TAKEMODE" +
|
|
|
|
|
+ " FROM PERFORMANCEPLANTEMPLATE t" +
|
|
|
|
|
+ " WHERE 1 = 1"
|
|
|
|
|
+ if r.USERID > 0 {
|
|
|
|
|
+ if r.INCLUDEPUB == 1 {
|
|
|
|
|
+ // t.userid is null 意思是查公共模板
|
|
|
|
|
+ sqlId.JoinFormat(" and (t.userid is null or t.userid = %v)", r.USERID)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlId.And("t.userid", r.USERID)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlId.AndEx("t.autoid", r.AUTOID, r.AUTOID > 0)
|
|
|
|
|
+ if r.FTTMPTYPE != "" {
|
|
|
|
|
+ sqlId.JoinFormat(" and t.TEMPLATETYPE in(%v)", r.FTTMPTYPE)
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlId.Join(" order by t.AUTOID")
|
|
|
|
|
+ return sqlId.String()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// GetDataEx 获取履约模板
|
|
|
|
|
+func (r *WrPerformanceTemplate) GetDataEx() (interface{}, error) {
|
|
|
|
|
+ sData := make([]WrPerformanceTemplate, 0)
|
|
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
|
|
+ for i := range sData {
|
|
|
|
|
+ sData[i].calc()
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// WrPerformanceTemplateEx 履约模板(含步骤信息)
|
|
|
|
|
+type WrPerformanceTemplateEx struct {
|
|
|
|
|
+ WrPerformanceTemplate `form:"extends"`
|
|
|
|
|
+ LstStep []WrGoodsPerformanceStep // 步骤信息列表
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *WrPerformanceTemplateEx) addStep(lst []WrGoodsPerformanceStep) {
|
|
|
|
|
+ for i := range lst {
|
|
|
|
|
+ if lst[i].TEMPLATEID == r.AUTOID {
|
|
|
|
|
+ r.LstStep = append(r.LstStep, lst[i])
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (r *WrPerformanceTemplateEx) GetDataEx() (interface{}, error) {
|
|
|
|
|
+ sData := make([]WrPerformanceTemplateEx, 0)
|
|
|
|
|
+ if d, err := r.WrPerformanceTemplate.GetDataEx(); err == nil {
|
|
|
|
|
+ if sTmplate, ok := d.([]WrPerformanceTemplate); ok {
|
|
|
|
|
+ if len(sTmplate) > 0 {
|
|
|
|
|
+ // 查履约步骤
|
|
|
|
|
+ ms := WrGoodsPerformanceStep{}
|
|
|
|
|
+ if d2, err := ms.GetData(); err == nil {
|
|
|
|
|
+ for i := range sTmplate {
|
|
|
|
|
+ val := WrPerformanceTemplateEx{}
|
|
|
|
|
+ val.WrPerformanceTemplate = sTmplate[i]
|
|
|
|
|
+ val.LstStep = make([]WrGoodsPerformanceStep, 0)
|
|
|
|
|
+ val.addStep(d2)
|
|
|
|
|
+ sData = append(sData, val)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return sData, nil
|
|
|
|
|
+}
|