parent
e818c6a652
commit
c0c9c249b8
@ -0,0 +1,28 @@
|
||||
package activity
|
||||
|
||||
func (Activity) TableName() string {
|
||||
return "activity"
|
||||
}
|
||||
|
||||
type Activity struct {
|
||||
ID int `json:"id"` // 活动ID
|
||||
Title string `json:"title"` // 活动标题
|
||||
Type string `json:"type"` // 活动类型
|
||||
RichtextID int `json:"richtext_id"` // 富文本ID
|
||||
RichtextTitle string `json:"richtext_title"` // 富文本标题
|
||||
StartTime int64 `json:"starttime"` // 活动开始时间
|
||||
EndTime int64 `json:"endtime"` // 活动结束时间
|
||||
Rules Rules `json:"rules" ` // 活动规则
|
||||
StatusCode string `json:"status_code"` // 活动状态码
|
||||
}
|
||||
type Rules struct {
|
||||
ActivityAutoClose string `json:"activity_auto_close"` // 活动自动关闭
|
||||
FictitiousNum string `json:"fictitious_num"` // 虚拟号码
|
||||
IsAlone string `json:"is_alone"` // 是否单独
|
||||
IsFictitious string `json:"is_fictitious"` // 是否虚拟
|
||||
LimitBuy string `json:"limit_buy"` // 限购
|
||||
OrderAutoClose string `json:"order_auto_close"` // 订单自动关闭
|
||||
TeamCard string `json:"team_card"` // 团购卡
|
||||
TeamNum string `json:"team_num"` // 团购人数
|
||||
ValidTime string `json:"valid_time"` // 有效时间
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
|
||||
"github.com/towgo/towgo/towgo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
xormDriver.Sync2(new(Activity))
|
||||
towgo.NewCRUDJsonrpcAPI("/activity", Activity{}, []Activity{}).RegAPI()
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
package common
|
||||
|
||||
type TimeRange struct {
|
||||
Start int64 `json:"start"` // 开始时间
|
||||
End int64 `json:"end"` // 结束时间
|
||||
}
|
||||
@ -1,27 +1,45 @@
|
||||
package goods
|
||||
|
||||
import "src/module/common"
|
||||
|
||||
func (Coupon) TableName() string {
|
||||
return "coupon"
|
||||
}
|
||||
|
||||
// Coupon 结构体表示优惠券信息
|
||||
type Coupon struct {
|
||||
ID int `json:"id"` // 优惠券ID
|
||||
ID int64 `json:"id"` // 优惠券ID
|
||||
Name string `json:"name"` // 优惠券名称
|
||||
Type string `json:"type"` // 优惠券类型
|
||||
GoodsID string `json:"goods_ids"` // 商品ID
|
||||
Amount string `json:"amount"` // 优惠券金额
|
||||
GoodsIds string `json:"goods_ids"` // 关联商品ID
|
||||
Amount string `json:"amount"` // 优惠金额
|
||||
Enough string `json:"enough"` // 满足条件金额
|
||||
Stock int `json:"stock"` // 库存数量
|
||||
Limit int `json:"limit"` // 领取限制
|
||||
GetTime common.TimeRange `json:"gettime"` // 领取时间范围
|
||||
UseTime common.TimeRange `json:"usetime"` // 使用时间范围
|
||||
Stock int64 `json:"stock"` // 库存
|
||||
Limit int64 `json:"limit"` // 领取限制
|
||||
Usetimestart int64 `json:"usetimestart"` // 可使用时间段开始
|
||||
Usetimeend int64 `json:"usetimeend"` // 可使用时间段结束
|
||||
Gettimestart int64 `json:"gettimestart"` // 可领取时间段开始
|
||||
Gettimeend int64 `json:"gettimeend"` // 可领取时间段结束
|
||||
Description string `json:"description"` // 优惠券描述
|
||||
StartTime int64 `json:"gettimestart"` // 领取开始时间
|
||||
EndTime int64 `json:"gettimeend"` // 领取结束时间
|
||||
Status string `json:"status_code"` // 优惠券状态代码
|
||||
StatusCode string `json:"status_code"` // 优惠券状态代码
|
||||
StatusName string `json:"status_name"` // 优惠券状态名称
|
||||
UserCoupons []string `json:"user_coupons"` // 用户优惠券列表
|
||||
GetTime TimeRange `json:"gettime" xorm:"-"` // 可领取时间段
|
||||
UseTime TimeRange `json:"usetime" xorm:"-"` // 可使用时间段
|
||||
UserCoupons []string `json:"user_coupons" xorm:"-"` // 用户优惠券列表
|
||||
}
|
||||
|
||||
type TimeRange struct {
|
||||
Start int64 `json:"start"` // 开始时间
|
||||
End int64 `json:"end"` // 结束时间
|
||||
}
|
||||
|
||||
func (coupon *Coupon) AfterQuery() error {
|
||||
coupon.GetTime = TimeRange{
|
||||
coupon.Gettimestart,
|
||||
coupon.Gettimeend,
|
||||
}
|
||||
coupon.UseTime = TimeRange{
|
||||
coupon.Usetimestart,
|
||||
coupon.Usetimeend,
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package itemGoodsSkuPrice
|
||||
|
||||
func (ItemGoodsSkuPrice) TableName() string {
|
||||
return "item_goods_sku_price"
|
||||
}
|
||||
|
||||
// ItemGoodsSkuPrice 结构体表示商品 SKU 的价格信息中的具体项
|
||||
type ItemGoodsSkuPrice struct {
|
||||
ID int64 `json:"id"` // 唯一标识
|
||||
ActivityID int64 `json:"activity_id"` // 活动的唯一标识
|
||||
SkuPriceID int64 `json:"sku_price_id"` // SKU 价格的唯一标识
|
||||
GoodsID int64 `json:"goods_id"` // 商品的唯一标识
|
||||
Stock int64 `json:"stock"` // 库存
|
||||
Sales int64 `json:"sales"` // 销量
|
||||
Price string `json:"price"` // 价格
|
||||
Status string `json:"status"` // 状态
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package itemGoodsSkuPrice
|
||||
|
||||
import (
|
||||
"github.com/towgo/towgo/dao/ormDriver/xormDriver"
|
||||
"github.com/towgo/towgo/towgo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
xormDriver.Sync2(new(ItemGoodsSkuPrice))
|
||||
towgo.NewCRUDJsonrpcAPI("/itemGoodsSkuPrice", ItemGoodsSkuPrice{}, []ItemGoodsSkuPrice{}).RegAPI()
|
||||
|
||||
}
|
||||
@ -1,22 +1,48 @@
|
||||
package goods
|
||||
|
||||
import (
|
||||
"github.com/towgo/towgo/dao/basedboperat"
|
||||
"src/module/itemGoodsSkuPrice"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (SKUPrice) TableName() string {
|
||||
return "sku_price"
|
||||
}
|
||||
|
||||
// SKUPrice 结构体表示SKU价格信息
|
||||
// SKUPrice 结构体表示商品 SKU 的价格信息
|
||||
type SKUPrice struct {
|
||||
ID int `json:"id"` // SKU价格ID
|
||||
GoodsID int `json:"goods_id"` // 商品ID
|
||||
Weigh int `json:"weigh"` // 重量
|
||||
Image string `json:"image"` // 图片
|
||||
Stock int `json:"stock"` // 库存
|
||||
StockWarning string `json:"stock_warning"` // 库存警告
|
||||
Sales int `json:"sales"` // 销售数量
|
||||
SN string `json:"sn"` // 序列号
|
||||
Weight int `json:"weight"` // 重量
|
||||
ID int64 `json:"id"` // SKU 价格的唯一标识
|
||||
GoodsSkuIds []int64 `json:"goods_sku_ids"` // 商品 SKU 的标识数组
|
||||
GoodsId int64 `json:"goods_id"` // 商品的唯一标识
|
||||
Weigh int64 `json:"weigh"` // 权重
|
||||
Image string `json:"image"` // 图片链接
|
||||
Stock int64 `json:"stock"` // 库存
|
||||
StockWarning interface{} `json:"stock_warning"` // 库存预警信息,根据实际情况调整数据类型
|
||||
Sales int64 `json:"sales"` // 销量
|
||||
SN string `json:"sn"` // 商品编号
|
||||
Weight int64 `json:"weight"` // 重量
|
||||
Price string `json:"price"` // 价格
|
||||
GoodsSKUText string `json:"goods_sku_text"` // 商品SKU文本
|
||||
GoodsSkuText string `json:"goods_sku_text"` // 商品 SKU 文本描述
|
||||
Status string `json:"status"` // 状态
|
||||
GoodsSKUIDArr []string `json:"goods_sku_id_arr"` // 商品SKU ID数组
|
||||
GrouponPrice string `json:"groupon_price"` // 团购价格
|
||||
ActivityType string `json:"activity_type"` // 活动类型
|
||||
ActivityId int64 `json:"activity_id"` // 活动的唯一标识
|
||||
ItemGoodsSkuPrice itemGoodsSkuPrice.ItemGoodsSkuPrice `json:"item_goods_sku_price" xorm:"-"` // 商品 SKU 价格信息
|
||||
GoodsSkuIdArr []string `json:"goods_sku_id_arr" xorm:"-"` // 商品 SKU 标识数组
|
||||
}
|
||||
|
||||
func (sku *SKUPrice) AfterQuery(session basedboperat.DbTransactionSession) error {
|
||||
var item itemGoodsSkuPrice.ItemGoodsSkuPrice
|
||||
err := session.Get(&item, nil, "sku_price_id = ?", sku.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sku.ItemGoodsSkuPrice = item
|
||||
for _, id := range sku.GoodsSkuIds {
|
||||
sku.GoodsSkuIdArr = append(sku.GoodsSkuIdArr, strconv.FormatInt(id, 10))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue