<?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.lyms.talkonlineweb.mapper.LymsOrderMapper">
<resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsOrder">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="orderno" column="orderno" jdbcType="VARCHAR"/>
<result property="pid" column="pid" jdbcType="INTEGER"/>
<result property="pcid" column="pcid" jdbcType="INTEGER"/>
<result property="gid" column="gid" jdbcType="INTEGER"/>
<result property="price" column="price" jdbcType="INTEGER"/>
<result property="cnt" column="cnt" jdbcType="INTEGER"/>
<result property="amount" column="amount" jdbcType="INTEGER"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="payorderid" column="payorderid" jdbcType="VARCHAR"/>
<result property="transactionId" column="transaction_id" jdbcType="VARCHAR"/>
<result property="openid" column="openid" jdbcType="VARCHAR"/>
<result property="serviceStartTime" column="service_start_time" jdbcType="TIMESTAMP"/>
<result property="serviceEndTime" column="service_end_time" jdbcType="TIMESTAMP"/>
<result property="refundStatus" column="refund_status" jdbcType="INTEGER"/>
<result property="payTime" column="pay_time" jdbcType="TIMESTAMP"/>
<result property="createdby" column="createdby" jdbcType="INTEGER"/>
<result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
<result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
<result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="queryOrderList" parameterType="com.lyms.talkonlineweb.request.OrderRequest"
resultType="com.lyms.talkonlineweb.result.OrderListResponse">
select
p.id as pid,
p.pname,
p.sex,
p.birth,
p.idno,
p.enrolment_phone as phone,
o.orderno,
o.pay_time as payTime,
goods.name as goodName,
o.refund_status as refundStatus,
o.cnt,
<if test="orderRequest.type != null and orderRequest.type == 1 ">
h.doctor,
</if>
o.pcid
from lyms_patient p,
lyms_order o ,
<if test="orderRequest.type != null and orderRequest.type == 1 ">
lyms_his_info h,
</if>
lyms_goods goods
where p.id = o.pid
and o.gid = goods.id
<if test="orderRequest.type != null and orderRequest.type == 1 ">
and p.idno = h.idCard
</if>
and o.status = 1
<if test="orderRequest.key != null and orderRequest.key != '' ">
and (p.pname = #{orderRequest.key} or p.enrolment_phone = #{orderRequest.key} or p.idno= #{orderRequest.key})
</if>
<if test="orderRequest.orderType != null and orderRequest.orderType == 1">
and ( o.pcid is not null)
</if>
<if test="orderRequest.orderType != null and orderRequest.orderType == 2">
and ( o.pcid is null)
</if>
<if test="orderRequest.payTimeStart != null and orderRequest.payTimeStart != ''">
and ( o.pay_time > #{orderRequest.payTimeStart})
</if>
<if test="orderRequest.payTimeEnd != null and orderRequest.payTimeEnd != ''">
and ( o.pay_time < #{orderRequest.payTimeEnd})
</if>
<if test="orderRequest.doctor != null and orderRequest.doctor != ''">
and ( h.doctor = #{orderRequest.doctor})
</if>
<if test="orderRequest.type != null and orderRequest.type == 1 ">
and (o.payorderid is NULL)
</if>
<if test="orderRequest.type != null and orderRequest.type == 2 ">
and (o.payorderid is NOT NULL)
</if>
GROUP BY p.id
order by o.pay_time desc
</select>
<select id="selectOrderTaskList" resultType="com.lyms.talkonlineweb.result.PushOrderResult">
SELECT
o.id,o.pid,pc.dname,pc.hname,p.pname,p.gzopenid,p.idno,o.service_start_time,pi.iname,pi.cid
FROM
`lyms_order` o
INNER JOIN lyms_patient p ON o.pid = p.id
INNER JOIN lyms_pcase pc on pc.pid =o.pid
inner join patient_info pi on pi.idno=p.idno
WHERE
((
<![CDATA[o.service_start_time >= #{sevenStart}
AND o.service_start_time <= #{sevenEnd})
or (o.service_start_time >= #{fourteenStart}
AND o.service_start_time <= #{fourteenEnd})
or (o.service_start_time >= #{twentyStart}
AND o.service_start_time <= #{twentyEnd})
or (o.service_start_time >= #{twentyEightStart}
AND o.service_start_time <= #{twentyEightEnd})
)]]>
and `status`=1
</select>
<select id="selectPushOrder" resultType="com.lyms.talkonlineweb.result.PushOrderResult">
SELECT
o.id,o.pid,pc.dname,pc.hname,p.pname,p.gzopenid,pi.iname,pi.cid
FROM
`lyms_order` o
INNER JOIN lyms_patient p ON o.pid = p.id
INNER JOIN lyms_pcase pc on pc.pid =o.pid
inner join patient_info pi on pi.idno=p.idno
WHERE
o.pid=#{pId}
and `status`=1
</select>
</mapper>