Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -231,6 +231,12 @@
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
</dependency>
|
||||
<!-- 支付宝服务端通用SDK -->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.39.165.ALL</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.chaozhanggui.system.cashierservice.alipayUtil;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.AlipayConfig;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 支付宝通用SDK工具类
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2024-09-23 16:15
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AlipayUtil {
|
||||
|
||||
/**
|
||||
* 网关地址 线上:https://openapi.alipay.com/gateway.do 沙箱:https://openapi.alipaydev.com/gateway.do
|
||||
*/
|
||||
@Value("${alipay.sdk.config.serverUrl}")
|
||||
private String serverUrl;
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
@Value("${alipay.sdk.config.appId}")
|
||||
private String appId;
|
||||
/**
|
||||
* 应用私钥
|
||||
*/
|
||||
@Value("${alipay.sdk.config.privateKey}")
|
||||
private String privateKey;
|
||||
/**
|
||||
* 支付宝公钥
|
||||
*/
|
||||
@Value("${alipay.sdk.config.alipayPublicKey}")
|
||||
private String alipayPublicKey;
|
||||
|
||||
/**
|
||||
* 创建支付宝客户端
|
||||
* @return AlipayClient
|
||||
*/
|
||||
@SneakyThrows
|
||||
public AlipayClient createClient() {
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
//设置网关地址
|
||||
alipayConfig.setServerUrl(serverUrl);
|
||||
//设置应用ID
|
||||
alipayConfig.setAppId(appId);
|
||||
//设置应用私钥
|
||||
alipayConfig.setPrivateKey(privateKey);
|
||||
//设置支付宝公钥
|
||||
alipayConfig.setAlipayPublicKey(alipayPublicKey);
|
||||
return new DefaultAlipayClient(alipayConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付宝用户的openId
|
||||
* @param code 用户信息授权码
|
||||
* @return openId
|
||||
*/
|
||||
public String getOpenId(String code) throws AlipayApiException{
|
||||
AlipaySystemOauthTokenRequest req = new AlipaySystemOauthTokenRequest();
|
||||
//SDK已经封装掉了公共参数,这里只需要传入业务参数
|
||||
req.setCode(code);
|
||||
req.setGrantType("authorization_code");
|
||||
//此次只是参数展示,未进行字符串转义,实际情况下请转义
|
||||
//req.setBizContent(" {" + " \"primary_industry_name\":\"IT科技/IT软件与服务\"," + " \"primary_industry_code\":\"10001/20102\"," + " \"secondary_industry_code\":\"10001/20102\"," + " \"secondary_industry_name\":\"IT科技/IT软件与服务\"" + " }");
|
||||
AlipaySystemOauthTokenResponse response;
|
||||
try {
|
||||
response = createClient().execute(req);
|
||||
}catch (AlipayApiException e){
|
||||
log.error("获取支付宝用户信息失败,错误码:{},错误信息:{}", e.getErrCode(), e.getErrMsg());
|
||||
throw e;
|
||||
}
|
||||
//调用失败
|
||||
if (!response.isSuccess()) {
|
||||
log.error("获取支付宝用户信息失败,错误码:{},错误信息:{}", response.getSubCode(), response.getSubMsg());
|
||||
throw new AlipayApiException(response.getSubCode(), response.getSubMsg());
|
||||
}
|
||||
//调用成功,则处理业务逻辑
|
||||
return response.getOpenId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.chaozhanggui.system.cashierservice.auth;
|
||||
|
||||
/**
|
||||
* 三方登录认证来源
|
||||
* @author tankaikai
|
||||
* @since 2024-09-23 17:51
|
||||
*/
|
||||
public enum AuthSource {
|
||||
WECHAT("微信", "wechat"),
|
||||
ALIPAY("支付宝", "alipay");
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
AuthSource(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public class LoginFilter implements Filter {
|
||||
|
||||
// "cashierService/login/**",//登录部分接口不校验
|
||||
"cashierService/login/wx/**",//登录部分接口不校验
|
||||
"cashierService/login/auth/**",//登录部分接口不校验
|
||||
"cashierService/login/app/login",//登录部分接口不校验
|
||||
"cashierService/product/queryProduct",
|
||||
"cashierService/product/queryProductSku",
|
||||
@@ -94,7 +95,7 @@ public class LoginFilter implements Filter {
|
||||
return;
|
||||
}
|
||||
|
||||
//environment 环境标识 wx app 后续environment不可为空
|
||||
//environment 环境标识 wx alipay app 后续environment不可为空
|
||||
String environment = request.getHeader("environment");
|
||||
|
||||
// 判断用户TOKEN是否存在
|
||||
@@ -130,7 +131,7 @@ public class LoginFilter implements Filter {
|
||||
String userId = jsonObject1.getString("userId");
|
||||
tokenKey=RedisCst.ONLINE_APP_USER.concat(userId);
|
||||
//获取redis中的token
|
||||
}else if(environment.equals("wx")){
|
||||
}else if(environment.equals("wx") || environment.equals("alipay")){
|
||||
//获取当前登录人的用户id
|
||||
String openId = jsonObject1.getString("openId");
|
||||
if(StringUtils.isBlank(openId)){
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.chaozhanggui.system.cashierservice.alipayUtil.AlipayUtil;
|
||||
import com.chaozhanggui.system.cashierservice.auth.AuthSource;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbMerchantAccountMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbMerchantAccount;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
||||
@@ -16,10 +18,13 @@ import com.chaozhanggui.system.cashierservice.service.LoginService;
|
||||
import com.chaozhanggui.system.cashierservice.service.OnlineUserService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.MD5Utils;
|
||||
import com.chaozhanggui.system.cashierservice.util.StringUtil;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -60,28 +65,27 @@ public class LoginContoller {
|
||||
@Autowired
|
||||
RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
AlipayUtil alipayUtil;
|
||||
|
||||
|
||||
@RequestMapping("/wx/business/login")
|
||||
public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "shopId", required = false) String shopId
|
||||
) {
|
||||
public Result wxBusinessLogin(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "shopId", required = false) String shopId) {
|
||||
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, businessAppId, businessSecrete);
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
if(Objects.isNull(openid)){
|
||||
if (Objects.isNull(openid)) {
|
||||
return Result.fail("获取微信id失败");
|
||||
}
|
||||
|
||||
return loginService.wxBusinessLogin(openid,shopId);
|
||||
return loginService.wxBusinessLogin(openid, shopId);
|
||||
}
|
||||
|
||||
@GetMapping("/wx/business/openId")
|
||||
public Result getOpenId(
|
||||
@RequestParam String code
|
||||
) {
|
||||
public Result getOpenId(@RequestParam String code) {
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
if(Objects.isNull(openid)){
|
||||
if (Objects.isNull(openid)) {
|
||||
return Result.fail("获取微信id失败");
|
||||
}
|
||||
|
||||
@@ -95,48 +99,36 @@ public class LoginContoller {
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/wx/custom/login")
|
||||
public Result wxCustomLogin(HttpServletRequest request, @RequestBody Map<String, String> map) {
|
||||
@RequestMapping("/auth/custom/login")
|
||||
@SneakyThrows
|
||||
public Result authCustomLogin(HttpServletRequest request, @RequestBody Map<String, String> map) {
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
||||
Result.fail("code不能为空");
|
||||
}
|
||||
String code = map.get("code").toString();
|
||||
String rawData = map.get("rawData");
|
||||
// String signature = map.get("signature");
|
||||
// String encryptedData = map.get("encryptedData");
|
||||
// String ivStr = map.get("iv");
|
||||
// String phone = map.get("phone");
|
||||
// 用户非敏感信息:rawData
|
||||
// 签名:signature
|
||||
JSONObject rawDataJson = JSON.parseObject(rawData);
|
||||
// 1.接收小程序发送的code
|
||||
// 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
|
||||
// 3.接收微信接口服务 获取返回的参数
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
// String sessionKey = SessionKeyOpenId.getString("session_key");
|
||||
|
||||
// 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey)
|
||||
// String signature2 = DigestUtils.sha1Hex(rawData + sessionKey);
|
||||
// if (!signature.equals(signature2)) {
|
||||
// return Result.fail("签名校验失败");
|
||||
// }
|
||||
// String phone = "";
|
||||
// try{
|
||||
// String data = WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr);
|
||||
// if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
|
||||
// }// phone =JSONObject.parseObject(data).get("phoneNumber").toString();
|
||||
// }catch (Exception e){
|
||||
// log.info("登录传参:获取手机号失败{}",e.getMessage());
|
||||
// }
|
||||
String nickName = rawDataJson.getString("nickName");
|
||||
String avatarUrl = rawDataJson.getString("avatarUrl");
|
||||
try {
|
||||
return loginService.wxCustomLogin(openid, avatarUrl, nickName, "", IpUtil.getIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 三方登录来源 wechat、alipay
|
||||
String source = map.getOrDefault("source",AuthSource.WECHAT.getValue());
|
||||
String code = map.get("code");
|
||||
if(AuthSource.WECHAT.getValue().equals(source)){
|
||||
// 1.接收小程序发送的code
|
||||
// 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
|
||||
// 3.接收微信接口服务 获取返回的参数
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
try {
|
||||
return loginService.wxCustomLogin(openid, "", "", "", IpUtil.getIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else if(AuthSource.ALIPAY.getValue().equals(source)){
|
||||
try {
|
||||
String openId = alipayUtil.getOpenId(code);
|
||||
return loginService.alipayCustomLogin(openId);
|
||||
}catch (AlipayApiException e){
|
||||
return Result.fail("登录失败:"+e.getErrMsg());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return Result.fail("登录失败");
|
||||
|
||||
}
|
||||
@@ -179,7 +171,7 @@ public class LoginContoller {
|
||||
// return Result.fail("获取手机号失败,请重试!");
|
||||
// }
|
||||
@RequestMapping("getPhoneNumber")
|
||||
public Result getPhoneNumber(@RequestHeader String openId,@RequestBody Map<String, String> map) {
|
||||
public Result getPhoneNumber(@RequestHeader String openId, @RequestBody Map<String, String> map) {
|
||||
|
||||
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("code") || ObjectUtil.isEmpty(map.get("code"))) {
|
||||
Result.fail("code不能为空");
|
||||
@@ -201,14 +193,14 @@ public class LoginContoller {
|
||||
try {
|
||||
if (ObjectUtil.isNotEmpty(data) && JSONObject.parseObject(data).containsKey("phoneNumber")) {
|
||||
// if (!map.containsKey("shopId") || ObjectUtil.isEmpty(map.get("shopId"))) {
|
||||
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
|
||||
return Result.success(CodeEnum.SUCCESS, JSONObject.parseObject(data).get("phoneNumber"));
|
||||
// }
|
||||
// log.info("登录传参 获取手机号成功 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,JSONObject.parseObject(data).get("phoneNumber"));
|
||||
// return loginService.upPhone(openId,JSONObject.parseObject(data).get("phoneNumber").toString(),map.get("shopId").toString());
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},",sessionKey,encryptedData,ivStr,data);
|
||||
log.info("登录传参 获取手机号失败 sessionKey:{}\n encryptedData:{} \nivStr:{} \n data:{},", sessionKey, encryptedData, ivStr, data);
|
||||
}
|
||||
return Result.fail("获取手机号失败,请重试!");
|
||||
}
|
||||
@@ -254,10 +246,8 @@ public class LoginContoller {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("createCardNo")
|
||||
public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id,
|
||||
@RequestParam("shopId") String shopId
|
||||
) {
|
||||
return loginService.createCardNo(id, openId,shopId);
|
||||
public Result createCardNo(@RequestHeader("openId") String openId, @RequestHeader("token") String token, @RequestHeader("id") String id, @RequestParam("shopId") String shopId) {
|
||||
return loginService.createCardNo(id, openId, shopId);
|
||||
}
|
||||
|
||||
@GetMapping("/userInfo")
|
||||
@@ -267,6 +257,7 @@ public class LoginContoller {
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
*
|
||||
* @param token
|
||||
* @param userInfo
|
||||
* @return
|
||||
@@ -281,16 +272,16 @@ public class LoginContoller {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/upPass")
|
||||
public Result upPass(@RequestHeader String token,@RequestBody UserPassDto passVo){
|
||||
public Result upPass(@RequestHeader String token, @RequestBody UserPassDto passVo) {
|
||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
String newPass = MD5Utils.MD5Encode(passVo.getNewPass(), "utf-8");
|
||||
if (ObjectUtil.isNull(passVo.getCode())) {
|
||||
String oldPass = MD5Utils.MD5Encode(passVo.getOldPass(), "utf-8");
|
||||
return loginService.upPass(userId,oldPass, newPass);
|
||||
return loginService.upPass(userId, oldPass, newPass);
|
||||
} else {
|
||||
boolean tf = loginService.validate(passVo.getCode(), passVo.getPhone());
|
||||
if (tf) {
|
||||
TbUserInfo userInfo=new TbUserInfo();
|
||||
TbUserInfo userInfo = new TbUserInfo();
|
||||
userInfo.setId(Integer.valueOf(userId));
|
||||
userInfo.setPassword(newPass);
|
||||
return loginService.upUserInfo(userInfo);
|
||||
@@ -301,16 +292,16 @@ public class LoginContoller {
|
||||
}
|
||||
|
||||
@PostMapping(value = "modityPass")
|
||||
public Result modityPass(@RequestHeader String token,@RequestBody UserPassDto passVo){
|
||||
public Result modityPass(@RequestHeader String token, @RequestBody UserPassDto passVo) {
|
||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
String newPass = MD5Utils.MD5Encode(passVo.getNewPass(), "utf-8");
|
||||
if (ObjectUtil.isNull(passVo.getCode())) {
|
||||
String oldPass = MD5Utils.MD5Encode(passVo.getOldPass(), "utf-8");
|
||||
return loginService.upPass(userId,oldPass, newPass);
|
||||
return loginService.upPass(userId, oldPass, newPass);
|
||||
} else {
|
||||
boolean tf = loginService.validate(passVo.getCode(), passVo.getPhone());
|
||||
if (tf) {
|
||||
TbUserInfo userInfo=new TbUserInfo();
|
||||
TbUserInfo userInfo = new TbUserInfo();
|
||||
userInfo.setId(Integer.valueOf(userId));
|
||||
userInfo.setPassword(newPass);
|
||||
return loginService.upUserInfo(userInfo);
|
||||
@@ -359,12 +350,12 @@ public class LoginContoller {
|
||||
}
|
||||
//验证密码
|
||||
String mdPasswordString = MD5Utils.MD5Encode(authUserDto.getPassword(), "utf-8");
|
||||
return loginService.appLogin(authUserDto.getUsername(),openid, mdPasswordString);
|
||||
return loginService.appLogin(authUserDto.getUsername(), openid, mdPasswordString);
|
||||
} else {
|
||||
// tf = true;
|
||||
tf = loginService.validate(authUserDto.getCode(), authUserDto.getUsername());
|
||||
if (tf) {
|
||||
return loginService.appLogin(authUserDto.getUsername(),openid, null);
|
||||
return loginService.appLogin(authUserDto.getUsername(), openid, null);
|
||||
} else {
|
||||
return Result.fail("验证码输入有误");
|
||||
}
|
||||
@@ -393,29 +384,31 @@ public class LoginContoller {
|
||||
|
||||
/**
|
||||
* 重置资金密码
|
||||
*
|
||||
* @param token
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("resetPwd")
|
||||
public Result resetPwd(@RequestHeader String token,@RequestBody Map<String, Object> map){
|
||||
public Result resetPwd(@RequestHeader String token, @RequestBody Map<String, Object> map) {
|
||||
|
||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
return loginService.resetPwd(userId,map);
|
||||
return loginService.resetPwd(userId, map);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param token
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("mpdifyPwd")
|
||||
public Result mpdifyPwd(@RequestHeader String token,@RequestBody Map<String, Object> map){
|
||||
public Result mpdifyPwd(@RequestHeader String token, @RequestBody Map<String, Object> map) {
|
||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
||||
return loginService.modifyPwd(userId,map);
|
||||
return loginService.modifyPwd(userId, map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopOpenId;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUser;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbUserShopMsg;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
@@ -141,34 +141,72 @@ public class LoginService {
|
||||
|
||||
}
|
||||
|
||||
private void buildNewUserInfo(TbUserInfo userInfo) {
|
||||
userInfo = new TbUserInfo();
|
||||
userInfo.setAmount(BigDecimal.ZERO);
|
||||
userInfo.setChargeAmount(BigDecimal.ZERO);
|
||||
userInfo.setLineOfCredit(BigDecimal.ZERO);
|
||||
userInfo.setConsumeNumber(0);
|
||||
userInfo.setConsumeAmount(BigDecimal.ZERO);
|
||||
userInfo.setTotalScore(0);
|
||||
userInfo.setLockScore(0);
|
||||
userInfo.setHeadImg("");
|
||||
userInfo.setNickName("");
|
||||
userInfo.setTelephone("");
|
||||
userInfo.setStatus(Byte.parseByte("1"));
|
||||
userInfo.setParentType("PERSON");
|
||||
userInfo.setIsResource(Byte.parseByte("0"));
|
||||
userInfo.setIsOnline(Byte.parseByte("0"));
|
||||
userInfo.setIsVip(Byte.parseByte("0"));
|
||||
userInfo.setIsAttentionMp(Byte.parseByte("0"));
|
||||
userInfo.setIsPwd("0");
|
||||
userInfo.setPwd(MD5Utils.md5("123456"));
|
||||
userInfo.setCreatedAt(System.currentTimeMillis());
|
||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public Result wxCustomLogin(String openId, String headImage, String nickName, String telephone, String ip) {
|
||||
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
|
||||
if (ObjectUtil.isNull(userInfo)) {
|
||||
userInfo = new TbUserInfo();
|
||||
userInfo.setAmount(BigDecimal.ZERO);
|
||||
userInfo.setChargeAmount(BigDecimal.ZERO);
|
||||
userInfo.setLineOfCredit(BigDecimal.ZERO);
|
||||
userInfo.setConsumeNumber(0);
|
||||
userInfo.setConsumeAmount(BigDecimal.ZERO);
|
||||
userInfo.setTotalScore(0);
|
||||
userInfo.setLockScore(0);
|
||||
buildNewUserInfo(userInfo);
|
||||
userInfo.setHeadImg(ObjectUtil.isNotNull(headImage) ? headImage : "");
|
||||
userInfo.setNickName(ObjectUtil.isNotNull(nickName) ? nickName : "微信用户");
|
||||
userInfo.setTelephone(ObjectUtil.isNotNull(telephone) ? telephone : "");
|
||||
userInfo.setMiniAppOpenId(openId);
|
||||
userInfo.setStatus(Byte.parseByte("1"));
|
||||
userInfo.setParentType("PERSON");
|
||||
userInfo.setIsResource(Byte.parseByte("0"));
|
||||
userInfo.setIsOnline(Byte.parseByte("0"));
|
||||
userInfo.setIsVip(Byte.parseByte("0"));
|
||||
userInfo.setSourcePath("WECHAT-APP");
|
||||
userInfo.setIsAttentionMp(Byte.parseByte("0"));
|
||||
userInfo.setSearchWord("||微信用户");
|
||||
userInfo.setIsPwd("0");
|
||||
userInfo.setPwd(MD5Utils.md5("123456"));
|
||||
userInfo.setCreatedAt(System.currentTimeMillis());
|
||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||
userInfo.setMiniAppOpenId(openId);
|
||||
tbUserInfoMapper.insert(userInfo);
|
||||
} else {
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
|
||||
}
|
||||
//生成token 信息
|
||||
String token = TokenUtil.generateToken(userInfo.getId(), userInfo.getMiniAppOpenId(), userInfo.getTelephone(), userInfo.getNickName());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("token", token);
|
||||
map.put("userInfo", userInfo);
|
||||
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(openId), JSON.toJSONString(map), 60 * 60 * 24 * 30L);
|
||||
log.info("登录传参 结果:" + JSONUtil.toJSONString(map));
|
||||
return Result.success(CodeEnum.SUCCESS, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝用户登录
|
||||
* @param openId
|
||||
* @return
|
||||
*/
|
||||
public Result alipayCustomLogin(String openId) {
|
||||
TbUserInfo userInfo = tbUserInfoMapper.selectByOpenId(openId);
|
||||
if (ObjectUtil.isNull(userInfo)) {
|
||||
userInfo = new TbUserInfo();
|
||||
buildNewUserInfo(userInfo);
|
||||
userInfo.setNickName("支付宝用户");
|
||||
userInfo.setSourcePath("ALIPAY-APP");
|
||||
userInfo.setSearchWord("||支付宝用户");
|
||||
userInfo.setMiniAppOpenId(openId);
|
||||
tbUserInfoMapper.insert(userInfo);
|
||||
} else {
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
|
||||
# 内网地址
|
||||
url: jdbc:mysql://rm-bp1kn7h89nz62cno1.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
|
||||
username: cashier
|
||||
password: Cashier@1@
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
@@ -24,6 +24,13 @@ wx:
|
||||
appId: wx212769170d2c6b2a
|
||||
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
|
||||
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
|
||||
alipay:
|
||||
sdk:
|
||||
config:
|
||||
serverUrl: https://openapi.alipay.com/gateway.do
|
||||
appId: 2021004145625815
|
||||
privateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCAjDBuS8K/IJb9ui+KuNm/sTUdEiaji4BNpZ92avO1N5JpNlGmac6ec4p3tNFT950sBLcQkClcUpQxUHQzAT6DYNNXOKyvfI/EmcqwCw6PaMNLs/8cV//J2WWZBUhLaOsjKurpm9/3W5MnTh4BGxIfBoeBMA8f8K3BgKdmyKtvIEV2h2cyjsMskdn+g6oNZcmWcms0pvpPHyH46mRaGFhpp0v19wX3WsamGldh1L2VntmaDN3C2XbSrXv90XYp5bEUqwTbLwXpMAlzTibF56d/iqv9oYi8cpAKougUFLOymnbutLNs2tLrEDSFwHcmG2/wbZHybZyYcIgFgv4arf+tAgMBAAECggEAf7hKKlw1y6Z6vvAtalxNZUuRZSfyog3p1bwYWxTavZPQcZ7Zs0lvVDmiO1u5m/7q96BbryY9IhCeUv0H5uF2lhwu/3s9AEL3qTPQkeb6eXxyhhX6A9RfPdM1Qbtg4CQHdHKg4qjP9znSVHwmDZ0y/QaEvdPdQzPjv92u9c2tn4N4x6XyBYcU5gzxiJNnIugCmBgcJo/3H2fgV+XXEhORPvy5of9b4oATHEaLS/8dAS2wuOjhzaGS4MXp3VkXn3XaYjwSzaL03qYWA+xm+aO5sJv8bmqZW7sNVck5o3sPo7cQ4VkBFVzyrRdmJcxcSRJ9MsB9JsrhoKI8pgaXrVie4QKBgQDU2vai0lpBIK/0jzRpPNoqdT8lnafnnWni8nU4kfAh+gCLi+HBPhQRT0kv4unQc2q2/gALE7sgZVO00JGY5a3R0orsojPoUSZlpypGW7GGqKy576NHn0nw4o/PdfysT92VWgt1hlfTf6qfCDhfE9APU+RGvlSWXcT8nxVel3iUaQKBgQCamoJN6+4v+chJvL2nqV8NVVRLp0vDIHxs1QOtKwUodx8Qp1D6CJYtavCXn8aNUFVNQJPJ7TQPpJjXP2rI4SN01weDwx+I+wh8PBGHV6/234R+6TvFgY1PrYgCdfNP4i/E7B4uyEhAxdU73PB8qkqRAeJGok05p7oG71KCOBiYpQKBgEZfGflcuDAeAW5GRhqg3rP4zWa/R7qgZVh9tll8jjp9b96y4XFE99d9MgId8BVVgyt6sEL5Q/2C4ni+F9TH4n6jMADp42VkJuCmsqhOOlP9whU67+2G8Sgtj0QUivPg964f9ffl8XVgGOW5DwIIB9p5btggptCLscufQK5kP545AoGADBvf6tR4wl8w9b2HqTMV08iEIqzGvVC1Dh0c/Zop/EJgN4CzUfIMOSBwGaAVAApzs+pD6QPgGP2OTwWTioo/qa4R05sbxDHNN1XJFa2jhZV6HiqMWOrNs5jm1zJ/zRjtHuJTdtyO9CvKiLbESy9XScY4/8lEfSiK5HIoJzTXkFUCgYAkYkvkW6psJpWj05XWq44UN0n6QOU/Igl35Um/iuOMVhsTmIt09STQVTuzJzfH82+sCqoRsD1blE5unKNUC1DK77aNKTv3Z0dxN9R7FAyfZRiYQXTrbBPBqWjay6FCNxn8e8UsJN4Z6FIV2LGlQI114krSap1MALKLVvnld0NaUQ==
|
||||
alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB
|
||||
decorator:
|
||||
datasource:
|
||||
p6spy:
|
||||
|
||||
Reference in New Issue
Block a user