java110
2022-01-11 7e5ed0e7b50567342946eb3e9dfaf5a213b0e7a9
service-api/src/main/java/com/java110/api/smo/login/impl/OwnerAppLoginSMOImpl.java
@@ -10,8 +10,10 @@
import com.java110.core.factory.AuthenticationFactory;
import com.java110.core.factory.WechatFactory;
import com.java110.dto.owner.OwnerAppUserDto;
import com.java110.dto.ownerCarOpenUser.OwnerCarOpenUserDto;
import com.java110.dto.smallWeChat.SmallWeChatDto;
import com.java110.dto.user.UserDto;
import com.java110.intf.user.IOwnerCarOpenUserV1InnerServiceSMO;
import com.java110.utils.cache.CommonCache;
import com.java110.utils.constant.CommonConstant;
import com.java110.utils.constant.ResponseConstant;
@@ -61,6 +63,9 @@
    @Autowired
    private WechatAuthProperties wechatAuthProperties;
    @Autowired
    private IOwnerCarOpenUserV1InnerServiceSMO ownerCarOpenUserV1InnerServiceSMOImpl;
    @Override
    public ResponseEntity<String> doLogin(IPageData pd) throws SMOException {
@@ -381,11 +386,7 @@
    @Override
    public ResponseEntity<String> refreshOpenId(IPageData pd, String redirectUrl, String wAppId, HttpServletRequest request, HttpServletResponse response) {
        //分配urlCode
        String urlCode = UUID.randomUUID().toString();
        JSONObject param = new JSONObject();
        param.put("redirectUrl", redirectUrl);
        CommonCache.setValue(urlCode, param.toJSONString(), expireTime);
        SmallWeChatDto smallWeChatDto = null;
        if (!StringUtil.isEmpty(wAppId)) {
            JSONObject paramIn = new JSONObject();
@@ -398,7 +399,17 @@
            smallWeChatDto.setAppSecret(wechatAuthProperties.getWechatAppSecret());
            smallWeChatDto.setMchId(wechatAuthProperties.getMchId());
            smallWeChatDto.setPayPassword(wechatAuthProperties.getKey());
            wAppId = wechatAuthProperties.getWechatAppId();
        }
        //分配urlCode
        String urlCode = UUID.randomUUID().toString();
        JSONObject param = new JSONObject();
        if (redirectUrl.indexOf("appId") < 0) {
            redirectUrl += ("&appId=" + smallWeChatDto.getAppId());
        }
        param.put("redirectUrl", redirectUrl);
        CommonCache.setValue(urlCode, param.toJSONString(), expireTime);
        URL url = null;
        String openUrl = "";
@@ -474,6 +485,15 @@
        String openId = paramObj.getString("openid");
        redirectUrl = redirectUrl + "&openId=" + openId;
        //查询是否有车牌号
        OwnerCarOpenUserDto ownerCarOpenUserDto = new OwnerCarOpenUserDto();
        ownerCarOpenUserDto.setOpenId(openId);
        List<OwnerCarOpenUserDto> ownerCarOpenUserDtos = ownerCarOpenUserV1InnerServiceSMOImpl.queryOwnerCarOpenUsers(ownerCarOpenUserDto);
        if (ownerCarOpenUserDtos != null && ownerCarOpenUserDtos.size() > 0) {
            redirectUrl += ("&carNum=" + ownerCarOpenUserDtos.get(0).getCarNum());
        }
        //redirectUrl = redirectUrl + (redirectUrl.indexOf("?") > 0 ? "&key=" + tmpUserDto.getKey() : "?key=" + tmpUserDto.getKey());
        return ResultVo.redirectPage(redirectUrl);
    }