<?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="cn.besteam.modules.medical.mapper.MwServicePeriodMapper">
|
|
|
<select id="getServicePeriodList" resultType="cn.besteam.modules.medical.vo.MwServicePeriodListDTO">
|
select * from (
|
select
|
a.id,
|
CONCAT(g.depart_name, '/', f.depart_name, '/', e.depart_name) as department,
|
a.depart_name as hospital,
|
DATE_FORMAT(a.expire_date, '%Y-%m-%d %H:%i:%s') as expireDate,
|
if(now() > a.expire_date, 1, 0) as isExpire,
|
if(DATE_ADD(now(), INTERVAL IFNULL(a.reminder_days, 0) DAY) > a.expire_date, 1, 0) as aboutToExpire,
|
a.reminder_days as reminderDays,
|
a.service_charge as serviceCharge,
|
d.item_text as serviceUnit
|
from sys_department a
|
left join mw_service_period c on (a.id = c.department_id and c.pay_status = 1 and c.`status` = 1 and c.del_flag = 0)
|
left join sys_dict_item d on (a.service_unit = d.id)
|
left join sys_department e on(a.parent_id = e.id)
|
left join sys_department f on(e.parent_id = f.id)
|
left join sys_department g on(f.parent_id = g.id)
|
where a.status = 1 and a.del_flag = 0 and a.org_type = 2
|
<if test="null != dto.departmentId">
|
and (e.id = #{dto.departmentId} or f.id = #{dto.departmentId} or g.id = #{dto.departmentId})
|
</if>
|
<if test="null != dto.serviceUnit">
|
and a.service_unit = #{dto.serviceUnit}
|
</if>
|
order by a.create_time desc
|
) as aa where 1 = 1
|
<if test="null != dto.isExpireexpired">
|
and aa.isExpire = #{dto.isExpireexpired}
|
</if>
|
<if test="null != dto.aboutToExpire">
|
and aa.aboutToExpire = #{dto.aboutToExpire}
|
</if>
|
</select>
|
|
|
|
<select id="getServicePeriodHistoryRecord" resultType="cn.besteam.modules.medical.vo.MwServicePeriodListDTO">
|
select
|
DATE_FORMAT(a.update_time, '%Y-%m-%d %H:%i:%s') as createTime,
|
DATE_FORMAT(a.expire_date, '%Y-%m-%d %H:%i:%s') as expireDate,
|
a.reminder_days as reminderDays,
|
a.service_charge as serviceCharge,
|
b.`name` as createUser,
|
a.note,
|
c.item_text as serviceUnit
|
from mw_service_period_log a
|
left join sys_user b on (a.create_user_id = b.id)
|
left join sys_dict_item c on (a.service_unit = c.id)
|
where a.department_id = #{id} order by a.create_time desc
|
</select>
|
|
|
<select id="getRenewOrderList" resultType="cn.besteam.modules.medical.dto.RenewOrderResponseVO">
|
select
|
a.id,
|
c.depart_name as departmentName,
|
b.depart_name as hospitalName,
|
a.`code`,
|
DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as orderTime,
|
a.pay_status as payStatus,
|
b.service_charge as serviceCharge,
|
DATE_FORMAT(a.pay_time, '%Y-%m-%d %H:%i:%s') as payTime,
|
a.pay_type as payType,
|
a.pay_amount as payMoney,
|
a.order_number as orderNumber,
|
a.is_invoiced as isInvoiced,
|
if(a.is_invoiced in (0, 2) and b.service_unit is not null, 1, 0) as canVote
|
from mw_service_period a
|
left join sys_department b on (a.department_id = b.id)
|
left join sys_department c on (b.parent_id = c.id)
|
where a.`status` = 1 and a.del_flag = 0
|
<if test="vo.hospitalIdList != null and vo.hospitalIdList.size > 0 ">
|
and a.department_id in
|
<foreach collection="vo.hospitalIdList" item="tempId" open="(" close=")" separator=",">
|
#{tempId}
|
</foreach>
|
</if>
|
<if test="null != vo.code and '' != vo.code">
|
and a.`code` like CONCAT('%', #{vo.code}, '%')
|
</if>
|
<if test="null != vo.payStatus">
|
and a.pay_status = #{vo.payStatus}
|
</if>
|
<if test="null != vo.isInvoiced">
|
and a.is_invoiced = #{vo.isInvoiced}
|
</if>
|
<if test="null != vo.startTime and '' != vo.startTime and null != vo.endTime and '' != vo.endTime">
|
and a.create_time between #{vo.startTime} and #{vo.endTime}
|
</if>
|
order by a.create_time desc
|
</select>
|
|
|
<select id="getRenewOrderOne" resultType="cn.besteam.modules.medical.dto.RenewOrderResponseVO">
|
select
|
a.id,
|
c.depart_name as departmentName,
|
b.depart_name as hospitalName,
|
a.`code`,
|
DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as orderTime,
|
a.pay_status as payStatus,
|
a.service_charge as serviceCharge,
|
DATE_FORMAT(a.pay_time, '%Y-%m-%d %H:%i:%s') as payTime,
|
a.pay_type as payType,
|
a.pay_amount as payMoney,
|
a.order_number as orderNumber,
|
a.is_invoiced as isInvoiced,
|
if(a.is_invoiced in (0, 2) and a.service_unit is not null, 1, 0) as canVote
|
from mw_service_period a
|
left join sys_department b on (a.department_id = b.id)
|
left join sys_department c on (b.parent_id = c.id)
|
where a.id = #{id}
|
</select>
|
</mapper>
|