예제 #1
0
파일: order.go 프로젝트: AlwaysOnline/go2o
func (this *Order) updateMemberAccount(m member.IMember,
	ptName, mName string, fee float32, unixTime int64) {
	if fee == 0 {
		return
	}

	//更新账户
	acc := m.GetAccount()
	acc.PresentBalance += fee
	acc.TotalPresentFee += fee
	acc.UpdateTime = unixTime
	m.SaveAccount()

	//给自己返现
	icLog := &member.IncomeLog{
		MemberId: this._value.MemberId,
		Type:     "backcash",
		Fee:      fee,
		Log: fmt.Sprintf("订单:%s(商家:%s,会员:%s)收入¥%.2f元",
			this._value.OrderNo, ptName, mName, fee),
		State:      1,
		RecordTime: unixTime,
	}
	m.SaveIncomeLog(icLog)
}
예제 #2
0
파일: order.go 프로젝트: AlwaysOnline/go2o
// 更新返现到会员账户
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)
}
예제 #3
0
파일: order.go 프로젝트: sunxboy/go2o
// 处理返现促销
func (this *Order) handleCashBackPromotion(pt partner.IPartner, m member.IMember,
	v *shopping.OrderPromotionBind, pm promotion.IPromotion) error {
	cpv := pm.GetRelationValue().(*promotion.ValueCashBack)

	//更新账户
	acc := m.GetAccount()
	acc.PresentBalance = acc.PresentBalance + float32(cpv.BackFee) // 更新赠送余额
	acc.Balance += float32(cpv.BackFee)                            // 更新账户余额
	acc.UpdateTime = time.Now().Unix()
	err := m.SaveAccount()

	if err == nil {
		// 优惠绑定生效
		v.IsApply = 1
		this._shoppingRep.SavePromotionBindForOrder(v)

		// 处理自定义返现
		c := pm.(promotion.ICashBackPromotion)
		HandleCashBackDataTag(m, this._value, c, this._memberRep)

		//给自己返现
		icLog := &member.IncomeLog{
			MemberId:   this._value.MemberId,
			OrderId:    this.GetDomainId(),
			Type:       "backcash",
			Fee:        float32(cpv.BackFee),
			Log:        fmt.Sprintf("返现¥%d元,订单号:%s", cpv.BackFee, this._value.OrderNo),
			State:      1,
			RecordTime: acc.UpdateTime,
		}
		err = m.SaveIncomeLog(icLog)
	}
	return err
}
예제 #4
0
파일: order.go 프로젝트: AlwaysOnline/go2o
// 更新账户
func updateAccountForOrder(m member.IMember, order shopping.IOrder) {
	acc := m.GetAccount()
	ov := order.GetValue()
	acc.TotalFee += ov.Fee
	acc.TotalPay += ov.PayFee
	acc.UpdateTime = time.Now().Unix()
	m.SaveAccount()
}
예제 #5
0
func backCashForMember(m member.IMember, order *shopping.ValueOrder, fee int, refName string) error {
	//更新账户
	acc := m.GetAccount()
	bfee := float32(fee)
	acc.PresentBalance += bfee // 更新赠送余额
	acc.TotalPresentFee += bfee
	acc.UpdateTime = time.Now().Unix()
	err := m.SaveAccount()

	if err == nil {
		//给自己返现
		icLog := &member.IncomeLog{
			MemberId:   m.GetAggregateRootId(),
			OrderId:    order.Id,
			Type:       "backcash",
			Fee:        float32(fee),
			Log:        fmt.Sprintf("推广返现¥%s元,订单号:%s,来源:%s", format.FormatFloat(bfee), order.OrderNo, refName),
			State:      1,
			RecordTime: acc.UpdateTime,
		}
		err = m.SaveIncomeLog(icLog)
	}
	return err
}