+ StoreMap.PricePercentagePack
This commit is contained in:
@@ -2025,7 +2025,7 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, v := range storeSkuList {
|
for _, v := range storeSkuList {
|
||||||
pricePercentage := int(storeMap[v.StoreID].PricePercentage)
|
pricePercentage := jxutils.GetPricePercentageByVendorPrice(storeMap[v.StoreID].PricePercentagePackObj, v.Price, int(storeMap[v.StoreID].PricePercentage))
|
||||||
skuName := skuNameMap[skuMap[v.SkuID].NameID]
|
skuName := skuNameMap[skuMap[v.SkuID].NameID]
|
||||||
v.Price = jxutils.CaculateSkuPriceFromVendor(v.Price, pricePercentage, 0)
|
v.Price = jxutils.CaculateSkuPriceFromVendor(v.Price, pricePercentage, 0)
|
||||||
v.UnitPrice = jxutils.CaculateSkuPriceFromVendor(skuName.Price, pricePercentage, 0)
|
v.UnitPrice = jxutils.CaculateSkuPriceFromVendor(skuName.Price, pricePercentage, 0)
|
||||||
|
|||||||
@@ -243,6 +243,40 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, catPercentage int) int
|
|||||||
return price
|
return price
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercentage int) (pricePercentage int) {
|
||||||
|
pricePercentage = defPricePercentage
|
||||||
|
// if len(l) > 0 {
|
||||||
|
// var lastItem *model.PricePercentageItem
|
||||||
|
// for _, v := range l {
|
||||||
|
// lastItem = v
|
||||||
|
// if v.BeginPrice > price {
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if lastItem != nil {
|
||||||
|
// pricePercentage = lastItem.PricePercentage
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return pricePercentage
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPricePercentageByVendorPrice(l model.PricePercentagePack, vendorPrice int, defPricePercentage int) (pricePercentage int) {
|
||||||
|
pricePercentage = defPricePercentage
|
||||||
|
// if len(l) > 0 {
|
||||||
|
// var lastItem *model.PricePercentageItem
|
||||||
|
// for _, v := range l {
|
||||||
|
// lastItem = v
|
||||||
|
// if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, 0) > vendorPrice {
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if lastItem != nil {
|
||||||
|
// pricePercentage = lastItem.PricePercentage
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return pricePercentage
|
||||||
|
}
|
||||||
|
|
||||||
func IsSkuSpecial(specQuality float32, specUnit string) bool {
|
func IsSkuSpecial(specQuality float32, specUnit string) bool {
|
||||||
return int(specQuality) == model.SpecialSpecQuality && (specUnit == model.SpecialSpecUnit || specUnit == model.SpecialSpecUnit2)
|
return int(specQuality) == model.SpecialSpecQuality && (specUnit == model.SpecialSpecUnit || specUnit == model.SpecialSpecUnit2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ type StoreDetail struct {
|
|||||||
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
SyncStatus int8 `orm:"default(2)" json:"syncStatus"`
|
||||||
|
|
||||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
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"` // 是否自动拣货
|
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||||
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
DeliveryCompetition int8 `orm:"default(1)" json:"deliveryCompetition"` // 是否支持配送竞争
|
||||||
@@ -35,11 +38,15 @@ type StoreDetail2 struct {
|
|||||||
CityName string
|
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) {
|
func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (storeDetail *StoreDetail, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*,
|
SELECT t1.*,
|
||||||
t2.vendor_store_id, t2.status vendor_status, t2.delivery_fee, t2.sync_status,
|
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.code, district.name district_name, district.parent_code, district.level, district.tel_code,
|
||||||
district.jd_code, district.ebai_code, district.enabled, district.mtps_price,
|
district.jd_code, district.ebai_code, district.enabled, district.mtps_price,
|
||||||
city.name city_name
|
city.name city_name
|
||||||
@@ -65,6 +72,9 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
|||||||
storeDetail = &StoreDetail{}
|
storeDetail = &StoreDetail{}
|
||||||
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
|
if err = GetRow(db, storeDetail, sql, sqlParams...); err == nil {
|
||||||
storeDetail.Place.Name = storeDetail.DistrictName
|
storeDetail.Place.Name = storeDetail.DistrictName
|
||||||
|
if storeDetail.PricePercentagePack != "" {
|
||||||
|
utils.UnmarshalUseNumber([]byte(storeDetail.PricePercentagePack), &storeDetail.PricePercentagePackObj)
|
||||||
|
}
|
||||||
return storeDetail, nil
|
return storeDetail, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -228,6 +228,9 @@ type StoreMap struct {
|
|||||||
Status int `json:"status"` // 取值同Store.Status
|
Status int `json:"status"` // 取值同Store.Status
|
||||||
|
|
||||||
PricePercentage int16 `orm:"default(100)" json:"pricePercentage"` // todo 厂商价格相对于本地价格的百分比,这个字段的修改会比较特殊,因为可能需要刷新厂商价格
|
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"` // 是否自动拣货
|
AutoPickup int8 `orm:"default(1)" json:"autoPickup"` // 是否自动拣货
|
||||||
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
DeliveryType int8 `orm:"default(0)" json:"deliveryType"` // 配送类型
|
||||||
DeliveryFee int `json:"deliveryFee"`
|
DeliveryFee int `json:"deliveryFee"`
|
||||||
@@ -303,3 +306,27 @@ func (v *VendorStoreSnapshot) CompareOperationTime(s2 *VendorStoreSnapshot) int
|
|||||||
}
|
}
|
||||||
return 1
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ type tStoreSkuFullInfo struct {
|
|||||||
EbaiCat3ID int64 `orm:"column(ebai_cat3_id)"`
|
EbaiCat3ID int64 `orm:"column(ebai_cat3_id)"`
|
||||||
|
|
||||||
PricePercentage int
|
PricePercentage int
|
||||||
|
PricePercentagePack string `orm:"size(4096)" json:"pricePercentagePack"` //
|
||||||
|
PricePercentagePackObj model.PricePercentagePack `orm:"-" json:"-"`
|
||||||
|
|
||||||
CatPricePercentage int
|
CatPricePercentage int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +85,8 @@ var (
|
|||||||
|
|
||||||
func (p *PurchaseHandler) getDirtyStoreSkus(db *dao.DaoDB, storeID int, skuIDs []int) (storeSkuInfoList []*tStoreSkuFullInfo, err error) {
|
func (p *PurchaseHandler) getDirtyStoreSkus(db *dao.DaoDB, storeID int, skuIDs []int) (storeSkuInfoList []*tStoreSkuFullInfo, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t8.price_percentage, t1.*, t2.spec_quality, t2.spec_unit, t2.weight, t2.status sku_status,
|
SELECT t8.price_percentage, t8.price_percentage_pack,
|
||||||
|
t1.*, t2.spec_quality, t2.spec_unit, t2.weight, t2.status sku_status,
|
||||||
t3.id name_id, t3.prefix, t3.name, t2.comment, t3.is_global, t3.unit, IF(t3.img_ebai <> '', t3.img_ebai, t3.img) img, t3.upc, t3.desc_img_ebai,
|
t3.id name_id, t3.prefix, t3.name, t2.comment, t3.is_global, t3.unit, IF(t3.img_ebai <> '', t3.img_ebai, t3.img) img, t3.upc, t3.desc_img_ebai,
|
||||||
t4.name cat_name, t4.ebai_price_percentage cat_price_percentage,
|
t4.name cat_name, t4.ebai_price_percentage cat_price_percentage,
|
||||||
t4.id cat_id, t4.level cat_level, t5.ebai_id cat_ebai_id,
|
t4.id cat_id, t4.level cat_level, t5.ebai_id cat_ebai_id,
|
||||||
@@ -119,6 +123,13 @@ func (p *PurchaseHandler) getDirtyStoreSkus(db *dao.DaoDB, storeID int, skuIDs [
|
|||||||
}
|
}
|
||||||
sql += " ORDER BY t1.price DESC"
|
sql += " ORDER BY t1.price DESC"
|
||||||
err = dao.GetRows(db, &storeSkuInfoList, sql, sqlParams...)
|
err = dao.GetRows(db, &storeSkuInfoList, sql, sqlParams...)
|
||||||
|
if err == nil {
|
||||||
|
for _, v := range storeSkuInfoList {
|
||||||
|
if v.PricePercentagePack != "" {
|
||||||
|
utils.UnmarshalUseNumber([]byte(v.PricePercentagePack), &v.PricePercentagePackObj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return storeSkuInfoList, err
|
return storeSkuInfoList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user