Merge branch 'main' of ssh://git.ma-al.com:8822/goc_daniel/b2b into order-actions
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package ordersRepo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/db"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model/enums"
|
||||
@@ -12,7 +14,7 @@ type UIOrdersRepo interface {
|
||||
UserHasOrder(user_id uint, order_id uint) (bool, error)
|
||||
Get(orderId uint) (*model.CustomerOrder, error)
|
||||
Find(user_id uint, p find.Paging, filt *filters.FiltersList) (*find.Found[model.CustomerOrder], error)
|
||||
PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, originalUserId uint) (*model.CustomerOrder, error)
|
||||
PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, originalUserId uint, base_price float64, tax_incl float64, tax_excl float64) (*model.CustomerOrder, error)
|
||||
ChangeOrderAddress(order_id uint, country_id uint, address_info string) error
|
||||
ChangeOrderStatus(orderId uint, newStatus enums.OrderStatus, userId uint) error
|
||||
GetOrderStatus(orderID uint) (enums.OrderStatus, error)
|
||||
@@ -83,7 +85,7 @@ func (repo *OrdersRepo) Find(user_id uint, p find.Paging, filt *filters.FiltersL
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, originalUserId uint) (*model.CustomerOrder, error) {
|
||||
func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, originalUserId uint, base_price float64, tax_incl float64, tax_excl float64) (*model.CustomerOrder, error) {
|
||||
order := model.CustomerOrder{
|
||||
UserID: cart.UserID,
|
||||
Name: name,
|
||||
@@ -100,6 +102,11 @@ func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, cou
|
||||
Amount: product.Amount,
|
||||
})
|
||||
}
|
||||
order.CreatedAt = time.Now()
|
||||
order.UpdatedAt = time.Now()
|
||||
order.BasePrice = base_price
|
||||
order.TaxIncl = tax_incl
|
||||
order.TaxExcl = tax_excl
|
||||
tx := db.Get().Begin()
|
||||
err := tx.Create(&order).Error
|
||||
if err != nil {
|
||||
@@ -133,6 +140,7 @@ func (repo *OrdersRepo) ChangeOrderAddress(order_id uint, country_id uint, addre
|
||||
Updates(map[string]interface{}{
|
||||
"country_id": country_id,
|
||||
"address_string": address_info,
|
||||
"updated_at": time.Now(),
|
||||
}).
|
||||
Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user