From bb13e3bd3577573e55391e4a670b4c80ca3680a0 Mon Sep 17 00:00:00 2001 From: wangh <9483> Date: Fri, 26 Jan 2024 10:48:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81openId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fuyou/service/impl/FyPayServiceImpl.java | 2 +- .../impl/ChainStoreInfoServiceImpl.java | 2 ++ .../service/impl/LJUserServiceImpl.java | 6 ++++ .../service/impl/MemberServiceImpl.java | 19 ++++++++-- .../controller/ClientSignController.java | 36 +++++++++++++++++++ gasStation-uni/pages/index/index.vue | 29 +++++++++++++-- gasStation-uni/pages/refuel/refuel.vue | 26 ++++++++++++-- gasStation-uni/pagesLogin/login/login.vue | 1 - 8 files changed, 112 insertions(+), 9 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java index b5c2952a1..78553bebe 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java @@ -453,7 +453,7 @@ public class FyPayServiceImpl implements FyPayService { String rspXml = Message.responseMsg(reqBody,Const.fuiou_32_url); //响应报文验签 Map resMap = Utils.xmlStr2Map(rspXml); - + log.info("--FyPayServiceImpl--:{}",resMap); String str = resMap.get("sign"); if (Utils.verifySign(resMap, str)){ System.out.println(resMap); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/store/service/impl/ChainStoreInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/store/service/impl/ChainStoreInfoServiceImpl.java index 94a15e636..0a3d562a5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/store/service/impl/ChainStoreInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/store/service/impl/ChainStoreInfoServiceImpl.java @@ -80,6 +80,8 @@ public class ChainStoreInfoServiceImpl extends ServiceImpl impleme return row; } + // @Override + // public int updateUserById(LJUser user) { + // return baseMapper.updateById(user); + // + // } + @Override public LJUser selectUserByMobileAndUserId(String mobile, Integer userId) { QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java index c9ab82f5f..b13867010 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java @@ -9,6 +9,7 @@ import com.fuint.business.store.entity.MtStore; import com.fuint.business.store.service.StoreService; import com.fuint.business.storeInformation.entity.LJStore; import com.fuint.business.storeInformation.service.ILJStoreService; +import com.fuint.business.userManager.entity.LJUser; import com.fuint.business.userManager.entity.LJUserGrade; import com.fuint.business.userManager.entity.MtInvitation; import com.fuint.business.userManager.entity.UserBalance; @@ -40,6 +41,7 @@ import com.fuint.repository.model.*; import com.fuint.utils.StringUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -61,6 +63,7 @@ import java.util.*; * CopyRight https://www.fuint.cn */ @Service +@Slf4j public class MemberServiceImpl extends ServiceImpl implements MemberService { @Resource @@ -754,9 +757,10 @@ public class MemberServiceImpl extends ServiceImpl impleme String mobile = StringUtil.isNotEmpty(userInfo.getString("phone")) ? userInfo.getString("phone") : ""; String source = StringUtil.isNotEmpty(userInfo.getString("source")) ? userInfo.getString("source") : MemberSourceEnum.WECHAT_LOGIN.getKey(); - - // 根绝手机号查询是否有该用户 没有则新建 有就更新 + log.info("--MemberServiceImpl:登陆时open_id--{}",openId); if (ObjectUtil.isNotEmpty(mobile) || "".equals(mobile)) { + // 根绝手机号查询是否有该用户 没有则新建 有就更新 + MtUser mtUserMobile = queryMemberByMobile2(mobile); MtUser mtUser = new MtUser(); @@ -798,7 +802,16 @@ public class MemberServiceImpl extends ServiceImpl impleme // 修改 mtUserMobile.setOpenId(openId); - updateById(mtUserMobile); +// ljUserService.updateById() + LJUser ljUser = new LJUser(); + BeanUtils.copyProperties(mtUserMobile,ljUser); + +// boolean b = ljUserService.updateById(ljUser); + + + int i = baseMapper.updateById(mtUserMobile); + + // 新增余额信息 if (ObjectUtil.isNotEmpty(storeId) && storeId !="") { createVaseInfo(mtUserMobile,storeId,staffId,inviterId); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSignController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSignController.java index 5b9a75166..b6881d8e8 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSignController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/module/clientApi/controller/ClientSignController.java @@ -6,7 +6,9 @@ import com.fuint.business.store.service.StoreService; import com.fuint.business.storeInformation.entity.LJStore; import com.fuint.business.storeInformation.service.ILJStoreService; import com.fuint.business.userManager.entity.ChainStoreConfig; +import com.fuint.business.userManager.entity.LJUser; import com.fuint.business.userManager.service.ChainStoreConfigService; +import com.fuint.business.userManager.service.LJUserService; import com.fuint.common.dto.AccountInfo; import com.fuint.common.dto.TokenDto; import com.fuint.common.dto.UserInfo; @@ -98,6 +100,9 @@ public class ClientSignController extends BaseController { @Resource ILJStoreService iljStoreService; + @Resource + LJUserService ljUserService; + /** * 连锁店配置信息 */ @@ -168,6 +173,37 @@ public class ClientSignController extends BaseController { } + + + + + + @ApiOperation(value = "微信授权登录(小程序)") + @RequestMapping(value = "/mpWxLogin2", method = RequestMethod.POST) + @ResponseBody + @CrossOrigin + public ResponseObject mpWxLogin2(HttpServletRequest request, @RequestBody Map param) throws BusinessCheckException { + + // 获取code信息 + JSONObject loginInfo = weixinService.getWxProfile2(param.get("code").toString()); + logger.info("--loginInfo{}--",loginInfo.toString()); + + if (ObjectUtil.isEmpty(loginInfo) && ObjectUtil.isEmpty(loginInfo.get("openid")) ) { + return getSuccessResult(true); + } + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + if (ObjectUtil.isEmpty(nowAccountInfo)) return getSuccessResult(true); + + LJUser ljUser = ljUserService.queryUserByUserId(nowAccountInfo.getId()); + if (ObjectUtil.isEmpty(ljUser.getOpenId())) return getSuccessResult(false); + + if (!loginInfo.get("openid").equals(ljUser.getOpenId())) { + return getSuccessResult(false); + } + + return getSuccessResult(true); + } + /** * 微信授权登录(公众号) * */ diff --git a/gasStation-uni/pages/index/index.vue b/gasStation-uni/pages/index/index.vue index dd013c029..51bd8e826 100644 --- a/gasStation-uni/pages/index/index.vue +++ b/gasStation-uni/pages/index/index.vue @@ -380,12 +380,12 @@ }) }, // 判断token是否与当前连锁店id相同 - getTheJudgmentIsTheSame() { + async getTheJudgmentIsTheSame() { // 判断是否登录 if (!this.AppToken) { return; } - request({ + await request({ url: 'chainStoreInfo/theJudgmentIsTheSame', method: 'get', data: { @@ -396,6 +396,31 @@ uni.removeStorageSync("App-Token"); } }) + + + // 判断当前登录的code是否相同 + wx.login({ + success(res) { + if (res.code) { + //发起网络请求 + request({ + url: 'clientApi/sign/mpWxLogin2', + method: "POST", + data: { + code: res.code + } + }).then(res => { + if (!res.data) { + uni.removeStorageSync("App-Token"); + } + }) + } else { + console.log('登录失败!' + res.errMsg) + } + } + }) + + }, // 获取门店信息 diff --git a/gasStation-uni/pages/refuel/refuel.vue b/gasStation-uni/pages/refuel/refuel.vue index 1468c40e4..f922206c1 100644 --- a/gasStation-uni/pages/refuel/refuel.vue +++ b/gasStation-uni/pages/refuel/refuel.vue @@ -490,12 +490,12 @@ // console.log(this.value); }, // 判断token是否与当前连锁店id相同 - getTheJudgmentIsTheSame() { + async getTheJudgmentIsTheSame() { // 判断是否登录 if (!this.AppToken) { return; } - request({ + await request({ url: 'chainStoreInfo/theJudgmentIsTheSame', method: 'get', data: { @@ -506,6 +506,28 @@ uni.removeStorageSync("App-Token"); } }) + + // 判断当前登录的code是否相同 + wx.login({ + success(res) { + if (res.code) { + //发起网络请求 + request({ + url: 'clientApi/sign/mpWxLogin2', + method: "POST", + data: { + code: res.code + } + }).then(res => { + if (!res.data) { + uni.removeStorageSync("App-Token"); + } + }) + } else { + console.log('登录失败!' + res.errMsg) + } + } + }) }, // 退格键被点击 backspace() { diff --git a/gasStation-uni/pagesLogin/login/login.vue b/gasStation-uni/pagesLogin/login/login.vue index 26b87d9cc..ff88e892f 100644 --- a/gasStation-uni/pagesLogin/login/login.vue +++ b/gasStation-uni/pagesLogin/login/login.vue @@ -44,7 +44,6 @@ }, onLoad() { console.log(this.$baseUrl); - }, components: {}, methods: {