禁用与不同步的门店创建活动时排除

This commit is contained in:
gazebo
2019-11-08 09:01:59 +08:00
parent 025ead8c05
commit f85c182f44
3 changed files with 27 additions and 19 deletions

View File

@@ -131,7 +131,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
for _, vendorID := range vendorIDs {
storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID)
if err = err2; err == nil {
if storeDetail.IsSync != 0 && storeDetail.Status != model.StoreStatusDisabled {
if storeDetail.IsSync != 0 && storeDetail.Status != model.StoreStatusDisabled && storeDetail.VendorStatus != model.StoreStatusDisabled {
for _, v := range oneStoreSkuParam {
validVendorMap[vendorID] = 1
validSkuMap[v.SkuID] = 1
@@ -168,7 +168,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
}
actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage))
if actSkuMap.ActualActPrice > 10 {
actSkuMap.ActualActPrice = int64(math.Round(float64(actSkuMap.ActualActPrice)/10) * 10)
actSkuMap.ActualActPrice = int64(math.Floor(float64(actSkuMap.ActualActPrice)/10) * 10)
}
}
if actSkuMap.ActualActPrice <= 0 {

View File

@@ -203,7 +203,9 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
sqlVendorStoreCond += " AND ( 1 = 0"
}
}
sqlFrom += "\nLEFT JOIN " + tableName + " " + tableAlias + " ON " + tableAlias + ".vendor_id = ? AND " + tableAlias + ".store_id = t1.id AND " + tableAlias + ".deleted_at = ?"
sqlFrom += "\nLEFT JOIN " + tableName + " " + tableAlias + " ON " + tableAlias + ".vendor_id = ? AND " +
tableAlias + ".store_id = t1.id AND " + tableAlias + ".deleted_at = ? AND " +
tableAlias + ".is_sync <> 0 "
sqlFromParams = append(sqlFromParams, vendor, utils.DefaultTimeValue)
if cond == 1 {
sqlVendorStoreCond += " " + mapCond + " " + tableAlias + ".id IS NOT NULL"
@@ -2102,21 +2104,8 @@ func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDi
if err = dao.GetRows(dao.GetDB(), &storeList1, sql, sqlParams...); err == nil {
var storeList2 []*Store4User
for _, v := range storeList1 {
isStoreOK := false
v.FloatLng = jxutils.IntCoordinate2Standard(v.Lng)
v.FloatLat = jxutils.IntCoordinate2Standard(v.Lat)
if v.DeliveryRangeType == model.DeliveryRangeTypeRadius {
maxDistance := int(utils.Str2Int64WithDefault(v.DeliveryRange, 0))
v.Distance = int(jxutils.EarthDistance(lng, lat, v.FloatLng, v.FloatLat) * 1000)
isStoreOK = v.Distance <= maxDistance
} else {
points := jxutils.CoordinateStr2Points(v.DeliveryRange)
if utils.IsPointInPolygon(lng, lat, points) {
v.Distance = int(jxutils.EarthDistance(lng, lat, v.FloatLng, v.FloatLat) * 1000)
isStoreOK = true
}
}
if isStoreOK {
if distance := jxutils.Point2StoreDistance(lng, lat, v.Lng, v.Lat, v.DeliveryRangeType, v.DeliveryRange); distance > 0 {
v.Distance = distance
storeList2 = append(storeList2, v)
}
}

View File

@@ -235,7 +235,7 @@ func IntCoordinate2MarsStandard(gpsLng, gpsLat int, coordinateType int) (marsLng
case model.CoordinateTypeGPS:
coordSys = autonavi.CoordSysGPS
case model.CoordinateTypeMars:
coordSys = autonavi.CoordSysAutonavi
return marsLng, marsLat, nil
case model.CoordinateTypeBaiDu:
coordSys = autonavi.CoordSysBaidu
case model.CoordinateTypeMapbar:
@@ -779,3 +779,22 @@ func GetOneEmailFromStr(str string) (email string) {
}
return email
}
// 计算一个坐标点距离一个门店的距离单位为米如果不在有效范围内则返回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)
}
}
return distance
}