package com.stylefeng.guns.modular.system.controller; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.*; import com.stylefeng.guns.modular.system.utils.HttpRequest; import com.stylefeng.guns.modular.system.utils.RedisUtil; import com.stylefeng.guns.modular.system.utils.tips.ErrorTip; import com.stylefeng.guns.modular.system.utils.tips.SuccessTip; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; import java.net.FileNameMap; import java.net.URLConnection; import java.util.*; @Controller @Api(tags = "订单") @RequestMapping("/api/order") public class OrderController { @Autowired private ITOrderService orderService; @Autowired private ITDriverService driverService; @Autowired private ITExamSiteService examSiteService; @Autowired private ITUserFeeSettingService feeSettingService; @Autowired private ITGroupService groupService; @Autowired private ITUserService itUserService; @Autowired private ITPriceService priceService; @Autowired private IUserService service; @Autowired private ITOrderLogService orderLogService; @Autowired private ITOrderFileService fileService; @Autowired private ITUserAddressService addressService; @Autowired private ITPortService portService; @Resource private ITGoodsService goodsService; @Autowired private RedisUtil redisUtil; /** * company 订单 * @param dto * @return */ @ApiOperation(value = "卡车公司-订单列表",notes="卡车公司-订单列表") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) @PostMapping(value = "/getOrderList") @ResponseBody public Object getOrderList(@RequestBody OrderListDto dto) { Page orderListVoPage = new Page<>(dto.getPageNumber(), dto.getPageSize()); List list = orderService.getOrderList(orderListVoPage,dto); orderListVoPage.setRecords(list); return new SuccessTip(orderListVoPage); } @ApiOperation(value = "卡车公司-订单取消",notes="卡车公司-订单取消") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/cancelOrderList") @ResponseBody public Object cancelOrderList(Long orderId) { TOrder tOrder = orderService.selectById(orderId); tOrder.setStatus("16"); orderService.updateById(tOrder); return new SuccessTip(); } @ApiOperation(value = "商品详情",notes="商品详情") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/getGoodsInfo") @ResponseBody public Object getGoodsInfo( Long orderId) { List list = orderService.getGoodsInfo(orderId); return new SuccessTip(list); } @ApiOperation(value = "卡车公司-删除订单",notes="卡车公司-删除订单") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/deleteOrder") @ResponseBody public Object deleteOrder( Long orderId) { TOrder tOrder = orderService.selectById(orderId); if(tOrder.getStatus().equals("16")){ orderService.deleteById(tOrder); return new SuccessTip(); }else { return new ErrorTip(5006,"The order status cannot be deleted"); } } @ApiOperation(value = "订单详情",notes="订单详情") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/getOrderInfo") @ResponseBody public Object getOrderInfo( Long orderId) { OrderInfo orderInfo = orderService.getOrderInfo(orderId); return new SuccessTip(orderInfo); } @Resource private TTransportationService tTransportationService; @Resource private TPowerUnitsService powerUnitsService; @ApiOperation(value = "卡车公司-获取运输安排",notes="卡车公司-获取运输安排") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/getTransportInfo") @ResponseBody public Object getTransportInfo(@RequestParam Long orderId) { TransportInfo transportInfo = new TransportInfo(); ArrayList orderDriverInfos = new ArrayList<>(); ArrayList driverIds = new ArrayList<>(); TOrder tOrder = orderService.selectById(orderId); // 第一个开始司机id Integer sDriverid = tOrder.getsDriverid(); if(sDriverid!=null){ driverIds.add(sDriverid); } // 第2个开始司机id Integer sDriverIdOne = tOrder.getsDriverIdOne(); if(sDriverIdOne!=null){ driverIds.add(sDriverIdOne); } Integer driverid = tOrder.geteDriverid(); if(driverid!=null){ driverIds.add(driverid); } Integer driverIdOne = tOrder.geteDriverIdOne(); if(driverIdOne!=null){ driverIds.add(driverIdOne); } List tTransportations = tTransportationService.selectList(new EntityWrapper().eq("order_id", orderId).in("driver_id", driverIds)); for (TTransportation tDriver : tTransportations) { OrderDriverInfo orderDriverInfo = new OrderDriverInfo(); orderDriverInfo.setId(tDriver.getId()); if(tDriver.getId().equals(sDriverIdOne)&&tDriver.getType()==2){ orderDriverInfo.setPickUp(tDriver.getPickDate()); } if(tDriver.getId().equals(driverid) &&tDriver.getType()==3){ orderDriverInfo.setEmptyDate(tDriver.getEmptyDate()); } if(tDriver.getId().equals(driverIdOne) &&tDriver.getType()==4){ orderDriverInfo.setReturnDate(tDriver.getReturnDate()); } orderDriverInfo.setContactEmail(tDriver.getEmail()); orderDriverInfo.setContactName(tDriver.getName()); orderDriverInfo.setContactPhone(tDriver.getPhone()); orderDriverInfo.setTPowerUnits(powerUnitsService.selectById(tDriver.getPowerUnit())); orderDriverInfo.setChassiess(powerUnitsService.selectById(tDriver.getChassises())); // TODO 第三方 目前不知道对接那个 orderDriverInfo.setAppointmentNumber(null); orderDriverInfos.add(orderDriverInfo); } transportInfo.setTruckCompany(tOrder.getTruckCompany()); transportInfo.setPickupTime(tOrder.getPickupTimeTruck()); transportInfo.setStreetTurn(tOrder.getStreetTurn()); transportInfo.setList(orderDriverInfos); Integer examSite = tOrder.getExamSite(); if(Objects.nonNull(examSite)){ TExamSite tExamSite = examSiteService.selectById(examSite); transportInfo.setAddress(tExamSite.getAddress()); transportInfo.setContactEmail(tExamSite.getContactEmail()); transportInfo.setContactName(tExamSite.getContactName()); transportInfo.setExamSiteName(tExamSite.getExamSiteName()); transportInfo.setZipCode(tExamSite.getZipCode()); } return new SuccessTip(transportInfo); } @ApiOperation(value = "获取费用明细",notes="获取费用明细") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/getPriceInfo") @ResponseBody public Object getPriceInfo(Long orderId){ TOrder tOrder = orderService.selectById(orderId); Integer userId = tOrder.getUserId(); // 获取用户所i在分组 TUser tUser = itUserService.selectById(userId); List prices = priceService.selectList(new EntityWrapper().eq("order_id", tOrder.getId())); ArrayList priceInfos = new ArrayList<>(); if(tUser.getGroupId()!=null){ TGroup tGroup = groupService.selectById(tUser.getGroupId()); User user = service.selectById(tGroup.getSalesId()); // 提成 Double commission = user.getCommission(); // 获取分组sale List tUserFeeSettings = feeSettingService.selectList(new EntityWrapper().eq("user_id", tGroup.getSalesId())); // 提成一个 根据价格判断 for (TPrice price : prices) { for (TUserFeeSetting tUserFeeSetting : tUserFeeSettings) { if(price.getType().equals(tUserFeeSetting.getName())){ PriceInfo priceInfo = new PriceInfo(); priceInfo.setName(price.getType()); priceInfo.setCustomerCost(price.getPrice()); if(tUserFeeSetting.getFee()!=null && tUserFeeSetting.getFee()!=0) { double v = ((double) tUserFeeSetting.getFee()) / 100; BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v)); BigDecimal subtract = price.getPrice().subtract(multiply); priceInfo.setCarrierCost(subtract); priceInfo.setSalesProfit(new BigDecimal(commission)); priceInfo.setMargin(multiply); }else { priceInfo.setMargin(new BigDecimal(0)); priceInfo.setSalesProfit(new BigDecimal(commission)); priceInfo.setCarrierCost(price.getPrice()); } priceInfos.add(priceInfo); break; } } } }else { for (TPrice price : prices) { PriceInfo priceInfo = new PriceInfo(); priceInfo.setCarrierCost(price.getPrice()); priceInfo.setCustomerCost(price.getPrice()); priceInfo.setName(price.getType()); priceInfo.setSalesProfit(new BigDecimal(0)); priceInfo.setMargin(new BigDecimal(0)); priceInfos.add(priceInfo); } } return new SuccessTip(priceInfos); } @ApiOperation(value = "获取订单日志",notes="获取订单日志") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int"), }) @GetMapping(value = "/getOrderLog") @ResponseBody public Object getOrderLog(Long orderId,int pageNumber,int pageSize){ Page tOrderLogPage = new Page<>(pageNumber, pageSize); Page page = orderLogService.selectPage(tOrderLogPage, new EntityWrapper().eq("order_id", orderId).orderBy("create_time",false)); return new SuccessTip(page); } @ApiOperation(value = "上传司机位置",notes="上传司机位置") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "driverId", value = "driverId", required = true, dataType = "Integer"), @ApiImplicitParam(name = "lon", value = "lon", required = true, dataType = "String"), @ApiImplicitParam(name = "lat", value = "lat", required = true, dataType = "String"), @ApiImplicitParam(name = "type", value = "type", required = true, dataType = "int"), }) @GetMapping(value = "/updateLonLat") @ResponseBody public Object updateLonLat(Integer driverId, String lon, String lat,int type){ // 通过司机id获取订单 List orders = orderService.selectList(new EntityWrapper().eq("nowDriverId", driverId)); if(orders.size()>0){ TOrder tOrder = orders.get(0); if(type==1){ orderService.saveLonLat(tOrder.getId(),lon,lat); } redisUtil.setStrValue(tOrder.getId().toString(),lon+lat); } return new SuccessTip(); } @ApiOperation(value = "获取订单司机位置",notes="获取订单司机位置") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), @ApiImplicitParam(name = "lon", value = "lon", required = true, dataType = "String"), @ApiImplicitParam(name = "lat", value = "lat", required = true, dataType = "String"), }) @GetMapping(value = "/getLonLat") @ResponseBody public Object getLonLat(Long orderId){ // 通过司机id获取订单 List> orders = orderService.getLonLat(orderId); return new SuccessTip(orders); } @ApiOperation(value = "卡车公司--安排司机",notes="卡车公司--安排司机") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) @PostMapping(value = "/selectDriver") @ResponseBody public Object selectDriver(@RequestBody CompanySelectDriverDto companySelectDriverDto){ try { Long orderId = companySelectDriverDto.getOrderId(); // 找出这个订单 TOrder tOrder = orderService.selectById(orderId); List list = companySelectDriverDto.getList(); tOrder.setsDriverid(list.get(0).getDriverId()); tOrder.setsDriverIdOne(list.get(1).getDriverId()); tOrder.seteDriverid(list.get(2).getDriverId()); tOrder.seteDriverIdOne(list.get(3).getDriverId()); tOrder.setTruckCompany(companySelectDriverDto.getTruckCompany()); tOrder.setPickupTimeTruck(companySelectDriverDto.getPickupTime()); tOrder.setStreetTurn(companySelectDriverDto.getStreetTurn()); // 添加司机信息 tTransportationService.insertBatch(companySelectDriverDto.getList()); // 更改订单信息 orderService.updateById(tOrder); return new SuccessTip(); }catch (Exception e){ e.printStackTrace(); } return new ErrorTip(500,"ERROR"); } @ApiOperation(value = "卡车公司--修改安排司机(多个)",notes="卡车公司--修改安排司机(多个)") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) @PostMapping(value = "/updateDriver") @ResponseBody public Object updateDriver(@RequestBody CompanySelectDriverDto companySelectDriverDto){ try { Long orderId = companySelectDriverDto.getOrderId(); // 找出这个订单 TOrder tOrder = orderService.selectById(orderId); List list = companySelectDriverDto.getList(); tOrder.setsDriverid(list.get(0).getDriverId()); tOrder.setsDriverIdOne(list.get(1).getDriverId()); tOrder.seteDriverid(list.get(2).getDriverId()); tOrder.seteDriverIdOne(list.get(3).getDriverId()); tOrder.setTruckCompany(companySelectDriverDto.getTruckCompany()); tOrder.setPickupTimeTruck(companySelectDriverDto.getPickupTime()); tOrder.setStreetTurn(companySelectDriverDto.getStreetTurn()); // 删除原来的司机信息 tTransportationService.delete(new EntityWrapper().eq("order_id",orderId)); // 添加新司机信息 tTransportationService.insertBatch(companySelectDriverDto.getList()); // 更改订单信息 orderService.updateById(tOrder); return new SuccessTip(); }catch (Exception e){ e.printStackTrace(); } return new ErrorTip(500,"ERROR"); } @ApiOperation(value = "卡车公司--修改安排司机(单个)",notes="卡车公司--修改安排司机(单个)") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) @PostMapping(value = "/updateDriverSingle") @ResponseBody public Object updateDriverSingle(@RequestBody CompanySelectDriverSingleDto companySelectDriverSingleDto){ try { Long orderId = companySelectDriverSingleDto.getOrderId(); // 找出这个订单 TOrder tOrder = orderService.selectById(orderId); TTransportation list = companySelectDriverSingleDto.getList(); Integer type = companySelectDriverSingleDto.getType(); if(type==1){ // 删除原来的司机信息 tTransportationService.delete(new EntityWrapper().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverid())); tOrder.setsDriverid(list.getDriverId()); }else if(type==2){ // 删除原来的司机信息 tTransportationService.delete(new EntityWrapper().eq("order_id",orderId).eq("driver_id",tOrder.getsDriverIdOne())); tOrder.setsDriverIdOne(list.getDriverId()); }else if(type==3){ // 删除原来的司机信息 tTransportationService.delete(new EntityWrapper().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverid())); tOrder.seteDriverid(list.getDriverId()); }else { // 删除原来的司机信息 tTransportationService.delete(new EntityWrapper().eq("order_id",orderId).eq("driver_id",tOrder.geteDriverIdOne())); tOrder.seteDriverIdOne(list.getDriverId()); } tTransportationService.insert(list); // 更改订单信息 orderService.updateById(tOrder); return new SuccessTip(); }catch (Exception e){ e.printStackTrace(); } return new ErrorTip(500,"ERROR"); } @Resource private TYardService yardService; /** * 点击定位点 * @param companyLocationDto * @return */ @ApiOperation(value = "卡车公司--点击定位(场地/码头)",notes="卡车公司--点击定位(场地/码头)") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), }) @PostMapping(value = "/getLocation") @ResponseBody public Object getLocation(@RequestBody CompanyLocationDto companyLocationDto){ try { Long orderId = companyLocationDto.getOrderId(); // 找出这个订单 TOrder tOrder = orderService.selectById(orderId); Integer type = companyLocationDto.getType(); if(type==1){ TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper().eq("order_id", orderId).eq("driver_id", tOrder.getsDriverIdOne())); if(tTransportation!=null){ Integer yardId = tTransportation.getYardId(); TYard tYard = yardService.selectById(yardId); return new SuccessTip(tYard); } }else if(type==2){ TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper().eq("order_id", orderId).eq("driver_id", tOrder.geteDriverid())); if(tTransportation!=null) { Integer yardId = tTransportation.getYardId(); TYard tYard = yardService.selectById(yardId); return new SuccessTip(tYard); } }else if(type==3){ TTransportation tTransportation = tTransportationService.selectOne(new EntityWrapper().eq("order_id", orderId).eq("driver_id", tOrder.geteDriverIdOne())); if(tTransportation!=null) { Integer portId = tTransportation.getPortId(); TPort tPort = portService.selectById(portId); return new SuccessTip(tPort); } } return new ErrorTip(5001,"not found"); }catch (Exception e){ e.printStackTrace(); } return new ErrorTip(500,"ERROR"); } @ApiOperation(value = "获取订单文件",notes="获取订单文件") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), @ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int"), }) @GetMapping(value = "/getOrderFile") @ResponseBody public Object getOrderFile(Long orderId,int pageNumber,int pageSize){ Page tOrderFilePage = new Page<>(pageNumber, pageSize); Page orderFilePage = fileService.selectPage(tOrderFilePage, new EntityWrapper().eq("order_id", orderId).orderBy("create_time",false)); List records = orderFilePage.getRecords(); for (TOrderFile record : records) { FileNameMap fileNameMap = URLConnection.getFileNameMap(); String contentTypeFor = fileNameMap.getContentTypeFor(record.getFile()); String type=null; if(contentTypeFor==null){ type="video"; }else { type="img"; } record.setType(type); } orderFilePage.setRecords(records); return new SuccessTip(orderFilePage); } @ApiOperation(value = "添加订单文件",notes="添加订单文件") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), @ApiImplicitParam(name = "url", value = "文件链接", required = true, dataType = "String"), @ApiImplicitParam(name = "name", value = "文件名称", required = true, dataType = "String"), }) @PostMapping(value = "/addOrderFile") @ResponseBody public Object addOrderFile(@RequestBody AddOrderFile addOrderFile){ Long orderId = addOrderFile.getOrderId(); List file = addOrderFile.getFile(); Boolean b =false; for (TOrderFileDto tOrderFileDto : file) { b = orderService.addOrderFile(orderId, tOrderFileDto.getUrl(), tOrderFileDto.getDeleteUrl()); } if(b){ return new SuccessTip(); } return new ErrorTip(500,"ERROR"); } @ApiOperation(value = "订单详情-提货单",notes="订单详情-提货单") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), }) @GetMapping(value = "/getOrderLading") @ResponseBody public Object getOrderLading(Long orderId){ try { OrderLading orderLading = new OrderLading(); TOrder tOrder = orderService.selectById(orderId); // 找出用户 TUser tUser = itUserService.selectById(tOrder.getUserId()); orderLading.setCustomerName(tUser.getCompanyName()); // 找出默认地址 List addresses = addressService.selectList(new EntityWrapper().eq("user_id", tUser.getId())); if(addresses.size()>0){ for (TUserAddress address : addresses) { if(address.getIsDefault()==1){ orderLading.setCustomerAddress(address.getAddress()); } } if(orderLading.getCustomerAddress()==null){ orderLading.setCustomerAddress(addresses.get(0).getAddress()); } } orderLading.setCustomerPhone(tUser.getPhone()); // 码头信息 TPort tPort = portService.selectById(tOrder.getPort()); orderLading.setPortAddress(tPort.getAddress()); orderLading.setOrderCreateTime(tOrder.getCreateTime()); orderLading.setShipmentDate(tOrder.getShipmentDate()); // 货物信息 TGoods tGoods = goodsService.selectList(new EntityWrapper().eq("order_id", orderId)).get(0); orderLading.setOurRef(tGoods.getOurRef()); orderLading.setSb(tGoods.getSb()); orderLading.setPo(tGoods.getPo()); orderLading.setCustRef(tGoods.getCustRef()); orderLading.setEntry(tGoods.getEntry()); // 获取收货信息 orderLading.setEndCompanyName(tOrder.geteCompanyName()); orderLading.setEndCompanyAddress(tOrder.geteAddress()); orderLading.setEndContactName(tOrder.geteName()); orderLading.setEndContactPhone(tOrder.getePhone()); return new SuccessTip(orderLading); }catch (Exception e){ e.printStackTrace(); return new ErrorTip(500,"ERROR"); } } @ApiOperation(value = "平台给用户报价/平台给卡车公司价格",notes="平台给用户报价/平台给卡车公司价格") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(name = "orderId", value = "orderId", required = true, dataType = "Long"), @ApiImplicitParam(name = "type", value = "1平台给用户报价 2平台给卡车公司价格", required = true, dataType = "int"), }) @GetMapping(value = "/getPriceFromPlatform") @ResponseBody public Object getPriceFromPlatform(Long orderId,int type){ HashMap map = new HashMap<>(); TOrder tOrder = orderService.selectById(orderId); // 根据订单获取报价 map.put("invoice",tOrder.getInvoiceNumber()); map.put("pickUpDate",tOrder.getShipmentDate()); map.put("returnDate",tOrder.getOrderOkTime()); List prices = priceService.selectList(new EntityWrapper().eq("order_id", orderId)); if(type==1){ map.put("price",prices); }else{ // 找出订单用户 --> 获取销售--> 获取提成 --> 计算应给卡车公司金额 Integer userId = tOrder.getUserId(); TUser tUser = itUserService.selectById(userId); if(tUser.getGroupId()==null){ map.put("price",prices); }else { TGroup tGroup = groupService.selectById(tUser.getGroupId()); User user = service.selectById(tGroup.getSalesId()); List tUserFeeSettings = feeSettingService.selectList(new EntityWrapper().eq("user_id", user.getId())); for (TPrice price : prices) { for (TUserFeeSetting tUserFeeSetting : tUserFeeSettings) { if(price.getType().equals(tUserFeeSetting.getName())){ if(tUserFeeSetting.getFee()!=null && tUserFeeSetting.getFee()!=0) { double v = ((double) tUserFeeSetting.getFee()) / 100; BigDecimal multiply = price.getPrice().multiply(new BigDecimal(v)); BigDecimal subtract = price.getPrice().subtract(multiply); price.setPrice(subtract); }else { price.setPrice(price.getPrice()); } break; } } } map.put("price",prices); } } return new SuccessTip(map); } public static void main(String[] args) { ArrayList doubles = new ArrayList<>(); doubles.add(23.2); doubles.add(2.2); doubles.add(3.5); double sum = doubles.stream().mapToDouble(Double::doubleValue).sum(); System.out.println(sum); } }