|
@@ -3,8 +3,12 @@ package com.zhongzheng.modules.top.mall.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
|
+import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
|
|
+import com.zhongzheng.common.utils.SnowflakeIdUtils;
|
|
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
import com.zhongzheng.modules.top.mall.bo.TopStoreAddBo;
|
|
import com.zhongzheng.modules.top.mall.bo.TopStoreAddBo;
|
|
|
import com.zhongzheng.modules.top.mall.bo.TopStoreEditBo;
|
|
import com.zhongzheng.modules.top.mall.bo.TopStoreEditBo;
|
|
|
import com.zhongzheng.modules.top.mall.bo.TopStoreQueryBo;
|
|
import com.zhongzheng.modules.top.mall.bo.TopStoreQueryBo;
|
|
@@ -36,6 +40,8 @@ public class TopStoreServiceImpl extends ServiceImpl<TopStoreMapper, TopStore> i
|
|
|
@Override
|
|
@Override
|
|
|
public TopStoreVo queryById(Long storeId){
|
|
public TopStoreVo queryById(Long storeId){
|
|
|
TopStore db = this.baseMapper.selectById(storeId);
|
|
TopStore db = this.baseMapper.selectById(storeId);
|
|
|
|
|
+ db.setPassword(null);
|
|
|
|
|
+ db.setInitPwd(null);
|
|
|
return BeanUtil.toBean(db, TopStoreVo.class);
|
|
return BeanUtil.toBean(db, TopStoreVo.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -74,27 +80,48 @@ public class TopStoreServiceImpl extends ServiceImpl<TopStoreMapper, TopStore> i
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean insertByAddBo(TopStoreAddBo bo) {
|
|
public Boolean insertByAddBo(TopStoreAddBo bo) {
|
|
|
- if(Validator.isEmpty(bo.getStoreName())||Validator.isEmpty(bo.getPassword())||Validator.isEmpty(bo.getUserName())||Validator.isEmpty(bo.getTelphone())){
|
|
|
|
|
- throw new CustomException("参数缺失");
|
|
|
|
|
|
|
+ if (getOne(new LambdaQueryWrapper<TopStore>().eq(TopStore::getStoreName, bo.getStoreName()).last("limit 1")) != null) {
|
|
|
|
|
+ throw new CustomException("该商户名已被注册");
|
|
|
}
|
|
}
|
|
|
- if (getOne(new LambdaQueryWrapper<TopStore>().eq(TopStore::getUserName, bo.getUserName()).last("limit 1")) != null) {
|
|
|
|
|
- throw new CustomException("该账号已被注册");
|
|
|
|
|
|
|
+ if (getOne(new LambdaQueryWrapper<TopStore>().eq(TopStore::getTelphone, bo.getTelphone()).last("limit 1")) != null) {
|
|
|
|
|
+ throw new CustomException("该手机号已被注册");
|
|
|
}
|
|
}
|
|
|
TopStore add = BeanUtil.toBean(bo, TopStore.class);
|
|
TopStore add = BeanUtil.toBean(bo, TopStore.class);
|
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ String pwd = add.getTelphone().substring(add.getTelphone().length() - 6);
|
|
|
|
|
+ add.setUserName("manager");
|
|
|
|
|
+ add.setPassword(pwd);
|
|
|
add.setInitPwd(add.getPassword());
|
|
add.setInitPwd(add.getPassword());
|
|
|
|
|
+ add.setPassword(SecurityUtils.encryptPassword(add.getPassword()));
|
|
|
|
|
+ add.setTenantId("867735392558919680");//初始按祥粤创建
|
|
|
|
|
+ SnowflakeIdUtils idWorker = new SnowflakeIdUtils(3, 1);
|
|
|
|
|
+ add.setStoreAccount(String.valueOf(idWorker.nextId()));
|
|
|
return this.save(add);
|
|
return this.save(add);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateByEditBo(TopStoreEditBo bo) {
|
|
public Boolean updateByEditBo(TopStoreEditBo bo) {
|
|
|
- if(Validator.isNotEmpty(bo.getUserName())){
|
|
|
|
|
- if (getOne(new LambdaQueryWrapper<TopStore>().ne(TopStore::getStoreId, bo.getStoreId()).eq(TopStore::getUserName, bo.getUserName()).last("limit 1")) != null) {
|
|
|
|
|
- throw new CustomException("该账号已被注册");
|
|
|
|
|
|
|
+ if(Validator.isEmpty(bo.getStoreId())){
|
|
|
|
|
+ throw new CustomException("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(Validator.isNotEmpty(bo.getStoreName())){
|
|
|
|
|
+ if (getOne(new LambdaQueryWrapper<TopStore>().ne(TopStore::getStoreId, bo.getStoreId()).eq(TopStore::getStoreName, bo.getStoreName()).last("limit 1")) != null) {
|
|
|
|
|
+ throw new CustomException("该商户名称已被注册");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(Validator.isNotEmpty(bo.getTelphone())){
|
|
|
|
|
+ TopStore topStore = getOne(new LambdaQueryWrapper<TopStore>().eq(TopStore::getStoreId, bo.getStoreId()));
|
|
|
|
|
+ if(!topStore.getTelphone().equals(bo.getTelphone())){
|
|
|
|
|
+ if (getOne(new LambdaQueryWrapper<TopStore>().ne(TopStore::getStoreId, bo.getStoreId()).eq(TopStore::getTelphone, bo.getTelphone()).last("limit 1")) != null) {
|
|
|
|
|
+ throw new CustomException("该手机号码已被注册");
|
|
|
|
|
+ }
|
|
|
|
|
+ String pwd = bo.getTelphone().substring(bo.getTelphone().length() - 6);
|
|
|
|
|
+ bo.setInitPwd(pwd);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
TopStore update = BeanUtil.toBean(bo, TopStore.class);
|
|
TopStore update = BeanUtil.toBean(bo, TopStore.class);
|
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
@@ -117,4 +144,30 @@ public class TopStoreServiceImpl extends ServiceImpl<TopStoreMapper, TopStore> i
|
|
|
}
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean restorePwd(TopStoreEditBo bo) {
|
|
|
|
|
+ if(Validator.isEmpty(bo.getStoreId())){
|
|
|
|
|
+ throw new CustomException("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ TopStoreVo storeVo = queryById(bo.getStoreId());
|
|
|
|
|
+ LambdaUpdateWrapper<TopStore> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ objectLambdaUpdateWrapper.eq(TopStore::getStoreId, bo.getStoreId());
|
|
|
|
|
+ objectLambdaUpdateWrapper.set(TopStore::getPassword, SecurityUtils.encryptPassword(storeVo.getInitPwd()));
|
|
|
|
|
+ objectLambdaUpdateWrapper.set(TopStore::getUpdateTime, DateUtils.getNowTime());
|
|
|
|
|
+ return this.update(null, objectLambdaUpdateWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updatePwd(TopStoreEditBo bo) {
|
|
|
|
|
+ if(Validator.isEmpty(bo.getStoreId())||Validator.isEmpty(bo.getPassword())){
|
|
|
|
|
+ throw new CustomException("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ TopStoreVo storeVo = queryById(bo.getStoreId());
|
|
|
|
|
+ LambdaUpdateWrapper<TopStore> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
|
|
|
|
+ objectLambdaUpdateWrapper.eq(TopStore::getStoreId, bo.getStoreId());
|
|
|
|
|
+ objectLambdaUpdateWrapper.set(TopStore::getPassword, SecurityUtils.encryptPassword(bo.getPassword()));
|
|
|
|
|
+ objectLambdaUpdateWrapper.set(TopStore::getUpdateTime, DateUtils.getNowTime());
|
|
|
|
|
+ return this.update(null, objectLambdaUpdateWrapper);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|