Commit 7b1f65a7 authored by Java—KA—李 青's avatar Java—KA—李 青

删除58jr相关代码

parent fd11fad2
package cn.quantgroup.xyqb.event;
import lombok.Getter;
import lombok.ToString;
import org.springframework.context.ApplicationEvent;
/**
* @author mengfan.feng
* @time 2015-09-15 15:05
*/
@Getter
@ToString
public class UserinfoChangedEvent extends ApplicationEvent {
private final String uuid;
private final Long channelId;
public UserinfoChangedEvent(Object source, String uuid, Long channelId) {
super(source);
this.uuid = uuid;
this.channelId = channelId;
}
}
package cn.quantgroup.xyqb.event.jr58;
import cn.quantgroup.xyqb.service.http.IHttpService;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class Jr58DataSender {
private static final Logger LOGGER = LoggerFactory.getLogger(Jr58DataSender.class);
@Autowired
private Jr58MessageSigner jr58MessageSigner;
@Autowired
private IHttpService httpService;
@Value("${jr58.notify.userinfo}")
private String jr58nNotifyUserinfo;
/**
* 向58金融同步用户信息
*
* @param uuid
*/
@Async
public void sendUserinfo(String uuid) {
try {
JSONObject json = new JSONObject();
json.put("salaryWay", 0);
json.put("loanPurpose", "12");
json.put("job", 0);
json.put("account", 1000);
json.put("salary", 0);
json.put("hourse", 1);
json.put("isShebao", 0);
json.put("education", "");
json.put("isCreditCard", "0");
json.put("isOtherLoanOrg", "0");
String userinfo = json.toString();
String param = uuid + "|1|" + userinfo;
String sign = jr58MessageSigner.sign(param);
Map<String, String> parameters = ImmutableMap.<String, String>builder()
.put("customerId", uuid)
.put("authorState", "100")
.put("baseFlag", "1")
.put("userinfo", userinfo)
.put("sign", sign)
.build();
httpService.post(jr58nNotifyUserinfo, parameters);
} catch (Exception e) {
LOGGER.error("向58金融同步用户信息", e);
}
}
}
package cn.quantgroup.xyqb.event.jr58;
import cn.quantgroup.cloudconfig.SafeValue;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
@Service
public class Jr58MessageSigner {
private PrivateKey generatedSigningKey;
@SafeValue("jr58.sign.key")
private String signingKeySpec;
@PostConstruct
private void init() throws Exception {
if (StringUtils.isEmpty(signingKeySpec)) return;
byte[] keyBytes = Base64.getDecoder().decode(signingKeySpec);
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
generatedSigningKey = keyFactory.generatePrivate(pkcs8KeySpec);
}
public String sign(String s) throws Exception {
if (generatedSigningKey == null) return "";
byte[] data = s.getBytes();
Signature signature = Signature.getInstance("MD5withRSA");
signature.initSign(generatedSigningKey);
signature.update(data);
byte[] signedBytes = signature.sign();
return Base64.getEncoder().encodeToString(signedBytes);
}
}
package cn.quantgroup.xyqb.event.jr58;
import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.event.UserinfoChangedEvent;
import cn.quantgroup.xyqb.service.user.IUserService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;
@Service
public class Jr58Notifier implements ApplicationListener<UserinfoChangedEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(Jr58Notifier.class);
@Autowired
private Jr58DataSender jr58DataSender;
@Autowired
private IUserService userService;
@Override
public void onApplicationEvent(UserinfoChangedEvent event) {
LOGGER.info("向58金融同步信息, event:{}", event);
String uuid = event.getUuid();
Long channelId = event.getChannelId();
if (StringUtils.isEmpty(uuid) || channelId == null || channelId != Constants.Channel.JR58) {
return;
}
User user = userService.findByUuidWithCache(uuid);
if (user == null || user.getRegisteredFrom() != Constants.Channel.JR58) {
return;
}
jr58DataSender.sendUserinfo(uuid);
}
}
package cn.quantgroup.xyqb.model.jr58;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* Created by Rocky on 2016/8/17.
*/
@Getter
@Setter
@ToString
public class Jr58Authorization {
private String userId;
private String sourceFrom;
private String authorizationData;
private OperatorData operator_data;
@Getter
@Setter
public static class OperatorData {
private OriginalData originalData;
private ReportData reportData;
@Getter
@Setter
public static class OriginalData {
private String phone;
private PhoneData phoneData;
private PhoneBillDataList[] phoneBillDataList;
private PhoneCallLogList[] phoneCallLogList;
private PhoneSmsLogList[] phoneSmsLogList;
@Getter
@Setter
public static class PhoneData {
private Long id;
private String phoneNum;
private String serialNo;
private String realName;
private String idCard;
private String sourceName;
private String authorizeChannel;
private String createTime;
private String updateTime;
}
@Getter
@Setter
public static class PhoneBillDataList {
private String localPhone;
private String totalCost;
private String planCost;
private String yearMnth;
private String authorizeChannel;
}
@Getter
@Setter
public static class PhoneCallLogList {
private String localPhone;
private String callPhone;
private String callId;
private String cost;
private String callType;
private String callStyle;
private String callDuration;
private String callTime;
private String callAddress;
private String authorizeChannel;
}
@Getter
@Setter
public static class PhoneSmsLogList {
private String localPhone;
private String otherPhone;
private String sendId;
private String totalCost;
private String sendAddress;
private String sendTime;
private String authorizeChannel;
}
}
@Getter
@Setter
public static class ReportData {
private String localPhone;
private Behavior behavior;
private Check check;
private CallList[] callList;
private ContactList[] contactList;
private OperatorList[] operatorList;
private RegionList[] regionList;
private ServiceList[] serviceList;
private TripConsumeList[] tripConsumeList;
@Getter
@Setter
public static class Behavior {
private String localPhone;
private String friendCircle;
private String localLivingYear;
private String powerOff;
private String callMacao;
private String call110;
private String call120;
private String callLawyer;
private String callCourt;
private String callLoan;
private String callBank;
private String callCredit;
private String useTime;
private String contactAmount;
private String contactFrequency;
private String livingLocation;
private String workingLocation;
private String nightUse;
private String authorizeChannel;
}
@Getter
@Setter
public static class Check {
private String localPhone;
private String idCardValidate;
private String operatorBinding;
private String nameOperatorMatch;
private String idcardOperatorMatch;
private String nameIdcardBlack;
private String namePhoneBlack;
private String callContact;
private String callHome;
private String callWork;
private String authorizeChannel;
}
@Getter
@Setter
public static class CallList {
private String localPhone;
private String phoneNum;
private String attribution;
private String contactName;
private String needsType;
private String callCount;
private String callInCount;
private String callOutCount;
private String callTime;
private String callInTime;
private String callOutTime;
private String relationSpeculate;
private String contact1week;
private String contact1month;
private String contact3month;
private String contact3monthMore;
private String contactEarlyMorning;
private String contactMorning;
private String contactNoon;
private String contactAfternoon;
private String contactNight;
private String contactWeekday;
private String contactWeekend;
private String contactHoliday;
private String contactAllDay;
private String authorizeChannel;
}
@Setter
@Getter
public static class ContactList {
}
@Getter
@Setter
public static class OperatorList {
private String localPhone;
private String operatorName;
private String operatorZh;
private String phoneNum;
private String attribution;
private String mnth;
private String callCount;
private String callInCount;
private String callOutCount;
private String callInTime;
private String callOutTime;
private String flow;
private String smsCount;
private String totalAmount;
private String authorizeChannel;
}
@Getter
@Setter
public static class RegionList {
private String localphone;
private String regionName;
private String numCount;
private String callInCount;
private String callOutCount;
private String callInTime;
private String callOutTime;
private String callInAvg;
private String callOutAvg;
private String callInCountPct;
private String callOutCountPct;
private String callInTimePct;
private String callOutTimePct;
private String authorizeChannel;
}
@Setter
@Getter
public static class ServiceList {
private String localPhone;
private String companyName;
private String companyType;
private String contactTimes;
private String contactMonth;
private String contactTimesMonth;
private String authorizeChannel;
}
@Setter
@Getter
public static class TripConsumeList {
}
}
}
}
package cn.quantgroup.xyqb.model.jr58;
import cn.quantgroup.xyqb.model.IdCardInfo;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author mengfan.feng
* @time 2015-09-09 15:46
*/
@Getter
@Setter
@ToString
public class Jr58RegisterParam {
private String wbId; // 58官方注册id
private String wbUserName; // 58用户名
private String customerId; // 量化派用户id
private String name; // 用户姓名
private String idcard; // 身份证号
private String email; // 用户邮箱
private String phone; // 手机号码
private String info; // 用户附加信息(用户是学生,那他的学校、专业之类;用户是上班族:公司之类)
private String roleId; // 角色id(用户职业:例如学生、上班族、企业主、网上店主)
private String flag; // 是否第一次登陆,第一次登陆:0;非第一次登陆:1,默认0
private String city; // 城市
private String accessMode; // 接入模式,openApi(目前的方式) weixin h5
private String appId; // 客户提供的appId
private IdCardInfo idCardInfo; // 证件信息
private String edu; // 学历 学历:B:硕士及以上 C:本科 D:专科 E::中专、高中 G:初中及以下
private String income; // 收入情况:3000以下:M1 3000~10000 :M2 10000~20000 : M3 20000以上 :M4
private String marry; // 婚姻状况 :A:已婚 B:未婚 C:离异 D:丧偶
private String monitorPhone; // 58监控请求属性,不存
/**** 授权*****/
private String account; //授权账号
private String authorizationType;//授权类型(运营商:1,支付宝:2)
/**** 授权*****/
}
package cn.quantgroup.xyqb.model.jr58;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author mengfan.feng
* @time 2015-09-11 09:54
*/
@Getter
@Setter
@ToString
public class Jr58RegisterResult {
private String errorcode;
private Boolean success;
private Boolean hasUser;
private String customerid;
}
package cn.quantgroup.xyqb.service.jr58;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.jr58.Jr58Authorization;
import cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam;
import java.io.UnsupportedEncodingException;
/**
* @author mengfan.feng
* @time 2015-09-09 16:43
*/
public interface Jr58Service {
/**
* 用户注册
*
* @param param
* @return
*/
String register(Jr58RegisterParam param);
/**
* 避免填写资料
*/
void getRidOfFillingProfile(User user, String phoneNo) throws UnsupportedEncodingException;
/**
* 推送授权数据
*/
void pushAuthorizationData(Jr58Authorization authorizationData);
/**
* 推送授权开始的状态
*
* @param userId
* @param account
* @param authorizationType
*/
void pushAuthorizationStatus(String userId, String account, String authorizationType);
}
package cn.quantgroup.xyqb.service.user; package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam;
import cn.quantgroup.xyqb.model.jr58.Jr58RegisterResult;
/** /**
* @author mengfan.feng * @author mengfan.feng
* @time 2015-08-19 17:44 * @time 2015-08-19 17:44
...@@ -18,14 +15,6 @@ public interface ILkbUserService { ...@@ -18,14 +15,6 @@ public interface ILkbUserService {
*/ */
String registerApp(String phoneNo, String password); String registerApp(String phoneNo, String password);
/**
* 58金融用户注册
*
* @param param
* @return
*/
Jr58RegisterResult registerJr58(Jr58RegisterParam param);
/** /**
* 同步用户信息 * 同步用户信息
* *
......
package cn.quantgroup.xyqb.service.user.impl; package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam;
import cn.quantgroup.xyqb.model.jr58.Jr58RegisterResult;
import cn.quantgroup.xyqb.service.http.IHttpService; import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.user.ILkbUserService; import cn.quantgroup.xyqb.service.user.ILkbUserService;
import cn.quantgroup.xyqb.util.PasswordUtil; import cn.quantgroup.xyqb.util.PasswordUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -59,32 +56,14 @@ public class LkbUserviceImpl implements ILkbUserService { ...@@ -59,32 +56,14 @@ public class LkbUserviceImpl implements ILkbUserService {
.build(); .build();
String response = httpService.get(clientUrl + registerApp, parameters); String response = httpService.get(clientUrl + registerApp, parameters);
//Map<String, String> result = GSON.fromJson(response, Map.class);
Map<String, String> result = JSONObject.parseObject(response, Map.class); Map<String, String> result = JSONObject.parseObject(response, Map.class);
if (result == null || "0".equals(result.get("flag"))) { if (result == null || "0".equals(result.get("flag"))) {
LOGGER.warn("向LKB注册用户失败, phoneNo:{}, password:{}", phoneNo, password); LOGGER.warn("向LKB注册用户失败, phoneNo:{}, password:{}", phoneNo, password);
return ""; return "";
} }
//String uid = java.util.UUID.randomUUID().toString().replace("-","");
return result.get("uid"); return result.get("uid");
} }
@Override
public Jr58RegisterResult registerJr58(Jr58RegisterParam param) {
Map<String, String> parameters = ImmutableMap.<String, String>builder()
.put("wbId", param.getWbId())
.put("customerId", param.getCustomerId())
.put("name", param.getName())
.put("idcard", param.getIdcard())
.put("email", StringUtils.substring(param.getEmail(), 0, 30))
.put("phone", param.getPhone())
.build();
String response = httpService.get(clientUrl + register58jr, parameters);
//return GSON.fromJson(response, Jr58RegisterResult.class);
return JSONObject.parseObject(response, Jr58RegisterResult.class);
}
@Override @Override
@Async @Async
public void userUpdate(String uuid, String name, String idNo) { public void userUpdate(String uuid, String name, String idNo) {
......
package cn.quantgroup.xyqb.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class JR58GzipUtil {
public static String bytesTogzip(byte[] bytes, String encode) {
if (bytes == null || bytes.length == 0) {
return null;
}
ByteArrayInputStream byteArrayIn = null;
GZIPInputStream in = null;
ByteArrayOutputStream byteArrayout = new ByteArrayOutputStream();
PrintStream out = new PrintStream(byteArrayout);
try {
byteArrayIn = new ByteArrayInputStream(bytes);
in = new GZIPInputStream(byteArrayIn);
byte[] b = new byte[1024];
int readlen = 0;
;
while ((readlen = in.read(b)) != -1) {
out.write(b, 0, readlen);
}
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
out.close();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("解密后的数据:");
return new String(byteArrayout.toByteArray(), Charset.forName(encode));
}
public static byte[] gzipTobytes(String str, String encode) {
if (str == null || str.length() == 0) {
return null;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = null;
try {
gzip = new GZIPOutputStream(out);
gzip.write(str.getBytes(encode));
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
gzip.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return out.toByteArray();
}
}
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