前端-胡立永 2 weeks ago
parent
commit
6fd59511b3
6 changed files with 28 additions and 11 deletions
  1. +15
    -8
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiLoginService.java
  2. +3
    -1
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiVipServiceImpl.java
  3. +6
    -1
      jeecg-boot/jeecg-boot-module/module-pay/src/main/java/org/jeecg/modules/pay/MpWxPayService.java
  4. +2
    -0
      jeecg-boot/jeecg-boot-module/module-pay/src/main/java/org/jeecg/modules/pay/config/WxPay.java
  5. +1
    -1
      jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml
  6. +1
    -0
      jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/pay_weixin.properties

+ 15
- 8
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiLoginService.java View File

@ -91,16 +91,16 @@ public class AppletApiLoginService {
log.info("微信登录成功,openid: {}", openid);
// 查找或创建用户
AppletUser appletUser = findOrCreateUser(openid, unionid, inviter);
AppletUser appletUser = findOrCreateUser(openid, unionid, inviter, type, jsonResponse);
String token = null;
if (LoginType.OFFICIAL.equals(type)){
String access_token = jsonResponse.getString("access_token");
setUserInfo(appletUser, access_token);
token = JwtUtil.sign(appletUser.getOfficialId(), appletUser.getId());
}else {
token = JwtUtil.sign(appletUser.getOpenid(), appletUser.getId());
}
// 生成JWT token
String token = JwtUtil.sign(appletUser.getOpenid(), appletUser.getId());
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
// 设置超时时间
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
@ -133,6 +133,7 @@ public class AppletApiLoginService {
String headimgurl = json_member.getString("headimgurl");
user.setName(nickname);
user.setAvatar(headimgurl);
appletUserService.updateById(user);
}
/**
@ -209,7 +210,7 @@ public class AppletApiLoginService {
* @param unionid 微信unionid
* @return 用户信息
*/
private AppletUser findOrCreateUser(String openid, String unionid, String inviter) {
private AppletUser findOrCreateUser(String openid, String unionid, String inviter, String type, JSONObject jsonResponse) {
try {
// 根据openid查找用户
AppletUser user = appletUserService.getByUnionId(openid, unionid);
@ -217,7 +218,13 @@ public class AppletApiLoginService {
if (user == null) {
// 创建新用户
user = new AppletUser();
user.setOpenid(openid);
if (LoginType.OFFICIAL.equals(type)){
user.setOfficialId(openid);
String access_token = jsonResponse.getString("access_token");
setUserInfo(user, access_token);
}else {
user.setOpenid(openid);
}
user.setName("微信用户" + openid.substring(0, 8));
user.setCreateTime(new Date());
user.setCreateBy("system");


+ 3
- 1
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiVipServiceImpl.java View File

@ -169,7 +169,9 @@ public class AppletApiVipServiceImpl implements AppletApiVipService {
price,
order.getId(),
openid,
order.toString());
order.toString(),
LoginType.OFFICIAL.equals(type)
);
return appOrder;
} else {


+ 6
- 1
jeecg-boot/jeecg-boot-module/module-pay/src/main/java/org/jeecg/modules/pay/MpWxPayService.java View File

@ -85,7 +85,7 @@ public class MpWxPayService {
*/
public Object createOrder(String productName, String clientIp,
String productId, Integer price, String orderNo,
String openId, String body){
String openId, String body, boolean type){
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
request.setDeviceInfo("WEB"); //设备号
request.setTradeType("JSAPI"); //交易类型
@ -97,6 +97,11 @@ public class MpWxPayService {
request.setNotifyUrl(wxPay.notifyOneUrl);//设置回调路径
request.setProductId(productId); //商品id
request.setOpenid(openId); //JSAPI OPENID
if (type){
request.setAppid(wxPay.getOfficialAppId());
}else {
request.setAppid(wxPay.getAppId());
}
if (dev){
request.setTotalFee(price);
request.setNotifyUrl(wxPay.notifyUrlOneDev);


+ 2
- 0
jeecg-boot/jeecg-boot-module/module-pay/src/main/java/org/jeecg/modules/pay/config/WxPay.java View File

@ -21,6 +21,8 @@ public class WxPay {
*/
public String appId;
public String officialAppId;
/**
* 微信支付mchKey
*/


+ 1
- 1
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml View File

@ -1,5 +1,5 @@
server:
port: 8002
port: 8003
undertow:
# max-http-post-size: 10MB # 平替 tomcat server.tomcat.max-swallow-siz, undertow该值默认为-1
worker-threads: 16 # 4核CPU标准配置


+ 1
- 0
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/pay_weixin.properties View File

@ -1,5 +1,6 @@
pay.mchId=1724993508
pay.appId=wx24736a3864e8f0e9
pay.officialAppId=wxd5dc792292466cf6
pay.mchKey=0fdb77429ffdf206c151af76a663041c
pay.keyPath=classpath:apiclient_cert.pem
pay.notifyUrl=https://www.multipleculture.com/englishread-admin/appletApi/member/payNotify


Loading…
Cancel
Save