| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.base.smo.front.AbstractFrontServiceSMO; |
| | | import com.java110.api.properties.WechatAuthProperties; |
| | | import com.java110.api.smo.DefaultAbstractComponentSMO; |
| | | import com.java110.api.smo.staff.IStaffAuthSMO; |
| | | import com.java110.core.context.IPageData; |
| | | import com.java110.core.context.PageData; |
| | | import com.java110.core.factory.WechatFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.owner.OwnerAppUserDto; |
| | | import com.java110.dto.smallWeChat.SmallWeChatDto; |
| | | import com.java110.api.properties.WechatAuthProperties; |
| | | import com.java110.api.smo.staff.IStaffAuthSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.ServiceConstant; |
| | | import com.java110.utils.constant.WechatConstant; |
| | | import com.java110.utils.exception.SMOException; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | |
| | | * wx登录 |
| | | */ |
| | | @Service("staffAuthSMOImpl") |
| | | public class StaffAuthSMOImpl extends AbstractFrontServiceSMO implements IStaffAuthSMO { |
| | | public class StaffAuthSMOImpl extends DefaultAbstractComponentSMO implements IStaffAuthSMO { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(StaffAuthSMOImpl.class); |
| | | |
| | |
| | | |
| | | ResponseEntity<String> paramOut = outRestTemplate.getForEntity(url, String.class); |
| | | |
| | | logger.debug("调用微信换去openId ", paramOut); |
| | | logger.debug("调用微信换去openId {}", paramOut); |
| | | if (paramOut.getStatusCode() != HttpStatus.OK) { |
| | | return ResultVo.redirectPage("/"); |
| | | |
| | |
| | | |
| | | paramOut = outRestTemplate.getForEntity(url, String.class); |
| | | |
| | | logger.debug("调用微信换去openId ", paramOut); |
| | | logger.debug("调用微信换去openId {}", paramOut); |
| | | if (paramOut.getStatusCode() != HttpStatus.OK) { |
| | | return ResultVo.redirectPage("/"); |
| | | } |
| | |
| | | paramAuth.put("openName", paramObj.getString("nickname")); |
| | | |
| | | ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, paramAuth.toJSONString(), |
| | | ServiceConstant.SERVICE_API_URL + "/api/staff/updateStaffAppAuth", HttpMethod.POST); |
| | | url = MappingCache.getValue("OWNER_WECHAT_URL"); |
| | | "/staff/updateStaffAppAuth", HttpMethod.POST); |
| | | url = MappingCache.getValue(MappingConstant.URL_DOMAIN,"OWNER_WECHAT_URL"); |
| | | if(url.contains("/#/")){ |
| | | if(url.contains("?")){ |
| | | url += ("&wAppId="+smallWeChatDto.getAppId()); |
| | | }else{ |
| | | url += ("?wAppId="+smallWeChatDto.getAppId()); |
| | | } |
| | | }else{ |
| | | url += ("/#/?wAppId="+smallWeChatDto.getAppId()); |
| | | } |
| | | return ResultVo.redirectPage(url); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | String openUrl = ""; |
| | | String url = MappingCache.getValue("OWNER_WECHAT_URL"); |
| | | String url = MappingCache.getValue(MappingConstant.URL_DOMAIN,"OWNER_WECHAT_URL"); |
| | | url = url |
| | | + "/app/loginStaffWechatAuth?appId=992020061452450002&staffId=" |
| | | + staffId + "&storeId=" + storeId + "&wId=" + WechatFactory.getWId(smallWeChatDto.getAppId()) |
| | | + "&communityId=" + communityId; |
| | | |
| | | if (url.contains("?")) { |
| | | url += ("&wAppId=" + smallWeChatDto.getAppId()); |
| | | } else { |
| | | url += ("?wAppId=" + smallWeChatDto.getAppId()); |
| | | } |
| | | try { |
| | | openUrl = WechatConstant.OPEN_AUTH |
| | | .replace("APPID", smallWeChatDto.getAppId()) |
| | |
| | | .replace( |
| | | "REDIRECT_URL", |
| | | URLEncoder |
| | | .encode( |
| | | (url |
| | | + "/app/loginStaffWechatAuth?appId=992020061452450002&staffId=" |
| | | + staffId + "&storeId=" + storeId + "&wId=" + WechatFactory.getWId(smallWeChatDto.getAppId())) |
| | | + "&communityId=" + communityId, |
| | | .encode(url, |
| | | "UTF-8")).replace("STATE", "1"); |
| | | response.sendRedirect(openUrl); |
| | | } catch (Exception e) { |
| | |
| | | "", "", "", "", |
| | | pd.getAppId()); |
| | | responseEntity = this.callCenterService(restTemplate, pd, "", |
| | | ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?communityId=" |
| | | "smallWeChat.listSmallWeChats?communityId=" |
| | | + paramIn.getString("communityId") + "&page=1&row=1&weChatType=" + SmallWeChatDto.WECHAT_TYPE_PUBLIC, HttpMethod.GET); |
| | | |
| | | if (responseEntity.getStatusCode() != HttpStatus.OK) { |