Example #1
0
func DeletePromotion(p promotion.IPromotion) error {
	var err error
	var rep promotion.IPromotionRep = nil
	if p.Type() == promotion.TypeFlagCashBack {
		v := p.(*CashBackPromotion)
		rep = v._promRep
		err = rep.DeleteValueCashBack(v.GetAggregateRootId())
	} else if p.Type() == promotion.TypeFlagCoupon {
		v := p.(*Coupon)
		rep = v._promRep
		err = rep.DeleteValueCoupon(v.GetAggregateRootId())
	}
	if err == nil && rep != nil {
		err = rep.DeletePromotion(p.GetAggregateRootId())
	}
	return err
}
Example #2
0
// 绑定促销优惠
func (o *orderImpl) bindPromotionOnSubmit(orderNo string,
	prom promotion.IPromotion) (int, error) {
	var title string
	var integral int
	var fee int

	//todo: 需要重构,其他促销
	if prom.Type() == promotion.TypeFlagCashBack {
		fee = prom.GetRelationValue().(*promotion.ValueCashBack).BackFee
		title = prom.TypeName() + ":" + prom.GetValue().ShortName
	}

	v := &order.OrderPromotionBind{
		PromotionId:     prom.GetAggregateRootId(),
		PromotionType:   prom.Type(),
		OrderId:         o.GetAggregateRootId(),
		Title:           title,
		SaveFee:         float32(fee),
		PresentIntegral: integral,
		IsConfirm:       1,
		IsApply:         0,
	}
	return o._orderRep.SavePromotionBindForOrder(v)
}