|
@@ -1,10 +1,5 @@
|
|
|
package com.chelvc.cloud.maintain.controller;
|
|
|
|
|
|
-import java.util.Map;
|
|
|
-import javax.validation.Valid;
|
|
|
-import javax.validation.constraints.Min;
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
-
|
|
|
import com.chelvc.cloud.vehicle.client.OmsOrderClient;
|
|
|
import com.chelvc.cloud.vehicle.client.OmsOrderReturnApplyClient;
|
|
|
import com.chelvc.cloud.vehicle.client.dto.ConfirmOrderResultDTO;
|
|
@@ -15,14 +10,21 @@ import com.chelvc.cloud.vehicle.client.param.OmsOrderModifyParam;
|
|
|
import com.chelvc.cloud.vehicle.client.param.OrderPagingParam;
|
|
|
import com.chelvc.framework.base.annotation.ResponseWrapping;
|
|
|
import com.chelvc.framework.common.model.Pagination;
|
|
|
+import com.chelvc.framework.wechat.WechatPaymentCallback;
|
|
|
+import com.chelvc.framework.wechat.WechatPaymentHandler;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 订单接口
|
|
@@ -38,6 +40,9 @@ public class OmsOrderController {
|
|
|
private final OmsOrderClient omsOrderClient;
|
|
|
private final OmsOrderReturnApplyClient omsOrderReturnApplyClient;
|
|
|
|
|
|
+ private final WechatPaymentHandler wechatPaymentHandler;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 根据购物车信息生成确认单信息
|
|
|
*
|
|
@@ -104,14 +109,28 @@ public class OmsOrderController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 支付成功回调
|
|
|
+ * 微信支付回调
|
|
|
*
|
|
|
- * @param id 查询参数
|
|
|
+ * @param name 查询参数
|
|
|
*/
|
|
|
- @GetMapping("/paySuccess/{id}")
|
|
|
- public void paySuccess(@PathVariable("id") @Min(value = 1, message = "商家ID不能小于1") Long id,
|
|
|
- Integer payType) {
|
|
|
- this.omsOrderClient.paySuccess(id, payType);
|
|
|
+ @PostMapping("/order/{name}/callback")
|
|
|
+ public void paySuccess(@PathVariable("name") String name,
|
|
|
+ @RequestBody String body, HttpServletResponse response) throws IOException {
|
|
|
+ //获取支付回调信息
|
|
|
+ WechatPaymentCallback callback = this.wechatPaymentHandler.callback(name, body);
|
|
|
+ if(callback == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer result = this.omsOrderClient.paySuccess(Long.valueOf(callback.getOrder()), 2);
|
|
|
+ if(result != 1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //返回成功报文
|
|
|
+ if(Objects.nonNull(callback.getResponse())){
|
|
|
+ try (OutputStream stream = response.getOutputStream()){
|
|
|
+ stream.write(callback.getResponse().getBytes());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|