Commit ddd71fb1 by gaopeng

Cookie字符串转数字方法修改

parent 5eedcfb4
......@@ -12,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.string.StringUtil;
/**
......@@ -125,25 +126,25 @@ public class Cookie {
String[] channel = userInfoArry[i].split("=");
String channelId = channel[channel.length - 1];
userInfos.put("channelId", StringUtil.isEmpty(channelId) || "undefined".equalsIgnoreCase(channelId)
|| "null".equalsIgnoreCase(channelId) ? null : Long.valueOf(channelId));
|| "null".equalsIgnoreCase(channelId) ? null : NumberUtil.toLong(channelId));
}
if (userInfoArry[i].contains("officialAccountsId")) {
String[] wechat = userInfoArry[i].split("=");
String officialAccountsId = wechat[wechat.length - 1];
userInfos.put("officialAccountsId", StringUtil.isEmpty(officialAccountsId) || "undefined".equalsIgnoreCase(officialAccountsId)
|| "null".equalsIgnoreCase(officialAccountsId) ? null : Long.valueOf(officialAccountsId));
|| "null".equalsIgnoreCase(officialAccountsId) ? null : NumberUtil.toLong(officialAccountsId));
}
if (userInfoArry[i].contains("wechatUserId")) {
String[] user = userInfoArry[i].split("=");
String wechatUserId = user[user.length - 1];
userInfos.put("wechatUserId", StringUtil.isEmpty(wechatUserId) || "undefined".equalsIgnoreCase(wechatUserId)
|| "null".equalsIgnoreCase(wechatUserId) ? null : Long.valueOf(wechatUserId));
|| "null".equalsIgnoreCase(wechatUserId) ? null : NumberUtil.toLong(wechatUserId));
}
if (userInfoArry[i].contains("partyId")) {
String[] party = userInfoArry[i].split("=");
String partyId = party[party.length - 1];
userInfos.put("partyId", StringUtil.isEmpty(partyId) || "undefined".equalsIgnoreCase(partyId) || "null".equalsIgnoreCase(partyId)
? null : Long.valueOf(partyId));
? null : NumberUtil.toLong(partyId));
}
// editBy TC cookie里面需要带上顾问,systemCode,是否系统,场景值
// modify by songx at 2017-05-17 如果值为undefined或者null直接跳过
......@@ -151,7 +152,7 @@ public class Cookie {
String[] adviser = userInfoArry[i].split("=");
String adviserId = adviser[adviser.length - 1];
userInfos.put("adviserId", StringUtil.isEmpty(adviserId) || "undefined".equalsIgnoreCase(adviserId) || "null".equalsIgnoreCase(adviserId)
? null : Long.valueOf(adviserId));
? null : NumberUtil.toLong(adviserId));
}
if (userInfoArry[i].contains("systemCode")) {
String[] systemCode = userInfoArry[i].split("=");
......@@ -168,25 +169,25 @@ public class Cookie {
String[] scene = userInfoArry[i].split("=");
String sceneId = scene[scene.length - 1];
userInfos.put("sceneId", StringUtil.isEmpty(sceneId) || "undefined".equalsIgnoreCase(sceneId) || "null".equalsIgnoreCase(sceneId) ? null
: Long.valueOf(sceneId));
: NumberUtil.toLong(sceneId));
}
if (userInfoArry[i].contains("userId")) {
String[] userLogin = userInfoArry[i].split("=");
String userId = userLogin[userLogin.length - 1];
userInfos.put("userId", StringUtil.isEmpty(userId) || "undefined".equalsIgnoreCase(userId) || "null".equalsIgnoreCase(userId) ? null
: Long.valueOf(userId));
: NumberUtil.toLong(userId));
}
if (userInfoArry[i].contains("merchantMemberId")) {
String[] merchant = userInfoArry[i].split("=");
String merchantMemberId = merchant[merchant.length - 1];
userInfos.put("merchantMemberId", StringUtil.isEmpty(merchantMemberId) || "undefined".equalsIgnoreCase(merchantMemberId)
|| "null".equalsIgnoreCase(merchantMemberId) ? null : Long.valueOf(merchantMemberId));
|| "null".equalsIgnoreCase(merchantMemberId) ? null : NumberUtil.toLong(merchantMemberId));
}
if (userInfoArry[i].contains("agentMemberId")) {
String[] merchant = userInfoArry[i].split("=");
String agentMemberId = merchant[merchant.length - 1];
userInfos.put("agentMemberId", StringUtil.isEmpty(agentMemberId) || "undefined".equalsIgnoreCase(agentMemberId)
|| "null".equalsIgnoreCase(agentMemberId) ? null : Long.valueOf(agentMemberId));
|| "null".equalsIgnoreCase(agentMemberId) ? null : NumberUtil.toLong(agentMemberId));
}
// add by gaop
if (userInfoArry[i].contains(PREVIEW_TYPE)) {
......@@ -205,13 +206,13 @@ public class Cookie {
String[] firstTD = userInfoArry[i].split("=");
String code = firstTD[firstTD.length - 1];
userInfos.put(FIRST_TD, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: Long.valueOf(code));
: NumberUtil.toLong(code));
}
if (userInfoArry[i].contains(SECOND_TD)) {
String[] secondTD = userInfoArry[i].split("=");
String code = secondTD[secondTD.length - 1];
userInfos.put(SECOND_TD, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: Long.valueOf(code));
: NumberUtil.toLong(code));
}
}
return userInfos;
......@@ -226,7 +227,7 @@ public class Cookie {
*/
public static Long getId(String userInfo, String type) throws BizException {
String value = getString(userInfo, type);
return StringUtil.isEmpty(value) || "undefined".equalsIgnoreCase(value) || "null".equalsIgnoreCase(value) ? null : Long.valueOf(value);
return StringUtil.isEmpty(value) || "undefined".equalsIgnoreCase(value) || "null".equalsIgnoreCase(value) ? null : NumberUtil.toLong(value);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment