liujie
2023-05-24 0c9e25aff0133d05bdaca55d1369eb90342b0b05
src/main/java/com/stylefeng/guns/modular/system/controller/DemandController.java
@@ -10,10 +10,12 @@
import com.stylefeng.guns.modular.system.enums.UserFeeSettingEnum;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.utils.AddressLookup;
import com.stylefeng.guns.modular.system.utils.ExcelUtil;
import com.stylefeng.guns.modular.system.utils.GoogleMap.DistancematrixVo;
import com.stylefeng.guns.modular.system.utils.GoogleMap.GeocodeVo;
import com.stylefeng.guns.modular.system.utils.GoogleMap.GoogleMapUtil;
import com.stylefeng.guns.modular.system.utils.PointInPolygon;
import com.stylefeng.guns.modular.system.utils.tips.ErrorTip;
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
import io.swagger.annotations.Api;
@@ -355,6 +357,7 @@
                            // 基础价格
                            String zipCode = demandDto.getZipCode();
                            String address1 = AddressLookup.getAddress(zipCode);
                            TCompanyBasic tCompanyBasic = companyBasicService.selectOne(new EntityWrapper<TCompanyBasic>().eq("port_id",ratesId).eq("zip_code", zipCode).eq("type", 1));
                            if(Objects.nonNull(tCompanyBasic)){
                                tCompanyResp=new TCompanyResp();
@@ -363,12 +366,39 @@
                                objects.add(tCompanyResp);
                            }else {
                                // 画圈 拿到的zipcode集合 去对比当前zipcode是否在集合中
                                TCompanyBasic type = companyBasicService.selectOne(new EntityWrapper<TCompanyBasic>().eq("type", 2).eq("port_id",ratesId).like("zip_code", zipCode));
                                if(Objects.nonNull(type)){
                                // 画圈 拿到的zipcode集合 去对比当前zipcode是否在集合中
                                List<TCompanyBasic> type = companyBasicService.selectList(new EntityWrapper<TCompanyBasic>().eq("type", 2).eq("port_id",ratesId).orderBy("fee",true));
                                if(type.size()>0){
                                    GeocodeVo geocode1 = googleMapUtil.getGeocode(zipCode);
                                    for (TCompanyBasic companyBasic : type) {
                                        boolean inPolygon = PointInPolygon.isInPolygon(geocode1.getLat(), geocode1.getLng(), companyBasic.getLonLat());
                                        if(inPolygon){
                                    tCompanyResp=new TCompanyResp();
                                    tCompanyResp.setPrice(type.getFee());
                                            tCompanyResp.setPrice(type.get(0).getFee());
                                    tCompanyResp.setName("LH+FSC");
                                    objects.add(tCompanyResp);
                                            break;
                                        }
                                    }
                                    if(tCompanyResp==null){
                                        // 距离
                                        tCompanyResp=new TCompanyResp();
                                        // 1条数据  不需要zipcode
                                        DistancematrixVo distancematrix = googleMapUtil.getDistancematrix(address, address1);
                                        double distance = distancematrix.getDistance().doubleValue();
                                        BigDecimal bigDecimal = new BigDecimal(distance * 0.0006214);
                                        List<TCompanyBasic> type1 = companyBasicService.selectList(new EntityWrapper<TCompanyBasic>().eq("type", 3).eq("port_id",ratesId).le("start",bigDecimal.doubleValue()).orderBy("start",true));
                                        if(type1.size()>0) {
                                            BigDecimal multiply = type1.get(0).getFee().multiply(bigDecimal);
                                            tCompanyResp.setPrice(multiply);
                                            tCompanyResp.setName("LH+FSC");
                                            objects.add(tCompanyResp);
                                        }else {
                                            tCompanyResp.setPrice(new BigDecimal(0));
                                            tCompanyResp.setName("LH+FSC");
                                            objects.add(tCompanyResp);
                                        }
                                    }
                                }else {
                                    tCompanyResp=new TCompanyResp();
                                    // 1条数据  不需要zipcode