| @@ -248,6 +248,11 @@ public interface TtOpenMaService extends TtMaService { | |||||
| */ | */ | ||||
| String APIQUERY_SHOP_MATERIAL = "https://open.microapp.bytedance.com/openapi/v1//microapp/operation/poi/query_shop_material"; | String APIQUERY_SHOP_MATERIAL = "https://open.microapp.bytedance.com/openapi/v1//microapp/operation/poi/query_shop_material"; | ||||
| /** | |||||
| * 获取客服链接 | |||||
| */ | |||||
| String CUSTOMER_SERVICE_URL = "https://developer.toutiao.com/api/apps/customer_service/url"; | |||||
| /** | /** | ||||
| * 获得小程序的域名配置信息 | * 获得小程序的域名配置信息 | ||||
| @@ -505,6 +510,8 @@ public interface TtOpenMaService extends TtMaService { | |||||
| String queryShopMeaterial(String supplierExtId)throws WxErrorException ; | String queryShopMeaterial(String supplierExtId)throws WxErrorException ; | ||||
| String queryCustomerServiceUrl(String openid, String type)throws WxErrorException ; | |||||
| // /** | // /** | ||||
| // * 小程序用户隐私保护指引服务 | // * 小程序用户隐私保护指引服务 | ||||
| // * | // * | ||||
| @@ -325,7 +325,7 @@ public class TtOpenComponentServiceImpl implements TtOpenComponentService { | |||||
| log.info("获取authorizerAccessToken-----------------"+responseContent); | log.info("获取authorizerAccessToken-----------------"+responseContent); | ||||
| TtOpenAuthorizationInfo queryAuth = TtOpenGsonBuilder.create().fromJson(responseContent, TtOpenAuthorizationInfo.class); | TtOpenAuthorizationInfo queryAuth = TtOpenGsonBuilder.create().fromJson(responseContent, TtOpenAuthorizationInfo.class); | ||||
| log.info("获取authorizerAccessToken-----------------"+queryAuth.getAuthorizerAccessToken()); | |||||
| log.info("获取authorizerAccessToken-----------------"+TtOpenGsonBuilder.create().toJson(queryAuth)); | |||||
| if (queryAuth.getAuthorizerAccessToken() != null) { | if (queryAuth.getAuthorizerAccessToken() != null) { | ||||
| config.updateAuthorizerAccessToken(queryAuth.getAuthorizerAppid(), | config.updateAuthorizerAccessToken(queryAuth.getAuthorizerAppid(), | ||||
| queryAuth.getAuthorizerAccessToken(), queryAuth.getExpiresIn()); | queryAuth.getAuthorizerAccessToken(), queryAuth.getExpiresIn()); | ||||
| @@ -710,6 +710,16 @@ public class TtOpenMaServiceImpl extends TtMaServiceImpl implements TtOpenMaServ | |||||
| return response; | return response; | ||||
| } | } | ||||
| @Override | |||||
| public String queryCustomerServiceUrl(String openid, String type) throws WxErrorException { | |||||
| String uri = CUSTOMER_SERVICE_URL + "?appid=" + ttOpenComponentService.getWxOpenConfigStorage().getComponentAppId() | |||||
| +"&openid="+openid | |||||
| +"&type="+type | |||||
| +"&scene=1"; | |||||
| String response = ttOpenComponentService.getByAppAccessToken(appId, uri, "access_token"); | |||||
| return response; | |||||
| } | |||||
| /** | /** | ||||
| * 将字符串对象转化为GsonArray对象 | * 将字符串对象转化为GsonArray对象 | ||||
| @@ -307,4 +307,37 @@ public class TtMerchantPoiController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("获取客服链接") | |||||
| @PostMapping("/query_customer_service_url") | |||||
| public ResultData queryCustomerServiceUrl(@RequestBody Map<String, String> param) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::queryCustomerServiceUrl"); | |||||
| String appid = param.get("appid"); | |||||
| String openid = param.get("openid"); | |||||
| if(StringUtils.isBlank(appid) || StringUtils.isBlank(openid)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| String type = param.get("type"); | |||||
| if(StringUtils.isBlank(type)){//来源,抖音传 1128,抖音极速版传 2329 | |||||
| type = "1128"; | |||||
| } | |||||
| if(!type.equals("1128") && !type.equals("2329")){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| } | |||||
| WxAppinfo appinfo = appinfoService.getByAppId(appid); | |||||
| if(appinfo == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"找不到小程序信息"); | |||||
| } | |||||
| try{ | |||||
| TtOpenMaService openMaService = openService.getTtOpenComponentService().getTtMaServiceByAppid(appid); | |||||
| String res = openMaService.queryCustomerServiceUrl(openid,type); | |||||
| return new ResultData(res); | |||||
| }catch(Exception e){ | |||||
| logger.error("获取客服链接 error"+ e.getMessage()); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"获取客服链接失败"); | |||||
| } | |||||
| } | |||||
| } | } | ||||