zouxuan hace 1 año
padre
commit
81425e16a7

+ 2 - 18
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/TenantActivationCodeController.java

@@ -165,30 +165,14 @@ public class TenantActivationCodeController extends BaseController {
     public HttpResponseResult<Boolean> sendCancel(@RequestParam("id") Long id) {
         TenantInfo tenantInfo = getTenantInfo();
         TenantActivationCode activationCode = tenantActivationCodeService.getById(id);
-        if (activationCode == null || !tenantInfo.getId().equals(activationCode.getTenantId())) {
-            throw new BizException("激活码不存在");
-        }
-        boolean update = tenantActivationCodeService.lambdaUpdate()
-                .set(TenantActivationCode::getSendStatus, EActivationCode.WAIT)
-                .set(TenantActivationCode::getActivationPhone, "")
-                .eq(TenantActivationCode::getId, id)
-                .eq(TenantActivationCode::getActivationStatus, false)
-                .eq(TenantActivationCode::getSendStatus, EActivationCode.SEND)
-                .update();
-        if (!update) {
-            throw new BizException("激活码已经激活");
-        }
-        Map<Long, String> receivers = new HashMap<>(1);
-        receivers.put(activationCode.getId(), activationCode.getId().toString());
-        tenantActivationCodeService.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
+        tenantActivationCodeService.sendCancel(tenantInfo, activationCode);
         return succeed();
     }
 
     @ApiOperation(value = "批量激活码发放取消", notes = "传入 激活码的ID")
     @PostMapping("/batchSendCancel")
     public HttpResponseResult<Boolean> batchSendCancel(@RequestParam("ids") String ids) {
-        TenantInfo tenantInfo = getTenantInfo();
-        tenantActivationCodeService.batchSendCancel(tenantInfo, ids);
+        tenantActivationCodeService.batchSendCancel(getTenantInfo(), ids);
         return succeed();
     }
 

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/SysUserService.java

@@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.service;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 
 import java.util.List;
@@ -10,6 +11,8 @@ import java.util.Map;
 
 public interface SysUserService{
 
+    SysUserMapper getDao();
+
     Long getUserId();
 
     SysUser getUser();

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantActivationCodeService.java

@@ -9,6 +9,7 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
 import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Map;
@@ -84,6 +85,9 @@ public interface TenantActivationCodeService extends IService<TenantActivationCo
 
     void resend(String code, Long userId, Long tenantId, Long tenantAlbumPurchaseId);
 
+    @Transactional(rollbackFor = Exception.class)
+    void sendCancel(TenantInfo tenantInfo, TenantActivationCode activationCode);
+
     void batchSendCancel(TenantInfo tenantInfo, String ids);
 
     void batchResend(TenantInfo tenantInfo, Long tenantAlbumPurchaseId, List<String> activationCodeList, List<Long> studentIdList);

+ 6 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MemberPriceSettingsServiceImpl.java

@@ -131,7 +131,7 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
         UserVipInfoVo userVipInfoVo = getUserVipInfoVo(vipCardRecord);
         //会员购买消息推送
         if (messageFlag) {
-            authSend(userVipInfoVo.getUserId(), DateUtil.format(vipCardRecord.getEndTime(), DateUtil.DEFAULT_PATTERN), orderDetailVo.getOrderClient());
+            authSend(userVipInfoVo.getUserId(), userVipInfoVo.getPhone(), DateUtil.format(vipCardRecord.getEndTime(), DateUtil.DEFAULT_PATTERN), orderDetailVo.getOrderClient());
         }
     }
 
@@ -221,7 +221,7 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
         getUserVipInfoVo(vipCardRecord);
 
         // 发消息
-        sendAddVipMessage(vipSubmitReq.getUserId(),client,vipSubmitReq.getTimes(),vipSubmitReq.getType(),vipSubmitReq.getReason());
+        sendAddVipMessage(vipSubmitReq.getUserId(),sysUser.getPhone(),client,vipSubmitReq.getTimes(),vipSubmitReq.getType(),vipSubmitReq.getReason());
 
         return true;
     }
@@ -299,10 +299,10 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
 
     }
 
-    private void sendAddVipMessage(Long userId, ClientEnum client, Integer times, PeriodEnum type, String reason) {
+    private void sendAddVipMessage(Long userId,String phone, ClientEnum client, Integer times, PeriodEnum type, String reason) {
         try {
             Map<Long, String> receivers = new HashMap<>();
-            receivers.put(userId, userId.toString());
+            receivers.put(userId, phone);
             Student student = studentService.getById(userId);
             if (client.equals(ClientEnum.STUDENT) && student != null && student.getTenantId() != null && student.getTenantId() >0) {
                 try {
@@ -346,9 +346,9 @@ public class MemberPriceSettingsServiceImpl extends ServiceImpl<MemberPriceSetti
 
 
     // 发送会员购买消息推送
-    private void authSend(Long userId, String param1,ClientEnum clientEnum) {
+    private void authSend(Long userId,String phone, String param1,ClientEnum clientEnum) {
         Map<Long, String> receivers = new HashMap<>();
-        receivers.put(userId, userId.toString());
+        receivers.put(userId, phone);
 
         // 判断是否是机构学生 机构学生推送走另一个
         Student student = studentService.getById(userId);

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -1191,7 +1191,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         }
         // 推送学生
         Map<Long, String> studentReceivers = new HashMap<>(1);
-        studentReceivers.put(studentId, studentId.toString());
+        studentReceivers.put(studentId,student.getPhone());
 
         try {
             Student studentInfo = studentService.getById(studentId);

+ 5 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -570,6 +570,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         if (student.getTenantId() == null || student.getTenantId() == -1) {
             return;
         }
+        SysUser sysUser = sysUserFeignService.queryUserById(student.getUserId());
+        if (sysUser == null) {
+            return;
+        }
         TenantInfo tenantInfo = tenantInfoService.getById(student.getTenantId());
         if (tenantInfo == null) {
             return;
@@ -579,7 +583,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
             return;
         }
         Map<Long, String> receivers = new HashMap<>();
-        receivers.put(student.getUserId(), student.getUserId().toString());
+        receivers.put(student.getUserId(), sysUser.getPhone());
         try {
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_STUDENT_CHANGE,
                     receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(),tenantInfo.getName(),newTenantInfo.getName());

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/SysUserServiceImpl.java

@@ -37,6 +37,12 @@ public class SysUserServiceImpl implements SysUserService {
 
     @Resource
     private SysUserContractRecordService sysUserContractRecordService;
+
+    @Override
+    public SysUserMapper getDao() {
+        return sysUserMapper;
+    }
+
     @Override
     public Long getUserId() {
         return Optional.ofNullable(sysUserFeignService.queryUserInfo()).

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

@@ -5,13 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.biz.dal.dao.StudentDao;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
-import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantActivationCodeMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumPurchaseMapper;
 import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper;
@@ -51,7 +51,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
     private StudentDao studentDao;
 
     @Autowired
-    private SysUserMapper sysUserMapper;
+    private SysUserService sysUserService;
 
     @Autowired
     private TenantAlbumPurchaseMapper tenantAlbumPurchaseMapper;
@@ -150,7 +150,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         }
 
         List<Long> studentIds = students.stream().map(Student::getUserId).collect(Collectors.toList());
-        Map<Long, String> idPhoneMap = sysUserMapper.selectBatchIds(studentIds).stream()
+        Map<Long, String> idPhoneMap = sysUserService.getDao().selectBatchIds(studentIds).stream()
                 .collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
 
         for (int i = 0; i < studentIds.size(); i++) {
@@ -172,8 +172,8 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
 
     private void sendActivationCodeMessage(Long userId,String phone) {
 
-        Map<Long, String> receivers = new HashMap<>();
-        receivers.put(userId, userId.toString());
+        Map<Long, String> receivers = new HashMap<>(1);
+        receivers.put(userId, phone);
         try {
             String url = sysMessageService.selectConfigUrl(MessageTypeEnum.TENANT_SEND_CODE.getCode());
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_SEND_CODE,
@@ -211,7 +211,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         if (code == null) {
             throw new BizException("激活码不存在");
         }
-        SysUser sysUser = sysUserMapper.selectById(studentId);
+        SysUser sysUser = sysUserService.getDao().selectById(studentId);
         if (Boolean.TRUE.equals(code.getActivationStatus()) || (EActivationCode.SEND.equals(code.getSendStatus()) &&
                 !sysUser.getPhone().equals(code.getActivationPhone()))) {
             throw new BizException("激活码已经被使用");
@@ -263,7 +263,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         if(code == null || !code.getTenantId().equals(tenantId)) {
             throw new BizException("激活码不存在");
         }
-        SysUser sysUser = sysUserMapper.selectById(student.getUserId());
+        SysUser sysUser = sysUserService.getDao().selectById(student.getUserId());
         if(!sysUser.getPhone().equals(code.getActivationPhone())) {
             // 该激活码未指定为当前学生使用
             throw new BizException("激活码不存在");
@@ -319,7 +319,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             throw new BizException("激活码已经被使用");
         }
 
-        SysUser sysUser = sysUserMapper.selectById(userId);
+        SysUser sysUser = sysUserService.getDao().selectById(userId);
         if (sysUser == null) {
             throw new BizException("用户不存在");
         }
@@ -327,13 +327,33 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         this.updateById(one);
         TenantInfo tenantInfo = tenantInfoService.getById(tenantId);
         Map<Long, String> receivers = new HashMap<>(1);
-        receivers.put(userId, userId.toString());
+        receivers.put(userId, sysUser.getPhone());
         this.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
         this.sendActivationCodeMessage(userId,sysUser.getPhone());
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
+    public void sendCancel(TenantInfo tenantInfo, TenantActivationCode activationCode) {
+        boolean update = this.lambdaUpdate()
+                .set(TenantActivationCode::getSendStatus, EActivationCode.WAIT)
+                .set(TenantActivationCode::getActivationPhone, "")
+                .eq(TenantActivationCode::getId, activationCode.getId())
+                .eq(TenantActivationCode::getActivationStatus, false)
+                .eq(TenantActivationCode::getSendStatus, EActivationCode.SEND)
+                .update();
+        if (!update) {
+            throw new BizException("激活码已经激活");
+        }
+        com.yonge.cooleshow.auth.api.entity.SysUser sysUser = sysUserService.findUserByPhone(activationCode.getActivationPhone());
+        if (sysUser != null) {
+            Map<Long, String> receivers = new HashMap<>(1);
+            receivers.put(sysUser.getId(), activationCode.getActivationPhone());
+            this.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
+        }
+    }
+    @Transactional(rollbackFor = Exception.class)
+    @Override
     public void batchSendCancel(TenantInfo tenantInfo, String ids) {
         List<Long> idList = Arrays.stream(ids.split(",")).map(Long::valueOf).distinct().collect(Collectors.toList());
         Collection<TenantActivationCode> tenantActivationCodes = this.listByIds(idList);
@@ -347,17 +367,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             throw new BizException("无可撤回的激活码");
         }
 
-        this.lambdaUpdate()
-                .set(TenantActivationCode::getSendStatus, EActivationCode.WAIT)
-                .set(TenantActivationCode::getActivationPhone, "")
-                .in(TenantActivationCode::getId, idList)
-                .eq(TenantActivationCode::getActivationStatus, false)
-                .eq(TenantActivationCode::getSendStatus, EActivationCode.SEND)
-                .eq(TenantActivationCode::getTenantId,tenantInfo.getId())
-                .update();
-        //转换map
-        Map<Long, String> receivers = idList.stream().collect(Collectors.toMap(Function.identity(), String::valueOf));
-        this.sendCancelActivationCodeMessage(receivers,tenantInfo.getName());
+        this.sendCancel(tenantInfo, tenantActivationCodes.iterator().next());
     }
 
     @Transactional(rollbackFor = Exception.class)
@@ -384,7 +394,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             throw new BizException("可发激活码的数量小于学生的数量");
         }
 
-        List<SysUser> sysUsers = sysUserMapper.selectBatchIds(studentIdList);
+        List<SysUser> sysUsers = sysUserService.getDao().selectBatchIds(studentIdList);
         Map<Long, String> mapPhoneById = sysUsers.stream().collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
 
         List<TenantActivationCode> updates = new ArrayList<>();

+ 6 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumServiceImpl.java

@@ -358,6 +358,11 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
 
     private void sendMsg(UserOrderDetailVo userOrderDetailVo) {
         try {
+            SysUser user = sysUserFeignService.queryUserById(userOrderDetailVo.getUserId());
+
+            if (user == null) {
+                return;
+            }
             Long userId = userOrderDetailVo.getUserId();
 
             // 查询机构专辑信息
@@ -376,7 +381,7 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
 
 
             Map<Long, String> receivers = new HashMap<>();
-            receivers.put(userId, userId.toString());
+            receivers.put(userId, user.getPhone());
 
             if (userOrderDetailVo.getOrderClient().equals(ClientEnum.STUDENT)) {
                 Student student = studentService.getById(userId);

+ 5 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java

@@ -460,12 +460,16 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 
 
     private void temporarySend(Long userId,Long tenantAlbumId) {
+        SysUser sysUser = sysUserFeignService.queryUserById(userId);
+        if (null == sysUser) {
+            return;
+        }
         TenantAlbum tenantAlbum = tenantAlbumService.getById(tenantAlbumId);
         if (tenantAlbum == null) {
             return;
         }
         Map<Long, String> receivers = new HashMap<>();
-        receivers.put(userId, userId.toString());
+        receivers.put(userId, sysUser.getPhone());
 
         try {
             String url = sysMessageService.selectConfigUrl(MessageTypeEnum.TENANT_ALBUM_EXPIRE.getCode());

+ 3 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/VipCardRecordServiceImpl.java

@@ -209,7 +209,7 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
             //发送消息
             //发送消息
             CompletableFuture.runAsync(() -> {
-                expireSend(record.getUserId(), record.getClientType());
+                expireSend(record.getUserId(),record.getPhone(), record.getClientType());
             });
             record.setMsgStatus(2);
             record.setUpdateTime(new Date());
@@ -254,9 +254,9 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
     }
 
     // 发送会员到期消息推送
-    private void expireSend(Long userId,ClientEnum userType) {
+    private void expireSend(Long userId,String phone,ClientEnum userType) {
         Map<Long, String> receivers = new HashMap<>();
-        receivers.put(userId, userId.toString());
+        receivers.put(userId, phone);
         Student student = studentService.getById(userId);
         if (userType.equals(ClientEnum.STUDENT) && student != null  && student.getTenantId() != null && student.getTenantId() >0) {
             try {

+ 1 - 2
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantActivationCodeController.java

@@ -186,8 +186,7 @@ public class TenantActivationCodeController extends BaseController {
     @ApiOperation(value = "批量激活码发放取消", notes = "传入 激活码的ID")
     @PostMapping("/batchSendCancel")
     public HttpResponseResult<Boolean> batchSendCancel(@RequestParam("ids") String ids) {
-        TenantInfo tenantInfo = getTenantInfo();
-        tenantActivationCodeService.batchSendCancel(tenantInfo, ids);
+        tenantActivationCodeService.batchSendCancel(getTenantInfo(), ids);
         return succeed();
     }