zhwl/zhwl-travel-agency/zhwl-travel-agency-account/target/classes/mapper/travelagency/account/ZdyTravelAgencyInfoMapper.xml
2025-07-01 17:54:58 +08:00

507 lines
18 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.zhwl.travelagency.account.mapper.ZdyTravelAgencyInfoMapper">
<resultMap type="ZdyTravelAgencyInfoVO" id="ZdyTravelAgencyInfoResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="sysUserId" column="sys_user_id"/>
<result property="account" column="account"/>
<result property="password" column="password"/>
<result property="accountStatus" column="account_status"/>
<result property="salesQuantity" column="sales_quantity"/>
<result property="salesAmount" column="sales_amount"/>
<result property="balance" column="balance"/>
<result property="payPassword" column="pay_password"/>
<result property="head" column="head"/>
<result property="phone" column="phone"/>
<result property="employeeAccountPrefix" column="employee_account_prefix"/>
<result property="bank" column="bank"/>
<result property="bankAccount" column="bank_account"/>
<result property="bankCardNumber" column="bank_card_number"/>
<result property="bankBranch" column="bank_branch"/>
<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="remark" column="remark"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectZdyTravelAgencyInfoVo">
select id,
name,
sys_user_id,
sales_quantity,
sales_amount,
balance,
pay_password,
head,
employee_account_prefix,
bank,
bank_account,
bank_card_number,
bank_branch,
create_by,
create_time,
update_by,
update_time,
remark,
dept_id
from zdy_travel_agency_info
</sql>
<select id="selectZdyTravelAgencyInfoList" parameterType="ZdyTravelAgencyInfoDTO"
resultMap="ZdyTravelAgencyInfoResult">
select a.id,
a.name,
a.sys_user_id,
c.sales_order_quantity sales_quantity,
c.sales_order_price sales_amount,
a.balance,
a.pay_password,
a.head,
a.employee_account_prefix,
a.bank,
a.bank_account,
a.bank_card_number,
a.bank_branch,
b.del_flag,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.remark,
a.dept_id,
b.user_name as account,
b.phonenumber as phone,
b.status as account_status,
b.password as password
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
left join (select sum(sales_order_quantity) sales_order_quantity,
sum(sales_order_price) sales_order_price,
travel_agency_id
from zdy_travel_agency_order_sales_record
group by travel_agency_id) c on c.travel_agency_id = a.id
<where>
<if test="name != null and name != ''">
and a.name like concat('%', #{name}, '%')
</if>
<if test="account != null and account != ''">
and b.user_name like concat('%', #{account}, '%')
</if>
<if test="password != null and password != ''">
and b.password = #{password}
</if>
<if test="accountStatus != null ">
and b.status = #{accountStatus}
</if>
<if test="salesQuantity != null">
and a.sales_quantity = #{salesQuantity}
</if>
<if test="salesAmount != null ">
and a.sales_amount = #{salesAmount}
</if>
<if test="balance != null ">
and a.balance = #{balance}
</if>
<if test="head != null and head != ''">
and a.head like concat('%', #{head}, '%')
</if>
<if test="phone != null and phone != ''">
and b.phonenumber like concat('%', #{phone}, '%')
</if>
<if test="employeeAccountPrefix != null and employeeAccountPrefix != ''">
and a.employee_account_prefix = #{employeeAccountPrefix}
</if>
<if test="bank != null ">
and a.bank = #{bank}
</if>
<if test="bankAccount != null and bankAccount != ''">
and a.bank_account = #{bankAccount}
</if>
<if test="bankCardNumber != null and bankCardNumber != ''">
and a.bank_card_number = #{bankCardNumber}
</if>
<if test="bankBranch != null and bankBranch != ''">
and a.bank_branch = #{bankBranch}
</if>
<if test="createBy != null and createBy != ''">
and a.create_by = #{createBy}
</if>
<if test="createTime != null ">
and a.create_time = #{createTime}
</if>
<if test="updateBy != null and updateBy != ''">
and a.update_by = #{updateBy}
</if>
<if test="updateTime != null ">
and a.update_time = #{updateTime}
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
and b.del_flag = '0'
<if test="ids != null and ids.size() != 0">
and a.id in
<foreach collection="ids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</if>
${params.dataScope}
</where>
order by a.create_time desc
</select>
<select id="selectZdyTravelAgencyInfoById" parameterType="Long"
resultMap="ZdyTravelAgencyInfoResult">
select a.id,
a.name,
a.sys_user_id,
a.sales_quantity,
a.sales_amount,
a.balance,
a.pay_password,
a.head,
a.employee_account_prefix,
a.bank,
a.bank_account,
a.bank_card_number,
a.bank_branch,
b.del_flag,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.remark,
b.user_name as account,
b.phonenumber as phone,
b.status as account_status,
b.password as password
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where a.id = #{id}
and b.del_flag = '0'
</select>
<select id="selectZdyTravelAgencyInfoByUserId" parameterType="Long"
resultMap="ZdyTravelAgencyInfoResult">
select a.id,
a.name,
a.sys_user_id,
a.sales_quantity,
a.sales_amount,
a.balance,
a.pay_password,
a.head,
a.employee_account_prefix,
a.bank,
a.bank_account,
a.bank_card_number,
a.bank_branch,
b.del_flag,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.remark,
b.user_name as account,
b.phonenumber as phone,
b.status as account_status,
b.password as password
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where a.sys_user_id = #{userId}
and b.del_flag = '0'
</select>
<insert id="insertZdyTravelAgencyInfo" parameterType="ZdyTravelAgencyInfoDTO" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_travel_agency_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,
</if>
<if test="sysUserId != null">sys_user_id,
</if>
<if test="salesQuantity != null">sales_quantity,
</if>
<if test="salesAmount != null">sales_amount,
</if>
<if test="balance != null">balance,
</if>
<if test="payPassword != null and payPassword!=''">pay_password,
</if>
<if test="head != null and head != ''">head,
</if>
<if test="employeeAccountPrefix != null and employeeAccountPrefix != ''">employee_account_prefix,
</if>
<if test="bank != null">bank,
</if>
<if test="bankAccount != null and bankAccount != ''">bank_account,
</if>
<if test="bankCardNumber != null and bankCardNumber != ''">bank_card_number,
</if>
<if test="bankBranch != null and bankBranch != ''">bank_branch,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="remark != null">remark,
</if>
<if test="deptId != null">dept_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},
</if>
<if test="sysUserId != null">#{sysUserId},
</if>
<if test="salesQuantity != null">#{salesQuantity},
</if>
<if test="salesAmount != null">#{salesAmount},
</if>
<if test="balance != null">#{balance},
</if>
<if test="payPassword != null and payPassword!=''">#{payPassword},
</if>
<if test="head != null and head != ''">#{head},
</if>
<if test="employeeAccountPrefix != null and employeeAccountPrefix != ''">#{employeeAccountPrefix},
</if>
<if test="bank != null">#{bank},
</if>
<if test="bankAccount != null and bankAccount != ''">#{bankAccount},
</if>
<if test="bankCardNumber != null and bankCardNumber != ''">#{bankCardNumber},
</if>
<if test="bankBranch != null and bankBranch != ''">#{bankBranch},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="remark != null">#{remark},
</if>
<if test="deptId != null">#{deptId},
</if>
</trim>
</insert>
<update id="updateZdyTravelAgencyInfo" parameterType="ZdyTravelAgencyInfoDTO">
update zdy_travel_agency_info
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name =
#{name},
</if>
<if test="sysUserId != null ">sys_user_id=#{sysUserId},
</if>
<if test="salesQuantity != null">sales_quantity = #{salesQuantity},
</if>
<if test="salesAmount != null">sales_amount = #{salesAmount},
</if>
<if test="balance != null">balance =
#{balance},
</if>
<if test="payPassword != null and payPassword!=''">pay_password =
#{payPassword},
</if>
<if test="head != null and head != ''">head =
#{head},
</if>
<if test="employeeAccountPrefix != null and employeeAccountPrefix != ''">employee_account_prefix =
#{employeeAccountPrefix},
</if>
<if test="bank != null">bank =
#{bank},
</if>
<if test="bankAccount != null and bankAccount != ''">bank_account =
#{bankAccount},
</if>
<if test="bankCardNumber != null and bankCardNumber != ''">bank_card_number =
#{bankCardNumber},
</if>
<if test="bankBranch != null and bankBranch != ''">bank_branch =
#{bankBranch},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteZdyTravelAgencyInfoById" parameterType="Long">
delete
from zdy_travel_agency_info
where id = #{id}
</delete>
<delete id="deleteZdyTravelAgencyInfoByIds" parameterType="String">
update sys_user set del_flag = 2 where user_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="countByEmployeeAccountPrefix" resultType="int">
select count(1)
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where b.del_flag = '0'
and employee_account_prefix = #{prefix}
</select>
<select id="countByBankCardNumber" resultType="int">
select count(1)
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where b.del_flag = '0'
and a.bank_card_number = #{bankCardNumber}
</select>
<select id="countByBankCardNumberNotId" resultType="int">
select count(1)
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where b.del_flag = '0'
and a.bank_card_number = #{bankCardNumber}
and a.id !=#{id}
</select>
<update id="updateBalance">
update
zdy_travel_agency_info
set balance=balance + #{amount}
where id = #{id}
</update>
<select id="getNames" resultType="string">
select name
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where b.del_flag = '0'
group by name
</select>
<select id="getVOByDeptId" parameterType="long" resultMap="ZdyTravelAgencyInfoResult">
select id
from zdy_travel_agency_info a
where a.dept_id = #{deptId}
</select>
<select id="getTravelAgencyInfos" resultMap="ZdyTravelAgencyInfoResult" parameterType="ZdyTravelAgencyInfoDTO">
select a.id,
a.name
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
<where>
b.del_flag = '0'
<if test="id != null">
and id = #{id}
</if>
${params.dataScope}
</where>
</select>
<update id="updatePayPassword">
update zdy_travel_agency_info
set pay_password = #{payPassword}
where id = #{id}
</update>
<select id="getAccountPrefixByDeptId" parameterType="java.lang.Long" resultType="java.lang.String">
select employee_account_prefix
from zdy_travel_agency_info
where dept_id = #{deptId}
</select>
<select id="getByDeptId" parameterType="Long" resultMap="ZdyTravelAgencyInfoResult">
select a.id,
a.name,
a.sys_user_id,
a.sales_quantity,
a.sales_amount,
a.balance,
a.pay_password,
a.head,
a.employee_account_prefix,
a.bank,
a.bank_account,
a.bank_card_number,
a.bank_branch,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.remark,
b.user_name as account,
b.phonenumber as phone,
b.status as account_status,
b.password as password
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where a.dept_id = #{deptId}
and b.del_flag = '0'
</select>
<select id="countQuantity" resultType="int">
select count(1)
from zdy_travel_agency_info a
inner join sys_user b on a.sys_user_id = b.user_id
where b.del_flag = '0'
</select>
<select id="getTravelAgencyInfosFromTicketOrder"
resultType="com.zhwl.travelagency.account.domain.vo.ZdyTravelAgencyInfoVO">
select a.id, ztai.name
from (select zto.travel_agency_id id
from zdy_ticket_order_item ztoi
left join zdy_ticket_order zto on ztoi.order_id = zto.id
where ztoi.del_flag = '0'
and zto.travel_agency_id is not null
${params.dataScope}
group by zto.travel_agency_id) a
left join zdy_travel_agency_info ztai on a.id = ztai.id
</select>
<select id="selectBaseList" resultType="java.util.Map">
SELECT
a.id,
a.name,
IFNULL(a.head,'') as head,
IFNULL(b.phonenumber,'') as phonenumber
FROM
zdy_travel_agency_info a
INNER JOIN sys_user b ON a.sys_user_id = b.user_id
</select>
</mapper>