Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ys305751572 committed Apr 24, 2016
2 parents 68f4b07 + ba62295 commit f4f76a8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class WeixinBaseController {
private CacheService<String> cacheService;

@RequestMapping("/toLogin")
public String toLogin(HttpServletRequest request, HttpServletResponse response,Long salemanId,Model model) {
public String toLogin(HttpServletRequest request, HttpServletResponse response, Long salemanId, Model model) {
Map<String, Object> params = CookiesUtils.ReadCookieMap(request);
if (params != null && params.size() != 0) {
String mobile = (String) params.get("mobile");
Expand All @@ -68,7 +68,7 @@ public String toLogin(HttpServletRequest request, HttpServletResponse response,L
}
}
System.out.println("salemanId:" + salemanId);
model.addAttribute("salemanId",salemanId);
model.addAttribute("salemanId", salemanId);
return "weixin/login";
}

Expand All @@ -78,7 +78,7 @@ public String lostPwd() {
}

@RequestMapping("/toRegister")
public String toRegister(Model model, Long fromUserId, Long couponId,Long salemanId) {
public String toRegister(Model model, Long fromUserId, Long couponId, Long salemanId) {
System.out.println("***********************************************************3、准备注册***********************************************************");
System.out.println("邀请人id:" + fromUserId);
System.out.println("优惠券id:" + couponId);
Expand All @@ -88,12 +88,12 @@ public String toRegister(Model model, Long fromUserId, Long couponId,Long salema
model.addAttribute("couponId", couponId);

System.out.println("salemanId:" + salemanId);
model.addAttribute("salemanId",salemanId);
model.addAttribute("salemanId", salemanId);
return "weixin/register";
}

@RequestMapping("/toPassword")
public String toSetPassword(String username, String yzm, Model model, Long fromUserId, Long couponId,Long salemanId) {
public String toSetPassword(String username, String yzm, Model model, Long fromUserId, Long couponId, Long salemanId) {
System.out.println("***********************************************************4、准备注册***********************************************************");
System.out.println("邀请人id:" + fromUserId);
System.out.println("优惠券id:" + couponId);
Expand All @@ -108,12 +108,12 @@ public String toSetPassword(String username, String yzm, Model model, Long fromU

System.out.println("salemanId:" + salemanId);

model.addAttribute("salemanId",salemanId);
model.addAttribute("salemanId", salemanId);
return "weixin/setpassword";
}

@RequestMapping("/register")
public void register(HttpServletRequest request, HttpServletResponse response, String username, String password, String code, Long fromUserId, Long couponId,Long salemanId) {
public void register(HttpServletRequest request, HttpServletResponse response, String username, String password, String code, Long fromUserId, Long couponId, Long salemanId) {
try {


Expand Down Expand Up @@ -144,7 +144,7 @@ public void register(HttpServletRequest request, HttpServletResponse response, S
KUser resultUser = userService.register(user);

System.out.println("salemanId:" + salemanId);
if(salemanId != null) {
if (salemanId != null) {
SalemanRecord record = new SalemanRecord();
Saleman s = new Saleman();
s.setId(salemanId);
Expand Down Expand Up @@ -199,11 +199,21 @@ public void register(HttpServletRequest request, HttpServletResponse response, S
}

@RequestMapping("/loginCheck")
public String login(HttpServletRequest request, HttpServletResponse response, String mobile, String password, Model model) {
public String login(HttpServletRequest request, HttpServletResponse response, String mobile, String password, Model model, Long fromUserId, Long couponId) {
Boolean success = service.loginWeixin(request, response, mobile, password);
Object goUrlObj = request.getSession().getAttribute(Constant.GO_URL);
System.out.println("goUrlObj:" + goUrlObj);
if (success) {
KUser kUser = (KUser) request.getSession().getAttribute(Constant.SESSION_WEIXIN_USER);

if (null != couponId) {
Coupon coupon = couponService.getById(couponId);
if (null != coupon && coupon.getIsChanged() == 0) {
coupon.setUserId(kUser.getId());
couponService.update(coupon);
}
}

if (goUrlObj != null) {
String goUrl = (String) goUrlObj;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ public String list(HttpServletRequest request, ModelMap model) {
model.addAttribute("couponList", list);
model.addAttribute("wxUser", wxUser);
model.addAttribute("user", kUser);
} catch (Exception e) {
e.printStackTrace();
}

// 生成时间戳
String timestamp = System.currentTimeMillis() + "";
timestamp = timestamp.substring(0, 10);
// 生成时间戳
String timestamp = System.currentTimeMillis() + "";
timestamp = timestamp.substring(0, 10);

// 生成随机字符串
String noncestr = String.valueOf(System.currentTimeMillis() / 1000);
// 生成随机字符串
String noncestr = String.valueOf(System.currentTimeMillis() / 1000);

// 生成签名
String signature = getSignature(request, noncestr, timestamp, "http://qq.tt/kdxgServer/weixin/coupons/list");
// 生成签名
String signature = getSignature(request, noncestr, timestamp, "http://qq.tt/kdxgServer/weixin/coupons/list");

model.addAttribute("timestamp", timestamp);
model.addAttribute("noncestr", noncestr);
model.addAttribute("signature", signature);
} catch (Exception e){
e.printStackTrace();
}
model.addAttribute("timestamp", timestamp);
model.addAttribute("noncestr", noncestr);
model.addAttribute("signature", signature);
return "weixin/coupon-list";
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/jsp/weixin/get-coupon.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</section>
<footer class="loading">
<div class="ending1">
<input class="button5" type="button" onclick="toRegister()" value="立即加入"/>
<input class="button5" type="button" onclick="toRegister()" value="立即领取"/>
</div>
</footer>
<div style="width: 100%;height: 100px;"></div>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/weixin/login.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<img src="${contextPath}/static/weixin/images/login_ logo.png">
</figure>
</header>
<input type="hidden" id="fromUserId" value="${fromUserId}"/>
<input type="hidden" id="couponId" value="${couponId}"/>
<input type="hidden" id="salemanId" name="salemanId" value="${salemanId}">
<section class="ff">
<form action="${contextPath}/weixin/login/loginCheck" method="post">
<input type="hidden" name="fromUserId" id="fromUserId" value="${fromUserId}"/>
<input type="hidden" name="couponId" id="couponId" value="${couponId}"/>
<div class="flex_box">
<input class="flex" type="text" placeholder="请输入手机号码" id="mobile" name="mobile"/>
</div>
Expand Down

0 comments on commit f4f76a8

Please sign in to comment.