Browse Source

退货快递信息处理

fubojin 18 hours ago
parent
commit
1c54b88e70

+ 18 - 5
yami-shop-api/src/main/java/com/yami/shop/api/controller/PayController.java

@@ -10,6 +10,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
 import com.yami.shop.bean.app.param.PayParam;
 import com.yami.shop.bean.model.Order;
+import com.yami.shop.bean.model.OrderSettlement;
 import com.yami.shop.bean.model.RefundDelivery;
 import com.yami.shop.bean.pay.PayInfoDto;
 import com.yami.shop.common.util.Arith;
@@ -17,6 +18,7 @@ import com.yami.shop.common.util.IPHelper;
 import com.yami.shop.security.api.model.YamiUser;
 import com.yami.shop.security.api.util.SecurityUtils;
 import com.yami.shop.service.OrderService;
+import com.yami.shop.service.OrderSettlementService;
 import com.yami.shop.service.PayService;
 import com.yami.shop.service.RefundDeliveryService;
 import com.yami.shop.wx.config.WechatPayServiceConfig;
@@ -36,22 +38,33 @@ import javax.validation.Valid;
 
 @RestController
 @RequestMapping("/p/order")
-@Api(tags = "订单接口")
+@Api(tags = "订单接口(测试退款)")
 @AllArgsConstructor
 public class PayController {
 
     private final PayService payService;
     private final OrderService orderService;
     private final RefundDeliveryService refundDeliveryService;
+    private final OrderSettlementService orderSettlementService;
     private final WxProviderService wxProviderService;
     private final String baseNotifyUrl ="https://shop.api.zswlgz.com";
 
 
-    @SneakyThrows
-    @PostMapping("/refund")
+    @GetMapping("/orderNumber")
     @ApiOperation(value = "测试退款")
-    public ResponseEntity<?> refund(@RequestBody RefundInfoPo refundInfo) {
-        return ResponseEntity.ok(wxProviderService.refundOrder(refundInfo));
+    public ResponseEntity<?> refund(@RequestParam String orderNumber) {
+        Order order = orderService.getOrderByOrderNumber(orderNumber);
+        OrderSettlement one = orderSettlementService.getOne(new LambdaQueryWrapper<OrderSettlement>().eq(OrderSettlement::getOrderNumber, orderNumber));
+
+        if (order.getActualTotal() == null || Math.abs(order.getActualTotal()) < 0.000001) {
+            return ResponseEntity.ok("该订单支付金额为0, 无法退款!");
+        }
+
+        RefundInfoPo refundInfoPo = new RefundInfoPo();
+        refundInfoPo.setOutTradeNo(one.getPayNo());
+        refundInfoPo.setTotal((int)(order.getActualTotal()*100));
+        refundInfoPo.setRefundMoney((int)(order.getActualTotal()*100));
+        return ResponseEntity.ok(wxProviderService.refundOrder(refundInfoPo));
     }
 
 

+ 2 - 10
yami-shop-api/src/main/java/com/yami/shop/api/controller/RefundDeliveryController.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.model.RefundDelivery;
 import com.yami.shop.common.util.PageParam;
-import com.yami.shop.security.api.util.SecurityUtils;
 import com.yami.shop.service.RefundDeliveryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -13,7 +12,6 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
-import java.util.Objects;
 
 /**
  * 退货物流信息接口
@@ -76,10 +74,7 @@ public class RefundDeliveryController {
         if (dbRefundDelivery == null) {
             return ResponseEntity.badRequest().body("退货物流信息不存在");
         }
-        // 确保用户只能更新自己的退货物流信息
-        if (!Objects.equals(dbRefundDelivery.getUserId(), SecurityUtils.getUser().getUserId())) {
-            return ResponseEntity.badRequest().body("无权限操作");
-        }
+
         refundDeliveryService.updateById(refundDelivery);
         return ResponseEntity.ok("更新成功");
     }
@@ -95,10 +90,7 @@ public class RefundDeliveryController {
         if (refundDelivery == null) {
             return ResponseEntity.badRequest().body("退货物流信息不存在");
         }
-        // 确保用户只能删除自己的退货物流信息
-        if (!Objects.equals(refundDelivery.getUserId(), SecurityUtils.getUser().getUserId())) {
-            return ResponseEntity.badRequest().body("无权限操作");
-        }
+
         refundDeliveryService.removeById(id);
         return ResponseEntity.ok("删除成功");
     }

+ 1 - 1
yami-shop-security/yami-shop-security-api/src/main/java/com/yami/shop/security/api/config/ResourceServerConfiguration.java

@@ -48,7 +48,7 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
                 .authorizeRequests()
                 .antMatchers(
                         "/p/delivery/getDeliveryList",
-                        "/p/order/refund"
+                        "/p/order/orderNumber"
                         ).permitAll()
                 .and()