Compare commits
2 Commits
5b4d2afc5a
...
c87006e721
Author | SHA1 | Date | |
---|---|---|---|
c87006e721 | |||
6985cf39aa |
@ -1,44 +1,44 @@
|
||||
package com.greenorange.promotion.config;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "wx.mini")
|
||||
public class WxOpenConfig {
|
||||
|
||||
private String appId;
|
||||
|
||||
private String appSecret;
|
||||
|
||||
private WxMaService wxMaService;
|
||||
|
||||
/**
|
||||
* 单例模式
|
||||
*/
|
||||
public WxMaService getWxMaService() {
|
||||
if (wxMaService != null) {
|
||||
return wxMaService;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (wxMaService != null) {
|
||||
return wxMaService;
|
||||
}
|
||||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
|
||||
config.setAppid(appId);
|
||||
config.setSecret(appSecret);
|
||||
WxMaService service = new WxMaServiceImpl();
|
||||
service.setWxMaConfig(config);
|
||||
wxMaService = service;
|
||||
return wxMaService;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.greenorange.promotion.config;
|
||||
//
|
||||
//import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
//import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
//import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
//import lombok.Data;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
//@Data
|
||||
//@Slf4j
|
||||
//@Configuration
|
||||
//@ConfigurationProperties(prefix = "wx.mini")
|
||||
//public class WxOpenConfig {
|
||||
//
|
||||
// private String appId;
|
||||
//
|
||||
// private String appSecret;
|
||||
//
|
||||
// private WxMaService wxMaService;
|
||||
//
|
||||
// /**
|
||||
// * 单例模式
|
||||
// */
|
||||
// public WxMaService getWxMaService() {
|
||||
// if (wxMaService != null) {
|
||||
// return wxMaService;
|
||||
// }
|
||||
// synchronized (this) {
|
||||
// if (wxMaService != null) {
|
||||
// return wxMaService;
|
||||
// }
|
||||
// WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
|
||||
// config.setAppid(appId);
|
||||
// config.setSecret(appSecret);
|
||||
// WxMaService service = new WxMaServiceImpl();
|
||||
// service.setWxMaConfig(config);
|
||||
// wxMaService = service;
|
||||
// return wxMaService;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
@ -1,78 +1,78 @@
|
||||
package com.greenorange.promotion.config;
|
||||
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.core.util.IOUtil;
|
||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||
import com.wechat.pay.java.service.refund.RefundService;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@Component("WxPayConfig")
|
||||
@ConfigurationProperties(prefix = "wx.pay")
|
||||
public class WxPayConfig {
|
||||
|
||||
private String appId;
|
||||
|
||||
private String apiV3Key;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String merchantId;
|
||||
|
||||
private String privateKeyPath;
|
||||
|
||||
private String merchantSerialNumber;
|
||||
|
||||
// RSA配置
|
||||
private RSAAutoCertificateConfig RSAConfig;
|
||||
|
||||
// JSAPI支付
|
||||
private JsapiServiceExtension jsapiServiceExtension;
|
||||
|
||||
// 退款
|
||||
private RefundService refundService;
|
||||
|
||||
/**
|
||||
* 初始化配置
|
||||
*/
|
||||
@Bean
|
||||
public boolean initWxPayConfig() throws IOException {
|
||||
this.RSAConfig = buildRSAAutoCertificateConfig();
|
||||
this.jsapiServiceExtension = buildJsapiServiceExtension(RSAConfig);
|
||||
this.refundService = buildRefundService(RSAConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 构建并使用自动更新平台证书的RSA配置,一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
|
||||
private RSAAutoCertificateConfig buildRSAAutoCertificateConfig() throws IOException {
|
||||
// 将 resource 目录下的文件转为 InputStream,然后利用 IOUtil.toString(inputStream) 转化为密钥
|
||||
String privateKey = IOUtil.toString(new ClassPathResource(privateKeyPath).getInputStream());
|
||||
return new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(merchantId)
|
||||
.privateKey(privateKey)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3Key)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 构建JSAPI支付
|
||||
private JsapiServiceExtension buildJsapiServiceExtension(RSAAutoCertificateConfig config) {
|
||||
return new JsapiServiceExtension.Builder().config(config).build();
|
||||
}
|
||||
|
||||
// 构建退款
|
||||
private RefundService buildRefundService(RSAAutoCertificateConfig config) {
|
||||
return new RefundService.Builder().config(config).build();
|
||||
}
|
||||
|
||||
}
|
||||
//package com.greenorange.promotion.config;
|
||||
//
|
||||
//import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
//import com.wechat.pay.java.core.util.IOUtil;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||
//import com.wechat.pay.java.service.refund.RefundService;
|
||||
//import lombok.Data;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.core.io.ClassPathResource;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//@Data
|
||||
//@Slf4j
|
||||
//@Configuration
|
||||
//@Component("WxPayConfig")
|
||||
//@ConfigurationProperties(prefix = "wx.pay")
|
||||
//public class WxPayConfig {
|
||||
//
|
||||
// private String appId;
|
||||
//
|
||||
// private String apiV3Key;
|
||||
//
|
||||
// private String notifyUrl;
|
||||
//
|
||||
// private String merchantId;
|
||||
//
|
||||
// private String privateKeyPath;
|
||||
//
|
||||
// private String merchantSerialNumber;
|
||||
//
|
||||
// // RSA配置
|
||||
// private RSAAutoCertificateConfig RSAConfig;
|
||||
//
|
||||
// // JSAPI支付
|
||||
// private JsapiServiceExtension jsapiServiceExtension;
|
||||
//
|
||||
// // 退款
|
||||
// private RefundService refundService;
|
||||
//
|
||||
// /**
|
||||
// * 初始化配置
|
||||
// */
|
||||
// @Bean
|
||||
// public boolean initWxPayConfig() throws IOException {
|
||||
// this.RSAConfig = buildRSAAutoCertificateConfig();
|
||||
// this.jsapiServiceExtension = buildJsapiServiceExtension(RSAConfig);
|
||||
// this.refundService = buildRefundService(RSAConfig);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// // 构建并使用自动更新平台证书的RSA配置,一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
|
||||
// private RSAAutoCertificateConfig buildRSAAutoCertificateConfig() throws IOException {
|
||||
// // 将 resource 目录下的文件转为 InputStream,然后利用 IOUtil.toString(inputStream) 转化为密钥
|
||||
// String privateKey = IOUtil.toString(new ClassPathResource(privateKeyPath).getInputStream());
|
||||
// return new RSAAutoCertificateConfig.Builder()
|
||||
// .merchantId(merchantId)
|
||||
// .privateKey(privateKey)
|
||||
// .merchantSerialNumber(merchantSerialNumber)
|
||||
// .apiV3Key(apiV3Key)
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
// // 构建JSAPI支付
|
||||
// private JsapiServiceExtension buildJsapiServiceExtension(RSAAutoCertificateConfig config) {
|
||||
// return new JsapiServiceExtension.Builder().config(config).build();
|
||||
// }
|
||||
//
|
||||
// // 构建退款
|
||||
// private RefundService buildRefundService(RSAAutoCertificateConfig config) {
|
||||
// return new RefundService.Builder().config(config).build();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
@ -58,4 +58,8 @@ public interface UserConstant {
|
||||
*/
|
||||
String STAFF_ROLE = "staff";
|
||||
|
||||
/**
|
||||
* 申请通知
|
||||
*/
|
||||
String APPLY_NOTICE_KEY = "applyNotice";
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class CourseController {
|
||||
public BaseResponse<List<CourseCardVO>> miniQueryCourseByKeyword(@Valid @RequestBody CommonStringRequest commonStringRequest) {
|
||||
String keyword = commonStringRequest.getTemplateString();
|
||||
LambdaQueryWrapper<Course> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(Course::getIsShelves, true);
|
||||
lambdaQueryWrapper.eq(Course::getIsShelves, 1);
|
||||
lambdaQueryWrapper.like(Course::getName, keyword);
|
||||
List<Course> courseList = courseService.list(lambdaQueryWrapper);
|
||||
List<CourseCardVO> courseCardVOS = commonService.convertList(courseList, CourseCardVO.class);
|
||||
|
@ -85,19 +85,71 @@ public class UserInfoController {
|
||||
// @PostMapping("test")
|
||||
// public BaseResponse<Boolean> test() throws IOException {
|
||||
// List<UserInfo> list = userInfoService.list();
|
||||
// List<UserMainInfo> userMainInfoList = userMainInfoService.list();
|
||||
// Map<Long, UserInfo> map = new HashMap<>();
|
||||
// for (UserInfo userInfo : list) {
|
||||
// map.put(userInfo.getId(), userInfo);
|
||||
// }
|
||||
// List<UserMainInfo> userMainInfoList = userMainInfoService.list();
|
||||
// for (UserMainInfo userMainInfo : userMainInfoList) {
|
||||
// Long userId = userMainInfo.getUserId();
|
||||
// UserInfo userInfo = map.get(userId);
|
||||
// String userRole = userInfo.getUserRole();
|
||||
// UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValue(userRole);
|
||||
// String wxQrCode = wechatGetQrcodeService.getWxQrCode(userInfo.getInvitationCode(), userRoleEnum);
|
||||
// UserMainInfo userMainInfo = UserMainInfo.builder().userId(userInfo.getId()).inviteQrCode(wxQrCode).build();
|
||||
// userMainInfoList.add(userMainInfo);
|
||||
// String view = wechatGetQrcodeService.getWxQrCode(userInfo.getInvitationCode(), userRoleEnum);
|
||||
// userMainInfo.setInviteQrCode(view);
|
||||
// }
|
||||
// userMainInfoService.saveOrUpdateBatch(userMainInfoList);
|
||||
// return ResultUtils.success(true);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* web端修改员工申请须知
|
||||
* @param commonStringRequest 修改内容
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@PostMapping("modify/applyNotice")
|
||||
@Operation(summary = "web端用户修改用户昵称", description = "参数:昵称,权限:管理员(boss, admin),方法名:modifyApplyNotice")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> modifyApplyNotice(@Valid @RequestBody CommonStringRequest commonStringRequest) {
|
||||
String applyNotice = commonStringRequest.getTemplateString();
|
||||
redisTemplate.opsForValue().set(UserConstant.APPLY_NOTICE_KEY, applyNotice);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端查询员工申请须知
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@PostMapping("query/applyNotice")
|
||||
@Operation(summary = "小程序端查询员工申请须知", description = "参数:无,权限:管理员(boss, admin),方法名:queryApplyNotice")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<String> queryApplyNotice() {
|
||||
String applyNotice = redisTemplate.opsForValue().get(UserConstant.APPLY_NOTICE_KEY);
|
||||
return ResultUtils.success(applyNotice);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户修改用户昵称
|
||||
* @param commonStringRequest 昵称
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@PostMapping("modify/nickname")
|
||||
@Operation(summary = "小程序端用户修改用户昵称", description = "参数:昵称,权限:管理员(boss, admin),方法名:modifyNickname")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
public BaseResponse<Boolean> modifyNickname(@Valid @RequestBody CommonStringRequest commonStringRequest, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
String nickName = commonStringRequest.getTemplateString();
|
||||
LambdaUpdateWrapper<UserInfo> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(UserInfo::getId, userId).set(UserInfo::getNickName, nickName);
|
||||
userInfoService.update(updateWrapper);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户修改用户头像
|
||||
* @param commonStringRequest 头像view值
|
||||
|
@ -1,153 +1,153 @@
|
||||
package com.greenorange.promotion.controller.wechat;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import com.greenorange.promotion.annotation.RequiresPermission;
|
||||
import com.greenorange.promotion.common.BaseResponse;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.common.ResultUtils;
|
||||
import com.greenorange.promotion.config.WxOpenConfig;
|
||||
import com.greenorange.promotion.constant.OrderStatusConstant;
|
||||
import com.greenorange.promotion.constant.UserConstant;
|
||||
import com.greenorange.promotion.exception.BusinessException;
|
||||
import com.greenorange.promotion.exception.ThrowUtils;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import com.greenorange.promotion.model.dto.wxPay.WechatPayRequest;
|
||||
import com.greenorange.promotion.model.entity.CourseOrder;
|
||||
import com.greenorange.promotion.model.entity.UserInfo;
|
||||
import com.greenorange.promotion.service.course.CourseOrderService;
|
||||
import com.greenorange.promotion.service.userInfo.UserInfoService;
|
||||
import com.greenorange.promotion.service.wechat.WechatPayService;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
import com.wechat.pay.java.service.refund.model.Refund;
|
||||
import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "微信支付")
|
||||
@RequestMapping("/wxPay")
|
||||
@Transactional
|
||||
public class WechatPayController {
|
||||
|
||||
|
||||
@Resource
|
||||
private WechatPayService weChatService;
|
||||
|
||||
@Resource
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Resource
|
||||
private CourseOrderService courseOrderService;
|
||||
|
||||
@Resource
|
||||
private WxOpenConfig wxOpenConfig;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JSAPI 下单
|
||||
*/
|
||||
@PostMapping("/payment/create")
|
||||
@Operation(summary = "JSAPI 下单", description = "参数:订单id, 权限:所有人, 方法名:createPayment")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
public BaseResponse<PrepayWithRequestPaymentResponse> createPayment(@Valid @RequestBody WechatPayRequest wechatPayRequest, HttpServletRequest request) {
|
||||
|
||||
String code = wechatPayRequest.getCode();
|
||||
WxMaJscode2SessionResult sessionInfo;
|
||||
String miniOpenId;
|
||||
try {
|
||||
WxMaService wxMaService = wxOpenConfig.getWxMaService();
|
||||
sessionInfo = wxMaService.jsCode2SessionInfo(code);
|
||||
miniOpenId = sessionInfo.getOpenid();
|
||||
if (StringUtils.isAnyBlank(miniOpenId)) {
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
|
||||
}
|
||||
} catch (WxErrorException e) {
|
||||
log.error("userLoginByWxOpen error", e);
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "登录失败,系统错误");
|
||||
}
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
|
||||
Long orderId = wechatPayRequest.getOrderId();
|
||||
CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
ThrowUtils.throwIf(courseOrder == null, ErrorCode.NOT_FOUND_ERROR, "订单不存在");
|
||||
ThrowUtils.throwIf(!courseOrder.getOrderStatus().equals(OrderStatusConstant.PENDING), ErrorCode.OPERATION_ERROR, "订单状态错误");
|
||||
if (!userInfo.getId().equals(courseOrder.getUserId())) {
|
||||
throw new BusinessException(ErrorCode.NO_AUTH_ERROR, "你不是该订单用户!");
|
||||
}
|
||||
PrepayWithRequestPaymentResponse response = weChatService.createPayment(String.valueOf(orderId), miniOpenId, courseOrder.getTotalAmount());
|
||||
return ResultUtils.success(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JSAPI 下单回调
|
||||
*/
|
||||
@Hidden
|
||||
@PostMapping("/payment/callback")
|
||||
@Operation(summary = "JSAPI 下单回调", description = "参数:订单id, 权限:所有人, 方法名:callbackPayment")
|
||||
public synchronized BaseResponse<Boolean> callbackPayment(HttpServletRequest request) throws IOException {
|
||||
// 获取下单信息
|
||||
Transaction transaction = weChatService.getTransactionInfo(request);
|
||||
System.out.println("下单信息:" + transaction);
|
||||
// 支付回调
|
||||
boolean result = weChatService.paymentCallback(transaction);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "微信支付回调失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Web管理员部分退款
|
||||
* @param commonRequest 订单id
|
||||
*/
|
||||
@PostMapping("/refund/part/create")
|
||||
@Operation(summary = "Web管理员部分退款", description = "参数:订单id, 权限:web端管理员, 方法名:createPartRefund")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Refund> createPartRefund(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long orderId = commonRequest.getId();
|
||||
CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
ThrowUtils.throwIf(courseOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在");
|
||||
|
||||
Refund refund = weChatService.refundPartPayment(String.valueOf(orderId), courseOrder.getTotalAmount());
|
||||
return ResultUtils.success(refund);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 部分退款回调
|
||||
*/
|
||||
@Hidden
|
||||
@PostMapping("/refund/part/callback")
|
||||
@Operation(summary = "部分退款回调", description = "参数:订单id, 权限:web端管理员, 方法名:callbackRefundPart")
|
||||
public BaseResponse<Boolean> callbackRefundPart(HttpServletRequest request) {
|
||||
// 获取退款信息
|
||||
RefundNotification refundNotification = weChatService.getRefundInfo(request);
|
||||
// 退款回调
|
||||
boolean result = weChatService.refundPartCallback(refundNotification);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "退款回调失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.greenorange.promotion.controller.wechat;
|
||||
//
|
||||
//import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
//import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
//import com.greenorange.promotion.annotation.RequiresPermission;
|
||||
//import com.greenorange.promotion.common.BaseResponse;
|
||||
//import com.greenorange.promotion.common.ErrorCode;
|
||||
//import com.greenorange.promotion.common.ResultUtils;
|
||||
//import com.greenorange.promotion.config.WxOpenConfig;
|
||||
//import com.greenorange.promotion.constant.OrderStatusConstant;
|
||||
//import com.greenorange.promotion.constant.UserConstant;
|
||||
//import com.greenorange.promotion.exception.BusinessException;
|
||||
//import com.greenorange.promotion.exception.ThrowUtils;
|
||||
//import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
//import com.greenorange.promotion.model.dto.wxPay.WechatPayRequest;
|
||||
//import com.greenorange.promotion.model.entity.CourseOrder;
|
||||
//import com.greenorange.promotion.model.entity.UserInfo;
|
||||
//import com.greenorange.promotion.service.course.CourseOrderService;
|
||||
//import com.greenorange.promotion.service.userInfo.UserInfoService;
|
||||
//import com.greenorange.promotion.service.wechat.WechatPayService;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
//import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
//import com.wechat.pay.java.service.refund.model.Refund;
|
||||
//import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||
//import io.swagger.v3.oas.annotations.Hidden;
|
||||
//import io.swagger.v3.oas.annotations.Operation;
|
||||
//import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
//import jakarta.annotation.Resource;
|
||||
//import jakarta.servlet.http.HttpServletRequest;
|
||||
//import jakarta.validation.Valid;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import me.chanjar.weixin.common.error.WxErrorException;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.springframework.transaction.annotation.Transactional;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@Tag(name = "微信支付")
|
||||
//@RequestMapping("/wxPay")
|
||||
//@Transactional
|
||||
//public class WechatPayController {
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private WechatPayService weChatService;
|
||||
//
|
||||
// @Resource
|
||||
// private UserInfoService userInfoService;
|
||||
//
|
||||
// @Resource
|
||||
// private CourseOrderService courseOrderService;
|
||||
//
|
||||
// @Resource
|
||||
// private WxOpenConfig wxOpenConfig;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * JSAPI 下单
|
||||
// */
|
||||
// @PostMapping("/payment/create")
|
||||
// @Operation(summary = "JSAPI 下单", description = "参数:订单id, 权限:所有人, 方法名:createPayment")
|
||||
// @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
// public BaseResponse<PrepayWithRequestPaymentResponse> createPayment(@Valid @RequestBody WechatPayRequest wechatPayRequest, HttpServletRequest request) {
|
||||
//
|
||||
// String code = wechatPayRequest.getCode();
|
||||
// WxMaJscode2SessionResult sessionInfo;
|
||||
// String miniOpenId;
|
||||
// try {
|
||||
// WxMaService wxMaService = wxOpenConfig.getWxMaService();
|
||||
// sessionInfo = wxMaService.jsCode2SessionInfo(code);
|
||||
// miniOpenId = sessionInfo.getOpenid();
|
||||
// if (StringUtils.isAnyBlank(miniOpenId)) {
|
||||
// throw new BusinessException(ErrorCode.SYSTEM_ERROR);
|
||||
// }
|
||||
// } catch (WxErrorException e) {
|
||||
// log.error("userLoginByWxOpen error", e);
|
||||
// throw new BusinessException(ErrorCode.SYSTEM_ERROR, "登录失败,系统错误");
|
||||
// }
|
||||
// Long userId = (Long) request.getAttribute("userId");
|
||||
// UserInfo userInfo = userInfoService.getById(userId);
|
||||
//
|
||||
// Long orderId = wechatPayRequest.getOrderId();
|
||||
// CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
// ThrowUtils.throwIf(courseOrder == null, ErrorCode.NOT_FOUND_ERROR, "订单不存在");
|
||||
// ThrowUtils.throwIf(!courseOrder.getOrderStatus().equals(OrderStatusConstant.PENDING), ErrorCode.OPERATION_ERROR, "订单状态错误");
|
||||
// if (!userInfo.getId().equals(courseOrder.getUserId())) {
|
||||
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR, "你不是该订单用户!");
|
||||
// }
|
||||
// PrepayWithRequestPaymentResponse response = weChatService.createPayment(String.valueOf(orderId), miniOpenId, courseOrder.getTotalAmount());
|
||||
// return ResultUtils.success(response);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * JSAPI 下单回调
|
||||
// */
|
||||
// @Hidden
|
||||
// @PostMapping("/payment/callback")
|
||||
// @Operation(summary = "JSAPI 下单回调", description = "参数:订单id, 权限:所有人, 方法名:callbackPayment")
|
||||
// public synchronized BaseResponse<Boolean> callbackPayment(HttpServletRequest request) throws IOException {
|
||||
// // 获取下单信息
|
||||
// Transaction transaction = weChatService.getTransactionInfo(request);
|
||||
// System.out.println("下单信息:" + transaction);
|
||||
// // 支付回调
|
||||
// boolean result = weChatService.paymentCallback(transaction);
|
||||
// ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "微信支付回调失败");
|
||||
// return ResultUtils.success(true);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Web管理员部分退款
|
||||
// * @param commonRequest 订单id
|
||||
// */
|
||||
// @PostMapping("/refund/part/create")
|
||||
// @Operation(summary = "Web管理员部分退款", description = "参数:订单id, 权限:web端管理员, 方法名:createPartRefund")
|
||||
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
// public BaseResponse<Refund> createPartRefund(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
// Long orderId = commonRequest.getId();
|
||||
// CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
// ThrowUtils.throwIf(courseOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在");
|
||||
//
|
||||
// Refund refund = weChatService.refundPartPayment(String.valueOf(orderId), courseOrder.getTotalAmount());
|
||||
// return ResultUtils.success(refund);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 部分退款回调
|
||||
// */
|
||||
// @Hidden
|
||||
// @PostMapping("/refund/part/callback")
|
||||
// @Operation(summary = "部分退款回调", description = "参数:订单id, 权限:web端管理员, 方法名:callbackRefundPart")
|
||||
// public BaseResponse<Boolean> callbackRefundPart(HttpServletRequest request) {
|
||||
// // 获取退款信息
|
||||
// RefundNotification refundNotification = weChatService.getRefundInfo(request);
|
||||
// // 退款回调
|
||||
// boolean result = weChatService.refundPartCallback(refundNotification);
|
||||
// ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "退款回调失败");
|
||||
// return ResultUtils.success(true);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.config.WxOpenConfig;
|
||||
import com.greenorange.promotion.constant.CommonConstant;
|
||||
import com.greenorange.promotion.constant.SystemConstant;
|
||||
import com.greenorange.promotion.constant.UserConstant;
|
||||
@ -174,7 +173,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(UserInfo::getNickName, nickName).eq(UserInfo::getUserRole, UserConstant.SUPERVISOR_ROLE);
|
||||
UserInfo userInfo = this.getOne(lambdaQueryWrapper);
|
||||
ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "昵称重复");
|
||||
ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "昵称已存在");
|
||||
}
|
||||
|
||||
// 根据邀请码获得上级用户信息
|
||||
@ -371,9 +370,11 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
phoneNumberLambdaQueryWrapper.eq(UserInfo::getPhoneNumber, phoneNumber);
|
||||
phoneNumberLambdaQueryWrapper = getQueryWrapperByUserRole(userRoleEnum, phoneNumberLambdaQueryWrapper);
|
||||
UserInfo userInfo = this.getOne(phoneNumberLambdaQueryWrapper);
|
||||
if (userInfo != null) {
|
||||
String userRole = userInfo.getUserRole();
|
||||
UserRoleEnum currentUserRoleEnum = UserRoleEnum.getEnumByValue(userRole);
|
||||
ThrowUtils.throwIf(userInfo != null, ErrorCode.OPERATION_ERROR, "该手机号为"+ currentUserRoleEnum.getText() +"账号");
|
||||
throw new BusinessException(ErrorCode.OPERATION_ERROR, "该手机号为"+ currentUserRoleEnum.getText() +"账号");
|
||||
}
|
||||
}
|
||||
String code = redisTemplate.opsForValue().get(SystemConstant.VERIFICATION_CODE + ":" + verificationCode);
|
||||
ThrowUtils.throwIf(code == null, ErrorCode.OPERATION_ERROR, "验证码已失效");
|
||||
|
@ -120,8 +120,7 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
param.put("page", "pages/loginModule/register/register");
|
||||
param.put("scene", inviteCode + "=" + userRoleEnum.getValue());
|
||||
param.put("width", 430);
|
||||
param.put("check_path", false);
|
||||
param.put("env_version", "develop");
|
||||
param.put("env_version", "release");
|
||||
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
|
||||
String jsonParams = JSONUtil.toJsonStr(param);
|
||||
byte[] responseBytes = HttpUtil.createPost(url)
|
||||
|
@ -1,368 +1,367 @@
|
||||
package com.greenorange.promotion.service.wechat.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.config.WxPayConfig;
|
||||
import com.greenorange.promotion.constant.OrderStatusConstant;
|
||||
import com.greenorange.promotion.constant.SystemConstant;
|
||||
import com.greenorange.promotion.exception.ThrowUtils;
|
||||
import com.greenorange.promotion.model.entity.*;
|
||||
import com.greenorange.promotion.model.enums.CommissionStatusEnum;
|
||||
import com.greenorange.promotion.service.common.CommonService;
|
||||
import com.greenorange.promotion.service.course.CourseOrderService;
|
||||
import com.greenorange.promotion.service.course.CoursePromotionCommissionPendingService;
|
||||
import com.greenorange.promotion.service.course.CourseService;
|
||||
import com.greenorange.promotion.service.refund.RefundRecordService;
|
||||
import com.greenorange.promotion.service.userInfo.UserInfoService;
|
||||
import com.greenorange.promotion.service.userInfo.UserPerformanceSummaryService;
|
||||
import com.greenorange.promotion.service.wechat.WechatPayService;
|
||||
import com.greenorange.promotion.utils.RefundUtils;
|
||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||
import com.wechat.pay.java.core.notification.RequestParam;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||
import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||
import com.wechat.pay.java.service.refund.model.Refund;
|
||||
import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author 陈新知
|
||||
*/
|
||||
@Service
|
||||
public class WechatPayServiceImpl implements WechatPayService {
|
||||
|
||||
|
||||
@Resource
|
||||
private WxPayConfig wxPayConfig;
|
||||
|
||||
|
||||
@Resource
|
||||
private CourseOrderService courseOrderService;
|
||||
|
||||
|
||||
@Resource
|
||||
private CourseService courseService;
|
||||
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
|
||||
@Resource
|
||||
private RefundRecordService refundRecordService;
|
||||
|
||||
|
||||
@Resource
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
|
||||
@Resource
|
||||
private UserPerformanceSummaryService userPerformanceSummaryService;
|
||||
|
||||
|
||||
@Resource
|
||||
private CoursePromotionCommissionPendingService coursePromotionCommissionPendingService;
|
||||
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
public static RequestParam requestParam = null;
|
||||
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
*/
|
||||
@Override
|
||||
public PrepayWithRequestPaymentResponse createPayment(String orderId, String miniOpenId, BigDecimal amount) {
|
||||
// request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
// 金额
|
||||
Amount WxAmount = new Amount();
|
||||
WxAmount.setTotal(amount.movePointRight(2).intValue());
|
||||
WxAmount.setCurrency("CNY");
|
||||
request.setAmount(WxAmount);
|
||||
// 公众号id
|
||||
request.setAppid(wxPayConfig.getAppId());
|
||||
// 商户号
|
||||
request.setMchid(wxPayConfig.getMerchantId());
|
||||
// 支付者信息
|
||||
Payer payer = new Payer();
|
||||
payer.setOpenid(miniOpenId);
|
||||
request.setPayer(payer);
|
||||
// 获取订单号
|
||||
CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
String orderNumber = courseOrder.getOrderNumber();
|
||||
// 描述
|
||||
request.setDescription("订单号:" + orderNumber);
|
||||
// 微信回调地址
|
||||
request.setNotifyUrl(wxPayConfig.getNotifyUrl() + "/wxPay/payment/callback");
|
||||
// 商户订单号
|
||||
request.setOutTradeNo(orderNumber);
|
||||
//返回数据,前端调起支付
|
||||
return wxPayConfig.getJsapiServiceExtension().prepayWithRequestPayment(request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
@Override
|
||||
public boolean paymentCallback(Transaction transaction) throws IOException {
|
||||
System.out.println("---------------------------微信支付回调(开始)-------------------------------");
|
||||
// 获取订单信息
|
||||
String orderNumber = transaction.getOutTradeNo();
|
||||
LambdaQueryWrapper<CourseOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CourseOrder::getOrderNumber, orderNumber);
|
||||
CourseOrder courseOrder = courseOrderService.getOne(queryWrapper);
|
||||
|
||||
// 修改订单状态
|
||||
LambdaUpdateWrapper<CourseOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CourseOrder::getId, courseOrder.getId())
|
||||
.set(CourseOrder::getOrderStatus, OrderStatusConstant.SUCCESS);
|
||||
courseOrderService.update(updateWrapper);
|
||||
|
||||
// 修改当前课程下单人数
|
||||
Long courseId = courseOrder.getCourseId();
|
||||
Course course = courseService.getById(courseId);
|
||||
if (course != null) {
|
||||
course.setOrderCount(course.getOrderCount() + 1);
|
||||
courseService.updateById(course);
|
||||
}
|
||||
|
||||
// 更新主管和员工的绩效记录
|
||||
Long userId = courseOrder.getUserId();
|
||||
List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||
List<Long> superUserIdList = pathToRoot.subList(1, 3);
|
||||
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(superUserIdList, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||
BigDecimal rate;
|
||||
Map<String, BigDecimal> rateMap = userPerformanceSummaryService.queryRakeRewardsRate();
|
||||
for (int i = 0; i < userPerformanceSummaryList.size(); i ++ ) {
|
||||
if (i == 0) rate = rateMap.get("first");
|
||||
else rate = rateMap.get("second");
|
||||
// 计算理论上获得的最大提成奖励
|
||||
BigDecimal rakeRewards = courseOrder.getTotalAmount().multiply(rate);
|
||||
UserPerformanceSummary userPerformanceSummary = userPerformanceSummaryList.get(i);
|
||||
|
||||
userPerformanceSummary.setTotalAmount(userPerformanceSummary.getTotalAmount().add(courseOrder.getTotalAmount()));
|
||||
userPerformanceSummary.setNetAmount(userPerformanceSummary.getNetAmount().add(courseOrder.getTotalAmount().multiply(SystemConstant.FEE_RATE)));
|
||||
userPerformanceSummary.setOrderCount(userPerformanceSummary.getOrderCount() + 1);
|
||||
userPerformanceSummary.setToRelease(userPerformanceSummary.getToRelease().add(rakeRewards.multiply(SystemConstant.REFUND_RATE)));
|
||||
userPerformanceSummary.setToSettle(userPerformanceSummary.getToSettle().add(rakeRewards.multiply(SystemConstant.FEE_RATE)));
|
||||
}
|
||||
userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);
|
||||
|
||||
|
||||
// 添加课程推广待提成记录
|
||||
Long firstUserId = pathToRoot.get(0);
|
||||
Long secondUserId = pathToRoot.get(1);
|
||||
CoursePromotionCommissionPending coursePromotionCommissionPending = CoursePromotionCommissionPending.builder()
|
||||
.firstUserId(firstUserId)
|
||||
.secondUserId(secondUserId)
|
||||
.courseId(courseId)
|
||||
.name(courseOrder.getName())
|
||||
.type(courseOrder.getType())
|
||||
.image(courseOrder.getImage())
|
||||
.orderId(courseOrder.getId())
|
||||
.userId(userId)
|
||||
.firstRate(rateMap.get("first"))
|
||||
.secondRate(rateMap.get("second"))
|
||||
.firstReward(courseOrder.getTotalAmount().multiply(rateMap.get("first")))
|
||||
.secondReward(courseOrder.getTotalAmount().multiply(rateMap.get("second")))
|
||||
.totalAmount(courseOrder.getTotalAmount())
|
||||
.commissionStatus(CommissionStatusEnum.PENDING.getValue())
|
||||
.orderCreateTime(courseOrder.getCreateTime())
|
||||
.build();
|
||||
coursePromotionCommissionPendingService.save(coursePromotionCommissionPending);
|
||||
|
||||
|
||||
System.out.println("---------------------------微信支付回调(结束)-------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 部分退款申请
|
||||
*/
|
||||
@Override
|
||||
public Refund refundPartPayment(String orderId, BigDecimal refundAmount) {
|
||||
// 获取订单
|
||||
CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
ThrowUtils.throwIf(courseOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在");
|
||||
// 判断该订单是否已经退款
|
||||
ThrowUtils.throwIf(courseOrder.getOrderStatus().equals(OrderStatusConstant.REFUNDED), ErrorCode.OPERATION_ERROR, "订单已退款");
|
||||
|
||||
String orderNumber = courseOrder.getOrderNumber();
|
||||
// 退款请求
|
||||
CreateRequest createRequest = new CreateRequest();
|
||||
// 商户订单号
|
||||
createRequest.setOutTradeNo(orderNumber);
|
||||
// 商户退款单号
|
||||
String outRefundNo = RefundUtils.generateRefundNo();
|
||||
createRequest.setOutRefundNo(outRefundNo);
|
||||
// 退款结果回调
|
||||
createRequest.setNotifyUrl(wxPayConfig.getNotifyUrl() + "/wxPay/refund/part/callback");
|
||||
// 退款金额
|
||||
AmountReq amountReq = new AmountReq();
|
||||
|
||||
amountReq.setRefund(refundAmount.movePointRight(2).longValue());
|
||||
amountReq.setTotal(courseOrder.getTotalAmount().movePointRight(2).longValue());
|
||||
amountReq.setCurrency("CNY");
|
||||
createRequest.setAmount(amountReq);
|
||||
|
||||
// // 生成退款记录
|
||||
// Course course = courseService.getById(courseOrder.getCourseId());
|
||||
// RefundRecord refundRecord = commonService.copyProperties(course, RefundRecord.class);
|
||||
// refundRecord.setId(null);
|
||||
// refundRecord.setOutTradeNo(orderNumber);
|
||||
// refundRecord.setOutRefundNo(outRefundNo);
|
||||
// refundRecord.setTotalAmount(courseOrder.getTotalAmount().movePointRight(2));
|
||||
// refundRecord.setRefundAmount(refundAmount.movePointRight(2));
|
||||
// refundRecord.setUserId(courseOrder.getUserId());
|
||||
// refundRecord.setCreateTime(null);
|
||||
// refundRecord.setUpdateTime(null);
|
||||
// refundRecordService.save(refundRecord);
|
||||
|
||||
// 申请退款
|
||||
System.out.println("退款请求:" + createRequest);
|
||||
Refund refund = wxPayConfig.getRefundService().create(createRequest);
|
||||
System.out.println("退款申请结果:" + refund);
|
||||
|
||||
return refund;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 部分退款回调
|
||||
*/
|
||||
@Override
|
||||
public boolean refundPartCallback(RefundNotification refundNotification) {
|
||||
System.out.println("---------------------------微信退款回调(开始)-------------------------------");
|
||||
// 获取订单信息
|
||||
String orderNumber = refundNotification.getOutTradeNo();
|
||||
LambdaQueryWrapper<CourseOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CourseOrder::getOrderNumber, orderNumber);
|
||||
CourseOrder courseOrder = courseOrderService.getOne(queryWrapper);
|
||||
|
||||
// 修改订单状态
|
||||
LambdaUpdateWrapper<CourseOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CourseOrder::getId, courseOrder.getId())
|
||||
.set(CourseOrder::getOrderStatus, OrderStatusConstant.REFUNDED);
|
||||
courseOrderService.update(updateWrapper);
|
||||
|
||||
// 修改课程下单人数
|
||||
Long courseId = courseOrder.getCourseId();
|
||||
Course course = courseService.getById(courseId);
|
||||
if (course != null) {
|
||||
course.setOrderCount(course.getOrderCount() - 1);
|
||||
courseService.updateById(course);
|
||||
}
|
||||
|
||||
// 更新主管和员工的绩效记录
|
||||
Long userId = courseOrder.getUserId();
|
||||
List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||
List<Long> superUserIdList = pathToRoot.subList(1, 3);
|
||||
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(superUserIdList, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||
BigDecimal rate;
|
||||
LambdaQueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new LambdaQueryWrapper<>();
|
||||
coursePromotionQueryWrapper.eq(CoursePromotionCommissionPending::getOrderId, courseOrder.getId());
|
||||
CoursePromotionCommissionPending coursePromotionCommissionPending = coursePromotionCommissionPendingService.getOne(coursePromotionQueryWrapper);
|
||||
for (int i = 0; i < userPerformanceSummaryList.size(); i ++ ) {
|
||||
if (i == 0) rate = coursePromotionCommissionPending.getFirstRate();
|
||||
else rate = coursePromotionCommissionPending.getSecondRate();
|
||||
// 计算理论上获得的最大提成奖励
|
||||
BigDecimal rakeRewards = courseOrder.getTotalAmount().multiply(rate);
|
||||
UserPerformanceSummary userPerformanceSummary = userPerformanceSummaryList.get(i);
|
||||
|
||||
userPerformanceSummary.setTotalAmount(userPerformanceSummary.getTotalAmount().subtract(courseOrder.getTotalAmount()));
|
||||
userPerformanceSummary.setNetAmount(userPerformanceSummary.getNetAmount().subtract(courseOrder.getTotalAmount().multiply(SystemConstant.FEE_RATE)));
|
||||
userPerformanceSummary.setToRelease(userPerformanceSummary.getToRelease().subtract(rakeRewards.multiply(SystemConstant.REFUND_RATE)));
|
||||
userPerformanceSummary.setRefunded(userPerformanceSummary.getRefunded().add(courseOrder.getTotalAmount().multiply(SystemConstant.REFUND_RATE)));
|
||||
}
|
||||
userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);
|
||||
|
||||
// 修改课程推广待提成状态为"已失效"
|
||||
LambdaUpdateWrapper<CoursePromotionCommissionPending> coursePromotionUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
coursePromotionUpdateWrapper.eq(CoursePromotionCommissionPending::getOrderId, courseOrder.getId())
|
||||
.set(CoursePromotionCommissionPending::getCommissionStatus, CommissionStatusEnum.EXPIRED.getValue());
|
||||
coursePromotionCommissionPendingService.update(coursePromotionUpdateWrapper);
|
||||
|
||||
System.out.println("---------------------------微信退款回调(结束)-------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取支付回调信息
|
||||
*/
|
||||
@Override
|
||||
public Transaction getTransactionInfo(HttpServletRequest request) {
|
||||
NotificationParser notificationParser = getNotificationParser(request);
|
||||
return notificationParser.parse(requestParam, Transaction.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取退款回调信息
|
||||
*/
|
||||
@Override
|
||||
public RefundNotification getRefundInfo(HttpServletRequest request) {
|
||||
NotificationParser notificationParser = getNotificationParser(request);
|
||||
return notificationParser.parse(requestParam, RefundNotification.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据微信官方发送的请求获取信息
|
||||
*/
|
||||
@SneakyThrows
|
||||
public NotificationParser getNotificationParser(HttpServletRequest request) {
|
||||
System.out.println("---------------------------获取信息-------------------------------");
|
||||
// 获取RSA配置
|
||||
NotificationParser notificationParser = new NotificationParser(wxPayConfig.getRSAConfig());
|
||||
// 构建请求
|
||||
StringBuilder bodyBuilder = new StringBuilder();
|
||||
BufferedReader reader = request.getReader();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
bodyBuilder.append(line);
|
||||
}
|
||||
String body = bodyBuilder.toString();
|
||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
||||
String signature = request.getHeader("Wechatpay-Signature");
|
||||
String singType = request.getHeader("Wechatpay-Signature-Type");
|
||||
String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
|
||||
requestParam = new RequestParam.Builder()
|
||||
.serialNumber(wechatPayCertificateSerialNumber)
|
||||
.nonce(nonce)
|
||||
.signature(signature)
|
||||
.timestamp(timestamp)
|
||||
.signType(singType)
|
||||
.body(body)
|
||||
.build();
|
||||
System.out.println(requestParam.toString());
|
||||
System.out.println("---------------------------信息获取完毕-------------------------------");
|
||||
return notificationParser;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.greenorange.promotion.service.wechat.impl;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
//import com.greenorange.promotion.common.ErrorCode;
|
||||
//import com.greenorange.promotion.constant.OrderStatusConstant;
|
||||
//import com.greenorange.promotion.constant.SystemConstant;
|
||||
//import com.greenorange.promotion.exception.ThrowUtils;
|
||||
//import com.greenorange.promotion.model.entity.*;
|
||||
//import com.greenorange.promotion.model.enums.CommissionStatusEnum;
|
||||
//import com.greenorange.promotion.service.common.CommonService;
|
||||
//import com.greenorange.promotion.service.course.CourseOrderService;
|
||||
//import com.greenorange.promotion.service.course.CoursePromotionCommissionPendingService;
|
||||
//import com.greenorange.promotion.service.course.CourseService;
|
||||
//import com.greenorange.promotion.service.refund.RefundRecordService;
|
||||
//import com.greenorange.promotion.service.userInfo.UserInfoService;
|
||||
//import com.greenorange.promotion.service.userInfo.UserPerformanceSummaryService;
|
||||
//import com.greenorange.promotion.service.wechat.WechatPayService;
|
||||
//import com.greenorange.promotion.utils.RefundUtils;
|
||||
//import com.wechat.pay.java.core.notification.NotificationParser;
|
||||
//import com.wechat.pay.java.core.notification.RequestParam;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.model.Amount;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
//import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
//import com.wechat.pay.java.service.refund.model.AmountReq;
|
||||
//import com.wechat.pay.java.service.refund.model.CreateRequest;
|
||||
//import com.wechat.pay.java.service.refund.model.Refund;
|
||||
//import com.wechat.pay.java.service.refund.model.RefundNotification;
|
||||
//import jakarta.annotation.Resource;
|
||||
//import jakarta.servlet.http.HttpServletRequest;
|
||||
//import lombok.SneakyThrows;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.IOException;
|
||||
//import java.math.BigDecimal;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//import java.util.function.Function;
|
||||
//
|
||||
///**
|
||||
// * @author 陈新知
|
||||
// */
|
||||
//@Service
|
||||
//public class WechatPayServiceImpl implements WechatPayService {
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private WxPayConfig wxPayConfig;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private CourseOrderService courseOrderService;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private CourseService courseService;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private CommonService commonService;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private RefundRecordService refundRecordService;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private UserInfoService userInfoService;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private UserPerformanceSummaryService userPerformanceSummaryService;
|
||||
//
|
||||
//
|
||||
// @Resource
|
||||
// private CoursePromotionCommissionPendingService coursePromotionCommissionPendingService;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 请求参数
|
||||
// */
|
||||
// public static RequestParam requestParam = null;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 微信支付
|
||||
// */
|
||||
// @Override
|
||||
// public PrepayWithRequestPaymentResponse createPayment(String orderId, String miniOpenId, BigDecimal amount) {
|
||||
// // request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// PrepayRequest request = new PrepayRequest();
|
||||
// // 金额
|
||||
// Amount WxAmount = new Amount();
|
||||
// WxAmount.setTotal(amount.movePointRight(2).intValue());
|
||||
// WxAmount.setCurrency("CNY");
|
||||
// request.setAmount(WxAmount);
|
||||
// // 公众号id
|
||||
// request.setAppid(wxPayConfig.getAppId());
|
||||
// // 商户号
|
||||
// request.setMchid(wxPayConfig.getMerchantId());
|
||||
// // 支付者信息
|
||||
// Payer payer = new Payer();
|
||||
// payer.setOpenid(miniOpenId);
|
||||
// request.setPayer(payer);
|
||||
// // 获取订单号
|
||||
// CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
// String orderNumber = courseOrder.getOrderNumber();
|
||||
// // 描述
|
||||
// request.setDescription("订单号:" + orderNumber);
|
||||
// // 微信回调地址
|
||||
// request.setNotifyUrl(wxPayConfig.getNotifyUrl() + "/wxPay/payment/callback");
|
||||
// // 商户订单号
|
||||
// request.setOutTradeNo(orderNumber);
|
||||
// //返回数据,前端调起支付
|
||||
// return wxPayConfig.getJsapiServiceExtension().prepayWithRequestPayment(request);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 支付回调
|
||||
// */
|
||||
// @Override
|
||||
// public boolean paymentCallback(Transaction transaction) throws IOException {
|
||||
// System.out.println("---------------------------微信支付回调(开始)-------------------------------");
|
||||
// // 获取订单信息
|
||||
// String orderNumber = transaction.getOutTradeNo();
|
||||
// LambdaQueryWrapper<CourseOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(CourseOrder::getOrderNumber, orderNumber);
|
||||
// CourseOrder courseOrder = courseOrderService.getOne(queryWrapper);
|
||||
//
|
||||
// // 修改订单状态
|
||||
// LambdaUpdateWrapper<CourseOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
// updateWrapper.eq(CourseOrder::getId, courseOrder.getId())
|
||||
// .set(CourseOrder::getOrderStatus, OrderStatusConstant.SUCCESS);
|
||||
// courseOrderService.update(updateWrapper);
|
||||
//
|
||||
// // 修改当前课程下单人数
|
||||
// Long courseId = courseOrder.getCourseId();
|
||||
// Course course = courseService.getById(courseId);
|
||||
// if (course != null) {
|
||||
// course.setOrderCount(course.getOrderCount() + 1);
|
||||
// courseService.updateById(course);
|
||||
// }
|
||||
//
|
||||
// // 更新主管和员工的绩效记录
|
||||
// Long userId = courseOrder.getUserId();
|
||||
// List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||
// List<Long> superUserIdList = pathToRoot.subList(1, 3);
|
||||
// List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(superUserIdList, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||
// BigDecimal rate;
|
||||
// Map<String, BigDecimal> rateMap = userPerformanceSummaryService.queryRakeRewardsRate();
|
||||
// for (int i = 0; i < userPerformanceSummaryList.size(); i ++ ) {
|
||||
// if (i == 0) rate = rateMap.get("first");
|
||||
// else rate = rateMap.get("second");
|
||||
// // 计算理论上获得的最大提成奖励
|
||||
// BigDecimal rakeRewards = courseOrder.getTotalAmount().multiply(rate);
|
||||
// UserPerformanceSummary userPerformanceSummary = userPerformanceSummaryList.get(i);
|
||||
//
|
||||
// userPerformanceSummary.setTotalAmount(userPerformanceSummary.getTotalAmount().add(courseOrder.getTotalAmount()));
|
||||
// userPerformanceSummary.setNetAmount(userPerformanceSummary.getNetAmount().add(courseOrder.getTotalAmount().multiply(SystemConstant.FEE_RATE)));
|
||||
// userPerformanceSummary.setOrderCount(userPerformanceSummary.getOrderCount() + 1);
|
||||
// userPerformanceSummary.setToRelease(userPerformanceSummary.getToRelease().add(rakeRewards.multiply(SystemConstant.REFUND_RATE)));
|
||||
// userPerformanceSummary.setToSettle(userPerformanceSummary.getToSettle().add(rakeRewards.multiply(SystemConstant.FEE_RATE)));
|
||||
// }
|
||||
// userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);
|
||||
//
|
||||
//
|
||||
// // 添加课程推广待提成记录
|
||||
// Long firstUserId = pathToRoot.get(0);
|
||||
// Long secondUserId = pathToRoot.get(1);
|
||||
// CoursePromotionCommissionPending coursePromotionCommissionPending = CoursePromotionCommissionPending.builder()
|
||||
// .firstUserId(firstUserId)
|
||||
// .secondUserId(secondUserId)
|
||||
// .courseId(courseId)
|
||||
// .name(courseOrder.getName())
|
||||
// .type(courseOrder.getType())
|
||||
// .image(courseOrder.getImage())
|
||||
// .orderId(courseOrder.getId())
|
||||
// .userId(userId)
|
||||
// .firstRate(rateMap.get("first"))
|
||||
// .secondRate(rateMap.get("second"))
|
||||
// .firstReward(courseOrder.getTotalAmount().multiply(rateMap.get("first")))
|
||||
// .secondReward(courseOrder.getTotalAmount().multiply(rateMap.get("second")))
|
||||
// .totalAmount(courseOrder.getTotalAmount())
|
||||
// .commissionStatus(CommissionStatusEnum.PENDING.getValue())
|
||||
// .orderCreateTime(courseOrder.getCreateTime())
|
||||
// .build();
|
||||
// coursePromotionCommissionPendingService.save(coursePromotionCommissionPending);
|
||||
//
|
||||
//
|
||||
// System.out.println("---------------------------微信支付回调(结束)-------------------------------");
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 部分退款申请
|
||||
// */
|
||||
// @Override
|
||||
// public Refund refundPartPayment(String orderId, BigDecimal refundAmount) {
|
||||
// // 获取订单
|
||||
// CourseOrder courseOrder = courseOrderService.getById(orderId);
|
||||
// ThrowUtils.throwIf(courseOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在");
|
||||
// // 判断该订单是否已经退款
|
||||
// ThrowUtils.throwIf(courseOrder.getOrderStatus().equals(OrderStatusConstant.REFUNDED), ErrorCode.OPERATION_ERROR, "订单已退款");
|
||||
//
|
||||
// String orderNumber = courseOrder.getOrderNumber();
|
||||
// // 退款请求
|
||||
// CreateRequest createRequest = new CreateRequest();
|
||||
// // 商户订单号
|
||||
// createRequest.setOutTradeNo(orderNumber);
|
||||
// // 商户退款单号
|
||||
// String outRefundNo = RefundUtils.generateRefundNo();
|
||||
// createRequest.setOutRefundNo(outRefundNo);
|
||||
// // 退款结果回调
|
||||
// createRequest.setNotifyUrl(wxPayConfig.getNotifyUrl() + "/wxPay/refund/part/callback");
|
||||
// // 退款金额
|
||||
// AmountReq amountReq = new AmountReq();
|
||||
//
|
||||
// amountReq.setRefund(refundAmount.movePointRight(2).longValue());
|
||||
// amountReq.setTotal(courseOrder.getTotalAmount().movePointRight(2).longValue());
|
||||
// amountReq.setCurrency("CNY");
|
||||
// createRequest.setAmount(amountReq);
|
||||
//
|
||||
//// // 生成退款记录
|
||||
//// Course course = courseService.getById(courseOrder.getCourseId());
|
||||
//// RefundRecord refundRecord = commonService.copyProperties(course, RefundRecord.class);
|
||||
//// refundRecord.setId(null);
|
||||
//// refundRecord.setOutTradeNo(orderNumber);
|
||||
//// refundRecord.setOutRefundNo(outRefundNo);
|
||||
//// refundRecord.setTotalAmount(courseOrder.getTotalAmount().movePointRight(2));
|
||||
//// refundRecord.setRefundAmount(refundAmount.movePointRight(2));
|
||||
//// refundRecord.setUserId(courseOrder.getUserId());
|
||||
//// refundRecord.setCreateTime(null);
|
||||
//// refundRecord.setUpdateTime(null);
|
||||
//// refundRecordService.save(refundRecord);
|
||||
//
|
||||
// // 申请退款
|
||||
// System.out.println("退款请求:" + createRequest);
|
||||
// Refund refund = wxPayConfig.getRefundService().create(createRequest);
|
||||
// System.out.println("退款申请结果:" + refund);
|
||||
//
|
||||
// return refund;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 部分退款回调
|
||||
// */
|
||||
// @Override
|
||||
// public boolean refundPartCallback(RefundNotification refundNotification) {
|
||||
// System.out.println("---------------------------微信退款回调(开始)-------------------------------");
|
||||
// // 获取订单信息
|
||||
// String orderNumber = refundNotification.getOutTradeNo();
|
||||
// LambdaQueryWrapper<CourseOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(CourseOrder::getOrderNumber, orderNumber);
|
||||
// CourseOrder courseOrder = courseOrderService.getOne(queryWrapper);
|
||||
//
|
||||
// // 修改订单状态
|
||||
// LambdaUpdateWrapper<CourseOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
// updateWrapper.eq(CourseOrder::getId, courseOrder.getId())
|
||||
// .set(CourseOrder::getOrderStatus, OrderStatusConstant.REFUNDED);
|
||||
// courseOrderService.update(updateWrapper);
|
||||
//
|
||||
// // 修改课程下单人数
|
||||
// Long courseId = courseOrder.getCourseId();
|
||||
// Course course = courseService.getById(courseId);
|
||||
// if (course != null) {
|
||||
// course.setOrderCount(course.getOrderCount() - 1);
|
||||
// courseService.updateById(course);
|
||||
// }
|
||||
//
|
||||
// // 更新主管和员工的绩效记录
|
||||
// Long userId = courseOrder.getUserId();
|
||||
// List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||
// List<Long> superUserIdList = pathToRoot.subList(1, 3);
|
||||
// List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(superUserIdList, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||
// BigDecimal rate;
|
||||
// LambdaQueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// coursePromotionQueryWrapper.eq(CoursePromotionCommissionPending::getOrderId, courseOrder.getId());
|
||||
// CoursePromotionCommissionPending coursePromotionCommissionPending = coursePromotionCommissionPendingService.getOne(coursePromotionQueryWrapper);
|
||||
// for (int i = 0; i < userPerformanceSummaryList.size(); i ++ ) {
|
||||
// if (i == 0) rate = coursePromotionCommissionPending.getFirstRate();
|
||||
// else rate = coursePromotionCommissionPending.getSecondRate();
|
||||
// // 计算理论上获得的最大提成奖励
|
||||
// BigDecimal rakeRewards = courseOrder.getTotalAmount().multiply(rate);
|
||||
// UserPerformanceSummary userPerformanceSummary = userPerformanceSummaryList.get(i);
|
||||
//
|
||||
// userPerformanceSummary.setTotalAmount(userPerformanceSummary.getTotalAmount().subtract(courseOrder.getTotalAmount()));
|
||||
// userPerformanceSummary.setNetAmount(userPerformanceSummary.getNetAmount().subtract(courseOrder.getTotalAmount().multiply(SystemConstant.FEE_RATE)));
|
||||
// userPerformanceSummary.setToRelease(userPerformanceSummary.getToRelease().subtract(rakeRewards.multiply(SystemConstant.REFUND_RATE)));
|
||||
// userPerformanceSummary.setRefunded(userPerformanceSummary.getRefunded().add(courseOrder.getTotalAmount().multiply(SystemConstant.REFUND_RATE)));
|
||||
// }
|
||||
// userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);
|
||||
//
|
||||
// // 修改课程推广待提成状态为"已失效"
|
||||
// LambdaUpdateWrapper<CoursePromotionCommissionPending> coursePromotionUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
// coursePromotionUpdateWrapper.eq(CoursePromotionCommissionPending::getOrderId, courseOrder.getId())
|
||||
// .set(CoursePromotionCommissionPending::getCommissionStatus, CommissionStatusEnum.EXPIRED.getValue());
|
||||
// coursePromotionCommissionPendingService.update(coursePromotionUpdateWrapper);
|
||||
//
|
||||
// System.out.println("---------------------------微信退款回调(结束)-------------------------------");
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 获取支付回调信息
|
||||
// */
|
||||
// @Override
|
||||
// public Transaction getTransactionInfo(HttpServletRequest request) {
|
||||
// NotificationParser notificationParser = getNotificationParser(request);
|
||||
// return notificationParser.parse(requestParam, Transaction.class);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 获取退款回调信息
|
||||
// */
|
||||
// @Override
|
||||
// public RefundNotification getRefundInfo(HttpServletRequest request) {
|
||||
// NotificationParser notificationParser = getNotificationParser(request);
|
||||
// return notificationParser.parse(requestParam, RefundNotification.class);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 根据微信官方发送的请求获取信息
|
||||
// */
|
||||
// @SneakyThrows
|
||||
// public NotificationParser getNotificationParser(HttpServletRequest request) {
|
||||
// System.out.println("---------------------------获取信息-------------------------------");
|
||||
// // 获取RSA配置
|
||||
// NotificationParser notificationParser = new NotificationParser(wxPayConfig.getRSAConfig());
|
||||
// // 构建请求
|
||||
// StringBuilder bodyBuilder = new StringBuilder();
|
||||
// BufferedReader reader = request.getReader();
|
||||
// String line;
|
||||
// while ((line = reader.readLine()) != null) {
|
||||
// bodyBuilder.append(line);
|
||||
// }
|
||||
// String body = bodyBuilder.toString();
|
||||
// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||
// String nonce = request.getHeader("Wechatpay-Nonce");
|
||||
// String signature = request.getHeader("Wechatpay-Signature");
|
||||
// String singType = request.getHeader("Wechatpay-Signature-Type");
|
||||
// String wechatPayCertificateSerialNumber = request.getHeader("Wechatpay-Serial");
|
||||
// requestParam = new RequestParam.Builder()
|
||||
// .serialNumber(wechatPayCertificateSerialNumber)
|
||||
// .nonce(nonce)
|
||||
// .signature(signature)
|
||||
// .timestamp(timestamp)
|
||||
// .signType(singType)
|
||||
// .body(body)
|
||||
// .build();
|
||||
// System.out.println(requestParam.toString());
|
||||
// System.out.println("---------------------------信息获取完毕-------------------------------");
|
||||
// return notificationParser;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
@ -81,31 +81,11 @@ mybatis-plus:
|
||||
|
||||
|
||||
|
||||
|
||||
wx:
|
||||
mini:
|
||||
appId: wx3f968a09e31d6bed
|
||||
appSecret: 0b23498d19665dc323efdd3ed5367041
|
||||
|
||||
pay:
|
||||
#应用id(小程序id)
|
||||
appId: wx61b63e27bddf4ea2
|
||||
#商户号
|
||||
merchantId: 1700326544
|
||||
#商户API私钥
|
||||
privateKeyPath: apiclient_key.pem
|
||||
#商户证书序列号
|
||||
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
|
||||
#商户APIv3密钥
|
||||
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
|
||||
#通知地址
|
||||
notifyUrl: https://winning-mouse-internally.ngrok-free.app
|
||||
#微信服务器地址
|
||||
domain: https://api.mch.weixin.qq.com
|
||||
#商户APIv2密钥
|
||||
apiV2Key: cvsOH6TgbbdNUUqFJyLmWGaIEKoSqANg
|
||||
#商户API证书
|
||||
certificatePath: static/apiclient_cert.p12
|
||||
|
||||
appId: wx8711c8d4fb04fef9
|
||||
appSecret: 3ec1f19949d99f059e2ae4be62d02123
|
||||
|
||||
|
||||
|
||||
|
@ -74,28 +74,8 @@ mybatis-plus:
|
||||
|
||||
wx:
|
||||
mini:
|
||||
appId: wx3f968a09e31d6bed
|
||||
appSecret: 0b23498d19665dc323efdd3ed5367041
|
||||
|
||||
pay:
|
||||
#应用id(小程序id)
|
||||
appId: wx61b63e27bddf4ea2
|
||||
#商户号
|
||||
merchantId: 1700326544
|
||||
#商户API私钥
|
||||
privateKeyPath: apiclient_key.pem
|
||||
#商户证书序列号
|
||||
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
|
||||
#商户APIv3密钥
|
||||
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
|
||||
#通知地址
|
||||
notifyUrl: https://winning-mouse-internally.ngrok-free.app
|
||||
#微信服务器地址
|
||||
domain: https://api.mch.weixin.qq.com
|
||||
#商户APIv2密钥
|
||||
apiV2Key: cvsOH6TgbbdNUUqFJyLmWGaIEKoSqANg
|
||||
#商户API证书
|
||||
certificatePath: static/apiclient_cert.p12
|
||||
appId: wx8711c8d4fb04fef9
|
||||
appSecret: 3ec1f19949d99f059e2ae4be62d02123
|
||||
|
||||
|
||||
|
||||
|
@ -63,32 +63,11 @@ mybatis-plus:
|
||||
|
||||
|
||||
|
||||
|
||||
wx:
|
||||
mini:
|
||||
appId: wx3f968a09e31d6bed
|
||||
appSecret: 0b23498d19665dc323efdd3ed5367041
|
||||
|
||||
pay:
|
||||
#应用id(小程序id)
|
||||
appId: wx61b63e27bddf4ea2
|
||||
#商户号
|
||||
merchantId: 1700326544
|
||||
# #商户API私钥
|
||||
# privateKeyPath: apiclient_key.pem
|
||||
#商户证书序列号
|
||||
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
|
||||
# #商户APIv3密钥
|
||||
# apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
|
||||
#通知地址
|
||||
notifyUrl: https://winning-mouse-internally.ngrok-free.app
|
||||
#微信服务器地址
|
||||
domain: https://api.mch.weixin.qq.com
|
||||
#商户APIv2密钥
|
||||
apiV2Key: cvsOH6TgbbdNUUqFJyLmWGaIEKoSqANg
|
||||
#商户API证书
|
||||
certificatePath: static/apiclient_cert.p12
|
||||
|
||||
|
||||
appId: wx8711c8d4fb04fef9
|
||||
appSecret: 3ec1f19949d99f059e2ae4be62d02123
|
||||
|
||||
|
||||
knife4j:
|
||||
|
112
src/main/resources/application-prod.yml
Normal file
112
src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,112 @@
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://160.202.242.36:3306/qingcheng_test?serverTimezone=Asia/Shanghai
|
||||
username: qingcheng
|
||||
password: Qc@8ls2jf
|
||||
hikari:
|
||||
maximum-pool-size: 300
|
||||
max-lifetime: 120000
|
||||
|
||||
|
||||
rabbitmq:
|
||||
host: 160.202.242.36
|
||||
port: 5672
|
||||
username: qingcheng
|
||||
password: cksys6509
|
||||
virtual-host: vhost-test
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1
|
||||
|
||||
|
||||
data:
|
||||
redis:
|
||||
port: 6379
|
||||
host: 160.202.242.36
|
||||
database: 8
|
||||
password: Cksys6509
|
||||
|
||||
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
|
||||
|
||||
# 文件上传和下载地址
|
||||
file:
|
||||
upload-dir: /www/wwwroot/fileUpload_qc/
|
||||
# upload-dir: D:/qingcheng/image/
|
||||
|
||||
|
||||
|
||||
springdoc:
|
||||
default-flat-param-object: true
|
||||
|
||||
#线程池配置
|
||||
threadpool:
|
||||
corePoolSize: 10
|
||||
maxPoolSize: 50
|
||||
queueCapacity: 1024
|
||||
keepAliveTime: 60
|
||||
|
||||
|
||||
server:
|
||||
port: 9095
|
||||
ssl:
|
||||
key-store: classpath:static/www.chenxinzhi.top.jks
|
||||
key-store-password: 3fqodotz
|
||||
key-store-type: JKS
|
||||
|
||||
|
||||
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: false
|
||||
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
logic-delete-field: isDelete #全局逻辑删除的实体字段名
|
||||
logic-delete-value: 1 #逻辑已删除值(默认为1)
|
||||
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
|
||||
type-handlers-package: com.cultural.heritage.handler
|
||||
|
||||
|
||||
|
||||
wx:
|
||||
mini:
|
||||
appId: wx8711c8d4fb04fef9
|
||||
appSecret: 3ec1f19949d99f059e2ae4be62d02123
|
||||
#
|
||||
# pay:
|
||||
# #应用id(小程序id)
|
||||
# appId: wx61b63e27bddf4ea2
|
||||
# #商户号
|
||||
# merchantId: 1700326544
|
||||
# #商户API私钥
|
||||
# privateKeyPath: apiclient_key.pem
|
||||
# #商户证书序列号
|
||||
# merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
|
||||
# #商户APIv3密钥
|
||||
# apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
|
||||
# #通知地址
|
||||
# notifyUrl: https://winning-mouse-internally.ngrok-free.app
|
||||
# #微信服务器地址
|
||||
# domain: https://api.mch.weixin.qq.com
|
||||
# #商户APIv2密钥
|
||||
# apiV2Key: cvsOH6TgbbdNUUqFJyLmWGaIEKoSqANg
|
||||
# #商户API证书
|
||||
# certificatePath: static/apiclient_cert.p12
|
||||
|
||||
|
||||
|
||||
|
||||
knife4j:
|
||||
enable: true
|
@ -77,28 +77,28 @@ mybatis-plus:
|
||||
|
||||
wx:
|
||||
mini:
|
||||
appId: wx3f968a09e31d6bed
|
||||
appSecret: 0b23498d19665dc323efdd3ed5367041
|
||||
|
||||
pay:
|
||||
#应用id(小程序id)
|
||||
appId: wx61b63e27bddf4ea2
|
||||
#商户号
|
||||
merchantId: 1700326544
|
||||
#商户API私钥
|
||||
privateKeyPath: apiclient_key.pem
|
||||
#商户证书序列号
|
||||
merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
|
||||
#商户APIv3密钥
|
||||
apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
|
||||
#通知地址
|
||||
notifyUrl: https://winning-mouse-internally.ngrok-free.app
|
||||
#微信服务器地址
|
||||
domain: https://api.mch.weixin.qq.com
|
||||
#商户APIv2密钥
|
||||
apiV2Key: cvsOH6TgbbdNUUqFJyLmWGaIEKoSqANg
|
||||
#商户API证书
|
||||
certificatePath: static/apiclient_cert.p12
|
||||
appId: wx8711c8d4fb04fef9
|
||||
appSecret: 3ec1f19949d99f059e2ae4be62d02123
|
||||
#
|
||||
# pay:
|
||||
# #应用id(小程序id)
|
||||
# appId: wx61b63e27bddf4ea2
|
||||
# #商户号
|
||||
# merchantId: 1700326544
|
||||
# #商户API私钥
|
||||
# privateKeyPath: apiclient_key.pem
|
||||
# #商户证书序列号
|
||||
# merchantSerialNumber: 6DC8953AB741D309920DA650B92F837BE38A2757
|
||||
# #商户APIv3密钥
|
||||
# apiV3Key: fbemuj4Xql7CYlQJAoTEPYxvPSNgYT2t
|
||||
# #通知地址
|
||||
# notifyUrl: https://winning-mouse-internally.ngrok-free.app
|
||||
# #微信服务器地址
|
||||
# domain: https://api.mch.weixin.qq.com
|
||||
# #商户APIv2密钥
|
||||
# apiV2Key: cvsOH6TgbbdNUUqFJyLmWGaIEKoSqANg
|
||||
# #商户API证书
|
||||
# certificatePath: static/apiclient_cert.p12
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -1,12 +0,0 @@
|
||||
$libDir = "D:\青橙\backend\src\main\resources\lib" # 使用绝对路径指定 lib 目录
|
||||
$repositoryDir = "D:\software\Maven\maven-repository" # 设置自定义仓库目录
|
||||
|
||||
# 遍历 lib 目录下的所有 JAR 文件并安装到指定的仓库
|
||||
Get-ChildItem -Path $libDir -Filter "*.jar" | ForEach-Object {
|
||||
mvn install:install-file -Dfile=$_.FullName `
|
||||
-DgroupId=com.example `
|
||||
-DartifactId=$($_.BaseName) `
|
||||
-Dversion=1.0 `
|
||||
-Dpackaging=jar `
|
||||
-DlocalRepositoryPath=$repositoryDir
|
||||
}
|
BIN
src/main/resources/static/www.chenxinzhi.top.jks
Normal file
BIN
src/main/resources/static/www.chenxinzhi.top.jks
Normal file
Binary file not shown.
Reference in New Issue
Block a user