|
@@ -1,17 +1,24 @@
|
|
package cn.newfeifan.mall.module.sale.service.merchantapply;
|
|
package cn.newfeifan.mall.module.sale.service.merchantapply;
|
|
|
|
|
|
|
|
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
|
|
+import cn.newfeifan.mall.module.member.enums.DictTypeConstants;
|
|
|
|
+import cn.newfeifan.mall.module.sale.controller.app.merchantapply.vo.MerchantApplyPageReqVO;
|
|
|
|
+import cn.newfeifan.mall.module.sale.controller.app.merchantapply.vo.MerchantApplySaveReqVO;
|
|
|
|
+import cn.newfeifan.mall.module.sale.enums.MerchantApplyCheckStatusEnum;
|
|
|
|
+import cn.newfeifan.mall.module.system.service.user.AdminUserService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
-import cn.newfeifan.mall.module.sale.controller.admin.merchantapply.vo.*;
|
|
|
|
import cn.newfeifan.mall.module.sale.dal.dataobject.merchantapply.MerchantApplyDO;
|
|
import cn.newfeifan.mall.module.sale.dal.dataobject.merchantapply.MerchantApplyDO;
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
import cn.newfeifan.mall.module.sale.dal.mysql.merchantapply.MerchantApplyMapper;
|
|
import cn.newfeifan.mall.module.sale.dal.mysql.merchantapply.MerchantApplyMapper;
|
|
|
|
|
|
|
|
+
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
+import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
import static cn.newfeifan.mall.module.sale.enums.ErrorCodeConstants.*;
|
|
import static cn.newfeifan.mall.module.sale.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -26,10 +33,27 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
|
|
@Resource
|
|
@Resource
|
|
private MerchantApplyMapper merchantApplyMapper;
|
|
private MerchantApplyMapper merchantApplyMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private AdminUserService usersService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Long createMerchantApply(MerchantApplySaveReqVO createReqVO) {
|
|
public Long createMerchantApply(MerchantApplySaveReqVO createReqVO) {
|
|
|
|
+
|
|
|
|
+ // 校验存在
|
|
|
|
+ if(usersService.getUserByMobile(createReqVO.getContactNumber()) != null){
|
|
|
|
+ ErrorCode ERROR = new ErrorCode(1_002_029_003, "联络人账户已存在");
|
|
|
|
+ throw exception(ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
// 插入
|
|
// 插入
|
|
MerchantApplyDO merchantApply = BeanUtils.toBean(createReqVO, MerchantApplyDO.class);
|
|
MerchantApplyDO merchantApply = BeanUtils.toBean(createReqVO, MerchantApplyDO.class);
|
|
|
|
+ merchantApply.setApplyMemberUserId(getLoginUserId());
|
|
|
|
+
|
|
|
|
+ // 默认log
|
|
|
|
+ if(createReqVO.getLogoUrl() == null || createReqVO.getLogoUrl().isEmpty()){
|
|
|
|
+ createReqVO.setLogoUrl(DictTypeConstants.DEFAULT_AVATAR);
|
|
|
|
+ }
|
|
|
|
+
|
|
merchantApplyMapper.insert(merchantApply);
|
|
merchantApplyMapper.insert(merchantApply);
|
|
// 返回
|
|
// 返回
|
|
return merchantApply.getId();
|
|
return merchantApply.getId();
|
|
@@ -37,10 +61,29 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void updateMerchantApply(MerchantApplySaveReqVO updateReqVO) {
|
|
public void updateMerchantApply(MerchantApplySaveReqVO updateReqVO) {
|
|
|
|
+
|
|
|
|
+ MerchantApplyDO merchantApplyDO = merchantApplyMapper.selectById(updateReqVO.getId());
|
|
|
|
+
|
|
|
|
+ // 联系人手机号校验
|
|
|
|
+ if(!merchantApplyDO.getContactNumber().equals(updateReqVO.getContactNumber()) && usersService.getUserByMobile(updateReqVO.getContactNumber()) != null){
|
|
|
|
+ ErrorCode ERROR = new ErrorCode(1_002_029_003, "联络人账户已存在");
|
|
|
|
+ throw exception(ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateReqVO.setApplyMemberUserId(getLoginUserId());
|
|
// 校验存在
|
|
// 校验存在
|
|
validateMerchantApplyExists(updateReqVO.getId());
|
|
validateMerchantApplyExists(updateReqVO.getId());
|
|
// 更新
|
|
// 更新
|
|
MerchantApplyDO updateObj = BeanUtils.toBean(updateReqVO, MerchantApplyDO.class);
|
|
MerchantApplyDO updateObj = BeanUtils.toBean(updateReqVO, MerchantApplyDO.class);
|
|
|
|
+
|
|
|
|
+ // 默认log
|
|
|
|
+ if(updateObj.getLogoUrl() == null || updateObj.getLogoUrl().isEmpty()){
|
|
|
|
+ updateObj.setLogoUrl(DictTypeConstants.DEFAULT_AVATAR);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 所有变动都需要重新审核
|
|
|
|
+ updateObj.setCheckStatus(MerchantApplyCheckStatusEnum.WAIT_AUDIT.getType());
|
|
|
|
+
|
|
merchantApplyMapper.updateById(updateObj);
|
|
merchantApplyMapper.updateById(updateObj);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -68,4 +111,9 @@ public class MerchantApplyServiceImpl implements MerchantApplyService {
|
|
return merchantApplyMapper.selectPage(pageReqVO);
|
|
return merchantApplyMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public MerchantApplyDO getMerchantApplyBYUserId(Long loginUserId) {
|
|
|
|
+ return merchantApplyMapper.selectOne(MerchantApplyDO::getApplyMemberUserId, loginUserId);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|