Authored by ping

Merge branch 'dev' into test

@@ -36,6 +36,7 @@ public class ClientSecretHelper { @@ -36,6 +36,7 @@ public class ClientSecretHelper {
36 if (MapUtils.isEmpty(map)) { 36 if (MapUtils.isEmpty(map)) {
37 return null; 37 return null;
38 } 38 }
  39 + map.put("v", "7");
39 map.put("client_secret", securityInterceptor.getSign(map)); 40 map.put("client_secret", securityInterceptor.getSign(map));
40 List<String> list = new ArrayList<String>(); 41 List<String> list = new ArrayList<String>();
41 for (Entry<String, String> entry : map.entrySet()) { 42 for (Entry<String, String> entry : map.entrySet()) {
@@ -11,4 +11,23 @@ public class RandomUtil { @@ -11,4 +11,23 @@ public class RandomUtil {
11 sb.append("yh"); 11 sb.append("yh");
12 return sb.toString(); 12 return sb.toString();
13 } 13 }
  14 +
  15 + /**
  16 + * java生成随机数字和字母组合
  17 + * @param length[生成随机数的长度]
  18 + * @return
  19 + */
  20 + public static String getCharAndNumr(int numLength,int charLength) {
  21 + String val = "";
  22 + Random random = new Random();
  23 + for (int i = 0; i < 6; i++) {
  24 + // 输出字母还是数字
  25 + val += String.valueOf(random.nextInt(10));
  26 + }
  27 + for(int j=0;j<2;j++){
  28 + int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
  29 + val += (char) (choice + random.nextInt(26));
  30 + }
  31 + return val;
  32 + }
14 } 33 }
@@ -7,10 +7,12 @@ import javax.annotation.Resource; @@ -7,10 +7,12 @@ import javax.annotation.Resource;
7 7
8 import org.slf4j.Logger; 8 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Value;
10 import org.springframework.stereotype.Controller; 11 import org.springframework.stereotype.Controller;
11 import org.springframework.web.bind.annotation.RequestMapping; 12 import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.ResponseBody; 13 import org.springframework.web.bind.annotation.ResponseBody;
13 14
  15 +import com.alibaba.fastjson.JSONObject;
14 import com.yoho.activity.common.ApiResponse; 16 import com.yoho.activity.common.ApiResponse;
15 import com.yoho.activity.service.ICocacolaService; 17 import com.yoho.activity.service.ICocacolaService;
16 import com.yoho.error.exception.ServiceException; 18 import com.yoho.error.exception.ServiceException;
@@ -22,12 +24,15 @@ import com.yoho.error.exception.ServiceException; @@ -22,12 +24,15 @@ import com.yoho.error.exception.ServiceException;
22 * 2016年4月1日 24 * 2016年4月1日
23 */ 25 */
24 @Controller 26 @Controller
  27 +@RequestMapping("/cocacola/CocacolaController")
25 public class CocacolaController { 28 public class CocacolaController {
26 29
27 static Logger log = LoggerFactory.getLogger(CocacolaController.class); 30 static Logger log = LoggerFactory.getLogger(CocacolaController.class);
28 31
29 @Resource 32 @Resource
30 ICocacolaService cocacolaService; 33 ICocacolaService cocacolaService;
  34 + @Value("${cocacola.wechat.share.url}")
  35 + private String wechatShareUrl;
31 36
32 /** 37 /**
33 * 发送短信验证码 38 * 发送短信验证码
@@ -36,7 +41,7 @@ public class CocacolaController { @@ -36,7 +41,7 @@ public class CocacolaController {
36 * @return 41 * @return
37 * @throws Exception 42 * @throws Exception
38 */ 43 */
39 - @RequestMapping(params = "method=h5.cocacola.sendSms") 44 + @RequestMapping("/sendSms")
40 @ResponseBody 45 @ResponseBody
41 public ApiResponse sendSms(String area, String mobile) throws ServiceException { 46 public ApiResponse sendSms(String area, String mobile) throws ServiceException {
42 log.info("sendSms with area={}, mobile={}", area, mobile); 47 log.info("sendSms with area={}, mobile={}", area, mobile);
@@ -61,7 +66,7 @@ public class CocacolaController { @@ -61,7 +66,7 @@ public class CocacolaController {
61 * @return 66 * @return
62 * @throws ServiceException 67 * @throws ServiceException
63 */ 68 */
64 - @RequestMapping(params = "method=h5.cocacola.validRegCodeAndSendCode") 69 + @RequestMapping("/validRegCodeAndSendCode")
65 @ResponseBody 70 @ResponseBody
66 public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException { 71 public ApiResponse validRegCodeAndSendCode(String code, String area, String mobile, String client_id) throws ServiceException {
67 log.info("validRegCodeAndSendCode with code={},area={}, mobile={},", code, area, mobile); 72 log.info("validRegCodeAndSendCode with code={},area={}, mobile={},", code, area, mobile);
@@ -70,6 +75,21 @@ public class CocacolaController { @@ -70,6 +75,21 @@ public class CocacolaController {
70 return response; 75 return response;
71 } 76 }
72 77
73 - 78 + /**
  79 + * 获取微信分享的url
  80 + * @return
  81 + * @throws ServiceException
  82 + */
  83 + @RequestMapping("/getWechatShareUrl")
  84 + @ResponseBody
  85 + public ApiResponse getWechatShareUrl() throws ServiceException {
  86 + log.info("enter getWechatShareUrl");
  87 + String url = wechatShareUrl;
  88 + log.info("getWechatShareUrl success");
  89 + JSONObject json = new JSONObject();
  90 + json.put("wechatShareUrl", url);
  91 + ApiResponse response = new ApiResponse(json);
  92 + return response;
  93 + }
74 94
75 } 95 }
@@ -104,6 +104,7 @@ public class CocacolaServiceImpl implements ICocacolaService { @@ -104,6 +104,7 @@ public class CocacolaServiceImpl implements ICocacolaService {
104 ApiResponse response = validRegCode(code, area, mobile); 104 ApiResponse response = validRegCode(code, area, mobile);
105 if (Constant.CODE_SUCCESS != response.getCode()) { 105 if (Constant.CODE_SUCCESS != response.getCode()) {
106 log.warn("validCodeAndSendCode error validCode is error with code={}, area={}, mobile={}", code, area, mobile); 106 log.warn("validCodeAndSendCode error validCode is error with code={}, area={}, mobile={}", code, area, mobile);
  107 + response.setMessage("验证码错误");
107 return response; 108 return response;
108 } 109 }
109 110
@@ -223,33 +224,39 @@ public class CocacolaServiceImpl implements ICocacolaService { @@ -223,33 +224,39 @@ public class CocacolaServiceImpl implements ICocacolaService {
223 bo.setArea(area); 224 bo.setArea(area);
224 bo.setCheckSSO(true); 225 bo.setCheckSSO(true);
225 ProfileInfoRsp result = service.call("users.getUserprofileByEmailOrMobile", bo, ProfileInfoRsp.class); 226 ProfileInfoRsp result = service.call("users.getUserprofileByEmailOrMobile", bo, ProfileInfoRsp.class);
  227 + log.info("call users.getUserprofileByEmailOrMobile result is {}", result);
226 // 查询用户不存在 228 // 查询用户不存在
227 JSONObject json = new JSONObject(); 229 JSONObject json = new JSONObject();
228 if (result == null || result.getUid() == 0) { 230 if (result == null || result.getUid() == 0) {
  231 + log.info("user not exists with mobile={}", mobile);
229 json.put("newUser", true); 232 json.put("newUser", true);
230 // 2.调用注册 233 // 2.调用注册
231 RegisterReqBO registerReqBO = new RegisterReqBO(); 234 RegisterReqBO registerReqBO = new RegisterReqBO();
232 registerReqBO.setArea(area); 235 registerReqBO.setArea(area);
233 registerReqBO.setProfile(mobile); 236 registerReqBO.setProfile(mobile);
234 - registerReqBO.setPassword(RandomUtil.autoGetPassword()); 237 + registerReqBO.setPassword(RandomUtil.getCharAndNumr(6, 2));
235 registerReqBO.setClient_type(client_type); 238 registerReqBO.setClient_type(client_type);
236 RegisterRspBO model = null; 239 RegisterRspBO model = null;
237 try { 240 try {
238 model = service.call("users.register", registerReqBO, RegisterRspBO.class); 241 model = service.call("users.register", registerReqBO, RegisterRspBO.class);
  242 + log.info("call register result is {}", model);
239 json.put("password", registerReqBO.getPassword()); 243 json.put("password", registerReqBO.getPassword());
240 // 3.记录新注册用户 领取人数 244 // 3.记录新注册用户 领取人数
241 -  
242 - yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);  
243 - yhRedisTemplate.longExpire(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 30, TimeUnit.DAYS);  
244 -  
245 } catch (Exception e) { 245 } catch (Exception e) {
246 log.warn("Redis exception. check get times. area is {}, mobile is {}, client_type={},exception is {}", area, mobile, client_type, e.getMessage()); 246 log.warn("Redis exception. check get times. area is {}, mobile is {}, client_type={},exception is {}", area, mobile, client_type, e.getMessage());
247 return new ApiResponse(603, "领取优惠券失败"); 247 return new ApiResponse(603, "领取优惠券失败");
248 } 248 }
  249 + try {
  250 + yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
  251 + yhRedisTemplate.longExpire(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 30, TimeUnit.DAYS);
  252 + } catch (Exception e) {
  253 + log.warn("cocacola set redis error with mobile is {}", mobile);
  254 + }
249 json.put("uid", model.getUid()); 255 json.put("uid", model.getUid());
250 } 256 }
251 // 3.已注册用户,redis记录领取人数 257 // 3.已注册用户,redis记录领取人数
252 else { 258 else {
  259 + log.info("user has exists with mobile={}", mobile);
253 json.put("newUser", false); 260 json.put("newUser", false);
254 try { 261 try {
255 yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1); 262 yhValueOperations.increment(Constant.USED_REGISTER_GET_TIME_MEM_KEY + mobile, 1);
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 <list> 18 <list>
19 <value>/LuckyUserNoticeRest/noticeByActId/</value> 19 <value>/LuckyUserNoticeRest/noticeByActId/</value>
20 <value>/LuckyDrawHandlerRest/luckyDraw/</value> 20 <value>/LuckyDrawHandlerRest/luckyDraw/</value>
  21 + <value>.+/CocacolaController/.+</value>
21 </list> 22 </list>
22 </property> 23 </property>
23 <property name="excludeMethods"> 24 <property name="excludeMethods">
@@ -25,8 +26,6 @@ @@ -25,8 +26,6 @@
25 <value>app.drawline.sendAwardToLuckyUser</value> 26 <value>app.drawline.sendAwardToLuckyUser</value>
26 <value>app.drawline.executeAddWhiteUser</value> 27 <value>app.drawline.executeAddWhiteUser</value>
27 <value>app.drawline.executeAddVirtualUser</value> 28 <value>app.drawline.executeAddVirtualUser</value>
28 - <value>h5.cocacola.sendSms</value>  
29 - <value>h5.cocacola.validRegCodeAndSendCode</value>  
30 </list> 29 </list>
31 </property> 30 </property>
32 </bean> 31 </bean>
@@ -25,7 +25,7 @@ redis.proxy.auth= @@ -25,7 +25,7 @@ redis.proxy.auth=
25 execute.timetask.host=192.168.90.9 25 execute.timetask.host=192.168.90.9
26 26
27 #zkAddress 27 #zkAddress
28 -zkAddress=127.0.0.1:2181 28 +zkAddress=192.168.102.205:2181
29 # web context 29 # web context
30 web.context=activity 30 web.context=activity
31 31
@@ -50,4 +50,6 @@ activity.drawlinelist.redisExpire=10 @@ -50,4 +50,6 @@ activity.drawlinelist.redisExpire=10
50 gateway.url=http://192.168.102.205:8080/gateway 50 gateway.url=http://192.168.102.205:8080/gateway
51 51
52 #调用运维发送短信接口时的,需要传入的密码(AES加密) 52 #调用运维发送短信接口时的,需要传入的密码(AES加密)
53 -sendSMS.password=7jVEde87bLffoTnt6tGxmw==  
  53 +sendSMS.password=7jVEde87bLffoTnt6tGxmw==
  54 +#可口可乐活动,微信分享地址
  55 +cocacola.wechat.share.url=http://devservice.yoho.cn:58077/activity/cocacola/html/index1.html
@@ -11,7 +11,8 @@ @@ -11,7 +11,8 @@
11 <property name="drawline.luckyUserNotice.interval" defaultValue="5" description="执行定时抽奖任务间隔,5分钟执行一次" /> 11 <property name="drawline.luckyUserNotice.interval" defaultValue="5" description="执行定时抽奖任务间隔,5分钟执行一次" />
12 <property name="is_debug_enable" defaultValue="false" description="开通接口访问校验" /> 12 <property name="is_debug_enable" defaultValue="false" description="开通接口访问校验" />
13 <property name="execute.timetask.host" defaultValue="192.168.90.9" description="绑定定时任务IP" /> 13 <property name="execute.timetask.host" defaultValue="192.168.90.9" description="绑定定时任务IP" />
14 - <property name="gateway.url" defaultValue="http://192.168.102.205:8080/gateway" description="gateway 的地址" /> 14 + <property name="gateway.url" defaultValue="http://testapi.yoho.cn:28078" description="gateway 的地址" />
  15 + <property name="cocacola.wechat.share.url" defaultValue="http://testservice.yoho.cn:28077/activity/cocacola/html/index1.html" description="可口可乐活动,微信分享地址" />
15 <property name="sendSMS.password" defaultValue="7jVEde87bLffoTnt6tGxmw==" description="调用运维发送短信接口时的,需要传入的密码(AES加密)" /> 16 <property name="sendSMS.password" defaultValue="7jVEde87bLffoTnt6tGxmw==" description="调用运维发送短信接口时的,需要传入的密码(AES加密)" />
16 </group> 17 </group>
17 <script> 18 <script>
@@ -50,4 +50,7 @@ activity.drawlinelist.redisExpire=10 @@ -50,4 +50,7 @@ activity.drawlinelist.redisExpire=10
50 gateway.url=${gateway.url} 50 gateway.url=${gateway.url}
51 51
52 #\u8C03\u7528\u8FD0\u7EF4\u53D1\u9001\u77ED\u4FE1\u63A5\u53E3\u65F6\u7684\uFF0C\u9700\u8981\u4F20\u5165\u7684\u5BC6\u7801\uFF08AES\u52A0\u5BC6\uFF09 52 #\u8C03\u7528\u8FD0\u7EF4\u53D1\u9001\u77ED\u4FE1\u63A5\u53E3\u65F6\u7684\uFF0C\u9700\u8981\u4F20\u5165\u7684\u5BC6\u7801\uFF08AES\u52A0\u5BC6\uFF09
53 -sendSMS.password=${sendSMS.password}  
  53 +sendSMS.password=${sendSMS.password}
  54 +
  55 +#\u53EF\u53E3\u53EF\u4E50\u6D3B\u52A8\uFF0C\u5FAE\u4FE1\u5206\u4EAB\u5730\u5740
  56 +cocacola.wechat.share.url=${cocacola.wechat.share.url}
@@ -172,6 +172,10 @@ @@ -172,6 +172,10 @@
172 color: #fff; 172 color: #fff;
173 margin: 0 40%; 173 margin: 0 40%;
174 } 174 }
  175 + .btn-list a{
  176 + text-decoration:none;
  177 + color: #000;
  178 + }
175 </style> 179 </style>
176 </head> 180 </head>
177 <body> 181 <body>
@@ -299,11 +303,23 @@ @@ -299,11 +303,23 @@
299 if (typeof(wx) == "undefined") { 303 if (typeof(wx) == "undefined") {
300 return; 304 return;
301 } 305 }
  306 + var shareUrl = "";
  307 + $.ajax({
  308 + async : false,
  309 + url : "/activity/cocacola/CocacolaController/getWechatShareUrl",
  310 + dataType : "json",
  311 + success : function(data) {
  312 + if (!data || data.code != 200) {
  313 + return;
  314 + }
  315 + shareUrl = data.data.wechatShareUrl;
  316 + }
  317 + });
302 var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage'; 318 var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';
303 var shareTitle = '来Yoho!Buy有货玩潮流,潮流逛不停'; 319 var shareTitle = '来Yoho!Buy有货玩潮流,潮流逛不停';
304 var shareImg = 'http://img12.static.yhbimg.com/activity/2016/04/07/11/02b3b297581ace1ca6251f7f9e67ca7937.jpg'; 320 var shareImg = 'http://img12.static.yhbimg.com/activity/2016/04/07/11/02b3b297581ace1ca6251f7f9e67ca7937.jpg';
305 var shareDesc = '揭盖赢福利,潮流逛不停'; 321 var shareDesc = '揭盖赢福利,潮流逛不停';
306 - var shareLink = 'http://172.16.6.190:8090/activity/cocacola/index1.html'; 322 + var shareLink = shareUrl;
307 $.getJSON(_weChatInterface + '?pageurl=' + 323 $.getJSON(_weChatInterface + '?pageurl=' +
308 encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) { 324 encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
309 var _appId, _timestamp, _nonceStr, _signature; 325 var _appId, _timestamp, _nonceStr, _signature;
@@ -241,10 +241,9 @@ var num = 0; @@ -241,10 +241,9 @@ var num = 0;
241 return; 241 return;
242 } 242 }
243 $.ajax({ 243 $.ajax({
244 - url:'/activity/', 244 + url:'/activity/cocacola/CocacolaController/sendSms',
245 data : { 245 data : {
246 - mobile : $("#phone").val(),  
247 - method : "h5.cocacola.sendSms" 246 + mobile : $("#phone").val()
248 }, 247 },
249 dataType:'json', 248 dataType:'json',
250 success:function(data){ 249 success:function(data){
@@ -272,7 +271,7 @@ var num = 0; @@ -272,7 +271,7 @@ var num = 0;
272 $('.centent span').eq('1').removeClass('get'); 271 $('.centent span').eq('1').removeClass('get');
273 if ($(this).siblings('input').val().length === 4) { 272 if ($(this).siblings('input').val().length === 4) {
274 $.ajax({ 273 $.ajax({
275 - url:'/activity/?method=h5.cocacola.validRegCodeAndSendCode', 274 + url:'/activity/cocacola/CocacolaController/validRegCodeAndSendCode',
276 data : { 275 data : {
277 code : $("#verification").val(), 276 code : $("#verification").val(),
278 mobile : $("#phone").val(), 277 mobile : $("#phone").val(),
@@ -324,11 +323,23 @@ var num = 0; @@ -324,11 +323,23 @@ var num = 0;
324 if (typeof(wx) == "undefined") { 323 if (typeof(wx) == "undefined") {
325 return; 324 return;
326 } 325 }
  326 + var shareUrl = "";
  327 + $.ajax({
  328 + async : false,
  329 + url : "/activity/cocacola/CocacolaController/getWechatShareUrl",
  330 + dataType : "json",
  331 + success : function(data) {
  332 + if (!data || data.code != 200) {
  333 + return;
  334 + }
  335 + shareUrl = data.data.wechatShareUrl;
  336 + }
  337 + });
327 var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage'; 338 var _weChatInterface = 'http://www.yohoshow.com/api/wechat/getSignPackage';
328 var shareTitle = '来Yoho!Buy有货玩潮流,潮流逛不停'; 339 var shareTitle = '来Yoho!Buy有货玩潮流,潮流逛不停';
329 var shareImg = 'http://img12.static.yhbimg.com/activity/2016/04/07/11/02b3b297581ace1ca6251f7f9e67ca7937.jpg'; 340 var shareImg = 'http://img12.static.yhbimg.com/activity/2016/04/07/11/02b3b297581ace1ca6251f7f9e67ca7937.jpg';
330 var shareDesc = '揭盖赢福利,潮流逛不停'; 341 var shareDesc = '揭盖赢福利,潮流逛不停';
331 - var shareLink = 'http://172.16.6.190:8090/activity/cocacola/index1.html'; 342 + var shareLink = shareUrl;
332 $.getJSON(_weChatInterface + '?pageurl=' + 343 $.getJSON(_weChatInterface + '?pageurl=' +
333 encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) { 344 encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
334 var _appId, _timestamp, _nonceStr, _signature; 345 var _appId, _timestamp, _nonceStr, _signature;