|
|
|
@ -31,15 +31,12 @@ import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.context.ApplicationContext; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
import java.util.concurrent.PriorityBlockingQueue; |
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
public class OrderServiceImpl implements OrderService, ITxTransaction { |
|
|
|
@ -80,9 +77,10 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { |
|
|
|
|
private RedisTemplate redisTemplate; |
|
|
|
|
@Autowired |
|
|
|
|
private ApplicationContext applicationContext; |
|
|
|
|
@Autowired |
|
|
|
|
private ThreadPoolTaskExecutor executor; |
|
|
|
|
|
|
|
|
|
private static final BigDecimal DECIMAL_DISH = new BigDecimal("0.1"); //下单金额计算的偏差值
|
|
|
|
|
private static final ExecutorService EXECUTOR_SERVICE = new ThreadPoolExecutor(5, 10, 0, TimeUnit.MINUTES, new PriorityBlockingQueue<>()); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Order> selectByAdIdAndStatus(String adId, String... status) { |
|
|
|
@ -302,10 +300,10 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate); |
|
|
|
|
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), payType,BigDecimal.ZERO.subtract(order.getTurnover())); |
|
|
|
|
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), payType, BigDecimal.ZERO.subtract(order.getTurnover())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(resultDTO.getCode()==200 && resultDTO.getData()) { |
|
|
|
|
if (resultDTO.getCode() == 200 && resultDTO.getData()) { |
|
|
|
|
//更新订单状态
|
|
|
|
|
receiptOrPayUpdateOrder(order, UserHandleConstants.PAY); |
|
|
|
|
//记录用户操作
|
|
|
|
@ -315,12 +313,12 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { |
|
|
|
|
order.getSellUserId(), order.getBuyUserId(), order.getId()); |
|
|
|
|
//发送手机消息通知
|
|
|
|
|
pushToSingle(order.getSellUserId(), order.getId(), PushEnums.OTC_ORDER_PAY.getPushType()); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
throw new OtcException(OtcEnums.FREEBALANCE_NOT_ENOUGH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (BooleanUtils.isTrue(ad.getBuiltIn())) { |
|
|
|
|
EXECUTOR_SERVICE.execute(() -> applicationContext.getBean(OrderService.class).receipt(order.getSellUserId(), orderId, "123456")); |
|
|
|
|
executor.execute(() -> applicationContext.getBean(OrderService.class).receipt(order.getSellUserId(), orderId, "123456")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -343,8 +341,8 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { |
|
|
|
|
checkOrderCanHandle(order, userId, UserHandleConstants.RECEIPT); |
|
|
|
|
|
|
|
|
|
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDtoByUserId(userId, redisTemplate); |
|
|
|
|
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(),order.getOrderPayType(),order.getTurnover()); |
|
|
|
|
if(resultDTO.getCode()==200 && resultDTO.getData()) { |
|
|
|
|
ResultDTO<Boolean> resultDTO = yyyyfMoneyFeign.resetWallet(yyyfUserDto.getAssessUserId(), order.getOrderPayType(), order.getTurnover()); |
|
|
|
|
if (resultDTO.getCode() == 200 && resultDTO.getData()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新订单状态
|
|
|
|
@ -362,7 +360,7 @@ public class OrderServiceImpl implements OrderService, ITxTransaction { |
|
|
|
|
order.getSellUserId(), order.getBuyUserId(), order.getId()); |
|
|
|
|
//发送手机消息通知
|
|
|
|
|
pushToSingle(order.getBuyUserId(), order.getId(), PushEnums.OTC_ORDER_RECEIPT.getPushType()); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
throw new OtcException(OtcEnums.ERROR_IN_WALLET_CALL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|