Joburgess 4 éve
szülő
commit
33e45b1eaf

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -17,6 +17,8 @@ import java.util.Map;
 
 public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrder> {
 
+    StudentPaymentOrder lockOrder(@Param("id") Long id);
+
     /**
      * 查询商品列表
      *

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1467,6 +1467,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		Integer userId = order.getUserId();
 		boolean isOk=order.getStatus().equals(DealStatusEnum.SUCCESS);
 
+		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.lockOrder(order.getId());
+
 		List<StudentPaymentOrder> userOrders = studentPaymentOrderDao.findUserBuyVipGroupOrder(userId, vipGroupId.intValue());
 		Map<DealStatusEnum, List<StudentPaymentOrder>> statusOrdersMap = userOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus));
 		if(!CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.SUCCESS))){
@@ -1474,7 +1476,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			return;
 		}
 
-		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.get(order.getId());
 		if(studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)){
 			return;
 		}

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -698,4 +698,8 @@
             SELECT username_ name ,id_ userId,phone_ phone FROM sys_user
             WHERE id_ = #{search} OR username_ LIKE CONCAT('%',#{search},'%') OR phone_ LIKE CONCAT('%',#{search},'%')
     </select>
+
+    <select id="lockOrder" resultType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
+        ELECT * FROM student_payment_order WHERE id_ = #{id} FOR UPDATE
+    </select>
 </mapper>