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);
|
}
|
|
/**
|
* 司机端充值余额 微信回调
|
*/
|
@ResponseBody
|
@PostMapping("/wechat/notify")
|
public Map<String,Object> wechatNotify(HttpServletRequest request) {
|
try {
|
return payService.wechatNotify(request);
|
} catch (Exception e) {
|
log.error("司机余额充值-微信回调异常:", e);
|
}
|
return null;
|
}
|
}
|