|
|
|
@ -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);
|
|
|
|
|