Beispiel #1
0
// 获取促销
func (this *promotionService) GetPromotion(id int) (*promotion.PromotionInfo, interface{}) {
	var prom promotion.IPromotion = this._rep.GetPromotion(id)
	if prom != nil {
		return prom.GetValue(), prom.GetRelationValue()
	}
	return nil, nil
}
Beispiel #2
0
/**************   Coupon ************/
func (this *promotionService) SaveCoupon(merchantId int, v *promotion.PromotionInfo, 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().MerchantId != merchantId {
			return -1, merchant.ErrMerchantNotMatch
		}
	} 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()
}
Beispiel #3
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)
}