Exemple #1
0
// 保存会员价
func (this *tmpGoodsImpl) SaveLevelPrice(v *goods.MemberPrice) (int, error) {
	v.GoodsId = this.GetDomainId()
	if this._value.SalePrice == v.Price {
		if v.Id > 0 {
			this._goodsRep.RemoveGoodsLevelPrice(v.Id)
		}
		return -1, nil
	}
	return this._goodsRep.SaveGoodsLevelPrice(v)
}
Exemple #2
0
// 保存会员价
func (this *goodsRep) SaveGoodsLevelPrice(v *goods.MemberPrice) (id int, err error) {
	//if v.Id <= 0 {
	//	this.Connector.ExecScalar(`SELECT MAX(id) FROM gs_member_price where goods_id=? and level=?`,
	//		&v.Id, v.GoodsId, v.Level)
	//}
	if v.Id > 0 {
		_, _, err = this.Connector.GetOrm().Save(v.Id, v)
		id = v.Id
	} else {
		var id64 int64
		_, id64, err = this.Connector.GetOrm().Save(nil, v)
		v.Id = int(id64)
	}
	return id, err
}