puzhibing
2025-01-07 eb5d7885fa9e4bd20c0827eec9b4cdd48c47b509
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -16,6 +16,7 @@
import com.ruoyi.order.model.Order;
import com.ruoyi.order.service.CommissionService;
import com.ruoyi.order.service.OrderService;
import com.ruoyi.order.util.payment.model.RefundCallbackResult;
import com.ruoyi.order.vo.*;
import com.ruoyi.other.api.domain.BaseSetting;
import com.ruoyi.other.api.feignClient.BaseSettingClient;
@@ -25,7 +26,10 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -147,13 +151,6 @@
    })
    @GetMapping("/confirm/{orderId}")
    public R<Void> confirm(@PathVariable("orderId") Long orderId){
        boolean update = orderService.update(new LambdaUpdateWrapper<Order>()
                .eq(Order::getId, orderId)
                .eq(Order::getOrderStatus, OrderStatus.PENDING_RECEIPT.getCode())
                .set(Order::getOrderStatus, OrderStatus.COMPLETED.getCode()));
        if(!update){
            return R.fail("订单状态异常");
        }
        R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5);
        if (R.isError(baseSettingR)) {
            return R.fail("售后设置获取失败");
@@ -165,7 +162,11 @@
        String content = baseSetting.getContent();
        JSONObject jsonObject = JSONObject.parseObject(content);
        Long days = jsonObject.getLong("days");
        commissionService.addToCommissionDelayQueue(orderId, LocalDateTime.now().plusDays(days));
        Order order = orderService.getById(orderId);
        order.setAfterSaleTime(LocalDateTime.now().plusDays(days));
        order.setIsCommission(0);
        order.setOrderStatus(OrderStatus.COMPLETED.getCode());
        orderService.updateById(order);
        return R.ok();
    }
@@ -321,5 +322,53 @@
    }
    /**
     * 订单取消支付回退
     * @param refundCallbackResult
     * @param response
     * @return
     */
    @ResponseBody
    @GetMapping("/refundPayMoneyCallback")
    public void refundPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){
        R callback = orderService.refundPayMoneyCallback(refundCallbackResult);
        if(callback.getCode() == 200){
            response.setStatus(200);
            PrintWriter out = null;
            try {
                out = response.getWriter();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            out.println("success");
            out.flush();
            out.close();
        }
    }
    /**
     * 取消订单快递费回退
     * @param refundCallbackResult
     * @param response
     */
    @ResponseBody
    @GetMapping("/refundExpressPayMoneyCallback")
    public void refundExpressPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response){
        R callback = orderService.refundExpressPayMoneyCallback(refundCallbackResult);
        if(callback.getCode() == 200){
            response.setStatus(200);
            PrintWriter out = null;
            try {
                out = response.getWriter();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            out.println("success");
            out.flush();
            out.close();
        }
    }
}