|
@@ -2,12 +2,15 @@ package com.caimei365.user.service.impl;
|
|
|
|
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
|
import com.caimei365.user.mapper.ClubMapper;
|
|
|
+import com.caimei365.user.mapper.RegisterMapper;
|
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
import com.caimei365.user.model.dto.ClubUpdateDto;
|
|
|
-import com.caimei365.user.model.po.ClubPo;
|
|
|
+import com.caimei365.user.model.po.UserBeansHistoryPo;
|
|
|
import com.caimei365.user.model.po.UserPo;
|
|
|
import com.caimei365.user.model.vo.*;
|
|
|
import com.caimei365.user.service.ClubService;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -30,6 +33,8 @@ public class ClubServiceImpl implements ClubService {
|
|
|
private ClubMapper clubMapper;
|
|
|
@Resource
|
|
|
private BaseMapper baseMapper;
|
|
|
+ @Resource
|
|
|
+ private RegisterMapper registerMapper;
|
|
|
|
|
|
/**
|
|
|
* 根据用户Id查询机构资料
|
|
@@ -78,28 +83,28 @@ public class ClubServiceImpl implements ClubService {
|
|
|
* 修改机构资料
|
|
|
*
|
|
|
* @param club ClubUpgradeDto:{
|
|
|
- * clubId 机构ID
|
|
|
- * userId 用户ID
|
|
|
- * name 机构名称
|
|
|
- * shortName 机构简称(shortName)
|
|
|
- * contractEmail 邮箱(contractEmail1)
|
|
|
- * contractPhone 固定电话
|
|
|
- * linkMan 联系人(linkMan1)
|
|
|
- * provinceId 省Id
|
|
|
- * cityId 市Id
|
|
|
- * townId 县区Id
|
|
|
- * address 地址
|
|
|
- * shopPhoto 门头照(headpic)
|
|
|
- * businessLicense 营业执照(businessLicenseImage)
|
|
|
- * socialCreditCode 统一社会信用代码(socialCreditCode)
|
|
|
- * firstClubType 一级分类:医美=1和生美=2
|
|
|
- * secondClubType 医美的二级分类:诊所=1、门诊=2、医院=3。 生美没有二级分类
|
|
|
- * department 医美分类下的门诊和医院则需要填写科室
|
|
|
- * medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
|
|
|
- * mainProduct 主打项目(mainpro)
|
|
|
- * fax 传真
|
|
|
- * profile 公司简介
|
|
|
- * }
|
|
|
+ * clubId 机构ID
|
|
|
+ * userId 用户ID
|
|
|
+ * name 机构名称
|
|
|
+ * shortName 机构简称(shortName)
|
|
|
+ * contractEmail 邮箱(contractEmail1)
|
|
|
+ * contractPhone 固定电话
|
|
|
+ * linkMan 联系人(linkMan1)
|
|
|
+ * provinceId 省Id
|
|
|
+ * cityId 市Id
|
|
|
+ * townId 县区Id
|
|
|
+ * address 地址
|
|
|
+ * shopPhoto 门头照(headpic)
|
|
|
+ * businessLicense 营业执照(businessLicenseImage)
|
|
|
+ * socialCreditCode 统一社会信用代码(socialCreditCode)
|
|
|
+ * firstClubType 一级分类:医美=1和生美=2
|
|
|
+ * secondClubType 医美的二级分类:诊所=1、门诊=2、医院=3。 生美没有二级分类
|
|
|
+ * department 医美分类下的门诊和医院则需要填写科室
|
|
|
+ * medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
|
|
|
+ * mainProduct 主打项目(mainpro)
|
|
|
+ * fax 传真
|
|
|
+ * profile 公司简介
|
|
|
+ * }
|
|
|
* @return ClubUpdateDto
|
|
|
*/
|
|
|
@Override
|
|
@@ -116,7 +121,7 @@ public class ClubServiceImpl implements ClubService {
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(club.getContractEmail())) {
|
|
|
Integer userIdByEmail = baseMapper.getUserIdByEmail(club.getContractEmail());
|
|
|
- if (null != userIdByEmail && !userIdByEmail.equals(club.getUserId()) ) {
|
|
|
+ if (null != userIdByEmail && !userIdByEmail.equals(club.getUserId())) {
|
|
|
return ResponseJson.error("该邮箱已被使用", null);
|
|
|
}
|
|
|
}
|
|
@@ -130,16 +135,67 @@ public class ClubServiceImpl implements ClubService {
|
|
|
user.setEmail(club.getContractEmail());
|
|
|
}
|
|
|
// 机构名称
|
|
|
- if (StringUtils.isNotBlank(club.getName())){
|
|
|
+ if (StringUtils.isNotBlank(club.getName())) {
|
|
|
user.setName(club.getName());
|
|
|
}
|
|
|
// 更新机构用户信息
|
|
|
clubMapper.updateClubUserByUpdateInfo(user);
|
|
|
// 更新机构信息
|
|
|
clubMapper.updateClubByUpdateInfo(club);
|
|
|
+
|
|
|
+ UserVo userVo = baseMapper.getUserByUserId(club.getUserId());
|
|
|
+ if (userVo != null && userVo.getUserIdentity() == 4) {
|
|
|
+ Integer id = clubMapper.findBeansHistoryByType(club.getUserId(), 3);
|
|
|
+ boolean b = StringUtils.isNotBlank(club.getLinkMan()) && StringUtils.isNotBlank(club.getFax())
|
|
|
+ && StringUtils.isNotBlank(club.getContractPhone()) && StringUtils.isNotBlank(club.getProfile());
|
|
|
+ if (b && id == null) {
|
|
|
+ saveUserBeans(userVo);
|
|
|
+ }
|
|
|
+ } else if (userVo != null && userVo.getUserIdentity() == 2) {
|
|
|
+ Integer id = clubMapper.findBeansHistoryByType(club.getUserId(), 4);
|
|
|
+ boolean b = StringUtils.isNotBlank(club.getLinkMan()) && StringUtils.isNotBlank(club.getFax()) && club.getTownId() != null
|
|
|
+ && StringUtils.isNotBlank(club.getContractPhone()) && StringUtils.isNotBlank(club.getProfile()) && StringUtils.isNotBlank(club.getAddress())
|
|
|
+ && StringUtils.isNotBlank(club.getName()) && StringUtils.isNotBlank(club.getShortName()) && StringUtils.isNotBlank(club.getContractEmail())
|
|
|
+ && StringUtils.isNotBlank(club.getSocialCreditCode()) && StringUtils.isNotBlank(club.getBusinessLicense()) && StringUtils.isNotBlank(club.getShopPhoto())
|
|
|
+ && club.getFirstClubType() != null && StringUtils.isNotBlank(club.getMainProduct());
|
|
|
+ if (b) {
|
|
|
+ if (club.getFirstClubType() == 1) {
|
|
|
+ //医美
|
|
|
+ b = club.getSecondClubType() != null && StringUtils.isNotBlank(club.getMedicalPracticeLicense());
|
|
|
+ if (b && ("2".equals(club.getMedicalPracticeLicense()) || "3".equals(club.getMedicalPracticeLicense()))) {
|
|
|
+ b = StringUtils.isNotBlank(club.getDepartment());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (b && id == null) {
|
|
|
+ saveUserBeans(userVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return ResponseJson.success("修改机构资料成功", club);
|
|
|
}
|
|
|
|
|
|
+ private void saveUserBeans(UserVo user) {
|
|
|
+ //机构完善资料,送20采美豆
|
|
|
+ UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
|
|
|
+ beansHistory.setUserId(user.getUserId());
|
|
|
+ if (user.getUserIdentity() == 4) {
|
|
|
+ //普通机构完善资料
|
|
|
+ beansHistory.setBeansType(3);
|
|
|
+ } else {
|
|
|
+ //会员机构完善资料
|
|
|
+ beansHistory.setBeansType(4);
|
|
|
+ }
|
|
|
+ beansHistory.setType(1);
|
|
|
+ beansHistory.setNum(20);
|
|
|
+ beansHistory.setPushStatus(0);
|
|
|
+ beansHistory.setAddTime(new Date());
|
|
|
+ registerMapper.insertBeansHistory(beansHistory);
|
|
|
+ Integer userBeans = user.getUserBeans();
|
|
|
+ userBeans = userBeans == null ? 20 : userBeans + 20;
|
|
|
+ clubMapper.updateUserBeans(user.getUserId(), userBeans);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 机构个人中心
|
|
|
*
|
|
@@ -180,4 +236,46 @@ public class ClubServiceImpl implements ClubService {
|
|
|
|
|
|
return ResponseJson.success(map);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<BeansHistoryVo> beansPopUps(Integer userId) {
|
|
|
+ BeansHistoryVo beansHistory = clubMapper.findBeansHistory(userId);
|
|
|
+ if (beansHistory == null) {
|
|
|
+ beansHistory = new BeansHistoryVo();
|
|
|
+ //线上支付送豆
|
|
|
+ Integer num = clubMapper.findByBeansType(userId, 6);
|
|
|
+ beansHistory.setBeansType(6);
|
|
|
+ if (num == null || num == 0) {
|
|
|
+ //下单送豆
|
|
|
+ num = clubMapper.findByBeansType(userId, 5);
|
|
|
+ beansHistory.setBeansType(5);
|
|
|
+ }
|
|
|
+ beansHistory.setNum(num);
|
|
|
+ }
|
|
|
+ if (beansHistory.getNum() == null || beansHistory.getNum() == 0) {
|
|
|
+ return ResponseJson.error("无推送", null);
|
|
|
+ }
|
|
|
+ clubMapper.updatePushStatus(userId);
|
|
|
+ return ResponseJson.success(beansHistory);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> beansHistory(Integer userId, Integer year, Integer month, Integer type, int pageNum, int pageSize) {
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
+ UserVo user = baseMapper.getUserByUserId(userId);
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(Calendar.YEAR, year);
|
|
|
+ calendar.set(Calendar.MONTH, month - 1);
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, calendar.getMinimum(Calendar.DATE));
|
|
|
+ String startTime = format.format(calendar.getTime()) + " 00:00:00";
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DATE));
|
|
|
+ String endTime = format.format(calendar.getTime()) + " 23:59:59";
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<BeansHistoryVo> historyList = clubMapper.findAllBeansHistory(userId, startTime, endTime, type);
|
|
|
+ PageInfo<BeansHistoryVo> pageInfo = new PageInfo<>(historyList);
|
|
|
+ map.put("pageInfo", pageInfo);
|
|
|
+ map.put("userBeans", user.getUserBeans());
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
}
|