|
@@ -3,23 +3,32 @@ package com.caimei365.user.service.impl;
|
|
|
import com.caimei365.user.components.CommonService;
|
|
|
import com.caimei365.user.mapper.BaseMapper;
|
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
|
+import com.caimei365.user.mapper.SuperVipMapper;
|
|
|
import com.caimei365.user.model.ResponseJson;
|
|
|
import com.caimei365.user.components.RedisService;
|
|
|
import com.caimei365.user.model.dto.MobileDto;
|
|
|
import com.caimei365.user.model.dto.PasswordDto;
|
|
|
+import com.caimei365.user.model.dto.SuperVipDto;
|
|
|
import com.caimei365.user.model.po.ShopPo;
|
|
|
+import com.caimei365.user.model.po.SuperVipPo;
|
|
|
+import com.caimei365.user.model.po.VipPayHistoryPo;
|
|
|
+import com.caimei365.user.model.vo.ClubTemporaryVo;
|
|
|
import com.caimei365.user.model.vo.ShopVo;
|
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
|
import com.caimei365.user.model.vo.UserVo;
|
|
|
import com.caimei365.user.service.BaseService;
|
|
|
import com.caimei365.user.utils.*;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@@ -32,6 +41,8 @@ import java.util.Map;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class BaseServiceImpl implements BaseService {
|
|
|
+ @Resource
|
|
|
+ private SuperVipMapper vipMapper;
|
|
|
@Resource
|
|
|
private CommonService commonService;
|
|
|
@Resource
|
|
@@ -68,7 +79,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
}
|
|
|
result.put("baseImage", captcha.getBase64Image());
|
|
|
result.put("token", captcha.getMd5Code());
|
|
|
- log.info("获取图片验证码:"+captcha.getCode() + ",token:" + captcha.getMd5Code());
|
|
|
+ log.info("获取图片验证码:" + captcha.getCode() + ",token:" + captcha.getMd5Code());
|
|
|
return ResponseJson.success(result);
|
|
|
} catch (Exception e) {
|
|
|
log.info(e.getMessage());
|
|
@@ -86,7 +97,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean checkCaptchaImage(String token, String imgCode, Integer platformType) {
|
|
|
- if (StringUtils.isBlank(token) || StringUtils.isBlank(imgCode)){
|
|
|
+ if (StringUtils.isBlank(token) || StringUtils.isBlank(imgCode)) {
|
|
|
return false;
|
|
|
}
|
|
|
String captchaKey = ImageCaptchaUtil.getCaptchaKey(token, platformType);
|
|
@@ -114,9 +125,11 @@ public class BaseServiceImpl implements BaseService {
|
|
|
public ResponseJson getSmsCode(String mobile, Integer activateCodeType, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
|
|
|
// 验证手机号
|
|
|
String result = ValidateUtil.validateMobile(mobile);
|
|
|
- if (result != null) {return ResponseJson.error(result);}
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
// 检查图片验证码
|
|
|
- if (null == isCheckCaptcha || 0 == isCheckCaptcha){
|
|
|
+ if (null == isCheckCaptcha || 0 == isCheckCaptcha) {
|
|
|
Boolean checkFlag = checkCaptchaImage(token, imgCode, platformType);
|
|
|
if (!checkFlag) {
|
|
|
return ResponseJson.error("图片验证码错误");
|
|
@@ -126,7 +139,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
// 生成六位验证码
|
|
|
String randomCode = CodeUtil.generateCodeInt(6);
|
|
|
boolean isBeta = "dev".equals(profile) || "beta".equals(profile);
|
|
|
- if (isBeta){
|
|
|
+ if (isBeta) {
|
|
|
// 开发 和 测试环境 固定短信验证码 666666
|
|
|
randomCode = "666666";
|
|
|
}
|
|
@@ -140,7 +153,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
// 找回密码
|
|
|
sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 1, "{code:" + randomCode + "}");
|
|
|
codeTypeTxt = "找回密码";
|
|
|
- } else if (2 == activateCodeType || 3 == activateCodeType){
|
|
|
+ } else if (2 == activateCodeType || 3 == activateCodeType) {
|
|
|
if (null != userId && userId > 0) {
|
|
|
return ResponseJson.error("该手机号已被使用");
|
|
|
}
|
|
@@ -150,27 +163,27 @@ public class BaseServiceImpl implements BaseService {
|
|
|
codeTypeTxt = "机构(自主)注册";
|
|
|
} else if (3 == activateCodeType) {
|
|
|
// 供应商(自主)注册
|
|
|
- sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 9, "{code:"+ randomCode +"}");
|
|
|
+ sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 9, "{code:" + randomCode + "}");
|
|
|
codeTypeTxt = "供应商(自主)注册";
|
|
|
} else {
|
|
|
return ResponseJson.error("参数错误:activateCodeType");
|
|
|
}
|
|
|
} else if (4 == activateCodeType) {
|
|
|
// 您正在更换联系人手机号,您的验证码为:${code}。
|
|
|
- sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 13, "{code:"+ randomCode +"}");
|
|
|
+ sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 13, "{code:" + randomCode + "}");
|
|
|
codeTypeTxt = "更换联系人(旧手机号验证码)";
|
|
|
} else if (5 == activateCodeType) {
|
|
|
if (null != userId && userId > 0) {
|
|
|
return ResponseJson.error("该手机号已被使用");
|
|
|
}
|
|
|
// 您正在更换联系人手机号,您的验证码为:${code}。
|
|
|
- sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 13, "{code:"+ randomCode +"}");
|
|
|
+ sendFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 13, "{code:" + randomCode + "}");
|
|
|
codeTypeTxt = "更换联系人(新手机号验证码)";
|
|
|
} else {
|
|
|
return ResponseJson.error("参数错误:activateCodeType");
|
|
|
}
|
|
|
if (sendFlag) {
|
|
|
- redisService.set("code:"+mobile, randomCode, 1800L);
|
|
|
+ redisService.set("code:" + mobile, randomCode, 1800L);
|
|
|
log.info(codeTypeTxt + ",发送到:" + mobile + "的短信验证码为: " + randomCode);
|
|
|
} else {
|
|
|
log.info(codeTypeTxt + ",验证码发送失败!");
|
|
@@ -193,40 +206,44 @@ public class BaseServiceImpl implements BaseService {
|
|
|
public ResponseJson getBindSmsCode(String mobile, String bindMobile, Integer userId, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
|
|
|
// 验证手机号
|
|
|
String result = ValidateUtil.validateMobile(mobile);
|
|
|
- if (result != null) {return ResponseJson.error(result);}
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
// 检查图片验证码
|
|
|
- if (null == isCheckCaptcha || 0 == isCheckCaptcha){
|
|
|
+ if (null == isCheckCaptcha || 0 == isCheckCaptcha) {
|
|
|
Boolean checkFlag = checkCaptchaImage(token, imgCode, platformType);
|
|
|
if (!checkFlag) {
|
|
|
return ResponseJson.error("图片验证码错误");
|
|
|
}
|
|
|
}
|
|
|
Integer dbUserId = null;
|
|
|
- if (StringUtils.isNotBlank(bindMobile)){
|
|
|
+ if (StringUtils.isNotBlank(bindMobile)) {
|
|
|
result = ValidateUtil.validateMobile(bindMobile);
|
|
|
- if (result != null) {return ResponseJson.error(result);}
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
// 根据手机号查询用户Id
|
|
|
dbUserId = baseMapper.getUserIdByMobile(bindMobile);
|
|
|
- } else if(null != userId) {
|
|
|
+ } else if (null != userId) {
|
|
|
// 根据用户Id查询用户是否存在
|
|
|
dbUserId = baseMapper.getUserIdByUserId(userId);
|
|
|
}
|
|
|
- if (null == dbUserId){
|
|
|
+ if (null == dbUserId) {
|
|
|
return ResponseJson.error("你输入的账号不存在");
|
|
|
}
|
|
|
Integer operationUserId = baseMapper.getOperationUserIdByMobile(mobile);
|
|
|
- if (null != operationUserId){
|
|
|
+ if (null != operationUserId) {
|
|
|
// 判断运营人员是否是机构手机号
|
|
|
Integer tempId = baseMapper.getUserIdByMobile(mobile);
|
|
|
- if (null != tempId && tempId.equals(userId)){
|
|
|
+ if (null != tempId && tempId.equals(userId)) {
|
|
|
// 判断机构状态
|
|
|
Integer clubStatus = baseMapper.getClubStatusByUserId(operationUserId);
|
|
|
- if(null != clubStatus && 91 != clubStatus) {
|
|
|
+ if (null != clubStatus && 91 != clubStatus) {
|
|
|
return ResponseJson.error("该手机号已被机构使用");
|
|
|
}
|
|
|
// 判断供应商状态
|
|
|
Integer shopStatus = baseMapper.getShopStatusByUserId(operationUserId);
|
|
|
- if(null != shopStatus && 91 != shopStatus) {
|
|
|
+ if (null != shopStatus && 91 != shopStatus) {
|
|
|
return ResponseJson.error("该手机号已被供应商使用");
|
|
|
}
|
|
|
}
|
|
@@ -234,20 +251,20 @@ public class BaseServiceImpl implements BaseService {
|
|
|
// 生成六位验证码
|
|
|
String randomCode = CodeUtil.generateCodeInt(6);
|
|
|
boolean isBeta = "dev".equals(profile) || "beta".equals(profile);
|
|
|
- if (isBeta){
|
|
|
+ if (isBeta) {
|
|
|
// 开发 和 测试环境 固定短信验证码 666666
|
|
|
randomCode = "666666";
|
|
|
}
|
|
|
String userName = baseMapper.getUserNameByUserId(userId);
|
|
|
// 欢迎成为${name}的运营人员,您的邀请码为${code}。
|
|
|
- boolean smsFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 11, "{name:"+ userName +",code:"+ randomCode +"}");
|
|
|
+ boolean smsFlag = isBeta || AliyunSmsUtil.sendSms(mobile, 11, "{name:" + userName + ",code:" + randomCode + "}");
|
|
|
if (!smsFlag) {
|
|
|
// 短信发送失败重试一次
|
|
|
- smsFlag = AliyunSmsUtil.sendSms(mobile, 11, "{name:\""+ userName +"\",code:"+ randomCode +"}");
|
|
|
+ smsFlag = AliyunSmsUtil.sendSms(mobile, 11, "{name:\"" + userName + "\",code:" + randomCode + "}");
|
|
|
}
|
|
|
if (smsFlag) {
|
|
|
- redisService.set("code:"+mobile, randomCode, 1800L);
|
|
|
- log.info( "绑定账号,发送到:" + mobile + "的短信验证码为: " + randomCode);
|
|
|
+ redisService.set("code:" + mobile, randomCode, 1800L);
|
|
|
+ log.info("绑定账号,发送到:" + mobile + "的短信验证码为: " + randomCode);
|
|
|
return ResponseJson.success("发送验证码成功");
|
|
|
} else {
|
|
|
return ResponseJson.error("验证码发送失败!请稍后重试");
|
|
@@ -271,7 +288,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
// 生成六位验证码
|
|
|
String randomCode = CodeUtil.generateCodeInt(6);
|
|
|
boolean isBeta = "dev".equals(profile) || "beta".equals(profile);
|
|
|
- if (isBeta){
|
|
|
+ if (isBeta) {
|
|
|
// 开发 和 测试环境 固定短信验证码 666666
|
|
|
randomCode = "666666";
|
|
|
}
|
|
@@ -295,8 +312,8 @@ public class BaseServiceImpl implements BaseService {
|
|
|
subject = "采美365网修改密码验证邮件";
|
|
|
}
|
|
|
EmailUtil.sendMail(email, subject, html);
|
|
|
- redisService.set("code:"+email, randomCode, 1800L);
|
|
|
- log.info( "subject,发送到:" + email + "的验证码为: " + randomCode);
|
|
|
+ redisService.set("code:" + email, randomCode, 1800L);
|
|
|
+ log.info("subject,发送到:" + email + "的验证码为: " + randomCode);
|
|
|
} catch (Exception e) {
|
|
|
return ResponseJson.error("发送验证码失败");
|
|
|
}
|
|
@@ -324,7 +341,9 @@ public class BaseServiceImpl implements BaseService {
|
|
|
if (status == 1) {
|
|
|
// 验证手机号
|
|
|
String result = ValidateUtil.validateMobile(mobileOrEmail);
|
|
|
- if (result != null) {return ResponseJson.error(result);}
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
} else {
|
|
|
// 验证邮箱
|
|
|
if (!ValidateUtil.validateEmail(mobileOrEmail)) {
|
|
@@ -336,7 +355,7 @@ public class BaseServiceImpl implements BaseService {
|
|
|
}
|
|
|
String redisSmsCode = (String) redisService.get("code:" + mobileOrEmail);
|
|
|
// 开发 和 测试环境 固定短信验证码 666666
|
|
|
- if ("dev".equals(profile) || "beta".equals(profile)){
|
|
|
+ if ("dev".equals(profile) || "beta".equals(profile)) {
|
|
|
redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
|
|
|
}
|
|
|
if (!smsCode.equals(redisSmsCode)) {
|
|
@@ -401,10 +420,12 @@ public class BaseServiceImpl implements BaseService {
|
|
|
}
|
|
|
// 旧手机号与验证码校验
|
|
|
String result = ValidateUtil.validateMobile(mobileDto.getMobile());
|
|
|
- if (result != null) {return ResponseJson.error(result);}
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
String smsCode = (String) redisService.get("code:" + mobileDto.getMobile());
|
|
|
// 开发 和 测试环境 固定短信验证码 666666
|
|
|
- if ("dev".equals(profile) || "beta".equals(profile)){
|
|
|
+ if ("dev".equals(profile) || "beta".equals(profile)) {
|
|
|
smsCode = (null != smsCode && !"null".equals(smsCode) ? smsCode : "666666");
|
|
|
}
|
|
|
if (!mobileDto.getSmsCode().equals(smsCode)) {
|
|
@@ -416,7 +437,9 @@ public class BaseServiceImpl implements BaseService {
|
|
|
}
|
|
|
//验证新手机号是否可用
|
|
|
result = commonService.mobileAndCodeValidate(mobileDto.getNewMobile(), mobileDto.getNewSmsCode());
|
|
|
- if (result != null) {return ResponseJson.error(result);}
|
|
|
+ if (result != null) {
|
|
|
+ return ResponseJson.error(result);
|
|
|
+ }
|
|
|
// 更新user表手机号
|
|
|
baseMapper.updateMobileByUserId(mobileDto.getNewMobile(), mobileDto.getUserId());
|
|
|
if (user.getUserIdentity() == 3) {
|
|
@@ -429,4 +452,46 @@ public class BaseServiceImpl implements BaseService {
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据id查超级会员购买记录
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson findVipHistory(Integer userId, Integer pageNum, Integer pageSize) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数异常:用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<VipPayHistoryPo> vipHistory = vipMapper.findVipHistory(userId);
|
|
|
+ PageInfo<VipPayHistoryPo> pageInfo = new PageInfo<>(vipHistory);
|
|
|
+ return ResponseJson.success(pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String, Object>> superCenter(Integer userId) {
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("参数异常:用户Id不能为空!", null);
|
|
|
+ }
|
|
|
+ //1.封装vipDto看超级会员是否过期,0未开通,-1过期,1未过期
|
|
|
+ SuperVipPo superVip = vipMapper.findSuperVip(userId);
|
|
|
+ SuperVipDto superVipDto = new SuperVipDto();
|
|
|
+ if (superVip == null) {
|
|
|
+ superVipDto.setEndFlag("0");
|
|
|
+ }
|
|
|
+ SuperVipPo endTime = vipMapper.findEndTime(userId);
|
|
|
+ if (endTime == null) {
|
|
|
+ superVipDto.setEndFlag("-1");
|
|
|
+ superVipDto.setEndTime(superVip.getEndTime());
|
|
|
+ }
|
|
|
+ superVipDto.setEndFlag("1");
|
|
|
+ superVipDto.setEndTime(endTime.getEndTime());
|
|
|
+ Map<String, Object> map = new HashMap(3);
|
|
|
+ map.put("vip", superVipDto);
|
|
|
+ //todo 2.查专属优惠卷
|
|
|
+
|
|
|
+ //todo 3.查专属商品
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
}
|