本文整理汇总了Golang中go2o/src/core/domain/interface/promotion.ICoupon类的典型用法代码示例。如果您正苦于以下问题:Golang ICoupon类的具体用法?Golang ICoupon怎么用?Golang ICoupon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICoupon类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ApplyCoupon
func (this *Order) ApplyCoupon(coupon promotion.ICoupon) error {
if this._coupons == nil {
this._coupons = []promotion.ICoupon{}
}
this._coupons = append(this._coupons, coupon)
//val := coupon.GetValue()
v := this._value
//v.CouponCode = val.Code
//v.CouponDescribe = coupon.GetDescribe()
v.CouponFee = coupon.GetCouponFee(v.Fee)
v.PayFee = v.Fee - v.CouponFee
v.DiscountFee = v.DiscountFee + v.CouponFee
return nil
}
示例2: SaveCoupon
func (this *promotionService) SaveCoupon(partnerId int, e *promotion.ValueCoupon) (int, error) {
prom := this._rep.GetPromotion(partnerId)
var coupon promotion.ICoupon
if e.Id > 0 {
coupon = prom.GetCoupon(e.Id)
if coupon == nil {
return 0, errors.New("优惠券不存在")
}
err := coupon.SetValue(e)
if err != nil {
return 0, err
}
} else {
coupon = prom.CreateCoupon(e)
}
return coupon.Save()
}
示例3: Clone
func (this *OrderCoupon) Clone(coupon promotion.ICoupon,
orderId int, orderFee float32) *OrderCoupon {
v := coupon.GetValue()
this.CouponCode = v.Code
this.CouponId = v.Id
this.OrderId = orderId
this.Fee = coupon.GetCouponFee(orderFee)
this.Describe = coupon.GetDescribe()
this.SendIntegral = v.Integral
return this
}
示例4: BuildOrder
// 生成订单
func (this *Shopping) BuildOrder(memberId int, couponCode string) (shopping.IOrder, shopping.ICart, error) {
order, m, cart, err := this.ParseShoppingCart(memberId)
if err != nil {
return order, cart, err
}
if len(couponCode) != 0 {
var coupon promotion.ICoupon
var result bool
var val = order.GetValue()
coupon, err = this._promRep.GetCouponByCode(
this._partnerId, couponCode)
// 如果优惠券不存在
if err != nil || coupon == nil {
log.PrintErr(err)
return order, cart, errors.New("优惠券无效")
}
result, err = coupon.CanUse(m, val.Fee)
if result {
if coupon.CanTake() {
_, err = coupon.GetTake(memberId)
//如果未占用,则占用
if err != nil {
err = coupon.Take(memberId)
}
} else {
_, err = coupon.GetBind(memberId)
}
if err != nil {
log.PrintErr(err)
return order, cart, errors.New("优惠券无效")
}
order.ApplyCoupon(coupon) //应用优惠券
}
}
return order, cart, err
}