|  |  |  | 
|---|
|  |  |  | package com.matrix.system.shopXcx.api; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.matrix.biz.bean.BizUser; | 
|---|
|  |  |  | import com.matrix.biz.dao.BizUserDao; | 
|---|
|  |  |  | import com.matrix.biz.service.BizUserService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.matrix.core.tools.StringUtils; | 
|---|
|  |  |  | import com.matrix.core.web.BaseAction; | 
|---|
|  |  |  | import com.matrix.system.common.constance.AppConstance; | 
|---|
|  |  |  | import com.matrix.system.common.interceptor.HostInterceptor; | 
|---|
|  |  |  | import net.sf.json.JSONObject; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BizUserDao bizUserDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | WeChatApiTools weChatApiTools; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | AjaxResult res = new AjaxResult(); | 
|---|
|  |  |  | LogUtil.info("code:{}" + code); | 
|---|
|  |  |  | if (StringUtils.isNotBlank(code)) { | 
|---|
|  |  |  | String requrl = WeChatApiTools.getXcxLoginUrl(code); | 
|---|
|  |  |  | String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId()); | 
|---|
|  |  |  | String reslutData = HttpCurlUtil.sendGetHttp(requrl, null); | 
|---|
|  |  |  | JSONObject json = JSONObject.fromObject(reslutData); | 
|---|
|  |  |  | LogUtil.debug("微信登录获取到登录信息={}", json); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 新增用户 | 
|---|
|  |  |  | bizUser = new BizUser(); | 
|---|
|  |  |  | bizUser.setSessionKey(sessionKey); | 
|---|
|  |  |  | bizUser.setIsSales(BizUser.NOT_SALES); | 
|---|
|  |  |  | bizUser.setOpenId(openId); | 
|---|
|  |  |  | bizUser.setLastLoginTime(new Date()); | 
|---|
|  |  |  | bizUser.setUserType(AppConstance.USER_TYPE_CUSTOMER); | 
|---|
|  |  |  | bizUser.setCompanyId(HostInterceptor.getCompanyId()); | 
|---|
|  |  |  | bizUserService.add(bizUser); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|