添加验证

master
LegnaYet 6 years ago
parent 9501cb4759
commit f031fe02d5

@ -82,8 +82,8 @@ public class StoreStaffController extends BaseController {
@ResponseBody
public Map<String, Object> addStaff(PoiStoreStaffVO poiStoreStaffVO) {
try {
poiStoreStaffService.addStaff(poiStoreStaffVO);
return success();
String code = poiStoreStaffService.addStaff(poiStoreStaffVO);
return data(code);
} catch (Exception e) {
log.error("获取店铺人员", e);
return fail();

@ -28,6 +28,7 @@ import com.kiisoo.ic.system.mapper.PrivilageUserDOMapper;
import com.kiisoo.ic.system.service.PrivilageAccountService;
import com.kiisoo.ic.system.service.PrivilageUserRoleService;
import com.kiisoo.ic.system.service.PrivilageUserService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
@ -231,12 +232,33 @@ public class PoiStoreStaffService {
*
* @param poiStoreStaffVO
*/
public int addStaff(PoiStoreStaffVO poiStoreStaffVO) throws Exception {
public String addStaff(PoiStoreStaffVO poiStoreStaffVO) throws Exception {
String staffCode = poiStoreStaffVO.getStaffCode();
String mobil = poiStoreStaffVO.getMobil();
QueryWrapper<PoiStoreStaff> staffQw = new QueryWrapper<>();
staffQw.eq("staff_code", staffCode).eq("status", "1");
List<PoiStoreStaff> staffs = poiStoreStaffDOMapper.selectList(staffQw);
if (CollectionUtils.isNotEmpty(staffs)){
return "0002";
}
QueryWrapper<PrivilageUserDO> mobileUserQw = new QueryWrapper<>();
mobileUserQw.eq("mobil",mobil).eq("status", "1");
List<PrivilageUserDO> mobileUsers = privilageUserDOMapper.selectList(mobileUserQw);
if (CollectionUtils.isNotEmpty(mobileUsers)){
return "0003";
}
QueryWrapper<PrivilageAccountDO> loginUserQw = new QueryWrapper<>();
loginUserQw.eq("login",mobil).eq("type", "1").eq("status", "1");
List<PrivilageAccountDO> loginUsers = privilageAccountDOMapper.selectList(loginUserQw);
if (CollectionUtils.isNotEmpty(loginUsers)){
return "0004";
}
//添加一个用户
PrivilageUserDO privilageUserDO = new PrivilageUserDO();
BeanUtils.copyProperties(poiStoreStaffVO,privilageUserDO);
Long userId = privilageUserService.addUser(privilageUserDO);
if (null == userId ) return 0;
if (null == userId ) return "0001";
QueryWrapper<PrivilageRoleDO> rowMapper = new QueryWrapper<>();
rowMapper.eq("code",poiStoreStaffVO.getRole());
PrivilageRoleDO privilageRoleDO = privilageRoleDOMapper.selectOne(rowMapper);
@ -258,7 +280,8 @@ public class PoiStoreStaffService {
poiStoreStaff.setType(4L);
}
poiStoreStaff.setEpWechatQrCode(qrCodeDO.getQrCode());
return poiStoreStaffDOMapper.insert(poiStoreStaff);
poiStoreStaffDOMapper.insert(poiStoreStaff);
return "0000";
}
/**

@ -74,9 +74,9 @@ public class PrivilageAccountController extends BaseController {
try {
JSONObject saveAccountInputJSON = JSONObject.parseObject(addFrom);
SaveAccountInput saveAccountInput1 = saveAccountInputJSON.toJavaObject(SaveAccountInput.class);
boolean flag = privilageAccountService.saveAccount(saveAccountInput1);
String flag = privilageAccountService.saveAccount(saveAccountInput1);
//成功为0000存在业务不能新增为0002
return flag ? data(Boolean.TRUE) : fail(0);
return data(flag);
} catch (Exception e) {
log.error("账号管理-保存账号出错", e);
return fail();
@ -95,9 +95,9 @@ public class PrivilageAccountController extends BaseController {
try {
JSONObject saveAccountInputJSON = JSONObject.parseObject(addFrom);
SaveAccountInput saveAccountInput1 = saveAccountInputJSON.toJavaObject(SaveAccountInput.class);
boolean flag = privilageAccountService.saveAccount(saveAccountInput1);
String flag = privilageAccountService.saveAccount(saveAccountInput1);
//成功为0000存在业务不能新增为0002
return flag ? data(success()) : data(fail());
return data(flag);
} catch (Exception e) {
log.error("账号管理-保存账号出错", e);
return fail();
@ -141,11 +141,8 @@ public class PrivilageAccountController extends BaseController {
JSONObject modifyJson = JSONObject.parseObject(modifyForm);
ModifyAccountInput modifyAccountInput = modifyJson.toJavaObject(ModifyAccountInput.class);
int code = privilageAccountService.modifyAccount(modifyAccountInput);
if(code == AccountEnum.ACCOUNT_MODIFY_STATUS_EXISTS.getType()) {
return fail(AccountEnum.ACCOUNT_MODIFY_STATUS_EXISTS.getType());
}
//成功
return data(Boolean.TRUE);
return data(code);
} catch (Exception e) {
log.error("修改账号出错", e);
return fail();

@ -16,6 +16,8 @@ public enum AccountEnum {
ACCOUNT_TYPE_SYSTEM("系统账号", 1),
ACCOUNT_MODIFY_STATUS_SUCCEED("账号修改成功", 0),
ACCOUNT_MODIFY_STATUS_EXISTS("账号已存在", 1),
ACCOUNT_MODIFY_STATUS_STAFF_EXISTS("工号已存在", 3),
ACCOUNT_MODIFY_STATUS_MOBILE_EXISTS("手机号已存在", 2),
ACCOUNT_TYPE_QYWX("企业微信账号类型", 2),
ACCOUNT_TYPE_MOBILE("企业微信账号类型", 3),
ACCOUNT_FIRST_PWD("123456", 0);

@ -37,7 +37,7 @@ public interface PrivilageAccountService extends IService<PrivilageAccountDO> {
* @param saveAccountInput
* @return
*/
boolean saveAccount(SaveAccountInput saveAccountInput);
String saveAccount(SaveAccountInput saveAccountInput);
/**
*

@ -32,6 +32,7 @@ import com.kiisoo.ic.system.service.PrivilageAccountService;
import com.kiisoo.ic.system.service.PrivilageUserRoleService;
import com.kiisoo.ic.system.service.PrivilageUserService;
import com.kiisoo.ic.webappmy.vo.StafferInfoVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
@ -147,13 +148,29 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveAccount(SaveAccountInput saveAccountInput) {
public String saveAccount(SaveAccountInput saveAccountInput) {
String account = saveAccountInput.getAccount();
String mobil = saveAccountInput.getMobil();
QueryWrapper<PrivilageUserDO> mobileUserQw = new QueryWrapper<>();
mobileUserQw.eq("mobil", mobil).eq("status", "1");
List<PrivilageUserDO> mobileUsers = privilageUserDOMapper.selectList(mobileUserQw);
if (CollectionUtils.isNotEmpty(mobileUsers)) {
return "0003";
}
QueryWrapper<PrivilageAccountDO> loginUserQw = new QueryWrapper<>();
loginUserQw.eq("login", account).eq("type", "1").eq("status", "1");
List<PrivilageAccountDO> loginUsers = privilageAccountDOMapper.selectList(loginUserQw);
if (CollectionUtils.isNotEmpty(loginUsers)) {
return "0004";
}
Long shopId = saveAccountInput.getShopId();
List<PrivilageAccountDO> privilageAccountDOS = listAccountExists(saveAccountInput.getAccount());
//存在跳过
if (privilageAccountDOS != null && privilageAccountDOS.size() > 0) return false;
if (privilageAccountDOS != null && privilageAccountDOS.size() > 0) return "0001";
//新增用户
Long userId = privilageUserService.insertUser(saveAccountInput.getUserName(),saveAccountInput.getMobil());
Long userId = privilageUserService.insertUser(saveAccountInput.getUserName(), saveAccountInput.getMobil());
//新增账号
insertAccount(saveAccountInput.getAccount(), saveAccountInput.getPassword(), userId);
//绑定用户角色关系
@ -162,14 +179,20 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
PrivilageRoleDO privilageRoleDO = privilageRoleDOMapper.selectById(saveAccountInput.getRoleId());
//店长维护用户店铺关系1.店长。4.导购
if (privilageRoleDO.getCode().equals(RoleEnum.ROLE_CODE_DZ.getRoleCode()) || privilageRoleDO.getCode().equals(RoleEnum.ROLE_CODE_DG.getRoleCode())) {
QueryWrapper<PoiStoreStaff> staffQw = new QueryWrapper<>();
staffQw.eq("staff_code", account).eq("status", "1");
List<PoiStoreStaff> staffs = poiStoreStaffDOMapper.selectList(staffQw);
if (CollectionUtils.isNotEmpty(staffs)) {
return "0002";
}
privilageDomainService.saveOneShop(userId, saveAccountInput.getAccount(), shopId, saveAccountInput.getType());
return true;
return "0000";
}
//运营人员维护全店铺域实体关系
if (privilageRoleDO.getCode().equals(RoleEnum.ROLE_CODE_YYRY.getRoleCode())) {
privilageDomainService.saveRoleY(userId, saveAccountInput.getCompanyId());
}
return true;
return "0000";
}
@Override
@ -207,7 +230,7 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
Long staffId = poiStoreStaffDOMapper.selectStaffIdByUserId(userId);
//删除该用户店长,导购
poiStoreStaffDOMapper.deleteById(staffId);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return true;
@ -215,6 +238,8 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
@Override
public int modifyAccount(ModifyAccountInput modifyAccountInput) {
String mobil = modifyAccountInput.getMobil();
String account = modifyAccountInput.getAccount();
//查询以前的账号名
PrivilageAccountDO privilageAccountDO = privilageAccountDOMapper.selectById(modifyAccountInput.getAccountId());
String oldLogin = privilageAccountDO.getLogin();
@ -226,6 +251,14 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
return AccountEnum.ACCOUNT_MODIFY_STATUS_EXISTS.getType();
}
}
QueryWrapper<PrivilageUserDO> mobileUserQw = new QueryWrapper<>();
mobileUserQw.eq("mobil", mobil).eq("status", "1");
List<PrivilageUserDO> mobileUsers = privilageUserDOMapper.selectList(mobileUserQw);
if (CollectionUtils.isNotEmpty(mobileUsers)) {
return AccountEnum.ACCOUNT_MODIFY_STATUS_MOBILE_EXISTS.getType();
}
//修改账号
PrivilageAccountDO privilageAccountDO1 = new PrivilageAccountDO();
privilageAccountDO1.setId(modifyAccountInput.getAccountId());
@ -257,6 +290,12 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
//店长维护用户店铺关系1.店长。4.导购
if (shopId != null && (privilageRoleDO.getCode().equals(RoleEnum.ROLE_CODE_DZ.getRoleCode()) || privilageRoleDO.getCode().equals(RoleEnum.ROLE_CODE_DG.getRoleCode()))) {
QueryWrapper<PoiStoreStaff> staffQw = new QueryWrapper<>();
staffQw.eq("staff_code", account).eq("status", "1");
List<PoiStoreStaff> staffs = poiStoreStaffDOMapper.selectList(staffQw);
if (CollectionUtils.isNotEmpty(staffs)) {
return AccountEnum.ACCOUNT_MODIFY_STATUS_STAFF_EXISTS.getType();
}
privilageDomainService.saveOneShop(userId, modifyAccountInput.getAccount(), shopId, modifyAccountInput.getType());
return AccountEnum.ACCOUNT_MODIFY_STATUS_SUCCEED.getType();
}
@ -292,11 +331,11 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
accountBean.setShopName(AccountBean.ALL_SHOP);
}
//运营人员
if(roleCode.equals(RoleEnum.ROLE_CODE_YYRY.getRoleCode())){
if (roleCode.equals(RoleEnum.ROLE_CODE_YYRY.getRoleCode())) {
QueryWrapper<PrivilageOrganizationalMember> wrapper = new QueryWrapper<>();
wrapper.eq("user_id",userId).last("limit 1");
wrapper.eq("user_id", userId).last("limit 1");
PrivilageOrganizationalMember p1 = organizationalMemberMapper.selectOne(wrapper);
if(p1 != null){
if (p1 != null) {
accountBean.setOrgId(p1.getOrgId());
PrivilageOrganizational list1 = retailCompanyMapper.selectById(p1.getOrgId());
accountBean.setShopName(list1.getName());
@ -384,9 +423,9 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
continue;
} else {
QueryWrapper<PrivilageAccountDO> wrapper = new QueryWrapper<>();
wrapper.eq("login",account).last("limit 1");
wrapper.eq("login", account).last("limit 1");
PrivilageAccountDO accountDO = privilageAccountDOMapper.selectOne(wrapper);
if(accountDO != null){
if (accountDO != null) {
ImportAccountErrorBean errorBean = new ImportAccountErrorBean();
errorBean.setError("第" + (r + 1) + "行账户已存在,请检查后重新导入!");
errorBeanList.add(errorBean);
@ -415,9 +454,9 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
codeByName = RoleEnum.getCodeByName(roleName);
//根据roleCode查询roleId
QueryWrapper<PrivilageRoleDO> wrapper = new QueryWrapper<>();
wrapper.eq("code",codeByName.getRoleCode()).last("limit 1");
wrapper.eq("code", codeByName.getRoleCode()).last("limit 1");
PrivilageRoleDO privilageRoleDO = privilageRoleDOMapper.selectOne(wrapper);
if(null == privilageRoleDO){
if (null == privilageRoleDO) {
ImportAccountErrorBean errorBean = new ImportAccountErrorBean();
errorBean.setError("第" + (r + 1) + "行角色代码输入有误,请检查后重新导入!");
errorBeanList.add(errorBean);
@ -426,19 +465,19 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
//可见店铺
String shopCode = getCellValue(row.getCell(4));
if(RoleEnum.ROLE_CODE_DZ.equals(codeByName) || RoleEnum.ROLE_CODE_DG.equals(codeByName)){
if (RoleEnum.ROLE_CODE_DZ.equals(codeByName) || RoleEnum.ROLE_CODE_DG.equals(codeByName)) {
//只有这两个角色是需要填写店铺信息的
if (StringUtils.isBlank(shopCode)) {
ImportAccountErrorBean errorBean = new ImportAccountErrorBean();
errorBean.setError("第" + (r + 1) + "行可见店铺不能为空,请输入完整重新导入该店铺!");
errorBeanList.add(errorBean);
continue;
}else {
} else {
//根据店铺code查询店铺id
QueryWrapper<PoiStore> wrapper = new QueryWrapper<>();
wrapper.eq("code",shopCode).last("limit 1");
wrapper.eq("code", shopCode).last("limit 1");
PoiStore poiStore = poiStoreDOMapper.selectOne(wrapper);
if(null == poiStore){
if (null == poiStore) {
ImportAccountErrorBean errorBean = new ImportAccountErrorBean();
errorBean.setError("第" + (r + 1) + "行店铺代码输入有误,请检查后重新导入!");
errorBeanList.add(errorBean);
@ -449,9 +488,9 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
}
}
}
if(errorBeanList.isEmpty()){
if (errorBeanList.isEmpty()) {
//如果没有任何报错信息就执行添加操作,如果有报错信息就不执行添加操作
accountCreate.forEach(this::saveAccount);
// accountCreate.forEach(this::saveAccount);
}
return errorBeanList;
}
@ -466,7 +505,7 @@ public class PrivilageAccountServiceImpl extends ServiceImpl<PrivilageAccountDOM
public PrivilageAccountDO getAccountByUserId(Long userId) {
QueryWrapper<PrivilageAccountDO> wrapper = new QueryWrapper<>();
wrapper.eq("user_id",userId).last("limit 1");
wrapper.eq("user_id", userId).last("limit 1");
return privilageAccountDOMapper.selectOne(wrapper);
}

Loading…
Cancel
Save