当前位置: 首页>>代码示例>>Golang>>正文


Golang shopping.ValueOrder类代码示例

本文整理汇总了Golang中go2o/src/core/domain/interface/shopping.ValueOrder的典型用法代码示例。如果您正苦于以下问题:Golang ValueOrder类的具体用法?Golang ValueOrder怎么用?Golang ValueOrder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ValueOrder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SaveOrder

func (this *shoppingRep) SaveOrder(partnerId int, v *shopping.ValueOrder) (int, error) {
	var err error
	d := this.Connector
	v.PartnerId = partnerId

	if v.Id > 0 {
		_, _, err = d.GetOrm().Save(v.Id, v)
	} else {
		//验证Partner和Member是否有绑定关系
		var num int
		if d.ExecScalar(`SELECT COUNT(0) FROM mm_relation WHERE member_id=? AND reg_partner_id=?`,
			&num, v.MemberId, v.PartnerId); num != 1 {
			return v.Id, errors.New("error partner and member.")
		}
		_, _, err = d.GetOrm().Save(nil, v)
		if err == nil {
			err = d.ExecScalar(`SELECT MAX(id) FROM pt_order WHERE partner_id=? AND member_id=?`, &v.Id,
				partnerId, v.MemberId)
		}
	}

	// 保存订单项
	if err == nil && v.Items != nil {
		orm := d.GetOrm()
		for _, v1 := range v.Items {
			if v1.Id > 0 {
				orm.Save(v1.Id, v1)
			} else {
				orm.Save(nil, v1)
			}
		}
	}

	return v.Id, err
}
开发者ID:linux-mac,项目名称:go2o,代码行数:35,代码来源:shopping_rep.go

示例3: SaveOrder

func (this *shoppingRep) SaveOrder(partnerId int, v *shopping.ValueOrder) (int, error) {
	var err error
	d := this.Connector
	v.PartnerId = partnerId

	if v.Id > 0 {
		_, _, err = d.GetOrm().Save(v.Id, v)
		if v.Status == enum.ORDER_COMPLETED {
			gof.CurrentApp.Storage().Set(variable.KvHaveNewCompletedOrder, enum.TRUE)
		}
	} else {
		//验证Partner和Member是否有绑定关系
		var num int
		if d.ExecScalar(`SELECT COUNT(0) FROM mm_relation WHERE member_id=? AND reg_partner_id=?`,
			&num, v.MemberId, v.PartnerId); num != 1 {
			return v.Id, errors.New("error partner and member.")
		}
		_, _, err = d.GetOrm().Save(nil, v)
		if err == nil {
			err = d.ExecScalar(`SELECT MAX(id) FROM pt_order WHERE partner_id=? AND member_id=?`, &v.Id,
				partnerId, v.MemberId)
		}

		// Sign new order
		gof.CurrentApp.Storage().Set(variable.KvHaveNewCreatedOrder, enum.TRUE)
	}

	// 保存订单项
	unix := time.Now().Unix()
	if err == nil && v.Items != nil {
		orm := d.GetOrm()
		for _, v1 := range v.Items {
			v1.OrderId = v.Id
			v1.UpdateTime = unix
			if v1.Id > 0 {
				orm.Save(v1.Id, v1)
			} else {
				orm.Save(nil, v1)
			}
		}
	}
	return v.Id, err
}
开发者ID:zoe527,项目名称:go2o,代码行数:43,代码来源:shopping_rep.go


注:本文中的go2o/src/core/domain/interface/shopping.ValueOrder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。