本文整理汇总了Golang中go2o/core/domain/interface/member.IMember类的典型用法代码示例。如果您正苦于以下问题:Golang IMember类的具体用法?Golang IMember怎么用?Golang IMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IMember类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: backFor3R
// 三级返现
func (o *subOrderImpl) backFor3R(mch merchant.IMerchant, m member.IMember,
back_fee float32, unixTime int64) (err error) {
if back_fee > 0 {
i := 0
mName := m.Profile().GetProfile().Name
saleConf := mch.ConfManager().GetSaleConf()
percent := saleConf.CashBackTg2Percent
for i < 2 {
rl := m.GetRelation()
if rl == nil || rl.RefereesId == 0 {
break
}
m = o._memberRep.GetMember(rl.RefereesId)
if m == nil {
break
}
if i == 1 {
percent = saleConf.CashBackTg1Percent
}
err = o.updateMemberAccount(m, mch.GetValue().Name, mName,
back_fee*percent, unixTime)
if err != nil {
domain.HandleError(err, "domain")
break
}
i++
}
}
return err
}
示例2: CanUse
// 是否可用
func (this *Coupon) CanUse(m member.IMember, fee float32) (bool, error) {
mv := m.GetValue()
cv := this.GetDetailsValue()
if this._value.Enabled == 0 {
return false, errors.New("无效的优惠券")
}
dtUnix := time.Now().Unix()
stUnix := cv.BeginTime
ovUnix := cv.OverTime
if dtUnix < stUnix {
return false, errors.New(fmt.Sprintf("优惠券必须在%s~%s使用",
time.Unix(cv.BeginTime, 0).Format("2006-01-02"),
time.Unix(cv.OverTime, 0).Format("2006-01-02")),
)
} else if dtUnix > ovUnix {
return false, errors.New("优惠拳已过期")
}
if cv.NeedBind == 0 && cv.Amount == 0 {
return false, errors.New("优惠券不足")
}
if mv.Level < cv.MinLevel {
return false, errors.New("会员等级不满足要求")
}
if fee < float32(cv.MinFee) {
return false, errors.New(fmt.Sprintf("订单金额需达到¥%d", cv.MinFee))
}
return true, nil
}
示例3: handleCashBackPromotion
// 处理返现促销
func (o *orderImpl) handleCashBackPromotion(pt merchant.IMerchant,
m member.IMember,
v *order.OrderPromotionBind, pm promotion.IPromotion) error {
cpv := pm.GetRelationValue().(*promotion.ValueCashBack)
//更新账户
bFee := float32(cpv.BackFee)
acc := m.GetAccount()
acv := acc.GetValue()
acv.PresentBalance += bFee // 更新赠送余额
acv.TotalPresentFee += bFee
// 赠送金额,不应该计入到余额,可采取充值到余额
//acc.Balance += float32(cpv.BackFee) // 更新账户余额
acv.UpdateTime = time.Now().Unix()
_, err := acc.Save()
if err == nil {
// 优惠绑定生效
v.IsApply = 1
o._orderRep.SavePromotionBindForOrder(v)
// 处理自定义返现
c := pm.(promotion.ICashBackPromotion)
HandleCashBackDataTag(m, o._value, c, o._memberRep)
//给自己返现
tit := fmt.Sprintf("返现¥%d元,订单号:%s", cpv.BackFee, o._value.OrderNo)
err = acc.PresentBalance(tit, o.GetOrderNo(), float32(cpv.BackFee))
}
return err
}
示例4: applyCoupon
// 应用优惠券
func (this *orderManagerImpl) applyCoupon(m member.IMember, order order.IOrder,
py payment.IPaymentOrder, couponCode string) error {
po := py.GetValue()
cp := this._promRep.GetCouponByCode(
m.GetAggregateRootId(), couponCode)
// 如果优惠券不存在
if cp == nil {
return errors.New("优惠券无效")
}
// 获取优惠券
coupon := cp.(promotion.ICouponPromotion)
result, err := coupon.CanUse(m, po.TotalFee)
if result {
if coupon.CanTake() {
_, err = coupon.GetTake(m.GetAggregateRootId())
//如果未占用,则占用
if err != nil {
err = coupon.Take(m.GetAggregateRootId())
}
} else {
_, err = coupon.GetBind(m.GetAggregateRootId())
}
if err != nil {
domain.HandleError(err, "domain")
err = errors.New("优惠券无效")
} else {
//应用优惠券
if err = order.ApplyCoupon(coupon); err == nil {
_, err = py.CouponDiscount(coupon)
}
}
}
return err
}
示例5: backCashForMember
func backCashForMember(m member.IMember, order *order.Order,
fee int, refName string) error {
//更新账户
acc := m.GetAccount()
acv := acc.GetValue()
bFee := float32(fee)
acv.PresentBalance += bFee // 更新赠送余额
acv.TotalPresentFee += bFee
acv.UpdateTime = time.Now().Unix()
_, err := acc.Save()
if err == nil {
tit := fmt.Sprintf("推广返现¥%s元,订单号:%s,来源:%s",
format.FormatFloat(bFee), order.OrderNo, refName)
err = acc.PresentBalance(tit, order.OrderNo, float32(fee))
}
return err
}
示例6: updateMemberAccount
func (o *subOrderImpl) updateMemberAccount(m member.IMember,
ptName, mName string, fee float32, unixTime int64) error {
if fee > 0 {
//更新账户
acc := m.GetAccount()
acv := acc.GetValue()
acv.PresentBalance += fee
acv.TotalPresentFee += fee
acv.UpdateTime = unixTime
_, err := acc.Save()
if err == nil {
//给自己返现
tit := fmt.Sprintf("订单:%s(商户:%s,会员:%s)收入¥%.2f元",
o._value.OrderNo, ptName, mName, fee)
err = acc.PresentBalance(tit, o._value.OrderNo, fee)
}
return err
}
return nil
}
示例7: GetSettleData
// 获取结算数据
func (this *cartImpl) GetSettleData() (s shop.IShop, d member.IDeliverAddress,
paymentOpt, deliverOpt int) {
//var err error
if this._value.ShopId > 0 && this._shop == nil {
//var pt merchant.IMerchant
//pt, err = this._partnerRep.GetMerchant(this._merchantId)
//if err == nil {
// this._shop = pt.ShopManager().GetShop(this._value.ShopId)
//}
//todo: not implement
}
if this._value.DeliverId > 0 && this._deliver == nil {
var m member.IMember
m = this._memberRep.GetMember(this._value.BuyerId)
if m != nil {
this._deliver = m.Profile().GetDeliver(this._value.DeliverId)
}
}
return this._shop, this._deliver, this._value.PaymentOpt, this._value.DeliverOpt
}
示例8: cashBack3R
func cashBack3R(level int, m member.IMember, order *order.Order, c promotion.ICashBackPromotion, memberRep member.IMemberRep) {
dt := c.GetDataTag()
var cm member.IMember = m
var pm member.IMember = m
// fmt.Println("------ START BACK ------")
var backFunc = func(m member.IMember, parentM member.IMember, fee int) {
// fmt.Println("---------[ back ]",parentM.GetValue().Name,fee)
backCashForMember(m, order, fee, parentM.Profile().GetProfile().Name)
}
var i int = 0
for true {
rl := cm.GetRelation()
// fmt.Println("-------- BACK - ID - ",rl.InvitationMemberId)
if rl == nil || rl.RefereesId == 0 {
break
}
cm = memberRep.GetMember(rl.RefereesId)
// fmt.Println("-------- BACK ",cm == nil)
if m == nil {
break
}
if fee, err := strconv.Atoi(dt[fmt.Sprintf("G%d", i)]); err == nil {
//log.Println("[ Back][ Cash] - ",i," back ",fee)
backFunc(cm, pm, fee)
}
pm = cm
i++
if i >= level {
break
}
}
}
示例9: updateShoppingMemberBackFee
// 更新返现到会员账户
func (o *subOrderImpl) updateShoppingMemberBackFee(mchName string,
m member.IMember, fee float32, unixTime int64) error {
if fee > 0 {
v := o.GetValue()
//更新账户
acc := m.GetAccount()
acv := acc.GetValue()
//acc.TotalFee += o._value.Fee
//acc.TotalPay += o._value.PayFee
acv.PresentBalance += fee // 更新赠送余额
acv.TotalPresentFee += fee
acv.UpdateTime = unixTime
acc.Save()
//给自己返现
tit := fmt.Sprintf("订单:%s(商户:%s)返现¥%.2f元", v.OrderNo, mchName, fee)
return acc.PresentBalance(tit, v.OrderNo, float32(fee))
}
return nil
}
示例10: SettlePersist
// 结算数据持久化
func (this *cartImpl) SettlePersist(shopId, paymentOpt, deliverOpt, deliverId int) error {
//var shop shop.IShop
var deliver member.IDeliverAddress
var err error
if shopId > 0 {
//var mch merchant.IMerchant
//mch, err = this._partnerRep.GetMerchant(this._merchantId)
//if err != nil {
// return err
//}
//shop = mch.ShopManager().GetShop(shopId)
//if shop == nil {
// return merchant.ErrNoSuchShop
//}
//this._shop = shop
//this._value.ShopId = shopId
//todo: not implement
return err
}
if this._value.BuyerId > 0 && deliverId > 0 {
var m member.IMember = this._memberRep.GetMember(this._value.BuyerId)
if m == nil {
return member.ErrNoSuchMember
}
deliver = m.Profile().GetDeliver(deliverId)
if deliver == nil {
return member.ErrInvalidSession
}
this._deliver = deliver
this._value.DeliverId = deliverId
}
this._value.PaymentOpt = paymentOpt
this._value.DeliverOpt = deliverOpt
return nil
}
示例11: createPaymentOrder
// 生成支付单
func (this *orderManagerImpl) createPaymentOrder(m member.IMember,
o order.IOrder) payment.IPaymentOrder {
val := o.GetValue()
v := &payment.PaymentOrderBean{
BuyUser: m.GetAggregateRootId(),
PaymentUser: m.GetAggregateRootId(),
VendorId: 0,
OrderId: 0,
// 支付单金额
TotalFee: val.FinalAmount,
// 余额抵扣
BalanceDiscount: 0,
// 积分抵扣
IntegralDiscount: 0,
// 系统支付抵扣金额
SystemDiscount: 0,
// 优惠券金额
CouponDiscount: 0,
// 立减金额
SubFee: 0,
// 支付选项
PaymentOpt: payment.OptPerm,
// 支付方式
PaymentSign: enum.PaymentOnlinePay,
//创建时间
CreateTime: time.Now().Unix(),
// 在线支付的交易单号
OuterNo: "",
//支付时间
PaidTime: 0,
// 状态: 0为未付款,1为已付款,2为已取消
State: payment.StateNotYetPayment,
}
v.FinalFee = v.TotalFee - v.SubFee - v.SystemDiscount -
v.IntegralDiscount - v.BalanceDiscount
return this._payRep.CreatePaymentOrder(v)
}
示例12: updateAccountForOrder
// 更新账户
func (o *subOrderImpl) updateAccountForOrder(m member.IMember) error {
if o._value.State != order.StatCompleted {
return order.ErrUnusualOrderStat
}
var err error
ov := o._value
conf := o._valRep.GetGlobNumberConf()
amount := ov.FinalAmount
acc := m.GetAccount()
// 增加经验
rate := conf.ExperienceRateByOrder
if exp := int(amount * rate); exp > 0 {
if err = m.AddExp(exp); err != nil {
return err
}
}
// 增加积分
//todo: 增加阶梯的返积分,比如订单满30送100积分
integral := int(amount*conf.IntegralRateByOrder) + conf.IntegralBackExtra
// 赠送积分
if integral > 0 {
err = m.GetAccount().AddIntegral(ov.VendorId, enum.INTEGRAL_TYPE_ORDER,
integral, fmt.Sprintf("订单返积分%d个", integral))
if err != nil {
return err
}
}
acv := acc.GetValue()
acv.TotalFee += ov.GoodsAmount
acv.TotalPay += ov.FinalAmount
acv.UpdateTime = time.Now().Unix()
_, err = acc.Save()
return err
}
示例13: GetMemberSummary
// 获取会员汇总信息
func (this *memberService) GetMemberSummary(memberId int) *dto.MemberSummary {
var m member.IMember = this._rep.GetMember(memberId)
if m != nil {
mv := m.GetValue()
acv := m.GetAccount().GetValue()
lv := m.GetLevel()
pro := m.Profile().GetProfile()
return &dto.MemberSummary{
Id: m.GetAggregateRootId(),
Usr: mv.Usr,
Name: pro.Name,
Avatar: format.GetResUrl(pro.Avatar),
Exp: mv.Exp,
Level: mv.Level,
LevelName: lv.Name,
Integral: acv.Integral,
Balance: acv.Balance,
PresentBalance: acv.PresentBalance,
GrowBalance: acv.GrowBalance,
GrowAmount: acv.GrowAmount,
GrowEarnings: acv.GrowEarnings,
GrowTotalEarnings: acv.GrowTotalEarnings,
UpdateTime: mv.UpdateTime,
}
}
return nil
}