fix(balance): add timestamp to balance logs for payment, refund, and recharge transactions
This commit is contained in:
parent
71d32d73bb
commit
3199dc5141
@ -411,10 +411,11 @@ func (l *PurchaseCheckoutLogic) balancePayment(u *user.User, o *order.Order) err
|
|||||||
// Create balance log if regular balance was used
|
// Create balance log if regular balance was used
|
||||||
if balanceUsed > 0 {
|
if balanceUsed > 0 {
|
||||||
balanceLog := &log.Balance{
|
balanceLog := &log.Balance{
|
||||||
Amount: balanceUsed,
|
Amount: balanceUsed,
|
||||||
Type: log.BalanceTypePayment, // Type 3 represents payment deduction
|
Type: log.BalanceTypePayment, // Type 3 represents payment deduction
|
||||||
OrderId: o.Id,
|
OrderId: o.Id,
|
||||||
Balance: userInfo.Balance,
|
Balance: userInfo.Balance,
|
||||||
|
Timestamp: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
content, _ := balanceLog.Marshal()
|
content, _ := balanceLog.Marshal()
|
||||||
err = db.Create(&log.SystemLog{
|
err = db.Create(&log.SystemLog{
|
||||||
|
|||||||
@ -94,10 +94,11 @@ func (l *UnsubscribeLogic) Unsubscribe(req *types.UnsubscribeRequest) error {
|
|||||||
balanceRefundAmount := balance - u.Balance
|
balanceRefundAmount := balance - u.Balance
|
||||||
if balanceRefundAmount > 0 {
|
if balanceRefundAmount > 0 {
|
||||||
balanceLog := log.Balance{
|
balanceLog := log.Balance{
|
||||||
OrderId: userSub.OrderId,
|
OrderId: userSub.OrderId,
|
||||||
Amount: balanceRefundAmount,
|
Amount: balanceRefundAmount,
|
||||||
Type: log.BalanceTypeRefund, // Type 4 represents refund transaction
|
Type: log.BalanceTypeRefund, // Type 4 represents refund transaction
|
||||||
Balance: balance,
|
Balance: balance,
|
||||||
|
Timestamp: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
content, _ := balanceLog.Marshal()
|
content, _ := balanceLog.Marshal()
|
||||||
|
|
||||||
|
|||||||
@ -622,10 +622,11 @@ func (l *ActivateOrderLogic) Recharge(ctx context.Context, orderInfo *order.Orde
|
|||||||
}
|
}
|
||||||
|
|
||||||
balanceLog := &log.Balance{
|
balanceLog := &log.Balance{
|
||||||
Amount: orderInfo.Price,
|
Amount: orderInfo.Price,
|
||||||
Type: CommissionTypeRecharge,
|
Type: CommissionTypeRecharge,
|
||||||
OrderId: orderInfo.Id,
|
OrderId: orderInfo.Id,
|
||||||
Balance: userInfo.Balance,
|
Balance: userInfo.Balance,
|
||||||
|
Timestamp: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
content, _ := balanceLog.Marshal()
|
content, _ := balanceLog.Marshal()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user