| | |
| | | @ResponseBody |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) |
| | | public Object addDemand(@RequestBody DemandDto demandDto) throws Exception { |
| | | Integer userId1 = demandDto.getUserId(); |
| | | |
| | | TUser tUser1 = userService.selectById(userId1); |
| | | if(tUser1.getPhone()==null){ |
| | | return new ErrorTip(5008,"It is necessary to complete the information before issuing the quotation demand"); |
| | | } |
| | | |
| | | |
| | | int breakNum=0; |
| | | // 计数 |
| | | int count=0; |
| | | Integer id = demandDto.getId(); |
| | | String s1 = System.currentTimeMillis() + ToolUtil.getRandomString(5); |
| | | String s2 = System.currentTimeMillis() + ToolUtil.getRandomString(5); |
| | |
| | | }else { |
| | | List<TCompany> companies = companyService.selectList(new EntityWrapper<TCompany>().in("id", set)); |
| | | for (TCompany company : companies) { |
| | | breakNum=0; |
| | | TCompanyCalculationResp tCompanyCalculationResp = new TCompanyCalculationResp(); |
| | | ArrayList<TOrder> tOrders = new ArrayList<>(); |
| | | // 超重 价格 |
| | |
| | | } |
| | | |
| | | for (GoodsListDto goodsListDto : list1) { |
| | | if(breakNum==1){ |
| | | break; |
| | | } |
| | | ArrayList<TPrice> tPrices = new ArrayList<>(); |
| | | // 生成订单 |
| | | // TOrder tOrder = new TOrder(); |
| | |
| | | List<GoodsDto> list = goodsListDto.getList(); |
| | | ArrayList<TGoods> tGoods1 = new ArrayList<>(); |
| | | for (GoodsDto goodsDto : list) { |
| | | |
| | | // 生成订单 |
| | | TOrder tOrder = new TOrder(); |
| | | tOrder.setCity(city.getId()); |
| | | tOrder.setState(state.getId()); |
| | | tOrder.setUserId(demandDto.getUserId()); |
| | | tOrder.setAccessorial(demandDto.getAccessorial()); |
| | | tOrder.setAccessorialStr(demandDto.getAccessorialStr()); |
| | | tOrder.setPort(demandDto.getPortId()); |
| | | tOrder.setShipmentDate(demandDto.getShipmentDate()); |
| | | tOrder.setDeliveryDate(demandDto.getDeliveryDate()); |
| | | tOrder.seteZipZ(s1); |
| | | tOrder.setCreateTime(new Date()); |
| | | tOrder.setStartLat("1"); |
| | | tOrder.setStartLon("1"); |
| | | tOrder.setDeliveryStr(demandDto.getDelivery()); |
| | | tOrder.setType(demandDto.getType()); |
| | | tOrder.setZipCode(demandDto.getZipCode()); |
| | | tOrder.seteAddress(demandDto.getZipCode()); |
| | | tOrder.setWarehouse(demandDto.getWarehouse()); |
| | | // TODO 未选择17 下一步选择 |
| | | tOrder.setStatus("17"); |
| | | tOrder.setInvoiceNumber(s2); |
| | | tOrder.setCompanyId(company.getId()); |
| | | tOrder.setCreateTime(new Date()); |
| | | orderService.insert(tOrder); |
| | | tOrders.add(tOrder); |
| | | |
| | | TCompanyResp tCompanyResp = new TCompanyResp(); |
| | | if("0".equals(demandDto.getWarehouse())){ |
| | | tCompanyResp=new TCompanyResp(); |
| | | BigDecimal setValue1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id",ratesId).eq("set_name", demandDto.getDelivery())).getSetValue(); |
| | | tCompanyResp.setName(demandDto.getDelivery()); |
| | | tCompanyResp.setPrice(setValue1); |
| | | objects.add(tCompanyResp); |
| | | |
| | | // 基础价格 |
| | | String zipCode = demandDto.getZipCode(); |
| | | // 地址信息 |
| | | String address1 = AddressLookup.getAddress(zipCode); |
| | | |
| | | List<TCompanyBasic> tCompanyBasic = companyBasicService.selectList(new EntityWrapper<TCompanyBasic>().eq("port_id",ratesId).eq("zip_code", zipCode).eq("type", 1)); |
| | | if(tCompanyBasic.size()>0){ |
| | | tCompanyResp=new TCompanyResp(); |
| | | tCompanyResp.setPrice(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)); |
| | | 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.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 { |
| | | breakNum=1; |
| | | count++; |
| | | break; |
| | | } |
| | | } |
| | | }else { |
| | | // 距离 |
| | | 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 { |
| | | breakNum=1; |
| | | count++; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | 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)){ |
| | | tCompanyResp.setPrice(tWarehouse.getWarePrice()); |
| | | }else { |
| | | tCompanyResp.setPrice(new BigDecimal("0")); |
| | | } |
| | | objects.add(tCompanyResp); |
| | | } |
| | | |
| | | // 是否超重 |
| | | Integer weight = goodsDto.getWeight(); |
| | | long between = DateUtil.between(demandDto.getShipmentDate(), demandDto.getDeliveryDate(), DateUnit.DAY); |
| | |
| | | } |
| | | |
| | | |
| | | if("0".equals(demandDto.getWarehouse())){ |
| | | tCompanyResp=new TCompanyResp(); |
| | | BigDecimal setValue1 = companyFeeSettingService.selectOne(new EntityWrapper<TCompanyFeeSetting>().eq("company_id", company.getId()).eq("rates_id",ratesId).eq("set_name", demandDto.getDelivery())).getSetValue(); |
| | | tCompanyResp.setName(demandDto.getDelivery()); |
| | | tCompanyResp.setPrice(setValue1); |
| | | objects.add(tCompanyResp); |
| | | |
| | | // 基础价格 |
| | | String zipCode = demandDto.getZipCode(); |
| | | // 地址信息 |
| | | String address1 = AddressLookup.getAddress(zipCode); |
| | | List<TCompanyBasic> tCompanyBasic = companyBasicService.selectList(new EntityWrapper<TCompanyBasic>().eq("port_id",ratesId).eq("zip_code", zipCode).eq("type", 1)); |
| | | if(tCompanyBasic.size()>0){ |
| | | tCompanyResp=new TCompanyResp(); |
| | | tCompanyResp.setPrice(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)); |
| | | 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.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 |
| | | 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(); |
| | | 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)){ |
| | | tCompanyResp.setPrice(tWarehouse.getWarePrice()); |
| | | }else { |
| | | tCompanyResp.setPrice(new BigDecimal("0")); |
| | | } |
| | | objects.add(tCompanyResp); |
| | | } |
| | | BigDecimal bigDecimal = objects.stream().map(e -> e.getPrice()==null?new BigDecimal(0):e.getPrice()).reduce(BigDecimal::add).get(); |
| | | // 生成订单 |
| | | TOrder tOrder = new TOrder(); |
| | | tOrder.setCity(city.getId()); |
| | | tOrder.setState(state.getId()); |
| | | tOrder.setUserId(demandDto.getUserId()); |
| | | tOrder.setAccessorial(demandDto.getAccessorial()); |
| | | tOrder.setAccessorialStr(demandDto.getAccessorialStr()); |
| | | tOrder.setPort(demandDto.getPortId()); |
| | | tOrder.setShipmentDate(demandDto.getShipmentDate()); |
| | | tOrder.setDeliveryDate(demandDto.getDeliveryDate()); |
| | | tOrder.seteZipZ(s1); |
| | | tOrder.setCreateTime(new Date()); |
| | | tOrder.setStartLat("1"); |
| | | tOrder.setStartLon("1"); |
| | | tOrder.setDeliveryStr(demandDto.getDelivery()); |
| | | tOrder.setType(demandDto.getType()); |
| | | tOrder.setZipCode(demandDto.getZipCode()); |
| | | if("0".equals(demandDto.getWarehouse())){ |
| | | tOrder.seteAddress(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()); |
| | | } |
| | | |
| | | tOrder.setWarehouse(demandDto.getWarehouse()); |
| | | tOrder.setStatus("17"); |
| | | tOrder.setInvoiceNumber(s2); |
| | | tOrder.setCompanyId(company.getId()); |
| | | tOrder.setCreateTime(new Date()); |
| | | orderService.insert(tOrder); |
| | | tOrders.add(tOrder); |
| | | tOrder.setAllTotal(bigDecimal); |
| | | orderService.updateById(tOrder); |
| | | objects.stream().forEach(e->e.setOrderId(tOrder.getId())); |
| | |
| | | }else { |
| | | String zipCode = demandDto.getZipCode(); |
| | | // GeocodeVo geocode1 = googleMapUtil.getGeocode(zipCode); |
| | | // tCompanyCalculationResp.setEndLon(String.valueOf(geocode1.getLng())); |
| | | // tCompanyCalculationResp.setEndLat(String.valueOf(geocode1.getLat())); |
| | | // tCompanyCalculationResp.setEndLon(String.valueOf(geocode1.getLng())); |
| | | tCompanyCalculationResp.setEndLat(String.valueOf(1)); |
| | | tCompanyCalculationResp.setEndLon(String.valueOf(1)); |
| | | tCompanyCalculationRespList.add(tCompanyCalculationResp); |
| | | } |
| | | |
| | | |
| | | } |
| | | if(count==companies.size()){ |
| | | return new ErrorTip(5001,"No truck company was matched to meet the demand"); |
| | | } |
| | | |
| | | } |
| | |
| | | List<TOrder> orders = orderService.selectList(new EntityWrapper<TOrder>().eq("e_zip_z", quote.getOrderId()).eq("status", 0)); |
| | | ArrayList<TGoods> goods = new ArrayList<>(); |
| | | BigDecimal bigDecimal = new BigDecimal(0); |
| | | ArrayList<TPrice> tPrices = new ArrayList<>(); |
| | | for (TOrder order : orders) { |
| | | TGoods tGoods = goodsService.selectOne(new EntityWrapper<TGoods>().eq("order_id", order.getId())); |
| | | goods.add(tGoods); |
| | | bigDecimal=bigDecimal.add(order.getAllTotal()); |
| | | List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", order.getId())); |
| | | tPrices.addAll(prices); |
| | | } |
| | | Map<String, BigDecimal> sumMap = tPrices.stream() |
| | | .collect(Collectors.groupingBy(TPrice::getType, Collectors.reducing(BigDecimal.ZERO, TPrice::getPrice, BigDecimal::add))); |
| | | List<PriceList> pricesList = sumMap.entrySet().stream() |
| | | .map(entry -> new PriceList(entry.getKey(), entry.getValue())) |
| | | .collect(Collectors.toList()); |
| | | Integer userId = orders.get(0).getUserId(); |
| | | TUser tUser = userService.selectById(userId); |
| | | String residueLimit = tUser.getResidueLimit(); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("money",bigDecimal); |
| | | map.put("data",goods); |
| | | map.put("residueLimit",residueLimit); |
| | | map.put("prices",pricesList); |
| | | return new SuccessTip(map); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "发布需求-第二步/修改需求",notes="发布需求-第二步/修改需求") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |