|
@@ -1,18 +1,50 @@
|
|
package com.fdkankan.pay.controller;
|
|
package com.fdkankan.pay.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.fdkankan.pay.common.ResultCode;
|
|
import com.fdkankan.pay.common.ResultData;
|
|
import com.fdkankan.pay.common.ResultData;
|
|
import com.fdkankan.pay.entity.Order;
|
|
import com.fdkankan.pay.entity.Order;
|
|
|
|
+import com.fdkankan.pay.entity.WxConfig;
|
|
|
|
+import com.fdkankan.pay.exception.BusinessException;
|
|
|
|
+import com.fdkankan.pay.httpClient.client.WxClient;
|
|
|
|
+import com.fdkankan.pay.service.IOrderService;
|
|
|
|
+import com.fdkankan.pay.service.IWxConfigService;
|
|
import com.fdkankan.pay.service.impl.PayOrderService;
|
|
import com.fdkankan.pay.service.impl.PayOrderService;
|
|
import com.fdkankan.pay.util.UrlUtils;
|
|
import com.fdkankan.pay.util.UrlUtils;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/service/pay")
|
|
@RequestMapping("/service/pay")
|
|
|
|
+@Slf4j
|
|
public class PayController extends BaseController {
|
|
public class PayController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
PayOrderService payOrderService;
|
|
PayOrderService payOrderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ WxClient wxClient;
|
|
|
|
+ @Autowired
|
|
|
|
+ IOrderService orderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ IWxConfigService wxConfigService;
|
|
|
|
+
|
|
|
|
+ @GetMapping("/wxLogin")
|
|
|
|
+ public ResultData wxLogin(@RequestParam(required = false) String code,@RequestParam(required = false) String orderSn){
|
|
|
|
+ log.info("wx-login----orderSn:{},code:{}",orderSn,code);
|
|
|
|
+ Order order = orderService.getByOrderSn(orderSn);
|
|
|
|
+ if(order == null ){
|
|
|
|
+ throw new BusinessException(ResultCode.ORDER_NOT_EXIST);
|
|
|
|
+ }
|
|
|
|
+ WxConfig wxConfig = wxConfigService.getByServeId(order.getServeId());
|
|
|
|
+ if(wxConfig == null){
|
|
|
|
+ throw new BusinessException(ResultCode.WX_CONFIG_NOT);
|
|
|
|
+ }
|
|
|
|
+ JSONObject object = wxClient.getToken(wxConfig.getAppid(), wxConfig.getSecret(), code);
|
|
|
|
+ return ResultData.ok(object);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
@PostMapping(value = "/openPay")
|
|
@PostMapping(value = "/openPay")
|
|
public ResultData openPay(@RequestBody Order param) throws Exception {
|
|
public ResultData openPay(@RequestBody Order param) throws Exception {
|