Просмотр исходного кода

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

release_toaliyun_real
Stormeye Wu 6 лет назад
Родитель
Сommit
cb790ef5ff
2 измененных файлов: 17 добавлений и 12 удалений
  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 Просмотреть файл

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

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

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.Map;

@@ -41,19 +36,20 @@ public class PosUtil {
private final OkHttpClient client = new OkHttpClient();
private String doPost(String url, Map<String, String> paramMap) {
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()) {
String key = entry.getKey();
String value = entry.getValue();
// 略过空值
if (StringUtils.isBlank(value))
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()
.url(url)
.post(body)
.post(requestBody)
.build();
Response response = null;
try {
@@ -83,10 +79,11 @@ public class PosUtil {
public String checkUserPassword(String baseUrl, String devId, String reqKey, String resKey,
String tenantId, String phone, String password) throws MallinkException {
Map<String, String> paramMap = new HashMap<>();
paramMap.put(WxPayConstant.DEV_ID, devId);
paramMap.put(WxPayConstant.TENANT_ID, tenantId);
paramMap.put(WxPayConstant.PHONE, phone);
paramMap.put(WxPayConstant.PASSWORD, password);
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, resKey);
paramMap = WxPayment.buildSignAfterParasMapForHMAC(paramMap, reqKey);

String respStr = doPost(baseUrl + checkUserPassword, paramMap);
if(respStr == null) {
@@ -101,6 +98,15 @@ public class PosUtil {
public static void main(String[] args) {
PosUtil posUtil = new PosUtil();
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 Просмотреть файл

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


Загрузка…
Отмена
Сохранить