382 lines
15 KiB
XML
382 lines
15 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.UserShipperMapper">
|
|
|
|
<sql id="selectShipperVo">
|
|
SELECT a.shipper_id,
|
|
a.user_id,
|
|
a.parent_shipper_id,
|
|
a.shipper_type,
|
|
a.shipper_enterprise_name,
|
|
a.shipper_enterprise_social_credit_code,
|
|
a.shipper_enterprise_phone,
|
|
a.shipper_enterprise_address,
|
|
a.shipper_enterprise_license_date_from,
|
|
a.shipper_enterprise_license_date_to,
|
|
a.shipper_enterprise_taxpayer,
|
|
a.shipper_enterprise_license_long,
|
|
a.shipper_enterprise_license_front_url,
|
|
a.shipper_corp,
|
|
a.shipper_corp_name,
|
|
a.shipper_corp_legal_name,
|
|
a.shipper_corp_idcard_number,
|
|
a.shipper_corp_idcard_number_des,
|
|
a.shipper_corp_idcard_date_from,
|
|
a.shipper_corp_idcard_date_to,
|
|
a.shipper_corp_idcard_long,
|
|
a.shipper_corp_idcard_front_url,
|
|
a.shipper_corp_idcard_back_url,
|
|
a.shipper_corp_idcard_inhand_url,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.create_by_name,
|
|
a.update_time,
|
|
a.update_by,
|
|
a.update_by_name,
|
|
a.del_flag,
|
|
a.shipper_fill,
|
|
a.shipper_fill_time,
|
|
a.shipper_enterprise_fill,
|
|
a.shipper_enterprise_fill_time,
|
|
a.shipper_fill_remark,
|
|
a.shipper_enterprise_fill_remark,
|
|
b.user_phone,
|
|
b.user_name,
|
|
b.role_name,
|
|
b.organization_name,
|
|
b.user_account,
|
|
b.user_member_code,
|
|
b.user_idcard_number,
|
|
b.user_idcard_date_from,
|
|
b.user_idcard_date_to,
|
|
b.user_idcard_long,
|
|
b.user_idcard_front_url,
|
|
b.user_idcard_back_url,
|
|
b.user_idcard_inhand_url,
|
|
b.user_area_county_id,
|
|
b.user_area_name,
|
|
b.user_area_address,
|
|
b.user_remark,
|
|
b.avatar,
|
|
b.user_birthday,
|
|
a.company_account_id,
|
|
a.esign_auth_status,
|
|
a.esign_enterprise_status,
|
|
a.esign_seal_auth_id
|
|
FROM user_shipper a
|
|
LEFT JOIN "USER" b ON a.user_id = b.user_id
|
|
WHERE a.del_flag = 1
|
|
AND b.del_flag = 1
|
|
</sql>
|
|
<sql id="selectShipperVo1">
|
|
SELECT b.shipper_id,
|
|
a.user_id,
|
|
b.parent_shipper_id,
|
|
b.shipper_type,
|
|
b.shipper_enterprise_name,
|
|
b.shipper_enterprise_social_credit_code,
|
|
b.shipper_enterprise_phone,
|
|
b.shipper_enterprise_address,
|
|
b.shipper_enterprise_license_date_from,
|
|
b.shipper_enterprise_license_date_to,
|
|
b.shipper_enterprise_taxpayer,
|
|
b.shipper_enterprise_license_long,
|
|
b.shipper_enterprise_license_front_url,
|
|
b.shipper_corp,
|
|
b.shipper_corp_name,
|
|
b.shipper_corp_legal_name,
|
|
b.shipper_corp_idcard_number,
|
|
b.shipper_corp_idcard_number_des,
|
|
b.shipper_corp_idcard_date_from,
|
|
b.shipper_corp_idcard_date_to,
|
|
b.shipper_corp_idcard_long,
|
|
b.shipper_corp_idcard_front_url,
|
|
b.shipper_corp_idcard_back_url,
|
|
b.shipper_corp_idcard_inhand_url,
|
|
a.create_time,
|
|
a.create_by,
|
|
a.create_by_name,
|
|
a.update_time,
|
|
a.update_by,
|
|
a.update_by_name,
|
|
b.del_flag,
|
|
b.shipper_fill,
|
|
b.shipper_fill_time,
|
|
b.shipper_enterprise_fill,
|
|
b.shipper_enterprise_fill_time,
|
|
b.shipper_fill_remark,
|
|
b.shipper_enterprise_fill_remark,
|
|
b.shipper_fill_auth_id,
|
|
b.shipper_fill_auth_name,
|
|
b.shipper_enterprisel_auth_name,
|
|
b.shipper_enterprisel_auth_id,
|
|
a.user_phone,
|
|
a.user_name,
|
|
a.organization_name,
|
|
a.user_account,
|
|
a.user_member_code,
|
|
a.user_idcard_number,
|
|
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.user_area_county_id,
|
|
a.user_area_name,
|
|
a.user_area_address,
|
|
a.user_remark,
|
|
a.avatar,
|
|
a.user_birthday,
|
|
b.authorized_quota,
|
|
b.settlement_day,
|
|
b.remark,
|
|
b.authorized_used_amount,
|
|
r.roleName,
|
|
b.is_auto_audit_order,
|
|
b.monthly_settlement_flag,
|
|
a.user_auth_status,
|
|
b.original_receipt_flag,
|
|
b.freight_node,b.customer_nc_code
|
|
FROM "USER" a
|
|
LEFT JOIN user_shipper b ON a.user_id = b.user_id
|
|
left join (select user_id, LISTAGG(DISTINCT 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 = a.user_id
|
|
WHERE a.del_flag = 1
|
|
AND (b.del_flag = 1 OR b.del_flag IS NULL)
|
|
AND a.business_type IN (1,3)
|
|
</sql>
|
|
|
|
<select id="selectList" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserShipperDO"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserShipperPo">
|
|
<include refid="selectShipperVo1"/>
|
|
<include refid="common_where"></include>
|
|
GROUP BY a.user_id
|
|
ORDER BY a.create_time DESC
|
|
</select>
|
|
|
|
<select id="selectByUserId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserShipperPo">
|
|
<include refid="selectShipperVo"/>
|
|
and a.user_id = #{value}
|
|
|
|
</select>
|
|
|
|
<select id="findByShipperId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.repository.po.UserShipperPo">
|
|
<include refid="selectShipperVo"/>
|
|
and a.shipper_id = #{value}
|
|
|
|
</select>
|
|
|
|
<select id="findByUserId" parameterType="java.lang.Long"
|
|
resultType="com.mhd.user.domain.userAggregate.entity.UserShipperEntity">
|
|
<include refid="selectShipperVo"/>
|
|
and a.user_id = #{value}
|
|
|
|
</select>
|
|
|
|
<select id="userShipperAndRoleList" resultType="com.mhd.user.domain.userAggregate.repository.po.UserShipperPo" parameterType="com.mhd.user.domain.userAggregate.repository.todo.UserShipperDO">
|
|
SELECT
|
|
b.shipper_id,
|
|
a.user_id,
|
|
WM_CONCAT(r.role_code) AS roleCode,
|
|
b.shipper_fill,
|
|
b.shipper_enterprise_fill,
|
|
a.business_type
|
|
FROM
|
|
"USER" a
|
|
LEFT JOIN user_shipper b ON b.user_id = a.user_id
|
|
LEFT JOIN user_role ur ON b.user_id = ur.user_id
|
|
LEFT JOIN role r ON ur.role_id = r.role_id
|
|
AND r.del_flag = 1
|
|
WHERE
|
|
a.del_flag = 1
|
|
AND (b.del_flag = 1 OR b.del_flag IS NULL)
|
|
AND a.business_type IN (1,3)
|
|
<include refid="common_where"></include>
|
|
GROUP BY
|
|
a.user_id
|
|
ORDER BY
|
|
a.create_time DESC
|
|
</select>
|
|
|
|
|
|
<sql id="common_where">
|
|
<if test="userId !=null">
|
|
and a.user_Id = #{userId}
|
|
</if>
|
|
/*一级组织ID*/
|
|
<if test="topOrganizationId !=null">
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
</if>
|
|
<if test="parentShipperId !=null">
|
|
and b.parent_shipper_id = #{parentShipperId}
|
|
</if>
|
|
/*用户组织ID*/
|
|
<if test="organizationId !=null">
|
|
and a.organization_id = #{organizationId}
|
|
</if>
|
|
/*组织名称*/
|
|
<if test="organizationName != null and organizationName != ''">
|
|
and a.organization_name like concat('%' , #{organizationName} , '%')
|
|
</if>
|
|
/*姓名*/
|
|
<!-- <if test="userName != null and userName != ''">-->
|
|
<!-- and b.user_name like concat('%' , #{userName} , '%')-->
|
|
<!-- </if>-->
|
|
/*姓名/手机号/邮箱*/
|
|
<if test="userName != null and userName != ''">
|
|
AND concat( a.user_name, a.user_phone, a.user_email ) 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="roleName != null and roleName != ''">
|
|
and r.roleName like concat('%' , #{roleName} , '%')
|
|
</if>
|
|
/*实名认证状态*/
|
|
<if test="userAuthStatus != null and userAuthStatus != ''">
|
|
and a.user_auth_status = #{userAuthStatus}
|
|
</if>
|
|
/*托运人认证*/
|
|
<if test="shipperAuthStatus != null and shipperAuthStatus != ''">
|
|
and b.shipper_fill = #{shipperAuthStatus}
|
|
</if>
|
|
/*托运企业认证*/
|
|
<if test="shipperEnterpriseFill != null and shipperEnterpriseFill != ''">
|
|
and b.shipper_enterprise_fill = #{shipperEnterpriseFill}
|
|
</if>
|
|
/*身份证有效期*/
|
|
<if test="userIdcardDateFrom!=null and userIdcardDateTo!=null ">
|
|
and DATE_FORMAT(a.user_idcard_date_from,'%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="userAreaAddress != null and userAreaAddress != ''">
|
|
and a.user_area_address like concat('%' , #{userAreaAddress} , '%')
|
|
</if>
|
|
/*添加人员*/
|
|
<if test="createByName != null and createByName != ''">
|
|
and a.create_by_name like concat('%' , #{createByName} , '%')
|
|
</if>
|
|
/*审核人员*/
|
|
<if test="shipperAuthByUsername != null and shipperAuthByUsername != ''">
|
|
and b.shipper_fill_auth_name like concat('%' , #{shipperAuthByUsername} , '%')
|
|
</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(b.shipper_fill_time,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{userAuthTimeFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(b.shipper_fill_time,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{userAuthTimeTo},'%Y-%m-%d')
|
|
</if>
|
|
|
|
/*企业名称*/
|
|
<if test="shipperEnterpriseName != null and shipperEnterpriseName != ''">
|
|
and b.shipper_enterprise_name like concat('%' , #{shipperEnterpriseName} , '%')
|
|
</if>
|
|
/*企业统一社会信用代码*/
|
|
<if test="shipperEnterpriseSocialCreditCode != null and shipperEnterpriseSocialCreditCode != ''">
|
|
and b.shipper_enterprise_social_credit_code like concat('%' , #{shipperEnterpriseSocialCreditCode} , '%')
|
|
</if>
|
|
/*企业营业期限*/
|
|
<if test="shipperEnterpriseLicenseDateFrom!=null and shipperEnterpriseLicenseDateTo!=null ">
|
|
and DATE_FORMAT(b.shipper_enterprise_license_date_to,'%Y-%m-%d') <![CDATA[>=]]>
|
|
DATE_FORMAT(#{shipperEnterpriseLicenseDateFrom},'%Y-%m-%d')
|
|
and DATE_FORMAT(b.shipper_enterprise_license_date_to,'%Y-%m-%d') <![CDATA[<=]]>
|
|
DATE_FORMAT(#{shipperEnterpriseLicenseDateTo},'%Y-%m-%d')
|
|
</if>
|
|
/*添加人员*/
|
|
<if test="createBy != null and createBy != ''">
|
|
and b.create_by = #{createBy}
|
|
</if>
|
|
/* 组织ID集合 */
|
|
<if test="permissionOrganizationIds!=null and permissionOrganizationIds.size > 0">
|
|
AND a.organization_id IN
|
|
<foreach collection="permissionOrganizationIds" item="organizationId" index="index" open="(" separator=" , "
|
|
close=")">
|
|
#{organizationId}
|
|
</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>
|
|
</sql>
|
|
|
|
<select id="getShipperCountByMatter" parameterType="com.mhd.common.core.domain.todo.StatisticalMattersDo"
|
|
resultType = "java.lang.Integer">
|
|
select
|
|
sum(case when us.shipper_fill = 2 then 1 end)
|
|
+
|
|
sum(case when us.shipper_enterprise_fill = 2 then 1 end) as count
|
|
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
|
|
<if test="statisticalMattersDo.organizationId != null and statisticalMattersDo.organizationId != ''">
|
|
and u.organization_id = #{statisticalMattersDo.organizationId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getChooseShipper" resultType="com.mhd.user.domain.userAggregate.entity.UserShipperEntity" parameterType="java.util.List">
|
|
select
|
|
*
|
|
from user_shipper
|
|
where del_flag = 1
|
|
AND user_id in
|
|
<foreach item="userId" collection="userIdList" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectBySealId" resultType="com.mhd.user.domain.userAggregate.entity.UserShipperEntity" parameterType="com.mhd.user.domain.userAggregate.entity.UserShipperEntity">
|
|
select
|
|
*
|
|
from user_shipper
|
|
where del_flag = 1
|
|
and esign_seal_auth_id = #{userShipperEntity.esignSealAuthId}
|
|
and esign_enterprise_status = #{userShipperEntity.esignEnterpriseStatus}
|
|
</select>
|
|
|
|
</mapper>
|