Commit 8f975e21 authored by shiyu's avatar shiyu

Merge remote-tracking branch 'origin/quanku_0930' into quanku_0930

parents 55424a5d 8c772fce
......@@ -132,7 +132,7 @@ public class MediaUtil {
public static Map<String, Object> getAspect(String image) {
Map<String, Object> map = new HashMap<>();
String[] _image = image.split("_");
String[] infoImage = _image[1].split("\\.");
String[] infoImage = _image[_image.length - 1].split("\\.");
String[] result = infoImage[0].split("x");
map.put("width", result[0]);
map.put("height", result[1]);
......
......@@ -9,7 +9,7 @@ import java.util.Date;
/**
* @author shiyu
* @date 2023/08/07
* @date 2023/09/28
*/
@Data
public class User implements Serializable {
......@@ -98,6 +98,11 @@ public class User implements Serializable {
*/
private String weixinOpenid;
/**
* 支付宝user_id
*/
private String alipayUserId;
/**
* 微信号
*/
......@@ -147,6 +152,7 @@ public class User implements Serializable {
sb.append(", profile=").append(profile);
sb.append(", background=").append(background);
sb.append(", weixinOpenid=").append(weixinOpenid);
sb.append(", alipayUserId=").append(alipayUserId);
sb.append(", wechatId=").append(wechatId);
sb.append(", status=").append(status);
sb.append(", addTime=").append(addTime);
......@@ -184,6 +190,7 @@ public class User implements Serializable {
&& (this.getProfile() == null ? other.getProfile() == null : this.getProfile().equals(other.getProfile()))
&& (this.getBackground() == null ? other.getBackground() == null : this.getBackground().equals(other.getBackground()))
&& (this.getWeixinOpenid() == null ? other.getWeixinOpenid() == null : this.getWeixinOpenid().equals(other.getWeixinOpenid()))
&& (this.getAlipayUserId() == null ? other.getAlipayUserId() == null : this.getAlipayUserId().equals(other.getAlipayUserId()))
&& (this.getWechatId() == null ? other.getWechatId() == null : this.getWechatId().equals(other.getWechatId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
......@@ -210,6 +217,7 @@ public class User implements Serializable {
result = prime * result + ((getProfile() == null) ? 0 : getProfile().hashCode());
result = prime * result + ((getBackground() == null) ? 0 : getBackground().hashCode());
result = prime * result + ((getWeixinOpenid() == null) ? 0 : getWeixinOpenid().hashCode());
result = prime * result + ((getAlipayUserId() == null) ? 0 : getAlipayUserId().hashCode());
result = prime * result + ((getWechatId() == null) ? 0 : getWechatId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
......@@ -252,6 +260,7 @@ public class User implements Serializable {
profile("profile", "profile", "VARCHAR", false),
background("background", "background", "VARCHAR", false),
weixinOpenid("weixin_openid", "weixinOpenid", "VARCHAR", false),
alipayUserId("alipay_user_id", "alipayUserId", "VARCHAR", false),
wechatId("wechat_id", "wechatId", "VARCHAR", false),
status("status", "status", "TINYINT", true),
addTime("add_time", "addTime", "TIMESTAMP", false),
......
......@@ -2113,6 +2113,148 @@ public class UserExample {
return (Criteria) this;
}
public Criteria andAlipayUserIdIsNull() {
addCriterion("alipay_user_id is null");
return (Criteria) this;
}
public Criteria andAlipayUserIdIsNotNull() {
addCriterion("alipay_user_id is not null");
return (Criteria) this;
}
public Criteria andAlipayUserIdEqualTo(String value) {
addCriterion("alipay_user_id =", value, "alipayUserId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAlipayUserIdEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("alipay_user_id = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAlipayUserIdNotEqualTo(String value) {
addCriterion("alipay_user_id <>", value, "alipayUserId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAlipayUserIdNotEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("alipay_user_id <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAlipayUserIdGreaterThan(String value) {
addCriterion("alipay_user_id >", value, "alipayUserId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAlipayUserIdGreaterThanColumn(User.Column column) {
addCriterion(new StringBuilder("alipay_user_id > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAlipayUserIdGreaterThanOrEqualTo(String value) {
addCriterion("alipay_user_id >=", value, "alipayUserId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAlipayUserIdGreaterThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("alipay_user_id >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAlipayUserIdLessThan(String value) {
addCriterion("alipay_user_id <", value, "alipayUserId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAlipayUserIdLessThanColumn(User.Column column) {
addCriterion(new StringBuilder("alipay_user_id < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAlipayUserIdLessThanOrEqualTo(String value) {
addCriterion("alipay_user_id <=", value, "alipayUserId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andAlipayUserIdLessThanOrEqualToColumn(User.Column column) {
addCriterion(new StringBuilder("alipay_user_id <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andAlipayUserIdLike(String value) {
addCriterion("alipay_user_id like", value, "alipayUserId");
return (Criteria) this;
}
public Criteria andAlipayUserIdNotLike(String value) {
addCriterion("alipay_user_id not like", value, "alipayUserId");
return (Criteria) this;
}
public Criteria andAlipayUserIdIn(List<String> values) {
addCriterion("alipay_user_id in", values, "alipayUserId");
return (Criteria) this;
}
public Criteria andAlipayUserIdNotIn(List<String> values) {
addCriterion("alipay_user_id not in", values, "alipayUserId");
return (Criteria) this;
}
public Criteria andAlipayUserIdBetween(String value1, String value2) {
addCriterion("alipay_user_id between", value1, value2, "alipayUserId");
return (Criteria) this;
}
public Criteria andAlipayUserIdNotBetween(String value1, String value2) {
addCriterion("alipay_user_id not between", value1, value2, "alipayUserId");
return (Criteria) this;
}
public Criteria andWechatIdIsNull() {
addCriterion("wechat_id is null");
return (Criteria) this;
......
......@@ -16,6 +16,7 @@
<result column="profile" jdbcType="VARCHAR" property="profile" />
<result column="background" jdbcType="VARCHAR" property="background" />
<result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid" />
<result column="alipay_user_id" jdbcType="VARCHAR" property="alipayUserId" />
<result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="add_time" jdbcType="TIMESTAMP" property="addTime" />
......@@ -83,8 +84,8 @@
</sql>
<sql id="Base_Column_List">
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
add_time, update_time, deleted, share_user_id
nickname, mobile, avatar, profile, background, weixin_openid, alipay_user_id, wechat_id,
`status`, add_time, update_time, deleted, share_user_id
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.UserExample" resultMap="BaseResultMap">
select
......@@ -120,8 +121,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
add_time, update_time, deleted, share_user_id
nickname, mobile, avatar, profile, background, weixin_openid, alipay_user_id, wechat_id,
`status`, add_time, update_time, deleted, share_user_id
</otherwise>
</choose>
from user
......@@ -173,8 +174,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
add_time, update_time, deleted, share_user_id
nickname, mobile, avatar, profile, background, weixin_openid, alipay_user_id, wechat_id,
`status`, add_time, update_time, deleted, share_user_id
</otherwise>
</choose>
from user
......@@ -198,16 +199,16 @@
birthday, last_login_time, last_login_ip,
user_level, nickname, mobile,
avatar, profile, background,
weixin_openid, wechat_id, `status`,
add_time, update_time, deleted,
share_user_id)
weixin_openid, alipay_user_id, wechat_id,
`status`, add_time, update_time,
deleted, share_user_id)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
#{birthday,jdbcType=DATE}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{lastLoginIp,jdbcType=VARCHAR},
#{userLevel,jdbcType=TINYINT}, #{nickname,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{avatar,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR}, #{background,jdbcType=VARCHAR},
#{weixinOpenid,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
#{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{deleted,jdbcType=BIT},
#{shareUserId,jdbcType=BIGINT})
#{weixinOpenid,jdbcType=VARCHAR}, #{alipayUserId,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{addTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{deleted,jdbcType=BIT}, #{shareUserId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.User">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -254,6 +255,9 @@
<if test="weixinOpenid != null">
weixin_openid,
</if>
<if test="alipayUserId != null">
alipay_user_id,
</if>
<if test="wechatId != null">
wechat_id,
</if>
......@@ -313,6 +317,9 @@
<if test="weixinOpenid != null">
#{weixinOpenid,jdbcType=VARCHAR},
</if>
<if test="alipayUserId != null">
#{alipayUserId,jdbcType=VARCHAR},
</if>
<if test="wechatId != null">
#{wechatId,jdbcType=VARCHAR},
</if>
......@@ -384,6 +391,9 @@
<if test="record.weixinOpenid != null">
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
</if>
<if test="record.alipayUserId != null">
alipay_user_id = #{record.alipayUserId,jdbcType=VARCHAR},
</if>
<if test="record.wechatId != null">
wechat_id = #{record.wechatId,jdbcType=VARCHAR},
</if>
......@@ -423,6 +433,7 @@
profile = #{record.profile,jdbcType=VARCHAR},
background = #{record.background,jdbcType=VARCHAR},
weixin_openid = #{record.weixinOpenid,jdbcType=VARCHAR},
alipay_user_id = #{record.alipayUserId,jdbcType=VARCHAR},
wechat_id = #{record.wechatId,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=TINYINT},
add_time = #{record.addTime,jdbcType=TIMESTAMP},
......@@ -475,6 +486,9 @@
<if test="weixinOpenid != null">
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
</if>
<if test="alipayUserId != null">
alipay_user_id = #{alipayUserId,jdbcType=VARCHAR},
</if>
<if test="wechatId != null">
wechat_id = #{wechatId,jdbcType=VARCHAR},
</if>
......@@ -511,6 +525,7 @@
profile = #{profile,jdbcType=VARCHAR},
background = #{background,jdbcType=VARCHAR},
weixin_openid = #{weixinOpenid,jdbcType=VARCHAR},
alipay_user_id = #{alipayUserId,jdbcType=VARCHAR},
wechat_id = #{wechatId,jdbcType=VARCHAR},
`status` = #{status,jdbcType=TINYINT},
add_time = #{addTime,jdbcType=TIMESTAMP},
......@@ -553,8 +568,8 @@
</when>
<otherwise>
id, username, `password`, gender, birthday, last_login_time, last_login_ip, user_level,
nickname, mobile, avatar, profile, background, weixin_openid, wechat_id, `status`,
add_time, update_time, deleted, share_user_id
nickname, mobile, avatar, profile, background, weixin_openid, alipay_user_id, wechat_id,
`status`, add_time, update_time, deleted, share_user_id
</otherwise>
</choose>
from user
......
......@@ -25,4 +25,5 @@ public class UserRequestDto implements Entity {
// 快捷登录方式(1、微信,2、支付宝,3、抖音)
private Integer loginType;
private String wxOpenId;
private String alipayUserId;
}
......@@ -226,6 +226,16 @@ public class ItemServiceImpl implements ItemService {
officialUserIds = itemsOfficialUsersRelations.stream()
.map(ItemsOfficialUsersRelation::getUserId).collect(Collectors.toList());
}
// 判断是否展示浏览量或仅自己可见
Integer isDisplay = null;
if (!isGuest) {
if (dto.getViewPermission().equals(ViewPermissionEnum.ALL.getCode())) {
isDisplay = 1;
}
if (dto.getViewPermission().equals(ViewPermissionEnum.ONLY_ONESELF.getCode())) {
isDisplay = 2;
}
}
if (!officialUserIds.contains(dto.getUserId())) {
// 查询用户和藏品关联表
......@@ -269,10 +279,8 @@ public class ItemServiceImpl implements ItemService {
// 设置用户头像和昵称
itemResponseVo.setItemNickname(nickname);
itemResponseVo.setItemAvatar(avatar);
// 判断是否需要展示浏览量
if (!isGuest && item.getViewPermission().equals(ViewPermissionEnum.ALL.getCode())) {
itemResponseVo.setIsDisplay(1);
}
// 设置是否需要展示浏览量或仅自己可见
itemResponseVo.setIsDisplay(isDisplay);
// 设置浏览量
itemResponseVo.setViewsNumber(item.getViewPermission().equals(ViewPermissionEnum.ALL.getCode()) ?
StringUtil.formatCount(footPrintDao.countByItemIds(dto.getUserId(), item.getId(), null)) : "0");
......@@ -301,6 +309,7 @@ public class ItemServiceImpl implements ItemService {
List<AgentTranceResponseVo> resultList = new ArrayList<>();
final String itemNickname = nickname;
final String itemAvatar = avatar;
Integer finalIsDisplay = isDisplay;
esPageInfo.getDataList().forEach(s -> {
ItemResponseVo itemResponseVo = new ItemResponseVo();
ItemOfEs es = (ItemOfEs) s;
......@@ -323,10 +332,8 @@ public class ItemServiceImpl implements ItemService {
// 设置藏品发布用户的昵称和头像
itemResponseVo.setItemNickname(itemNickname);
itemResponseVo.setItemAvatar(itemAvatar);
// 判断是否需要展示浏览量
if (!isGuest && es.getViewPermission().equals(ViewPermissionEnum.ALL.getCode())) {
itemResponseVo.setIsDisplay(1);
}
// 设置是否需要展示浏览量或仅自己可见
itemResponseVo.setIsDisplay(finalIsDisplay);
// 设置浏览量
itemResponseVo.setViewsNumber(StringUtil.formatCount(footPrintDao.countByItemIds(dto.getUserId(), es.getId(), null)));
......
......@@ -179,6 +179,7 @@ public class UserServiceImpl implements UserService {
if (StringUtils.equals("false", mobile)) {
return Result.failed("用户信息解密失败");
}
dto.setAlipayUserId(alipayLoginManager.getAlipayUserId(dto.getLoginCode()));
}
if (dto.getLoginType().equals(LoginTypeEnum.TIKTOK.getCode())) {
String sessionKey = tikTokLoginManager.getSessionKey(dto.getLoginCode());
......@@ -456,9 +457,8 @@ public class UserServiceImpl implements UserService {
user.setWechatId("");
user.setMobile(dto.getMobile());
user.setAvatar(avatarUrl);
if (StringUtils.isNotBlank(dto.getWxOpenId())) {
user.setWeixinOpenid(dto.getWxOpenId());
}
user.setWeixinOpenid(dto.getWxOpenId());
user.setAlipayUserId(dto.getAlipayUserId());
while (true) {
String nickname = "收藏家" + StringUtil.generateRandomString(10);
if (!userDao.isExistedByNickname(0L, nickname)) {
......@@ -480,6 +480,9 @@ public class UserServiceImpl implements UserService {
if (StringUtils.isNotBlank(dto.getWxOpenId())) {
user.setWeixinOpenid(dto.getWxOpenId());
}
if (StringUtils.isNotBlank(dto.getAlipayUserId())) {
user.setAlipayUserId(dto.getAlipayUserId());
}
user.setLastLoginTime(new Date());
user.setLastLoginIp(IpUtil.client(request));
if (userDao.updateById(user) == 0) {
......
......@@ -5,11 +5,14 @@ import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipayEncrypt;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayOpenAppQrcodeCreateRequest;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipayOpenAppQrcodeCreateResponse;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import com.xxdxxs.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -27,13 +30,13 @@ public class AlipayLoginManager {
private static final Logger logger = LoggerFactory.getLogger(AlipayLoginManager.class);
// 支付宝小程序对应的appid
private static final String appid = "2021004108672867";
private static final String appid = "2021004120659218";
// 支付宝小程序对应的支付宝公钥
private static final String signVeriKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgUwrLm4n13ixVgq1nUS3Aggieny0yxl8uiwNEKNNoL8MZnvrKmZSFAgr8m7384OLuElo2CXTTMZWCNeGo7If+qb1whCBsrGBfWAjrEdFlTNirWINaoS9F/fvJPRQ/biFryvhvP/AJewkAA2NuxZwbYpelw6zc+lNF0bGiSBujAawFs1Ok2SQMMk4javXvUwibx7u+aiSCDOy7IaZW+Rv6wVfeHT2uHIDKvOYyitdmjiJikuIzvILeZs4sZwlZvWEbEa1bPmAhi5ZZsh62Nt7Xd3OnMvcj9VK9xkJGJ3Dgx3MmAC54kDl0CST9a4sdRRbMi4gd7v+K8e484TQdHjQMwIDAQAB";
private static final String signVeriKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg9VJ19qaoZngq6FcHfKm4qjazl6h9FdhLppIPeHvs9XeEZcqPKkN82qpx7TWGO5jGkMNklFFz85Zp/grGJPwNjWh9LgOBVGtc9/JRffXM5vmPgS/CMNdWdMe9lFE1wLWNUHKuHGQUHP+WRAD9GvR6VLLRm0pAFKxH1WQCDoiU5fBFTsXBsciG2b/x/nttPCcmtMcFPuQFyJVuxpGs3/bmHu/yfxujWCHbfk6fcM3GcnknhCwtut+4TcrrccDWonqtVlQtvf6Ob9YTyXlOYs1xm3OtjHIDRP985N3WUNppfvJwnOaVjorTf5/3fm4F8W2kVshAqixkqXj9HmyqWYKtQIDAQAB";
// 支付宝小程序对应的加解密密钥
private static final String decryptKey = "kpeGeMSDTQZWyheHWt4Iwg==";
private static final String decryptKey = "ozhATStzhD/F/LV7CFX81g==";
// 支付宝小程序对应的应用私钥
private static final String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDltXUqBWcnmTt8O/vc8Br9hF87mKB3+9KQ5jN9Oh8FCs0J+0mED+ggBKLhNCsBb+uyu+MHqs5kBYDTwqp5fDPTyW37RklvfpHcf9HO9o1V7+C+t7qA2GLaXl/G5JDjpIipd+sHLj/yPw5DsTuMi8HUwb+ninSoil0Bg2QqTYL/2TiAfJ3+3s7nKIrjuEUmd47qFfpoyyPP0ZY+3E57M+vkklEvFWy8dCCvEh9bZY4ebVS4IUMLyhATpCqn8ESOjlkaIC4rAuTLhr52+hNsQUGzeVcKmpKGYm4YEhKaiwGW0MecjFd5wLj/ThPNnHNk23CwVfgN74ISu5UwibSHNzydAgMBAAECggEANw2tXfvbhD8SZa0OqR4Wqen+1Q64buk4xyeU8Y9rfc7f42OJdBBH5tyVmPni0L5dNAIZ4G2Md6ZmANqn9uPQnBKrvExVL1abaMhtpXer2gvaxnrMRTMXRhTWSZngK970LgGin57zDoEUTx78EawxMWeaInJpkTdQIRu3dvgKzHxz2uuWPXvRWTsgHrOcya7tjB05aQDJvPmZIfduER170kRw+nkhNLYoaYnfvlG5lBS+Nbw9wJmIt1VziET+anBEjCiQAxZdefsw2O9+N27MR8dToOyY2/03rzByuSZav204D6BG9Ggs47ogfvoszFYzXxedqj8WNXmtW59za++XNQKBgQD8q6WzgKdFp9mdZp0O9WfbYwUnrTnijRIJo6if2YMUipN/nbsEo50MDeWMEVfxrW+JYkgcL5xU6FDtPwoR5uN31NaFluuqSCoOdVtTUgpdNIMIDKbmplr5b8WuF7Ng0mSi9FYhRqbkQS0Lk412/eUxvXWIcyhUnbb3cqGPart/ZwKBgQDovFods6BF1gdfKDIWNZB4wTCUkQ7KOHmHfuHdAhZV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odiC1C+rxGRSTigVlFWjU6UADni01bHGORpzkBPfWKFW+z9FPczHnxGF9ipOKcqpsIFRaw0MkUzeUdaDGfRtSQ6E+Dex6MNiNbvIKwxA4qkjMHaeBKz8/xyLKy0Nhp/dQ=";
// 支付宝小程序链接前缀
private static final String linkPrefix = "alipays://platformapi/startapp?appId=%s";
......@@ -90,6 +93,36 @@ public class AlipayLoginManager {
return JsonUtils.getValueByPath(plainData, "mobile");
}
public String getAlipayUserId(String loginCode) {
logger.info("开始解密获取支付宝小程序登录用户的access_token");
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(appid);
alipayConfig.setPrivateKey(privateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(signVeriKey);
alipayConfig.setCharset("UTF8");
alipayConfig.setSignType("RSA2");
try {
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode(loginCode);
request.setGrantType("authorization_code");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
logger.info("调用支付宝小程序获取登录用户的access_token的结果:" + response.getBody());
if (response.isSuccess()) {
logger.info("调用支付宝小程序获取登录用户的access_token成功");
return JsonUtils.getValueByPath(response.getBody(), "alipay_system_oauth_token_response/user_id");
} else {
logger.info("调用支付宝小程序获取登录用户的access_token失败");
return "";
}
} catch (Exception e) {
logger.error("调用支付宝小程序获取登录用户的access_token异常");
return "";
}
}
/**
* 获取二维码
*
......
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