|
@@ -13,21 +13,19 @@ import com.yami.shop.security.api.util.SecurityUtils;
|
|
import com.yami.shop.service.*;
|
|
import com.yami.shop.service.*;
|
|
import com.yami.shop.wx.po.JsapiPayInfoPo;
|
|
import com.yami.shop.wx.po.JsapiPayInfoPo;
|
|
import com.yami.shop.wx.service.WxProviderService;
|
|
import com.yami.shop.wx.service.WxProviderService;
|
|
|
|
+import com.yami.shop.wx.utils.CullenUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
-@RequestMapping("/order")
|
|
|
|
-//@RequestMapping("/p/order")
|
|
|
|
|
|
+@RequestMapping("/p/order")
|
|
@Api(tags = "订单接口")
|
|
@Api(tags = "订单接口")
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class PayController {
|
|
public class PayController {
|
|
@@ -37,7 +35,6 @@ public class PayController {
|
|
private final OrderService orderService;
|
|
private final OrderService orderService;
|
|
private final OrderRefundService orderRefundService;
|
|
private final OrderRefundService orderRefundService;
|
|
private final RefundDeliveryService refundDeliveryService;
|
|
private final RefundDeliveryService refundDeliveryService;
|
|
- @Autowired
|
|
|
|
private final WxProviderService wxProviderService;
|
|
private final WxProviderService wxProviderService;
|
|
|
|
|
|
|
|
|
|
@@ -59,16 +56,13 @@ public class PayController {
|
|
return ResponseEntity.ok().build();
|
|
return ResponseEntity.ok().build();
|
|
}
|
|
}
|
|
|
|
|
|
- if (payInfo.getPayAmount() < 0.01) {
|
|
|
|
- throw new GlobalException("订单金额有误,无法进行支付");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ CullenUtils.validateDataThrowException(payInfo.getPayAmount() < 0.01, "订单金额有误,无法进行支付");
|
|
JsapiPayInfoPo po = new JsapiPayInfoPo();
|
|
JsapiPayInfoPo po = new JsapiPayInfoPo();
|
|
po.setDescription(payInfo.getBody());
|
|
po.setDescription(payInfo.getBody());
|
|
po.setTotal((int) Arith.mul(payInfo.getPayAmount(), 100));
|
|
po.setTotal((int) Arith.mul(payInfo.getPayAmount(), 100));
|
|
po.setOpenId(user.getBizUserId());
|
|
po.setOpenId(user.getBizUserId());
|
|
po.setOutTradeNo(payInfo.getPayNo());
|
|
po.setOutTradeNo(payInfo.getPayNo());
|
|
- po.setNotifyUrl("http://localhost:8112/notice/pay/order/" + payParam.getPayType());
|
|
|
|
|
|
+ po.setNotifyUrl(getNotifyUrl("http://localhost:8112"));
|
|
return ResponseEntity.ok(wxProviderService.subJsapi(po));
|
|
return ResponseEntity.ok(wxProviderService.subJsapi(po));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -84,26 +78,18 @@ public class PayController {
|
|
|
|
|
|
RefundDelivery refundDelivery = refundDeliveryService.getOne(new LambdaQueryWrapper<RefundDelivery>()
|
|
RefundDelivery refundDelivery = refundDeliveryService.getOne(new LambdaQueryWrapper<RefundDelivery>()
|
|
.eq(RefundDelivery::getRefundSn, payParam.getOrderNumbers()));
|
|
.eq(RefundDelivery::getRefundSn, payParam.getOrderNumbers()));
|
|
- if (refundDelivery.getPayer().equals("1")) {
|
|
|
|
- throw new GlobalException("无需支付");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- PayInfoDto payInfoDto = new PayInfoDto();
|
|
|
|
- payInfoDto.setBody("退货配送费");
|
|
|
|
- payInfoDto.setPayAmount(refundDelivery.getPrice());
|
|
|
|
- payInfoDto.setPayNo("refundSn" + payParam.getOrderNumbers());
|
|
|
|
- payInfoDto.setIsScore(0);
|
|
|
|
-
|
|
|
|
- payInfoDto.setBizUserId(user.getBizUserId());
|
|
|
|
- payInfoDto.setPayType(payParam.getPayType());
|
|
|
|
- payInfoDto.setApiNoticeUrl("/notice/pay/order/" + payParam.getPayType());
|
|
|
|
- payInfoDto.setReturnUrl(payParam.getReturnUrl());
|
|
|
|
-
|
|
|
|
|
|
|
|
- return payManagerService.doPay(httpResponse, payInfoDto);
|
|
|
|
|
|
+ CullenUtils.validateDataThrowException(refundDelivery.getPayer().equals("1"), "无需支付");
|
|
|
|
+ CullenUtils.validateDataThrowException(refundDelivery.getPrice() < 0.01, "订单金额有误,无法进行支付");
|
|
|
|
+ JsapiPayInfoPo po = new JsapiPayInfoPo();
|
|
|
|
+ po.setDescription("退货配送费");
|
|
|
|
+ po.setTotal((int) Arith.mul(refundDelivery.getPrice(), 100));
|
|
|
|
+ po.setOpenId(user.getBizUserId());
|
|
|
|
+ po.setOutTradeNo("refundSn" + payParam.getOrderNumbers());
|
|
|
|
+ po.setNotifyUrl(getNotifyUrl("http://localhost:8112"));
|
|
|
|
+ return ResponseEntity.ok(wxProviderService.subJsapi(po));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@GetMapping("/isPay/{orderNumbers}")
|
|
@GetMapping("/isPay/{orderNumbers}")
|
|
@ApiOperation(value = "根据订单号查询该订单是否已经支付", notes = "根据订单号查询该订单是否已经支付")
|
|
@ApiOperation(value = "根据订单号查询该订单是否已经支付", notes = "根据订单号查询该订单是否已经支付")
|
|
public ResponseEntity<Boolean> isPay(@PathVariable String orderNumbers) {
|
|
public ResponseEntity<Boolean> isPay(@PathVariable String orderNumbers) {
|
|
@@ -115,4 +101,8 @@ public class PayController {
|
|
int count = orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, orderNumber).eq(Order::getUserId, userId).eq(Order::getIsPayed, 1));
|
|
int count = orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getOrderNumber, orderNumber).eq(Order::getUserId, userId).eq(Order::getIsPayed, 1));
|
|
return ResponseEntity.ok(count > 0);
|
|
return ResponseEntity.ok(count > 0);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private static String getNotifyUrl(String uri) {
|
|
|
|
+ return uri.concat("/notice/pay/order/wxNotify");
|
|
|
|
+ }
|
|
}
|
|
}
|