Ejemplo n.º 1
0
// 保存促销
func (this *promotionService) SavePromotion(v *promotion.ValuePromotion) (int, error) {
	var prom promotion.IPromotion
	if v.Id > 0 {
		prom = this._newRep.GetPromotion(v.Id)
		prom.SetValue(v)
	} else {
		prom = this._newRep.CreatePromotion(v)
	}
	return prom.Save()
}
Ejemplo n.º 2
0
// 保存促销
func (this *promotionService) SavePromotion(v *promotion.ValuePromotion) (int, error) {
	var prom promotion.IPromotion
	if v.Id > 0 {
		prom = this._rep.GetPromotion(v.Id)
		err := prom.SetValue(v)
		if err != nil {
			return v.Id, err
		}
	} else {
		prom = this._rep.CreatePromotion(v)
	}
	return prom.Save()
}
Ejemplo n.º 3
0
func (this *promotionService) SaveCashBackPromotion(partnerId int, v *promotion.ValuePromotion,
	v1 *promotion.ValueCashBack) (int, error) {
	var prom promotion.IPromotion
	if v.Id > 0 {
		prom = this._newRep.GetPromotion(v.Id)
		if prom.GetValue().PartnerId != partnerId {
			return -1, partner.ErrNotMatch
		}
		prom.SetValue(v)
	} else {
		prom = this._newRep.CreatePromotion(v)
	}

	cb := prom.(promotion.ICashBackPromotion)

	if err := cb.SetDetailsValue(v1); err != nil {
		return v.Id, err
	}

	return prom.Save()
}
Ejemplo n.º 4
0
/**************   Coupon ************/
func (this *promotionService) SaveCoupon(partnerId int, v *promotion.ValuePromotion, v1 *promotion.ValueCoupon) (int, error) {
	var prom promotion.IPromotion
	var err error
	if v.Id > 0 {
		prom = this._rep.GetPromotion(v.Id)
		if prom.GetValue().PartnerId != partnerId {
			return -1, partner.ErrNotMatch
		}
	} else {
		prom = this._rep.CreatePromotion(v)
	}

	if err = prom.SetValue(v); err == nil {
		cb := prom.(promotion.ICouponPromotion)
		err = cb.SetDetailsValue(v1)
	}

	if err != nil {
		return v.Id, err
	}

	return prom.Save()
}