You've already forked FrameTour-BE
配置、记录请求、支付
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.service.impl.mobile;
|
||||
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.mapper.*;
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.model.mobile.goods.*;
|
||||
@ -43,14 +44,13 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
private FaceMapper faceMapper;
|
||||
|
||||
public ApiResponse<List<GoodsPageVO>> goodsList(GoodsReqQuery query) {
|
||||
JwtInfo worker = JwtTokenUtil.getWorker();
|
||||
//查询原素材
|
||||
List<GoodsPageVO> goodsList = new ArrayList<>();
|
||||
|
||||
VideoReqQuery videoReqQuery = new VideoReqQuery();
|
||||
videoReqQuery.setScenicId(query.getScenicId());
|
||||
videoReqQuery.setIsBuy(query.getIsBuy());
|
||||
videoReqQuery.setMemberId(worker.getUserId());
|
||||
videoReqQuery.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
|
||||
//查询成片vlog
|
||||
List<VideoRespVO> videoList = videoMapper.list(videoReqQuery);
|
||||
videoList.forEach(videoRespVO -> {
|
||||
|
@ -90,13 +90,14 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
// request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(req.getTotalPrice());
|
||||
amount.setTotal(1);
|
||||
request.setAmount(amount);
|
||||
request.setAppid(wechatConfig.getAppId());
|
||||
request.setAppid(wechatConfig.getMiniProgramAppId());
|
||||
request.setMchid(wechatConfig.getMchId());
|
||||
request.setDescription(req.getGoodsName());
|
||||
request.setNotifyUrl(wechatConfig.getPayNotifyUrl());
|
||||
request.setOutTradeNo(req.getOrderSn().toString());
|
||||
request.setDescription(req.getDescription());
|
||||
|
||||
Payer payer = new Payer();
|
||||
payer.setOpenid(req.getOpenId());
|
||||
@ -109,7 +110,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
vo.setTimeStamp(timeStamp);
|
||||
String substring = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 32);
|
||||
vo.setNonceStr(substring);
|
||||
String signatureStr = Stream.of(wechatConfig.getAppId(), String.valueOf(timeStamp), substring, "prepay_id=" + response.getPrepayId())
|
||||
String signatureStr = Stream.of(wechatConfig.getMiniProgramAppId(), String.valueOf(timeStamp), substring, "prepay_id=" + response.getPrepayId())
|
||||
.collect(Collectors.joining("\n", "", "\n"));
|
||||
String sign = WXPayUtil.getSign(signatureStr, wechatConfig.getKeyPath());
|
||||
vo.setPaySign(sign);
|
||||
@ -137,6 +138,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
stringBuffer.append(s);
|
||||
}
|
||||
String s1 = stringBuffer.toString();
|
||||
log.warn("微信支付回调:{}", s1);
|
||||
String timestamp = request.getHeader(WECHAT_PAY_TIMESTAMP);
|
||||
String nonce = request.getHeader(WECHAT_PAY_NONCE);
|
||||
String signType = request.getHeader(WeiXinConstant.WECHATPAY_SIGNATURE_TYPE);
|
||||
@ -145,7 +147,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
|
||||
NotificationConfig config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(wechatConfig.getMchId())
|
||||
.privateKeyFromPath(wechatConfig.getKeyPath())
|
||||
.privateKey(wechatConfig.getKeyPath())
|
||||
.merchantSerialNumber(wechatConfig.getMchSerialNo())
|
||||
.apiV3Key(wechatConfig.getApiV3())
|
||||
.build();
|
||||
@ -401,7 +403,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
// 对参数进行加密
|
||||
byte[] bytes = parameter.getBytes(String.valueOf(StandardCharsets.UTF_8));
|
||||
Signature sign = Signature.getInstance("SHA256withRSA");
|
||||
PrivateKey privateKey = PemUtil.loadPrivateKeyFromPath(wechatConfig.getKeyPath()); // privateKeyPath是商户证书密钥的位置apiclient_key.pem
|
||||
PrivateKey privateKey = PemUtil.loadPrivateKeyFromString(wechatConfig.getKeyPath()); // privateKeyPath是商户证书密钥的位置apiclient_key.pem
|
||||
sign.initSign(privateKey); // 商户密钥文件路径
|
||||
sign.update(bytes);
|
||||
String signature = Base64.getEncoder().encodeToString(sign.sign());
|
||||
@ -425,7 +427,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
static void init(WechatConfig wechatConfig) {
|
||||
instance = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(wechatConfig.getMchId())
|
||||
.privateKeyFromPath(wechatConfig.getKeyPath())
|
||||
.privateKey(wechatConfig.getKeyPath())
|
||||
.merchantSerialNumber(wechatConfig.getMchSerialNo())
|
||||
.apiV3Key(wechatConfig.getApiV3())
|
||||
.build();
|
||||
|
@ -130,17 +130,17 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderItems.add(orderItemEntity);
|
||||
|
||||
//修改商品状态
|
||||
if (Objects.equals(goodsType, GoodsTypeEnum.VIDEO.code)) {
|
||||
VideoEntity videoEntity = new VideoEntity();
|
||||
videoEntity.setId(goodsId);
|
||||
videoEntity.setIsBuy(1);
|
||||
videoMapper.update(videoEntity);
|
||||
}else if (Objects.equals(goodsType, GoodsTypeEnum.SOURCE.code)) {
|
||||
SourceEntity sourceEntity = new SourceEntity();
|
||||
sourceEntity.setId(goodsId);
|
||||
sourceEntity.setIsBuy(1);
|
||||
sourceMapper.update(sourceEntity);
|
||||
}
|
||||
// if (Objects.equals(goodsType, GoodsTypeEnum.VIDEO.code)) {
|
||||
// VideoEntity videoEntity = new VideoEntity();
|
||||
// videoEntity.setId(goodsId);
|
||||
// videoEntity.setIsBuy(1);
|
||||
// videoMapper.update(videoEntity);
|
||||
// }else if (Objects.equals(goodsType, GoodsTypeEnum.SOURCE.code)) {
|
||||
// SourceEntity sourceEntity = new SourceEntity();
|
||||
// sourceEntity.setId(goodsId);
|
||||
// sourceEntity.setIsBuy(1);
|
||||
// sourceMapper.update(sourceEntity);
|
||||
// }
|
||||
});
|
||||
int addOrderItems = orderMapper.addOrderItems(orderItems);
|
||||
if (addOrderItems == NumberConstant.ZERO) {
|
||||
@ -157,12 +157,10 @@ public class OrderServiceImpl implements OrderService {
|
||||
statisticsMapper.addStatisticsRecord(statisticsRecordAddReq);
|
||||
|
||||
|
||||
//TODO 封装微信支付请求
|
||||
// WxPayRespVO wxPayRespVO = initiatePayment(order, goodsDetailVO);
|
||||
// return ApiResponse.success(wxPayRespVO);
|
||||
WxPayRespVO wxPayRespVO = initiatePayment(order, goodsDetailVO);
|
||||
return ApiResponse.success(wxPayRespVO);
|
||||
|
||||
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +185,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
wxPayOrderReqVO.setOpenId(order.getOpenid())
|
||||
.setOrderSn(order.getId())
|
||||
.setTotalPrice(BigDecimalUtil.convertToCents(order.getPrice()))
|
||||
.setGoodsName(goodsName);
|
||||
.setGoodsName(goodsName)
|
||||
.setDescription("VLOG视频支付");
|
||||
|
||||
return wxPayService.createOrder(wxPayOrderReqVO);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public interface WxPayService {
|
||||
/**
|
||||
* 微信支付回调
|
||||
*/
|
||||
void payNotify(HttpServletRequest request);
|
||||
void payNotify(HttpServletRequest xml);
|
||||
|
||||
/**
|
||||
* 微信支付结果查询
|
||||
|
Reference in New Issue
Block a user