add 开店状态通知、app扫码接口增加source参数

master
luoyang 5 years ago
parent 20200198c8
commit 963dbc7040

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.3.51</version> <version>1.3.52</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -14,5 +14,7 @@ public interface RetailRSvcService {
JSONObject enterIntoServiceBySourceCode(String sourceCode, JSONObject params); JSONObject enterIntoServiceBySourceCode(String sourceCode, JSONObject params);
JSONObject setUpShopBySourceCode(String sourceCode, JSONObject params);
JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker); JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker);
} }

@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean; import au.com.royalpay.payment.manage.appclient.beans.RSvcMchBean;
import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService; import au.com.royalpay.payment.manage.appclient.core.RetailRSvcService;
import au.com.royalpay.payment.manage.appclient.extend.JWTUtil; import au.com.royalpay.payment.manage.appclient.extend.JWTUtil;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper; import au.com.royalpay.payment.manage.mappers.system.ClientServicesApplyMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.codec.AESCrypt; import au.com.royalpay.payment.tools.codec.AESCrypt;
@ -38,6 +39,8 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
private CommonIncrementalChannelMapper commonIncrementalChannelMapper; private CommonIncrementalChannelMapper commonIncrementalChannelMapper;
@Resource @Resource
private ClientServicesApplyMapper clientServicesApplyMapper; private ClientServicesApplyMapper clientServicesApplyMapper;
@Resource
private ClientConfigMapper clientConfigMapper;
@Override @Override
public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) { public JSONObject findMchInfoBySourceCode(JSONObject device, String sourceCode) {
@ -128,6 +131,41 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
return result; return result;
} }
@Override
public JSONObject setUpShopBySourceCode(String sourceCode, JSONObject params) {
JSONObject result = new JSONObject();
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);
try {
if (svcInfo == null || StringUtils.isEmpty(svcInfo.getString("channel_pub_key"))
|| StringUtils.isEmpty(svcInfo.getString("platform_pub_key")) || StringUtils.isEmpty("platform_pri_key")) {
throw new BadRequestException("this channel config is wrong");
}
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(params.getString("nonce_str")));
String signa = params.getString("sign");
params.remove("sign");
params = JSONObject.parseObject(JSON.toJSONString(params), Feature.OrderedField);
boolean checkSign = SignUtils.validSign(params.toJSONString(), signa, svcInfo.getString("channel_pub_key"));
if (!checkSign) {
throw new BadRequestException("sign is wrong");
}
String clientMoniker = decData(params.getString("partnerCode"), key, svcInfo.getString("platform_pri_key"));
logger.debug("{} new shop set up :{}", clientMoniker,params.toJSONString());
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id"));
clientConfig.put("geek_shop_status", 1);
clientConfigMapper.update(clientConfig);
result.put("result_status", "SUCCESS");
} catch (Exception e) {
logger.error("set up geek shop fail:{} - {}",sourceCode,e.getMessage());
result.put("result_status", "SYSTEMERROR");
result.put("result_msg", e.getMessage());
}
return result;
}
@Override @Override
public JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker) { public JSONObject getGeekSsoTokenInfo(String sourceCode, String clientMoniker) {
JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode); JSONObject svcInfo = commonIncrementalChannelMapper.findIncreamentalChannelBySourceCode(sourceCode);

@ -422,8 +422,9 @@ public class RetailAppController {
} }
@GetMapping("/partner_signin_app_qrcode/{codeId}") @GetMapping("/partner_signin_app_qrcode/{codeId}")
public void partnerAppSigninViaQRCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String codeId) { public void partnerAppSigninViaQRCode(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String codeId,
signInStatusManager.clientQRCodeAppSignIn(device, codeId); @RequestParam(required = false) String source) {
signInStatusManager.clientQRCodeAppSignIn(device, codeId, source);
} }
/* 优惠券Begin */ /* 优惠券Begin */

@ -17,4 +17,9 @@ public class RsvcServiceController {
public JSONObject enterIntoServiceBySourceCode(@PathVariable String source_code, @RequestBody JSONObject params) { public JSONObject enterIntoServiceBySourceCode(@PathVariable String source_code, @RequestBody JSONObject params) {
return retailRSvcService.enterIntoServiceBySourceCode(source_code, params); return retailRSvcService.enterIntoServiceBySourceCode(source_code, params);
} }
@PostMapping(value = "/{source_code}/setUpShop")
public JSONObject setUpShopBySourceCode(@PathVariable String source_code, @RequestBody JSONObject params) {
return retailRSvcService.setUpShopBySourceCode(source_code, params);
}
} }

@ -56,11 +56,11 @@ public interface SignInStatusManager {
JSONObject newClientAppSignInQRCode(); JSONObject newClientAppSignInQRCode();
void clientQRCodeAppSignIn(JSONObject device, String codeId); void clientQRCodeAppSignIn(JSONObject device, String codeId, String source);
void clientQRCodeWechatSignIn(JSONObject wxUser, String codeId); void clientQRCodeWechatSignIn(JSONObject wxUser, String codeId);
String appQRCodeSignInStatus(String codeId); JSONObject appQRCodeSignInStatus(String codeId);
JSONObject customerQRCode(); JSONObject customerQRCode();

@ -4,7 +4,6 @@ import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo; import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.connections.mpsupport.MpClient;
import au.com.royalpay.payment.tools.connections.mpsupport.MpClientAppWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpClientAppWechatApiProvider;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
@ -316,7 +315,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
} }
@Override @Override
public void clientQRCodeAppSignIn(JSONObject device, String codeId) { public void clientQRCodeAppSignIn(JSONObject device, String codeId, String source) {
getlockRandomCodeId(codeId); getlockRandomCodeId(codeId);
String statusKey = newStatusKey(); String statusKey = newStatusKey();
JSONObject account = new JSONObject(); JSONObject account = new JSONObject();
@ -328,6 +327,9 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
} }
stringRedisTemplate.boundValueOps(partnerLoginRedisKey(statusKey)).set("" + account.getString("account_id"), 30, TimeUnit.MINUTES); stringRedisTemplate.boundValueOps(partnerLoginRedisKey(statusKey)).set("" + account.getString("account_id"), 30, TimeUnit.MINUTES);
stringRedisTemplate.boundValueOps(redisPrefix + ":app_qrcode_signin:code:" + codeId).set(statusKey, 1, TimeUnit.MINUTES); stringRedisTemplate.boundValueOps(redisPrefix + ":app_qrcode_signin:code:" + codeId).set(statusKey, 1, TimeUnit.MINUTES);
if (StringUtils.isNotBlank(source)) {
stringRedisTemplate.boundValueOps(redisPrefix + ":app_qrcode_signin_" + source + ":code:" + codeId).set(statusKey, 1, TimeUnit.MINUTES);
}
} }
@Override @Override
@ -346,13 +348,20 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
} }
@Override @Override
public String appQRCodeSignInStatus(String codeId) { public JSONObject appQRCodeSignInStatus(String codeId) {
JSONObject statusInfo = new JSONObject();
String statusKey = stringRedisTemplate.boundValueOps(redisPrefix + ":app_qrcode_signin:code:" + codeId).get(); String statusKey = stringRedisTemplate.boundValueOps(redisPrefix + ":app_qrcode_signin:code:" + codeId).get();
if (statusKey == null) { if (statusKey == null) {
throw new ForbiddenException("Not signed yet"); throw new ForbiddenException("Not signed yet");
} }
stringRedisTemplate.delete(redisPrefix + ":app_qrcode_signin:code:" + codeId); stringRedisTemplate.delete(redisPrefix + ":app_qrcode_signin:code:" + codeId);
return statusKey; String source = stringRedisTemplate.boundValueOps(redisPrefix + ":app_qrcode_signin_RYCBSM:code:" + codeId).get();
if (source != null) {
statusInfo.put("redirect_geek", true);
stringRedisTemplate.delete(redisPrefix + ":app_qrcode_signin_RYCBSM:code:" + codeId);
}
statusInfo.put("status_key", statusKey);
return statusInfo;
} }
@Override @Override

@ -20,6 +20,7 @@ import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.code.kaptcha.Producer; import com.google.code.kaptcha.Producer;
import org.apache.commons.lang3.StringUtils;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -315,9 +316,11 @@ public class SignInController {
@GetMapping("/partner_signin_app_qrcode/{codeId}/check") @GetMapping("/partner_signin_app_qrcode/{codeId}/check")
public void checkQRCodeAppLoginStatus(@PathVariable String codeId, HttpServletResponse response) { public JSONObject checkQRCodeAppLoginStatus(@PathVariable String codeId, HttpServletResponse response) {
String statusKey = signInStatusManager.appQRCodeSignInStatus(codeId); JSONObject statusInfo = signInStatusManager.appQRCodeSignInStatus(codeId);
HttpUtils.setCookie(response, CommonConsts.PARTNER_STATUS, statusKey); HttpUtils.setCookie(response, CommonConsts.PARTNER_STATUS, statusInfo.getString("status_key"));
statusInfo.remove("status_key");
return statusInfo;
} }
@WechatMapping(value = "/partner_signin_qrcode/{codeId}", method = RequestMethod.GET) @WechatMapping(value = "/partner_signin_qrcode/{codeId}", method = RequestMethod.GET)
@ -327,13 +330,18 @@ public class SignInController {
} }
@GetMapping("/partner_signin_qrcode/verify/{codeId}") @GetMapping("/partner_signin_qrcode/verify/{codeId}")
public void verifyQRCode(@PathVariable String codeId, @RequestHeader("User-Agent") String ua, HttpServletResponse response) throws IOException { public void verifyQRCode(@PathVariable String codeId, @RequestHeader("User-Agent") String ua,
HttpServletResponse response, @RequestParam(required = false) String source) throws IOException {
if (ua.toLowerCase().contains("micromessenger")) { if (ua.toLowerCase().contains("micromessenger")) {
response.sendRedirect("/global/userstatus/partner_signin_qrcode/" + codeId); response.sendRedirect("/global/userstatus/partner_signin_qrcode/" + codeId);
return; return;
} }
if (ua.toLowerCase().contains("royalpayclient")) { if (ua.toLowerCase().contains("royalpayclient")) {
response.sendRedirect("/api/v1.0/retail/app/partner_signin_app_qrcode/" + codeId); if (StringUtils.isNotBlank(source)) {
response.sendRedirect("/api/v1.0/retail/app/partner_signin_app_qrcode/" + codeId + "?source=" + source);
}else {
response.sendRedirect("/api/v1.0/retail/app/partner_signin_app_qrcode/" + codeId);
}
return; return;
} }
throw new ForbiddenException("error.not_support_browser"); throw new ForbiddenException("error.not_support_browser");

@ -338,8 +338,12 @@
$.ajax({ $.ajax({
url: '/global/userstatus/partner_signin_app_qrcode/' + codeId + '/check', url: '/global/userstatus/partner_signin_app_qrcode/' + codeId + '/check',
method: 'get', method: 'get',
success: function () { success: function (res) {
getGeekSsoLoginUrl(); if (res.redirect_geek) {
getGeekSsoLoginUrl();
}else {
location.href = '/index.html';
}
}, },
error: function () { error: function () {
if ($('#qrdiv').is(":visible")) { if ($('#qrdiv').is(":visible")) {

@ -319,8 +319,12 @@
$.ajax({ $.ajax({
url: '/global/userstatus/partner_signin_app_qrcode/' + codeId + '/check', url: '/global/userstatus/partner_signin_app_qrcode/' + codeId + '/check',
method: 'get', method: 'get',
success: function () { success: function (res) {
getGeekSsoLoginUrl(); if (res.redirect_geek) {
getGeekSsoLoginUrl();
}else {
location.href = '/index.html';
}
}, },
error: function () { error: function () {
if ($('#qrdiv').is(":visible")) { if ($('#qrdiv').is(":visible")) {

Loading…
Cancel
Save