提交 99dc93fc 编写于 作者: peijun.zhao's avatar peijun.zhao

add batch 获取微信用户信息

上级 1b476dc9
流水线 #30252 已失败 于阶段
in 0 second
......@@ -3,6 +3,8 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountWeChatInfoEntity;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface AccountWeChatInfoMapper {
......@@ -25,5 +27,7 @@ public interface AccountWeChatInfoMapper {
int updateByPrimaryKey(AccountWeChatInfoEntity record);
List<AccountWeChatInfoEntity> selectBatchByUnionId(List<String> list);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.DoctorEntity;
import com.pica.cloud.account.account.server.entity.PICAPDoctor;
import com.pica.cloud.account.account.server.model.WechatInfoDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
......@@ -114,4 +115,7 @@ public interface DoctorMapper {
String getUnionIdByDoctorId(@Param("doctorId") Integer doctorId);
List<WechatInfoDto> getBatchUnionIdByDoctorId(List<Integer> list);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.model;
public class WechatInfoDto {
private Integer doctorId;
private String unionId;
private String openId;
public Integer getDoctorId() {
return doctorId;
}
public void setDoctorId(Integer doctorId) {
this.doctorId = doctorId;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId;
}
}
......@@ -3,15 +3,20 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountWeChatInfoEntity;
import com.pica.cloud.account.account.server.mapper.AccountWeChatInfoMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.model.WechatInfoDto;
import com.pica.cloud.account.account.server.service.WechatService;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.StringUtil;
import io.swagger.models.auth.In;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
......@@ -35,20 +40,32 @@ public class WechatServiceImpl implements WechatService {
@Override
public Map<Integer, String> getAccountWechatInfoBatch(List<Integer> docIds) {
Map<Integer, String> rtnMap = new HashMap<>();
for(Integer i : docIds){
String openId = "";
String unionId = doctorMapper.getUnionIdByDoctorId(i);
if(StringUtil.isEmpty(unionId)){
rtnMap.put(i,"");
}else {
AccountWeChatInfoEntity rs = weChatInfoMapper.selectByUnionId(unionId);
if(null != rs){
openId = rs.getOpenid();
if(CollectionUtils.isEmpty(docIds)){
return null;
}
Map<Integer, String> doctorOpenMap = new HashMap<>();
List<WechatInfoDto> wechatInfoDtos = doctorMapper.getBatchUnionIdByDoctorId(docIds);
Map<String, Integer> unionMap = new HashMap<>();
for(WechatInfoDto dto : wechatInfoDtos){
unionMap.put(dto.getUnionId(),dto.getDoctorId());
}
List<String> unionIds = wechatInfoDtos.stream().map(obj -> obj.getUnionId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(unionIds)){
List<AccountWeChatInfoEntity> wechatList = weChatInfoMapper.selectBatchByUnionId(unionIds);
for(AccountWeChatInfoEntity entity : wechatList){
if(unionMap.containsKey(entity.getUnionid())){
doctorOpenMap.put(unionMap.get(entity.getUnionid()),entity.getOpenid());
}
rtnMap.put(i,openId);
}
}
return rtnMap;
for(Integer docId : docIds){
if(!doctorOpenMap.containsKey(docId)){
doctorOpenMap.put(docId,null);
}
}
return doctorOpenMap;
}
}
......@@ -48,6 +48,18 @@
limit 1
</select>
<select id="selectBatchByUnionId" resultMap="BaseResultMap" parameterType="java.util.List">
select
<include refid="Base_Column_List"/>
from account_wechat_info
where unionid in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
and delete_flag = 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from account_wechat_info
where id = #{id,jdbcType=INTEGER}
......
......@@ -1071,5 +1071,17 @@
and d.delete_flag = 1 and a.delete_flag = 1 and u.delete_flag = 1
</select>
<select id="getBatchUnionIdByDoctorId" resultType="com.pica.cloud.account.account.server.model.WechatInfoDto" parameterType="java.util.List">
select u.union_id as unionId, d.id as doctorId from p_doctor d
join account_info a on d.acct_id = a.id
join account_union u on a.id = u.acct_id
-- where d.id = #{doctorId}
where d.id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
and u.union_type = 1
and d.delete_flag = 1 and a.delete_flag = 1 and u.delete_flag = 1
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册