|  | @@ -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));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 |