detail价格计算折扣
This commit is contained in:
parent
eff2d6d630
commit
519bedfc7c
|
|
@ -176,6 +176,8 @@ public class PayServiceImpl implements PayService {
|
|||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
|
||||
.in(TbOrderDetail::getStatus, "unpaid")
|
||||
.setSql(StrUtil.format("price_amount=price*num*{}", orderInfo.getDiscountRatio()))
|
||||
|
||||
.set(TbOrderDetail::getStatus, "closed"));
|
||||
|
||||
//修改主单状态
|
||||
|
|
|
|||
|
|
@ -1599,6 +1599,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getUseType, orderInfo.getUseType())
|
||||
.eq(TbOrderDetail::getStatus, "unpaid")
|
||||
.setSql(StrUtil.format("price_amount=price*num*{}", payDTO.getDiscount()))
|
||||
.set(TbOrderDetail::getStatus, "closed"));
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
|
|
|||
|
|
@ -70,6 +70,31 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
public static<T> T runFunAndTransaction(Supplier<T> supplier, StringRedisTemplate redisTemplate, String lockKey) {
|
||||
try{
|
||||
// 创建线程id, 用作判断
|
||||
String clientId = UUID.randomUUID().toString();
|
||||
// 设置分布式锁
|
||||
boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.MILLISECONDS));
|
||||
int count = 0;
|
||||
while (!lock) {
|
||||
if (count++ > 100) {
|
||||
throw new BadRequestException("系统繁忙, 稍后再试");
|
||||
}
|
||||
Thread.sleep(20);
|
||||
lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, clientId, 30, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
return supplier.get();
|
||||
} catch (RuntimeException e){
|
||||
log.info("执行出错:{}", e.getMessage());
|
||||
throw e;
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally{
|
||||
redisTemplate.delete(lockKey);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, R> R runFunAndRetry(
|
||||
Supplier<R> function,
|
||||
Function<R, Boolean> check, Consumer<R> errFun) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue