300 lines
16 KiB
XML
300 lines
16 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.ruoyi.system.mapper.SysDeptMapper">
|
|
|
|
<resultMap type="SysDept" id="SysDeptResult">
|
|
<id property="deptId" column="dept_id" />
|
|
<result property="parentId" column="parent_id" />
|
|
<result property="ancestors" column="ancestors" />
|
|
<result property="deptName" column="dept_name" />
|
|
<result property="orderNum" column="order_num" />
|
|
<result property="leader" column="leader" />
|
|
<result property="phone" column="phone" />
|
|
<result property="email" column="email" />
|
|
<result property="status" column="status" />
|
|
<result property="delFlag" column="" />
|
|
<result property="parentName" column="parent_name" />
|
|
<result property="platformServiceFee" column="platform_service_fee" />
|
|
<result property="handlingCharge" column="handling_charge" />
|
|
<!-- <result property="isProfitSharing" column="is_profit_sharing" />-->
|
|
<result property="separateAccount" column="separate_account" />
|
|
<result property="isUsePlatformApp" column="is_use_platform_app" />
|
|
<result property="domain" column="domain" />
|
|
<result property="appid" column="appid" />
|
|
<result property="appName" column="app_name" />
|
|
<result property="balance" column="balance" />
|
|
<result property="appSecret" column="app_secret" />
|
|
<result property="merchantId" column="merchant_id" />
|
|
<result property="apiV3Key" column="api_v3_key" />
|
|
<result property="notifyUrl" column="notify_url" />
|
|
<result property="privateKeyPath" column="private_key_path" />
|
|
<result property="merchantSerialNumber" column="merchant_serial_number" />
|
|
<result property="refundNotifyUrl" column="refund_notify_url" />
|
|
<result property="appUserId" column="app_user_id" />
|
|
<result property="handlingChargeType" column="handling_charge_type" />
|
|
<result property="withdrawHandlingCharge" column="withdraw_handling_charge" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="collectionCode" column="collection_code" />
|
|
</resultMap>
|
|
|
|
<sql id="selectDeptVo">
|
|
select d.dept_id, d.parent_id, d.ancestors, d.dept_name,
|
|
d.order_num, d.leader, d.phone, d.email, d.status,
|
|
d.del_flag,d.platform_service_fee, d.handling_charge, d.is_profit_sharing, d.separate_account, d.domain, d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret,
|
|
d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url, d.app_user_id, d.handling_charge_type,withdraw_handling_charge,
|
|
d.create_by, d.create_time,d.collection_code
|
|
from sys_dept d
|
|
</sql>
|
|
|
|
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
|
SELECT d.dept_id, d.parent_id, d.ancestors, d.dept_name,
|
|
d.order_num, d.leader, d.phone, d.email, d.status,
|
|
d.del_flag, d.platform_service_fee, d.handling_charge, d.is_profit_sharing, d.separate_account, d.domain, d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret,
|
|
d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path, d.merchant_serial_number, d.refund_notify_url, d.app_user_id,d.handling_charge_type,withdraw_handling_charge,
|
|
u.user_name AS userName,
|
|
GROUP_CONCAT(oa.area_name SEPARATOR ' | ') AS areaName,
|
|
d.create_by, d.create_time,d.collection_code
|
|
FROM sys_dept d
|
|
LEFT JOIN et_user u ON d.app_user_id = u.user_id
|
|
LEFT JOIN et_area_dept ad ON ad.dept_id = d.dept_id
|
|
LEFT JOIN et_operating_area oa ON oa.area_id = ad.area_id
|
|
WHERE d.del_flag = '0' AND d.parent_id != 0
|
|
<if test="deptId != null and deptId != 0">
|
|
AND d.dept_id = #{deptId}
|
|
</if>
|
|
<if test="parentId != null and parentId != 0">
|
|
AND d.parent_id = #{parentId}
|
|
</if>
|
|
<if test="deptName != null and deptName != ''">
|
|
AND d.dept_name LIKE CONCAT('%', #{deptName}, '%')
|
|
</if>
|
|
<if test="areaName != null and areaName != ''">
|
|
AND oa.area_name LIKE CONCAT('%', #{areaName}, '%')
|
|
</if>
|
|
<if test="userName != null and userName != ''">
|
|
AND u.user_name LIKE CONCAT('%', #{userName}, '%')
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
AND d.status = #{status}
|
|
</if>
|
|
<!-- 数据范围过滤 -->
|
|
${params.dataScope}
|
|
GROUP BY d.dept_id
|
|
ORDER BY d.dept_name
|
|
</select>
|
|
|
|
<select id="selectDeptListByRoleId" resultType="Long">
|
|
select d.dept_id
|
|
from sys_dept d
|
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
|
where rd.role_id = #{roleId}
|
|
<if test="deptCheckStrictly">
|
|
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
|
</if>
|
|
order by d.parent_id, d.order_num
|
|
</select>
|
|
|
|
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
|
|
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.platform_service_fee, d.handling_charge,
|
|
d.is_profit_sharing,d.domain,d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret,d.balance,d.separate_account,
|
|
d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url,d.app_user_id,d.handling_charge_type,withdraw_handling_charge,d.collection_code,
|
|
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
|
from sys_dept d
|
|
where d.dept_id = #{deptId}
|
|
</select>
|
|
|
|
<select id="selectDeptByAppUserId" parameterType="Long" resultMap="SysDeptResult">
|
|
select d.dept_id, d.parent_id, d.app_user_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.platform_service_fee, d.handling_charge,
|
|
d.is_profit_sharing,d.domain,d.is_use_platform_app, d.appid, d.app_name, d.balance, d.app_secret,d.balance,d.separate_account,
|
|
d.merchant_id, d.api_v3_key, d.notify_url, d.private_key_path,d.merchant_serial_number,d.refund_notify_url,d.app_user_id,d.handling_charge_type,withdraw_handling_charge,d.collection_code,
|
|
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
|
from sys_dept d
|
|
where d.app_user_id = #{appUserId}
|
|
</select>
|
|
|
|
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
|
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
|
|
</select>
|
|
|
|
<select id="checkDeptExistArea" parameterType="Long" resultType="int">
|
|
select count(1) from et_operating_area a
|
|
LEFT JOIN et_area_dept ad ON ad.area_id = a.area_id
|
|
LEFT JOIN sys_dept d ON d.dept_id = ad.dept_id
|
|
where d.dept_id = #{deptId}
|
|
</select>
|
|
|
|
<select id="checkDeptExistFeeRule" parameterType="Long" resultType="int">
|
|
select count(1) from et_fee_rule where dept_id = #{deptId} and is_deleted = 0
|
|
</select>
|
|
|
|
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
|
|
select count(1) from sys_dept
|
|
where del_flag = '0' and parent_id = #{deptId} limit 1
|
|
</select>
|
|
|
|
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
|
|
select * from sys_dept where find_in_set(#{deptId}, ancestors)
|
|
</select>
|
|
|
|
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
|
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
|
|
</select>
|
|
|
|
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
|
<include refid="selectDeptVo"/>
|
|
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
|
</select>
|
|
|
|
<select id="selectEtOperatingAreaBySerialNumber" resultMap="SysDeptResult">
|
|
<include refid="selectDeptVo"/>
|
|
where wechatpay_serial = #{wechatpaySerial}
|
|
</select>
|
|
|
|
<insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
|
|
insert into sys_dept(
|
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
|
<if test="deptName != null and deptName != ''">dept_name,</if>
|
|
<if test="ancestors != null and ancestors != ''">ancestors,</if>
|
|
<if test="orderNum != null">order_num,</if>
|
|
<if test="leader != null and leader != ''">leader,</if>
|
|
<if test="phone != null and phone != ''">phone,</if>
|
|
<if test="email != null and email != ''">email,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
<if test="platformServiceFee != null and platformServiceFee != ''">platform_service_fee,</if>
|
|
<if test="handlingCharge != null and handlingCharge != ''">handling_charge,</if>
|
|
<!-- <if test="isProfitSharing != null and isProfitSharing != ''">is_profit_sharing,</if>-->
|
|
<if test="separateAccount != null and separateAccount != ''">separate_account,</if>
|
|
<if test="isUsePlatformApp != null and isUsePlatformApp != ''">is_use_platform_app,</if>
|
|
<if test="domain != null and domain != ''">domain,</if>
|
|
<if test="appid != null and appid != ''">appid,</if>
|
|
<if test="appName != null and appName != ''">app_name,</if>
|
|
<if test="appSecret != null and appSecret != ''">app_secret,</if>
|
|
<if test="merchantId != null and merchantId != ''">merchant_id,</if>
|
|
<if test="apiV3Key != null and apiV3Key != ''">api_v3_key,</if>
|
|
<if test="notifyUrl != null and notifyUrl != ''">notify_url,</if>
|
|
<if test="privateKeyPath != null and privateKeyPath != ''">private_key_path,</if>
|
|
<if test="merchantSerialNumber != null and merchantSerialNumber != ''">merchant_serial_number,</if>
|
|
<if test="refundNotifyUrl != null and refundNotifyUrl != ''">refund_notify_url,</if>
|
|
<if test="appUserId != null and appUserId != ''">app_user_id,</if>
|
|
<if test="handlingChargeType != null and handlingChargeType != ''">handling_charge_type,</if>
|
|
<if test="withdrawHandlingCharge != null and withdrawHandlingCharge != ''">withdraw_handling_charge,</if>
|
|
<if test="collectionCode != null and collectionCode != ''">collection_code,</if>
|
|
create_time
|
|
)values(
|
|
<if test="deptId != null and deptId != 0">#{deptId},</if>
|
|
<if test="parentId != null and parentId != 0">#{parentId},</if>
|
|
<if test="deptName != null and deptName != ''">#{deptName},</if>
|
|
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
|
<if test="orderNum != null">#{orderNum},</if>
|
|
<if test="leader != null and leader != ''">#{leader},</if>
|
|
<if test="phone != null and phone != ''">#{phone},</if>
|
|
<if test="email != null and email != ''">#{email},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
<if test="platformServiceFee != null and platformServiceFee != ''">#{platformServiceFee},</if>
|
|
<if test="handlingCharge != null and handlingCharge != ''">#{handlingCharge},</if>
|
|
<!-- <if test="isProfitSharing != null and isProfitSharing != ''">#{isProfitSharing},</if>-->
|
|
<if test="separateAccount != null and separateAccount != ''">#{separateAccount},</if>
|
|
<if test="isUsePlatformApp != null and isUsePlatformApp != ''">#{isUsePlatformApp},</if>
|
|
<if test="domain != null and domain != ''">#{domain},</if>
|
|
<if test="appid != null and appid != ''">#{appid},</if>
|
|
<if test="appName != null and appName != ''">#{appName},</if>
|
|
<if test="appSecret != null and appSecret != ''">#{appSecret},</if>
|
|
<if test="merchantId != null and merchantId != ''">#{merchantId},</if>
|
|
<if test="apiV3Key != null and apiV3Key != ''">#{apiV3Key},</if>
|
|
<if test="notifyUrl != null and notifyUrl != ''">#{notifyUrl},</if>
|
|
<if test="privateKeyPath != null and privateKeyPath != ''">#{privateKeyPath},</if>
|
|
<if test="merchantSerialNumber != null and merchantSerialNumber != ''">#{merchantSerialNumber},</if>
|
|
<if test="refundNotifyUrl != null and refundNotifyUrl != ''">#{refundNotifyUrl},</if>
|
|
<if test="appUserId != null and appUserId != ''">#{appUserId},</if>
|
|
<if test="handlingChargeType != null and handlingChargeType != ''">#{handlingChargeType},</if>
|
|
<if test="withdrawHandlingCharge != null and withdrawHandlingCharge != ''">#{withdrawHandlingCharge},</if>
|
|
<if test="collectionCode != null and collectionCode != ''">#{collectionCode},</if>
|
|
sysdate()
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateDept" parameterType="SysDept">
|
|
update sys_dept
|
|
<set>
|
|
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
|
|
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
|
|
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
|
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
|
<if test="leader != null">leader = #{leader},</if>
|
|
<if test="phone != null">phone = #{phone},</if>
|
|
<if test="email != null">email = #{email},</if>
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
<if test="platformServiceFee != null and platformServiceFee != ''">platform_service_fee = #{platformServiceFee},</if>
|
|
<if test="handlingCharge != null and handlingCharge != ''">handling_charge = #{handlingCharge},</if>
|
|
<!-- <if test="isProfitSharing != null and isProfitSharing != ''">is_profit_sharing = #{isProfitSharing},</if>-->
|
|
<if test="separateAccount != null and separateAccount != ''">separate_account = #{separateAccount},</if>
|
|
<if test="isUsePlatformApp != null and isUsePlatformApp != ''">is_use_platform_app = #{isUsePlatformApp},</if>
|
|
<if test="domain != null and domain != ''">domain = #{domain},</if>
|
|
<if test="appid != null and appid != ''">appid = #{appid},</if>
|
|
<if test="appName != null and appName != ''">app_name = #{appName},</if>
|
|
<if test="appSecret != null and appSecret != ''">app_secret = #{appSecret},</if>
|
|
<if test="merchantId != null and merchantId != ''">merchant_id = #{merchantId},</if>
|
|
<if test="apiV3Key != null and apiV3Key != ''">api_v3_key = #{apiV3Key},</if>
|
|
<if test="notifyUrl != null and notifyUrl != ''">notify_url = #{notifyUrl},</if>
|
|
<if test="privateKeyPath != null and privateKeyPath != ''">private_key_path = #{privateKeyPath},</if>
|
|
<if test="merchantSerialNumber != null and merchantSerialNumber != ''">merchant_serial_number = #{merchantSerialNumber},</if>
|
|
<if test="refundNotifyUrl != null and refundNotifyUrl != ''">refund_notify_url = #{refundNotifyUrl},</if>
|
|
<if test="appUserId != null">app_user_id = #{appUserId},</if>
|
|
<if test="handlingChargeType != null">handling_charge_type = #{handlingChargeType},</if>
|
|
<if test="withdrawHandlingCharge != null">withdraw_handling_charge = #{withdrawHandlingCharge},</if>
|
|
<if test="collectionCode != null">collection_code = #{collectionCode},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
where dept_id = #{deptId}
|
|
</update>
|
|
|
|
<update id="updateDeptChildren" parameterType="java.util.List">
|
|
update sys_dept set ancestors =
|
|
<foreach collection="depts" item="item" index="index"
|
|
separator=" " open="case dept_id" close="end">
|
|
when #{item.deptId} then #{item.ancestors}
|
|
</foreach>
|
|
where dept_id in
|
|
<foreach collection="depts" item="item" index="index"
|
|
separator="," open="(" close=")">
|
|
#{item.deptId}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updateDeptStatusNormal" parameterType="Long">
|
|
update sys_dept set status = '0' where dept_id in
|
|
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</update>
|
|
<update id="changeDeptBalance">
|
|
update sys_dept set balance = balance + #{amount} where dept_id = #{deptId}
|
|
</update>
|
|
|
|
<delete id="deleteDeptById" parameterType="Long">
|
|
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
|
</delete>
|
|
|
|
<select id="selectAllCount" resultType="java.lang.Integer">
|
|
select count(1) from sys_dept where del_flag = '0'
|
|
</select>
|
|
|
|
<select id="getAppCount" resultType="java.lang.Integer">
|
|
select count(1) from sys_dept where is_use_platform_app = 'false' and del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectAllBalance" resultType="java.math.BigDecimal">
|
|
select COALESCE(SUM(balance), 0) from sys_dept where del_flag = '0'
|
|
</select>
|
|
|
|
</mapper>
|