uniapp 时间戳转换
commit
9326a31489
|
@ -1,6 +1,7 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.promoter;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
|
@ -115,11 +116,12 @@ public class PromoterController {
|
|||
}
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入推广员")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
})
|
||||
// @Parameters({
|
||||
// @Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
// @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
// })
|
||||
// @PreAuthorize("@ss.hasPermission('system:user:import')")
|
||||
@TenantIgnore
|
||||
public CommonResult<PromoterImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<PromoterImportExcelVO> list = ExcelUtils.read(file, PromoterImportExcelVO.class);
|
||||
|
|
|
@ -22,10 +22,12 @@ import javax.annotation.Resource;
|
|||
import javax.validation.Validator;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.promoter.vo.*;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.promoter.PromoterDO;
|
||||
|
@ -179,6 +181,12 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
if (CollUtil.isEmpty(importUsers)) {
|
||||
throw exception(PROMOTER_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
Set<String> collect = importUsers.stream().map(PromoterImportExcelVO::getMobile).collect(Collectors.toSet());
|
||||
List<MemberUserDO> list = memberUserService.getByMobileList(collect);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<String> collect1 = list.stream().map(MemberUserDO::getMobile).collect(Collectors.toList());
|
||||
throw new ServiceException(200, "电话号码:" + collect1 + "重复");
|
||||
}
|
||||
PromoterImportRespVO respVO = PromoterImportRespVO.builder().createUsernames(new ArrayList<>())
|
||||
.updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
|
||||
List<DeptRespDTO> deptRespDTOList = deptApi.getDeptList();
|
||||
|
@ -191,20 +199,20 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
return;
|
||||
}
|
||||
//判断手机号是否注册
|
||||
MemberUserDO memberUserDO = memberUserService.getUserByMobile(importUser.getMobile());
|
||||
if (memberUserDO == null) {
|
||||
// MemberUserDO memberUserDO = memberUserService.getUserByMobile(importUser.getMobile());
|
||||
// if (memberUserDO == null) {
|
||||
//创建用户
|
||||
memberUserDO = new MemberUserDO();
|
||||
MemberUserDO memberUserDO = new MemberUserDO();
|
||||
memberUserDO.setNickname(importUser.getNickName());
|
||||
memberUserDO.setMobile(importUser.getMobile());
|
||||
memberUserDO.setPassword(importUser.getMobile().substring(importUser.getMobile().length() - 6));
|
||||
memberUserDO.setStatus(0);
|
||||
memberUserService.createUserIfAbsent(importUser.getMobile(), importUser.getNickName(), getClientIP());
|
||||
}
|
||||
MemberUserDO userIfAbsent = memberUserService.createUserIfAbsent(importUser.getMobile(), importUser.getNickName(), getClientIP());
|
||||
// }
|
||||
// 插入
|
||||
PromoterDO promoter = new PromoterDO();
|
||||
promoter.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId());
|
||||
promoter.setUserId(memberUserDO.getId());
|
||||
promoter.setUserId(userIfAbsent.getId());
|
||||
promoter.setCreateTime(LocalDateTime.now());
|
||||
Long count = promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId, memberUserDO.getId()));
|
||||
if (count > 0) {
|
||||
|
@ -225,8 +233,6 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PromoterDO getPromoterDOByUserId(Long userId) {
|
||||
return promoterMapper.selectOne(Wrappers.<PromoterDO>lambdaQuery().eq(PromoterDO::getUserId, userId).last("LIMIT 1"));
|
||||
|
|
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
|||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 会员用户 Service 接口
|
||||
|
@ -139,4 +140,6 @@ public interface MemberUserService {
|
|||
|
||||
|
||||
Long promoterOrderCount(AppUserInfoReqDTO reqVO);
|
||||
|
||||
List<MemberUserDO> getByMobileList(Set<String> collect);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
|||
import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi;
|
||||
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
|
||||
import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
@ -27,6 +28,7 @@ import java.io.InputStream;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
|
@ -103,7 +105,7 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||
user.setMobile(mobile);
|
||||
user.setNickname(realName);
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(encodePassword(mobile.substring(5,11))); // 加密密码
|
||||
user.setPassword(encodePassword(mobile.substring(mobile.length() - 6))); // 加密密码
|
||||
user.setRegisterIp(registerIp);
|
||||
user.setPromoterId(promoterId);
|
||||
user.setTenantId(TenantContextHolder.getRequiredTenantId());
|
||||
|
@ -261,4 +263,11 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|||
|
||||
return memberUserMapper.promoterOrderCount(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberUserDO> getByMobileList(Set<String> collect) {
|
||||
LambdaQueryWrapper<MemberUserDO> qw = new LambdaQueryWrapper();
|
||||
qw.in(MemberUserDO::getMobile,collect);
|
||||
return memberUserMapper.selectList(qw);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue