|
|
@@ -6,11 +6,14 @@ package com.jeeplus.modules.sys.service;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.jeeplus.common.annotation.LoginAppIntercept;
|
|
|
import com.jeeplus.common.annotation.LoginWxAppletsIntercept;
|
|
|
+import com.jeeplus.common.captcha.TxCaptchaUtils;
|
|
|
import com.jeeplus.common.config.Global;
|
|
|
import com.jeeplus.common.json.AjaxJson;
|
|
|
import com.jeeplus.common.oss.OSSClientUtil;
|
|
|
import com.jeeplus.common.sms.SMS253Utils;
|
|
|
import com.jeeplus.common.sms.SMSConst;
|
|
|
+import com.jeeplus.common.smstx.TxSmsEnum;
|
|
|
+import com.jeeplus.common.smstx.TxSmsUtils;
|
|
|
import com.jeeplus.common.utils.CacheUtils;
|
|
|
import com.jeeplus.common.utils.StringUtils;
|
|
|
import com.jeeplus.common.utils.api.IPUtil;
|
|
|
@@ -45,6 +48,8 @@ import com.jeeplus.modules.tools.utils.TwoDimensionCode;
|
|
|
import com.jeeplus.modules.utils.AppLoginsEnum;
|
|
|
import com.jeeplus.modules.vipmanager.entity.MpMemberAccountF;
|
|
|
import net.sf.json.JSONObject;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -75,7 +80,7 @@ import java.util.*;
|
|
|
@Service
|
|
|
@Transactional(readOnly = true)
|
|
|
public class HpUserService extends CrudService<HpUserMapper, HpUser> {
|
|
|
-
|
|
|
+ private Logger log = LoggerFactory.getLogger(getClass());
|
|
|
@Autowired
|
|
|
private HpResumeWorkExperienceService hpResumeWorkExperienceService;
|
|
|
@Autowired
|
|
|
@@ -96,6 +101,10 @@ public class HpUserService extends CrudService<HpUserMapper, HpUser> {
|
|
|
private HpResumeBankMapper hpResumeBankMapper;
|
|
|
@Autowired
|
|
|
private MpMemberTaskServiceF mpMemberTaskServiceF;
|
|
|
+ @Autowired
|
|
|
+ private TxCaptchaUtils txCaptchaUtils;
|
|
|
+ @Autowired
|
|
|
+ private TxSmsUtils txSmsUtils;
|
|
|
|
|
|
private static final String APP_USER = "appUser";
|
|
|
private static final String APP_USERMSG = "appUserMsg";
|
|
|
@@ -166,29 +175,37 @@ public class HpUserService extends CrudService<HpUserMapper, HpUser> {
|
|
|
if (StringUtils.isBlank(ticket) || StringUtils.isBlank(randstr)) {
|
|
|
throw new OtherException("10000", "系统内部错误!");
|
|
|
}
|
|
|
- //验证码票据验证
|
|
|
- JSONObject json = getTicketData(hashMap, request);
|
|
|
- JSONObject jsonObject = TokenUtil.checkTicket(json);
|
|
|
- logger.info("验证码票据验证========={}", jsonObject.toString());
|
|
|
- long captchaCode = jsonObject.getLong("CaptchaCode");
|
|
|
- if (captchaCode != Constants.CAPTCHA_CODE_OK) {
|
|
|
- throw new OtherException("10000", "系统内部错误!");
|
|
|
+ // 验证码票据验证
|
|
|
+ com.alibaba.fastjson.JSONObject json = getTicketData(hashMap, request);
|
|
|
+ log.info("验证码票据验证========={}", json.toString());
|
|
|
+ boolean isCheck = txCaptchaUtils.checkTicket(json);
|
|
|
+ if (!isCheck) {
|
|
|
+ throw new OtherException("10000", "获取验证码失败,请稍后重试!");
|
|
|
}
|
|
|
+
|
|
|
+ // 手机号
|
|
|
+ List<String> phoneList = new ArrayList<>();
|
|
|
+ phoneList.add(mobile);
|
|
|
+
|
|
|
Random random = new Random();
|
|
|
- String code = "";
|
|
|
+ // 随机数
|
|
|
+ String captcha = "";
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
- code += random.nextInt(10);
|
|
|
- }
|
|
|
- HashMap<String, String> hashMaps = new HashMap<String, String>();
|
|
|
- // 手机号码
|
|
|
- hashMaps.put("phone", mobile);
|
|
|
- hashMaps.put("msg", "亲爱的用户,您的验证码是" + code + ",如非本人操作请忽略!");
|
|
|
- returnMap = SMS253Utils.sendSms(hashMaps);
|
|
|
- if (SMSConst.OKCode.equals(returnMap.get("success"))) {
|
|
|
- returnMap.put("code", code);
|
|
|
- //将获取到的验证码存到redis中
|
|
|
- CacheUtils.put(APP_USER, mobile, code);
|
|
|
+ captcha += random.nextInt(10);
|
|
|
}
|
|
|
+ List<String> templateParams = new ArrayList<>();
|
|
|
+ templateParams.add(captcha);
|
|
|
+ templateParams.add("10");
|
|
|
+ boolean b = txSmsUtils.sendSms(phoneList, templateParams, TxSmsEnum.LOGIN_TEMPLATE_CODE);
|
|
|
+ if (b == false) {
|
|
|
+ throw new OtherException("10000", "短信验证码发送失败,请稍后重试");
|
|
|
+ }
|
|
|
+ //将获取到的验证码存到redis中
|
|
|
+ CacheUtils.put(APP_USER, mobile, captcha);
|
|
|
+ returnMap.put("success", 200);
|
|
|
+ returnMap.put("msg", "获取短信验证码成功!");
|
|
|
+ returnMap.put("code", captcha);
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
throw new OtherException("10000", "系统内部错误!");
|
|
|
}
|
|
|
@@ -202,8 +219,8 @@ public class HpUserService extends CrudService<HpUserMapper, HpUser> {
|
|
|
* @param requestMap
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject getTicketData(HashMap<String, String> requestMap, HttpServletRequest request) {
|
|
|
- JSONObject json = new JSONObject();
|
|
|
+ public com.alibaba.fastjson.JSONObject getTicketData(HashMap<String, String> requestMap, HttpServletRequest request) {
|
|
|
+ com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
//固定填值:9。可在控制台配置不同验证码类型。
|
|
|
json.put("CaptchaType", 9);
|
|
|
//前端回调函数返回的用户验证票据
|