776 lines
36 KiB
XML
776 lines
36 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.mhd.user.domain.userAggregate.repository.mapper.UserMapper">
|
|
|
|
<sql id="selectUserVo">
|
|
SELECT a.user_id,
|
|
a.top_organization_id,
|
|
a.organization_id,
|
|
a.role_id,
|
|
a.role_name,
|
|
a.user_phone,
|
|
a.user_name,
|
|
a.user_account,
|
|
COALESCE(CONCAT( a.user_name, ' ', a.user_phone, ' ', a.user_account)
|
|
,a.user_name, ' ', a.user_phone, ' ', a.user_account) AS userShowName,
|
|
a.user_member_code,
|
|
a.user_password,
|
|
a.user_salt,
|
|
a.organization_name,
|
|
a.user_pay_password,
|
|
a.user_idcard_number,
|
|
a.user_idcard_number_des,
|
|
a.user_idcard_date_from,
|
|
a.user_idcard_date_to,
|
|
a.user_idcard_long,
|
|
a.user_idcard_front_url,
|
|
a.user_idcard_back_url,
|
|
a.user_idcard_inhand_url,
|
|
a.avatar,
|
|
a.user_status,
|
|
a.user_email,
|
|
a.user_area_county_id,
|
|
a.user_area_name,
|
|
a.user_area_address,
|
|
a.user_wechat_account,
|
|
a.user_wechat_openid,
|
|
a.user_wechat_session_key,
|
|
a.password_wrong_times,
|
|
a.last_login_time,
|
|
a.last_login_ip,
|
|
a.app_openid,
|
|
a.user_client_id,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.create_by_name,
|
|
a.update_time,
|
|
a.update_by,
|
|
a.update_by_name,
|
|
a.del_flag,
|
|
a.user_remark,
|
|
a.user_auth_status,
|
|
a.user_status_remark,
|
|
a.user_status_time,
|
|
a.user_account_type,
|
|
a.user_birthday,
|
|
a.sex,
|
|
a.is_driver_bidding,
|
|
a.certification_authority,
|
|
a.account_id,
|
|
a.promo_code,
|
|
a.user_template_seal_status,
|
|
a.emergency_contact_name,
|
|
a.emergency_contact_phone,
|
|
a.business_type,
|
|
a.user_template_seal,
|
|
a.data_sources,
|
|
a.role_code,
|
|
a.department_id,
|
|
a.ding_user_id,
|
|
a.ding_dept_id,
|
|
a.validity_period_management,a.salesperson_nc_code,a.document_preparer_nc_code,
|
|
a.legal_representative,
|
|
a.unified_code,
|
|
a.registered_phone,
|
|
a.registered_address,
|
|
a.fax,
|
|
a.payment_bank,
|
|
a.payment_account,
|
|
a.invoice_title,
|
|
a.tax_number
|
|
FROM "USER" a
|
|
where a.del_flag = 1
|
|
</sql>
|
|
|
|
<select id="selectList" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
|
|
<include refid="common_where"></include>
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectUserShipperList" parameterType="com.mhd.common.core.domain.po.UserPo"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
SELECT
|
|
u.user_id AS userId,
|
|
u.user_member_code AS userMemberCode,
|
|
s.shipper_enterprise_name AS shipperEnterpriseName,
|
|
u.user_name AS userName,
|
|
u.user_phone AS userPhone,
|
|
u.user_idcard_number as userIdcardNumber,
|
|
u.top_organization_id AS topOrganizationId
|
|
FROM
|
|
user_shipper s
|
|
LEFT JOIN
|
|
"USER" u
|
|
ON u.user_id = s.user_id
|
|
<where>
|
|
<if test="topOrganizationId != null "> and u.top_organization_id = #{topOrganizationId}</if>
|
|
<if test="userMemberCode != null "> and u.user_member_code = #{userMemberCode}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectUserShipperListWaybill" parameterType="com.mhd.common.core.domain.po.UserPo"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
SELECT
|
|
u.user_id AS userId,
|
|
u.user_member_code AS userMemberCode,
|
|
s.shipper_enterprise_name AS shipperEnterpriseName,
|
|
u.user_name AS userName,
|
|
u.user_phone AS userPhone,
|
|
u.user_idcard_number as userIdcardNumber,
|
|
u.top_organization_id AS topOrganizationId
|
|
FROM
|
|
user_shipper s
|
|
LEFT JOIN
|
|
"USER" u
|
|
ON u.user_id = s.user_id and u.del_flag = 1
|
|
<where>
|
|
s.del_flag = 1 and s.shipper_fill = 3
|
|
<if test="topOrganizationId != null "> and u.top_organization_id = #{topOrganizationId}</if>
|
|
<if test="userMemberCode != null and userMemberCode !='' "> and u.user_member_code = #{userMemberCode}</if>
|
|
</where>
|
|
</select>
|
|
<!-- 根据一级组织ID和用户登录账号查询用户 -->
|
|
<select id="findByTopOrganizationIdAndUserAccount" parameterType="java.lang.Long"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
and a.user_account = #{userAccount}
|
|
<if test="roleCode != null and roleCode != ''">
|
|
and a.role_code = #{roleCode}
|
|
</if>
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id != #{userId}
|
|
</if>
|
|
limit 1
|
|
</select>
|
|
<!-- 根据用户钉钉userID查询用户 -->
|
|
<select id="getUserByDingUserId" parameterType="java.lang.String"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.ding_user_id = #{dingUserId}
|
|
limit 1
|
|
</select>
|
|
|
|
<!-- 根据一级组织ID和职务/角色权限字符role_code查询单个用户 -->
|
|
<select id="findAdminUserByOrganizationId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.organization_id = #{organizationId}
|
|
and a.role_code = #{roleCode}
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id != #{userId}
|
|
</if>
|
|
</select>
|
|
<select id="selectByUserId" parameterType="java.lang.Long" resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.user_id = #{value}
|
|
</select>
|
|
|
|
<select id="selectByUserName" parameterType="java.lang.String" resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.user_name = #{value}</select>
|
|
|
|
|
|
<!-- 根据用户手机号查询自己以外的用户 -->
|
|
<select id="findByTopOrganizationIdAndUserPhone"
|
|
parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id != #{userId}
|
|
</if>
|
|
and a.user_phone = #{userPhone}
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
<if test="roleCode != null and roleCode != ''">
|
|
and a.role_code = #{roleCode}
|
|
</if>
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id != #{userId}
|
|
</if>
|
|
limit 1
|
|
</select>
|
|
<!-- 根据用户身份证号查询自己以外的用户 -->
|
|
<select id="findByTopOrganizationIdAndIdCard"
|
|
parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO"
|
|
resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.user_idcard_number = #{userIdcardNumber}
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id != #{userId}
|
|
</if>
|
|
limit 1
|
|
</select>
|
|
|
|
<sql id="common_where">
|
|
<if test="createBy != null"> and a.create_by = #{createBy}</if>
|
|
<if test="userAccountType != null"> and a.user_account_type = #{userAccountType}</if>
|
|
<if test="userAccountTypeList != null">
|
|
and a.user_account_type in
|
|
<foreach item="userAccountType" collection="userAccountTypeList" open="(" separator="," close=")">
|
|
#{userAccountType}
|
|
</foreach>
|
|
</if>
|
|
<if test="createBy != null and organizationIdList == null">
|
|
and a.create_by = #{createBy}</if>
|
|
<if test="organizationIdList != null and createBy == null">
|
|
AND a.organization_id in
|
|
<foreach item="id" collection="organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="organizationIdList != null and createBy != null">
|
|
AND (a.organization_id in
|
|
<foreach item="id" collection="organizationIdList" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
OR a.create_by = #{createBy})
|
|
</if>
|
|
|
|
<if test="userIds !=null and userIds.size() > 0 ">
|
|
and a.user_id in
|
|
<foreach item="id" collection="userIds" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id = #{userId}
|
|
</if>
|
|
|
|
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
|
<if test="organizationId != null">
|
|
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
|
and a.organization_id = #{organizationId}
|
|
and a.organization_name IS NOT NULL
|
|
</if>
|
|
<if test="topOrganizationId != null">
|
|
<!-- 如果设置了 topOrganizationId,添加 top_organization_id 条件 -->
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
<if test="organizationId == null">
|
|
<!-- 如果没有设置 organizationId,添加 organization_name IS NOT NULL 条件 -->
|
|
and a.organization_name IS NOT NULL
|
|
</if>
|
|
</if>
|
|
/*组织名称*/
|
|
<if test="organizationName != null and organizationName != ''">
|
|
and a.organization_name like concat('%' , #{organizationName} , '%')
|
|
</if>
|
|
/*姓名、手机号*/
|
|
<if test="userInfo != null and userInfo != ''">
|
|
and (a.user_name like concat('%' , #{userInfo} , '%')
|
|
or a.user_phone like concat('%' , #{userInfo} , '%'))
|
|
</if>
|
|
/*姓名*/
|
|
<if test="userName != null and userName != ''">
|
|
and a.user_name like concat('%' , #{userName} , '%')
|
|
</if>
|
|
/*登录账号*/
|
|
<if test="userAccount != null and userAccount != ''">
|
|
and a.user_account like concat('%' , #{userAccount} , '%')
|
|
</if>
|
|
/*手机号*/
|
|
<if test="userPhone != null and userPhone != ''">
|
|
and a.user_phone like concat('%' , #{userPhone} , '%')
|
|
</if>
|
|
/*身份证号*/
|
|
<if test="userIdcardNumber != null and userIdcardNumber != ''">
|
|
and a.user_idcard_number like concat('%' , #{userIdcardNumber} , '%')
|
|
</if>
|
|
/*角色*/
|
|
<if test="roleCode != null and roleCode != ''">
|
|
and a.role_code like concat('%' , #{roleCode} , '%')
|
|
</if>
|
|
/*角色*/
|
|
<if test="roleName != null and roleName != ''">
|
|
and a.role_name like concat('%' , #{roleName} , '%')
|
|
</if>
|
|
/*实名认证状态*/
|
|
<if test="userAuthStatus != null and userAuthStatus != ''">
|
|
and a.user_auth_status = #{userAuthStatus}
|
|
</if>
|
|
/*身份证有效期*/
|
|
<if test="userIdcardDateFrom!=null and userIdcardDateTo!=null ">
|
|
and DATE_FORMAT(a.user_idcard_date_to,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userIdcardDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.user_idcard_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userIdcardDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*详细地址*/
|
|
<if test="userAreaAddressInfo != null and userAreaAddressInfo != ''">
|
|
and a.user_area_address like concat('%' , #{userAreaAddressInfo} , '%')
|
|
</if>
|
|
/*用户电子签章状态 0-无状态,1-已创建,2-未创建*/
|
|
<if test="userTemplateSealStatus != null and userTemplateSealStatus != '' and userTemplateSealStatus==1">
|
|
and a.user_template_seal is not null
|
|
and a.user_template_seal != ''
|
|
</if>
|
|
/*用户电子签章状态 0-无状态,1-已创建,2-未创建*/
|
|
<if test="userTemplateSealStatus != null and userTemplateSealStatus != '' and userTemplateSealStatus==2">
|
|
and (a.user_template_seal is null or a.user_template_seal = '')
|
|
</if>
|
|
/*用户三方支付账号状态 0-无状态,1-已创建,2-未创建*/
|
|
<if test="userPayAccountStatus != null and userPayAccountStatus != '' and userPayAccountStatus==1">
|
|
and a.user_pay_account is not null
|
|
and a.user_pay_account != ''
|
|
</if>
|
|
/*用户三方支付账号状态 0-无状态,1-已创建,2-未创建*/
|
|
<if test="userPayAccountStatus != null and userPayAccountStatus != '' and userPayAccountStatus==2">
|
|
and ( a.user_pay_account is null or a.user_pay_account ='')
|
|
</if>
|
|
/*用户三方支付账号*/
|
|
<if test="userPayAccount != null and userPayAccount != ''">
|
|
and a.user_pay_account like concat('%' , #{userPayAccount} , '%')
|
|
</if>
|
|
/*用户绑卡账号*/
|
|
<if test="userBankCardAccount != null and userBankCardAccount != ''">
|
|
and a.user_bankcard_account like concat('%' , #{userBankCardAccount} , '%')
|
|
</if>
|
|
|
|
/*用户绑卡状态:0-无状态,1-已绑卡,2-未绑卡*/
|
|
<if test="userBankCardStatus != null and userBankCardStatus != '' and userBankCardStatus==1">
|
|
and a.user_bankcard_account is not null
|
|
and a.user_bankcard_account != ''
|
|
</if>
|
|
/*用户绑卡状态:0-无状态,1-已绑卡,2-未绑卡*/
|
|
<if test="userBankCardStatus != null and userBankCardStatus != '' and userBankCardStatus==2">
|
|
and ( a.user_bankcard_account is null or a.user_bankcard_account= '')
|
|
</if>
|
|
|
|
/*用户状态:0-无状态,1-正常,2-锁定*/
|
|
<if test="userStatus != null and userStatus != ''">
|
|
and a.user_status = #{userStatus}
|
|
</if>
|
|
|
|
/*最近一次登录时间*/
|
|
<if test="lastLoginTimeFrom!=null and lastLoginTimeTo!=null ">
|
|
and DATE_FORMAT(a.last_login_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{lastLoginTimeFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.last_login_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{lastLoginTimeTo},'%Y-%m-%d')
|
|
</if>
|
|
|
|
/*添加人员*/
|
|
<if test="createByName != null and createByName != ''">
|
|
and a.create_by_name like concat('%' , #{createByName} , '%')
|
|
</if>
|
|
|
|
/*审核人员*/
|
|
<if test="userAuthByUsername != null and userAuthByUsername != ''">
|
|
and a.user_auth_by like concat('%' , #{userAuthByUsername} , '%')
|
|
</if>
|
|
/*审核人员*/
|
|
<if test="userAuthByUsername != null and userAuthByUsername != ''">
|
|
and a.user_auth_by_username like concat('%' , #{userAuthByUsername} , '%')
|
|
</if>
|
|
|
|
/*添加时间*/
|
|
<if test="createTime!=null and createTime!=null ">
|
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{createTime},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{createTime},'%Y-%m-%d')
|
|
</if>
|
|
/*添加时间*/
|
|
<if test="createTimeFrom!=null and createTimeTo!=null ">
|
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{createTimeFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.create_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{createTimeTo},'%Y-%m-%d')
|
|
</if>
|
|
/*审核时间*/
|
|
<if test="userAuthTimeFrom!=null and userAuthTimeTo!=null ">
|
|
and DATE_FORMAT(a.user_auth_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userAuthTimeFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(a.user_auth_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userAuthTimeTo},'%Y-%m-%d')
|
|
</if>
|
|
/* 身份证状态:用户身份证到期状态:0-无状态,1-正常,2-临期一个月,3-临期三个月,4-过期,5-长期 */
|
|
/* 正常: 直接赋值,查询当前时间小于过期时间的 */
|
|
<if test="userIdcardStatus == 1 ">
|
|
and DATE_FORMAT(#{userIdcardTime},'%Y-%m-%d') <![CDATA[<]]> DATE_FORMAT(a.user_idcard_date_to,'%Y-%m-%d')
|
|
</if>
|
|
/* 临期一个月:当前时间加一个月,查询该时间大于过期时间的 临期三个月:当前时间加三个月,查询该时间大于过期时间的*/
|
|
<if test="userIdcardStatus == 2 or userIdcardStatus == 3">
|
|
and DATE_FORMAT(#{userIdcardTimeAdd},'%Y-%m-%d') <![CDATA[>=]]> a.user_idcard_date_to
|
|
and DATE_FORMAT(#{userIdcardTime},'%Y-%m-%d') <![CDATA[<=]]> a.user_idcard_date_to
|
|
</if>
|
|
/* 过期:查询当前时间大于过期时间的*/
|
|
<if test="userIdcardStatus == 4 ">
|
|
and DATE_FORMAT(#{userIdcardTime},'%Y-%m-%d') <![CDATA[>]]> DATE_FORMAT(a.user_idcard_date_to,'%Y-%m-%d')
|
|
</if>
|
|
/* 长期:查询 user_idcard_long字段为1的*/
|
|
<if test="userIdcardStatus == 5 ">
|
|
and a.user_idcard_long = 1
|
|
</if>
|
|
/*用户编码*/
|
|
<if test="userMemberCode != null and userMemberCode != ''">
|
|
and a.user_member_code = #{userMemberCode}
|
|
</if>
|
|
/*详细地址*/
|
|
<if test="userAreaAddress != null and userAreaAddress != ''">
|
|
and a.user_area_address like concat('%' , #{userAreaAddress} , '%')
|
|
</if>
|
|
/*紧急联系人*/
|
|
<if test="emergencyContactName != null and emergencyContactName != ''">
|
|
and a.emergency_contact_name like concat('%' , #{emergencyContactName} , '%')
|
|
</if>
|
|
/*紧急联系人手机号*/
|
|
<if test="emergencyContactPhone != null and emergencyContactPhone != ''">
|
|
and a.emergency_contact_phone like concat('%' , #{emergencyContactPhone} , '%')
|
|
</if>
|
|
<if test="userAreaCountyId != null and userAreaCountyId != ''">
|
|
and a.user_area_county_id = #{userAreaCountyId}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="selectAppUserList" resultType="com.mhd.common.core.domain.po.app.UserAppPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO">
|
|
SELECT
|
|
a.user_id,
|
|
a.top_organization_id,
|
|
a.organization_id,
|
|
a.organization_name,
|
|
a.user_name,
|
|
a.user_phone,
|
|
a.user_account,
|
|
a.avatar
|
|
FROM
|
|
"USER" a
|
|
WHERE
|
|
a.del_flag = 1
|
|
<include refid="common_where1"></include>
|
|
</select>
|
|
|
|
<sql id="common_where1">
|
|
<if test="userDO.userPhone != null and userDO.userPhone != ''">
|
|
and (a.user_phone = #{userDO.userPhone} or a.user_account = #{userDO.userPhone})
|
|
</if>
|
|
<if test="userDO.topOrganizationId !=null">
|
|
and a.top_organization_id = #{userDO.topOrganizationId}
|
|
</if>
|
|
</sql>
|
|
|
|
<select id="getCaptainAuthInfoByUserId"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverCaptainAuthPo">
|
|
select u.user_id,
|
|
u.user_phone,
|
|
u.user_name,
|
|
u.user_account,
|
|
u.user_idcard_number,
|
|
u.user_idcard_date_from,
|
|
u.user_idcard_date_to,
|
|
u.user_idcard_long,
|
|
u.user_idcard_front_url,
|
|
u.user_idcard_back_url,
|
|
u.user_idcard_inhand_url,
|
|
u.avatar,
|
|
u.user_area_county_id,
|
|
u.user_area_name,
|
|
u.user_area_address,
|
|
u.user_birthday,
|
|
ude.driver_captain_fill
|
|
from user_driver_enterprise ude
|
|
left join "USER" u on ude.user_id = u.user_id and u.del_flag = 1
|
|
where ude.del_flag = 1
|
|
and ude.driver_type = 2
|
|
and u.user_id = #{userId}
|
|
</select>
|
|
|
|
<select id="getDocumentWarningList"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDocumentWarningQueryPo"
|
|
parameterType="com.mhd.user.interfaces.dto.queryDTO.UserDocumentWarningQueryDTO">
|
|
select u.user_id,
|
|
u.user_account,
|
|
u.user_name,
|
|
dvb.vehicle_license_plate_number,
|
|
(case
|
|
when instr(roleCode, 'driver') > 0 or instr(roleCode, 'carrier') > 0 or
|
|
instr(roleCode, 'captain') > 0
|
|
then 1 end) as type,
|
|
u.user_idcard_date_to,
|
|
u.user_idcard_long,
|
|
ude.driver_enterprise_license_date_to,
|
|
ude.driver_enterprise_license_long,
|
|
ude.driver_business_license_date_to,
|
|
ude.driver_business_license_long,
|
|
ud.driver_license_date_to,
|
|
ud.driver_license_long,
|
|
ud.driver_work_license_date_to,
|
|
ud.driver_work_license_long,
|
|
dvb.vehicle_checkout_period_validity,
|
|
dvb.business_license_expire_end_date,
|
|
dvb.business_license_long_status,
|
|
dvb.road_transport_certificate_expire_date,
|
|
dvb.road_transport_certificate_long_status,
|
|
(if(u.user_idcard_long = 1, 4,
|
|
(case
|
|
when datediff(u.user_idcard_date_to, NOW()) > 30 then 1
|
|
when datediff(u.user_idcard_date_to, NOW()) < 30
|
|
and datediff(u.user_idcard_date_to, NOW()) > 0 then 3
|
|
when datediff(u.user_idcard_date_to, NOW()) < 0 then 2
|
|
else 0
|
|
end))) as idCardExpStatus,
|
|
(if(ude.driver_enterprise_license_long = 1, 4,
|
|
(case
|
|
when datediff(ude.driver_enterprise_license_date_to, NOW()) > 30 then 1
|
|
when datediff(ude.driver_enterprise_license_date_to, NOW()) < 30
|
|
and datediff(ude.driver_enterprise_license_date_to, NOW()) > 0 then 3
|
|
when datediff(ude.driver_enterprise_license_date_to, NOW()) < 0 then 2
|
|
else 0
|
|
end))) as businessLicenseStatus,
|
|
(if(ud.driver_license_long = 1, 4,
|
|
(case
|
|
when datediff(ud.driver_license_date_to, NOW()) > 30 then 1
|
|
when datediff(ud.driver_license_date_to, NOW()) < 30
|
|
and datediff(ud.driver_license_date_to, NOW()) > 0 then 3
|
|
when datediff(ud.driver_license_date_to, NOW()) < 0 then 2
|
|
else 0
|
|
end))) as driverLicenseExpStatus,
|
|
(if(ud.driver_work_license_long = 1, 4,
|
|
(case
|
|
when datediff(ud.driver_work_license_date_to, NOW()) > 30 then 1
|
|
when datediff(ud.driver_work_license_date_to, NOW()) < 30
|
|
and datediff(ud.driver_work_license_date_to, NOW()) > 0 then 3
|
|
when datediff(ud.driver_work_license_date_to, NOW()) < 0 then 2
|
|
else 0
|
|
end))) as workCertificateExpStatus,
|
|
(if(dvb.business_license_long_status = 1, 4,
|
|
(case
|
|
when datediff(dvb.business_license_expire_end_date, NOW()) > 30 then 1
|
|
when datediff(dvb.business_license_expire_end_date, NOW()) < 30
|
|
and datediff(dvb.business_license_expire_end_date, NOW()) > 0 then 3
|
|
when datediff(dvb.business_license_expire_end_date, NOW()) < 0 then 2
|
|
else 0
|
|
end))) as businessLicenseExpStatus,
|
|
(if(dvb.road_transport_certificate_long_status = 1, 4,
|
|
(case
|
|
when datediff(dvb.road_transport_certificate_expire_date, NOW()) > 30 then 1
|
|
when datediff(dvb.road_transport_certificate_expire_date, NOW()) < 30
|
|
and datediff(dvb.road_transport_certificate_expire_date, NOW()) > 0 then 3
|
|
when datediff(dvb.road_transport_certificate_expire_date, NOW()) < 0 then 2
|
|
else 0
|
|
end))) as transportPermitExpStatus,
|
|
(case
|
|
when datediff(dvb.vehicle_checkout_period_validity, NOW()) > 30 then 1
|
|
when datediff(dvb.vehicle_checkout_period_validity, NOW()) < 30
|
|
and datediff(dvb.vehicle_checkout_period_validity, NOW()) > 0 then 3
|
|
when datediff(dvb.vehicle_checkout_period_validity, NOW()) < 0 then 2
|
|
else 0
|
|
end) as drivingPermitExpStatus
|
|
from "USER" u
|
|
left join user_driver ud on u.user_id = ud.user_id and ud.del_flag = 1
|
|
left join user_driver_enterprise ude on u.user_id = ude.user_id and ude.del_flag = 1 and ude.driver_type = 1
|
|
left join driver_vehicle_bind dvb
|
|
on u.user_id = dvb.driver_bind_id and dvb.del_flag = 1 and dvb.default_flag = 1
|
|
left join (select ur.user_id, group_concat(r.role_code) as roleCode
|
|
from role r
|
|
left join user_role ur on r.role_id = ur.role_id
|
|
<where>
|
|
r.del_flag = 1
|
|
and ur.del_flag = 1
|
|
<if test="userDocumentWarningQueryDTO.type != null and userDocumentWarningQueryDTO.type == 0">
|
|
and role_code in ('shipper','company')
|
|
</if>
|
|
<if test="userDocumentWarningQueryDTO.type != null and userDocumentWarningQueryDTO.type == 1">
|
|
and role_code in ('driver', 'carrier', 'captain')
|
|
</if>
|
|
<if test="userDocumentWarningQueryDTO.type == null">
|
|
and role_code in ('driver','carrier', 'captain','shipper','company')
|
|
</if>
|
|
</where>
|
|
group by ur.user_id) r on r.user_id = u.user_id
|
|
<where>
|
|
u.del_flag = 1
|
|
and r.roleCode is not null
|
|
<!-- 用户名称 -->
|
|
<if test=" userDocumentWarningQueryDTO.userName != null and userDocumentWarningQueryDTO.userName != ''">
|
|
and u.user_name LIKE CONCAT('%',#{ userDocumentWarningQueryDTO.userName},'%')
|
|
</if>
|
|
<!-- 用户账号 -->
|
|
<if test=" userDocumentWarningQueryDTO.userAccount != null and userDocumentWarningQueryDTO.userAccount != ''">
|
|
and u.user_account LIKE CONCAT('%',#{ userDocumentWarningQueryDTO.userAccount},'%')
|
|
</if>
|
|
<!-- 身份证临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'a'.toString()">
|
|
and (datediff(u.user_idcard_date_to, NOW()) < 30
|
|
and datediff(u.user_idcard_date_to, NOW()) > 0
|
|
and u.user_idcard_long != 1)
|
|
</if>
|
|
<!-- 身份证过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'h'.toString()">
|
|
and (datediff(u.user_idcard_date_to, NOW()) < 0
|
|
and u.user_idcard_long != 1)
|
|
</if>
|
|
<!-- 营业执照临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'b'.toString()">
|
|
and (datediff(ude.driver_enterprise_license_date_to, NOW()) < 30
|
|
and datediff(ude.driver_enterprise_license_date_to, NOW()) > 0
|
|
and ude.driver_enterprise_license_long != 1)
|
|
</if>
|
|
<!-- 营业执照过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'i'.toString()">
|
|
and (datediff(ude.driver_enterprise_license_date_to, NOW()) < 0
|
|
and ude.driver_enterprise_license_long != 1)
|
|
</if>
|
|
<!-- 驾驶证临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'c'.toString()">
|
|
and (datediff(ud.driver_license_date_to, NOW()) < 30
|
|
and datediff(ud.driver_license_date_to, NOW()) > 0
|
|
and ud.driver_license_long != 1)
|
|
</if>
|
|
<!-- 驾驶证过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'j'.toString()">
|
|
and (datediff(ud.driver_license_date_to, NOW()) < 0
|
|
and ud.driver_license_long != 1)
|
|
</if>
|
|
<!-- 从业资格证临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'd'.toString()">
|
|
and (datediff(ud.driver_work_license_date_to, NOW()) < 30
|
|
and datediff(ud.driver_work_license_date_to, NOW()) > 0
|
|
and ud.driver_work_license_long != 1)
|
|
</if>
|
|
<!-- 从业资格证过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'k'.toString()">
|
|
and (datediff(ud.driver_work_license_date_to, NOW()) < 0
|
|
and ud.driver_work_license_long != 1)
|
|
</if>
|
|
<!-- 行驶证临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'e'.toString()">
|
|
and (datediff(dvb.vehicle_checkout_period_validity, NOW()) < 30 and datediff(dvb.vehicle_checkout_period_validity, NOW()) > 0)
|
|
</if>
|
|
<!-- 行驶证过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'l'.toString()">
|
|
and datediff(dvb.vehicle_checkout_period_validity, NOW()) < 0
|
|
</if>
|
|
<!-- 道路运输许可证临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'f'.toString()">
|
|
and (datediff(dvb.road_transport_certificate_expire_date, NOW()) < 30
|
|
and datediff(dvb.road_transport_certificate_expire_date, NOW()) > 0
|
|
and dvb.road_transport_certificate_long_status != 1)
|
|
</if>
|
|
<!-- 道路运输许可证过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'm'.toString()">
|
|
and (datediff(dvb.road_transport_certificate_expire_date, NOW()) < 0
|
|
and dvb.road_transport_certificate_long_status != 1)
|
|
</if>
|
|
<!-- 道路运输经营许可证临期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'g'.toString()">
|
|
and (datediff(dvb.business_license_expire_end_date, NOW()) < 30
|
|
and datediff(dvb.business_license_expire_end_date, NOW()) > 0
|
|
and dvb.business_license_long_status != 1)
|
|
</if>
|
|
<!-- 道路运输经营许可证过期 -->
|
|
<if test=" userDocumentWarningQueryDTO.seach != null and userDocumentWarningQueryDTO.seach != '' and userDocumentWarningQueryDTO.seach == 'n'.toString()">
|
|
and (datediff(dvb.business_license_expire_end_date, NOW()) < 0
|
|
and dvb.business_license_long_status != 1)
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="findByPromoCode" resultType="com.mhd.common.core.domain.po.UserPo">
|
|
<include refid="selectUserVo"/>
|
|
and a.promo_code = #{promoCode}
|
|
<if test="userId !=null and userId !='' ">
|
|
and a.user_id != #{userId}
|
|
</if>
|
|
limit 1
|
|
</select>
|
|
<select id="getAllShipperByOrganization"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserShipperPo">
|
|
SELECT
|
|
u.user_id,
|
|
u.user_name,
|
|
us.shipper_enterprise_name,
|
|
us.shipper_type
|
|
FROM
|
|
"USER" u
|
|
LEFT JOIN user_shipper us ON u.user_id = us.user_id
|
|
WHERE
|
|
u.del_flag = 1
|
|
AND us.del_flag = 1
|
|
AND ((us.shipper_type = 1 AND us.shipper_fill = 3)
|
|
OR ( us.shipper_type = 2 AND us.shipper_enterprise_fill = 3 ))
|
|
AND top_organization_id = #{topOrganizationId}
|
|
</select>
|
|
|
|
<select id="getAllDriverByOrganization"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserDriverEnterprisePo">
|
|
SELECT
|
|
u.user_id,
|
|
u.user_name,
|
|
ude.driver_enterprise_name,
|
|
ude.driver_type
|
|
FROM
|
|
"USER" u
|
|
LEFT JOIN user_driver_enterprise ude ON u.user_id = ude.user_id
|
|
WHERE
|
|
u.del_flag = 1
|
|
AND ude.del_flag = 1
|
|
AND ((
|
|
ude.driver_type = 1
|
|
AND ude.driver_enterprise_fill = 3
|
|
)
|
|
OR ( ude.driver_type = 2 AND ude.driver_captain_fill = 3 ))
|
|
AND top_organization_id = #{topOrganizationId}
|
|
</select>
|
|
|
|
<select id="selectAppUserListByRoleCode" resultType="com.mhd.common.core.domain.po.app.UserAppPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserDO">
|
|
SELECT
|
|
a.user_id,
|
|
a.top_organization_id,
|
|
a.organization_id,
|
|
a.organization_name,
|
|
a.user_name,
|
|
a.user_phone,
|
|
a.user_account,
|
|
a.avatar
|
|
FROM
|
|
"USER" a
|
|
WHERE
|
|
a.del_flag = 1
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
and a.role_code = #{roleCode}
|
|
</select>
|
|
|
|
<select id="findAllShipperInfo" resultType="com.mhd.user.interfaces.vo.QueryAllShipperInfoVo">
|
|
SELECT u.user_id, u.user_name, u.user_area_address, u.user_area_county_id, u.user_area_name ,u.user_phone,u.has_default_address,b.shipper_id,b.shipper_enterprise_name,u.DOCUMENT_PREPARER_NC_CODE,b.CUSTOMER_NC_CODE,u.organization_id AS organizationId,u.top_organization_id AS topOrganizationId,
|
|
b.settlement_currency AS settlementCurrency
|
|
FROM "USER" u
|
|
LEFT JOIN user_shipper b ON u.user_id = b.user_id
|
|
left join (select user_id, LISTAGG(r.role_name, '&') WITHIN GROUP(ORDER BY r.role_name) AS roleName
|
|
from role r
|
|
left join user_role ur on r.role_id = ur.role_id and ur.del_flag = 1
|
|
where r.del_flag = 1
|
|
and role_code in ('shipper', 'company')
|
|
group by user_id) r on r.user_id = u.user_id
|
|
WHERE u.del_flag = 1
|
|
AND (b.del_flag = 1 OR b.del_flag IS NULL)
|
|
AND u.business_type IN (1,3)
|
|
<if test="userId !=null">
|
|
AND u.user_Id = #{userId}
|
|
</if>
|
|
/*组织ID - 数据隔离:南光组织(organizationId=2827)查询全部,其他组织查询自己组织的数据*/
|
|
<if test="organizationId !=null">
|
|
AND u.organization_id = #{organizationId}
|
|
AND u.organization_name IS NOT NULL
|
|
</if>
|
|
GROUP BY u.user_id, u.user_name, u.user_area_address, u.user_area_county_id, u.user_area_name, u.user_phone, u.has_default_address, b.shipper_id, b.shipper_enterprise_name, u.DOCUMENT_PREPARER_NC_CODE, b.CUSTOMER_NC_CODE, u.organization_id, u.top_organization_id, b.settlement_currency
|
|
</select>
|
|
<select id="finShipperEnterpriseNamedByUserId" resultType="string">
|
|
SELECT
|
|
user_shipper.shipper_enterprise_name
|
|
FROM
|
|
"USER" u
|
|
INNER JOIN
|
|
user_shipper ON u.user_id = user_shipper.user_id
|
|
WHERE
|
|
u.del_flag = 1
|
|
AND user_shipper.del_flag = 1
|
|
AND u.business_type IN (1, 3)
|
|
AND u.user_Id = #{userId}
|
|
</select>
|
|
</mapper> |