+ StoreMap.PricePercentagePack

This commit is contained in:
gazebo
2019-07-15 15:37:45 +08:00
parent 598a9738e8
commit ae4dff1b2d
5 changed files with 96 additions and 14 deletions

View File

@@ -15,11 +15,14 @@ type StoreDetail struct {
DeliveryFee int `json:"deliveryFee"`
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePack string `orm:"size(4096)" json:"pricePercentagePack"` //
PricePercentagePackObj model.PricePercentagePack `orm:"-" json:"-"`
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
model.Place // district info
DistrictName string `json:"-"`
@@ -35,11 +38,15 @@ type StoreDetail2 struct {
CityName string
}
func (s *StoreDetail) GetPricePerentage(price int) (pricePercentage int) {
return pricePercentage
}
func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (storeDetail *StoreDetail, err error) {
sql := `
SELECT t1.*,
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
t2.price_percentage, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
t2.price_percentage, t2.price_percentage_pack, t2.auto_pickup, t2.delivery_type, t2.delivery_competition, t2.is_sync,
district.code, district.name district_name, district.parent_code, district.level, district.tel_code,
district.jd_code, district.ebai_code, district.enabled, district.mtps_price,
city.name city_name
@@ -65,6 +72,9 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
storeDetail = &StoreDetail{}
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
storeDetail.Place.Name = storeDetail.DistrictName
if storeDetail.PricePercentagePack != "" {
utils.UnmarshalUseNumber([]byte(storeDetail.PricePercentagePack), &storeDetail.PricePercentagePackObj)
}
return storeDetail, nil
}
return nil, err

View File

@@ -227,11 +227,14 @@ type StoreMap struct {
VendorStoreID string `orm:"column(vendor_store_id);size(48)" json:"vendorStoreID"`
Status int `json:"status"` // 取值同Store.Status
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
DeliveryFee int `json:"deliveryFee"`
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
PricePercentagePack string `orm:"size(4096)" json:"pricePercentagePack"` //
PricePercentagePackObj PricePercentagePack `orm:"-" json:"-"`
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
DeliveryFee int `json:"deliveryFee"`
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
IsSync int8 `orm:"default(1)" json:"isSync"` // 是否同步
@@ -303,3 +306,27 @@ func (v *VendorStoreSnapshot) CompareOperationTime(s2 *VendorStoreSnapshot) int
}
return 1
}
type PricePercentageItem struct {
BeginPrice int `json:"beginPrice"` // 启始价格区间(包括)
PricePercentage int `json:"pricePercentage"` // 调价比例
}
type PricePercentagePack []*PricePercentageItem
func (l PricePercentagePack) Len() int {
return len(l)
}
// Less reports whether the element with
// index i should sort before the element with index j.
func (l PricePercentagePack) Less(i, j int) bool {
return l[i].BeginPrice < l[j].BeginPrice
}
// Swap swaps the elements with indexes i and j.
func (l PricePercentagePack) Swap(i, j int) {
tmp := l[i]
l[i] = l[j]
l[j] = tmp
}