|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
import com.usky.dxtop.common.core.domain.model.LoginUser;
|
|
|
import com.usky.dxtop.common.core.page.CommonPage;
|
|
|
import com.usky.dxtop.common.exception.CustomException;
|
|
@@ -41,12 +42,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.Future;
|
|
|
+import java.util.concurrent.FutureTask;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -95,6 +100,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
@Autowired
|
|
|
private ISysConfigService sysConfigService;
|
|
|
|
|
|
+ private Map<String, String> map = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public boolean add(Order order) {
|
|
@@ -201,7 +208,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
msgLog.setExchange(ChargeConsumeConfig.NAME);
|
|
|
msgLog.setRoutingKey(ChargeConsumeConfig.NAME);
|
|
|
msgLog.setMsg(JSON.toJSONString(chargeVo));
|
|
|
- msgLogService.addOrUpdate(msgLog);
|
|
|
+ msgLog.setId(System.currentTimeMillis());
|
|
|
+ msgLog.setCreateTime(new Date());
|
|
|
+ msgLogService.save(msgLog);
|
|
|
chargeVo.setSeq(msgLog.getId());
|
|
|
CorrelationData correlationData = new CorrelationData(msgLog.getId().toString());
|
|
|
rabbitTemplate.convertAndSend(msgLog.getExchange(), msgLog.getRoutingKey(), chargeVo,correlationData);
|
|
@@ -224,12 +233,36 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean isCheckOrder(String orderNumber){
|
|
|
- Order order = one(orderNumber);
|
|
|
- //订单是未支付和支付中需要处理
|
|
|
- return OrderStatus.NO_PAYMENT.getCode().equals(order.getOrderFlag()) || OrderStatus.AWAIT_PAY.getCode().equals(order.getOrderFlag());
|
|
|
+ if (map.putIfAbsent(orderNumber, orderNumber) != null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Order order = one(orderNumber);
|
|
|
+ //订单是未支付和支付中需要处理
|
|
|
+ boolean isCheck = OrderStatus.NO_PAYMENT.getCode().equals(order.getOrderFlag()) || OrderStatus.AWAIT_PAY.getCode().equals(order.getOrderFlag());
|
|
|
+ if (isCheck){
|
|
|
+ //判断是不是游客充值
|
|
|
+ if (null == order.getUserId() || 0 == order.getUserId()){
|
|
|
+ order.setOrderFlag(OrderStatus.COMPLETE.getCode());
|
|
|
+ }else {
|
|
|
+ //调用卡充值api
|
|
|
+ callCardTopApi(order);
|
|
|
+ }
|
|
|
+ this.updateById(order);
|
|
|
+ }
|
|
|
+ return isCheck;
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("订单查询异常"+e);
|
|
|
+ throw new CustomException("订单查询异常");
|
|
|
+ }finally {
|
|
|
+ map.remove(orderNumber);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询交易后处理订单
|
|
|
* @param order
|
|
@@ -270,16 +303,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void paySuccess(Order order){
|
|
|
- if (isCheckOrder(order.getOrderNumber())){
|
|
|
- //判断是不是游客充值
|
|
|
- if (null == order.getUserId() || 0 == order.getUserId()){
|
|
|
- order.setOrderFlag(OrderStatus.COMPLETE.getCode());
|
|
|
- }else {
|
|
|
- //调用卡充值api
|
|
|
- callCardTopApi(order);
|
|
|
- }
|
|
|
- this.updateById(order);
|
|
|
- }
|
|
|
+ isCheckOrder(order.getOrderNumber());
|
|
|
}
|
|
|
|
|
|
|