44323
2024-01-29 f9ce347bc1325ec05704b1213cdafdd9db8dd578
cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java
@@ -12,14 +12,17 @@
import com.dsh.other.util.GeodesyUtil;
import com.dsh.other.util.ResultUtil;
import com.dsh.other.util.ToolUtil;
import com.sun.javafx.binding.StringFormatter;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -202,37 +205,29 @@
        if (citycodeResp.getCityCode() == null) {
            Map<String, String> geocode = gdMapGeocodingUtil.geocode(citycodeResp.getLongitude(), citycodeResp.getLatitude());
            String provinceCode = geocode.get("provinceCode");
            if(null != geocode){
            String cityCode = geocode.get("cityCode");
            citycodeResp.setCityCode(cityCode);
            }
        }
        List<Store> list = storeService.list(new QueryWrapper<Store>()
                .eq("state", 1)
                .eq("cityCode", citycodeResp.getCityCode()));
        if (list.size() > 0) {
//            if (ToolUtil.isEmpty(citycodeResp.getLongitude()) && ToolUtil.isEmpty(citycodeResp.getLatitude())){
//                return detailLists;
//            }
            for (Store store : list) {
                String current = citycodeResp.getLongitude() + "," + citycodeResp.getLatitude();
                String result = store.getLon() + "," + store.getLat();
                String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result);
//                long l = Long.parseLong(distanceTOKilometer);
////                取5公里范围内的门店
//                if ( l > 5){
//                    continue;
//                }
                Map<String, Double> distance = GeodesyUtil.getDistance(current, result);
                StoreDetailList detailList = new StoreDetailList();
                detailList.setStoreId(store.getId());
                detailList.setStoreImg(store.getCoverDrawing());
                detailList.setStoreName(store.getName());
                detailList.setStoreAddress(store.getAddress());
                detailList.setStorePhone(store.getPhone());
//                detailList.setStoreDistance(l);
                detailList.setStoreTime(store.getStartTime() + "-" + store.getEndTime());
                detailList.setStoreInfo(store.getIntroduce());
                detailList.setStoreDistance(Double.valueOf(distanceTOKilometer));
                detailList.setStoreDistance(null != distance ? Double.valueOf(String.format("%.2f", distance.get("WGS84") / 1000)) : 0D);
                detailLists.add(detailList);
            }
        }
@@ -422,7 +417,7 @@
    @ApiImplicitParams({
            @ApiImplicitParam(value = "门店id", name = "id", dataType = "int", required = true),
    })
    public ResultUtil<List<TStoreOtherConfigTrue>> queryIndexSet(Integer id) {
    public ResultUtil<List<TStoreOtherVo>> queryIndexSet(Integer id) {
        try {
            List<TStoreOtherConfigTrue> tStoreOtherConfigTrues = new ArrayList<>();
@@ -430,14 +425,20 @@
            if (list.size() > 0) {
                tStoreOtherConfigTrues = tStoreOtherConfigTrueService.list(new LambdaQueryWrapper<TStoreOtherConfigTrue>().in(TStoreOtherConfigTrue::getPid, list.stream().map(TStoreOther::getId).collect(Collectors.toList())).eq(TStoreOtherConfigTrue::getState, 1));
            }
            for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) {
            List<TStoreOtherVo> list1 = new ArrayList<>();
                for (TStoreOther tStoreOther : list) {
                TStoreOtherVo storeOtherVo = new TStoreOtherVo();
                BeanUtils.copyProperties(tStoreOther, storeOtherVo);
                List<TStoreOtherConfigTrue> lists = new ArrayList<>();
                for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) {
                    if (tStoreOtherConfigTrue.getPid() == tStoreOther.getId()) {
                        tStoreOtherConfigTrue.setSort(tStoreOther.getSort());
                        lists.add(tStoreOtherConfigTrue);
                    }
                }
                storeOtherVo.setList(lists);
                list1.add(storeOtherVo);
            }
            return ResultUtil.success(tStoreOtherConfigTrues);
            return ResultUtil.success(list1);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();