本文整理汇总了Golang中go2o/src/core/domain/interface/shopping.ICart类的典型用法代码示例。如果您正苦于以下问题:Golang ICart类的具体用法?Golang ICart怎么用?Golang ICart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICart类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ParseShoppingCart
// 将购物车转换为订单
func (this *Shopping) ParseShoppingCart(memberId int) (shopping.IOrder,
member.IMember, shopping.ICart, error) {
var order shopping.IOrder
var val shopping.ValueOrder
var cart shopping.ICart
var m member.IMember
var err error
m = this._memberRep.GetMember(memberId)
if m == nil {
return nil, m, nil, member.ErrSessionTimeout
}
cart, err = this.GetCurrentCart(memberId)
if err != nil || cart == nil || len(cart.GetValue().Items) == 0 {
return nil, m, cart, shopping.ErrEmptyShoppingCart
}
val.MemberId = memberId
val.PartnerId = this._partnerId
tf, of := cart.GetFee()
val.TotalFee = tf //总金额
val.Fee = of //实际金额
val.PayFee = of
val.DiscountFee = tf - of //优惠金额
val.PartnerId = this._partnerId
val.Status = 1
order = this.CreateOrder(&val, cart)
return order, m, cart, nil
}
开发者ID:heofonum,项目名称:go2o,代码行数:34,代码来源:shopping.go
示例2: Combine
// 合并购物车,并返回新的购物车
func (this *Cart) Combine(c shopping.ICart) (shopping.ICart, error) {
if c.GetDomainId() != this.GetDomainId() {
for _, v := range c.GetValue().Items {
this.AddItem(v.GoodsId, v.Num)
}
}
return this, nil
}
开发者ID:honj51,项目名称:go2o,代码行数:9,代码来源:cart.go
示例3: getShoppingCart
// 获取购物车
func (this *shoppingService) getShoppingCart(partnerId int, memberId int, cartKey string) shopping.ICart {
sp := this._rep.GetShopping(partnerId)
var c shopping.ICart
var mc shopping.ICart
var skIsNil = len(cartKey) == 0
var mmNotNil = memberId != 0
if mmNotNil {
mc, _ = sp.GetNotBoughtCart(memberId)
if mc != nil && (skIsNil || mc.GetValue().CartKey == cartKey) {
return mc
}
}
if !skIsNil {
// 根据Key获取购物车
c, _ = sp.GetCart(cartKey)
if c == nil {
// 新的购物车不存在,直接返回会员的购物车
if mc != nil {
return mc
}
} else {
cv := c.GetValue()
//合并购物车
if cv.BuyerId <= 0 {
// 设置购买者
if mmNotNil {
c.SetBuyer(memberId)
}
} else if mc != nil {
// 合并购物车
nc, err := mc.Combine(c)
if err == nil {
nc.Save()
return nc
}
return mc
}
// 如果没有购买,则返回
if cv.IsBought == 0 {
return c
}
}
}
// 返回一个新的购物车
return sp.NewCart(memberId)
}
开发者ID:honj51,项目名称:go2o,代码行数:53,代码来源:shopping_service.go
示例4: parseDtoCart
func (this *shoppingService) parseDtoCart(c shopping.ICart) *dto.ShoppingCart {
var cart = new(dto.ShoppingCart)
v := c.GetValue()
cart.Id = c.GetDomainId()
cart.BuyerId = v.BuyerId
cart.CartKey = v.CartKey
cart.UpdateTime = v.UpdateTime
t, f := c.GetFee()
cart.TotalFee = t
cart.OrderFee = f
cart.Summary = c.GetSummary()
cart.IsBought = v.IsBought
if v.Items != nil {
if l := len(v.Items); l != 0 {
cart.Items = make([]*dto.CartItem, l)
for i, v := range v.Items {
cart.Items[i] = &dto.CartItem{
GoodsId: v.GoodsId,
GoodsName: v.Name,
GoodsNo: v.GoodsNo,
SmallTitle: v.SmallTitle,
GoodsImage: v.Image,
Num: v.Num,
Price: v.Price,
SalePrice: v.SalePrice,
}
}
}
}
return cart
}
开发者ID:honj51,项目名称:go2o,代码行数:33,代码来源:shopping_service.go
示例5: applyCartPromotionObSubmit
// 应用购物车内商品的促销
func (this *Order) applyCartPromotionObSubmit(vo *shopping.ValueOrder, cart shopping.ICart) ([]promotion.IPromotion, int) {
var proms []promotion.IPromotion = make([]promotion.IPromotion, 0)
var prom promotion.IPromotion
var saveFee int
var totalSaveFee int
var intOrderFee = int(vo.Fee)
var rightBack bool
for _, v := range cart.GetCartGoods() {
prom = nil
saveFee = 0
rightBack = false
// 判断商品的最省促销
for _, v1 := range v.GetPromotions() {
// 返现
if v1.Type() == promotion.TypeFlagCashBack {
vc := v1.GetRelationValue().(*promotion.ValueCashBack)
if vc.MinFee < intOrderFee {
if vc.BackFee > saveFee {
prom = v1
saveFee = vc.BackFee
rightBack = vc.BackType == promotion.BackUseForOrder // 是否立即抵扣
}
}
}
//todo: 其他促销
}
if prom != nil {
proms = append(proms, prom)
if rightBack {
totalSaveFee += saveFee
}
}
}
return proms, totalSaveFee
}
开发者ID:AlwaysOnline,项目名称:go2o,代码行数:42,代码来源:order.go
示例6: CheckCart
// 检查购物车
func (this *Shopping) CheckCart(cart shopping.ICart) error {
if cart == nil || len(cart.GetValue().Items) == 0 {
return shopping.ErrEmptyShoppingCart
}
sl := this._saleRep.GetSale(this._partnerId)
for _, v := range cart.GetValue().Items {
goods := sl.GetGoods(v.GoodsId)
if goods == nil {
return sale.ErrNoSuchGoods // 没有商品
}
stockNum := goods.GetValue().StockNum
if stockNum == 0 {
return sale.ErrFullOfStock // 已经卖完了
}
if stockNum < v.Quantity {
return sale.ErrOutOfStock // 超出库存
}
}
return nil
}
开发者ID:zoe527,项目名称:go2o,代码行数:22,代码来源:shopping.go
示例7: GetShoppingCart
func (this *Shopping) GetShoppingCart(buyerId int, cartKey string) shopping.ICart {
var hasOutCart = len(cartKey) != 0
var hasBuyer = buyerId != 0
var memCart shopping.ICart = nil // 消费者的购物车
var outCart shopping.ICart = nil // 通过cartKey传入的购物车
if hasBuyer {
// 如果没有传递cartKey ,或者传递的cart和会员绑定的购物车相同,直接返回
if memCart, _ = this.GetCurrentCart(buyerId); memCart != nil {
if !hasOutCart || memCart.GetValue().CartKey == cartKey {
return memCart
}
} else {
memCart = this.NewCart(buyerId)
}
}
if hasOutCart {
outCart, _ = this.GetCartByKey(cartKey)
}
// 合并购物车
if outCart != nil && hasBuyer {
if bid := outCart.GetValue().BuyerId; bid <= 0 || bid == buyerId {
memCart, _ = memCart.Combine(outCart)
outCart.Destroy()
memCart.Save()
}
}
if memCart != nil {
return memCart
}
if outCart != nil {
return outCart
}
return this.NewCart(buyerId)
// if !hasOutCart {
// if c == nil {
// // 新的购物车不存在,直接返回会员的购物车
// if mc != nil {
// return mc
// }
// } else {
// cv := c.GetValue()
// //合并购物车
// if cv.BuyerId <= 0 {
// // 设置购买者
// if hasBuyer {
// c.SetBuyer(buyerId)
// }
// } else if mc != nil && cv.BuyerId == buyerId {
// // 合并购物车
// nc, err := mc.Combine(c)
// if err == nil {
// nc.Save()
// return nc
// }
// return mc
// }
//
// // 如果没有购买,则返回
// return c
// }
// }
// 返回一个新的购物车
// return this.NewCart(buyerId)
}
开发者ID:heofonum,项目名称:go2o,代码行数:74,代码来源:shopping.go
示例8: NewCart
//创建购物车
// @buyerId 为购买会员ID,0表示匿名购物车
func (this *Shopping) NewCart(buyerId int) shopping.ICart {
var cart shopping.ICart = newCart(this._partnerRep, this._memberRep, this._saleRep,
this._goodsRep, this._rep, this._partnerId, buyerId)
cart.Save()
return cart
}
开发者ID:heofonum,项目名称:go2o,代码行数:8,代码来源:shopping.go
注:本文中的go2o/src/core/domain/interface/shopping.ICart类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论