This commit is contained in:
苏尹岚
2021-03-10 12:01:29 +08:00
parent 54167eade1
commit a09bc75d82

View File

@@ -451,7 +451,11 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
handler := partner.GetPurchasePlatformFromVendorID(vendorID) handler := partner.GetPurchasePlatformFromVendorID(vendorID)
if store, err := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID); err == nil { if store, err := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID); err == nil {
if storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, []int{v}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 && err == nil { if storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, []int{v}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 && err == nil {
if vendorID == model.VendorIDJD && store.DeliveryRangeType != model.DeliveryRangeTypePolygon {
storeMaps[0].CoverArea = math.Pi * utils.Str2Float64WithDefault(store.DeliveryRange, 0) * utils.Str2Float64WithDefault(store.DeliveryRange, 0) / float64(10000)
} else {
storeMaps[0].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), vendorID) storeMaps[0].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), vendorID)
}
dao.UpdateEntity(db, storeMaps[0], "CoverArea") dao.UpdateEntity(db, storeMaps[0], "CoverArea")
result.CoverArea = storeMaps[0].CoverArea result.CoverArea = storeMaps[0].CoverArea
} }
@@ -515,7 +519,7 @@ func CalculateCoverArea(coordinate []string, vendorID int) (area float64) {
var xyList [][2]float64 var xyList [][2]float64
for _, v := range coordinate { for _, v := range coordinate {
cell := strings.Split(v, ",") cell := strings.Split(v, ",")
if len(cell) == 0 { if len(cell) == 0 || len(cell) == 1 {
continue continue
} }
var lat, lng float64 var lat, lng float64