This commit is contained in:
苏尹岚
2021-03-09 11:36:07 +08:00
parent d5c90df9b7
commit e0f6b09ef5

View File

@@ -440,7 +440,6 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
store, _ := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID) 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 { 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, ";"))
fmt.Println("store.DeliveryRange", store.DeliveryRange)
dao.UpdateEntity(db, storeMaps[0], "CoverArea") dao.UpdateEntity(db, storeMaps[0], "CoverArea")
result.CoverArea = storeMaps[0].CoverArea result.CoverArea = storeMaps[0].CoverArea
} }
@@ -462,12 +461,13 @@ func CalculateCoverArea(coordinate []string) (area float64) {
xys := jxutils.MillierConvertion(lat, lng) xys := jxutils.MillierConvertion(lat, lng)
xyList = append(xyList, xys) xyList = append(xyList, xys)
} }
fmt.Println("xyList", xyList)
var sum float64 var sum float64
for i := 0; i < len(xyList)-1; i++ { for i := 0; i < len(xyList)-1; i++ {
sum += (xyList[i+1][0] - xyList[i][0]) * (xyList[i+1][1] + xyList[i+1][1]) sum += (xyList[i+1][0] - xyList[i][0]) * (xyList[i+1][1] + xyList[i+1][1])
} }
sum += (xyList[0][0] - xyList[len(xyList)-1][0]) * (xyList[0][1] + xyList[len(xyList)-1][1]) sum += (xyList[0][0] - xyList[len(xyList)-1][0]) * (xyList[0][1] + xyList[len(xyList)-1][1])
fmt.Println("1111111111111111111111111111111111111111", sum)
sum /= float64(2) sum /= float64(2)
fmt.Println("1111111111111111111111111111111111111111", sum)
return math.Round(sum) return math.Round(sum)
} }