Authored by ping

Merge branch 'dev' into test

... ... @@ -36,6 +36,7 @@ public class ClientSecretHelper {
if (MapUtils.isEmpty(map)) {
return null;
}
map.put("v", "7");
map.put("client_secret", securityInterceptor.getSign(map));
List<String> list = new ArrayList<String>();
for (Entry<String, String> entry : map.entrySet()) {
... ...
... ... @@ -11,4 +11,23 @@ public class RandomUtil {
sb.append("yh");
return sb.toString();
}
/**
* java生成随机数字和字母组合
* @param length[生成随机数的长度]
* @return
*/
public static String getCharAndNumr(int numLength,int charLength) {
String val = "";
Random random = new Random();
for (int i = 0; i < 6; i++) {
// 输出字母还是数字
val += String.valueOf(random.nextInt(10));
}
for(int j=0;j<2;j++){
int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
val += (char) (choice + random.nextInt(26));
}
return val;
}
}
... ...
... ... @@ -7,10 +7,12 @@ import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.yoho.activity.common.ApiResponse;
import com.yoho.activity.service.ICocacolaService;
import com.yoho.error.exception.ServiceException;
... ... @@ -22,12 +24,15 @@ import com.yoho.error.exception.ServiceException;
* 2016年4月1日
*/
@Controller
@RequestMapping("/cocacola/CocacolaController")
public class CocacolaController {
static Logger log = LoggerFactory.getLogger(CocacolaController.class);
@Resource
ICocacolaService cocacolaService;
@Value("${cocacola.wechat.share.url}")
private String wechatShareUrl;
/**
* 发送短信验证码
... ... @@ -36,7 +41,7 @@ public class CocacolaController {
* @return
* @throws Exception
*/
@RequestMapping(params = "method=h5.cocacola.sendSms")
@RequestMapping("/sendSms")
@ResponseBody
public ApiResponse sendSms(String area, String mobile) throws ServiceException {
log.info("sendSms with area={}, mobile={}", area, mobile);
... ... @@ -61,7 +66,7 @@ public class CocacolaController {
* @return
* @throws ServiceException
*/
@RequestMapping(params = "method=h5.cocacola.validRegCodeAndSendCode")
@RequestMapping("/validRegCodeAndSendCode")
@ResponseBody
public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException {
log.info("validRegCodeAndSendCode with code={},area={}, mobile={},", code, area, mobile);
... ... @@ -70,6 +75,21 @@ public class CocacolaController {
return response;
}
/**
* 获取微信分享的url
* @return
* @throws ServiceException
*/
@RequestMapping("/getWechatShareUrl")
@ResponseBody
public ApiResponse getWechatShareUrl() throws ServiceException {
log.info("enter getWechatShareUrl");
String url = wechatShareUrl;
log.info("getWechatShareUrl success");
JSONObject json = new JSONObject();
json.put("wechatShareUrl", url);
ApiResponse response = new ApiResponse(json);
return response;
}
}
... ...
... ... @@ -104,6 +104,7 @@ public class CocacolaServiceImpl implements ICocacolaService {
ApiResponse response = validRegCode(code, area, mobile);
if (Constant.CODE_SUCCESS != response.getCode()) {
log.warn("validCodeAndSendCode error validCode is error with code={}, area={}, mobile={}", code, area, mobile);
response.setMessage("验证码错误");
return response;
}
... ... @@ -223,33 +224,39 @@ public class CocacolaServiceImpl implements ICocacolaService {
bo.setArea(area);
bo.setCheckSSO(true);
ProfileInfoRsp result = service.call("users.getUserprofileByEmailOrMobile", bo, ProfileInfoRsp.class);
log.info("call users.getUserprofileByEmailOrMobile result is {}", result);
// 查询用户不存在
JSONObject json = new JSONObject();
if (result == null || result.getUid() == 0) {
log.info("user not exists with mobile={}", mobile);
json.put("newUser", true);
// 2.调用注册
RegisterReqBO registerReqBO = new RegisterReqBO();
registerReqBO.setArea(area);
registerReqBO.setProfile(mobile);
registerReqBO.setPassword(RandomUtil.autoGetPassword());
registerReqBO.setPassword(RandomUtil.getCharAndNumr(6, 2));
registerReqBO.setClient_type(client_type);
RegisterRspBO model = null;
try {
model = service.call("users.register", registerReqBO, RegisterRspBO.class);
log.info("call register result is {}", model);
json.put("password", registerReqBO.getPassword());
// 3.记录新注册用户 领取人数
yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
yhRedisTemplate.longExpire(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 30, TimeUnit.DAYS);
} catch (Exception e) {
log.warn("Redis exception. check get times. area is {}, mobile is {}, client_type={},exception is {}", area, mobile, client_type, e.getMessage());
return new ApiResponse(603, "领取优惠券失败");
}
try {
yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
yhRedisTemplate.longExpire(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 30, TimeUnit.DAYS);
} catch (Exception e) {
log.warn("cocacola set redis error with mobile is {}", mobile);
}
json.put("uid", model.getUid());
}
// 3.已注册用户,redis记录领取人数
else {
log.info("user has exists with mobile={}", mobile);
json.put("newUser", false);
try {
yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
... ...
... ... @@ -18,6 +18,7 @@
<list>
<value>/LuckyUserNoticeRest/noticeByActId/</value>
<value>/LuckyDrawHandlerRest/luckyDraw/</value>
<value>.+/CocacolaController/.+</value>
</list>
</property>
<property name="excludeMethods">
... ... @@ -25,8 +26,6 @@
<value>app.drawline.sendAwardToLuckyUser</value>
<value>app.drawline.executeAddWhiteUser</value>
<value>app.drawline.executeAddVirtualUser</value>
<value>h5.cocacola.sendSms</value>
<value>h5.cocacola.validRegCodeAndSendCode</value>
</list>
</property>
</bean>
... ...
... ... @@ -25,7 +25,7 @@ redis.proxy.auth=
execute.timetask.host=192.168.90.9
#zkAddress
zkAddress=127.0.0.1:2181
zkAddress=192.168.102.205:2181
# web context
web.context=activity
... ... @@ -50,4 +50,6 @@ activity.drawlinelist.redisExpire=10
gateway.url=http://192.168.102.205:8080/gateway
#调用运维发送短信接口时的,需要传入的密码(AES加密)
sendSMS.password=7jVEde87bLffoTnt6tGxmw==
\ No newline at end of file
sendSMS.password=7jVEde87bLffoTnt6tGxmw==
#可口可乐活动,微信分享地址
cocacola.wechat.share.url=http://devservice.yoho.cn:58077/activity/cocacola/html/index1.html
\ No newline at end of file
... ...
... ... @@ -11,7 +11,8 @@
<property name="drawline.luckyUserNotice.interval" defaultValue="5" description="执行定时抽奖任务间隔,5分钟执行一次" />
<property name="is_debug_enable" defaultValue="false" description="开通接口访问校验" />
<property name="execute.timetask.host" defaultValue="192.168.90.9" description="绑定定时任务IP" />
<property name="gateway.url" defaultValue="http://192.168.102.205:8080/gateway" description="gateway 的地址" />
<property name="gateway.url" defaultValue="http://testapi.yoho.cn:28078" description="gateway 的地址" />
<property name="cocacola.wechat.share.url" defaultValue="http://testservice.yoho.cn:28077/activity/cocacola/html/index1.html" description="可口可乐活动,微信分享地址" />
<property name="sendSMS.password" defaultValue="7jVEde87bLffoTnt6tGxmw==" description="调用运维发送短信接口时的,需要传入的密码(AES加密)" />
</group>
<script>
... ...
... ... @@ -50,4 +50,7 @@ activity.drawlinelist.redisExpire=10
gateway.url=${gateway.url}
#\u8C03\u7528\u8FD0\u7EF4\u53D1\u9001\u77ED\u4FE1\u63A5\u53E3\u65F6\u7684\uFF0C\u9700\u8981\u4F20\u5165\u7684\u5BC6\u7801\uFF08AES\u52A0\u5BC6\uFF09
sendSMS.password=${sendSMS.password}
\ No newline at end of file
sendSMS.password=${sendSMS.password}
#\u53EF\u53E3\u53EF\u4E50\u6D3B\u52A8\uFF0C\u5FAE\u4FE1\u5206\u4EAB\u5730\u5740
cocacola.wechat.share.url=${cocacola.wechat.share.url}
\ No newline at end of file
... ...
... ... @@ -172,6 +172,10 @@
color: #fff;
margin: 0 40%;
}
.btn-list a{
text-decoration:none;
color: #000;
}
</style>
</head>
<body>
... ... @@ -299,11 +303,23 @@
if (typeof(wx) == "undefined") {
return;
}
var shareUrl = "";
$.ajax({
async : false,
url : "/activity/cocacola/CocacolaController/getWechatShareUrl",
dataType : "json",
success : function(data) {
if (!data || data.code != 200) {
return;
}
shareUrl = data.data.wechatShareUrl;
}
});
var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';
var shareTitle = '来Yoho!Buy有货玩潮流,潮流逛不停';
var shareImg = 'http://img12.static.yhbimg.com/activity/2016/04/07/11/02b3b297581ace1ca6251f7f9e67ca7937.jpg';
var shareDesc = '揭盖赢福利,潮流逛不停';
var shareLink = 'http://172.16.6.190:8090/activity/cocacola/index1.html';
var shareLink = shareUrl;
$.getJSON(_weChatInterface + '?pageurl=' +
encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
var _appId, _timestamp, _nonceStr, _signature;
... ...
... ... @@ -241,10 +241,9 @@ var num = 0;
return;
}
$.ajax({
url:'/activity/',
url:'/activity/cocacola/CocacolaController/sendSms',
data : {
mobile : $("#phone").val(),
method : "h5.cocacola.sendSms"
mobile : $("#phone").val()
},
dataType:'json',
success:function(data){
... ... @@ -272,7 +271,7 @@ var num = 0;
$('.centent span').eq('1').removeClass('get');
if ($(this).siblings('input').val().length === 4) {
$.ajax({
url:'/activity/?method=h5.cocacola.validRegCodeAndSendCode',
url:'/activity/cocacola/CocacolaController/validRegCodeAndSendCode',
data : {
code : $("#verification").val(),
mobile : $("#phone").val(),
... ... @@ -324,11 +323,23 @@ var num = 0;
if (typeof(wx) == "undefined") {
return;
}
var shareUrl = "";
$.ajax({
async : false,
url : "/activity/cocacola/CocacolaController/getWechatShareUrl",
dataType : "json",
success : function(data) {
if (!data || data.code != 200) {
return;
}
shareUrl = data.data.wechatShareUrl;
}
});
var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';
var shareTitle = '来Yoho!Buy有货玩潮流,潮流逛不停';
var shareImg = 'http://img12.static.yhbimg.com/activity/2016/04/07/11/02b3b297581ace1ca6251f7f9e67ca7937.jpg';
var shareDesc = '揭盖赢福利,潮流逛不停';
var shareLink = 'http://172.16.6.190:8090/activity/cocacola/index1.html';
var shareLink = shareUrl;
$.getJSON(_weChatInterface + '?pageurl=' +
encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
var _appId, _timestamp, _nonceStr, _signature;
... ...