This commit is contained in:
苏尹岚
2021-03-09 11:59:23 +08:00
parent 244a874040
commit 83cbb071b0

View File

@@ -441,7 +441,7 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
handler := partner.GetPurchasePlatformFromVendorID(vendorID)
store, _ := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID)
if storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, []int{v}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 && err == nil {
storeMaps[0].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"))
storeMaps[0].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), vendorID)
dao.UpdateEntity(db, storeMaps[0], "CoverArea")
result.CoverArea = storeMaps[0].CoverArea
}
@@ -451,15 +451,21 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
return getStoreManageStateResult, err
}
func CalculateCoverArea(coordinate []string) (area float64) {
func CalculateCoverArea(coordinate []string, vendorID int) (area float64) {
if len(coordinate) == 0 {
return 0
}
var xyList [][2]float64
for _, v := range coordinate {
cell := strings.Split(v, ",")
lat := utils.Str2Float64WithDefault(cell[0], 0)
lng := utils.Str2Float64WithDefault(cell[1], 0)
var lat, lng float64
if vendorID == model.VendorIDJD {
lng = utils.Str2Float64WithDefault(cell[0], 0)
lat = utils.Str2Float64WithDefault(cell[1], 0)
} else {
lat = utils.Str2Float64WithDefault(cell[0], 0)
lng = utils.Str2Float64WithDefault(cell[1], 0)
}
xys := jxutils.MillierConvertion(lat, lng)
xyList = append(xyList, xys)
}