Commit 948b2fe9 by wangnb

包活干V1.9.0保单接口开发--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@26995 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 86a0ceb1
...@@ -12,6 +12,7 @@ package com.glsx.ordercenter.constants; ...@@ -12,6 +12,7 @@ package com.glsx.ordercenter.constants;
public enum ResultCodeEnum { public enum ResultCodeEnum {
DSC_SUCCESS(0, "成功"), DSC_SUCCESS(0, "成功"),
TSP_SUCCESS(0, "成功"),
SUCCESS(200, "成功"), SUCCESS(200, "成功"),
FAIL(400, "失败"), FAIL(400, "失败"),
ERROR(500, "系统异常"), ERROR(500, "系统异常"),
......
package com.glsx.ordercenter.dto.insurance;
import java.io.Serializable;
import java.math.BigDecimal;
public class TspSaveReq implements Serializable {
//保险公司名称(华安:sinosafe,富德:sinofd,阳光:sinosig,人保:picc)
private String insuranceCompany;
//投保唯一序列号(建议使用UUID.randomUUID())
private String seqNo;
//第一受益人
private String compensationName;
//被保险人地址
private String address;
//客户类型(个人:00,企业:02,个人(港澳):03,个人(台):04,个人(军官):05)
private String customerType;
//证件类型(身份证:00,统一社会信用代码:02,港澳返乡证:03,台胞证:04,军官证:05)
private String cardType;
//证件号码
private String cardNo;
//姓名
private String name;
//被保险人手机号
private String phone;
//保单生效日期(精确到秒) 2020-04-08 00:00:00
private String effectDate;
//保险期限(单位:月) 36
private String insurePeriod;
//保额,车辆价格
private String sumAmount;
//车架号
private String standNo;
//发动机号
private String engine;
//购车类型(00贷款车,01全款车)
private String buyType;
//车辆颜色
private String vehicleColor;
//车辆品牌名称
private String vehicleBrand;
//子品牌名称
private String vehicleChildsBrandName;
//车系名称
private String vehicleSeriesName;
//车辆价格
private BigDecimal vehiclePrice;
//车辆使用性质(1非营运车;2营运车.华安只支持非运营)
private String vehicleUsage;
//=============以下字段未使用做签名校验================//
//人保投保时保单类型(驾宝无忧:0000,海圳专版:0001,部分特殊版:0002)保险公司为人保时必填
private String planNo;
private String birthday;
private String sex;
private String installPoint;
private String installPerson;
private String spid;
private String specialContent;
//GT007 设备型号
private String deviceName;
//产品类型(00:有源,01:无源)
private String productType;
private String deviceType;
private String sn;
private String activeDate;
private String plateNum;
// 车型名称
private String vehicleTypeName;
//店面名称
private String shopName;
//安装时间
private String fixTime;
//保费
private Long sumPremium;
public Long getSumPremium() {
return sumPremium;
}
public void setSumPremium(Long sumPremium) {
this.sumPremium = sumPremium;
}
public String getInsuranceCompany() {
return insuranceCompany;
}
public void setInsuranceCompany(String insuranceCompany) {
this.insuranceCompany = insuranceCompany;
}
public String getSeqNo() {
return seqNo;
}
public void setSeqNo(String seqNo) {
this.seqNo = seqNo;
}
public String getCompensationName() {
return compensationName;
}
public void setCompensationName(String compensationName) {
this.compensationName = compensationName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCustomerType() {
return customerType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
public String getCardType() {
return cardType;
}
public void setCardType(String cardType) {
this.cardType = cardType;
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEffectDate() {
return effectDate;
}
public void setEffectDate(String effectDate) {
this.effectDate = effectDate;
}
public String getInsurePeriod() {
return insurePeriod;
}
public void setInsurePeriod(String insurePeriod) {
this.insurePeriod = insurePeriod;
}
public String getSumAmount() {
return sumAmount;
}
public void setSumAmount(String sumAmount) {
this.sumAmount = sumAmount;
}
public String getStandNo() {
return standNo;
}
public void setStandNo(String standNo) {
this.standNo = standNo;
}
public String getEngine() {
return engine;
}
public void setEngine(String engine) {
this.engine = engine;
}
public String getBuyType() {
return buyType;
}
public void setBuyType(String buyType) {
this.buyType = buyType;
}
public String getVehicleColor() {
return vehicleColor;
}
public void setVehicleColor(String vehicleColor) {
this.vehicleColor = vehicleColor;
}
public String getVehicleBrand() {
return vehicleBrand;
}
public void setVehicleBrand(String vehicleBrand) {
this.vehicleBrand = vehicleBrand;
}
public String getVehicleChildsBrandName() {
return vehicleChildsBrandName;
}
public void setVehicleChildsBrandName(String vehicleChildsBrandName) {
this.vehicleChildsBrandName = vehicleChildsBrandName;
}
public String getVehicleSeriesName() {
return vehicleSeriesName;
}
public void setVehicleSeriesName(String vehicleSeriesName) {
this.vehicleSeriesName = vehicleSeriesName;
}
public BigDecimal getVehiclePrice() {
return vehiclePrice;
}
public void setVehiclePrice(BigDecimal vehiclePrice) {
this.vehiclePrice = vehiclePrice;
}
public String getVehicleUsage() {
return vehicleUsage;
}
public void setVehicleUsage(String vehicleUsage) {
this.vehicleUsage = vehicleUsage;
}
public String getPlanNo() {
return planNo;
}
public void setPlanNo(String planNo) {
this.planNo = planNo;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getInstallPoint() {
return installPoint;
}
public void setInstallPoint(String installPoint) {
this.installPoint = installPoint;
}
public String getInstallPerson() {
return installPerson;
}
public void setInstallPerson(String installPerson) {
this.installPerson = installPerson;
}
public String getSpid() {
return spid;
}
public void setSpid(String spid) {
this.spid = spid;
}
public String getSpecialContent() {
return specialContent;
}
public void setSpecialContent(String specialContent) {
this.specialContent = specialContent;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getProductType() {
return productType;
}
public void setProductType(String productType) {
this.productType = productType;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getActiveDate() {
return activeDate;
}
public void setActiveDate(String activeDate) {
this.activeDate = activeDate;
}
public String getPlateNum() {
return plateNum;
}
public void setPlateNum(String plateNum) {
this.plateNum = plateNum;
}
public String getVehicleTypeName() {
return vehicleTypeName;
}
public void setVehicleTypeName(String vehicleTypeName) {
this.vehicleTypeName = vehicleTypeName;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getFixTime() {
return fixTime;
}
public void setFixTime(String fixTime) {
this.fixTime = fixTime;
}
}
package com.glsx.ordercenter.dto.insurance;
import java.io.Serializable;
import java.math.BigDecimal;
public class TspUpdateReq implements Serializable {
//保险公司名称(华安:sinosafe,富德:sinofd,阳光:sinosig,人保:picc)
private String insuranceCompany;
//保险公司投保保单号
private String fullInsuranceNo;
//投保唯一序列号(建议使用UUID.randomUUID())
private String seqNo;
//第一受益人
private String compensationName;
//被保险人地址
private String address;
//客户类型(个人:00,企业:02,个人(港澳):03,个人(台):04,个人(军官):05)
private String customerType;
//证件类型(身份证:00,统一社会信用代码:02,港澳返乡证:03,台胞证:04,军官证:05)
private String cardType;
private String birthday;
private String sex;
//证件号码
private String cardNo;
//姓名
private String name;
//被保险人手机号
private String phone;
//保单生效日期(精确到秒) 2020-04-08 00:00:00
private String effectDate;
//保险期限(单位:月) 36
private String insurePeriod;
private String installPoint;
private String installPerson;
//保额,车辆价格
private Long sumAmount;
private String spid;
private String specialContent;
//车架号
private String standNo;
private String plateNum;
//发动机号
private String engine;
//购车类型(00贷款车,01全款车)
private String buyType;
//车辆颜色
private String vehicleColor;
//车辆品牌名称
private String vehicleBrand;
//子品牌名称
private String vehicleChildsBrandName;
//车系名称
private String vehicleSeriesName;
private String vehicleTypeName;
//车辆价格
private BigDecimal vehiclePrice;
//车辆使用性质(1非营运车;2营运车.华安只支持非运营)
private String vehicleUsage;
private String shopName;
private String fixTime;
//保费
private Long sumPremium;
public Long getSumPremium() {
return sumPremium;
}
public void setSumPremium(Long sumPremium) {
this.sumPremium = sumPremium;
}
public String getInsuranceCompany() {
return insuranceCompany;
}
public void setInsuranceCompany(String insuranceCompany) {
this.insuranceCompany = insuranceCompany;
}
public String getFullInsuranceNo() {
return fullInsuranceNo;
}
public void setFullInsuranceNo(String fullInsuranceNo) {
this.fullInsuranceNo = fullInsuranceNo;
}
public String getSeqNo() {
return seqNo;
}
public void setSeqNo(String seqNo) {
this.seqNo = seqNo;
}
public String getCompensationName() {
return compensationName;
}
public void setCompensationName(String compensationName) {
this.compensationName = compensationName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCustomerType() {
return customerType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
public String getCardType() {
return cardType;
}
public void setCardType(String cardType) {
this.cardType = cardType;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEffectDate() {
return effectDate;
}
public void setEffectDate(String effectDate) {
this.effectDate = effectDate;
}
public String getInsurePeriod() {
return insurePeriod;
}
public void setInsurePeriod(String insurePeriod) {
this.insurePeriod = insurePeriod;
}
public String getInstallPoint() {
return installPoint;
}
public void setInstallPoint(String installPoint) {
this.installPoint = installPoint;
}
public String getInstallPerson() {
return installPerson;
}
public void setInstallPerson(String installPerson) {
this.installPerson = installPerson;
}
public Long getSumAmount() {
return sumAmount;
}
public void setSumAmount(Long sumAmount) {
this.sumAmount = sumAmount;
}
public String getSpid() {
return spid;
}
public void setSpid(String spid) {
this.spid = spid;
}
public String getSpecialContent() {
return specialContent;
}
public void setSpecialContent(String specialContent) {
this.specialContent = specialContent;
}
public String getStandNo() {
return standNo;
}
public void setStandNo(String standNo) {
this.standNo = standNo;
}
public String getPlateNum() {
return plateNum;
}
public void setPlateNum(String plateNum) {
this.plateNum = plateNum;
}
public String getEngine() {
return engine;
}
public void setEngine(String engine) {
this.engine = engine;
}
public String getBuyType() {
return buyType;
}
public void setBuyType(String buyType) {
this.buyType = buyType;
}
public String getVehicleColor() {
return vehicleColor;
}
public void setVehicleColor(String vehicleColor) {
this.vehicleColor = vehicleColor;
}
public String getVehicleBrand() {
return vehicleBrand;
}
public void setVehicleBrand(String vehicleBrand) {
this.vehicleBrand = vehicleBrand;
}
public String getVehicleChildsBrandName() {
return vehicleChildsBrandName;
}
public void setVehicleChildsBrandName(String vehicleChildsBrandName) {
this.vehicleChildsBrandName = vehicleChildsBrandName;
}
public String getVehicleSeriesName() {
return vehicleSeriesName;
}
public void setVehicleSeriesName(String vehicleSeriesName) {
this.vehicleSeriesName = vehicleSeriesName;
}
public String getVehicleTypeName() {
return vehicleTypeName;
}
public void setVehicleTypeName(String vehicleTypeName) {
this.vehicleTypeName = vehicleTypeName;
}
public BigDecimal getVehiclePrice() {
return vehiclePrice;
}
public void setVehiclePrice(BigDecimal vehiclePrice) {
this.vehiclePrice = vehiclePrice;
}
public String getVehicleUsage() {
return vehicleUsage;
}
public void setVehicleUsage(String vehicleUsage) {
this.vehicleUsage = vehicleUsage;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getFixTime() {
return fixTime;
}
public void setFixTime(String fixTime) {
this.fixTime = fixTime;
}
}
...@@ -19,7 +19,7 @@ public class OraParamsReq implements Serializable { ...@@ -19,7 +19,7 @@ public class OraParamsReq implements Serializable {
@NotBlank(message = "appkey不能为空") @NotBlank(message = "appkey不能为空")
private String appkey; private String appkey;
@NotBlank(message = "v") @NotBlank(message = "v不能为空")
private String v; private String v;
@NotBlank(message = "nonce不能为空") @NotBlank(message = "nonce不能为空")
......
package com.glsx.ordercenter.thread;
import com.alibaba.fastjson.JSON;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.gps.utils.HttpUtil;
import com.glsx.ordercenter.dto.insurance.TspResp;
import com.glsx.ordercenter.dto.insurance.TspRespData;
import com.glsx.ordercenter.mapper.insurance.SysInsurancePolicyMapper;
import com.glsx.ordercenter.pojo.insurance.SysInsurancePolicy;
import com.glsx.ordercenter.utils.TspSignUtil;
import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Semaphore;
/**
* @author think.wang
* @version 1.0.0
* @Title TspInsurancePdfTask
* @Package com.glsx.ordercenter.thread
* @Description 调用TSP接口获取保单信息pdf路径
* @date 2020/5/28
*/
public class TspInsurancePdfTask implements Runnable{
private Logger logger = LoggerFactory.getLogger(TspInsurancePdfTask.class);
private Integer id;
private SysInsurancePolicyMapper policyMapper;
private Semaphore semaphore;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public TspInsurancePdfTask(Integer id, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.id = id;
this.policyMapper = policyMapper;
this.semaphore = semaphore;
}
@Override
public void run() {
try {
semaphore.acquire();
//系统参数获取
String insuranceUrl = PropertiesUtil.getProperty("insurance.picc.url");
String method = PropertiesUtil.getProperty("insurance.picc.pdf"); //调用获取pdf方法
String appKey = PropertiesUtil.getProperty("insurance.picc.appKey");
String appSecret = PropertiesUtil.getProperty("insurance.picc.secret");
String version = PropertiesUtil.getProperty("insurance.picc.version");
String format = PropertiesUtil.getProperty("insurance.picc.format");
String source = PropertiesUtil.getProperty("insurance.picc.source");
SysInsurancePolicy insurancePolicy = policyMapper.selectByPrimaryKey(id);
if(insurancePolicy == null){
logger.error("通过id={}未找到保单数据", id);
return;
}
//业务参数封装
Map<String, String> map = new HashMap<>();
map.put("insuranceCompany", insurancePolicy.getInsuranceCompany());
map.put("fullInsuranceNo", insurancePolicy.getInsuranceNo());
map.put("seqNo", insurancePolicy.getInsuranceSeqNo());
logger.info("获取pdf签名参数值为:{}", map);
//系统参数封装
map.put("method", method);
map.put("format", format);
map.put("v", version);
map.put("appKey", appKey);
map.put("timestamp", DateUtil.formatDate(new Date()));
map.put("source", source);
String sign = TspSignUtil.sign(map, appSecret); //除了sign所有参数进行验签
map.put("sign", sign);
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
result = HttpUtil.postData(insuranceUrl, JSON.toJSONString(map), ContentType.APPLICATION_JSON);
logger.info(result + "======获取pdf信息响应数据=========" + map.get("fullInsuranceNo"));
break;
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setId(id);
TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp.getCode().equals("0")){ //请求成功
TspRespData respData = tspResp.getData();
policy.setInsurancePdf(respData.getObj()); //得到pdf路径
policyMapper.updateByPrimaryKeySelective(policy); //保存返回数据
}
} catch (Exception e) {
logger.error("调用TSP获取pdf接口异常:{}", e);
}finally {
semaphore.release();
}
}
}
package com.glsx.ordercenter.thread;
import com.alibaba.fastjson.JSON;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.StringUtils;
import com.glsx.gps.utils.HttpUtil;
import com.glsx.ordercenter.constants.insurance.InsuranceCardType;
import com.glsx.ordercenter.constants.insurance.InsuranceCustomerType;
import com.glsx.ordercenter.constants.insurance.InsuranceStatus;
import com.glsx.ordercenter.dto.insurance.TspResp;
import com.glsx.ordercenter.dto.insurance.TspRespData;
import com.glsx.ordercenter.dto.insurance.TspSaveReq;
import com.glsx.ordercenter.mapper.insurance.SysInsurancePolicyMapper;
import com.glsx.ordercenter.pojo.insurance.SysInsurancePolicy;
import com.glsx.ordercenter.utils.ObjectUtils;
import com.glsx.ordercenter.utils.TspSignUtil;
import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Semaphore;
/**
* @author think.wang
* @version 1.0.0
* @Title TspSaveInsuranceTask
* @Package com.glsx.ordercenter.thread
* @Description 调用TSP接口进行投保
* @date 2020/5/28
*/
public class TspSaveInsuranceTask implements Runnable{
private Logger logger = LoggerFactory.getLogger(TspSaveInsuranceTask.class);
private SysInsurancePolicy data;
private SysInsurancePolicyMapper policyMapper;
private Semaphore semaphore;
protected final int TRY_COUNT = 3;
protected final int TRY_WAIT_TIME = 5 * 100;
public TspSaveInsuranceTask(SysInsurancePolicy data, SysInsurancePolicyMapper policyMapper, Semaphore semaphore) {
this.data = data;
this.policyMapper = policyMapper;
this.semaphore = semaphore;
}
@Override
public void run() {
try {
semaphore.acquire();
//系统参数获取
String insuranceUrl = PropertiesUtil.getProperty("insurance.picc.url");
String method = PropertiesUtil.getProperty("insurance.picc.save"); //调用投保方法
String appKey = PropertiesUtil.getProperty("insurance.picc.appKey");
String appSecret = PropertiesUtil.getProperty("insurance.picc.secret");
String version = PropertiesUtil.getProperty("insurance.picc.version");
String format = PropertiesUtil.getProperty("insurance.picc.format");
String source = PropertiesUtil.getProperty("insurance.picc.source");
//业务参数封装
TspSaveReq req = this.setSaveData(data);
//对象转map进行签名
logger.info("投保签名的对象为:{}", JSON.toJSONString(req));
Map<String, String> map = ObjectUtils.objectToMap(req);
//系统参数封装
map.put("method", method);
map.put("format", format);
map.put("v", version);
map.put("appKey", appKey);
map.put("timestamp", DateUtil.formatDate(new Date()));
map.put("source", source);
String sign = TspSignUtil.sign(map, appSecret); //除了sign所有参数进行验签
map.put("sign", sign);
//发送请求
String result = null;
int tryCount = TRY_COUNT;
while (tryCount-- > 0) {
try {
result = HttpUtil.postData(insuranceUrl, JSON.toJSONString(map), ContentType.APPLICATION_JSON);
logger.info(result + "======投保请求人保投保响应数据=========" + map.get("standNo"));
break;
} catch (Exception e) {
Thread.sleep(TRY_WAIT_TIME);
continue;
}
}
SysInsurancePolicy policy = new SysInsurancePolicy();
policy.setId(data.getId());
TspResp tspResp = JSON.parseObject(result, TspResp.class);
if(tspResp.getCode().equals("0")){ //请求成功
TspRespData respData = tspResp.getData();
policy.setStatus(InsuranceStatus.APPLIED.getStatus().byteValue());
policy.setInsuranceNo(respData.getObj()); //保单号set
policy.setInsuranceSeqNo(respData.getInfo()); //保单序列号set
}else{
policy.setStatus(InsuranceStatus.APPLY_FAILED.getStatus().byteValue()); //更新状态投保失败
}
policyMapper.updateByPrimaryKeySelective(policy); //保存返回数据
} catch (Exception e) {
logger.error("调用TSP投保接口异常:{}", e);
}finally {
semaphore.release();
}
}
/**
* 数据设置
* @param policy
* @return
*/
private TspSaveReq setSaveData(SysInsurancePolicy policy){
TspSaveReq saveReq = new TspSaveReq();
saveReq.setInsuranceCompany("picc"); //默认人保
saveReq.setSeqNo(UUID.randomUUID().toString());
saveReq.setPlanNo("0000");
saveReq.setCompensationName(policy.getTastingUnit()); //第一受益人
String address = policy.getVehicleOwnerAddress();
saveReq.setAddress(StringUtils.isEmpty(address) ? "暂无" : address); //车主地址 必填
String customerType = InsuranceCustomerType.INDIVIDUAL.getType().equals(policy.getCustomerType()) ? "00" : "02";
saveReq.setCustomerType(customerType);
String cardType = InsuranceCardType.CREDIT_CODE.getType().equals(policy.getIdCardType()) ? "02" : "00"; //其他和身份证都传身份证类型
saveReq.setCardType(cardType);
saveReq.setCardNo(policy.getIdCardNum());
saveReq.setBirthday(""); //填写
saveReq.setName(policy.getVehicleOwnerName());
saveReq.setSex("");
saveReq.setPhone(policy.getPhone());
saveReq.setEffectDate(DateUtil.formatDate(policy.getExpectedEffectiveTime()));
saveReq.setInsurePeriod(String.valueOf(policy.getInsurancePeriod() * 12)); //保单期限
saveReq.setInstallPoint("");
saveReq.setInstallPerson("");
saveReq.setSumAmount(String.valueOf(policy.getPilferInsuranceMoney())); //保额 必填
saveReq.setSumPremium(0L); //保费
saveReq.setSpid("");
saveReq.setSpecialContent("");
saveReq.setDeviceName(""); //设备型号
saveReq.setProductType(""); //产品类型
saveReq.setDeviceType("");
saveReq.setSn(policy.getGpsNo()); //设备号
saveReq.setActiveDate("");
saveReq.setStandNo(policy.getVin());
saveReq.setPlateNum(policy.getVehicleNo());
saveReq.setEngine(policy.getEngineNumber());
saveReq.setBuyType("00"); //默认贷款车
saveReq.setVehicleColor(policy.getVehicleColor());
saveReq.setVehicleBrand(policy.getCarBrand());
saveReq.setVehicleChildsBrandName("其他");
saveReq.setVehicleSeriesName("其他");
saveReq.setVehicleTypeName("");
saveReq.setVehiclePrice(policy.getVehicleInvoiceMoney()); //车辆价格
saveReq.setVehicleUsage("1"); //默认都是非运营车
saveReq.setShopName("");
saveReq.setFixTime("");
return saveReq;
}
}
package com.glsx.ordercenter.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.TreeMap;
/**
* @author think.wang
* @version 1.0.0
* @Title ObjectUtils
* @Package com.glsx.ordercenter.utils
* @Description 对象处理工具类
* @date 2020/5/28
*/
public class ObjectUtils {
private static final Logger logger = LoggerFactory.getLogger(ObjectUtils.class);
/**
* 对象转Map
* @param obj
* @return
*/
public static Map<String, String> objectToMap(Object obj) {
Map<String, String> map = new TreeMap<>();
Class<?> clazz = obj.getClass();
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
String fieldName = field.getName();
Object value = null;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
e.printStackTrace();
logger.info("对象转换成map异常");
}
if (value == null) {
map.put(fieldName, "");
} else {
map.put(fieldName, String.valueOf(value));
}
}
return map;
}
}
package com.glsx.ordercenter.utils; package com.glsx.ordercenter.utils;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.glsx.ordercenter.constants.insurance.OraConstants; import com.glsx.ordercenter.constants.insurance.OraConstants;
import com.glsx.ordercenter.constants.insurance.OraResultCode; import com.glsx.ordercenter.constants.insurance.OraResultCode;
...@@ -16,12 +7,18 @@ import com.glsx.ordercenter.exception.insurance.OraBizException; ...@@ -16,12 +7,18 @@ import com.glsx.ordercenter.exception.insurance.OraBizException;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.util.*;
/** /**
* @author think.wang * @author think.wang
* @version 1.0.0 * @version 1.0.0
* @Title EulerUtil * @Title OraSignUtil
* @Package com.glsx.ordercenter.utils * @Package com.glsx.ordercenter.utils
* @Description 长城欧了验签 * @Description 长城欧拉验签
* @date 2020/5/25 * @date 2020/5/25
*/ */
public class OraSignUtil { public class OraSignUtil {
...@@ -136,4 +133,5 @@ public class OraSignUtil { ...@@ -136,4 +133,5 @@ public class OraSignUtil {
} }
return sign.toString(); return sign.toString();
} }
} }
package com.glsx.ordercenter.utils;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* @author think.wang
* @version 1.0.0
* @Title TspSignUtil
* @Package com.glsx.ordercenter.utils
* @Description Tsp保单验签
* @date 2020/5/25
*/
public class TspSignUtil {
/**
* 使用<code>secret</code>对paramValues按以下算法进行签名: <br/>
* uppercase(hex(sha1(secretkey1value1key2value2...secret))
* @param paramValues 参数列表
* @param secret 秘钥
* @return
*/
public static String sign(Map<String, String> paramValues, String secret) {
try {
StringBuilder sb = new StringBuilder();
List<String> paramNames = new ArrayList<>(paramValues.size());
paramNames.addAll(paramValues.keySet());
Collections.sort(paramNames);
sb.append(secret);
for (String paramName : paramNames) {
sb.append(paramName).append(paramValues.get(paramName));
}
sb.append(secret);
byte[] sha1Digest = getSHA1Digest(sb.toString());
return byte2hex(sha1Digest);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private static byte[] getSHA1Digest(String data) throws IOException {
byte[] bytes = null;
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
bytes = md.digest(data.getBytes("UTF-8"));
} catch (GeneralSecurityException gse) {
throw new IOException(gse);
}
return bytes;
}
private static String byte2hex(byte[] bytes) {
StringBuilder sign = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
String hex = Integer.toHexString(bytes[i] & 0xFF);
if (hex.length() == 1) {
sign.append("0");
}
sign.append(hex.toUpperCase());
}
return sign.toString();
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!