expand orders
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"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
@@ -11,7 +13,7 @@ import (
|
||||
type UIOrdersRepo interface {
|
||||
UserHasOrder(user_id uint, order_id uint) (bool, 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) error
|
||||
PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, base_price float64, tax_incl float64, tax_excl float64) error
|
||||
ChangeOrderAddress(order_id uint, country_id uint, address_info string) error
|
||||
ChangeOrderStatus(order_id uint, status string) error
|
||||
}
|
||||
@@ -69,7 +71,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) error {
|
||||
func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, country_id uint, address_info string, base_price float64, tax_incl float64, tax_excl float64) error {
|
||||
order := model.CustomerOrder{
|
||||
UserID: cart.UserID,
|
||||
Name: name,
|
||||
@@ -87,6 +89,12 @@ func (repo *OrdersRepo) PlaceNewOrder(cart *model.CustomerCart, name string, cou
|
||||
})
|
||||
}
|
||||
|
||||
order.CreatedAt = time.Now()
|
||||
order.UpdatedAt = time.Now()
|
||||
order.BasePrice = base_price
|
||||
order.TaxIncl = tax_incl
|
||||
order.TaxExcl = tax_excl
|
||||
|
||||
return db.DB.Create(&order).Error
|
||||
}
|
||||
|
||||
@@ -97,6 +105,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
|
||||
}
|
||||
@@ -105,6 +114,9 @@ func (repo *OrdersRepo) ChangeOrderStatus(order_id uint, status string) error {
|
||||
return db.DB.
|
||||
Table("b2b_customer_orders").
|
||||
Where("order_id = ?", order_id).
|
||||
Update("status", status).
|
||||
Updates(map[string]interface{}{
|
||||
"status": status,
|
||||
"updated_at": time.Now(),
|
||||
}).
|
||||
Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user