Exemple #1
0
func createCouponPromotion(p *Promotion) promotion.IPromotion {
	var pv *promotion.ValueCoupon

	if p.GetAggregateRootId() > 0 {
		pv = p._promRep.GetValueCoupon(p.GetAggregateRootId())
	}
	if pv == nil {
		pv = &promotion.ValueCoupon{
			Id:         p.GetAggregateRootId(),
			CreateTime: time.Now().Unix(),
		}

	}

	if p.GetAggregateRootId() <= 0 {
		pv.Amount = pv.TotalAmount
	}

	return newCoupon(p, pv, p._promRep, p._memberRep)
}
Exemple #2
0
func (this *Promotion) CreateCoupon(val *promotion.ValueCoupon) promotion.ICoupon {
	val.PartnerId = this.GetAggregateRootId()
	val.CreateTime = time.Now().Unix()
	val.Amount = val.TotalAmount
	return newCoupon(val, this.promRep, this.memberRep)
}