加入积分系统,将充值与积分关联

This commit is contained in:
2024-03-06 20:56:22 +08:00
parent ee96759832
commit e84d800ba0
16 changed files with 234 additions and 34 deletions

View File

@@ -21,12 +21,12 @@ public class AliPayController {
private AliPayService aliPayService;
@ApiOperation("统一收单下单并支付页面接口的调用")
@PostMapping("/trade/page/pay/{productId}")
public Response<String> tradePagePay(@PathVariable Long productId,@RequestParam String returnUrl){
@PostMapping("/trade/page/pay/{amount}")
public Response<String> tradePagePay(@PathVariable Integer amount, @RequestParam String returnUrl){
log.info("统一收单下单并支付页面接口的调用");
//支付宝开放平台接受 request 请求对象后
// 会为开发者生成一个html 形式的 form表单包含自动提交的脚本
String formStr = aliPayService.tradeCreate(productId, returnUrl);
String formStr = aliPayService.tradeCreate(amount, returnUrl);
//我们将form表单字符串返回给前端程序之后前端将会调用自动提交脚本进行表单的提交
//此时表单会自动提交到action属性所指向的支付宝开放平台中从而为用户展示一个支付页面
return Response.success(formStr);

View File

@@ -0,0 +1,28 @@
package com.ai.da.controller;
import com.ai.da.common.response.Response;
import com.ai.da.service.CreditsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@CrossOrigin
@RestController
@RequestMapping("/api/credits")
@Api(tags = "积分")
@Slf4j
public class CreditsController {
@Resource
private CreditsService creditsService;
@ApiOperation("获取积分")
@GetMapping("/getCredits")
public Response<String> getCredits(){
String credits = creditsService.getCredits();
return Response.success(credits);
}
}

View File

@@ -30,9 +30,9 @@ public class PayPalCheckoutController {
private CallBackService callBackService;
@ApiOperation(value = "创建订单")
@PostMapping(value = "/trade/{productId}")
public Response<HashMap<String, String>> createOrder(@PathVariable Long productId,@RequestParam String returnUrl) throws SerializeException {
HashMap<String, String> approvalUrl = payPalCheckoutService.createOrder(productId,returnUrl);
@PostMapping(value = "/trade/{amount}")
public Response<HashMap<String, String>> createOrder(@PathVariable Integer amount, @RequestParam String returnUrl) throws SerializeException {
HashMap<String, String> approvalUrl = payPalCheckoutService.createOrder(amount,returnUrl);
return Response.success(approvalUrl);
}
@@ -41,7 +41,7 @@ public class PayPalCheckoutController {
public Response<String> callback(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Boolean result = callBackService.doGet(request, response);
if (result){
return Response.success();
return Response.success(200,"success");
}else {
return Response.fail(500,"failure");
}