| @@ -20,6 +20,9 @@ public class WxCUserCar extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId") | @io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId") | ||||
| private Long cUserId; | private Long cUserId; | ||||
| @TableField(exist = false) | |||||
| private List<Long> userIds; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String userPhone; | private String userPhone; | ||||
| @@ -18,5 +18,4 @@ public interface WxCUserCarMapper extends CommonMapper<WxCUserCar, Long> { | |||||
| List<Map<String, Object>> queryCarCountHistory(HashMap<String,Object> params); | List<Map<String, Object>> queryCarCountHistory(HashMap<String,Object> params); | ||||
| List<WxCUserCar> findList1(WxCUserCar record); | |||||
| } | } | ||||
| @@ -15,6 +15,7 @@ import com.iformall.enums.EnumScoreType; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| public interface WxCUserBasicInfoService { | public interface WxCUserBasicInfoService { | ||||
| /** | /** | ||||
| @@ -45,6 +46,8 @@ public interface WxCUserBasicInfoService { | |||||
| PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); | PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); | ||||
| List<WxCUserBasicInfo> listPhoneAndNameByIds(WxCUserBasicInfo record); | List<WxCUserBasicInfo> listPhoneAndNameByIds(WxCUserBasicInfo record); | ||||
| Map<Long,WxCUserBasicInfo> getUserMap(TenantEntity tenantEntity, List<Long> cUserIdList); | |||||
| /** | /** | ||||
| * 根据实体查询列表 | * 根据实体查询列表 | ||||
| * @param record | * @param record | ||||
| @@ -594,6 +594,24 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||||
| public List<WxCUserBasicInfo> listPhoneAndNameByIds(WxCUserBasicInfo record) { | public List<WxCUserBasicInfo> listPhoneAndNameByIds(WxCUserBasicInfo record) { | ||||
| return wxCUserBasicInfoMapper.findListPhoneAndNameByIds(record); | return wxCUserBasicInfoMapper.findListPhoneAndNameByIds(record); | ||||
| } | } | ||||
| @Override | |||||
| public Map<Long,WxCUserBasicInfo> getUserMap(TenantEntity tenantEntity,List<Long> cUserIdList) { | |||||
| Map<Long,WxCUserBasicInfo> userMap = new HashMap<Long,WxCUserBasicInfo>(); | |||||
| if (cUserIdList.size() > 0) { | |||||
| WxCUserBasicInfo cUserBasicInfoQ = new WxCUserBasicInfo(); | |||||
| cUserBasicInfoQ.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||||
| cUserBasicInfoQ.setIds(cUserIdList); | |||||
| List<WxCUserBasicInfo> userList = wxCUserBasicInfoMapper.findListPhoneAndNameByIds(cUserBasicInfoQ); | |||||
| if (null != userList) { | |||||
| for (int i = 0 ; i < userList.size() ; i ++) { | |||||
| WxCUserBasicInfo cbi = userList.get(i); | |||||
| userMap.put(cbi.getId(), cbi); | |||||
| } | |||||
| } | |||||
| } | |||||
| return userMap; | |||||
| } | |||||
| @Override | @Override | ||||
| public List<WxCUserBasicInfo> findByPhone(TenantEntity tenantEntity, String phone) { | public List<WxCUserBasicInfo> findByPhone(TenantEntity tenantEntity, String phone) { | ||||
| @@ -5,28 +5,75 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.WxCUserCar; | import com.iformall.domain.po.WxCUserCar; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | |||||
| import com.iformall.mapper.WxCUserCarMapper; | import com.iformall.mapper.WxCUserCarMapper; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | |||||
| import com.iformall.service.WxCUserCarService; | import com.iformall.service.WxCUserCarService; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxCUserCarServiceImpl implements WxCUserCarService { | public class WxCUserCarServiceImpl implements WxCUserCarService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| WxCUserCarMapper wxCUserCarMapper; | WxCUserCarMapper wxCUserCarMapper; | ||||
| @Autowired | |||||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||||
| @Autowired | |||||
| WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| private void handlerUserParam(WxCUserCar record){ | |||||
| if(StringUtils.isNotBlank(record.getUserPhone())){ | |||||
| WxCUserBasicInfo biq = new WxCUserBasicInfo(); | |||||
| biq.setFinalTenantId(record.getFinalTenantId()); | |||||
| biq.setPhone(record.getUserPhone()); | |||||
| List<Long> idList = wxCUserBasicInfoMapper.findIdList(biq); | |||||
| if(idList == null && idList.isEmpty()){ | |||||
| record.setId(-999L); | |||||
| }else{ | |||||
| record.setUserIds(idList); | |||||
| } | |||||
| } | |||||
| } | |||||
| private void handlerResult(TenantEntity tenantEntity,List<WxCUserCar> userCarList){ | |||||
| if(userCarList == null || userCarList.isEmpty()){ | |||||
| return; | |||||
| } | |||||
| List<Long> userIds = userCarList.stream().map(uc -> uc.getCUserId()).collect(Collectors.toList()); | |||||
| Map<Long, WxCUserBasicInfo> userMap = wxCUserBasicInfoService.getUserMap(tenantEntity, userIds); | |||||
| for (WxCUserCar uc:userCarList) { | |||||
| WxCUserBasicInfo basicInfo = userMap.get(uc.getCUserId()); | |||||
| if(basicInfo != null){ | |||||
| uc.setUserPhone(basicInfo.getPhone()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | @Override | ||||
| public PageInfo<WxCUserCar> listAsPage(WxCUserCar record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCUserCar> listAsPage(WxCUserCar record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserCarMapper.findList1(record)); | |||||
| handlerUserParam(record); | |||||
| if(record.getId() != null && record.getId().equals(-999L)){ | |||||
| return new PageInfo<>(); | |||||
| } | |||||
| PageInfo<WxCUserCar> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserCarMapper.findList(record)); | |||||
| handlerResult(record,pageInfo.getList()); | |||||
| return pageInfo; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -23,13 +23,11 @@ | |||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where wcuc.`tenant_id` = #{tenantId} | |||||
| <if test=" null != id "> | <if test=" null != id "> | ||||
| and wcuc.`id` = #{id} | and wcuc.`id` = #{id} | ||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and wcuc.`tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and wcuc.`parent_tenant_id` = #{parentTenantId} | and wcuc.`parent_tenant_id` = #{parentTenantId} | ||||
| </if> | </if> | ||||
| @@ -66,35 +64,26 @@ | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | |||||
| <!-- <if test=" null != sortColumns"> order by ${sortColumns} </if>--> | |||||
| </if> | |||||
| <if test=" null != userIds "> | |||||
| and wcuc.c_user_id in | |||||
| <foreach collection="userIds" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <!-- <if test=" null != sortColumns"> order by ${sortColumns} </if>--> | |||||
| order by wcuc.create_date | order by wcuc.create_date | ||||
| </sql> | </sql> | ||||
| <select id="findList1" parameterType="com.iformall.domain.po.WxCUserCar" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/>,wcubi.`phone` | |||||
| from wx_c_user_car wcuc | |||||
| left join wx_c_user_basic_info wcubi on wcubi.id = wcuc.c_user_id | |||||
| where 1 = 1 | |||||
| <if test=" null != userPhone"> | |||||
| and wcubi.`phone` like concat('%', #{userPhone},'%') | |||||
| </if> | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserCar" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.iformall.domain.po.WxCUserCar" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| <include refid="allColumns"/> | <include refid="allColumns"/> | ||||
| from wx_c_user_car wcuc | from wx_c_user_car wcuc | ||||
| where 1 = 1 | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="countList" parameterType="com.iformall.domain.po.WxCUserCar" resultType="java.lang.Integer"> | <select id="countList" parameterType="com.iformall.domain.po.WxCUserCar" resultType="java.lang.Integer"> | ||||
| select count(1) from wx_c_user_car wcuc | select count(1) from wx_c_user_car wcuc | ||||
| where 1 = 1 | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||