Commit 84360ed7 authored by 33's avatar 33

优化代码,修复隐藏BUG

parent aa10f76f
...@@ -12,13 +12,12 @@ import com.fzm.common.service.AdminService; ...@@ -12,13 +12,12 @@ import com.fzm.common.service.AdminService;
import com.fzm.common.service.UserService; import com.fzm.common.service.UserService;
import com.fzm.common.utils.JwtUtil; import com.fzm.common.utils.JwtUtil;
import com.fzm.common.utils.RedisUtil; import com.fzm.common.utils.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -28,11 +27,13 @@ import java.util.Date; ...@@ -28,11 +27,13 @@ import java.util.Date;
* @author tangtuo * @author tangtuo
* @date 2021/7/13 14:30 * @date 2021/7/13 14:30
*/ */
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AuthenticationInterceptor implements HandlerInterceptor { public class AuthenticationInterceptor implements HandlerInterceptor {
private final RedisUtil redisUtil; @Resource
private final UserService userService; private RedisUtil redisUtil;
private final AdminService adminService; @Resource
private UserService userService;
@Resource
private AdminService adminService;
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
......
...@@ -39,6 +39,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; ...@@ -39,6 +39,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -66,27 +67,32 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper, ...@@ -66,27 +67,32 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
private final CopyrightOwnerService copyrightOwnerService; private final CopyrightOwnerService copyrightOwnerService;
private final UserService userService; private final UserService userService;
private final AuthPersonService authPersonService; private final AuthPersonService authPersonService;
private final NftService nftService;
private final ObsUtil obsUtil; private final ObsUtil obsUtil;
private final ThreadPoolTaskExecutor threadPoolTaskExecutor; private final ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final OpusCategoryService opusCategoryService; private final OpusCategoryService opusCategoryService;
private final CopyrightProperties copyrightProperties; private final CopyrightProperties copyrightProperties;
private final Redisson redisson;
private final DraftService draftService; private final DraftService draftService;
private final OrderService orderService;
private final WxPayService wxPayService;
private final NotifyPublisher notifyPublisher; private final NotifyPublisher notifyPublisher;
@Resource
private NftService nftService;
@Resource
private OrderService orderService;
@Resource
private WxPayService wxPayService;
@Resource
private Redisson redisson;
@Override @Override
public Integer submit(CopyrightDTO copyrightDTO) { public Integer submit(CopyrightDTO copyrightDTO) {
// 判断此nft是否属于当前登录用户所有 // 判断此nft是否属于当前登录用户所有
Nft nft = nftService.getByNftHash(copyrightDTO.getNftHash()); Nft nft = nftService.getByNftHash(copyrightDTO.getNftHash());
User user = userService.getUserByToken(); Integer userId = LoginUserInfo.getLoginUser().getUserId();
if (nft == null || !nft.getUserId().equals(user.getId())) { if (nft == null || !nft.getUserId().equals(userId)) {
throw GlobalException.newException(ResultCode.FAILED, "请先确认此nft的有效性"); throw GlobalException.newException(ResultCode.FAILED, "请先确认此nft的有效性");
} }
AuthPerson authPerson = authPersonService.getByUserId(user.getId()); AuthPerson authPerson = authPersonService.getByUserId(userId);
if (authPerson == null) { if (authPerson == null) {
throw GlobalException.newException(ResultCode.UNAUTHORIZED, "申请人尚未实名认证"); throw GlobalException.newException(ResultCode.UNAUTHORIZED, "申请人尚未实名认证");
} }
...@@ -99,7 +105,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper, ...@@ -99,7 +105,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
CopyrightApply copyrightApply = new CopyrightApply(copyrightDTO); CopyrightApply copyrightApply = new CopyrightApply(copyrightDTO);
// 首次提交,登记状态为待支付 // 首次提交,登记状态为待支付
copyrightApply.setRegisterState(CopyrightApplyState.TO_BE_PAY.getCode()); copyrightApply.setRegisterState(CopyrightApplyState.TO_BE_PAY.getCode());
copyrightApply.setUserId(user.getId()); copyrightApply.setUserId(userId);
copyrightApply.setApplyName(authPerson.getName()); copyrightApply.setApplyName(authPerson.getName());
copyrightApply.setApplyTime(new Date()); copyrightApply.setApplyTime(new Date());
try { try {
......
...@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
...@@ -41,9 +42,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements ...@@ -41,9 +42,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
private final SnowflakeUtil snowflakeUtil; private final SnowflakeUtil snowflakeUtil;
private final RabbitTemplate rabbitTemplate; private final RabbitTemplate rabbitTemplate;
private final OrderMapper orderMapper; private final OrderMapper orderMapper;
private final WxPayService wxPayService;
private final ChargeService chargeService; private final ChargeService chargeService;
@Resource
private WxPayService wxPayService;
@Override @Override
public Order getByPaySceneAndProductId(Integer payScene, Integer productId, Integer orderStatus) { public Order getByPaySceneAndProductId(Integer payScene, Integer productId, Integer orderStatus) {
QueryWrapper<Order> queryWrapper = new QueryWrapper<>(); QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
......
...@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service; ...@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -56,18 +57,20 @@ import java.util.concurrent.TimeUnit; ...@@ -56,18 +57,20 @@ import java.util.concurrent.TimeUnit;
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class WxPayServiceImpl implements WxPayService { public class WxPayServiceImpl implements WxPayService {
private final CloseableHttpClient httpClient; private final CloseableHttpClient httpClient;
private final WxPayProperties wxPayProperties; private final WxPayProperties wxPayProperties;
private final PrivateKey wxPrivateKey; private final PrivateKey wxPrivateKey;
private final OrderService orderService; private final OrderService orderService;
private final Redisson redisson;
private final PaymentService paymentService; private final PaymentService paymentService;
private final RabbitTemplate rabbitTemplate; private final RabbitTemplate rabbitTemplate;
private final SnowflakeUtil snowflakeUtil; private final SnowflakeUtil snowflakeUtil;
private final RefundService refundService;
private final SmsService smsService; private final SmsService smsService;
@Resource
private Redisson redisson;
@Resource
private RefundService refundService;
public Map<String, Object> payJsapi(JsapiPayDto jsapiPayDto) throws Exception { public Map<String, Object> payJsapi(JsapiPayDto jsapiPayDto) throws Exception {
RLock lock = redisson.getLock("pay-" + jsapiPayDto.getOrderId()); RLock lock = redisson.getLock("pay-" + jsapiPayDto.getOrderId());
if (!lock.tryLock(10, TimeUnit.SECONDS)) { if (!lock.tryLock(10, TimeUnit.SECONDS)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment