Ejemplo n.º 1
0
Archivo: cart.go Proyecto: honj51/go2o
// 获取结算数据
func (this *Cart) GetSettleData() (s partner.IShop, d member.IDeliver, paymentOpt, deliverOpt int) {
	var err error
	if this.value.ShopId > 0 && this._shop == nil {
		var pt partner.IPartner
		pt, err = this.partnerRep.GetPartner(this.partnerId)
		if err == nil {
			this._shop = pt.GetShop(this.value.ShopId)
		}
	}
	if this.value.DeliverId > 0 && this._deliver == nil {
		var m member.IMember
		m, err = this.memberRep.GetMember(this.value.BuyerId)
		if err == nil {
			this._deliver = m.GetDeliver(this.value.DeliverId)
		}
	}
	return this._shop, this._deliver, this.value.PaymentOpt, this.value.DeliverOpt
}
Ejemplo n.º 2
0
Archivo: cart.go Proyecto: sunxboy/go2o
// 结算数据持久化
func (this *Cart) SettlePersist(shopId, paymentOpt, deliverOpt, deliverId int) error {
	var shop partner.IShop
	var deliver member.IDeliver
	var err error

	if shopId > 0 {
		var pt partner.IPartner
		pt, err = this._partnerRep.GetPartner(this._partnerId)
		if err != nil {
			return err
		}
		shop = pt.GetShop(shopId)
		if shop == nil {
			return partner.ErrNoSuchShop
		}
		this._shop = shop
		this._value.ShopId = shopId
	}

	if this._value.BuyerId > 0 && deliverId > 0 {
		var m member.IMember
		m, err = this._memberRep.GetMember(this._value.BuyerId)
		if err != nil {
			return err
		}
		deliver = m.GetDeliver(deliverId)
		fmt.Println("-----", m.GetAggregateRootId(), deliverId)
		if deliver == nil {
			return member.ErrInvalidSession
		}
		this._deliver = deliver
		this._value.DeliverId = deliverId
	}

	this._value.PaymentOpt = paymentOpt
	this._value.DeliverOpt = deliverOpt
	return nil
}