func (this *OrderCoupon) Clone(coupon promotion.ICouponPromotion, orderId int, orderFee float32) *OrderCoupon { v := coupon.GetDetailsValue() 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 }
// 应用优惠券 func (o *orderImpl) ApplyCoupon(coupon promotion.ICouponPromotion) error { //if o._coupons == nil { // o._coupons = []promotion.ICouponPromotion{} //} //o._coupons = append(o._coupons, coupon) // 添加到促销信息中 if o._orderPbs == nil { o._orderPbs = []*order.OrderPromotionBind{} } for _, v := range o._orderPbs { if v.PromotionId == coupon.GetDomainId() { return order.ErrPromotionApplied } } o._orderPbs = append(o._orderPbs, &order.OrderPromotionBind{ Id: 0, // 订单号 OrderId: 0, // 促销编号 PromotionId: coupon.GetDomainId(), // 促销类型 PromotionType: coupon.(promotion.IPromotion).Type(), // 标题 Title: coupon.GetDescribe(), // 节省金额 SaveFee: coupon.GetCouponFee(o._value.GoodsAmount), // 赠送积分 PresentIntegral: 0, //todo;///// // 是否应用 IsApply: 0, // 是否确认 IsConfirm: 0, }) //v := o._value //v.CouponCode = val.Code //v.CouponDescribe = coupon.GetDescribe() //v.CouponFee = coupon.GetCouponFee(v.TotalFee) //v.PayFee = o.GetPaymentFee() //v.DiscountFee = v.DiscountFee + v.CouponFee return nil }