Exemple #1
0
// 获取会员汇总信息
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
}
Exemple #2
0
// 处理返现促销
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
}
Exemple #3
0
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
}
Exemple #4
0
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
}
Exemple #5
0
// 更新返现到会员账户
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
}
Exemple #6
0
// 更新返现到会员账户
func (o *orderImpl) updateShoppingMemberBackFee(pt merchant.IMerchant,
	m member.IMember, fee float32, unixTime int64) {
	if fee == 0 {
		return
	}
	v := o.GetValue()
	pv := pt.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, pv.Name, fee)
	acc.PresentBalance(tit, v.OrderNo, float32(fee))
}
Exemple #7
0
// 更新账户
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
}