func (this *shoppingService) GetOrderByNo(orderNo string) *order.Order { order := this._manager.GetOrderByNo(orderNo) if order != nil { return order.GetValue() } return nil }
func (this *shoppingService) PrepareOrder(buyerId int, cartKey string) *order.Order { cart := this.getShoppingCart(buyerId, cartKey) order, _, err := this._manager.PrepareOrder(cart, "", "") if err != nil { return nil } return order.GetValue() }
func (this *shoppingService) PrepareOrder2(buyerId int, cartKey string, subject string, couponCode string) (map[string]interface{}, error) { cart := this.getShoppingCart(buyerId, cartKey) order, py, err := this._manager.PrepareOrder(cart, subject, couponCode) if err != nil { return nil, err } v := order.GetValue() po := py.GetValue() buf := bytes.NewBufferString("") for _, v := range order.GetCoupons() { buf.WriteString(v.GetDescribe()) buf.WriteString("\n") } discountFee := v.GoodsAmount - po.TotalFee + po.SubFee data := make(map[string]interface{}) // 取消优惠券 data["totalFee"] = v.GoodsAmount data["fee"] = po.TotalFee data["payFee"] = po.FinalFee data["discountFee"] = discountFee data["expressFee"] = v.ExpressFee // 设置优惠券的信息 if couponCode != "" { // 优惠券没有减金额 if po.CouponDiscount == 0 { data["result"] = po.CouponDiscount != 0 data["message"] = "优惠券无效" } else { // 成功应用优惠券 data["couponFee"] = po.CouponDiscount data["couponDescribe"] = buf.String() } } return data, err }