提交 8818bbb0 作者: 张小凤

Re(update)

上级 d666307a
package com.mmc.csf.release.commit; package com.mmc.csf.release.commit;
import com.alibaba.fastjson.JSONObject;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.infomation.vo.GrabTheOrderVO;
import com.mmc.csf.release.controller.BaseController; import com.mmc.csf.release.controller.BaseController;
import com.mmc.csf.release.industry.UserPayInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.CodeSignature;
import org.aspectj.lang.reflect.MethodSignature;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -28,6 +40,15 @@ public class NotRepeatSubmitConfig extends BaseController { ...@@ -28,6 +40,15 @@ public class NotRepeatSubmitConfig extends BaseController {
@Autowired @Autowired
private RedissonClient redissonClient; private RedissonClient redissonClient;
@Value("${iuav.omsapp.url}")
private String omsApp;
@Value("${iuav.payment.url}")
private String paymentApp;
@Autowired
private RestTemplate restTemplate;
@Pointcut("@within(notRepeatSubmit)||@annotation(notRepeatSubmit)") @Pointcut("@within(notRepeatSubmit)||@annotation(notRepeatSubmit)")
public void pointcut(NotRepeatSubmit notRepeatSubmit) { public void pointcut(NotRepeatSubmit notRepeatSubmit) {
...@@ -50,6 +71,21 @@ public class NotRepeatSubmitConfig extends BaseController { ...@@ -50,6 +71,21 @@ public class NotRepeatSubmitConfig extends BaseController {
RLock accountUriLock = redissonClient.getLock(accountUriLockKey); RLock accountUriLock = redissonClient.getLock(accountUriLockKey);
boolean tryLock; boolean tryLock;
MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature();
Method method = signature.getMethod();
String name = method.getDeclaringClass().getName();
String[] parameterNames = signature.getParameterNames();
Map<String, Object> map = new HashMap<String, Object>();
Object[] values = proceedingJoinPoint.getArgs();
String[] names = ((CodeSignature) proceedingJoinPoint.getSignature()).getParameterNames();
for (int i = 0; i < names.length; i++) {
map.put(names[i], values[i]);
}
log.info(map + "");
GrabTheOrderVO grabTheOrderVO = (GrabTheOrderVO) map.get("grabTheOrderVO");
//尝试获取分布式锁 //尝试获取分布式锁
//-1为永久 leaseTime 最多等待几秒 上锁以后leaseTime秒自动解锁 //-1为永久 leaseTime 最多等待几秒 上锁以后leaseTime秒自动解锁
...@@ -57,6 +93,11 @@ public class NotRepeatSubmitConfig extends BaseController { ...@@ -57,6 +93,11 @@ public class NotRepeatSubmitConfig extends BaseController {
log.info("tryLock:" + tryLock); log.info("tryLock:" + tryLock);
if (tryLock) { if (tryLock) {
try { try {
String wechatPayOrderNumber = grabTheOrderVO.getWechatPayOrderNumber();
Integer requirementsInfoId = grabTheOrderVO.getRequirementsInfoId();
/* if (wechatPayOrderNumber != null) {
queryUserPayInfo()
}*/
// 查询订单库存判断是否大于0 // 查询订单库存判断是否大于0
// 大于0表示还有库存可以更新订单库存将库存数字减一更新到数据库中 // 大于0表示还有库存可以更新订单库存将库存数字减一更新到数据库中
...@@ -76,4 +117,41 @@ public class NotRepeatSubmitConfig extends BaseController { ...@@ -76,4 +117,41 @@ public class NotRepeatSubmitConfig extends BaseController {
} }
/**
* 通过订单编号查看是否支付成功
*
* @param orderNo
* @return
*/
public UserPayInfoVO queryUserPayInfo(String orderNo, HttpServletRequest request) {
String token = request.getHeader("token");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(orderNo), headers);
ResponseEntity<UserPayInfoVO> exchange = restTemplate.exchange(paymentApp + "/payment/wechat/queryUserPayInfo?orderNo=" + orderNo, HttpMethod.GET, entity, UserPayInfoVO.class);
UserPayInfoVO body = exchange.getBody();
return body;
}
/**
* 删除抢单未支付的金额
*
* @param requirementsInfoId
* @param request
* @return
*/
public ResultBody getDelete(Integer requirementsInfoId, HttpServletRequest request) {
String token = request.getHeader("token");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(requirementsInfoId), headers);
ResponseEntity<ResultBody> exchange = restTemplate.exchange(omsApp + "releaseOrder/getDelete?requirementsInfoId=" + requirementsInfoId, HttpMethod.GET, entity, ResultBody.class);
//UserPayInfoVO body = exchange.getBody();
ResultBody body = exchange.getBody();
return body;
}
} }
...@@ -1319,7 +1319,8 @@ public class RequirementsServiceImpl implements RequirementsService { ...@@ -1319,7 +1319,8 @@ public class RequirementsServiceImpl implements RequirementsService {
RequirementsAmountDO amountDO = new RequirementsAmountDO(requirementsEditVO); RequirementsAmountDO amountDO = new RequirementsAmountDO(requirementsEditVO);
if (requirementsEditVO.getWechatPayOrderNumber() != null) { if (requirementsEditVO.getWechatPayOrderNumber() != null) {
UserPayInfoVO userPayInfoVO = queryUserPayInfo(requirementsEditVO.getWechatPayOrderNumber(), request); UserPayInfoVO userPayInfoVO = queryUserPayInfo(requirementsEditVO.getWechatPayOrderNumber(), request);
if (userPayInfoVO.getTradeState() != "SUCCESS") { String tradeState = userPayInfoVO.getTradeState();
if (!"SUCCESS".equals(tradeState)) {
return ResultBody.error("支付失败,请重新支付"); return ResultBody.error("支付失败,请重新支付");
} }
} }
...@@ -1327,6 +1328,16 @@ public class RequirementsServiceImpl implements RequirementsService { ...@@ -1327,6 +1328,16 @@ public class RequirementsServiceImpl implements RequirementsService {
PublisherWalletFlowVO publisherWalletFlowVO = new PublisherWalletFlowVO(); PublisherWalletFlowVO publisherWalletFlowVO = new PublisherWalletFlowVO();
IsNullConvertZeroUtil.checkIsNull(publisherWalletFlowVO); IsNullConvertZeroUtil.checkIsNull(publisherWalletFlowVO);
ApplyRefundVO applyRefundVO = new ApplyRefundVO(); ApplyRefundVO applyRefundVO = new ApplyRefundVO();
RequirementsInfoDO infoDO = new RequirementsInfoDO(requirementsEditVO);
if (requirementsInfoDO == null) {
return ResultBody.error("只能修改自己发布的服务需求");
}
Integer serviceFlowId = requirementsInfoDO.getServiceFlowId();
if (serviceFlowId != 1) {
return ResultBody.error("只有未抢单的信息才能被修改");
}
//先退款 //先退款
if (requirementsInfoDO.getCashAmount().compareTo(BigDecimal.ZERO) != 0 || if (requirementsInfoDO.getCashAmount().compareTo(BigDecimal.ZERO) != 0 ||
requirementsInfoDO.getSalaryAmount().compareTo(BigDecimal.ZERO) != 0) { requirementsInfoDO.getSalaryAmount().compareTo(BigDecimal.ZERO) != 0) {
...@@ -1350,16 +1361,6 @@ public class RequirementsServiceImpl implements RequirementsService { ...@@ -1350,16 +1361,6 @@ public class RequirementsServiceImpl implements RequirementsService {
applyRefund(applyRefundVO, request.getHeader("token")); applyRefund(applyRefundVO, request.getHeader("token"));
} }
RequirementsInfoDO infoDO = new RequirementsInfoDO(requirementsEditVO);
if (requirementsInfoDO == null) {
return ResultBody.error("只能修改自己发布的服务需求");
}
Integer serviceFlowId = requirementsInfoDO.getServiceFlowId();
if (serviceFlowId != 1) {
return ResultBody.error("只有未抢单的信息才能被修改");
}
//用户钱包信息接口 //用户钱包信息接口
ResultBody resultBody = getCurrentUserPayWalletInfo(request); ResultBody resultBody = getCurrentUserPayWalletInfo(request);
GetOrderNumberDTO orderNumberDTO = new GetOrderNumberDTO(); GetOrderNumberDTO orderNumberDTO = new GetOrderNumberDTO();
...@@ -2377,9 +2378,13 @@ public class RequirementsServiceImpl implements RequirementsService { ...@@ -2377,9 +2378,13 @@ public class RequirementsServiceImpl implements RequirementsService {
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token); headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(orderNo), headers); HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(orderNo), headers);
ResponseEntity<UserPayInfoVO> exchange = restTemplate.exchange(paymentApp + "/payment/wechat/queryUserPayInfo?orderNo=" + orderNo, HttpMethod.GET, entity, UserPayInfoVO.class); ResponseEntity<Object> exchange = restTemplate.exchange(paymentApp + "/payment/wechat/queryUserPayInfo?orderNo=" + orderNo, HttpMethod.GET, entity, Object.class);
UserPayInfoVO body = exchange.getBody(); Object body = exchange.getBody();
return body; String s = JSONObject.toJSONString(body);
UserPayInfoVO userPayInfoVO = JSONObject.parseObject(s, UserPayInfoVO.class);
System.out.println(userPayInfoVO);
// UserPayInfoVO body = exchange.getBody();
return userPayInfoVO;
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论