Authored by Ge

Merge branch '防刷'

package com.yoho.unions.dal;
import com.yoho.unions.dal.model.MktUnionCode;
public interface MktUnionCodeMapper {
int deleteByPrimaryKey(Integer id);
int insert(MktUnionCode record);
int insertSelective(MktUnionCode record);
MktUnionCode selectByPrimaryKey(Integer id);
MktUnionCode selectByCode(String code);
int updateByPrimaryKeySelective(MktUnionCode record);
int updateByPrimaryKey(MktUnionCode record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
public class MktUnionCode {
private Integer id;
private Long unionType;
private String code;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Long getUnionType() {
return unionType;
}
public void setUnionType(Long unionType) {
this.unionType = unionType;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.unions.dal.MktUnionCodeMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.MktUnionCode" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="union_type" property="unionType" jdbcType="BIGINT" />
<result column="code" property="code" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, union_type, code
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from mkt_union_code
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from mkt_union_code
where code = #{code} limit 1;
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -36,9 +36,9 @@ public class TencentMktController {
*/
@RequestMapping("/sendSms")
@ResponseBody
public ApiResponse sendSms(String area, String mobile, String activityCode) throws ServiceException {
public ApiResponse sendSms(String area, String mobile, String activityCode,String checkCode) throws ServiceException {
log.info("sendSms with area={}, mobile={}, activityCode={}", area, mobile, activityCode);
ApiResponse response = tencentMktService.sendSms(area, mobile, activityCode);
ApiResponse response = tencentMktService.sendSms(area, mobile, activityCode,checkCode);
log.info("sendSms with area={}, mobile={}, activityCode={}, response={}", area, mobile, activityCode, response);
return response;
}
... ... @@ -77,9 +77,9 @@ public class TencentMktController {
*/
@RequestMapping("/validRegCodeAndSendCode")
@ResponseBody
public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id, String activityCode) throws ServiceException {
log.info("validRegCodeAndSendCode with code={},area={}, mobile={}, activityCode={}", code, area, mobile, activityCode);
ApiResponse response = tencentMktService.validCodeAndSendCode(code, area, mobile, client_id, activityCode);
public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id, String activityCode,String checkCode) throws ServiceException {
log.info("validRegCodeAndSendCode with code={},area={}, mobile={}, activityCode={},checkCode={}", code, area, mobile, activityCode,checkCode);
ApiResponse response = tencentMktService.validCodeAndSendCode(code, area, mobile, client_id, activityCode,checkCode);
log.info("validRegCodeAndSendCode with code={}, area={}, mobile={}, response={}, activityCode={}",code, area, mobile, response, activityCode);
return response;
}
... ...
... ... @@ -23,7 +23,7 @@ public interface ITencentMktService {
* @return
* @throws Exception
*/
public ApiResponse sendSms(String area, String mobile, String activityCode) throws ServiceException;
public ApiResponse sendSms(String area, String mobile, String activityCode,String code) throws ServiceException;
/**
* 验证验证码
... ... @@ -38,7 +38,7 @@ public interface ITencentMktService {
* @return
* @throws ServiceException
*/
public ApiResponse validCodeAndSendCode(String code, String area, String mobile, String client_id, String activityCode) throws ServiceException;
public ApiResponse validCodeAndSendCode(String code, String area, String mobile, String client_id, String activityCode,String checkCode) throws ServiceException;
/**
* 查询活動
... ...
... ... @@ -22,7 +22,9 @@ import com.yoho.unions.convert.TencentMktActivityConvert;
import com.yoho.unions.dal.IMktMarketingUrlDAO;
import com.yoho.unions.dal.ITencentMktActivityDAO;
import com.yoho.unions.dal.ITencentMktCouponHistoryDAO;
import com.yoho.unions.dal.MktUnionCodeMapper;
import com.yoho.unions.dal.model.MktMarketingUrl;
import com.yoho.unions.dal.model.MktUnionCode;
import com.yoho.unions.dal.model.TencentMktActivity;
import com.yoho.unions.dal.model.TencentMktCouponHistory;
import com.yoho.unions.helper.*;
... ... @@ -34,6 +36,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
... ... @@ -84,6 +87,9 @@ public class TencentMktServiceImpl implements ITencentMktService {
@Resource
UserServiceHelper userServiceHelper;
@Autowired
MktUnionCodeMapper mktUnionCodeMapper;
@Resource
ITencentMktCouponHistoryDAO tencentMktCouponHistoryMapper;
... ... @@ -91,7 +97,7 @@ public class TencentMktServiceImpl implements ITencentMktService {
public static final String TENCENT_MKT__ACTIVITY_CACHEKEY = "yh:activity:tencentmkt:";
@Override
public ApiResponse sendSms(String area, String mobile, String activityCode) throws ServiceException {
public ApiResponse sendSms(String area, String mobile, String activityCode,String code) throws ServiceException {
log.info("sendSms with area={}, mobile={}, activityCode={}", area, mobile, activityCode);
// 检查参数
if (StringUtils.isEmpty(mobile)) {
... ... @@ -104,6 +110,20 @@ public class TencentMktServiceImpl implements ITencentMktService {
return new ApiResponse(503, "手机号码格式不对");
}
//新的活动链接,必须要带校验code
if(Long.valueOf(activityCode)>100000000008371L){
if(StringUtils.isEmpty(code)){
log.warn("call getUserprofileByEmailOrMobile. code is null");
return new ApiResponse(506, "校验失败");
}
//验证union_type和code能不能对应
MktUnionCode mktUnionCode =mktUnionCodeMapper.selectByCode(code);
if (null==mktUnionCode||!activityCode.equals(String.valueOf(mktUnionCode.getUnionType()))){
log.warn("call getUserprofileByEmailOrMobile. check error");
return new ApiResponse(506, "校验失败");
}
}
// 验证新老用户
ProfileRequestBO bo = new ProfileRequestBO();
bo.setMobile(mobile);
... ... @@ -180,8 +200,8 @@ public class TencentMktServiceImpl implements ITencentMktService {
}
@Override
public ApiResponse validCodeAndSendCode(String code, String area, String mobile, String client_id, String activityCode) throws ServiceException {
log.debug("validRegCodeAndSendCode with code={}, area={}, mobile={}, activityCode={}", code, area, mobile, activityCode);
public ApiResponse validCodeAndSendCode(String code, String area, String mobile, String client_id, String activityCode,String checkCode) throws ServiceException {
log.debug("validRegCodeAndSendCode with code={}, area={}, mobile={}, activityCode={},checkCode={}", code, area, mobile, activityCode,checkCode);
// 验证验证码
ApiResponse response = validRegCode(code, area, mobile);
... ... @@ -191,6 +211,20 @@ public class TencentMktServiceImpl implements ITencentMktService {
return response;
}
if(Long.valueOf(activityCode)>100000000008371L){
if(StringUtils.isEmpty(code)){
log.warn("call getUserprofileByEmailOrMobile. code is null");
return new ApiResponse(506, "校验失败");
}
//验证union_type和code能不能对应
MktUnionCode mktUnionCode =mktUnionCodeMapper.selectByCode(checkCode);
if (null==mktUnionCode||!activityCode.equals(String.valueOf(mktUnionCode.getUnionType()))){
log.warn("call getUserprofileByEmailOrMobile. check error");
return new ApiResponse(505, "校验失败");
}
}
// 判断用户是否已经注册过,如果未注册,则调用注册接口
// 老用户则直接返回
//看一下这个活动是否设置了老用户也可以领取
... ...
... ... @@ -67,6 +67,7 @@ datasources:
- com.yoho.unions.dal.IUnionUidTypeDAO
- com.yoho.unions.dal.IChannelReportFormDAO
- com.yoho.unions.dal.IMktReportFormDAO
- com.yoho.unions.dal.MktUnionCodeMapper
bigdata_yh_unions:
... ...
... ... @@ -58,6 +58,7 @@ datasources:
- com.yoho.unions.dal.IUnionUidTypeDAO
- com.yoho.unions.dal.IChannelReportFormDAO
- com.yoho.unions.dal.IMktReportFormDAO
- com.yoho.unions.dal.MktUnionCodeMapper
bigdata_yh_unions:
... ...
... ... @@ -66,6 +66,7 @@
if (activityCode == ""){
activityCode = getQueryStr("union_type");
}
var checkCode = getQueryStr("checkCode");
var activityData = null;
let search = window.location.search;
... ...
... ... @@ -157,7 +157,8 @@
url: '/union/tencentMkt/TencentMktController/sendSms',
data: {
mobile: $('#phone').val(),
activityCode: activityCode
activityCode: activityCode,
checkCode:checkCode
},
success: function(data) {
if (data.code === 200 || data.code === 502 || data.code === 503 || data.code === 404) {
... ...
... ... @@ -129,7 +129,8 @@ $('#getCoupon').on('click', function() {
url: '/union/tencentMkt/TencentMktController/sendSms',
data: {
mobile: $('#phone').val(),
activityCode: activityCode
activityCode: activityCode,
checkCode:checkCode
},
success: function(data) {
... ... @@ -166,7 +167,8 @@ $('.input-content').on('click', '.get', function() {
data: {
code: $('#verification').val(),
mobile: $('#phone').val(),
activityCode: activityCode
activityCode: activityCode,
checkCode:checkCode
},
dataType: 'json',
success: function(data) {
... ...