xinelu-api/xinelu-nurse-manage/src/main/resources/mapper/manage/goodsOrder/GoodsOrderMapper.xml
2023-10-26 11:02:12 +08:00

777 lines
29 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.xinelu.manage.mapper.goodsOrder.GoodsOrderMapper">
<resultMap type="GoodsOrder" id="GoodsOrderResult">
<result property="id" column="id"/>
<result property="nurseStationId" column="nurse_station_id"/>
<result property="patientId" column="patient_id"/>
<result property="orderNo" column="order_no"/>
<result property="orderStatus" column="order_status"/>
<result property="totalPrice" column="total_price"/>
<result property="receiver" column="receiver"/>
<result property="receiveAddress" column="receive_address"/>
<result property="phone" column="phone"/>
<result property="orderTime" column="order_time"/>
<result property="orderChannel" column="order_channel"/>
<result property="buySource" column="buy_source"/>
<result property="remark" column="remark"/>
<result property="expressNo" column="express_no"/>
<result property="delFlag" column="del_flag"/>
<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="refundType" column="refund_type"/>
<result property="refundReasonDictId" column="refund_reason_dict_id"/>
<result property="refundReasonRemark" column="refund_reason_remark"/>
<result property="confirmRefundStatus" column="confirm_refund_status"/>
<result property="orderType" column="order_type"/>
<result property="hospitalPersonId" column="hospital_person_id"/>
<result property="originalTotalPrice" column="original_total_price"/>
<result property="healthConsultationContent" column="health_consultation_content"/>
<result property="healthAppointDate" column="health_appoint_date"/>
<result property="hospitalPersonName" column="hospital_person_name"/>
<result property="consultationInfoId" column="consultation_info_id"/>
</resultMap>
<!--商品订单信息及评价-->
<resultMap type="com.xinelu.manage.vo.goodsorder.GoodsOrderVO" id="GoodsOrderVOResult">
<result property="nurseStationId" column="nurse_station_id"/>
<result property="patientId" column="patient_id"/>
<result property="orderNo" column="order_no"/>
<result property="orderStatus" column="order_status"/>
<result property="totalPrice" column="total_price"/>
<result property="receiver" column="receiver"/>
<result property="receiveAddress" column="receive_address"/>
<result property="phone" column="phone"/>
<result property="orderTime" column="order_time"/>
<result property="orderChannel" column="order_channel"/>
<result property="buySource" column="buy_source"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
<result property="expressNo" column="express_no"/>
<result property="originalTotalPrice" column="original_total_price"/>
<result property="goodsOrderId" column="goods_order_id"/>
<result property="goodsName" column="goods_name"/>
<result property="goodsCount" column="goods_count"/>
<result property="goodsAttributeName" column="goods_attribute_name"/>
<result property="goodsAttributeContent" column="goods_attribute_content"/>
<result property="goodsPrice" column="goods_price"/>
<result property="discountPrice" column="discount_price"/>
<result property="transportPrice" column="transport_price"/>
<result property="giveIntegral" column="give_integral"/>
<result property="couponId" column="coupon_id"/>
<result property="couponTitle" column="coupon_title"/>
<result property="evaluateContent" column="evaluate_content"/>
<result property="compositeScore" column="composite_score"/>
<result property="orderType" column="order_type"/>
<result property="integralExchangeCount" column="integral_exchange_count"/>
<result property="integralExchangeSill" column="integral_exchange_sill"/>
<result property="originalTotalPrice" column="original_total_price"/>
<result property="hospitalPersonId" column="hospital_person_id"/>
<result property="healthConsultationContent" column="health_consultation_content"/>
<result property="healthAppointDate" column="health_appoint_date"/>
<collection property="orderEvaluatePictureInfoList" javaType="java.util.List"
resultMap="OrderEvaluatePictureInfoResult"/>
</resultMap>
<!--评价图片-->
<resultMap type="OrderEvaluatePictureInfo" id="OrderEvaluatePictureInfoResult">
<result property="id" column="id"/>
<result property="orderEvaluateId" column="order_evaluate_id"/>
<result property="evaluatePictureUrl" column="evaluate_picture_url"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectGoodsOrderVo">
select id,
nurse_station_id,
patient_id,
order_no,
order_status,
total_price,
receiver,
receive_address,
phone,
order_time,
order_channel,
IFNULL(buy_source, '') buy_source,
remark,
express_no,
del_flag,
create_by,
create_time,
update_by,
update_time,
refund_type,
refund_reason_dict_id,
refund_reason_remark,
confirm_refund_status,
order_type,
hospital_person_id,
original_total_price,
health_consultation_content,
health_appoint_date,
hospital_person_name,
consultation_info_id
from goods_order
</sql>
<select id="selectGoodsOrderList" parameterType="com.xinelu.manage.vo.goodsorder.GoodsInfoOrderVO"
resultType="com.xinelu.manage.vo.goodsorder.GoodsInfoOrderVO">
SELECT
g.id,
g.nurse_station_id,
g.patient_id,
g.order_no,
g.order_status,
g.total_price,
g.receiver,
g.receive_address,
g.phone,
g.order_time,
g.order_channel,
g.buy_source,
g.remark,
g.express_no,
g.del_flag,
g.create_by,
g.create_time,
g.update_by,
g.update_time,
g.refund_type,
g.refund_reason_dict_id,
g.refund_reason_remark,
g.confirm_refund_status,
g.order_type,
g.health_consultation_content,
g.health_appoint_date,
ns.nurse_station_name,
god.goods_name
FROM
goods_order g
LEFT JOIN nurse_station ns ON g.nurse_station_id = ns.id
LEFT JOIN goods_order_details god ON god.goods_order_id = g.id
<where>
<if test="nurseStationId != null ">
and g.nurse_station_id = #{nurseStationId}
</if>
<if test="patientId != null ">
and g.patient_id = #{patientId}
</if>
<if test="orderNo != null and orderNo != ''">
and g.order_no = #{orderNo}
</if>
<if test="orderStatus != null and orderStatus != ''">
and g.order_status = #{orderStatus}
</if>
<if test="totalPrice != null ">
and g.total_price = #{totalPrice}
</if>
<if test="receiver != null and receiver != ''">
and g.receiver = #{receiver}
</if>
<if test="receiveAddress != null and receiveAddress != ''">
and g.receive_address = #{receiveAddress}
</if>
<if test="phone != null and phone != ''">
and g.phone = #{phone}
</if>
<if test="buySource != null and buySource != ''">
and g.buy_source = #{buySource}
</if>
<if test="orderTime != null ">
and g.order_time = #{orderTime}
</if>
<if test="orderChannel != null and orderChannel != ''">
and g.order_channel = #{orderChannel}
</if>
<if test="expressNo != null and expressNo != ''">
and g.express_no = #{expressNo}
</if>
<if test="orderType != null and orderType != ''">
and g.order_type = #{orderType}
</if>
<if test="hospitalPersonId != null ">
and g.hospital_person_id = #{hospitalPersonId}
</if>
<if test="nurseStationName != null and nurseStationName != ''">
and ns.nurse_station_name like concat('%', #{nurseStationName}, '%')
</if>
and g.del_flag = 0
</where>
ORDER BY g.create_time DESC
</select>
<select id="selectGoodsOrderById" parameterType="Long"
resultMap="GoodsOrderResult">
<include refid="selectGoodsOrderVo"/>
where id = #{id}
</select>
<insert id="insertGoodsOrder" parameterType="GoodsOrder" useGeneratedKeys="true"
keyProperty="id">
insert into goods_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="nurseStationId != null">nurse_station_id,
</if>
<if test="patientId != null">patient_id,
</if>
<if test="orderNo != null">order_no,
</if>
<if test="orderStatus != null">order_status,
</if>
<if test="totalPrice != null">total_price,
</if>
<if test="receiver != null">receiver,
</if>
<if test="receiveAddress != null">receive_address,
</if>
<if test="phone != null">phone,
</if>
<if test="orderTime != null">order_time,
</if>
<if test="orderChannel != null">order_channel,
</if>
<if test="buySource != null">buy_source,
</if>
<if test="remark != null">remark,
</if>
<if test="expressNo != null">express_no,
</if>
<if test="delFlag != null">del_flag,
</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="refundType != null">refund_type,
</if>
<if test="refundReasonDictId != null">refund_reason_dict_id,
</if>
<if test="refundReasonRemark != null">refund_reason_remark,
</if>
<if test="confirmRefundStatus != null">confirm_refund_status,
</if>
<if test="orderType != null">order_type,
</if>
<if test="hospitalPersonId != null">hospital_person_id,
</if>
<if test="originalTotalPrice != null">original_total_price,
</if>
<if test="healthConsultationContent != null">health_consultation_content,
</if>
<if test="healthAppointDate != null">health_appoint_date,
</if>
<if test="hospitalPersonName != null">hospital_person_name,
</if>
<if test="consultationInfoId != null">consultation_info_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nurseStationId != null">#{nurseStationId},
</if>
<if test="patientId != null">#{patientId},
</if>
<if test="orderNo != null">#{orderNo},
</if>
<if test="orderStatus != null">#{orderStatus},
</if>
<if test="totalPrice != null">#{totalPrice},
</if>
<if test="receiver != null">#{receiver},
</if>
<if test="receiveAddress != null">#{receiveAddress},
</if>
<if test="phone != null">#{phone},
</if>
<if test="orderTime != null">#{orderTime},
</if>
<if test="orderChannel != null">#{orderChannel},
</if>
<if test="buySource != null">#{buySource},
</if>
<if test="remark != null">#{remark},
</if>
<if test="expressNo != null">#{expressNo},
</if>
<if test="delFlag != null">#{delFlag},
</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="refundType != null">#{refundType},
</if>
<if test="refundReasonDictId != null">#{refundReasonDictId},
</if>
<if test="refundReasonRemark != null">#{refundReasonRemark},
</if>
<if test="confirmRefundStatus != null">#{confirmRefundStatus},
</if>
<if test="orderType != null">#{orderType},
</if>
<if test="hospitalPersonId != null">#{hospitalPersonId},
</if>
<if test="originalTotalPrice != null">#{originalTotalPrice},
</if>
<if test="healthConsultationContent != null">#{healthConsultationContent},
</if>
<if test="healthAppointDate != null">#{healthAppointDate},
</if>
<if test="hospitalPersonName != null">#{hospitalPersonName},
</if>
<if test="consultationInfoId != null">#{consultationInfoId},
</if>
</trim>
</insert>
<update id="updateGoodsOrder" parameterType="GoodsOrder">
update goods_order
<trim prefix="SET" suffixOverrides=",">
<if test="nurseStationId != null">nurse_station_id =
#{nurseStationId},
</if>
<if test="patientId != null">patient_id =
#{patientId},
</if>
<if test="orderNo != null">order_no =
#{orderNo},
</if>
<if test="orderStatus != null">order_status =
#{orderStatus},
</if>
<if test="totalPrice != null">total_price =
#{totalPrice},
</if>
<if test="receiver != null">receiver =
#{receiver},
</if>
<if test="receiveAddress != null">receive_address =
#{receiveAddress},
</if>
<if test="phone != null">phone =
#{phone},
</if>
<if test="orderTime != null">order_time =
#{orderTime},
</if>
<if test="orderChannel != null">order_channel =
#{orderChannel},
</if>
<if test="buySource != null">buy_source =
#{buySource},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="expressNo != null">express_no =
#{expressNo},
</if>
<if test="delFlag != null">del_flag =
#{delFlag},
</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="refundType != null">refund_type =
#{refundType},
</if>
<if test="refundReasonDictId != null">refund_reason_dict_id =
#{refundReasonDictId},
</if>
<if test="refundReasonRemark != null">refund_reason_remark =
#{refundReasonRemark},
</if>
<if test="confirmRefundStatus != null">confirm_refund_status =
#{confirmRefundStatus},
</if>
<if test="orderType != null">order_type =
#{orderType},
</if>
<if test="hospitalPersonId != null">hospital_person_id =
#{hospitalPersonId},
</if>
<if test="originalTotalPrice != null">original_total_price =
#{originalTotalPrice},
</if>
<if test="healthConsultationContent != null">health_consultation_content =
#{healthConsultationContent},
</if>
<if test="healthAppointDate != null">health_appoint_date =
#{healthAppointDate},
</if>
<if test="hospitalPersonName != null">hospital_person_name =
#{hospitalPersonName},
</if>
<if test="consultationInfoId != null">consultation_info_id =
#{consultationInfoId},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteGoodsOrderById" parameterType="Long">
delete
from goods_order
where id = #{id}
</delete>
<delete id="deleteGoodsOrderByIds" parameterType="String">
delete from goods_order where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getGoodsOrderByOrder" parameterType="com.xinelu.manage.vo.goodsorder.GoodsOrderVO"
resultMap="GoodsOrderVOResult">
select
gr.nurse_station_id,
gr.patient_id,
gr.order_no,
gr.order_status,
gr.total_price,
gr.receiver,
gr.receive_address,
gr.phone,
gr.order_time,
gr.order_channel,
gr.buy_source,
gr.remark,
gr.del_flag,
gr.express_no,
gr.order_type,
gr.original_total_price,
gr.hospital_person_id,
gr.health_consultation_content,
gr.health_appoint_date,
god.goods_order_id,
god.order_no godOrderNo,
god.goods_name,
god.goods_count,
god.goods_attribute_name,
god.goods_attribute_content,
god.goods_price,
god.total_price godTotalPrice,
god.discount_price,
god.transport_price,
god.give_integral,
god.integral_exchange_sill,
god.integral_exchange_count,
god.coupon_id,
god.coupon_title,
oei.evaluate_content,
oei.composite_score,
oei.evaluate_content,
oepi.evaluate_picture_url
from goods_order gr
left join goods_order_details god on gr.id = god.goods_order_id
left join order_evaluate_info oei ON oei.order_no =gr.order_no
left join order_evaluate_picture_info oepi ON oepi.order_evaluate_id = oei.id
<where>
<if test="orderNo != null and orderNo != ''">
and gr.order_no = #{orderNo}
</if>
</where>
and gr.del_flag = 0
</select>
<select id="selectGoodsOrderDetailsByOrderNo"
resultType="com.xinelu.manage.vo.goodsorder.GoodsOrderDetailsVO">
SELECT gor.nurse_station_id,
gor.nurse_station_id,
gor.order_no,
gor.order_status,
gor.total_price,
gor.receiver,
gor.receive_address,
gor.phone,
gor.order_time,
gor.order_channel,
gor.buy_source,
god.goods_name,
god.goods_count,
god.goods_price,
god.discount_price,
god.transport_price,
god.give_integral
FROM goods_order gor
INNER JOIN goods_order_details god
ON god.goods_order_id = gor.id
<where>
<if test="orderNo != null and orderNo != ''">
gor.order_no = #{orderNo}
</if>
</where>
</select>
<select id="getGoodsOrderByOrderNo" parameterType="string" resultType="GoodsOrder">
<include refid="selectGoodsOrderVo"/>
<where>
del_flag = 0
<if test="orderNo != null and orderNo != ''">
and order_no = #{orderNo}
</if>
</where>
</select>
<update id="updateGoodsOrderStatus" parameterType="string">
update goods_order
set order_status = #{orderStatus},
update_time = now()
where del_flag = 0
and order_no = #{orderNo}
and order_status &lt;&gt; #{orderStatus}
</update>
<select id="getWaitPayGoodsOrderList" resultType="com.xinelu.manage.vo.goods.GoodsOrderAndDetailsInfo">
SELECT DISTINCT gr.order_no,
IFNULL(gr.buy_source, '') buy_source,
grd.goods_attribute_details_id,
grd.goods_count,
gr.patient_id,
grd.coupon_id,
IFNULL(gr.order_type, '') order_type
FROM goods_order gr
INNER JOIN goods_order_details grd ON gr.order_no = grd.order_no
WHERE gr.order_time &lt;= #{time}
AND gr.order_status = 'WAIT_PAY'
AND gr.del_flag = 0
</select>
<update id="updateBatchGoodsOrderStatus">
UPDATE goods_order SET order_status = #{orderStatus}, update_time = now()
WHERE
del_flag = 0
AND order_status &lt;&gt; #{orderStatus}
AND order_no IN
<foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
#{orderNo}
</foreach>
</update>
<select id="getWaitPayStatusGoodsOrderList" resultType="goodsOrder">
SELECT DISTINCT
patient_id,
order_no,
order_status,
total_price,
order_channel,
IFNULL(buy_source, '') buy_source
FROM
goods_order
where
del_flag = 0 AND order_status = #{orderStatus}
</select>
<select id="getGoodsAndDetailsOrderInfo" resultType="com.xinelu.manage.vo.goods.GoodsOrderAndDetailsInfo">
SELECT DISTINCT gr.order_no,
gr.buy_source,
grd.goods_attribute_details_id,
grd.goods_count,
gr.order_status,
gr.patient_id,
grd.coupon_id,
gr.order_type
FROM goods_order gr
inner join goods_order_details grd on gr.order_no = grd.order_no
WHERE gr.order_no = #{orderNo}
AND gr.del_flag = 0
</select>
<select id="getRefundGoodsOrderInfo" parameterType="string" resultType="com.xinelu.manage.vo.RefundOrderInfoVO">
SELECT gr.order_no,
IFNULL(gr.buy_source, '') buy_source,
god.goods_attribute_details_id,
god.goods_count,
rf.out_refund_no,
gr.patient_id,
god.coupon_id,
IFNULL(gr.order_type, '') order_type
FROM goods_order gr
INNER JOIN goods_order_details god ON gr.order_no = god.order_no
INNER JOIN refund_info rf ON gr.order_no = rf.order_no
WHERE gr.order_status = #{orderStatus}
AND gr.confirm_refund_status = #{confirmRefundStatus}
AND rf.wechat_refund_status = #{refundStatus}
AND gr.del_flag = 0
</select>
<select id="getGoodsOrderRefund" parameterType="com.xinelu.manage.vo.goodsorder.GoodsOrderRefundVO"
resultType="com.xinelu.manage.vo.goodsorder.GoodsOrderRefundVO">
SELECT
g.id goodsOrderId,
g.nurse_station_id,
g.patient_id,
g.order_no goOrderNo,
g.order_status,
g.total_price,
g.receiver,
g.receive_address,
g.phone,
g.order_time,
g.refund_type,
g.refund_reason_dict_id,
g.refund_reason_remark,
g.confirm_refund_status,
g.update_time,
g.express_no,
g.order_type,
g.original_total_price,
g.health_consultation_content,
g.health_appoint_date,
god.integral_deduction_count,
god.id goodsOrderDetailsId,
god.order_no godOrderNo,
god.goods_name,
god.goods_count,
god.goods_attribute_name,
god.goods_attribute_content,
god.goods_price,
god.total_price godTotalPrice,
god.discount_price,
god.transport_price,
god.give_integral,
gad.integral_exchange_flag,
god.integral_exchange_sill,
god.integral_exchange_count,
god.coupon_id,
god.coupon_title,
gad.attribute_piture_url,
sdd.dict_label
FROM
goods_order g
LEFT JOIN goods_order_details god ON g.id = god.goods_order_id
LEFT JOIN goods_attribute_details gad ON god.goods_attribute_details_id = gad.id
LEFT JOIN sys_dict_data sdd ON sdd.dict_code = g.refund_reason_dict_id
<where>
<if test="goodsOrderId != null ">
and g.id = #{goodsOrderId}
</if>
and g.del_flag = 0
and god.del_flag = 0
</where>
</select>
<update id="updateGoodsConfirmRefundStatus" parameterType="string">
update goods_order
set confirm_refund_status = #{confirmRefundStatus},
update_time = now()
where del_flag = 0
and order_no = #{orderNo}
and confirm_refund_status &lt;&gt; #{confirmRefundStatus}
</update>
<select id="getWaitPayGoodsOrderCountList" parameterType="list"
resultType="com.xinelu.manage.vo.goods.GoodsOrderAndDetailsInfo">
SELECT DISTINCT gr.order_no,
gr.buy_source,
grd.goods_attribute_details_id,
grd.goods_count,
gr.patient_id,
grd.coupon_id,
gr.order_type
FROM goods_order gr
INNER JOIN goods_order_details grd ON gr.order_no = grd.order_no
WHERE
gr.del_flag = 0
AND gr.order_status = 'WAIT_PAY'
AND gr.order_no in
<foreach collection="orderNoList" item="orderNo" open="(" separator="," close=")">
#{orderNo}
</foreach>
</select>
<select id="getGoodOrder" resultType="com.xinelu.manage.vo.goodsorder.GoodsInfoRedemptionVO">
select
IFNULL(gr.patient_id, 0) patient_id,
gr.order_no,
gr.order_status,
gr.order_type,
gr.order_time,
gr.confirm_refund_status,
gr.order_channel,
god.goods_attribute_id,
god.goods_attribute_details_id,
god.integral_exchange_sill,
god.integral_exchange_count
from goods_order gr
inner join goods_order_details god on gr.id = god.goods_order_id
<where>
<if test="orderNo != null and orderNo != ''">
and gr.order_no = #{orderNo}
</if>
</where>
and gr.del_flag = 0
and god.del_flag = 0
</select>
<update id="updateConfirmRefundStatusAndOrderStatus" parameterType="string">
update goods_order
set confirm_refund_status = #{confirmRefundStatus}, order_status = #{orderStatus}, update_time = now()
where del_flag = 0
and order_no = #{orderNo}
and confirm_refund_status &lt;&gt; #{confirmRefundStatus}
</update>
<select id="selectGoodsOrderByTime" resultType="com.xinelu.manage.vo.orderDetails.GoodsOrderAndDetails">
select gor.patient_id,
gor.order_no,
gor.order_status,
gor.total_price,
gor.order_time,
god.goods_name,
god.goods_count
from goods_order gor
LEFT JOIN goods_order_details god ON god.order_no = gor.order_no
where gor.order_time &gt; #{beforeTime}
and gor.order_time &lt;= #{time}
and gor.order_status = #{orderStatus} and gor.order_type = #{orderType}
and gor.del_flag = 0
</select>
<select id="getConsultationOrders" resultType="com.xinelu.manage.vo.goodsorder.AppGoodsOrderVO">
select
c.patient_id as patientId, c.id as consultationInfoId,
c.patient_name as patientName, c.card_no as cardNo,
c.phone, c.address,c.appointment_date, c.appointment_start_time, c.appointment_end_time,c.problem_description,
gr.id as goodsOrderId,gr.order_no, gr.order_status, gr.total_price, gr.health_consultation_content
from goods_order gr left join consultation_info c on gr.consultation_info_id = c.id
where gr.del_flag = 0 and c.consultation_type = 'VIDEO_CONSULTATION'
<if test="hospitalPersonId != null">
and gr.hospital_person_id = #{hospitalPersonId}
</if>
<if test="orderStatus != null and orderStatus != ''">
and gr.order_status = #{orderStatus}
</if>
<if test="orderType != null and orderType != ''">
and gr.order_type = #{orderType}
</if>
</select>
</mapper>