luofl
2025-03-14 0449a6264819bce3869f47b9e5bd3729f158db54
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -9,6 +9,7 @@
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;
@@ -183,9 +184,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 +209,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 +247,7 @@
        }
        return orderDetailVO;
    }
    @Override
    public boolean check(Order order, Integer shopId, Long userId) {
@@ -499,7 +501,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 +597,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 +665,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 +814,7 @@
        Long days = jsonObject.getLong("days");
        order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
        this.updateById(order);
        commissionService.calculationCommissionShop(order.getId());
        return R.ok();
    }
@@ -985,18 +989,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,9 +1115,38 @@
                userAddress.getProvince() + userAddress.getCity());
        order.setExpressResult(JSON.toJSONString(mapTrackKD100Vo));
        this.updateById(order);
        String s = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxdeed472c98e42a54&secret=c89c697c981452480e0781fb82d4284c");
        JSONObject jsonObject2 = JSONObject.parseObject(s);
        System.out.println(jsonObject.getString("access_token"));
        return R.ok();
    }
    public static void main(String[] args) {
        String a = "{\n" +
                "  \"access_token\": \"90_4PJ8b5aLJa2M7aCtoskALEzfoap1me291Jc3ogi18NGH0Ts-Tol7K3COLLvkQ1JLcouvew11ORqcHf6mH5LA2KSC08NxiDhsjRPKuRh14mpvQRHmeFvwr-wKWjkANLdACAUHF\",\n" +
                "  \"order_key\": {\n" +
                "    \"order_number_type\": 1\n" +
                "  },\n" +
                "  \"logistics_type\": 1,\n" +
                "  \"delivery_mode\": 1,\n" +
                "  \"shipping_list\": [\n" +
                "    {\n" +
                "      \"item_desc\": \"这是一个测试\"\n" +
                "    }\n" +
                "  ],\n" +
                "  \"upload_time\": \"2022-12-15T13:29:35.120+08:00\",\n" +
                "  \"payer\": {\n" +
                "    \"openid\": \"ooOrs63KYDHcyhnUmTFpprHc6sb4\"\n" +
                "  }\n" +
                "}";
        JSONObject jsonObject = JSONObject.parseObject(a);
        System.out.println(jsonObject);
    }
    public static void importExpress2(String filePath) throws MalformedURLException {
        // 从网络地址读取