Mhamdans17 commited on
Commit ·
24a5138
1
Parent(s): 52fc9c2
fix: add platform_fee to select query in ListOrders
Browse files- controllers/order_controller.go +1 -1
- testdb.go +19 -0
controllers/order_controller.go
CHANGED
|
@@ -255,7 +255,7 @@ func ListOrders(c *gin.Context) {
|
|
| 255 |
skip, _ := strconv.Atoi(skipStr)
|
| 256 |
limit, _ := strconv.Atoi(limitStr)
|
| 257 |
|
| 258 |
-
query := config.DB.Select("id, company_id, branch_id, order_number, total_amount, paid_amount, change_amount, payment_method, payment_status, midtrans_order_id, midtrans_token, created_at").
|
| 259 |
Preload("Branch", func(db *gorm.DB) *gorm.DB {
|
| 260 |
return db.Select("id, name")
|
| 261 |
}).
|
|
|
|
| 255 |
skip, _ := strconv.Atoi(skipStr)
|
| 256 |
limit, _ := strconv.Atoi(limitStr)
|
| 257 |
|
| 258 |
+
query := config.DB.Select("id, company_id, branch_id, order_number, total_amount, platform_fee, paid_amount, change_amount, payment_method, payment_status, midtrans_order_id, midtrans_token, created_at").
|
| 259 |
Preload("Branch", func(db *gorm.DB) *gorm.DB {
|
| 260 |
return db.Select("id, name")
|
| 261 |
}).
|
testdb.go
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"service-warungpos-go/config"
|
| 6 |
+
"service-warungpos-go/models"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
func main() {
|
| 10 |
+
config.LoadConfig()
|
| 11 |
+
config.ConnectDatabase()
|
| 12 |
+
|
| 13 |
+
var orders []models.Order
|
| 14 |
+
config.DB.Order("id desc").Limit(3).Find(&orders)
|
| 15 |
+
|
| 16 |
+
for _, o := range orders {
|
| 17 |
+
fmt.Printf("Order: %s | Total: %d | Fee: %d | PayMethod: %s\n", o.OrderNumber, o.TotalAmount, o.PlatformFee, o.PaymentMethod)
|
| 18 |
+
}
|
| 19 |
+
}
|