微信小程序获取手机号
This commit is contained in:
parent
1526776971
commit
7d3700ceb3
@ -35,6 +35,7 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,4 +474,57 @@ public class HttpUtils {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向指定URL发送GET方法的请求
|
||||||
|
*
|
||||||
|
* @param url 发送请求的URL
|
||||||
|
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||||
|
* @return URL 所代表远程资源的响应结果
|
||||||
|
*/
|
||||||
|
public static String sendGet(String url, String param) {
|
||||||
|
String result = "";
|
||||||
|
BufferedReader in = null;
|
||||||
|
try {
|
||||||
|
String urlNameString = url + "?" + param;
|
||||||
|
URL realUrl = new URL(urlNameString);
|
||||||
|
// 打开和URL之间的连接
|
||||||
|
URLConnection connection = realUrl.openConnection();
|
||||||
|
// 设置通用的请求属性
|
||||||
|
connection.setRequestProperty("accept", "*/*");
|
||||||
|
connection.setRequestProperty("connection", "Keep-Alive");
|
||||||
|
connection.setRequestProperty("user-agent",
|
||||||
|
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||||
|
// 建立实际的连接
|
||||||
|
connection.connect();
|
||||||
|
// 获取所有响应头字段
|
||||||
|
Map<String, List<String>> map = connection.getHeaderFields();
|
||||||
|
// 遍历所有的响应头字段
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
System.out.println(key + "--->" + map.get(key));
|
||||||
|
}
|
||||||
|
// 定义 BufferedReader输入流来读取URL的响应
|
||||||
|
in = new BufferedReader(new InputStreamReader(
|
||||||
|
connection.getInputStream(), "utf-8"));
|
||||||
|
String line;
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
result += line;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("发送GET请求出现异常!" + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 使用finally块来关闭输入流
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -82,6 +81,7 @@ public class XhpcPileOrderController extends BaseController {
|
|||||||
map.put("userId", userId);
|
map.put("userId", userId);
|
||||||
map.put("message", remark);
|
map.put("message", remark);
|
||||||
JSONObject json = new JSONObject(map);
|
JSONObject json = new JSONObject(map);
|
||||||
|
logger.info("桩启动回调接口>>>>>json:"+json.toString());
|
||||||
//消息对了内容
|
//消息对了内容
|
||||||
webSocketService.getMessage(userId+"",json.toString());
|
webSocketService.getMessage(userId+"",json.toString());
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|||||||
@ -114,6 +114,27 @@ public class XhpcStatisticsTimeInterval extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long historyOrderId;
|
private Long historyOrderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EVCS开始时间(格式:yyyy-MM-dd HH:mm:ss)
|
||||||
|
*/
|
||||||
|
private String startTimeEvcs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EVCS结束时间(格式:yyyy-MM-dd HH:mm:ss)
|
||||||
|
*/
|
||||||
|
private String endTimeEvcs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EVCS时段电价(单价)
|
||||||
|
*/
|
||||||
|
private BigDecimal elecPriceEvcs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EVCS时段服务费价格(单价)
|
||||||
|
*/
|
||||||
|
private BigDecimal servicePriceEvcs;
|
||||||
|
|
||||||
|
|
||||||
public Long getStatisticsTimeIntervalId() {
|
public Long getStatisticsTimeIntervalId() {
|
||||||
|
|
||||||
return statisticsTimeIntervalId;
|
return statisticsTimeIntervalId;
|
||||||
@ -354,4 +375,44 @@ public class XhpcStatisticsTimeInterval extends BaseEntity {
|
|||||||
this.historyOrderId = historyOrderId;
|
this.historyOrderId = historyOrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStartTimeEvcs() {
|
||||||
|
|
||||||
|
return startTimeEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTimeEvcs(String startTimeEvcs) {
|
||||||
|
|
||||||
|
this.startTimeEvcs = startTimeEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndTimeEvcs() {
|
||||||
|
|
||||||
|
return endTimeEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTimeEvcs(String endTimeEvcs) {
|
||||||
|
|
||||||
|
this.endTimeEvcs = endTimeEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getElecPriceEvcs() {
|
||||||
|
|
||||||
|
return elecPriceEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setElecPriceEvcs(BigDecimal elecPriceEvcs) {
|
||||||
|
|
||||||
|
this.elecPriceEvcs = elecPriceEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getServicePriceEvcs() {
|
||||||
|
|
||||||
|
return servicePriceEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServicePriceEvcs(BigDecimal servicePriceEvcs) {
|
||||||
|
|
||||||
|
this.servicePriceEvcs = servicePriceEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,7 +144,7 @@ public interface XhpcChargeOrderMapper {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取电桩信息
|
* 获取电桩信息
|
||||||
* @param chargingPileId
|
* @param terminalId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String,Object> getXhpcChargingPile(@Param("terminalId")Long terminalId);
|
Map<String,Object> getXhpcChargingPile(@Param("terminalId")Long terminalId);
|
||||||
|
|||||||
@ -346,142 +346,142 @@
|
|||||||
UPDATE xhpc_history_order
|
UPDATE xhpc_history_order
|
||||||
<set>
|
<set>
|
||||||
<if test="chargingStationId != null">
|
<if test="chargingStationId != null">
|
||||||
charging_station_id = #{chargingStationId,jdbcType=BIGINT},
|
charging_station_id = #{chargingStationId},
|
||||||
</if>
|
</if>
|
||||||
<if test="chargeOrderId != null">
|
<if test="chargeOrderId != null">
|
||||||
charge_order_id = #{chargeOrderId,jdbcType=BIGINT},
|
charge_order_id = #{chargeOrderId},
|
||||||
</if>
|
</if>
|
||||||
<if test="userId != null">
|
<if test="userId != null">
|
||||||
user_id = #{userId,jdbcType=BIGINT},
|
user_id = #{userId},
|
||||||
</if>
|
</if>
|
||||||
<if test="terminalId != null">
|
<if test="terminalId != null">
|
||||||
terminal_id = #{terminalId,jdbcType=BIGINT},
|
terminal_id = #{terminalId},
|
||||||
</if>
|
</if>
|
||||||
<if test="serialNumber != null">
|
<if test="serialNumber != null">
|
||||||
serial_number = #{serialNumber,jdbcType=VARCHAR},
|
serial_number = #{serialNumber},
|
||||||
</if>
|
</if>
|
||||||
<if test="internetSerialNumber != null">
|
<if test="internetSerialNumber != null">
|
||||||
internet_serial_number = #{internetSerialNumber,jdbcType=VARCHAR},
|
internet_serial_number = #{internetSerialNumber},
|
||||||
</if>
|
</if>
|
||||||
<if test="powerPriceTotal != null">
|
<if test="powerPriceTotal != null">
|
||||||
power_price_total = #{powerPriceTotal,jdbcType=DECIMAL},
|
power_price_total = #{powerPriceTotal},
|
||||||
</if>
|
</if>
|
||||||
<if test="servicePriceTotal != null">
|
<if test="servicePriceTotal != null">
|
||||||
service_price_total = #{servicePriceTotal,jdbcType=DECIMAL},
|
service_price_total = #{servicePriceTotal},
|
||||||
</if>
|
</if>
|
||||||
<if test="totalPrice != null">
|
<if test="totalPrice != null">
|
||||||
total_price = #{totalPrice,jdbcType=DECIMAL},
|
total_price = #{totalPrice},
|
||||||
</if>
|
</if>
|
||||||
<if test="promotionDiscount != null">
|
<if test="promotionDiscount != null">
|
||||||
promotion_discount = #{promotionDiscount,jdbcType=DECIMAL},
|
promotion_discount = #{promotionDiscount},
|
||||||
</if>
|
</if>
|
||||||
<if test="actPrice != null">
|
<if test="actPrice != null">
|
||||||
act_price = #{actPrice,jdbcType=DECIMAL},
|
act_price = #{actPrice},
|
||||||
</if>
|
</if>
|
||||||
<if test="actPowerPrice != null">
|
<if test="actPowerPrice != null">
|
||||||
act_power_price = #{actPowerPrice,jdbcType=DECIMAL},
|
act_power_price = #{actPowerPrice},
|
||||||
</if>
|
</if>
|
||||||
<if test="actServicePrice != null">
|
<if test="actServicePrice != null">
|
||||||
act_service_price = #{actServicePrice,jdbcType=DECIMAL},
|
act_service_price = #{actServicePrice},
|
||||||
</if>
|
</if>
|
||||||
<if test="internetCommission != null">
|
<if test="internetCommission != null">
|
||||||
internet_commission = #{internetCommission,jdbcType=DECIMAL},
|
internet_commission = #{internetCommission},
|
||||||
</if>
|
</if>
|
||||||
<if test="internetSvcCommission != null">
|
<if test="internetSvcCommission != null">
|
||||||
internet_svc_commission = #{internetSvcCommission,jdbcType=DECIMAL},
|
internet_svc_commission = #{internetSvcCommission},
|
||||||
</if>
|
</if>
|
||||||
<if test="platformCommission != null">
|
<if test="platformCommission != null">
|
||||||
platform_commission = #{platformCommission,jdbcType=DECIMAL},
|
platform_commission = #{platformCommission},
|
||||||
</if>
|
</if>
|
||||||
<if test="platformSvcCommisssion != null">
|
<if test="platformSvcCommisssion != null">
|
||||||
platform_svc_commisssion = #{platformSvcCommisssion,jdbcType=DECIMAL},
|
platform_svc_commisssion = #{platformSvcCommisssion},
|
||||||
</if>
|
</if>
|
||||||
<if test="operationCommission != null">
|
<if test="operationCommission != null">
|
||||||
operation_commission = #{operationCommission,jdbcType=DECIMAL},
|
operation_commission = #{operationCommission},
|
||||||
</if>
|
</if>
|
||||||
<if test="operationSvcCommission != null">
|
<if test="operationSvcCommission != null">
|
||||||
operation_svc_commission = #{operationSvcCommission,jdbcType=DECIMAL},
|
operation_svc_commission = #{operationSvcCommission},
|
||||||
</if>
|
</if>
|
||||||
<if test="startSoc != null">
|
<if test="startSoc != null">
|
||||||
start_soc = #{startSoc,jdbcType=VARCHAR},
|
start_soc = #{startSoc},
|
||||||
</if>
|
</if>
|
||||||
<if test="endSoc != null">
|
<if test="endSoc != null">
|
||||||
end_soc = #{endSoc,jdbcType=VARCHAR},
|
end_soc = #{endSoc},
|
||||||
</if>
|
</if>
|
||||||
<if test="reconciliationStatus != null">
|
<if test="reconciliationStatus != null">
|
||||||
reconciliation_status = #{reconciliationStatus,jdbcType=INTEGER},
|
reconciliation_status = #{reconciliationStatus},
|
||||||
</if>
|
</if>
|
||||||
<if test="sortingStatus != null">
|
<if test="sortingStatus != null">
|
||||||
sorting_status = #{sortingStatus,jdbcType=INTEGER},
|
sorting_status = #{sortingStatus},
|
||||||
</if>
|
</if>
|
||||||
<if test="type != null">
|
<if test="type != null">
|
||||||
`type` = #{type,jdbcType=TINYINT},
|
`type` = #{type},
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null">
|
<if test="status != null">
|
||||||
`status` = #{status,jdbcType=INTEGER},
|
`status` = #{status},
|
||||||
</if>
|
</if>
|
||||||
<if test="delFlag != null">
|
<if test="delFlag != null">
|
||||||
del_flag = #{delFlag,jdbcType=INTEGER},
|
del_flag = #{delFlag},
|
||||||
</if>
|
</if>
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
create_time = #{createTime},
|
||||||
</if>
|
</if>
|
||||||
<if test="createBy != null">
|
<if test="createBy != null">
|
||||||
create_by = #{createBy,jdbcType=VARCHAR},
|
create_by = #{createBy},
|
||||||
</if>
|
</if>
|
||||||
<if test="updateTime != null">
|
<if test="updateTime != null">
|
||||||
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
update_time = #{updateTime},
|
||||||
</if>
|
</if>
|
||||||
<if test="updateBy != null">
|
<if test="updateBy != null">
|
||||||
update_by = #{updateBy,jdbcType=VARCHAR},
|
update_by = #{updateBy},
|
||||||
</if>
|
</if>
|
||||||
<if test="remark != null">
|
<if test="remark != null">
|
||||||
remark = #{remark,jdbcType=VARCHAR},
|
remark = #{remark},
|
||||||
</if>
|
</if>
|
||||||
<if test="state != null">
|
<if test="state != null">
|
||||||
`state` = #{state,jdbcType=INTEGER},
|
`state` = #{state},
|
||||||
</if>
|
</if>
|
||||||
<if test="vinNormal != null">
|
<if test="vinNormal != null">
|
||||||
vin_normal = #{vinNormal,jdbcType=VARCHAR},
|
vin_normal = #{vinNormal},
|
||||||
</if>
|
</if>
|
||||||
<if test="searchValue != null">
|
<if test="searchValue != null">
|
||||||
search_value = #{searchValue,jdbcType=VARCHAR},
|
search_value = #{searchValue},
|
||||||
</if>
|
</if>
|
||||||
<if test="operatorIdEvcs != null">
|
<if test="operatorIdEvcs != null">
|
||||||
operator_id_evcs = #{operatorIdEvcs,jdbcType=VARCHAR},
|
operator_id_evcs = #{operatorIdEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="chargeModelEvcs != null">
|
<if test="chargeModelEvcs != null">
|
||||||
charge_model_evcs = #{chargeModelEvcs,jdbcType=INTEGER},
|
charge_model_evcs = #{chargeModelEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="connectorPowerEvcs != null">
|
<if test="connectorPowerEvcs != null">
|
||||||
connector_power_evcs = #{connectorPowerEvcs,jdbcType=DOUBLE},
|
connector_power_evcs = #{connectorPowerEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="meterValueEndEvcs != null">
|
<if test="meterValueEndEvcs != null">
|
||||||
meter_value_end_evcs = #{meterValueEndEvcs,jdbcType=DOUBLE},
|
meter_value_end_evcs = #{meterValueEndEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="meterValueStartEvcs != null">
|
<if test="meterValueStartEvcs != null">
|
||||||
meter_value_start_evcs = #{meterValueStartEvcs,jdbcType=DOUBLE},
|
meter_value_start_evcs = #{meterValueStartEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="operatorId3rdptyEvcs != null">
|
<if test="operatorId3rdptyEvcs != null">
|
||||||
operator_id3rdpty_evcs = #{operatorId3rdptyEvcs,jdbcType=VARCHAR},
|
operator_id3rdpty_evcs = #{operatorId3rdptyEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="startTime != null">
|
<if test="startTime != null">
|
||||||
start_time = #{startTime,jdbcType=TIMESTAMP},
|
start_time = #{startTime},
|
||||||
</if>
|
</if>
|
||||||
<if test="stopReasonEvcs != null">
|
<if test="stopReasonEvcs != null">
|
||||||
stop_reason_evcs = #{stopReasonEvcs,jdbcType=INTEGER},
|
stop_reason_evcs = #{stopReasonEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="totalPower != null">
|
<if test="totalPower != null">
|
||||||
total_power = #{totalPower,jdbcType=DOUBLE},
|
total_power = #{totalPower},
|
||||||
</if>
|
</if>
|
||||||
<if test="userNameEvcs != null">
|
<if test="userNameEvcs != null">
|
||||||
user_name_evcs = #{userNameEvcs,jdbcType=VARCHAR},
|
user_name_evcs = #{userNameEvcs},
|
||||||
</if>
|
</if>
|
||||||
<if test="phone != null">
|
<if test="phone != null">
|
||||||
phone = #{phone,jdbcType=VARCHAR},
|
phone = #{phone},
|
||||||
</if>
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where history_order_id = #{historyOrderId,jdbcType=BIGINT}
|
where history_order_id = #{historyOrderId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="info" parameterType="java.lang.Long" resultMap="XhpcHistoryOrderResult">
|
<select id="info" parameterType="java.lang.Long" resultMap="XhpcHistoryOrderResult">
|
||||||
|
|||||||
@ -30,6 +30,10 @@
|
|||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="remark" column="remark"/>
|
<result property="remark" column="remark"/>
|
||||||
<result property="terminalId" column="terminal_id"/>
|
<result property="terminalId" column="terminal_id"/>
|
||||||
|
<result property="startTimeEvcs" column="start_time_evcs"/>
|
||||||
|
<result property="endTimeEvcs" column="end_time_evcs"/>
|
||||||
|
<result property="elecPriceEvcs" column="elec_price_evcs"/>
|
||||||
|
<result property="servicePriceEvcs" column="service_price_evcs"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="getTimeIntervalPage" resultType="map">
|
<select id="getTimeIntervalPage" resultType="map">
|
||||||
@ -416,7 +420,19 @@
|
|||||||
terminal_id,
|
terminal_id,
|
||||||
</if>
|
</if>
|
||||||
<if test="null != historyOrderId ">
|
<if test="null != historyOrderId ">
|
||||||
history_order_id
|
history_order_id,
|
||||||
|
</if>
|
||||||
|
<if test="null != startTimeEvcs ">
|
||||||
|
start_time_evcs,
|
||||||
|
</if>
|
||||||
|
<if test="null != endTimeEvcs ">
|
||||||
|
end_time_evcs,
|
||||||
|
</if>
|
||||||
|
<if test="null != elecPriceEvcs ">
|
||||||
|
elec_price_evcs,
|
||||||
|
</if>
|
||||||
|
<if test="null != servicePriceEvcs ">
|
||||||
|
service_price_evcs
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
@ -493,7 +509,19 @@
|
|||||||
#{terminalId},
|
#{terminalId},
|
||||||
</if>
|
</if>
|
||||||
<if test="null != historyOrderId ">
|
<if test="null != historyOrderId ">
|
||||||
#{historyOrderId}
|
#{historyOrderId},
|
||||||
|
</if>
|
||||||
|
<if test="null != startTimeEvcs ">
|
||||||
|
#{startTimeEvcs},
|
||||||
|
</if>
|
||||||
|
<if test="null != endTimeEvcs ">
|
||||||
|
#{endTimeEvcs},
|
||||||
|
</if>
|
||||||
|
<if test="null != elecPriceEvcs ">
|
||||||
|
#{elecPriceEvcs},
|
||||||
|
</if>
|
||||||
|
<if test="null != servicePriceEvcs ">
|
||||||
|
#{servicePriceEvcs}
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@ -143,25 +143,26 @@ public class XhpcAppUserController extends BaseController {
|
|||||||
if (StringUtils.isEmpty(jsCode)) {
|
if (StringUtils.isEmpty(jsCode)) {
|
||||||
return R.fail(HttpStatus.NOT_NULL, "信息不完整");
|
return R.fail(HttpStatus.NOT_NULL, "信息不完整");
|
||||||
}
|
}
|
||||||
|
encryptedData =encryptedData.replace(' ','+');
|
||||||
String url = environment.getProperty("WXGETJSCODE") + jsCode + "&grant_type=authorization_code";
|
String url = environment.getProperty("WXGETJSCODE") + jsCode + "&grant_type=authorization_code";
|
||||||
String result = HttpUtils.get(url);
|
String result = HttpUtils.get(url);
|
||||||
JSONObject json = JSON.parseObject(result);
|
JSONObject json = JSON.parseObject(result);
|
||||||
if (null != json) {
|
if (null != json) {
|
||||||
String openid = json.getString("openid");
|
String openid = json.getString("openid");
|
||||||
String sessionKey = json.getString("session_key");
|
String sessionKey = json.getString("session_key");
|
||||||
|
System.out.println("sessionKey:"+sessionKey);
|
||||||
if (StringUtils.isEmpty(openid)) {
|
if (StringUtils.isEmpty(openid)) {
|
||||||
return R.fail(HttpStatus.ERROR_STATUS, "openid获取失败");
|
return R.fail(HttpStatus.ERROR_STATUS, "openid获取失败");
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(sessionKey)) {
|
if (StringUtils.isEmpty(sessionKey)) {
|
||||||
return R.fail(HttpStatus.ERROR_STATUS, "openid获取失败");
|
return R.fail(HttpStatus.ERROR_STATUS, "openid获取失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>(16);
|
Map<String, Object> map = new HashMap<>(16);
|
||||||
map.put("openid", openid);
|
map.put("openid", openid);
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
if ((!"".equals(encryptedData) && encryptedData != null) && (!"".equals(iv) && iv != null)) {
|
if ((!"".equals(encryptedData) && encryptedData != null) && (!"".equals(iv) && iv != null)) {
|
||||||
jsonObject = getPhoneNumber(encryptedData, sessionKey, iv);
|
jsonObject = getPhoneNumber(encryptedData, sessionKey, iv);
|
||||||
if (StringUtils.isNull(jsonObject)) {
|
if (jsonObject !=null) {
|
||||||
map.put("name", jsonObject.get("nickName"));
|
map.put("name", jsonObject.get("nickName"));
|
||||||
map.put("sex", jsonObject.get("gender"));
|
map.put("sex", jsonObject.get("gender"));
|
||||||
map.put("avatar", jsonObject.get("avatarUrl"));
|
map.put("avatar", jsonObject.get("avatarUrl"));
|
||||||
@ -197,7 +198,7 @@ public class XhpcAppUserController extends BaseController {
|
|||||||
}
|
}
|
||||||
// 初始化
|
// 初始化
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");
|
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||||
SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
|
SecretKeySpec spec = new SecretKeySpec(keyByte, "AES");
|
||||||
AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
|
AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES");
|
||||||
parameters.init(new IvParameterSpec(ivByte));
|
parameters.init(new IvParameterSpec(ivByte));
|
||||||
@ -212,7 +213,6 @@ public class XhpcAppUserController extends BaseController {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝授权
|
* 支付宝授权
|
||||||
*/
|
*/
|
||||||
@ -241,4 +241,5 @@ public class XhpcAppUserController extends BaseController {
|
|||||||
|
|
||||||
return iXhpcAppUserUserService.logout(phone, code);
|
return iXhpcAppUserUserService.logout(phone, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,13 +110,13 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
return R.fail(HttpStatus.NOT_NULL, "openid不能为空");
|
return R.fail(HttpStatus.NOT_NULL, "openid不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(code)) {
|
// if (StringUtils.isEmpty(code)) {
|
||||||
return R.fail(HttpStatus.NOT_NULL, "验证码不能为空");
|
// return R.fail(HttpStatus.NOT_NULL, "验证码不能为空");
|
||||||
}
|
// }
|
||||||
String captcha = redisService.getCacheObject("pvToken:" + phone);
|
// String captcha = redisService.getCacheObject("pvToken:" + phone);
|
||||||
if (!code.equalsIgnoreCase(captcha)) {
|
// if (!code.equalsIgnoreCase(captcha)) {
|
||||||
R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
|
// R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
|
||||||
}
|
// }
|
||||||
XhpcAppUser info = xhpcAppUserMapper.getAppUserByPhone(phone);
|
XhpcAppUser info = xhpcAppUserMapper.getAppUserByPhone(phone);
|
||||||
if (StringUtils.isNotNull(info)) {
|
if (StringUtils.isNotNull(info)) {
|
||||||
return R.fail(HttpStatus.ALREADY_EXISTING, "账号已存在");
|
return R.fail(HttpStatus.ALREADY_EXISTING, "账号已存在");
|
||||||
@ -247,7 +247,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
|||||||
return R.fail(HttpStatus.DATA_ERROR, "用户不存在");
|
return R.fail(HttpStatus.DATA_ERROR, "用户不存在");
|
||||||
}
|
}
|
||||||
if (StatusConstants.OPERATION_ALI_PAY_TYPE.equals(type)) {
|
if (StatusConstants.OPERATION_ALI_PAY_TYPE.equals(type)) {
|
||||||
if (UserConstants.NO_LOGIN == user.getWeixinLogin()) {
|
if (UserConstants.NO_LOGIN == user.getAlipayLogin()) {
|
||||||
return R.fail(HttpStatus.USER_LOGIN, "用户未登录");
|
return R.fail(HttpStatus.USER_LOGIN, "用户未登录");
|
||||||
}
|
}
|
||||||
} else if (StatusConstants.OPERATION_WX_TYPE.equals(type)) {
|
} else if (StatusConstants.OPERATION_WX_TYPE.equals(type)) {
|
||||||
|
|||||||
@ -0,0 +1,90 @@
|
|||||||
|
package com.xhpc.user.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.bouncycastle.util.Arrays;
|
||||||
|
import org.bouncycastle.util.encoders.Base64;
|
||||||
|
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.security.Key;
|
||||||
|
import java.security.Security;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author yuyang
|
||||||
|
* @date 2021/9/26 11:33
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class WechatDecryptDataUtil {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String result = decryptData(
|
||||||
|
"3lL+weYF65ym3D/ADsu2b+Rw3MrXmQkFhb2DVtI1HrIW6U7+tOQSHyzNXZCr0Zcs/nIZyEFEBWRpoK4DmOhyYdRKj1R6hhykDY/UquuVXhLB5JrwmHLnFduYQcVAUqC7eUVW4G7E781CphPHxUOUZJYTJC4bkFqOnSVnh49duQJSE2FQVU5XpjVtWTun7qxF6ccQy6wFsVCl5S/ChBdimg==",
|
||||||
|
"xQOZ2TnaZyOtQQsXGRHzgw==",
|
||||||
|
"iBMSyXmseiSJQR5Iv04Qog=="
|
||||||
|
);
|
||||||
|
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||||
|
|
||||||
|
System.out.println("jsonObject = " + jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decryptData(String encryptDataB64, String sessionKeyB64, String ivB64) {
|
||||||
|
return new String(
|
||||||
|
decryptOfDiyIV(
|
||||||
|
Base64.decode(encryptDataB64),
|
||||||
|
Base64.decode(sessionKeyB64),
|
||||||
|
Base64.decode(ivB64)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String KEY_ALGORITHM = "AES";
|
||||||
|
private static final String ALGORITHM_STR = "AES/CBC/PKCS7Padding";
|
||||||
|
private static Key key;
|
||||||
|
private static Cipher cipher;
|
||||||
|
|
||||||
|
private static void init(byte[] keyBytes) {
|
||||||
|
// 如果密钥不足16位,那么就补足. 这个if 中的内容很重要
|
||||||
|
int base = 16;
|
||||||
|
if (keyBytes.length % base != 0) {
|
||||||
|
int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
|
||||||
|
byte[] temp = new byte[groups * base];
|
||||||
|
Arrays.fill(temp, (byte) 0);
|
||||||
|
System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
|
||||||
|
keyBytes = temp;
|
||||||
|
}
|
||||||
|
// 初始化
|
||||||
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
// 转化成JAVA的密钥格式
|
||||||
|
key = new SecretKeySpec(keyBytes, KEY_ALGORITHM);
|
||||||
|
try {
|
||||||
|
// 初始化cipher
|
||||||
|
cipher = Cipher.getInstance(ALGORITHM_STR, "BC");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密方法
|
||||||
|
*
|
||||||
|
* @param encryptedData 要解密的字符串
|
||||||
|
* @param keyBytes 解密密钥
|
||||||
|
* @param ivs 自定义对称解密算法初始向量 iv
|
||||||
|
* @return 解密后的字节数组
|
||||||
|
*/
|
||||||
|
private static byte[] decryptOfDiyIV(byte[] encryptedData, byte[] keyBytes, byte[] ivs) {
|
||||||
|
byte[] encryptedText = null;
|
||||||
|
init(keyBytes);
|
||||||
|
try {
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(ivs));
|
||||||
|
encryptedText = cipher.doFinal(encryptedData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return encryptedText;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,6 +3,8 @@ package com.xhpc.wxma.controller;
|
|||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.common.core.web.controller.BaseController;
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
import com.xhpc.wxma.socket.OrderNotificationWebSocket;
|
import com.xhpc.wxma.socket.OrderNotificationWebSocket;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
public class OrderNotificationWebSocketController extends BaseController {
|
public class OrderNotificationWebSocketController extends BaseController {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(OrderNotificationWebSocketController.class);
|
||||||
@GetMapping("/test")
|
@GetMapping("/test")
|
||||||
public void test(@RequestParam String userId){
|
public void test(@RequestParam String userId){
|
||||||
OrderNotificationWebSocket.sendMessage(userId,"有新订单啦");
|
OrderNotificationWebSocket.sendMessage(userId,"有新订单啦");
|
||||||
@ -22,6 +25,7 @@ public class OrderNotificationWebSocketController extends BaseController {
|
|||||||
@GetMapping("/orderWebSocket/getMessage")
|
@GetMapping("/orderWebSocket/getMessage")
|
||||||
public R getMessage(@RequestParam String userId, @RequestParam String message){
|
public R getMessage(@RequestParam String userId, @RequestParam String message){
|
||||||
OrderNotificationWebSocket.sendMessage(userId,message);
|
OrderNotificationWebSocket.sendMessage(userId,message);
|
||||||
|
logger.info("发送消息成功------->>>>>message:"+message);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user