Переглянути джерело

1.批量激活码逻辑错误发放错误

yuanliang 1 рік тому
батько
коміт
a7e1102103

+ 10 - 11
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java

@@ -152,17 +152,16 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         Map<Long, String> idPhoneMap = sysUserMapper.selectBatchIds(studentIds).stream()
                 .collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
 
-        for (Long studentId : studentIds) {
-            for (TenantActivationCode tenantActivationCode : tenantActivationCodes) {
-                boolean update = this.lambdaUpdate()
-                        .set(TenantActivationCode::getSendStatus, EActivationCode.SEND.getCode())
-                        .set(TenantActivationCode::getActivationPhone, idPhoneMap.get(studentId))
-                        .eq(TenantActivationCode::getActivationStatus, false)
-                        .eq(TenantActivationCode::getId, tenantActivationCode.getId())
-                        .update();
-                if (!update) {
-                    throw new BizException("激活码已被激活:" + tenantActivationCode.getActivationCode());
-                }
+        for (int i = 0; i < studentIds.size(); i++) {
+            Long studentId = studentIds.get(i);
+            boolean update = this.lambdaUpdate()
+                    .set(TenantActivationCode::getSendStatus, EActivationCode.SEND.getCode())
+                    .set(TenantActivationCode::getActivationPhone, idPhoneMap.get(studentId))
+                    .eq(TenantActivationCode::getActivationStatus, false)
+                    .eq(TenantActivationCode::getId, tenantActivationCodes.get(i).getId())
+                    .update();
+            if (!update) {
+                throw new BizException("激活码已被激活:" + tenantActivationCodes.get(i).getActivationCode());
             }
         }
     }