Files

42 lines
1.2 KiB
Go

package models
type Product struct {
Id int64 `json:"id"` // 商品ID
Identity string `json:"identity"` // 商品唯一标识
Title string `json:"title"` // 商品标题
CoverImage string `json:"cover_image"` // 商品封面图
SalesPrice int64 `json:"sales_price"` // 销售价格
CostPrice int64 `json:"cost_price"` // 成本价格
Args string `json:"args"` // 商品参数
StoreId uint `json:"store_id"` // 门店ID
StoreIdentity string `json:"store_identity"` // 门店标识
GasTypes int64 `json:"gas_types"` // 配送方式
SupplyId int64 `json:"supply_id"` // 供应商ID
}
type Spec struct {
Title string `json:"title"`
SerialNumber string `json:"serial_number"`
Price int64 `json:"price"`
}
func QuicklyCreateOrder(identity string, order *OrderSummary, detail []*OrderDetails) error {
tx := DBService.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()
if err := tx.Create(&order).Error; err != nil {
tx.Rollback()
return err
}
if len(detail) > 0 {
if err := tx.Create(&detail).Error; err != nil {
tx.Rollback()
return err
}
}
return tx.Commit().Error
}