...
|
...
|
@@ -6,6 +6,8 @@ import com.yoho.core.dal.datasource.annotation.Database; |
|
|
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
|
|
|
import com.yohobuy.ufo.model.order.common.TabType;
|
|
|
import com.yohoufo.common.alarm.EventBusPublisher;
|
|
|
import com.yohoufo.common.concurrent.lock.RedisLock;
|
|
|
import com.yohoufo.common.concurrent.lock.RedisLockFactory;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
|
...
|
...
|
@@ -21,6 +23,7 @@ import com.yohoufo.order.event.SellerOrderPriceChangeEvent; |
|
|
import com.yohoufo.order.model.dto.*;
|
|
|
import com.yohoufo.order.service.MerchantOrderPaymentService;
|
|
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
|
|
import com.yohoufo.order.service.cache.ExpiredTime;
|
|
|
import com.yohoufo.order.service.proxy.ProductProxyService;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -31,6 +34,7 @@ import java.math.BigDecimal; |
|
|
import java.util.*;
|
|
|
import java.util.concurrent.Callable;
|
|
|
import java.util.concurrent.FutureTask;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* Created by jiexiang.wu on 2018/12/21.
|
...
|
...
|
@@ -49,6 +53,9 @@ public abstract class AbstractSellerAdjustPriceTaskHandler extends AbstractSelle |
|
|
@Autowired
|
|
|
protected ProductProxyService productProxyService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisLockFactory redisLockFactory;
|
|
|
|
|
|
@Override
|
|
|
protected List<FutureTask> getFutureTasks(SellerTaskResult result, SellerTaskDTO<ChangePricePrepareDTO> taskDto) {
|
|
|
ChangePricePrepareDTO cppDto = taskDto.getProcessData();
|
...
|
...
|
@@ -81,6 +88,9 @@ public abstract class AbstractSellerAdjustPriceTaskHandler extends AbstractSelle |
|
|
|
|
|
@Override
|
|
|
public Integer call() throws Exception {
|
|
|
RedisLock skupPriceLock = redisLockFactory.newLock(CacheKeyBuilder.skupPriceLockKey(skupDto.getSkup()), ExpiredTime.SKUP_PRICE_LOCK_SECONDS, TimeUnit.SECONDS);
|
|
|
boolean isSkupPriceLocked = false;
|
|
|
|
|
|
try {
|
|
|
log.info("[{}-{}-{}] handle before sellerOrder:{},before sellerOrderGoods:{},after earnestMoney:{},after income:{}",
|
|
|
uid, taskId, skupDto.getSkup(),
|
...
|
...
|
@@ -88,6 +98,13 @@ public abstract class AbstractSellerAdjustPriceTaskHandler extends AbstractSelle |
|
|
skupDto.getSellerOrderGoods(),
|
|
|
computeResult.getEarnestMoney().getEarnestMoney(),
|
|
|
computeResult.getIncome());
|
|
|
|
|
|
isSkupPriceLocked = skupPriceLock.tryLock();
|
|
|
if(!isSkupPriceLocked) {
|
|
|
log.warn("skup price locked failed before price adjust, skup: {}", skupDto.getSkup());
|
|
|
throw new UfoServiceException(400, "卖家正在调整商品价格,请稍后下单");
|
|
|
}
|
|
|
|
|
|
skupAdjustPriceDBService.update(taskId, salePrice, diffEarnestMoney, computeResult, skupDto);
|
|
|
log.info("[{}-{}-{}] handle success", uid, taskId, skupDto.getSkup());
|
|
|
return skupDto.getSkup();
|
...
|
...
|
@@ -99,6 +116,10 @@ public abstract class AbstractSellerAdjustPriceTaskHandler extends AbstractSelle |
|
|
computeResult.getEarnestMoney().getEarnestMoney(),
|
|
|
computeResult.getIncome(), t);
|
|
|
return null;
|
|
|
} finally {
|
|
|
if (isSkupPriceLocked) {
|
|
|
skupPriceLock.unlock();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|