From 485b09d75ac79350392e234a62521050bf6374de Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期二, 04 三月 2025 11:00:43 +0800 Subject: [PATCH] 修改物流信息导入模板 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 108 ++++++++++++++++++++++++++++++----------------------- 1 files changed, 61 insertions(+), 47 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index b5cd03b..e0d7b19 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -133,6 +133,10 @@ @Resource private RegionClient regionClient; + @Resource + private AppUserGiveawayTemporaryClient appUserGiveawayTemporaryClient; + @Resource + private ShopGiveawayTemporaryClient shopGiveawayTemporaryClient; @Override @@ -293,15 +297,14 @@ JSONObject jsonObject = JSONObject.parseObject(content); Long days = jsonObject.getLong("days"); order.setOrderStatus(OrderStatus.COMPLETED.getCode()); - order.setIsCommission(0); order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); order.setEndTime(LocalDateTime.now()); order.setCancellerAppUserId(loginUserApplet.getUserid()); if (StringUtils.isNotEmpty(technicianId) && !"null".equals(technicianId)) { order.setTechnicianId(Integer.valueOf(technicianId)); } - // TODO orderMapper.updateById(order); + commissionService.calculationCommissionShop(order.getId()); } @@ -456,52 +459,12 @@ throw new RuntimeException("订单取消失败"); } shopPointClient.deleteShopPointCopy(orderId, Arrays.asList(1,2,3)); + appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(orderId); + shopGiveawayTemporaryClient.delShopGiveawayTemporary(orderId); return r; } - /** - * 确认发货操作 - * - * @return - */ - @Override - public R confirmDelivery(ConfirmDelivery confirmDelivery) { - Order order = this.getById(confirmDelivery.getOrderId()); - if (1 == order.getPayStatus()) { - return R.fail("订单还未完成支付"); - } - if (1 == order.getOrderType() || null == order.getAddressJson()) { - return R.fail("该订单不支付快递配送"); - } - if (1 != order.getOrderStatus()) { - return R.fail("无效的操作"); - } - //添加快递号和修改订单状态 - order.setExpressJson(confirmDelivery.getCode()); - order.setDeliverProvince(confirmDelivery.getDeliverProvince()); - order.setDeliverProvinceCode(confirmDelivery.getDeliverProvinceCode()); - order.setDeliverCity(confirmDelivery.getDeliverCity()); - order.setDeliverCityCode(confirmDelivery.getDeliverCityCode()); - order.setDeliverDistrict(confirmDelivery.getDeliverDistrict()); - order.setDeliverDistrictCode(confirmDelivery.getDeliverDistrictCode()); - order.setOrderStatus(2); - //添加查询快递信息队列 - //一小时后定时查询快递信息 - SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); - JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); - Integer waitTime = jsonObject.getInteger("waitTime"); - redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); - JSONObject jsonObject1 = JSON.parseObject(confirmDelivery.getCode()); - String com = jsonObject1.getString("com"); - String num = jsonObject1.getString("num"); - UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); - MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(), - userAddress.getProvince() + userAddress.getCity()); - order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); - this.updateById(order); - return R.ok(); - } /** @@ -997,11 +960,15 @@ } } - @SneakyThrows @Override @Transactional(rollbackFor = Exception.class) public void importExpress(String url) { - URL url1 = new URL(url); + URL url1 = null; + try { + url1 = new URL(url); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } try (InputStream fileInputStream = url1.openStream()) { Workbook workbook = new XSSFWorkbook(fileInputStream); Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet @@ -1065,7 +1032,10 @@ confirmDelivery.setDeliverProvinceCode(regionBiCode.getData().getCode()); confirmDelivery.setDeliverCity(regionBiCode1.getData().getName()); confirmDelivery.setDeliverCityCode(regionBiCode1.getData().getCode()); - confirmDelivery(confirmDelivery); + R r = confirmDelivery(confirmDelivery); + if (R.isError(r)) { + throw new ServiceException(r.getMsg(), 500); + } } } catch (IOException e) { @@ -1076,6 +1046,50 @@ } + /** + * 确认发货操作 + * + * @return + */ + @Override + public R confirmDelivery(ConfirmDelivery confirmDelivery) { + Order order = this.getById(confirmDelivery.getOrderId()); + if (1 == order.getPayStatus()) { + return R.fail("订单还未完成支付"); + } + if (1 == order.getOrderType() || null == order.getAddressJson()) { + return R.fail("该订单不支付快递配送"); + } + if (1 != order.getOrderStatus()) { + return R.fail("无效的操作"); + } + //添加快递号和修改订单状态 + order.setExpressJson(confirmDelivery.getCode()); + order.setDeliverProvince(confirmDelivery.getDeliverProvince()); + order.setDeliverProvinceCode(confirmDelivery.getDeliverProvinceCode()); + order.setDeliverCity(confirmDelivery.getDeliverCity()); + order.setDeliverCityCode(confirmDelivery.getDeliverCityCode()); + order.setDeliverDistrict(confirmDelivery.getDeliverDistrict()); + order.setDeliverDistrictCode(confirmDelivery.getDeliverDistrictCode()); + order.setOrderStatus(2); + //添加查询快递信息队列 + //一小时后定时查询快递信息 + SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); + JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); + Integer waitTime = jsonObject.getInteger("waitTime"); + redisTemplate.opsForZSet().add("order_express", order.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); + + JSONObject jsonObject1 = JSON.parseObject(confirmDelivery.getCode()); + String com = jsonObject1.getString("com"); + String num = jsonObject1.getString("num"); + UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); + MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, order.getDeliverProvince() + order.getDeliverCity(), + userAddress.getProvince() + userAddress.getCity()); + order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); + this.updateById(order); + return R.ok(); + } + public static void importExpress2(String filePath) throws MalformedURLException { // 从网络地址读取 -- Gitblit v1.7.1