|
|
@@ -84,9 +84,13 @@ import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.PlatformTransactionManager;
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -162,15 +166,14 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
private TbIndentSmsSendLogService smsSendLogService;
|
|
|
@Autowired
|
|
|
private TbIndentSmsTemplateService smsTemplateService;
|
|
|
-
|
|
|
@Autowired
|
|
|
+ private PlatformTransactionManager transactionManager;
|
|
|
+
|
|
|
+ @Resource
|
|
|
private RedissonClient redissonClient;
|
|
|
|
|
|
private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DateUtils.TIME_PATTERN1);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @Transactional
|
|
|
@Override
|
|
|
public void insertOrder(Long userId, Long shopId, Long goodsId, Integer num, Long skuId, String skuMessage, Integer orderType) {
|
|
|
// 判断当前时间是否在店铺营业范围内
|
|
|
@@ -190,6 +193,9 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
TbOrder order = appOrderDao.selectOne(new QueryWrapper<TbOrder>().eq("user_id", userId).eq("shop_id", shopId).eq("status", 1));
|
|
|
Goods goods = goodsDao.selectById(goodsId);
|
|
|
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
+
|
|
|
+ // 开启编程式事务
|
|
|
+ TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
|
|
|
if (order == null) {
|
|
|
UserEntity userEntity = userDao.selectById(userId);
|
|
|
TbOrder tbOrder = new TbOrder();
|
|
|
@@ -254,6 +260,9 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
tbOrder1.setAddGoodsTime(format);
|
|
|
appOrderDao.updateById(tbOrder1);
|
|
|
}
|
|
|
+
|
|
|
+ // 在锁中提交事务
|
|
|
+ transactionManager.commit(status);
|
|
|
} finally {
|
|
|
lock.unlock();
|
|
|
}
|
|
|
@@ -387,6 +396,10 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
throw new SqxException("无效的订单id");
|
|
|
}
|
|
|
|
|
|
+ if (parentOrder.getIsPay() == 1) {
|
|
|
+ throw new SqxException("当前订单已支付,请勿重复支付!");
|
|
|
+ }
|
|
|
+
|
|
|
// 获取店铺信息
|
|
|
// 注意:调用shopMessageService获取店铺信息,这个service对店铺的抽成比例有特殊处理(历史代码就是如此/(ㄒoㄒ)/~~)
|
|
|
GoodsShop goodsShop = shopMessageService.selectShopId(parentOrder.getShopId());
|