|
@ -3,6 +3,10 @@ package com.epmet.service.impl; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.nacos.client.config.utils.IOUtils; |
|
|
import com.alibaba.nacos.client.config.utils.IOUtils; |
|
|
|
|
|
import com.dingtalk.api.DefaultDingTalkClient; |
|
|
|
|
|
import com.dingtalk.api.DingTalkClient; |
|
|
|
|
|
import com.dingtalk.api.request.OapiRobotSendRequest; |
|
|
|
|
|
import com.dingtalk.api.response.OapiRobotSendResponse; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
@ -12,6 +16,7 @@ import com.epmet.constant.ModuleConstant; |
|
|
import com.epmet.constant.ThirdRedisKeyConstant; |
|
|
import com.epmet.constant.ThirdRedisKeyConstant; |
|
|
import com.epmet.constant.ThirdRunTimeInfoConstant; |
|
|
import com.epmet.constant.ThirdRunTimeInfoConstant; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dao.*; |
|
|
|
|
|
import com.epmet.dto.CustomerMpDTO; |
|
|
import com.epmet.dto.PaCustomerUserAgencyDTO; |
|
|
import com.epmet.dto.PaCustomerUserAgencyDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
@ -21,6 +26,7 @@ import com.epmet.mpaes.WXXmlToMapUtil; |
|
|
import com.epmet.redis.RedisThird; |
|
|
import com.epmet.redis.RedisThird; |
|
|
import com.epmet.service.ComponentVerifyTicketService; |
|
|
import com.epmet.service.ComponentVerifyTicketService; |
|
|
import com.epmet.wxapi.constant.WxMaCodeConstant; |
|
|
import com.epmet.wxapi.constant.WxMaCodeConstant; |
|
|
|
|
|
import com.taobao.api.ApiException; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
@ -34,6 +40,7 @@ import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
|
|
|
|
import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN; |
|
|
import static com.epmet.constant.ModuleConstant.COMPONENT_ACCESS_TOKEN; |
|
|
import static com.epmet.constant.ThirdRunTimeInfoConstant.*; |
|
|
import static com.epmet.constant.ThirdRunTimeInfoConstant.*; |
|
@ -88,6 +95,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
private PaUserDao paUserDao; |
|
|
private PaUserDao paUserDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private PaCustomerServiceImpl paCustomerServiceImpl; |
|
|
private PaCustomerServiceImpl paCustomerServiceImpl; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PaCustomerDao paCustomerDao; |
|
|
|
|
|
|
|
|
@Value("${third.platform.appId}") |
|
|
@Value("${third.platform.appId}") |
|
|
private String componentAppId; |
|
|
private String componentAppId; |
|
@ -448,6 +457,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
authCodeDao.updateAppId(customerId,clientType,authAppId); |
|
|
authCodeDao.updateAppId(customerId,clientType,authAppId); |
|
|
// 4. 保存授权方账户信息
|
|
|
// 4. 保存授权方账户信息
|
|
|
this.saveAuthAccountInfo(customerId,authAppId,clientType); |
|
|
this.saveAuthAccountInfo(customerId,authAppId,clientType); |
|
|
|
|
|
// 5. 校验客户居民端、工作端小程序是否全部授权,全部授权完成的推送钉钉消息 sun
|
|
|
|
|
|
this.checkAuthorization(customerId); |
|
|
log.info("回调结束"); |
|
|
log.info("回调结束"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -689,4 +700,54 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe |
|
|
date.setTime(aLong); |
|
|
date.setTime(aLong); |
|
|
return date; |
|
|
return date; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @author sun |
|
|
|
|
|
* @Description 校验客户两哥小程序是否完成授权 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void checkAuthorization(String customerId){ |
|
|
|
|
|
List<CustomerMpDTO> list = customerMpDao.selectByCustomerId(customerId); |
|
|
|
|
|
AtomicBoolean bl = new AtomicBoolean(false); |
|
|
|
|
|
list.forEach(mp->{ |
|
|
|
|
|
if(mp.getAuthorizationFlag()!=NumConstant.ONE){ |
|
|
|
|
|
bl.set(true); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
if(!bl.get()){ |
|
|
|
|
|
dDingNews(customerId); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @author sun |
|
|
|
|
|
* @Description 发送钉钉消息,通知运营人员有新客户完成授权 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String dDingNews(String customerId) { |
|
|
|
|
|
//1.查询客户及管理员信息,用于发送消息使用
|
|
|
|
|
|
CustomerAndUserResultDTO result = paCustomerDao.selectCustomerAndUser(customerId); |
|
|
|
|
|
if (null == result || null == result.getCustomerId()) { |
|
|
|
|
|
log.error("授权完成发送钉钉消息失败,原因:未查询到客户信息,客户Id->" + customerId); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
//2.拼接钉钉消息内容并发送
|
|
|
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=b4e47783ad72ba643278598ff8af90e745890c13538b2a4dc139635a71289dfd"); |
|
|
|
|
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
|
|
|
|
|
request.setMsgtype("markdown"); |
|
|
|
|
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
|
|
|
|
|
markdown.setTitle("授权客户信息"); |
|
|
|
|
|
//"新客户通知"几个字是设置机器人时自定义的关键字,要保持代码与机器人设置的一致
|
|
|
|
|
|
markdown.setText("新客户通知: \n" + |
|
|
|
|
|
"> 客户名称: " + result.getCustomerName() + "\n\n" + |
|
|
|
|
|
"> 管理员称谓: " + result.getAppellation() + "\n\n" + |
|
|
|
|
|
"> 联系方式: " + result.getPhone() + "\n"); |
|
|
|
|
|
request.setMarkdown(markdown); |
|
|
|
|
|
try { |
|
|
|
|
|
OapiRobotSendResponse response = client.execute(request); |
|
|
|
|
|
} catch (ApiException e) { |
|
|
|
|
|
log.error("机器人生病了......"); |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|