Browse Source

[POS][修改]:B用户登录检查

release_toaliyun_real
Stormeye Wu 6 years ago
parent
commit
cb790ef5ff
2 changed files with 17 additions and 12 deletions
  1. +17
    -11
      mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java
  2. +0
    -1
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java

+ 17
- 11
mallinkBApi/src/main/java/com/iformall/utils/PosUtil.java View File

@@ -1,7 +1,6 @@
package com.iformall.utils; package com.iformall.utils;


import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
@@ -13,10 +12,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


@@ -41,19 +36,20 @@ public class PosUtil {
private final OkHttpClient client = new OkHttpClient(); private final OkHttpClient client = new OkHttpClient();
private String doPost(String url, Map<String, String> paramMap) { private String doPost(String url, Map<String, String> paramMap) {
String result = null; String result = null;
FormBody.Builder builder = new FormBody.Builder();
MediaType jsonType = MediaType.parse("application/json; charset=utf-8");
JSONObject json = new JSONObject();
for (Map.Entry<String, String> entry: paramMap.entrySet()) { for (Map.Entry<String, String> entry: paramMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String value = entry.getValue(); String value = entry.getValue();
// 略过空值 // 略过空值
if (StringUtils.isBlank(value)) if (StringUtils.isBlank(value))
continue; continue;
builder.add(key, value);
json.put(key, value);
} }
RequestBody body = builder.build();
RequestBody requestBody = RequestBody.create(jsonType, JSON.toJSONString(json));
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
.post(body)
.post(requestBody)
.build(); .build();
Response response = null; Response response = null;
try { try {
@@ -83,10 +79,11 @@ public class PosUtil {
public String checkUserPassword(String baseUrl, String devId, String reqKey, String resKey, public String checkUserPassword(String baseUrl, String devId, String reqKey, String resKey,
String tenantId, String phone, String password) throws MallinkException { String tenantId, String phone, String password) throws MallinkException {
Map<String, String> paramMap = new HashMap<>(); Map<String, String> paramMap = new HashMap<>();
paramMap.put(WxPayConstant.DEV_ID, devId);
paramMap.put(WxPayConstant.TENANT_ID, tenantId); paramMap.put(WxPayConstant.TENANT_ID, tenantId);
paramMap.put(WxPayConstant.PHONE, phone); paramMap.put(WxPayConstant.PHONE, phone);
paramMap.put(WxPayConstant.PASSWORD, password); paramMap.put(WxPayConstant.PASSWORD, password);
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, resKey);
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey);


String respStr = doPost(baseUrl + checkUserPassword, paramMap); String respStr = doPost(baseUrl + checkUserPassword, paramMap);
if(respStr == null) { if(respStr == null) {
@@ -101,6 +98,15 @@ public class PosUtil {
public static void main(String[] args) { public static void main(String[] args) {
PosUtil posUtil = new PosUtil(); PosUtil posUtil = new PosUtil();
String resStr = posUtil.checkUserPassword(domain, devId, reqKey, resKey, "456", "13120223636", "drpos345"); String resStr = posUtil.checkUserPassword(domain, devId, reqKey, resKey, "456", "13120223636", "drpos345");
System.out.println(resStr);
if (resStr != null) {
System.out.println(resStr);
JSONObject retObj = JSON.parseObject(resStr);
Map options = retObj;
if (!WxPayment.verifyNotifyHMAC(options, resKey)) {
System.out.println("verify sign error");
} else {
System.out.println("verify sign ok");
}
}
} }
} }

+ 0
- 1
mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java View File

@@ -115,7 +115,6 @@ public class PosServiceImpl implements PosService {
retMap.put(WxPayConstant.TENANT_ID, user1.getTenantId()); retMap.put(WxPayConstant.TENANT_ID, user1.getTenantId());
retMap.put(WxPayConstant.MERCHANT_ID, String.valueOf(user1.getMerchantId())); retMap.put(WxPayConstant.MERCHANT_ID, String.valueOf(user1.getMerchantId()));
retMap.put(WxPayConstant.BUSER_ID, String.valueOf(user1.getId())); retMap.put(WxPayConstant.BUSER_ID, String.valueOf(user1.getId()));
retMap.put(WxPayConstant.MEM_ID, String.valueOf(user1.getId()));
return retMap; return retMap;
} else { } else {
logger.error(ErrorCode.PASSWORD_ERROR.getMessage()); logger.error(ErrorCode.PASSWORD_ERROR.getMessage());


Loading…
Cancel
Save