| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package com.izouma.nineth.web;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.izouma.nineth.service.SandPayService;
- import com.izouma.nineth.utils.SnowflakeIdWorker;
- import lombok.AllArgsConstructor;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import java.math.BigDecimal;
- import java.time.LocalDateTime;
- @RestController
- @RequestMapping("/sandPayTest")
- @AllArgsConstructor
- public class SandPayTestController {
- private final SandPayService sandPayService;
- private final SnowflakeIdWorker snowflakeIdWorker;
- @GetMapping(value = "/pay", produces = "text/html")
- private String testpay() {
- JSONObject extend = new JSONObject();
- extend.put("type", "test");
- extend.put("id", 1);
- JSONObject res = sandPayService.requestAlipay(snowflakeIdWorker.nextId() + "", new BigDecimal("0.01"),
- "话费充值", "话费充值", 180, extend.toJSONString());
- String qrCode = res.getJSONObject("body").getString("qrCode");
- return "<html><body><a style=\"font-size:28px;\" href=\"" + qrCode + "\">" + qrCode + "</a></body></html>";
- }
- @GetMapping(value = "/transfer")
- private String testTransfer(@RequestParam String name, @RequestParam String bank, @RequestParam BigDecimal amount) {
- return JSON.toJSONString(sandPayService.transfer(snowflakeIdWorker.nextId() + "", name, bank, amount), true);
- }
- @GetMapping(value = "/refund")
- public String refund(@RequestParam String orderId, @RequestParam BigDecimal amount) {
- return JSON.toJSONString(sandPayService.refund(orderId, amount), true);
- }
- }
|