Revert "feat(loyalty): EnakPoint & EnakCoin" (#32)

This reverts merge commit 645da30, returning main to f0ff59f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
efrilm
2026-09-30 15:16:15 +07:00
co-authored by Claude Opus 5.5
parent 645da3048e
commit 4e24f9bbb0
195 changed files with 2179 additions and 20060 deletions
@@ -60,8 +60,6 @@ func PaymentMethodAnalyticsModelToContract(resp *models.PaymentMethodAnalyticsRe
OrderCount: item.OrderCount,
PaymentCount: item.PaymentCount,
Percentage: item.Percentage,
PointsUsed: item.PointsUsed,
CountsAsCashIn: item.CountsAsCashIn,
})
}
@@ -74,9 +72,6 @@ func PaymentMethodAnalyticsModelToContract(resp *models.PaymentMethodAnalyticsRe
GroupBy: resp.GroupBy,
Summary: contract.PaymentMethodSummary{
TotalAmount: resp.Summary.TotalAmount,
PointAmount: resp.Summary.PointAmount,
PointsUsed: resp.Summary.PointsUsed,
TotalWithPoints: resp.Summary.TotalWithPoints,
TotalOrders: resp.Summary.TotalOrders,
TotalPayments: resp.Summary.TotalPayments,
AverageOrderValue: resp.Summary.AverageOrderValue,
@@ -622,8 +617,6 @@ func DashboardAnalyticsModelToContract(resp *models.DashboardAnalyticsResponse)
OrderCount: item.OrderCount,
PaymentCount: item.PaymentCount,
Percentage: item.Percentage,
PointsUsed: item.PointsUsed,
CountsAsCashIn: item.CountsAsCashIn,
})
}
@@ -5,6 +5,131 @@ import (
"apskel-pos-be/internal/models"
)
// Customer Points Transformers
func CreateCustomerPointsRequestToModel(req *contract.CreateCustomerPointsRequest) *models.CreateCustomerPointsRequest {
return &models.CreateCustomerPointsRequest{
CustomerID: req.CustomerID,
Balance: req.Balance,
}
}
func UpdateCustomerPointsRequestToModel(req *contract.UpdateCustomerPointsRequest) *models.UpdateCustomerPointsRequest {
return &models.UpdateCustomerPointsRequest{
Balance: req.Balance,
}
}
func ListCustomerPointsRequestToModel(req *contract.ListCustomerPointsRequest) *models.ListCustomerPointsQuery {
return &models.ListCustomerPointsQuery{
Page: req.Page,
Limit: req.Limit,
Search: req.Search,
SortBy: req.SortBy,
SortOrder: req.SortOrder,
}
}
func CustomerPointsModelToResponse(model *models.CustomerPointsResponse) *contract.CustomerPointsResponse {
if model == nil {
return nil
}
var customer *contract.CustomerResponse
if model.Customer != nil {
customer = CustomerModelToResponse(model.Customer)
}
return &contract.CustomerPointsResponse{
ID: model.ID,
CustomerID: model.CustomerID,
Balance: model.Balance,
Customer: customer,
CreatedAt: model.CreatedAt,
UpdatedAt: model.UpdatedAt,
}
}
func PaginatedCustomerPointsResponseToContract(model *models.PaginatedCustomerPointsResponse) *contract.PaginatedCustomerPointsResponse {
if model == nil {
return nil
}
responses := make([]contract.CustomerPointsResponse, len(model.Data))
for i, item := range model.Data {
responses[i] = *CustomerPointsModelToResponse(&item)
}
return &contract.PaginatedCustomerPointsResponse{
Data: responses,
TotalCount: model.TotalCount,
Page: model.Page,
Limit: model.Limit,
TotalPages: model.TotalPages,
}
}
// Customer Tokens Transformers
func CreateCustomerTokensRequestToModel(req *contract.CreateCustomerTokensRequest) *models.CreateCustomerTokensRequest {
return &models.CreateCustomerTokensRequest{
CustomerID: req.CustomerID,
TokenType: req.TokenType,
Balance: req.Balance,
}
}
func UpdateCustomerTokensRequestToModel(req *contract.UpdateCustomerTokensRequest) *models.UpdateCustomerTokensRequest {
return &models.UpdateCustomerTokensRequest{
Balance: req.Balance,
}
}
func ListCustomerTokensRequestToModel(req *contract.ListCustomerTokensRequest) *models.ListCustomerTokensQuery {
return &models.ListCustomerTokensQuery{
Page: req.Page,
Limit: req.Limit,
Search: req.Search,
TokenType: req.TokenType,
SortBy: req.SortBy,
SortOrder: req.SortOrder,
}
}
func CustomerTokensModelToResponse(model *models.CustomerTokensResponse) *contract.CustomerTokensResponse {
if model == nil {
return nil
}
var customer *contract.CustomerResponse
if model.Customer != nil {
customer = CustomerModelToResponse(model.Customer)
}
return &contract.CustomerTokensResponse{
ID: model.ID,
CustomerID: model.CustomerID,
TokenType: model.TokenType,
Balance: model.Balance,
Customer: customer,
CreatedAt: model.CreatedAt,
UpdatedAt: model.UpdatedAt,
}
}
func PaginatedCustomerTokensResponseToContract(model *models.PaginatedResponse[models.CustomerTokensResponse]) *contract.PaginatedCustomerTokensResponse {
responses := make([]contract.CustomerTokensResponse, len(model.Data))
for i, item := range model.Data {
responses[i] = *CustomerTokensModelToResponse(&item)
}
return &contract.PaginatedCustomerTokensResponse{
Data: responses,
TotalCount: int(model.Pagination.Total),
Page: model.Pagination.Page,
Limit: model.Pagination.Limit,
TotalPages: model.Pagination.TotalPages,
}
}
// Tier Transformers
func CreateTierRequestToModel(req *contract.CreateTierRequest) *models.CreateTierRequest {
return &models.CreateTierRequest{
@@ -225,7 +350,7 @@ func CreateGamePlayRequestToModel(req *contract.CreateGamePlayRequest) *models.C
return &models.CreateGamePlayRequest{
GameID: req.GameID,
CustomerID: req.CustomerID,
CoinsUsed: req.CoinsUsed,
TokenUsed: req.TokenUsed,
RandomSeed: req.RandomSeed,
}
}
@@ -234,6 +359,7 @@ func PlayGameRequestToModel(req *contract.PlayGameRequest) *models.PlayGameReque
return &models.PlayGameRequest{
GameID: req.GameID,
CustomerID: req.CustomerID,
TokenUsed: req.TokenUsed,
}
}
@@ -275,8 +401,7 @@ func GamePlayModelToResponse(model *models.GamePlayResponse) *contract.GamePlayR
GameID: model.GameID,
CustomerID: model.CustomerID,
PrizeID: model.PrizeID,
CoinsUsed: model.CoinsUsed,
TokenUsed: model.CoinsUsed,
TokenUsed: model.TokenUsed,
RandomSeed: model.RandomSeed,
CreatedAt: model.CreatedAt,
Game: game,
@@ -308,8 +433,7 @@ func PlayGameModelToResponse(model *models.PlayGameResponse) *contract.PlayGameR
return &contract.PlayGameResponse{
GamePlay: gamePlayValue,
PrizeWon: prizeWon,
CoinsRemaining: model.CoinsRemaining,
TokensRemaining: model.CoinsRemaining,
TokensRemaining: model.TokensRemaining,
}
}
@@ -161,8 +161,6 @@ func OrderModelToContract(resp *models.OrderResponse) *contract.OrderResponse {
TotalPaid: resp.TotalPaid,
PaymentCount: resp.PaymentCount,
SplitType: resp.SplitType,
PointsEarned: resp.PointsEarned,
CoinsEarned: resp.CoinsEarned,
}
}
@@ -324,8 +322,6 @@ func CreatePaymentContractToModel(req *contract.CreatePaymentRequest) *models.Cr
return &models.CreatePaymentRequest{
OrderID: req.OrderID,
PaymentMethodID: req.PaymentMethodID,
Points: req.Points,
PaymentCode: req.PaymentCode,
Amount: req.Amount,
TransactionID: req.TransactionID,
SplitNumber: req.SplitNumber,
@@ -367,8 +363,6 @@ func PaymentModelToContract(resp *models.PaymentResponse) *contract.PaymentRespo
SplitType: resp.SplitType,
SplitDescription: resp.SplitDescription,
RefundAmount: resp.RefundAmount,
PointsUsed: resp.PointsUsed,
PointValue: resp.PointValue,
RefundReason: resp.RefundReason,
RefundedAt: resp.RefundedAt,
RefundedBy: resp.RefundedBy,
@@ -1,14 +1,11 @@
package transformer
import (
"encoding/json"
"testing"
"apskel-pos-be/internal/contract"
"apskel-pos-be/internal/models"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -49,14 +46,3 @@ func TestAddToOrderContractToModelCarriesWeight(t *testing.T) {
require.NotNil(t, result.OrderItems[0].Weight)
require.Equal(t, weight, *result.OrderItems[0].Weight)
}
func TestOrderModelToContractCarriesEarnings(t *testing.T) {
got := OrderModelToContract(&models.OrderResponse{PointsEarned: 875, CoinsEarned: 3})
assert.Equal(t, int64(875), got.PointsEarned)
assert.Equal(t, int64(3), got.CoinsEarned)
body, err := json.Marshal(OrderModelToContract(&models.OrderResponse{}))
assert.NoError(t, err)
assert.Contains(t, string(body), `"points_earned":0`, "present as 0 when nothing was earned")
assert.Contains(t, string(body), `"coins_earned":0`)
}