|
@@ -2,12 +2,17 @@ package com.yonge.cooleshow.student.controller;
|
|
|
|
|
|
import com.huifu.adapay.core.AdapayCore;
|
|
|
import com.huifu.adapay.core.util.AdapaySign;
|
|
|
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.sdk.PaymentSdk;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.EmployeeService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.UserOrderService;
|
|
|
+import com.yonge.cooleshow.common.controller.BaseController;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -20,17 +25,15 @@ import java.util.Map;
|
|
|
@RestController
|
|
|
@RequestMapping("/payment")
|
|
|
@Api(value = "付款接口", tags = "付款接口")
|
|
|
-public class PaymentController {
|
|
|
+public class PaymentController extends BaseController {
|
|
|
@Autowired
|
|
|
private PaymentSdk paymentSdk;
|
|
|
@Autowired
|
|
|
private UserOrderService userOrderService;
|
|
|
-
|
|
|
-/* @ApiOperation(value = "订单付款")
|
|
|
- @PostMapping("/orderPay")
|
|
|
- public HttpResponseResult<Map<String, Object>> orderPay(@RequestBody PaymentReq param) {
|
|
|
- return HttpResponseResult.succeed(paymentSdk.executePayment(param));
|
|
|
- }*/
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ @Autowired
|
|
|
+ private EmployeeService employeeService;
|
|
|
|
|
|
@ApiOperation(value = "查询付款单")
|
|
|
@GetMapping("/queryPayment")
|
|
@@ -40,8 +43,19 @@ public class PaymentController {
|
|
|
|
|
|
@ApiOperation(value = "微信支付获取openid")
|
|
|
@GetMapping("/getOpenId")
|
|
|
- public HttpResponseResult<Map<String, Object>> getOpenId(String js_code) {
|
|
|
- return paymentSdk.getOpenId(js_code);
|
|
|
+ public HttpResponseResult<Map<String, String>> getOpenId(String js_code) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
+ if (user == null || null == user.getId()) {
|
|
|
+ return failed(HttpStatus.FORBIDDEN, "请登录");
|
|
|
+ }
|
|
|
+ HttpResponseResult<Map<String, String>> responseResult = paymentSdk.getOpenId(js_code);
|
|
|
+ if(responseResult.getStatus()){
|
|
|
+ Map<String, String> data = responseResult.getData();
|
|
|
+ //绑定到用户表
|
|
|
+ user.setWechatId(data.get("openid"));
|
|
|
+ sysUserFeignService.bindOpenId(user);
|
|
|
+ }
|
|
|
+ return responseResult;
|
|
|
}
|
|
|
|
|
|
/***
|