liujie
2023-08-31 8d7dbd6d2c0775d45043474c1525ad827b4cd3bd
src/main/java/com/stylefeng/guns/modular/system/controller/DemandController.java
@@ -11,13 +11,10 @@
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.*;
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.UserInfoUtil;
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -34,6 +31,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -133,14 +131,14 @@
        tQuote.setUserId(demandDto.getUserId());
        quoteService.insert(tQuote);
//        List<TUserFeeSetting> tUserFeeSettings=null;
//        //获取当前用户的sale
//        Integer userId = demandDto.getUserId();
        List<TUserFeeSetting> tUserFeeSettings=null;
        //获取当前用户的sale
        Integer userId = demandDto.getUserId();
//        TUser tUser = userService.selectById(userId);
//        if(tUser.getGroupId()!=null){
//            TGroup tGroup = groupService.selectById(tUser.getGroupId());
//             tUserFeeSettings = userFeeSettingService.selectList(new EntityWrapper<TUserFeeSetting>().eq("user_id",tGroup.getSalesId()));
//
        tUserFeeSettings = userFeeSettingService.selectList(new EntityWrapper<TUserFeeSetting>().eq("user_id",userId).isNotNull("fee").gt("fee",0));
//        }
@@ -224,7 +222,6 @@
        TCountry city = countryService.selectById(tPort.getCity());
        TCountry state = countryService.selectById(city.getParentId());
        String address = tPort.getAddress();
//        GeocodeVo geocode = googleMapUtil.getGeocode(address);
        List<TCompanyCalculationResp> tCompanyCalculationRespList = new ArrayList<>(tCompanyList.size());
@@ -264,18 +261,37 @@
                    List<GoodsDto> list = goodsListDto.getList();
                    ArrayList<TGoods> tGoods1 = new ArrayList<>();
                    objects = new ArrayList<>();
                    Long orderId= null;
                    for (GoodsDto goodsDto : list) {
                        tPrices = new ArrayList<>();
                        objects = new ArrayList<>();
                        TCompanyResp tCompanyResp = new TCompanyResp();
                        if("0".equals(demandDto.getWarehouse())){
                            tCompanyResp=new TCompanyResp();
                            TCompanyFeeSetting feeSetting = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", demandDto.getDelivery()));
                            if(feeSetting==null){
                                breakNum=1;
                                count++;
                                break;
//                                breakNum=1;
//                                count++;
//                                break;
                            }else {
                                tCompanyResp.setName(demandDto.getDelivery());
                                tCompanyResp.setPrice(feeSetting.getSetValue());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(demandDto.getDelivery())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                        tCompanyResp.setPrice(feeSetting.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                    tCompanyResp.setPrice(feeSetting.getSetValue());
                                }
//                                tCompanyResp.setPrice(feeSetting.getSetValue());
//                                tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                objects.add(tCompanyResp);
                            }
@@ -283,33 +299,69 @@
                            String zipCode = demandDto.getZipCode();
                            // 地址信息
                            String address1 = AddressLookup.getAddress(zipCode);
                            System.out.println("地址信息+"+address1);
                            if(address1==null){
                                return new com.stylefeng.guns.modular.system.utils.tips.ErrorTip(5001,"Please enter the correct zipcode");
                            }
                            List<TCompanyBasic> tCompanyBasic = companyBasicService.selectList(new EntityWrapper<TCompanyBasic>().eq("port_id",ratesId).eq("zip_code", zipCode).eq("type", 1));
                            System.out.println(tCompanyBasic);
                            if(tCompanyBasic.size()>0){
                                System.out.println("点对点++++++++++++");
                                tCompanyResp=new TCompanyResp();
                                tCompanyResp.setPrice(tCompanyBasic.get(0).getFee());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals("LH+FSC")).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(tCompanyBasic.get(0).getFee()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setPrice(tCompanyBasic.get(0).getFee());
                                        tCompanyResp.setAdminPrice(tCompanyBasic.get(0).getFee().add(bigDecimal));
                                    }else {
                                        tCompanyResp.setPrice(tCompanyBasic.get(0).getFee());
                                        tCompanyResp.setAdminPrice(tCompanyBasic.get(0).getFee());
                                    }
                                }else {
                                    tCompanyResp.setPrice(tCompanyBasic.get(0).getFee());
                                    tCompanyResp.setAdminPrice(tCompanyBasic.get(0).getFee());
                                }
                                tCompanyResp.setName("LH+FSC");
                                objects.add(tCompanyResp);
                            }else {
                                // 画圈 拿到的zipcode集合 去对比当前zipcode是否在集合中
                                List<TCompanyBasic> type = companyBasicService.selectList(new EntityWrapper<TCompanyBasic>().eq("type", 2).eq("port_id",ratesId).orderBy("fee",true));
                                System.out.println(type);
                                tCompanyResp=new TCompanyResp();
                                if(type.size()>0){
                                    GeocodeVo geocode1 = googleMapUtil.getGeocode(address1  );
                                    GeocodeVo geocode1 = googleMapUtil.getGeocode(address1);
                                    System.out.println("谷歌终点经纬度"+geocode1.getLat()+"|"+geocode1.getLng());
                                    for (TCompanyBasic companyBasic : type) {
                                        boolean inPolygon = PointInPolygon.isInPolygon(geocode1.getLat(), geocode1.getLng(), companyBasic.getLonLat());
                                        if(inPolygon){
                                            tCompanyResp=new TCompanyResp();
                                            tCompanyResp.setPrice(type.get(0).getFee());
                                            if(tUserFeeSettings!=null){
                                                List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals("LH+FSC")).collect(Collectors.toList());
                                                if(collect.size()>0){
                                                    BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(companyBasic.getFee()).setScale(2, RoundingMode.HALF_UP);
                                                    tCompanyResp.setPrice(companyBasic.getFee());
                                                    tCompanyResp.setAdminPrice(companyBasic.getFee().add(bigDecimal));
                                                }else {
                                                    tCompanyResp.setPrice(companyBasic.getFee());
                                                    tCompanyResp.setAdminPrice(companyBasic.getFee());
                                                }
                                            }else {
                                                tCompanyResp.setPrice(companyBasic.getFee());
                                                tCompanyResp.setAdminPrice(companyBasic.getFee());
                                            }
//                                            tCompanyResp.setPrice(companyBasic.getFee());
//                                            tCompanyResp.setAdminPrice(companyBasic.getFee());
                                            tCompanyResp.setName("LH+FSC");
                                            objects.add(tCompanyResp);
                                            break;
                                        }
                                    }
                                    if(tCompanyResp==null){
                                    if(tCompanyResp==null || "".equals(tCompanyResp.getName()) || tCompanyResp.getName()==null){
                                        // 距离
                                        tCompanyResp=new TCompanyResp();
                                        // 1条数据  不需要zipcode
@@ -319,7 +371,23 @@
                                        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);
                                            if(tUserFeeSettings!=null){
                                                List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals("LH+FSC")).collect(Collectors.toList());
                                                if(collect.size()>0){
                                                    BigDecimal bigDecimal1 = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(multiply).setScale(2, RoundingMode.HALF_UP);
                                                    tCompanyResp.setPrice(multiply);
                                                    tCompanyResp.setAdminPrice(multiply.add(bigDecimal1));
                                                }else {
                                                    tCompanyResp.setPrice(multiply);
                                                    tCompanyResp.setAdminPrice(multiply);
                                                }
                                            }else {
                                                tCompanyResp.setPrice(multiply);
                                                tCompanyResp.setAdminPrice(multiply);
                                            }
//                                            tCompanyResp.setPrice(multiply);
//                                            tCompanyResp.setAdminPrice(multiply);
                                            tCompanyResp.setName("LH+FSC");
                                            objects.add(tCompanyResp);
                                        }else {
@@ -338,7 +406,20 @@
                                    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);
                                        if(tUserFeeSettings!=null){
                                            List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals("LH+FSC")).collect(Collectors.toList());
                                            if(collect.size()>0){
                                                BigDecimal bigDecimal1 = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(multiply).setScale(2, RoundingMode.HALF_UP);
                                                tCompanyResp.setPrice(multiply);
                                                tCompanyResp.setAdminPrice(multiply.add(bigDecimal1));
                                            }else {
                                                tCompanyResp.setPrice(multiply);
                                                tCompanyResp.setAdminPrice(multiply);
                                            }
                                        }else {
                                            tCompanyResp.setPrice(multiply);
                                            tCompanyResp.setAdminPrice(multiply);
                                        }
                                        tCompanyResp.setName("LH+FSC");
                                        objects.add(tCompanyResp);
                                    }else {
@@ -353,37 +434,57 @@
                            tCompanyResp=new TCompanyResp();
                            TWarehouse tWarehouse = warehouseService.selectOne(new EntityWrapper<TWarehouse>().eq("company_id", company.getId()).eq("code", demandDto.getWarehouse()).eq("port_id",ratesId));
                            tCompanyResp.setName(UserFeeSettingEnum.LH_FSH.getDesc());
                            if(Objects.nonNull(tWarehouse)){
                            if(Objects.nonNull(tWarehouse) && tWarehouse.getWarePrice().doubleValue()>0){
                                tCompanyResp.setPrice(tWarehouse.getWarePrice());
                                tCompanyResp.setAdminPrice(tWarehouse.getWarePrice());
                            }else {
                                tCompanyResp.setPrice(new BigDecimal("0"));
                                breakNum=1;
                                count++;
                                break;
                            }
                            objects.add(tCompanyResp);
                        }
                        // 是否超重
                        Integer weight = goodsDto.getWeight();
                        long between = DateUtil.between(demandDto.getShipmentDate(), demandDto.getDeliveryDate(), DateUnit.DAY);
//                        long between = DateUtil.between(demandDto.getShipmentDate(), demandDto.getDeliveryDate(), DateUnit.DAY);
                        String arg1 = tPort.getName();
                        String arg2="";
                        if(!"0".equals(demandDto.getWarehouse())){
                            System.out.println("公司id:"+company.getId());
                            System.out.println("公司ratesId:"+ratesId);
                            TWarehouse tWarehouse = warehouseService.selectOne(new EntityWrapper<TWarehouse>().eq("company_id", company.getId()).eq("code", demandDto.getWarehouse()).eq("port_id",ratesId));
                            arg2=tWarehouse.getCity();
                            if(tWarehouse==null){
                                breakNum=1;
                                count++;
                                break;
                            }
                            arg2=tWarehouse.getZipCode();
                        }else {
                            arg2 = AddressLookup.getAddress(demandDto.getZipCode());
                            arg2 = demandDto.getZipCode();
                        }
//                        DistancematrixVo distancematrix = googleMapUtil.getDistancematrix(tPort.getAddress(), arg2);
//                        String arg3=String.valueOf(distancematrix.getDistance());
//                        String arg4= demandDto.getList().get(0).getShippingLine();
//                        String arg5 = demandDto.getType();
//                        GoodsDto goodsDto1 = demandDto.getList().get(0).getList().get(0);
//                        String arg6 =goodsDto1.getType();
//                        String arg7="None";
//                        String arg8 = goodsDto1.getKg();
//                        BigDecimal days = new BigDecimal(ChassisRentalDaysUtil.chassisRentalDays(1, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8));
                        if(between==0){
                            between=1;
                        }
                        System.out.println("arg2:"+arg2);
                        DistancematrixVo distancematrix = googleMapUtil.getDistancematrix(tPort.getAddress(), arg2);
                        String arg3=String.valueOf(distancematrix.getDistance()/1609);
                        String arg4= demandDto.getList().get(0).getShippingLine();
                        String arg5 = demandDto.getType();
                        GoodsDto goodsDto1 = demandDto.getList().get(0).getList().get(0);
                        String arg6 =goodsDto1.getSize()+"ft";
                        String arg7="None";
                        String arg8 = goodsDto1.getKg();
                        System.out.println("参数:"+arg1+"|"+arg2+"|"+arg3+"|"+arg4+"|"+arg5+"|"+arg6+"|"+arg7+"|"+arg8);
//                        arg1="WBCT";
//                        arg2="Ontario";
//                        arg3="55";
//                        arg4="COSCO";
//                        arg5="Drop & hook";
//                        arg6="40ft";
//                        arg7="None";
//                        arg8="44806";
                        BigDecimal days = new BigDecimal(ChassisRentalDaysUtil.chassisRentalDays(1, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)).setScale(0, RoundingMode.HALF_UP);
//                        if(between==0){
//                            between=1;
//                        }
                        if(weight==1){
                            TCompanyFeeSetting feeSetting = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id",ratesId).eq("set_name", UserFeeSettingEnum.OVERWEIGHT.getDesc()));
                            if(feeSetting==null){
@@ -393,7 +494,20 @@
                            }else {
                                tCompanyResp=new TCompanyResp();
                                tCompanyResp.setName(UserFeeSettingEnum.OVERWEIGHT.getDesc());
                                tCompanyResp.setPrice(feeSetting.getSetValue());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.OVERWEIGHT.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                        tCompanyResp.setPrice(feeSetting.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                    tCompanyResp.setPrice(feeSetting.getSetValue());
                                }
                                objects.add(tCompanyResp);
                            }
                            TCompanyFeeSetting feeSetting1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id",ratesId).eq("set_name", "trl-axle chassis"));
@@ -404,8 +518,21 @@
                            }else {
                                tCompanyResp=new TCompanyResp();
                                tCompanyResp.setName(UserFeeSettingEnum.CHASSIS_FEE.getDesc());
//                                tCompanyResp.setPrice(feeSetting1.getSetValue().multiply(days));
                                tCompanyResp.setPrice(feeSetting1.getSetValue().multiply(new BigDecimal(between)));
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.CHASSIS_FEE.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting1.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                    tCompanyResp.setPrice(feeSetting1.getSetValue());
                                }
                                tCompanyResp.setDay(days.toString());
                                objects.add(tCompanyResp);
                            }
                        }else {
@@ -417,8 +544,23 @@
                                count++;
                                break;
                            }else {
//                                tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                                tCompanyResp.setPrice(feeSetting.getSetValue().multiply(new BigDecimal(between)));
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.CHASSIS_FEE.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting.getSetValue().multiply(days)).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue().multiply(days).add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue().multiply(days));
                                        tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting.getSetValue().multiply(days));
                                    tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                                }
                                tCompanyResp.setDay(days.toString());
//                                tCompanyResp.setPrice(feeSetting.getSetValue().multiply(new BigDecimal(between)));
                            }
                            objects.add(tCompanyResp);
                        }
@@ -431,9 +573,21 @@
                                tCompanyResp.setName(UserFeeSettingEnum.PREPULL.getDesc());
                                tCompanyResp.setPrice(new BigDecimal(0));
                            }else {
                                BigDecimal setValue = feeSetting.getSetValue();
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.PREPULL.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                        tCompanyResp.setPrice(feeSetting.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting.getSetValue());
                                    tCompanyResp.setPrice(feeSetting.getSetValue());
                                }
                                tCompanyResp.setName(UserFeeSettingEnum.PREPULL.getDesc());
                                tCompanyResp.setPrice(setValue);
                            }
//                            BigDecimal setValue = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id",ratesId).eq("set_name", UserFeeSettingEnum.PREPULL.getDesc())).getSetValue();
@@ -443,34 +597,91 @@
                        tCompanyResp=new TCompanyResp();
                        TCompanyFeeSetting feeSetting = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.DETENTION_CONGESTION.getDesc()));
                        if(feeSetting!=null){
                            days = new BigDecimal(ChassisRentalDaysUtil.chassisRentalDays(4, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)).setScale(0, RoundingMode.HALF_UP);
                            tCompanyResp.setName(UserFeeSettingEnum.DETENTION_CONGESTION.getDesc());
                            tCompanyResp.setPrice(feeSetting.getSetValue());
//                            tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                            tCompanyResp.setDay(days.toString());
                            if(tUserFeeSettings!=null){
                                List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.DETENTION_CONGESTION.getDesc())).collect(Collectors.toList());
                                if(collect.size()>0){
                                    BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting.getSetValue().multiply(days)).setScale(2, RoundingMode.HALF_UP);
                                    tCompanyResp.setAdminPrice(feeSetting.getSetValue().multiply(days).add(bigDecimal));
                                    tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting.getSetValue().multiply(days));
                                    tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                                }
                            }else {
                                tCompanyResp.setAdminPrice(feeSetting.getSetValue().multiply(days));
                                tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
                            }
                        }else {
                            tCompanyResp.setName(UserFeeSettingEnum.DETENTION_CONGESTION.getDesc());
                            tCompanyResp.setPrice(new BigDecimal(0));
                            tCompanyResp.setAdminPrice(new BigDecimal(0));
                        }
//                        BigDecimal setValue = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id",ratesId).eq("set_name", UserFeeSettingEnum.DETENTION_CONGESTION.getDesc())).getSetValue();
                        objects.add(tCompanyResp);
                        // 仓储费
//                        tCompanyResp=new TCompanyResp();
//                        days = new BigDecimal(ChassisRentalDaysUtil.chassisRentalDays(3, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8));
//                        TCompanyFeeSetting storage = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.STORAGE.getDesc()));
//                        if(storage!=null){
//                            tCompanyResp.setName(UserFeeSettingEnum.STORAGE.getDesc());
//                            tCompanyResp.setPrice(feeSetting.getSetValue().multiply(days));
//                        }else {
//                            tCompanyResp.setName(UserFeeSettingEnum.STORAGE.getDesc());
//                            tCompanyResp.setPrice(new BigDecimal(0));
//                        }
                        tCompanyResp=new TCompanyResp();
                        days = new BigDecimal(ChassisRentalDaysUtil.chassisRentalDays(2, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)).add(new BigDecimal(ChassisRentalDaysUtil.chassisRentalDays(3, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))).setScale(0, RoundingMode.HALF_UP);
                        System.out.println("仓储费"+days);
                        TCompanyFeeSetting storage = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.STORAGE.getDesc()));
                        System.out.println(storage);
                        if(storage!=null){
                            tCompanyResp.setName(UserFeeSettingEnum.STORAGE.getDesc());
//                            tCompanyResp.setPrice(storage.getSetValue().multiply(days));
                            if(tUserFeeSettings!=null){
                                List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.STORAGE.getDesc())).collect(Collectors.toList());
                                if(collect.size()>0){
                                    BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(storage.getSetValue().multiply(days)).setScale(2, RoundingMode.HALF_UP);
                                    tCompanyResp.setAdminPrice(storage.getSetValue().multiply(days).add(bigDecimal));
                                    tCompanyResp.setPrice(storage.getSetValue().multiply(days));
                                }else {
                                    tCompanyResp.setAdminPrice(storage.getSetValue().multiply(days));
                                    tCompanyResp.setPrice(storage.getSetValue().multiply(days));
                                }
                            }else {
                                tCompanyResp.setAdminPrice(storage.getSetValue().multiply(days));
                                tCompanyResp.setPrice(storage.getSetValue().multiply(days));
                            }
                            tCompanyResp.setDay(days.toString());
                            objects.add(tCompanyResp);
                        }else {
                            tCompanyResp.setName(UserFeeSettingEnum.STORAGE.getDesc());
                            tCompanyResp.setPrice(new BigDecimal(0));
                            objects.add(tCompanyResp);
                        }
                        if(goodsDto.getDanger()==1){
                            tCompanyResp=new TCompanyResp();
                            TCompanyFeeSetting feeSetting1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.HAZMAT.getDesc()));
                            if(feeSetting1!=null){
                                tCompanyResp.setName(UserFeeSettingEnum.HAZMAT.getDesc());
                                tCompanyResp.setPrice(feeSetting1.getSetValue());
//                                tCompanyResp.setPrice(feeSetting1.getSetValue());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.HAZMAT.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting1.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                    tCompanyResp.setPrice(feeSetting1.getSetValue());
                                }
                                objects.add(tCompanyResp);
                            }else {
                                breakNum=1;
@@ -485,7 +696,23 @@
                            TCompanyFeeSetting feeSetting1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.URGENT_SEE.getDesc()));
                            if(feeSetting1!=null){
                                tCompanyResp.setName(UserFeeSettingEnum.URGENT_SEE.getDesc());
                                tCompanyResp.setPrice(feeSetting1.getSetValue());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.URGENT_SEE.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting1.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                    tCompanyResp.setPrice(feeSetting1.getSetValue());
                                }
//                                tCompanyResp.setPrice(feeSetting1.getSetValue());
                                objects.add(tCompanyResp);
                            }else {
                                breakNum=1;
@@ -500,7 +727,20 @@
                            TCompanyFeeSetting feeSetting1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.PIERPASS.getDesc()));
                            if(feeSetting1!=null){
                                tCompanyResp.setName(UserFeeSettingEnum.PIERPASS.getDesc());
                                tCompanyResp.setPrice(feeSetting1.getSetValue());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.PIERPASS.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting1.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                    tCompanyResp.setPrice(feeSetting1.getSetValue());
                                }
                                objects.add(tCompanyResp);
                            }else {
                                breakNum=1;
@@ -514,7 +754,20 @@
                            TCompanyFeeSetting feeSetting1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id", ratesId).eq("set_name", UserFeeSettingEnum.CTF.getDesc()));
                            if(feeSetting1!=null){
                                tCompanyResp.setName(UserFeeSettingEnum.CTF.getDesc());
                                tCompanyResp.setPrice(feeSetting1.getSetValue());
                                if(tUserFeeSettings!=null){
                                    List<TUserFeeSetting> collect = tUserFeeSettings.stream().filter(e -> e.getName().equals(UserFeeSettingEnum.CTF.getDesc())).collect(Collectors.toList());
                                    if(collect.size()>0){
                                        BigDecimal bigDecimal = new BigDecimal(collect.get(0).getFee().doubleValue() / 100).multiply(feeSetting1.getSetValue()).setScale(2, RoundingMode.HALF_UP);
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue().add(bigDecimal));
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }else {
                                        tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                        tCompanyResp.setPrice(feeSetting1.getSetValue());
                                    }
                                }else {
                                    tCompanyResp.setAdminPrice(feeSetting1.getSetValue());
                                    tCompanyResp.setPrice(feeSetting1.getSetValue());
                                }
                                objects.add(tCompanyResp);
                            }else {
                                breakNum=1;
@@ -549,7 +802,7 @@
                        tOrder.setType(demandDto.getType());
                        tOrder.setZipCode(demandDto.getZipCode());
                        if("0".equals(demandDto.getWarehouse())){
                            tOrder.seteAddress(demandDto.getZipCode());
                            tOrder.seteAddress(AddressLookup.getAddress(demandDto.getZipCode()));
                        }else {
                            TWarehouse tWarehouse = warehouseService.selectOne(new EntityWrapper<TWarehouse>().eq("company_id", company.getId()).eq("code", demandDto.getWarehouse()).eq("port_id",ratesId));
                            tOrder.seteAddress(tWarehouse.getAddress());
@@ -565,7 +818,7 @@
                        tOrder.setAllTotal(bigDecimal);
                        orderService.updateById(tOrder);
                        objects.stream().forEach(e->e.setOrderId(tOrder.getId()));
                        orderId= tOrder.getId();
                        TGoods tGoods = new TGoods();
                        tGoods.setShippingLine(goodsListDto.getShippingLine());
                        tGoods.setDanger(goodsListDto.getDanger());
@@ -577,6 +830,24 @@
                        tGoods.setTypeClass(goodsDto.getTypeClass());
                        tGoods.setLineStr(goodsDto.getLineStr());
                        tGoods1.add(tGoods);
                        String randomNumber = ToolUtil.getRandomNumber(10);
                        for (TCompanyResp object : objects) {
                            TPrice tPrice = new TPrice();
                            tPrice.setCreateTime(new Date());
                            tPrice.setOrderId(orderId);
                            tPrice.setState("1");
                            tPrice.setPrice(object.getAdminPrice());
                            tPrice.setCarPrice(object.getPrice());
                            tPrice.setType(object.getName());
                            tPrice.setStatus(1);
                            tPrice.setNumber(randomNumber);
                            tPrice.setDay(object.getDay());
                            tPrices.add(tPrice);
                        }
                        if(tPrices.size()>0){
                            priceService.insertBatch(tPrices);
                        }
                    }
                    if(tGoods1.size()>0){
@@ -584,21 +855,7 @@
                    }
                    String randomNumber = ToolUtil.getRandomNumber(10);
                    for (TCompanyResp object : objects) {
                        TPrice tPrice = new TPrice();
                        tPrice.setCreateTime(new Date());
                        tPrice.setOrderId(object.getOrderId());
                        tPrice.setState("1");
                        tPrice.setPrice(object.getPrice());
                        tPrice.setType(object.getName());
                        tPrice.setStatus(1);
                        tPrice.setNumber(randomNumber);
                        tPrices.add(tPrice);
                    }
                    if(tPrices.size()>0){
                        priceService.insertBatch(tPrices);
                    }
                }
                tCompanyCalculationResp.setOrderList(tOrders);
@@ -679,7 +936,11 @@
    }
    private String getStr(String str){
        if(str==null){
            return null;
        }
        String s = "";
        String[] split = str.split(",");
        if(split.length==1){
@@ -691,7 +952,7 @@
            }
        }else {
            for (int i = 0; i < split.length; i++) {
                if(!split[i].equals("CTF")&&!split[i].equals("URGENT FEE") && !split[i].equals("CTF")){
                if(!split[i].equals("CTF")&&!split[i].equals("URGENT FEE") && !split[i].equals("PIPERPASS")){
                    if(i==split.length-1){
                        s+=split[i];
                    }else {
@@ -775,9 +1036,22 @@
        List<TOrder> orders = new ArrayList<>();
        for (DemandDtoTwo dtoTwo : demandDtoTwo.getDemandDtoTwo()) {
            TOrder tOrder = new TOrder();
            BeanUtil.copyProperties(dtoTwo,tOrder);
            orders.add(tOrder);
            TOrder tOrder1 = orderService.selectById(dtoTwo.getId());
            List<TOrder> orders1 = orderService.selectList(new EntityWrapper<TOrder>().eq("e_zip_z", tOrder1.geteZipZ()));
            for (TOrder order : orders1) {
                order.setsName(dtoTwo.getSName());
                order.setsPhone(dtoTwo.getSPhone());
                order.setsEmail(dtoTwo.getSEmail());
                order.setePhone(dtoTwo.getEPhone());
                order.seteEmail(dtoTwo.getEEmail());
                order.seteName(dtoTwo.getEName());
                if(dtoTwo.getEAddress()!=null && !"".equals(dtoTwo.getEAddress())){
                    order.seteAddress(dtoTwo.getEAddress());
                }
                orders.add(order);
            }
        }
        orderService.updateBatchById(orders);
        List<TUserFeeSetting> tUserFeeSettings =null;
        Long next = integers.iterator().next();
        TOrder tOrder1 = orderService.selectById(next);
@@ -785,7 +1059,9 @@
        TUser tUser = userService.selectById(userId);
        if(tUser.getGroupId()!=null){
            TGroup tGroup = groupService.selectById(tUser.getGroupId());
            tUserFeeSettings = userFeeSettingService.selectList(new EntityWrapper<TUserFeeSetting>().eq("user_id", tGroup.getSalesId()));
            if(tGroup!=null) {
                tUserFeeSettings = userFeeSettingService.selectList(new EntityWrapper<TUserFeeSetting>().eq("user_id", tGroup.getSalesId()));
            }
        }
        for (Long order : integers) {
@@ -797,27 +1073,30 @@
            tOrder.setStatus("0");
            BigDecimal bigDecimal = new BigDecimal(0);
            // 通过每个订单  找出当前的用户的sale  找出提成算出应给卡车公司的价格
            List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", order));
            if(tUserFeeSettings!=null){
                for (TUserFeeSetting tUserFeeSetting : tUserFeeSettings) {
                    for (TPrice price : prices) {
                        if(tUserFeeSetting.getName().equals(price.getType())){
                            double v = (double) tUserFeeSetting.getFee() / 100;
                            BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v));
                            // 付卡车的钱
                            BigDecimal subtract = price.getPrice().subtract(multiply);
                            price.setCarPrice(subtract);
                            bigDecimal = bigDecimal.add(subtract);
                        }else {
                            price.setCarPrice(price.getPrice());
                            bigDecimal = bigDecimal.add(price.getPrice());
                        }
                    }
                }
            }else {
                prices.stream().forEach(e->e.setCarPrice(e.getPrice()));
            List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", order).eq("status",1));
//            if(tUserFeeSettings!=null && tUserFeeSettings.size()>0){
//                for (TUserFeeSetting tUserFeeSetting : tUserFeeSettings) {
//                    for (TPrice price : prices) {
//                        if(tUserFeeSetting.getName().equals(price.getType())){
//                            double v = (double) tUserFeeSetting.getFee() / 100;
//                            BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v));
//                            // 付卡车的钱
//                            BigDecimal subtract = price.getPrice().subtract(multiply);
//                            price.setCarPrice(subtract);
//                            bigDecimal = bigDecimal.add(subtract);
//                        }else {
//                            price.setCarPrice(price.getPrice());
//                            bigDecimal = bigDecimal.add(price.getPrice());
//                        }
//                    }
//                }
//            }else {
//                prices.stream().forEach(e->e.setCarPrice(e.getPrice()));
//            }
//            priceService.updateBatchById(prices);
            for (TPrice price : prices) {
                bigDecimal = bigDecimal.add(price.getPrice());
            }
            priceService.updateBatchById(prices);
            tOrder.setPayMoney(bigDecimal);
            orderService.updateById(tOrder);