|
|
@@ -14,15 +14,17 @@ const (
|
|
|
)
|
|
|
|
|
|
type OrderDtItem struct {
|
|
|
- Id int64 `orm:"column(id);pk" json:"id"` // int(11)
|
|
|
- OrderId int64 `orm:"column(order_id)" json:"order_id"` // int(11)
|
|
|
- OrderNo string `orm:"column(order_no);null" json:"order_no"` // varchar(64)
|
|
|
- OrderDtId int64 `orm:"column(dt_id)" json:"order_dt_id"` // int(11)
|
|
|
- ProductId int64 `orm:"column(product_id)" json:"product_id"` // int(11)
|
|
|
- Price int64 `orm:"column(price)" json:"price"` // int(11)
|
|
|
- Title string `orm:"column(product_name);null" json:"title"` // varchar(64)
|
|
|
- Nums int64 `orm:"column(nums);null" json:"nums"` // tinyint(1)
|
|
|
- Send bool `orm:"column(is_zeng)" json:"send"`
|
|
|
+ Id int64 `orm:"column(id);pk" json:"id"` // int(11)
|
|
|
+ OrderId int64 `orm:"column(order_id)" json:"order_id"` // int(11)
|
|
|
+ OrderNo string `orm:"column(order_no);null" json:"order_no"` // varchar(64)
|
|
|
+ OrderDtId int64 `orm:"column(dt_id)" json:"order_dt_id"` // int(11)
|
|
|
+ ProductId int64 `orm:"column(product_id)" json:"product_id"` // int(11)
|
|
|
+ Price int64 `orm:"column(price)" json:"price"` // int(11)
|
|
|
+ Title string `orm:"column(product_name);null" json:"title"` // varchar(64)
|
|
|
+ Nums int64 `orm:"column(nums);null" json:"nums"` // tinyint(1)
|
|
|
+ Send bool `orm:"column(is_zeng)" json:"send"`
|
|
|
+ SizeName string `orm:"column(size_name)" json:"size_name"` // varchar(255)
|
|
|
+ ColorName string `orm:"column(color_name)" json:"color_name"` // varchar(255)
|
|
|
CreatedAt time.Time `orm:"column(created_at);auto_now_add;type(datetime)" json:"-"` // datetime
|
|
|
UpdatedAt time.Time `orm:"column(updated_at);auto_now;type(datetime)" json:"-"` // datetime
|
|
|
}
|
|
|
@@ -40,7 +42,7 @@ type ProductItem struct {
|
|
|
}
|
|
|
|
|
|
//创建订单明细项
|
|
|
-func (self *OrderDtItem) Create(orderNo, title string, pId, price, pCount, orderId, orderDtId int64, send bool) *OrderDtItem {
|
|
|
+func (self *OrderDtItem) Create(orderNo, title, sizeName, colorName string, pId, price, pCount, orderId, orderDtId int64, send bool) *OrderDtItem {
|
|
|
item := &OrderDtItem{
|
|
|
OrderNo: orderNo,
|
|
|
OrderId: orderId,
|
|
|
@@ -50,6 +52,8 @@ func (self *OrderDtItem) Create(orderNo, title string, pId, price, pCount, order
|
|
|
Title: title,
|
|
|
Nums: pCount,
|
|
|
Send: send,
|
|
|
+ SizeName: sizeName,
|
|
|
+ ColorName: colorName,
|
|
|
}
|
|
|
id, err := orm.NewOrm().Insert(item)
|
|
|
if err != nil {
|
|
|
@@ -62,15 +66,45 @@ func (self *OrderDtItem) Create(orderNo, title string, pId, price, pCount, order
|
|
|
|
|
|
//生成订单明细
|
|
|
func GenerateOrderDtItem(detail_item *OrderDetail) error {
|
|
|
+ sizeName := ""
|
|
|
+ colorName := ""
|
|
|
product := product_model.GetProductById(detail_item.ProductId, true)
|
|
|
if product.Package {
|
|
|
product_list := product_model.GetPackageList(product.Id, false)
|
|
|
for _, pd := range product_list {
|
|
|
+ pd_info := product_model.GetProductById(pd.ItemId, true)
|
|
|
+
|
|
|
+ //获取商品属性详情
|
|
|
+ if pd_info.SizeId > 0 {
|
|
|
+ productSize := product_model.GetProductAttrValueById(pd_info.SizeId)
|
|
|
+ if productSize != nil {
|
|
|
+ sizeName = productSize.Name
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if pd_info.ColorId > 0 {
|
|
|
+ productColor := product_model.GetProductAttrValueById(pd_info.ColorId)
|
|
|
+ if productColor != nil {
|
|
|
+ colorName = productColor.Name
|
|
|
+ }
|
|
|
+ }
|
|
|
count := detail_item.Count * pd.Nums
|
|
|
- new(OrderDtItem).Create(detail_item.OrderNo, pd.ItemTitle, pd.ItemId, detail_item.Price, count, detail_item.OrderId, detail_item.Id, detail_item.Send)
|
|
|
+ new(OrderDtItem).Create(detail_item.OrderNo, pd.ItemTitle, sizeName, colorName, pd.ItemId, detail_item.Price, count, detail_item.OrderId, detail_item.Id, detail_item.Send)
|
|
|
}
|
|
|
} else {
|
|
|
- new(OrderDtItem).Create(detail_item.OrderNo, product.Name, product.Id, detail_item.Price, detail_item.Count, detail_item.OrderId, detail_item.Id, detail_item.Send)
|
|
|
+ //获取商品属性详情
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ new(OrderDtItem).Create(detail_item.OrderNo, product.Name, sizeName, colorName, product.Id, detail_item.Price, detail_item.Count, detail_item.OrderId, detail_item.Id, detail_item.Send)
|
|
|
}
|
|
|
beego.BeeLogger.Warn("orderdtbase GenerateOrderDtItem ")
|
|
|
return nil
|