| | |
| | | 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; |
| | |
| | | tOrder.setInvoiceNumber(s2); |
| | | tOrder.setCompanyId(company.getId()); |
| | | tOrder.setCreateTime(new Date()); |
| | | tOrder.seteAddress(demandDto.getEAddress()); |
| | | if("0".equals(demandDto.getWarehouse())){ |
| | | tOrder.seteAddress(demandDto.getEAddress()); |
| | | }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.setOrderType(1); |
| | | orderService.insert(tOrder); |
| | | tOrders.add(tOrder); |
| | |
| | | |
| | | // 基础价格 |
| | | 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(); |
| | |
| | | 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)){ |
| | | tCompanyResp=new TCompanyResp(); |
| | | tCompanyResp.setPrice(type.getFee()); |
| | | tCompanyResp.setName("LH+FSC"); |
| | | objects.add(tCompanyResp); |
| | | // 画圈 拿到的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 |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "需求列表",notes="需求列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | |
| | | @ApiImplicitParam(name = "address", value = "address", required = false, dataType = "String"), |
| | | @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "String"), |
| | | @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "String"), |
| | | @ApiImplicitParam(name = "portId", value = "portId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "companyId", value = "companyId", required = true, dataType = "int"), |
| | | }) |
| | | @GetMapping(value = "/getWarehouse") |
| | | @ResponseBody |
| | | public Object getWarehouse( String address,int pageNumber,int pageSize) { |
| | | public Object getWarehouse( String address,int pageNumber,int pageSize,int portId,int companyId) { |
| | | TRates tRates1 = ratesService.selectOne(new EntityWrapper<TRates>().eq("metro_id", portId).eq("type", 2).eq("company_id", companyId)); |
| | | int ratesId=0; |
| | | if(tRates1!=null){ |
| | | ratesId=tRates1.getId(); |
| | | }else { |
| | | // 找出city |
| | | TPort tPort = portService.selectById(portId); |
| | | TCountry tCountry = countryService.selectById(tPort.getCity()); |
| | | // 是否是符合的港区 |
| | | tRates1 = ratesService.selectOne(new EntityWrapper<TRates>().eq("metro_id", tCountry.getId()).eq("type", 1).eq("company_id", companyId)); |
| | | if(tRates1!=null){ |
| | | ratesId=tRates1.getId(); |
| | | }else { |
| | | ratesId=-1; |
| | | } |
| | | // ratesId=tCountry.getId(); |
| | | } |
| | | |
| | | Page<TWarehouse> tWarehousePage = new Page<>(pageNumber, pageSize); |
| | | |
| | | EntityWrapper<TWarehouse> tWarehouseEntityWrapper = new EntityWrapper<>(); |
| | | tWarehouseEntityWrapper.eq("company_id",0); |
| | | tWarehouseEntityWrapper.eq("company_id",companyId); |
| | | tWarehouseEntityWrapper.eq("port_id",ratesId); |
| | | if(Objects.nonNull(address)){ |
| | | tWarehouseEntityWrapper.like("address",address); |
| | | } |