yangdamao il y a 10 mois
Parent
commit
752ca6e7fa

+ 14 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserController.java

@@ -1,15 +1,19 @@
 package com.zhongzheng.controller.user;
 
 import cn.afterturn.easypoi.excel.entity.ExportParams;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.zhongzheng.common.annotation.Log;
 import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.common.utils.poi.EasyPoiUtil;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.alisms.service.IAliSmsService;
+import com.zhongzheng.modules.top.order.bo.TopOrderQuestionImportBo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import com.zhongzheng.modules.user.service.IUserService;
@@ -212,6 +216,16 @@ public class UserController extends BaseController {
         return util.exportEasyExcel(util.exportEasyData(errorList), "导出失败导入用户"+timeStr);
     }
 
+    @ApiOperation("重置学员手机号码")
+    @PostMapping("/export/reset/tel")
+    public AjaxResult<Void> exporResetData(MultipartFile file){
+        List<UserTelImportExportBo> questionImportBos = EasyPoiUtil.importExcel(file,0,1,UserTelImportExportBo.class);
+        if (CollectionUtils.isEmpty(questionImportBos)){
+            throw new CustomException("导入文件格式不正确或文件为空,请检查文件!");
+        }
+        iUserService.exporResetData(questionImportBos);
+        return AjaxResult.success();
+    }
 
     @ApiOperation("批量获取用户ID")
     @Log(title = "批量获取用户ID", businessType = BusinessType.IMPORT)

+ 33 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -2233,6 +2233,39 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         return getOne(new LambdaQueryWrapper<User>().eq(User::getGzhOpenId,openId).last("limit 1"));
     }
 
+    @Override
+    public void exporResetData(List<UserTelImportExportBo> bos) {
+        List<String> idCards = bos.stream().map(item -> EncryptHandler.encrypt(item.getIdCard())).collect(Collectors.toList());
+        List<User> userList = list(new LambdaQueryWrapper<User>()
+                .in(User::getIdCard, idCards));
+        if (CollectionUtils.isEmpty(userList)){
+            return;
+        }
+        //先重置在修改
+        userList.forEach(x -> x.setTelphone(getTelPhone()));
+        updateBatchById(userList);
+
+        userList.forEach(x -> {
+            String s = EncryptHandler.decryptTwo(x.getIdCard());
+            if (bos.stream().anyMatch(y -> y.getIdCard().equals(s))){
+                UserTelImportExportBo exportBo = bos.stream().filter(k -> k.getIdCard().equals(s)).findFirst().orElse(null);
+                if (ObjectUtils.isNotNull(exportBo)){
+                    x.setTelphone(exportBo.getTelphone());
+                }
+            }
+        });
+        updateBatchById(userList);
+    }
+
+    private String getTelPhone(){
+        String mobile = TelPhoneUtils.createMobile();
+        int count = count(new LambdaQueryWrapper<User>().eq(User::getIdCard, EncryptHandler.encrypt(mobile)));
+        if (count > 0){
+            getTelPhone();
+        }
+        return mobile;
+    }
+
     @Override
     public Map<String, Object> accountLogin(UserAppAccountLoginBo bo) {
         if(Validator.isEmpty(bo.getAccount())){

+ 28 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserTelImportExportBo.java

@@ -0,0 +1,28 @@
+package com.zhongzheng.modules.user.bo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * 客户端用户添加对象 user
+ *
+ * @author ruoyi
+ * @date 2021-06-08
+ */
+@Data
+@ApiModel("客户端导入用户添加对象")
+public class UserTelImportExportBo {
+
+    /** 身份证号 */
+    @Excel(name = "身份证号码")
+    @ApiModelProperty("身份证号")
+    private String idCard;
+    /** 手机号码 */
+    @Excel(name = "手机号码")
+    @ApiModelProperty("手机号码")
+    private String telphone;
+
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserService.java

@@ -174,4 +174,6 @@ public interface IUserService extends IService<User> {
 	Integer getBusinessPhotoSign(Long orderGoodsId);
 
 	User getUserByGzhOpenId(String openId);
+
+	void exporResetData(List<UserTelImportExportBo> bos);
 }