|
|
@@ -159,24 +159,9 @@ func (self *OrderController) MultipleCreate() {
|
|
|
if product == nil {
|
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
}
|
|
|
-
|
|
|
- //获取商品属性详情
|
|
|
- sizeName := ""
|
|
|
- colorName := ""
|
|
|
- if product.SizeId > 0 {
|
|
|
- productSize := product_model.GetProductAttrValueById(product.SizeId)
|
|
|
- if productSize != nil {
|
|
|
- sizeName = productSize.Name
|
|
|
- }
|
|
|
- }
|
|
|
- if product.ColorId > 0 {
|
|
|
- productColor := product_model.GetProductAttrValueById(product.ColorId)
|
|
|
- if productColor != nil {
|
|
|
- colorName = productColor.Name
|
|
|
- }
|
|
|
- }
|
|
|
+ //创建订单明细
|
|
|
totalPrice += product.Price * cNums
|
|
|
- go new(order_model.OrderDetail).Create(order.OrderId, order.Id, cartItem.ProductId, product.Price, product.RoboBalancePrice, product.Name, sizeName, colorName, cNums)
|
|
|
+ go CreateOrderDetails(product, order, cNums)
|
|
|
}
|
|
|
freight := order_model.FREIGHT
|
|
|
if totalPrice >= order_model.FREIGHT_LIMIT || beego.AppConfig.String("RunMode") == "dev" {
|
|
|
@@ -233,23 +218,9 @@ func (self *OrderController) MultShopCreate() {
|
|
|
self.ReturnError(403, apps.NoShopSale, "", nil)
|
|
|
}
|
|
|
|
|
|
- //获取商品属性详情
|
|
|
- sizeName := ""
|
|
|
- colorName := ""
|
|
|
- if product.SizeId > 0 {
|
|
|
- productSize := product_model.GetProductAttrValueById(product.SizeId)
|
|
|
- if productSize != nil {
|
|
|
- sizeName = productSize.Name
|
|
|
- }
|
|
|
- }
|
|
|
- if product.ColorId > 0 {
|
|
|
- productColor := product_model.GetProductAttrValueById(product.ColorId)
|
|
|
- if productColor != nil {
|
|
|
- colorName = productColor.Name
|
|
|
- }
|
|
|
- }
|
|
|
+ //创建订单明细
|
|
|
totalPrice += product.Price * cNums
|
|
|
- go new(order_model.OrderDetail).Create(order.OrderId, order.Id, pId, product.Price, product.RoboBalancePrice, product.Name, sizeName, colorName, cNums)
|
|
|
+ go CreateOrderDetails(product, order, cNums)
|
|
|
}
|
|
|
freight := order_model.FREIGHT
|
|
|
if totalPrice >= order_model.FREIGHT_LIMIT || beego.AppConfig.String("RunMode") == "dev" {
|
|
|
@@ -270,7 +241,7 @@ func (self *OrderController) MultShopCreate() {
|
|
|
}
|
|
|
|
|
|
func ClearCart(userId int64, orderId string) {
|
|
|
- orderDetails := order_model.GetAllDetailsOrderId(orderId)
|
|
|
+ orderDetails := order_model.GetAllDetailsOrderId(orderId, true)
|
|
|
for _, item := range orderDetails {
|
|
|
cartItem := order_model.GetCartByUidAndPid(userId, item.ProductId)
|
|
|
if cartItem != nil {
|
|
|
@@ -289,7 +260,7 @@ func (self *OrderController) Detail() {
|
|
|
beego.BeeLogger.Error("order not exist id=[%s]", oId)
|
|
|
self.ReturnError(404, apps.OrderNotExist, "", nil)
|
|
|
}
|
|
|
- orderList := order_model.GetAllDetailsOrderId(o.OrderId)
|
|
|
+ orderList := order_model.GetAllDetailsOrderId(o.OrderId, true)
|
|
|
for _, item := range orderList {
|
|
|
product := product_model.GetProductById(item.ProductId, cache)
|
|
|
if product == nil {
|
|
|
@@ -360,7 +331,7 @@ func (self *OrderController) List() {
|
|
|
count := order_model.GetUserOrdersCount(wxUId, status)
|
|
|
|
|
|
for _, item := range orders {
|
|
|
- orderList := order_model.GetAllDetailsOrderId(item.OrderId)
|
|
|
+ orderList := order_model.GetAllDetailsOrderId(item.OrderId, true)
|
|
|
for _, orderItem := range orderList {
|
|
|
product := product_model.GetProductById(orderItem.ProductId, cache)
|
|
|
if product == nil {
|
|
|
@@ -485,3 +456,22 @@ func (self *OrderController) MerchantListCount() {
|
|
|
self.Data["json"] = &Ret{ListCount: count}
|
|
|
self.ServeJSON()
|
|
|
}
|
|
|
+
|
|
|
+func CreateOrderDetails(product *product_model.Product, order *order_model.Order, cNums int64) {
|
|
|
+ //获取商品属性详情
|
|
|
+ sizeName := ""
|
|
|
+ colorName := ""
|
|
|
+ if product.SizeId > 0 {
|
|
|
+ productSize := product_model.GetProductAttrValueById(product.SizeId)
|
|
|
+ if productSize != nil {
|
|
|
+ sizeName = productSize.Name
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if product.ColorId > 0 {
|
|
|
+ productColor := product_model.GetProductAttrValueById(product.ColorId)
|
|
|
+ if productColor != nil {
|
|
|
+ colorName = productColor.Name
|
|
|
+ }
|
|
|
+ }
|
|
|
+ go new(order_model.OrderDetail).Create(order.OrderId, order.Id, product.Id, product.Price, product.RoboBalancePrice, product.Name, sizeName, colorName, cNums)
|
|
|
+}
|