yanderong
2026-06-09 b19474186df25762866bd9323c3f3ac8be4de9b9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.stylefeng.guns.modular.api;
 
import com.alibaba.fastjson.JSON;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IPayService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.vo.WxPayAppVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Objects;
 
/**
 * 支付控制器
 *
 * @author Lux
 * @version 1.0.0
 * @since 2026/6/3 14:49
 */
@Slf4j
@Controller
@RequestMapping("/api/pay")
@Api(tags = "龙江易支付")
@RequiredArgsConstructor
public class PayController {
 
    private final IPayService payService;
    private final IDriverService driverService;
 
    @ResponseBody
    @PostMapping("/wechat/recharge")
    @ApiOperation(value = "微信充值操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "充值金额", name = "money", required = true, dataType = "double"),
 
    })
    public ResultUtil wechatRecharge(BigDecimal money, HttpServletRequest request) throws Exception {
        Integer uid = driverService.getUserIdFormRedis(request);
        log.info("司机【{}】-微信充值【{}】-下单开始", uid, money);
        if (Objects.isNull(uid)) {
            return ResultUtil.tokenErr();
        }
        if(Objects.isNull(money)) {
            return ResultUtil.paranErr("充值金额不能为空");
        }
        WxPayAppVO wxPayAppVO = payService.wechatRecharge(uid, money);
        log.info("司机【{}】-微信充值-开下结束,返回前端数据为:{}", uid, JSON.toJSONString(wxPayAppVO));
        return ResultUtil.success(wxPayAppVO);
    }
}