- 去除无用代码,主要是promotion相关的
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
type PromotionStoreSku struct {
|
||||
model.PromotionSku
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
}
|
||||
|
||||
func GenSkuPriceMapKey(storeID, skuID int) (key int64) {
|
||||
return int64(storeID)*1000000 + int64(skuID)
|
||||
}
|
||||
|
||||
func GetPromotionSkuPriceMap(db *DaoDB, vendorID int, storeIDs, skuIDs []int, fromTime, toTime time.Time) (skuPriceMap map[int64]*PromotionStoreSku, err error) {
|
||||
sql := `
|
||||
SELECT t2.store_id, t3.*
|
||||
FROM promotion t1
|
||||
JOIN promotion_store t2 ON t2.promotion_id = t1.id
|
||||
JOIN promotion_sku t3 ON t3.promotion_id = t1.id
|
||||
WHERE t1.deleted_at = ? AND t1.vendor_id = ? AND NOT (t1.begin_at > ? OR t1.end_at < ?) AND (t1.status = ? OR t1.status = ?)`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
vendorID,
|
||||
toTime,
|
||||
fromTime,
|
||||
model.PromotionStatusRemoteCreated,
|
||||
}
|
||||
if vendorID == model.VendorIDJX {
|
||||
sqlParams = append(sqlParams, model.PromotionStatusLocalCreated)
|
||||
} else {
|
||||
sqlParams = append(sqlParams, model.PromotionStatusRemoteCreated)
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND t2.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
sql += " AND t3.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
sql += " ORDER BY t2.store_id, t3.sku_id, t3.price"
|
||||
var skuPriceList []*PromotionStoreSku
|
||||
if err = GetRows(db, &skuPriceList, sql, sqlParams...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
skuPriceMap = make(map[int64]*PromotionStoreSku)
|
||||
for _, v := range skuPriceList {
|
||||
index := GenSkuPriceMapKey(v.StoreID, v.SkuID)
|
||||
if true /*skuPriceMap[index] == nil || v.EarningPrice < skuPriceMap[index].EarningPrice*/ {
|
||||
skuPriceMap[index] = v
|
||||
}
|
||||
}
|
||||
return skuPriceMap, err
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package legacymodel2
|
||||
|
||||
type Jdorder struct {
|
||||
Id int `orm:"column(id);auto"`
|
||||
Code string `orm:"column(code);size(2);null"`
|
||||
Msg string `orm:"column(msg);size(100);null"`
|
||||
Data string `orm:"column(data);null"`
|
||||
Success int8 `orm:"column(success);null"`
|
||||
Jdorderid int64 `orm:"column(jdorderid);null;unique"`
|
||||
VendorOrderID string `orm:"column(vendor_order_id);size(48);unique" json:"vendorOrderID"`
|
||||
Cityname string `orm:"column(cityname);size(20);null"`
|
||||
Orderstatus int `orm:"column(orderstatus);null"`
|
||||
Orderstatustime string `orm:"column(orderstatustime);size(50);null;index"`
|
||||
}
|
||||
|
||||
func (t *Jdorder) TableName() string {
|
||||
return "jdorder"
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
PromotionStatusLocalCreated = 0 // 本地成功创建,
|
||||
PromotionStatusRemoteFailed = 1 // 远程创建失败,
|
||||
PromotionStatusRemoteCreated = 2 // 远程成功创建,
|
||||
PromotionStatusCanceled = 3 // 被显示取消
|
||||
PromotionStatusEnded = 4 // 已经超过活动时间,且被显示置为结束
|
||||
)
|
||||
|
||||
const (
|
||||
PromotionCreateTypeByJX = 0
|
||||
PromotionCreateTypeByVendor = 1
|
||||
)
|
||||
|
||||
var (
|
||||
PromotionStatusName = map[int]string{
|
||||
PromotionStatusLocalCreated: "未确认",
|
||||
PromotionStatusRemoteFailed: "失败",
|
||||
PromotionStatusRemoteCreated: "正常",
|
||||
PromotionStatusCanceled: "取消",
|
||||
PromotionStatusEnded: "结束",
|
||||
}
|
||||
)
|
||||
|
||||
type Promotion struct {
|
||||
ModelIDCULD
|
||||
|
||||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||||
Name string `orm:"size(64)" json:"name"`
|
||||
Advertising string `orm:"size(255)" json:"advertising"`
|
||||
Type int `json:"type"`
|
||||
Status int `json:"status"`
|
||||
LimitDevice int8 `json:"limitDevice"`
|
||||
LimitPin int8 `json:"limitPin"`
|
||||
LimitDaily int8 `json:"limitDaily"`
|
||||
LimitCount int `json:"limitCount"`
|
||||
Source string `orm:"size(255)" json:"source"`
|
||||
CreateType int8 `json:"createType"`
|
||||
VendorPromotionID string `orm:"size(64);column(vendor_promotion_id);index" json:"vendorPromotionID"`
|
||||
BeginAt time.Time `orm:"type(datetime);index" json:"beginAt"`
|
||||
EndAt time.Time `orm:"type(datetime);index" json:"endAt"`
|
||||
Remark string `orm:"type(text)" json:"-"`
|
||||
}
|
||||
|
||||
func (*Promotion) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"Name", "VendorID", "Type", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
type PromotionStore struct {
|
||||
ModelIDCULD
|
||||
|
||||
PromotionID int `orm:"column(promotion_id)" json:"promotionID"`
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||||
}
|
||||
|
||||
func (*PromotionStore) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"PromotionID", "StoreID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
|
||||
type PromotionSku struct {
|
||||
ModelIDCULD
|
||||
|
||||
PromotionID int `orm:"column(promotion_id)" json:"promotionID"`
|
||||
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
||||
PriceType int `json:"priceType"`
|
||||
Price int `json:"price"` // 分,活动价,这个不是单价
|
||||
LimitSkuCount int `json:"limitSkuCount"`
|
||||
IsLock int8 `json:"isLock"` // 是否锁定门店商品信息
|
||||
|
||||
EarningPrice int `json:"earningPrice"` // 活动商品设置,结算给门店老板的钱
|
||||
}
|
||||
|
||||
func (*PromotionSku) TableUnique() [][]string {
|
||||
return [][]string{
|
||||
[]string{"PromotionID", "SkuID", "DeletedAt"},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user