Mhamdans17 commited on
Commit ·
3bfd210
1
Parent(s): 9f5aad1
feat: include detailed bought items and branch in point history reason
Browse files
controllers/order_controller.go
CHANGED
|
@@ -989,11 +989,26 @@ func awardPoints(tx *gorm.DB, order *models.Order, company *models.Company) {
|
|
| 989 |
}
|
| 990 |
}
|
| 991 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 992 |
history := models.PointHistory{
|
| 993 |
CompanyID: company.ID,
|
| 994 |
MemberID: member.ID,
|
| 995 |
PointsDelta: pointsToAdd,
|
| 996 |
-
Reason: "
|
| 997 |
}
|
| 998 |
tx.Create(&history)
|
| 999 |
|
|
|
|
| 989 |
}
|
| 990 |
}
|
| 991 |
|
| 992 |
+
var itemNames string
|
| 993 |
+
for i, item := range order.Items {
|
| 994 |
+
pName := "Item"
|
| 995 |
+
if item.Product != nil {
|
| 996 |
+
pName = item.Product.Name
|
| 997 |
+
}
|
| 998 |
+
if i > 0 {
|
| 999 |
+
itemNames += ", "
|
| 1000 |
+
}
|
| 1001 |
+
itemNames += fmt.Sprintf("%dx %s", item.Quantity, pName)
|
| 1002 |
+
}
|
| 1003 |
+
if len(itemNames) > 45 {
|
| 1004 |
+
itemNames = itemNames[:42] + "..."
|
| 1005 |
+
}
|
| 1006 |
+
|
| 1007 |
history := models.PointHistory{
|
| 1008 |
CompanyID: company.ID,
|
| 1009 |
MemberID: member.ID,
|
| 1010 |
PointsDelta: pointsToAdd,
|
| 1011 |
+
Reason: "Beli " + itemNames + " (Cabang " + branchName + ")",
|
| 1012 |
}
|
| 1013 |
tx.Create(&history)
|
| 1014 |
|