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


Golang partner.IPartner类代码示例

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


在下文中一共展示了IPartner类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SavePartner

func (this *partnerService) SavePartner(partnerId int, v *partner.ValuePartner) (int, error) {
	var pt partner.IPartner
	var err error
	var isCreate bool

	v.Id = partnerId

	if partnerId > 0 {
		pt, _ = this._partnerRep.GetPartner(partnerId)
		if pt == nil {
			err = errors.New("no such partner")
		} else {
			err = pt.SetValue(v)
		}
	} else {
		isCreate = true
		pt, err = this._partnerRep.CreatePartner(v)
	}

	if err != nil {
		return 0, err
	}

	partnerId, err = pt.Save()

	if isCreate {
		this.initializePartner(partnerId)
	}

	return partnerId, err
}
开发者ID:jacobxk,项目名称:go2o,代码行数:31,代码来源:partner_service.go

示例2: updateShoppingMemberBackFee

// 更新返现到会员账户
func (this *Order) updateShoppingMemberBackFee(pt partner.IPartner,
	m member.IMember, fee float32, unixTime int64) {
	if fee == 0 {
		return
	}
	v := this.GetValue()
	pv := pt.GetValue()

	//更新账户
	acc := m.GetAccount()
	//acc.TotalFee += this._value.Fee
	//acc.TotalPay += this._value.PayFee
	acc.PresentBalance += fee // 更新赠送余额
	acc.TotalPresentFee += fee
	acc.UpdateTime = unixTime
	m.SaveAccount()

	//给自己返现
	icLog := &member.IncomeLog{
		MemberId:   this._value.MemberId,
		OrderId:    v.Id,
		Type:       "backcash",
		Fee:        fee,
		Log:        fmt.Sprintf("订单:%s(商家:%s)返现¥%.2f元", v.OrderNo, pv.Name, fee),
		State:      1,
		RecordTime: unixTime,
	}
	m.SaveIncomeLog(icLog)
}
开发者ID:AlwaysOnline,项目名称:go2o,代码行数:30,代码来源:order.go

示例3: backFor3R

// 三级返现
func (this *Order) backFor3R(pt partner.IPartner, m member.IMember,
	back_fee float32, unixTime int64) {
	if back_fee == 0 {
		return
	}

	i := 0
	mName := m.GetValue().Name
	saleConf := pt.GetSaleConf()
	percent := saleConf.CashBackTg2Percent
	for i < 2 {
		rl := m.GetRelation()
		if rl == nil || rl.InvitationMemberId == 0 {
			break
		}

		m = this._memberRep.GetMember(rl.InvitationMemberId)
		if m == nil {
			break
		}

		if i == 1 {
			percent = saleConf.CashBackTg1Percent
		}

		this.updateMemberAccount(m, pt.GetValue().Name, mName,
			back_fee*percent, unixTime)
		i++
	}
}
开发者ID:AlwaysOnline,项目名称:go2o,代码行数:31,代码来源:order.go

示例4: GetSettleData

// 获取结算数据
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
}
开发者ID:honj51,项目名称:go2o,代码行数:19,代码来源:cart.go

示例5: SavePartner

func (this *partnerService) SavePartner(partnerId int, v *partner.ValuePartner) (int, error) {
	var pt partner.IPartner
	var err error
	v.Id = partnerId

	if partnerId > 0 {
		pt, _ = this._partnerRep.GetPartner(partnerId)
		if pt == nil {
			err = errors.New("no such partner")
		} else {
			err = pt.SetValue(v)
		}
	} else {
		pt, err = this._partnerRep.CreatePartner(v)
	}

	if err != nil {
		return 0, err
	}

	return pt.Save()
}
开发者ID:honj51,项目名称:go2o,代码行数:22,代码来源:partner_service.go

示例6: updateShoppingMemberBackFee

// 更新返现到会员账户
func (this *Order) updateShoppingMemberBackFee(pt partner.IPartner,
	m member.IMember, fee float32, unixTime int64) {
	if fee == 0 {
		return
	}
	v := this.GetValue()
	pv := pt.GetValue()

	//更新账户
	acc := m.GetAccount()
	acv := acc.GetValue()
	//acc.TotalFee += this._value.Fee
	//acc.TotalPay += this._value.PayFee
	acv.PresentBalance += fee // 更新赠送余额
	acv.TotalPresentFee += fee
	acv.UpdateTime = unixTime
	acc.Save()

	//给自己返现
	tit := fmt.Sprintf("订单:%s(商家:%s)返现¥%.2f元", v.OrderNo, pv.Name, fee)
	acc.PresentBalance(tit, v.OrderNo, float32(fee))
}
开发者ID:zoe527,项目名称:go2o,代码行数:23,代码来源:order.go

示例7: SettlePersist

// 结算数据持久化
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
}
开发者ID:sunxboy,项目名称:go2o,代码行数:39,代码来源:cart.go

示例8: sendNotifyMail

func (this *Member) sendNotifyMail(pt partner.IPartner) error {
	tplId := pt.KvManager().GetInt(partner.KeyMssTplIdOfProfileComplete)
	if tplId > 0 {
		mailTpl := pt.MssManager().GetMailTemplate(tplId)
		if mailTpl != nil {
			tpl, err := pt.MssManager().CreateMsgTemplate(mailTpl)
			if err != nil {
				return err
			}

			//todo:?? data
			var data = map[string]string{
				"Name":           this._value.Name,
				"InvitationCode": this._value.InvitationCode,
			}

			return pt.MssManager().Send(tpl, data, []string{this._value.Email})
		}
	}
	return errors.New("no such email template")
}
开发者ID:henrylee2cn,项目名称:go2o,代码行数:21,代码来源:member.go

示例9: Complete

// 完成订单
func (this *Order) Complete() error {
	now := time.Now().Unix()
	v := this._value
	m := this._memberRep.GetMember(v.MemberId)
	if m == nil {
		return member.ErrNoSuchMember
	}
	var err error
	var ptl partner.IPartner
	ptl, err = this._partnerRep.GetPartner(v.PartnerId)
	if err != nil {
		log.Println("供应商异常!", v.PartnerId)
		log.PrintErr(err)
		return err
	}

	pv := ptl.GetValue()
	if pv.ExpiresTime < time.Now().Unix() {
		return errors.New("您的账户已经过期!")
	}

	// 增加经验
	if EXP_BIT == 0 {
		fv := infrastructure.GetApp().Config().GetFloat(variable.EXP_BIT)
		if fv <= 0 {
			panic("[WANNING]:Exp_bit not set!")
		}
		EXP_BIT = float32(fv)
	}
	if err = m.AddExp(int(v.Fee * EXP_BIT)); err != nil {
		return err
	}

	// 更新账户
	updateAccountForOrder(m, this)

	//******* 返现到账户  ************
	var back_fee float32
	saleConf := ptl.GetSaleConf()
	if saleConf.CashBackPercent > 0 {
		back_fee = v.Fee * saleConf.CashBackPercent

		//将此次消费记入会员账户
		this.updateShoppingMemberBackFee(ptl, m,
			back_fee*saleConf.CashBackMemberPercent, now)

		//todo: 增加阶梯的返积分,比如订单满30送100积分
		backIntegral := int(v.Fee)*saleConf.IntegralBackNum +
			saleConf.IntegralBackExtra

		// 赠送积分
		if backIntegral != 0 {
			err = m.AddIntegral(v.PartnerId, enum.INTEGRAL_TYPE_ORDER,
				backIntegral, fmt.Sprintf("订单返积分%d个", backIntegral))
			if err != nil {
				return err
			}
		}
	}

	this._value.Status = enum.ORDER_COMPLETED
	this._value.IsSuspend = 0
	this._value.UpdateTime = now

	_, err = this.Save()

	if err == nil {
		err = this.AppendLog(enum.ORDER_LOG_SETUP, false, "订单已完成")
		// 处理返现促销
		this.handleCashBackPromotions(ptl, m)
		// 三级返现
		if back_fee > 0 {
			this.backFor3R(ptl, m, back_fee, now)
		}
	}
	return err
}
开发者ID:AlwaysOnline,项目名称:go2o,代码行数:78,代码来源:order.go

示例10: Complete

// 完成订单
func (this *Order) Complete() error {
	now := time.Now().Unix()
	v := this._value
	m, err := this._memberRep.GetMember(v.MemberId)
	if err == nil {
		var ptl partner.IPartner
		ptl, err = this._partnerRep.GetPartner(v.PartnerId)
		if err != nil {
			log.Println("供应商异常!", v.PartnerId)
			log.PrintErr(err)
			return err
		}

		pv := ptl.GetValue()
		if pv.ExpiresTime < time.Now().Unix() {
			return errors.New("您的账户已经过期!")
		}

		//返现比例
		saleConf := ptl.GetSaleConf()
		back_fee := v.Fee * saleConf.CashBackPercent

		//将此次消费记入会员账户
		this.updateShoppingMemberAccount(ptl, m,
			back_fee*saleConf.CashBackMemberPercent, now)

		//todo: 增加阶梯的返积分,比如订单满30送100积分
		backIntegral := int(v.Fee)*saleConf.IntegralBackNum +
			saleConf.IntegralBackExtra

		//判断是否满足升级条件
		if backIntegral != 0 {
			err = m.AddIntegral(v.PartnerId, enum.INTEGRAL_TYPE_ORDER,
				backIntegral, fmt.Sprintf("订单返积分%d个", backIntegral))
			if err != nil {
				return err
			}
		}

		// 增加经验
		if EXP_BIT == 0 {
			fv := infrastructure.GetApp().
				Config().GetFloat(variable.EXP_BIT)
			EXP_BIT = float32(fv)
		}

		if EXP_BIT == 0 {
			log.Println("[WANNING]:Exp_bit not set!")
		}

		err = m.AddExp(int(v.Fee * EXP_BIT))
		if err != nil {
			return err
		}

		// 三级返现
		this.backFor3R(ptl, m, back_fee, now)

		this._value.Status = enum.ORDER_COMPLETED
		this._value.IsSuspend = 0
		this._value.UpdateTime = now

		_, err := this.Save()

		if err == nil {
			err = this.AppendLog(enum.ORDER_LOG_SETUP, false, "订单已完成")
		}
	}
	return err
}
开发者ID:keenhanzheng,项目名称:go2o,代码行数:71,代码来源:order.go


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