From 15bfd012429367bf9b8f03bdc8bb101ae0bdfe4d Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 21 三月 2025 15:26:39 +0800 Subject: [PATCH] 修改统计bug --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 41 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 36 insertions(+), 5 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 bd0bbc2..f0fa211 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 @@ -1,5 +1,8 @@ package com.ruoyi.order.service.impl; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -9,11 +12,13 @@ import com.ruoyi.common.core.constant.ExpressCompanyMap; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.HttpUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.uuid.QRCodeGenerator; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.enums.OrderStatus; +import com.ruoyi.order.event.ConfirmDeliveryEvent; import com.ruoyi.order.mapper.OrderGoodMapper; import com.ruoyi.order.mapper.OrderMapper; import com.ruoyi.order.model.Order; @@ -44,6 +49,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.jetbrains.annotations.Nullable; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -58,6 +64,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.*; @@ -137,6 +144,8 @@ private AppUserGiveawayTemporaryClient appUserGiveawayTemporaryClient; @Resource private ShopGiveawayTemporaryClient shopGiveawayTemporaryClient; + @Resource + private ApplicationEventPublisher applicationEventPublisher; @Override @@ -183,9 +192,9 @@ } // 优惠券 String couponJson = order.getCouponJson(); - CouponInfo couponInfo = new CouponInfo(); + JSONObject jsonObject = new JSONObject(); if (StringUtils.isNotEmpty(couponJson)) { - couponInfo = JSONObject.parseObject(couponJson, CouponInfo.class); + jsonObject = JSONObject.parseObject(couponJson); } // 参与活动 @@ -208,7 +217,7 @@ orderDetailVO.setOrderNumber(order.getOrderNumber()); orderDetailVO.setCreateTime(order.getCreateTime()); orderDetailVO.setTotalAmount(order.getTotalAmount()); - orderDetailVO.setCouponName(couponInfo.getCouponName()); + orderDetailVO.setCouponName(jsonObject.getString("couponName")); orderDetailVO.setActivityName(orderActivityInfo.getActivityName()); orderDetailVO.setCouponAmount(order.getDiscountTotalAmount()); orderDetailVO.setExpressAmount(order.getExpressAmount()); @@ -246,6 +255,7 @@ } return orderDetailVO; } + @Override public boolean check(Order order, Integer shopId, Long userId) { @@ -499,7 +509,8 @@ public R refundPayMoney(Order order) { //开始退款 Integer payMethod = order.getPayMethod(); - BigDecimal paymentAmount = order.getPaymentAmount(); + BigDecimal expressAmount = order.getExpressAmount() == null ? BigDecimal.ZERO : order.getExpressAmount(); + BigDecimal paymentAmount = order.getPaymentAmount().add(expressAmount); AppUser appUser = appUserClient.getAppUserById(order.getAppUserId()); if (1 == payMethod) { //微信退款 @@ -594,7 +605,6 @@ if (3 == payMethod) { //开始运费退款,积分支付,运费是单独进行支付的,所以需要单独退款 if (null != order.getExpressAmount() && BigDecimal.ZERO.compareTo(order.getExpressAmount()) < 0) { - BigDecimal expressAmount = order.getExpressAmount(); if (1 == order.getExpressPayMethod()) { //微信退款 RefundResult refund = PaymentUtil.refund(order.getOrderNumber(), "R" + order.getOrderNumber(), expressAmount.doubleValue(), "/order/order/refundExpressPayMoneyCallback"); @@ -663,6 +673,7 @@ order.setRefundTime(LocalDateTime.now()); shopPointClient.deleteShopPointCopy(order.getId(), Arrays.asList(1,2,3)); + shopBalanceStatementClient.deleteShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)); appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); return R.ok(); @@ -811,6 +822,7 @@ Long days = jsonObject.getLong("days"); order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); this.updateById(order); + commissionService.calculationCommissionShop(order.getId()); return R.ok(); } @@ -985,18 +997,33 @@ for (int i = 1; i <= lastRowNum; i++) { Row row = sheet.getRow(i); // 订单编号 + if (row.getCell(0) == null){ + throw new ServiceException("第" + i + "行订单编号为空", 500); + } row.getCell(0).setCellType(CellType.STRING); String orderNum = row.getCell(0).getStringCellValue(); // 快递单号 + if (row.getCell(1) == null){ + throw new ServiceException("第" + i + "行快递单号为空", 500); + } row.getCell(1).setCellType(CellType.STRING); String expressNum = row.getCell(1).getStringCellValue(); // 快递公司名称 + if (row.getCell(2) == null){ + throw new ServiceException("第" + i + "行快递公司为空", 500); + } row.getCell(2).setCellType(CellType.STRING); String expressName = row.getCell(2).getStringCellValue(); // 省区划代码 + if (row.getCell(3) == null){ + throw new ServiceException("第" + i + "行省区划代码为空", 500); + } row.getCell(3).setCellType(CellType.STRING); String provinceCode = row.getCell(3).getStringCellValue(); // 市区划代码 + if (row.getCell(4) == null){ + throw new ServiceException("第" + i + "行市区划代码为空", 500); + } row.getCell(4).setCellType(CellType.STRING); String cityCode = row.getCell(4).getStringCellValue(); Order order = this.getOne(new LambdaQueryWrapper<Order>() @@ -1096,10 +1123,14 @@ userAddress.getProvince() + userAddress.getCity()); order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); this.updateById(order); + + // 发布事件 + applicationEventPublisher.publishEvent(new ConfirmDeliveryEvent(order.getId())); return R.ok(); } + public static void importExpress2(String filePath) throws MalformedURLException { // 从网络地址读取 URL url = new URL(filePath); -- Gitblit v1.7.1