|
@@ -3,6 +3,13 @@ package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.microsvc.toolkit.common.webportal.exception.BizException;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.SmsCodeService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -10,6 +17,9 @@ import com.yonge.cooleshow.biz.dal.entity.TenantApplyRecord;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.TenantApplyRecordWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantApplyRecordMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantApplyRecordService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* 机构入驻申请记录
|
|
@@ -19,12 +29,19 @@ import com.yonge.cooleshow.biz.dal.service.TenantApplyRecordService;
|
|
|
@Service
|
|
|
public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordMapper, TenantApplyRecord> implements TenantApplyRecordService {
|
|
|
|
|
|
- /**
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TenantStaffService tenantStaffService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SmsCodeService smsCodeService;
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询详情
|
|
|
* @param id 详情ID
|
|
|
* @return TenantApplyRecord
|
|
|
*/
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public TenantApplyRecord detail(Long id) {
|
|
|
|
|
|
return baseMapper.selectById(id);
|
|
@@ -41,15 +58,15 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
|
|
|
|
|
|
return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
* @param tenantApplyRecord TenantApplyRecordWrapper.TenantApplyRecord
|
|
|
* @return Boolean
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean add(TenantApplyRecordWrapper.TenantApplyRecord tenantApplyRecord) {
|
|
|
-
|
|
|
+ public Boolean add(TenantApplyRecordWrapper.TenantApplyRecord tenantApplyRecord) {
|
|
|
+
|
|
|
return this.save(JSON.parseObject(tenantApplyRecord.jsonString(), TenantApplyRecord.class));
|
|
|
}
|
|
|
|
|
@@ -63,4 +80,51 @@ public class TenantApplyRecordServiceImpl extends ServiceImpl<TenantApplyRecordM
|
|
|
|
|
|
return this.updateById(JSON.parseObject(tenantApplyRecord.jsonString(), TenantApplyRecord.class));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 申请入驻
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void apply(TenantApplyRecordWrapper.TenantApply tenantApply) {
|
|
|
+
|
|
|
+ // 检测验证码
|
|
|
+ boolean b = smsCodeService.verifyValidCode(tenantApply.getPhone(), tenantApply.getCode(), null);
|
|
|
+ if (!b) {
|
|
|
+ throw new BizException("验证码错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 根据手机号 判断是否已经有机构账户
|
|
|
+ TenantStaff tenantStaff = tenantStaffService.getByPhone(tenantApply.getPhone());
|
|
|
+ if (tenantStaff != null) {
|
|
|
+ throw new BizException("该手机号已经有机构账户");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询申请记录 是否存在正在申请中的
|
|
|
+ TenantApplyRecord record = this.lambdaQuery()
|
|
|
+ .eq(TenantApplyRecord::getPhone, tenantApply.getPhone())
|
|
|
+ .in(TenantApplyRecord::getStatus, AuthStatusEnum.DOING, AuthStatusEnum.UNPASS)
|
|
|
+ .last("limit 1")
|
|
|
+ .one();
|
|
|
+
|
|
|
+ // 保存申请记录
|
|
|
+ TenantApplyRecord tenantApplyRecord = JSON.parseObject(tenantApply.jsonString(), TenantApplyRecord.class);
|
|
|
+ if (record != null) {
|
|
|
+ tenantApplyRecord.setId(record.getId());
|
|
|
+ }
|
|
|
+ tenantApplyRecord.setStatus(AuthStatusEnum.DOING);
|
|
|
+ tenantApplyRecord.setUpdateTime(new Date());
|
|
|
+ this.saveOrUpdate(tenantApplyRecord);
|
|
|
+
|
|
|
+ // 审核人 审核理由 null
|
|
|
+ this.lambdaUpdate()
|
|
|
+ .eq(TenantApplyRecord::getId, tenantApplyRecord.getId())
|
|
|
+ .set(TenantApplyRecord::getVerifyUserId, null)
|
|
|
+ .set(TenantApplyRecord::getReason, null)
|
|
|
+ .update();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|