|
@@ -108,29 +108,31 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public Long insertFsStore(FsStoreScrm fsStore) {
|
|
public Long insertFsStore(FsStoreScrm fsStore) {
|
|
|
|
|
+ //店铺名称检查
|
|
|
|
|
+ Boolean storeNameExist = fsStoreMapper.isStoreNameExist(fsStore.getStoreName(), null);
|
|
|
|
|
+ if(storeNameExist){
|
|
|
|
|
+ throw new CustomException("已存在相同店铺名称,请修改店铺名称!");
|
|
|
|
|
+ }
|
|
|
//检查商家填写的账号是否重复
|
|
//检查商家填写的账号是否重复
|
|
|
- if (fsStore.getAccount() != null) {
|
|
|
|
|
- FsStoreScrm fs = fsStoreMapper.selectFsStoreByAccount(fsStore.getAccount());
|
|
|
|
|
- if (fs != null) {
|
|
|
|
|
- throw new CustomException("店铺账号重复");
|
|
|
|
|
|
|
+ FsStoreScrm fs = fsStoreMapper.selectFsStoreByAccount(fsStore.getAccount());
|
|
|
|
|
+ if (fs != null) {
|
|
|
|
|
+ throw new CustomException("店铺账号重复");
|
|
|
|
|
+ }
|
|
|
|
|
+ //FIXME
|
|
|
|
|
+ boolean exists = fsStoreMapper.existsByBusinessCode(fsStore.getBusinessCode());
|
|
|
|
|
+ if (exists) {
|
|
|
|
|
+ // 检查是否是同一个商家
|
|
|
|
|
+ String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(fsStore.getBusinessCode());
|
|
|
|
|
+ if (existingMerchantId != null) {
|
|
|
|
|
+ // 同一商家下检查店铺名称是否重复
|
|
|
|
|
+ if (fsStoreMapper.existsStoreNameInMerchant(existingMerchantId, fsStore.getStoreName())) {
|
|
|
|
|
+ throw new CustomException("该商家下已存在同名店铺");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
StoreMD5PasswordEncoder storeMD5PasswordEncoder = new StoreMD5PasswordEncoder();
|
|
StoreMD5PasswordEncoder storeMD5PasswordEncoder = new StoreMD5PasswordEncoder();
|
|
|
fsStore.setPassword(storeMD5PasswordEncoder.encode("XyzAbc~12"));
|
|
fsStore.setPassword(storeMD5PasswordEncoder.encode("XyzAbc~12"));
|
|
|
fsStore.setCreateTime(DateUtils.getNowDate());
|
|
fsStore.setCreateTime(DateUtils.getNowDate());
|
|
|
- if (fsStore.getBusinessCode() != null && !fsStore.getBusinessCode().trim().isEmpty()) {
|
|
|
|
|
- boolean exists = fsStoreMapper.existsByBusinessCode(fsStore.getBusinessCode());
|
|
|
|
|
- if (exists) {
|
|
|
|
|
- // 检查是否是同一个商家
|
|
|
|
|
- String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(fsStore.getBusinessCode());
|
|
|
|
|
- if (existingMerchantId != null) {
|
|
|
|
|
- // 同一商家下检查店铺名称是否重复
|
|
|
|
|
- if (fsStoreMapper.existsStoreNameInMerchant(existingMerchantId, fsStore.getStoreName())) {
|
|
|
|
|
- throw new CustomException("该商家下已存在同名店铺");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
//生成商家id
|
|
//生成商家id
|
|
|
String merchantId = generateMerchantId(fsStore.getBusinessCode());
|
|
String merchantId = generateMerchantId(fsStore.getBusinessCode());
|
|
|
//生成店铺id
|
|
//生成店铺id
|
|
@@ -216,6 +218,11 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public int updateFsStore(FsStoreScrm fsStore) {
|
|
public int updateFsStore(FsStoreScrm fsStore) {
|
|
|
|
|
+ //店铺名称检查
|
|
|
|
|
+ Boolean storeNameExist = fsStoreMapper.isStoreNameExist(fsStore.getStoreName(), fsStore.getStoreId());
|
|
|
|
|
+ if(storeNameExist){
|
|
|
|
|
+ throw new CustomException("已存在相同店铺名称,请修改店铺名称!");
|
|
|
|
|
+ }
|
|
|
fsStore.setUpdateTime(DateUtils.getNowDate());
|
|
fsStore.setUpdateTime(DateUtils.getNowDate());
|
|
|
storeAuditLogUtil.addOperLog(fsStore.getStoreId());
|
|
storeAuditLogUtil.addOperLog(fsStore.getStoreId());
|
|
|
FsStoreScrm oldFsStore = fsStoreMapper.selectFsStoreByStoreId(fsStore.getStoreId());
|
|
FsStoreScrm oldFsStore = fsStoreMapper.selectFsStoreByStoreId(fsStore.getStoreId());
|