题目修改
parent
32ab1db4a9
commit
aeae6d9d8e
|
@ -47,4 +47,7 @@ public class Constants {
|
||||||
//字典表题目分类标识
|
//字典表题目分类标识
|
||||||
public static String QUESTION_CATEGORY = "QusetionCategory";
|
public static String QUESTION_CATEGORY = "QusetionCategory";
|
||||||
|
|
||||||
|
//微信支付
|
||||||
|
public static String WECHAT_PAY = "weChatPay";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.jwl.driver.server.controller;
|
package com.jwl.driver.server.controller;
|
||||||
|
|
||||||
import com.jwl.driver.server.config.WechatPayConfig;
|
import com.jwl.driver.server.config.WechatPayConfig;
|
||||||
|
import com.jwl.driver.server.entity.OrderPayInfo;
|
||||||
import com.jwl.driver.server.response.BaseResponse;
|
import com.jwl.driver.server.response.BaseResponse;
|
||||||
|
import com.jwl.driver.server.service.IOrderPayInfoService;
|
||||||
import com.jwl.driver.server.vo.H5PayVo;
|
import com.jwl.driver.server.vo.H5PayVo;
|
||||||
import com.wechat.pay.java.core.Config;
|
import com.wechat.pay.java.core.Config;
|
||||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||||
|
@ -12,12 +14,15 @@ import com.wechat.pay.java.service.payments.model.Transaction;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付小程序 接口
|
* 微信支付小程序 接口
|
||||||
|
@ -31,23 +36,28 @@ public class H5PayController {
|
||||||
@Resource
|
@Resource
|
||||||
private WechatPayConfig wechatPayConfig;
|
private WechatPayConfig wechatPayConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOrderPayInfoService orderPayInfoService;
|
||||||
|
|
||||||
//生成预支付订单
|
//生成预支付订单
|
||||||
@ApiOperation("生成预支付订单")
|
@ApiOperation("生成预支付订单")
|
||||||
@PostMapping("/prepay")
|
@PostMapping("/prepay")
|
||||||
public BaseResponse createPrepay(@RequestBody H5PayVo payVo){
|
public BaseResponse createPrepay(@RequestBody H5PayVo payVo){
|
||||||
// 构建service
|
// 构建service
|
||||||
H5Service service = createService();
|
H5Service service = createService();
|
||||||
|
//在order_pay_info里新增一条数据
|
||||||
|
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payVo);
|
||||||
|
|
||||||
// 请求下单参数
|
// 请求下单参数
|
||||||
PrepayRequest request = new PrepayRequest();
|
PrepayRequest request = new PrepayRequest();
|
||||||
Amount amount = new Amount();
|
Amount amount = new Amount();
|
||||||
amount.setTotal(Integer.valueOf((payVo.getMoney()*100)+""));
|
amount.setTotal(Integer.valueOf((payVo.getMoney().multiply(new BigDecimal("100")).setScale(0).toString())+""));
|
||||||
request.setAmount(amount);
|
request.setAmount(amount);
|
||||||
request.setAppid(wechatPayConfig.getAppId());
|
request.setAppid(wechatPayConfig.getAppId());
|
||||||
request.setMchid(wechatPayConfig.getMchId());
|
request.setMchid(wechatPayConfig.getMchId());
|
||||||
request.setDescription(payVo.getDescription());
|
request.setDescription(payVo.getDescription());
|
||||||
request.setNotifyUrl(wechatPayConfig.getPayNoticeUrl());
|
request.setNotifyUrl(wechatPayConfig.getPayNoticeUrl());
|
||||||
request.setOutTradeNo(payVo.getOutTradeNo());
|
request.setOutTradeNo(orderPayInfo.getPayId().toString());
|
||||||
//场景参数
|
//场景参数
|
||||||
SceneInfo sceneInfo = new SceneInfo();
|
SceneInfo sceneInfo = new SceneInfo();
|
||||||
sceneInfo.setPayerClientIp(payVo.getClientIp());
|
sceneInfo.setPayerClientIp(payVo.getClientIp());
|
||||||
|
@ -57,7 +67,6 @@ public class H5PayController {
|
||||||
// 使用微信扫描 code_url 对应的二维码,即可体验Native支付
|
// 使用微信扫描 code_url 对应的二维码,即可体验Native支付
|
||||||
// log.info(response);
|
// log.info(response);
|
||||||
return BaseResponse.success(response);
|
return BaseResponse.success(response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private H5Service createService() {
|
private H5Service createService() {
|
||||||
|
|
|
@ -4,12 +4,16 @@ package com.jwl.driver.server.controller;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jwl.driver.server.config.WechatPayConfig;
|
import com.jwl.driver.server.config.WechatPayConfig;
|
||||||
import com.jwl.driver.server.response.BaseResponse;
|
import com.jwl.driver.server.response.BaseResponse;
|
||||||
|
import com.jwl.driver.server.service.IOrderPayInfoService;
|
||||||
|
import com.jwl.driver.server.service.ITdMemberService;
|
||||||
|
import com.jwl.driver.server.service.ITdSysUserMemberService;
|
||||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||||
import com.wechat.pay.java.core.notification.NotificationConfig;
|
import com.wechat.pay.java.core.notification.NotificationConfig;
|
||||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||||
import com.wechat.pay.java.core.notification.RequestParam;
|
import com.wechat.pay.java.core.notification.RequestParam;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpRequest;
|
import org.springframework.http.HttpRequest;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
@ -36,6 +40,12 @@ public class PayNoticeLogController {
|
||||||
@Resource
|
@Resource
|
||||||
private WechatPayConfig wechatPayConfig;
|
private WechatPayConfig wechatPayConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITdSysUserMemberService userMemberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOrderPayInfoService payInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付回调接口 本接口不能做验证
|
* 支付回调接口 本接口不能做验证
|
||||||
* @param wechatPayCertificateSerialNumber
|
* @param wechatPayCertificateSerialNumber
|
||||||
|
@ -76,11 +86,19 @@ public class PayNoticeLogController {
|
||||||
System.out.println("decryptObject="+decryptObject.toJSONString());
|
System.out.println("decryptObject="+decryptObject.toJSONString());
|
||||||
|
|
||||||
String trade_state=decryptObject.getString("trade_state");
|
String trade_state=decryptObject.getString("trade_state");
|
||||||
|
//取业务id
|
||||||
|
String outTradeNo = decryptObject.getString("out_trade_no");
|
||||||
JSONObject jsonResponse = new JSONObject();
|
JSONObject jsonResponse = new JSONObject();
|
||||||
if(trade_state.equals("SUCCESS")) {
|
if(trade_state.equals("SUCCESS")) {
|
||||||
//各种业务逻辑
|
//各种业务逻辑
|
||||||
|
//1.订单详情表里修改数据
|
||||||
|
payInfoService.payNotice(Long.parseLong(outTradeNo),Boolean.FALSE);
|
||||||
|
//2.冲会员
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
//还是各种业务逻辑
|
//还是各种业务逻辑
|
||||||
|
//1.订单详情表里修改数据
|
||||||
|
payInfoService.payNotice(Long.parseLong(outTradeNo),Boolean.FALSE);
|
||||||
}
|
}
|
||||||
jsonResponse.put("code", "SUCCESS");
|
jsonResponse.put("code", "SUCCESS");
|
||||||
jsonResponse.put("message", "成功");
|
jsonResponse.put("message", "成功");
|
||||||
|
|
|
@ -4,6 +4,7 @@ package com.jwl.driver.server.controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -13,8 +14,9 @@ import org.springframework.stereotype.Controller;
|
||||||
* @author Automated procedures
|
* @author Automated procedures
|
||||||
* @since 2023-08-10
|
* @since 2023-08-10
|
||||||
*/
|
*/
|
||||||
@Controller
|
@RestController
|
||||||
@RequestMapping("//payPrepay")
|
@RequestMapping("/payPrepay")
|
||||||
public class PayPrepayController {
|
public class PayPrepayController {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.jwl.driver.server.enums;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹林
|
||||||
|
* @description 支付状态
|
||||||
|
* @create 2023/8/20 1:19
|
||||||
|
*/
|
||||||
|
public enum PayStatus {
|
||||||
|
NOT(1, "未支付"),
|
||||||
|
SUCCESS(2, "支付成功"),
|
||||||
|
FAIL(3, "支付失败");
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
|
private String name;
|
||||||
|
public static final Map<Integer, PayStatus> valueMap = new HashMap();
|
||||||
|
|
||||||
|
public static PayStatus fromValue(Integer value) {
|
||||||
|
return (PayStatus)valueMap.get(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PayStatus(Integer value, String name) {
|
||||||
|
this.value = value;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
PayStatus[] var0 = values();
|
||||||
|
int var1 = var0.length;
|
||||||
|
|
||||||
|
for(int var2 = 0; var2 < var1; ++var2) {
|
||||||
|
PayStatus value = var0[var2];
|
||||||
|
valueMap.put(value.getValue(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.jwl.driver.server.service;
|
||||||
|
|
||||||
import com.jwl.driver.server.entity.OrderPayInfo;
|
import com.jwl.driver.server.entity.OrderPayInfo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.jwl.driver.server.vo.H5PayVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -13,4 +14,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
*/
|
*/
|
||||||
public interface IOrderPayInfoService extends IService<OrderPayInfo> {
|
public interface IOrderPayInfoService extends IService<OrderPayInfo> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付创建预支付申请
|
||||||
|
* @param payVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderPayInfo createOrderPayInfo(H5PayVo payVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付结果
|
||||||
|
* @param payId
|
||||||
|
* @param payResult
|
||||||
|
*/
|
||||||
|
Boolean payNotice(Long payId, Boolean payResult);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,28 @@
|
||||||
package com.jwl.driver.server.service.impl;
|
package com.jwl.driver.server.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Snowflake;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.jwl.driver.server.constant.Constants;
|
||||||
import com.jwl.driver.server.entity.OrderPayInfo;
|
import com.jwl.driver.server.entity.OrderPayInfo;
|
||||||
|
import com.jwl.driver.server.entity.TdMember;
|
||||||
|
import com.jwl.driver.server.entity.TdSysUser;
|
||||||
|
import com.jwl.driver.server.enums.PayStatus;
|
||||||
|
import com.jwl.driver.server.exception.BusinessException;
|
||||||
import com.jwl.driver.server.mapper.OrderPayInfoMapper;
|
import com.jwl.driver.server.mapper.OrderPayInfoMapper;
|
||||||
import com.jwl.driver.server.service.IOrderPayInfoService;
|
import com.jwl.driver.server.service.IOrderPayInfoService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.jwl.driver.server.service.ITdMemberService;
|
||||||
|
import com.jwl.driver.server.service.ITdSysUserService;
|
||||||
|
import com.jwl.driver.server.util.SecurityUtil;
|
||||||
|
import com.jwl.driver.server.vo.H5PayVo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -15,6 +33,57 @@ import org.springframework.stereotype.Service;
|
||||||
* @since 2023-08-10
|
* @since 2023-08-10
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class OrderPayInfoServiceImpl extends ServiceImpl<OrderPayInfoMapper, OrderPayInfo> implements IOrderPayInfoService {
|
public class OrderPayInfoServiceImpl extends ServiceImpl<OrderPayInfoMapper, OrderPayInfo> implements IOrderPayInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITdSysUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITdMemberService memberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Snowflake snowflake;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderPayInfo createOrderPayInfo(H5PayVo payVo) {
|
||||||
|
Long userId = StrUtil.isNotBlank(payVo.getUserId()) ? Long.parseLong(payVo.getUserId()) : SecurityUtil.getUserId();
|
||||||
|
TdSysUser user = userService.getById(userId);
|
||||||
|
if (Objects.isNull(user)) {
|
||||||
|
log.error("数据异常,用户不存在" + userId);
|
||||||
|
throw new BusinessException("数据缺失");
|
||||||
|
}
|
||||||
|
TdMember member = memberService.getById(Integer.parseInt(payVo.getOutTradeNo()));
|
||||||
|
if (Objects.isNull(member) || StrUtil.equals(Constants.IS_ACTIVE_FALSE, member.getIsActive())) {
|
||||||
|
log.error("数据异常,会员不存在或者已过期" + payVo.getOutTradeNo());
|
||||||
|
throw new BusinessException("数据缺失");
|
||||||
|
}
|
||||||
|
OrderPayInfo orderPayInfo = new OrderPayInfo()
|
||||||
|
.setPayId(snowflake.nextId())
|
||||||
|
.setMemberId(Integer.parseInt(payVo.getOutTradeNo()))
|
||||||
|
.setMoney(payVo.getMoney())
|
||||||
|
.setPaymentType(Constants.WECHAT_PAY)
|
||||||
|
.setDescription(user.getUserName() + "-" + member.getMemberName())
|
||||||
|
.setPayStatus(PayStatus.NOT.getValue())
|
||||||
|
.setDeleteStatus(0)
|
||||||
|
.setUserId(userId)
|
||||||
|
.setCreateTime(LocalDateTime.now())
|
||||||
|
.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
this.save(orderPayInfo);
|
||||||
|
return orderPayInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean payNotice(Long payId, Boolean payResult) {
|
||||||
|
|
||||||
|
OrderPayInfo orderPayInfo = this.getById(payId);
|
||||||
|
if (Objects.isNull(orderPayInfo)){
|
||||||
|
throw new BusinessException("订单信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,13 @@ import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@ApiModel("H5支付")
|
@ApiModel("H5支付")
|
||||||
@Data
|
@Data
|
||||||
public class H5PayVo {
|
public class H5PayVo {
|
||||||
@ApiModelProperty("支付金额")
|
@ApiModelProperty("支付金额")
|
||||||
private Double money;//金额
|
private BigDecimal money;//金额
|
||||||
|
|
||||||
@ApiModelProperty("用户id")
|
@ApiModelProperty("用户id")
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
|
@ -45,6 +45,11 @@ driver:
|
||||||
- /tdQuestion/duima/list
|
- /tdQuestion/duima/list
|
||||||
- /tdQuestion/duima/update
|
- /tdQuestion/duima/update
|
||||||
- /payNoticeLog
|
- /payNoticeLog
|
||||||
|
- /tdQuestion/queryQuestionById
|
||||||
|
- /tdQuestion/queryQuestionByIdList
|
||||||
|
- /tdQuestion/queryQuestion
|
||||||
|
- /tdQuestion/getTestQuestion
|
||||||
|
- /tdQuestion/questionCategory
|
||||||
|
|
||||||
# 需要权限校验url集合
|
# 需要权限校验url集合
|
||||||
needAuthEndPoints:
|
needAuthEndPoints:
|
||||||
|
@ -58,8 +63,6 @@ message:
|
||||||
code:
|
code:
|
||||||
expireTime: 300
|
expireTime: 300
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wechatpay:
|
wechatpay:
|
||||||
appId: wx756a7425037609fb
|
appId: wx756a7425037609fb
|
||||||
appSecret: 3e8053032b16c574e38d554ddd438cfd
|
appSecret: 3e8053032b16c574e38d554ddd438cfd
|
||||||
|
|
Loading…
Reference in New Issue