c
This commit is contained in:
261
business/model/legacymodel/act.go
Normal file
261
business/model/legacymodel/act.go
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ActTypeAll = -1
|
||||||
|
ActSkuFake = 0 // 假活动,只用于存储活动结算信息
|
||||||
|
ActSkuDirectDown = 3 // 直降
|
||||||
|
ActSkuSecKill = 4 // 秒杀
|
||||||
|
ActSkuDiscount = 5 // 折扣
|
||||||
|
|
||||||
|
ActDiscountTypePrice = 1 //折扣类型是最低价
|
||||||
|
ActDiscountTypePercentage = 2 //折扣类型是最低折扣
|
||||||
|
|
||||||
|
TrendTypeUp = 1 //涨价趋势
|
||||||
|
TrendTypeDown = 2 //降价趋势
|
||||||
|
TrendTypeNothing = 0 //不变
|
||||||
|
|
||||||
|
ActOrderBegin = 10
|
||||||
|
ActOrderMoneyOff = 11
|
||||||
|
ActOrderMoneyOffCoupon = 12
|
||||||
|
ActOrderReduceFreight = 13
|
||||||
|
ActOrderReduceFreightCoupon = 14
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ActStatusNA = 0 // 未知
|
||||||
|
ActStatusCreated = 1 // 需同步
|
||||||
|
ActStatusCanceled = 2 // 需同步
|
||||||
|
ActStatusEnded = 3 // 不需要同步,根据活动时间自动刷新的
|
||||||
|
|
||||||
|
ActCreateTypeAPI = 1
|
||||||
|
ActCreateTypeCallback = 2
|
||||||
|
ActCreateTypeSpider = 3
|
||||||
|
|
||||||
|
OverlapRuleNormal = 0 // 不允许重叠(重叠会报错)
|
||||||
|
OverlapRuleReplace = 1 // 相同活动类型,或秒杀替换直降
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ActTypeName = map[int]string{
|
||||||
|
ActSkuFake: "结算",
|
||||||
|
ActSkuDirectDown: "直降",
|
||||||
|
ActSkuSecKill: "秒杀",
|
||||||
|
ActSkuDiscount: "折扣",
|
||||||
|
}
|
||||||
|
|
||||||
|
ActStatusName = map[int]string{
|
||||||
|
ActStatusNA: "未知",
|
||||||
|
ActStatusCreated: "正常",
|
||||||
|
ActStatusCanceled: "取消",
|
||||||
|
ActStatusEnded: "结束",
|
||||||
|
}
|
||||||
|
|
||||||
|
ActCreateTypeName = map[int]string{
|
||||||
|
ActCreateTypeAPI: "API",
|
||||||
|
ActCreateTypeCallback: "回调",
|
||||||
|
ActCreateTypeSpider: "网页",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type Act struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
Name string `orm:"size(64)" json:"name"`
|
||||||
|
Advertising string `orm:"size(255)" json:"advertising"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
LimitUser int `json:"limitUser"` // 是否按用户限制
|
||||||
|
LimitDaily int `json:"limitDaily"` // 每日限购单数
|
||||||
|
LimitCount int `json:"limitCount"` // 每单限购数量
|
||||||
|
Source string `orm:"size(255)" json:"source"`
|
||||||
|
CreateType int `json:"createType"`
|
||||||
|
IsSpecial int8 `json:"isSpecial"` // 是否是特殊绑定活动
|
||||||
|
OverlapRule int `json:"overlapRule"`
|
||||||
|
PricePercentage int `json:"pricePercentage"` // 单品级活动才有效
|
||||||
|
BeginAt time.Time `orm:"type(datetime);index" json:"beginAt"`
|
||||||
|
EndAt time.Time `orm:"type(datetime);index" json:"endAt"`
|
||||||
|
VendorMask int `json:"-"`
|
||||||
|
Remark string `orm:"size(255)" json:"remark"`
|
||||||
|
DiscountType int `json:"discountType"` //折扣类型,1为最低价,2为最低折扣
|
||||||
|
DiscountValue1 int `json:"DiscountValue1"` //第一档折扣
|
||||||
|
DiscountValue2 int `json:"DiscountValue2"` //第二档折扣
|
||||||
|
}
|
||||||
|
|
||||||
|
// test
|
||||||
|
func (*Act) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"Name", "Type", "DeletedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActMap struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
ActID int `orm:"column(act_id)" json:"actID"`
|
||||||
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
|
|
||||||
|
VendorActID string `orm:"column(vendor_act_id);size(48)" json:"vendorActID"`
|
||||||
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||||
|
|
||||||
|
Remark string `orm:"size(1024)" json:"remark"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ActMap) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"ActID", "VendorID", "DeletedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ActMap) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"VendorActID", "VendorID", "DeletedAt"}, // 饿百,美团活动的VendorActID统一为空,不能设置为唯一索引
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不建表
|
||||||
|
type Act2 struct {
|
||||||
|
MapID int `orm:"column(map_id)"`
|
||||||
|
|
||||||
|
Act
|
||||||
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||||
|
|
||||||
|
VendorActID string `orm:"column(vendor_act_id);size(48)" json:"vendorActID"`
|
||||||
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Act2) GetRealActName() string {
|
||||||
|
if IsSyncStatusNeedCreate(a.SyncStatus) {
|
||||||
|
return a.Name
|
||||||
|
}
|
||||||
|
return a.Name + "_" + utils.Int64ToStr(time.Now().Unix())
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActOrderRule struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
ActID int `orm:"column(act_id)" json:"actID"`
|
||||||
|
SalePrice int64 `orm:"" json:"salePrice"` // 满的价格
|
||||||
|
DeductPrice int64 `orm:"" json:"deductPrice"` // 减的价格
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActStoreSku struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
ActID int `orm:"column(act_id)" json:"actID"`
|
||||||
|
|
||||||
|
OriginalPrice int64 `orm:"" json:"originalPrice"` // 单品级活动用,创建活动时商品的原始京西价
|
||||||
|
|
||||||
|
// 以下字段,API中有效
|
||||||
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
|
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
||||||
|
|
||||||
|
PricePercentage int `orm:"" json:"pricePercentage"` // 单品级活动用,SKU级的价格比例,非0覆盖Act中的PricePercentage
|
||||||
|
ActPrice int64 `orm:"" json:"actPrice"` // 单品级活动用,SKU级指定的价格,非0覆盖CustomPricePercentage与Act中的PricePercentage
|
||||||
|
EarningPrice int64 `json:"earningPrice"` // 活动商品设置,结算给门店老板的钱
|
||||||
|
Stock int `orm:"" json:"stock"` // 活动库存
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ActStoreSku) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"ActID", "StoreID", "SkuID", "DeletedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActStoreSkuMap struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
BindID int `orm:"column(bind_id)" json:"bindID"`
|
||||||
|
ActID int `orm:"column(act_id)" json:"actID"`
|
||||||
|
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||||
|
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
||||||
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
|
||||||
|
VendorActID string `orm:"column(vendor_act_id);size(48)" json:"vendorActID"`
|
||||||
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||||
|
VendorPrice int64 `json:"vendorPrice"` // 创建活动时的平台价格
|
||||||
|
ActualActPrice int64 `json:"actualActPrice"` // 单品级活动用,创建活动时商品的活动价格
|
||||||
|
EarningPrice int64 `json:"earningPrice"` // 活动商品设置,结算给门店老板的钱
|
||||||
|
TrendType int `json:"trendType"` //折扣活动使用,涨跌趋势,1为涨,2为跌,0为不动
|
||||||
|
TrendPrice int `json:"trendPrice"` //涨跌具体多少
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ActStoreSkuMap) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"ActID", "BindID", "VendorID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ActStoreSkuMap) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"ActID", "StoreID", "SkuID", "VendorID", "DeletedAt"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不建表
|
||||||
|
type ActStoreSku2 struct {
|
||||||
|
MapID int `orm:"column(map_id)"`
|
||||||
|
|
||||||
|
Type int `json:"type"`
|
||||||
|
DiscountType int `json:"discountType"`
|
||||||
|
DiscountValue1 int `json:"discountValue1"`
|
||||||
|
DiscountValue2 int `json:"discountValue2"`
|
||||||
|
|
||||||
|
ActStoreSku
|
||||||
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
|
||||||
|
VendorActID string `orm:"column(vendor_act_id);size(48)" json:"vendorActID"`
|
||||||
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||||
|
VendorPrice int64 `json:"vendorPrice"` // 创建活动时的平台价格
|
||||||
|
ActualActPrice int64 `json:"actualActPrice"` // 单品级活动用,创建活动时商品的活动价格
|
||||||
|
|
||||||
|
VendorStoreID string `orm:"column(vendor_store_id)" json:"vendorStoreID"`
|
||||||
|
StoreName string `json:"storeName"`
|
||||||
|
|
||||||
|
VendorSkuID string `orm:"column(vendor_sku_id)" json:"vendorSkuID"`
|
||||||
|
|
||||||
|
SkuName string `json:"skuName"`
|
||||||
|
|
||||||
|
Prefix string `json:"-"`
|
||||||
|
ExPrefix string
|
||||||
|
ExPrefixBegin *time.Time
|
||||||
|
ExPrefixEnd *time.Time
|
||||||
|
SkuNameName string `orm:"column(sku_name_name)" json:"-"`
|
||||||
|
Unit string `orm:"size(8)" json:"-"`
|
||||||
|
SpecQuality float32 `json:"-"`
|
||||||
|
SpecUnit string `json:"-"`
|
||||||
|
Comment string `json:"-"`
|
||||||
|
TrendType int `json:"trendType"` //折扣活动使用,涨跌趋势,1为涨,2为跌,0为不动
|
||||||
|
TrendPrice int `json:"trendPrice"` //涨跌具体多少
|
||||||
|
}
|
||||||
|
|
||||||
|
type StoreSkuAct struct {
|
||||||
|
ModelIDCUL
|
||||||
|
StoreID int `orm:"column(store_id)"`
|
||||||
|
SkuID int `orm:"column(sku_id);index"`
|
||||||
|
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||||
|
|
||||||
|
ActPercentage int `json:"actPercentage"` // 直降活动百分比
|
||||||
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||||
|
// ActID int `orm:"column(act_id);index" json:"actID"`
|
||||||
|
VendorActID string `orm:"column(vendor_act_id);size(48);index" json:"vendorActID"`
|
||||||
|
HintActID int `orm:"column(hint_act_id);size(48);index" json:"hintActID"`
|
||||||
|
VendorActPrice int64 `json:"vendorActPrice"` // 保存数据用,实际的活动价
|
||||||
|
Remark string `orm:"column(remark);size(1024)" json:"remark"`
|
||||||
|
|
||||||
|
// EarningActID int `orm:"column(earning_act_id);index" json:"earningActID"`
|
||||||
|
// EarningPrice int64 `json:"earningPrice"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*StoreSkuAct) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"StoreID", "SkuID", "VendorID"},
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user