Files
DpsManagerServer/旧的java项目/src/main/java/com/example/sjkbf/controller/ZfController.java
2026-04-15 15:19:28 +08:00

74 lines
2.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.example.sjkbf.controller;
import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.example.sjkbf.config.Configuration.CurrentUserId;
import com.example.sjkbf.entity.CommonResult;
import com.example.sjkbf.service.UserOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.Map;
@RestController()
@RequestMapping("/zf")
public class ZfController {
String payKey = "8658ea66fbbe4a1aad4691ddecefe5fa";
String payUrl = "https://2277883.pay.lanjingzf.com/createOrder?";
@Autowired
private UserOrderService service;
/**
*
* @param payId 商户订单号
* @param param 创建订单的时候传入的参数
* @param type 支付方式 微信支付为1 支付宝支付为2
* @param price 订单金额
* @param reallyPrice 实际支付金额
* @param sign 校验签名,计算方式 = md5(payId + param + type + price + reallyPrice + 通讯密钥)
*/
@RequestMapping("callback")
public String callback(@RequestParam String payId,@RequestParam String param,@RequestParam Integer type, @RequestParam Float price,@RequestParam Float reallyPrice,@RequestParam String sign){
System.out.println(payId);
System.out.println(param);
System.out.println(type);
System.out.println(price);
System.out.println(reallyPrice);
System.out.println(sign);
return service.callback(payId, param, type, price, reallyPrice, sign);
}
@RequestMapping("create")
public ResponseEntity<CommonResult<String>> create(@RequestBody Map<String,Integer> body, @CurrentUserId String userName) throws IOException {
String s = service.create(body.get("type"), body.get("price"), userName);
return ResponseEntity.ok( CommonResult.success(s));
}
public static void main(String[] args) throws InterruptedException, IOException {
UserOrderService service = new UserOrderService();
String s = service.create(1, 1, "123");
System.out.println(s);
}
}