master
eason 6 years ago
parent 0fe284cff8
commit 91bcf7f9b3

@ -62,5 +62,9 @@ public interface SignInStatusManager {
String appQRCodeSignInStatus(String codeId);
JSONObject customerQRCode();
void scanCustomerQrcode(String codeId, String openid);
String getWechatCustomerId(String codeId);
}

@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import javax.annotation.Resource;
@ -319,6 +320,31 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
return statusKey;
}
@Override
public JSONObject customerQRCode() {
String codeId = "customer_" + RandomStringUtils.random(15, true, true) + "_" + System.currentTimeMillis();
JSONObject res = new JSONObject();
res.put("code_id", codeId);
res.put("code_img", QRCodeUtils.qrcodeImageCode(PlatformEnvironment.getEnv().concatUrl("/global/userstatus/customer_wechat_qrcode/" + codeId), 300,false));
System.out.println("====code:"+codeId);
return res;
}
@Override
public void scanCustomerQrcode(String codeId, String openid) {
stringRedisTemplate.boundValueOps(redisPrefix + ":customer_qrcode:code:" + codeId).set(openid, 1, TimeUnit.MINUTES);
}
@Override
public String getWechatCustomerId(String codeId) {
String statusKey = stringRedisTemplate.boundValueOps(redisPrefix + ":customer_qrcode:code:" + codeId).get();
if (statusKey == null) {
throw new ForbiddenException("Not signed yet");
}
stringRedisTemplate.delete(redisPrefix + ":customer_qrcode:code:" + codeId);
return statusKey;
}
private void lockRandomCodeId(String codeId) {
stringRedisTemplate.boundValueOps(redisPrefix + "partner_signin" + codeId).set(codeId, 30, TimeUnit.SECONDS);

@ -326,4 +326,21 @@ public class SignInController {
}
throw new ForbiddenException("error.not_support_browser");
}
@RequestMapping(value = "/customer_wechat_qrcode", method = RequestMethod.GET)
public JSONObject customerQRCode() {
return signInStatusManager.customerQRCode();
}
@WechatMapping(value = "/customer_wechat_qrcode/{codeId}", method = RequestMethod.GET)
public ModelAndView scanCustomerQrcode(@PathVariable String codeId, @ModelAttribute(CommonConsts.WECHATINFO) JSONObject wechatUser) {
signInStatusManager.scanCustomerQrcode(codeId, wechatUser.getString("openid"));
return new ModelAndView("manager_bind_success");
}
@RequestMapping(value = "/customer_wechat_qrcode/{codeId}/check", method = RequestMethod.GET)
public void getCustomerID(@PathVariable String codeId, HttpServletResponse response) {
String statusKey = signInStatusManager.getWechatCustomerId(codeId);
HttpUtils.setCookie(response, "CustomerID", statusKey,false);
}
}

@ -23,6 +23,7 @@
}
.order-box{
height: 400px;
width: 800px;
margin: 2% auto;
box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.21);
@ -66,7 +67,7 @@
color: #FFFFFF;
}
.intro{
line-height: 550px;
margin: 100px 0 50px;
color: #FFFFFF;
}
.order-box .right{

Loading…
Cancel
Save