shan
This commit is contained in:
@@ -797,14 +797,6 @@ func OperationTime2Str2(openTime, closeTime int16) (str string) {
|
||||
return str
|
||||
}
|
||||
|
||||
func OperationTimeStr4VendorStore(v *model.VendorStoreSnapshot) (str string) {
|
||||
str = fmt.Sprintf("%s", OperationTime2Str2(v.OpenTime1, v.CloseTime1))
|
||||
if v.OpenTime2 > 0 && v.CloseTime2 > 0 {
|
||||
str += fmt.Sprintf(",%s", OperationTime2Str2(v.OpenTime2, v.CloseTime2))
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func OperationTime2HourMinuteFormat(time time.Time) (i int16) {
|
||||
return int16(time.Hour()*100 + time.Minute())
|
||||
}
|
||||
@@ -895,30 +887,23 @@ func GetOneEmailFromStr(str string) (email string) {
|
||||
|
||||
// 计算一个坐标点距离一个门店的距离,单位为米,如果不在有效范围内,则返回0
|
||||
func Point2StoreDistance(lng, lat float64, intStoreLng, intStoreLat int, deliveryRangeType int8, deliveryRange string) (distance int) {
|
||||
storeLng := IntCoordinate2Standard(intStoreLng)
|
||||
storeLat := IntCoordinate2Standard(intStoreLat)
|
||||
if deliveryRangeType == model.DeliveryRangeTypeRadius {
|
||||
maxDistance := int(utils.Str2Int64WithDefault(deliveryRange, 0))
|
||||
distance = int(EarthDistance(lng, lat, storeLng, storeLat) * 1000)
|
||||
if distance > maxDistance {
|
||||
distance = 0
|
||||
}
|
||||
} else {
|
||||
points := CoordinateStr2Points(deliveryRange)
|
||||
if utils.IsPointInPolygon(lng, lat, points) {
|
||||
distance = int(EarthDistance(lng, lat, storeLng, storeLat) * 1000)
|
||||
}
|
||||
}
|
||||
// storeLng := IntCoordinate2Standard(intStoreLng)
|
||||
// storeLat := IntCoordinate2Standard(intStoreLat)
|
||||
// if deliveryRangeType == model.DeliveryRangeTypeRadius {
|
||||
// maxDistance := int(utils.Str2Int64WithDefault(deliveryRange, 0))
|
||||
// distance = int(EarthDistance(lng, lat, storeLng, storeLat) * 1000)
|
||||
// if distance > maxDistance {
|
||||
// distance = 0
|
||||
// }
|
||||
// } else {
|
||||
// points := CoordinateStr2Points(deliveryRange)
|
||||
// if utils.IsPointInPolygon(lng, lat, points) {
|
||||
// distance = int(EarthDistance(lng, lat, storeLng, storeLat) * 1000)
|
||||
// }
|
||||
// }
|
||||
return distance
|
||||
}
|
||||
|
||||
func TranslateStorePriceType(storePriceType int8) int8 {
|
||||
if storePriceType == model.StoreChangePriceTypeManagedStore {
|
||||
storePriceType = model.StoreChangePriceTypeBossDisabled
|
||||
}
|
||||
return storePriceType
|
||||
}
|
||||
|
||||
func TranslateSoundSize(vendorID, soundPercentage int) (soundSize string) {
|
||||
if vendorID == model.VendorIDYiLianYun || vendorID == model.VendorIDFeiE {
|
||||
if soundPercentage == 0 {
|
||||
|
||||
@@ -216,42 +216,6 @@ func RegularizeSkuQuality(specQuality float32, specUnit string) (g int) {
|
||||
return int(specQuality)
|
||||
}
|
||||
|
||||
// 计算SKU价格,unitPrice为一斤的单价,specQuality为质量,单位为克
|
||||
func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string, skuNameUnit string) int {
|
||||
if skuNameUnit != model.SpecialUnit {
|
||||
return unitPrice
|
||||
}
|
||||
specQuality2 := RegularizeSkuQuality(specQuality, specUnit)
|
||||
floatPrice := float64(unitPrice) * float64(specQuality2) / float64(model.SpecialSpecQuality)
|
||||
// if specQuality2 < 250 {
|
||||
// floatPrice = floatPrice * 110 / 100
|
||||
// } else if specQuality2 < 500 {
|
||||
// floatPrice = floatPrice * 105 / 100
|
||||
// }
|
||||
if floatPrice <= 1 {
|
||||
floatPrice = 1
|
||||
}
|
||||
return int(math.Round(floatPrice))
|
||||
}
|
||||
|
||||
// 计算SKU标准价格,CaculateSkuPrice的逆过程
|
||||
func CaculateUnitPrice(skuPrice int, specQuality float32, specUnit string, skuNameUnit string) (unitPrice int) {
|
||||
if skuNameUnit != model.SpecialUnit {
|
||||
return skuPrice
|
||||
}
|
||||
specQuality2 := RegularizeSkuQuality(specQuality, specUnit)
|
||||
unitPrice = skuPrice * model.SpecialSpecQuality / specQuality2
|
||||
// if specQuality2 < 250 {
|
||||
// unitPrice = unitPrice * 100 / 110
|
||||
// } else if specQuality2 < 500 {
|
||||
// unitPrice = unitPrice * 100 / 105
|
||||
// }
|
||||
if unitPrice <= 1 {
|
||||
unitPrice = 1
|
||||
}
|
||||
return unitPrice
|
||||
}
|
||||
|
||||
func ConstrainPricePercentage(percentage int) int {
|
||||
if percentage < model.MinVendorPricePercentage || percentage > model.MaxVendorPricePercentage {
|
||||
percentage = model.DefVendorPricePercentage
|
||||
@@ -287,65 +251,6 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, priceAdd int) (price in
|
||||
return price
|
||||
}
|
||||
|
||||
func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercentage int) (pricePercentage, priceAdd int) {
|
||||
pricePercentage = defPricePercentage
|
||||
itemLen := len(l)
|
||||
if itemLen > 0 {
|
||||
low := 0
|
||||
high := itemLen - 1
|
||||
mid := 0
|
||||
for low <= high {
|
||||
mid = low + (high-low)/2
|
||||
if mid < 0 || mid >= itemLen-1 {
|
||||
break
|
||||
}
|
||||
if price >= l[mid].BeginPrice {
|
||||
if price < l[mid+1].BeginPrice {
|
||||
break
|
||||
} else {
|
||||
low = mid + 1
|
||||
}
|
||||
} else {
|
||||
high = mid - 1
|
||||
}
|
||||
}
|
||||
if mid >= 0 && mid <= itemLen-1 && low <= high {
|
||||
pricePercentage = l[mid].PricePercentage
|
||||
priceAdd = l[mid].PriceAdd
|
||||
}
|
||||
}
|
||||
return pricePercentage, priceAdd
|
||||
}
|
||||
|
||||
func GetPricePercentageByVendorPrice(l model.PricePercentagePack, vendorPrice int, defPricePercentage int) (pricePercentage, priceAdd int) {
|
||||
pricePercentage = defPricePercentage
|
||||
if len(l) > 0 {
|
||||
var lastItem *model.PricePercentageItem
|
||||
for _, v := range l {
|
||||
if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, v.PriceAdd) > vendorPrice {
|
||||
break
|
||||
}
|
||||
lastItem = v
|
||||
}
|
||||
if lastItem != nil {
|
||||
pricePercentage = lastItem.PricePercentage
|
||||
priceAdd = lastItem.PriceAdd
|
||||
}
|
||||
}
|
||||
return pricePercentage, priceAdd
|
||||
}
|
||||
|
||||
func CaculatePriceByPricePack(l model.PricePercentagePack, defPricePercentage, price int) (outPrice int) {
|
||||
pricePercentage, priceAdd := GetPricePercentage(l, price, defPricePercentage)
|
||||
return CaculateSkuVendorPrice(price, pricePercentage, priceAdd)
|
||||
}
|
||||
|
||||
func CaculateJxPriceByPricePack(l model.PricePercentagePack, defPricePercentage, vendorPrice int) (jxPrice int) {
|
||||
pricePercentage, priceAdd := GetPricePercentageByVendorPrice(l, vendorPrice, defPricePercentage)
|
||||
jxPrice = CaculateSkuPriceFromVendor(vendorPrice, pricePercentage, priceAdd)
|
||||
return jxPrice
|
||||
}
|
||||
|
||||
func ConstrainPayPercentage(payPerCentage int) int {
|
||||
if payPerCentage <= 50 {
|
||||
payPerCentage = 70
|
||||
@@ -353,10 +258,6 @@ func ConstrainPayPercentage(payPerCentage int) int {
|
||||
return payPerCentage
|
||||
}
|
||||
|
||||
func IsSkuSpecial(specQuality float32, specUnit string) bool {
|
||||
return int(specQuality) == model.SpecialSpecQuality && (specUnit == model.SpecialSpecUnit || specUnit == model.SpecialSpecUnit2)
|
||||
}
|
||||
|
||||
var lastFakeID int64
|
||||
var lastFakeIDMutex sync.RWMutex
|
||||
|
||||
@@ -440,28 +341,6 @@ func FormatSkuWeight(specQuality float32, specUnit string) int {
|
||||
return RegularizeSkuQuality(specQuality, specUnit)
|
||||
}
|
||||
|
||||
type SkuList []*model.Sku
|
||||
|
||||
func (s SkuList) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s SkuList) Less(i, j int) bool {
|
||||
if s[i].NameID == s[j].NameID {
|
||||
if s[i].SpecUnit == s[j].SpecUnit {
|
||||
return s[i].SpecQuality < s[j].SpecQuality
|
||||
}
|
||||
return s[i].SpecUnit < s[j].SpecUnit
|
||||
}
|
||||
return s[i].NameID < s[j].NameID
|
||||
}
|
||||
|
||||
func (s SkuList) Swap(i, j int) {
|
||||
tmp := s[i]
|
||||
s[i] = s[j]
|
||||
s[j] = tmp
|
||||
}
|
||||
|
||||
func DownloadFileByURL(fileURL string) (bodyData []byte, fileMD5 string, err error) {
|
||||
response, err := http.Get(fileURL)
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user