cashier-client/src/main/resources/mapper/TbOrderInfoMapper.xml

648 lines
27 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.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
<result column="settlement_amount" jdbcType="DECIMAL" property="settlementAmount"/>
<result column="pack_fee" jdbcType="DECIMAL" property="packFee"/>
<result column="origin_amount" jdbcType="DECIMAL" property="originAmount"/>
<result column="product_amount" jdbcType="DECIMAL" property="productAmount"/>
<result column="amount" jdbcType="DECIMAL" property="amount"/>
<result column="refund_amount" jdbcType="DECIMAL" property="refundAmount"/>
<result column="pay_type" jdbcType="VARCHAR" property="payType"/>
<result column="pay_amount" jdbcType="DECIMAL" property="payAmount"/>
<result column="order_amount" jdbcType="DECIMAL" property="orderAmount"/>
<result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
<result column="discount_ratio" jdbcType="DECIMAL" property="discountRatio"/>
<result column="discount_amount" jdbcType="DECIMAL" property="discountAmount"/>
<result column="table_id" jdbcType="VARCHAR" property="tableId"/>
<result column="small_change" jdbcType="DECIMAL" property="smallChange"/>
<result column="send_type" jdbcType="VARCHAR" property="sendType"/>
<result column="order_type" jdbcType="VARCHAR" property="orderType"/>
<result column="product_type" jdbcType="VARCHAR" property="productType"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
<result column="billing_id" jdbcType="VARCHAR" property="billingId"/>
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId"/>
<result column="shop_id" jdbcType="VARCHAR" property="shopId"/>
<result column="is_vip" jdbcType="TINYINT" property="isVip"/>
<result column="member_id" jdbcType="VARCHAR" property="memberId"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
<result column="product_score" jdbcType="INTEGER" property="productScore"/>
<result column="deduct_score" jdbcType="INTEGER" property="deductScore"/>
<result column="user_coupon_id" jdbcType="VARCHAR" property="userCouponId"/>
<result column="user_coupon_amount" jdbcType="DECIMAL" property="userCouponAmount"/>
<result column="refund_able" jdbcType="TINYINT" property="refundAble"/>
<result column="paid_time" jdbcType="BIGINT" property="paidTime"/>
<result column="is_effect" jdbcType="TINYINT" property="isEffect"/>
<result column="is_group" jdbcType="TINYINT" property="isGroup"/>
<result column="updated_at" jdbcType="BIGINT" property="updatedAt"/>
<result column="system_time" jdbcType="BIGINT" property="systemTime"/>
<result column="created_at" jdbcType="BIGINT" property="createdAt"/>
<result column="is_accepted" jdbcType="TINYINT" property="isAccepted"/>
<result column="pay_order_no" jdbcType="VARCHAR" property="payOrderNo"/>
<result column="trade_day" jdbcType="VARCHAR" property="tradeDay"/>
<result column="source" jdbcType="VARCHAR" property="source"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="master_id" jdbcType="VARCHAR" property="masterId"/>
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
<result column="out_number" jdbcType="VARCHAR" property="outNumber"/>
<result column="use_type" jdbcType="VARCHAR" property="useType"/>
</resultMap>
<sql id="Base_Column_List">
id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount,
refund_amount, pay_type, pay_amount, order_amount, freight_amount, discount_ratio,
discount_amount, table_id, small_change, send_type, order_type, product_type, status,
billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score,
user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group,
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,out_number, use_type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_order_info
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAllByShop" resultType="com.chaozhanggui.system.cashierservice.entity.po.OrderPo">
SELECT
toi.created_at AS createAt,
toi.id,
toi.order_no AS orderNo,
toi.order_amount AS orderAmount,
count(*) AS productNum,
toi.order_type AS orderType,
GROUP_CONCAT(tod.product_name) AS productName,
toi.STATUS,
toi.out_number AS outNumber,
toi.table_name AS tableName,
toi.remark,
toi.master_id as masterId,
toi.discount_ratio as discountRatio,
toi.discount_amount as discountAmount
FROM
tb_order_info toi
LEFT JOIN tb_order_detail tod ON tod.order_id = toi.id
WHERE
toi.shop_id = #{shopId}
<if test="startTime != null">
and created_at &gt;= #{startTime}
</if>
<if test="endTime != null">
and created_at &lt;= #{endTime}
</if>
<choose>
<when test="orderType == 'return'">
and toi.order_type = 'return' and toi.status in ('refund','closed')
</when>
<when test="orderType == 'cash'">
and toi.order_type in ('cash','miniapp') and toi.status in ('refund','closed')
</when>
<otherwise>
and toi.status in ('refund','closed')
</otherwise>
</choose>
<if test="day != null and day != ''">
and toi.trade_day = #{day}
</if>
<if test="orderNo != null and orderNo != ''">
and toi.order_no = #{orderNo}
</if>
group by toi.id,toi.shop_id
order by toi.id desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_order_info
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo"
useGeneratedKeys="true" keyProperty="id">
insert into tb_order_info (id, order_no, settlement_amount,
pack_fee, origin_amount, product_amount,
amount, refund_amount, pay_type,
pay_amount, order_amount, freight_amount,
discount_ratio, discount_amount, table_id,
small_change, send_type, order_type,
product_type, status, billing_id,
merchant_id, shop_id, is_vip,
member_id, user_id, product_score,
deduct_score, user_coupon_id, user_coupon_amount,
refund_able, paid_time, is_effect,
is_group, updated_at, system_time,
created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,out_number, use_type
)
values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
#{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL},
#{amount,jdbcType=DECIMAL}, #{refundAmount,jdbcType=DECIMAL}, #{payType,jdbcType=VARCHAR},
#{payAmount,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL},
#{discountRatio,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{tableId,jdbcType=VARCHAR},
#{smallChange,jdbcType=DECIMAL}, #{sendType,jdbcType=VARCHAR}, #{orderType,jdbcType=VARCHAR},
#{productType,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{billingId,jdbcType=VARCHAR},
#{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT},
#{memberId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{productScore,jdbcType=INTEGER},
#{deductScore,jdbcType=INTEGER}, #{userCouponId,jdbcType=VARCHAR}, #{userCouponAmount,jdbcType=DECIMAL},
#{refundAble,jdbcType=TINYINT}, #{paidTime,jdbcType=BIGINT}, #{isEffect,jdbcType=TINYINT},
#{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT},
#{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR},
#{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{masterId,jdbcType=VARCHAR},#{tableName,jdbcType=VARCHAR},
#{outNumber,jdbcType=VARCHAR},#{useType,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
insert into tb_order_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="orderNo != null">
order_no,
</if>
<if test="settlementAmount != null">
settlement_amount,
</if>
<if test="packFee != null">
pack_fee,
</if>
<if test="originAmount != null">
origin_amount,
</if>
<if test="productAmount != null">
product_amount,
</if>
<if test="amount != null">
amount,
</if>
<if test="refundAmount != null">
refund_amount,
</if>
<if test="payType != null">
pay_type,
</if>
<if test="payAmount != null">
pay_amount,
</if>
<if test="orderAmount != null">
order_amount,
</if>
<if test="freightAmount != null">
freight_amount,
</if>
<if test="discountRatio != null">
discount_ratio,
</if>
<if test="discountAmount != null">
discount_amount,
</if>
<if test="tableId != null">
table_id,
</if>
<if test="smallChange != null">
small_change,
</if>
<if test="sendType != null">
send_type,
</if>
<if test="orderType != null">
order_type,
</if>
<if test="productType != null">
product_type,
</if>
<if test="status != null">
status,
</if>
<if test="billingId != null">
billing_id,
</if>
<if test="merchantId != null">
merchant_id,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="isVip != null">
is_vip,
</if>
<if test="memberId != null">
member_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="productScore != null">
product_score,
</if>
<if test="deductScore != null">
deduct_score,
</if>
<if test="userCouponId != null">
user_coupon_id,
</if>
<if test="userCouponAmount != null">
user_coupon_amount,
</if>
<if test="refundAble != null">
refund_able,
</if>
<if test="paidTime != null">
paid_time,
</if>
<if test="isEffect != null">
is_effect,
</if>
<if test="isGroup != null">
is_group,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="systemTime != null">
system_time,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="isAccepted != null">
is_accepted,
</if>
<if test="payOrderNo != null">
pay_order_no,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="orderNo != null">
#{orderNo,jdbcType=VARCHAR},
</if>
<if test="settlementAmount != null">
#{settlementAmount,jdbcType=DECIMAL},
</if>
<if test="packFee != null">
#{packFee,jdbcType=DECIMAL},
</if>
<if test="originAmount != null">
#{originAmount,jdbcType=DECIMAL},
</if>
<if test="productAmount != null">
#{productAmount,jdbcType=DECIMAL},
</if>
<if test="amount != null">
#{amount,jdbcType=DECIMAL},
</if>
<if test="refundAmount != null">
#{refundAmount,jdbcType=DECIMAL},
</if>
<if test="payType != null">
#{payType,jdbcType=VARCHAR},
</if>
<if test="payAmount != null">
#{payAmount,jdbcType=DECIMAL},
</if>
<if test="orderAmount != null">
#{orderAmount,jdbcType=DECIMAL},
</if>
<if test="freightAmount != null">
#{freightAmount,jdbcType=DECIMAL},
</if>
<if test="discountRatio != null">
#{discountRatio,jdbcType=DECIMAL},
</if>
<if test="discountAmount != null">
#{discountAmount,jdbcType=DECIMAL},
</if>
<if test="tableId != null">
#{tableId,jdbcType=VARCHAR},
</if>
<if test="smallChange != null">
#{smallChange,jdbcType=DECIMAL},
</if>
<if test="sendType != null">
#{sendType,jdbcType=VARCHAR},
</if>
<if test="orderType != null">
#{orderType,jdbcType=VARCHAR},
</if>
<if test="productType != null">
#{productType,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="billingId != null">
#{billingId,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
#{merchantId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="isVip != null">
#{isVip,jdbcType=TINYINT},
</if>
<if test="memberId != null">
#{memberId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="productScore != null">
#{productScore,jdbcType=INTEGER},
</if>
<if test="deductScore != null">
#{deductScore,jdbcType=INTEGER},
</if>
<if test="userCouponId != null">
#{userCouponId,jdbcType=VARCHAR},
</if>
<if test="userCouponAmount != null">
#{userCouponAmount,jdbcType=DECIMAL},
</if>
<if test="refundAble != null">
#{refundAble,jdbcType=TINYINT},
</if>
<if test="paidTime != null">
#{paidTime,jdbcType=BIGINT},
</if>
<if test="isEffect != null">
#{isEffect,jdbcType=TINYINT},
</if>
<if test="isGroup != null">
#{isGroup,jdbcType=TINYINT},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=BIGINT},
</if>
<if test="systemTime != null">
#{systemTime,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=BIGINT},
</if>
<if test="isAccepted != null">
#{isAccepted,jdbcType=TINYINT},
</if>
<if test="payOrderNo != null">
#{payOrderNo,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
update tb_order_info
<set>
<if test="orderNo != null">
order_no = #{orderNo,jdbcType=VARCHAR},
</if>
<if test="settlementAmount != null">
settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
</if>
<if test="packFee != null">
pack_fee = #{packFee,jdbcType=DECIMAL},
</if>
<if test="originAmount != null">
origin_amount = #{originAmount,jdbcType=DECIMAL},
</if>
<if test="productAmount != null">
product_amount = #{productAmount,jdbcType=DECIMAL},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="refundAmount != null">
refund_amount = #{refundAmount,jdbcType=DECIMAL},
</if>
<if test="payType != null">
pay_type = #{payType,jdbcType=VARCHAR},
</if>
<if test="payAmount != null">
pay_amount = #{payAmount,jdbcType=DECIMAL},
</if>
<if test="orderAmount != null">
order_amount = #{orderAmount,jdbcType=DECIMAL},
</if>
<if test="freightAmount != null">
freight_amount = #{freightAmount,jdbcType=DECIMAL},
</if>
<if test="discountRatio != null">
discount_ratio = #{discountRatio,jdbcType=DECIMAL},
</if>
<if test="discountAmount != null">
discount_amount = #{discountAmount,jdbcType=DECIMAL},
</if>
<if test="tableId != null">
table_id = #{tableId,jdbcType=VARCHAR},
</if>
<if test="smallChange != null">
small_change = #{smallChange,jdbcType=DECIMAL},
</if>
<if test="sendType != null">
send_type = #{sendType,jdbcType=VARCHAR},
</if>
<if test="orderType != null">
order_type = #{orderType,jdbcType=VARCHAR},
</if>
<if test="productType != null">
product_type = #{productType,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="billingId != null">
billing_id = #{billingId,jdbcType=VARCHAR},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=VARCHAR},
</if>
<if test="isVip != null">
is_vip = #{isVip,jdbcType=TINYINT},
</if>
<if test="memberId != null">
member_id = #{memberId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="productScore != null">
product_score = #{productScore,jdbcType=INTEGER},
</if>
<if test="deductScore != null">
deduct_score = #{deductScore,jdbcType=INTEGER},
</if>
<if test="userCouponId != null">
user_coupon_id = #{userCouponId,jdbcType=VARCHAR},
</if>
<if test="userCouponAmount != null">
user_coupon_amount = #{userCouponAmount,jdbcType=DECIMAL},
</if>
<if test="refundAble != null">
refund_able = #{refundAble,jdbcType=TINYINT},
</if>
<if test="paidTime != null">
paid_time = #{paidTime,jdbcType=BIGINT},
</if>
<if test="isEffect != null">
is_effect = #{isEffect,jdbcType=TINYINT},
</if>
<if test="isGroup != null">
is_group = #{isGroup,jdbcType=TINYINT},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=BIGINT},
</if>
<if test="systemTime != null">
system_time = #{systemTime,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=BIGINT},
</if>
<if test="isAccepted != null">
is_accepted = #{isAccepted,jdbcType=TINYINT},
</if>
<if test="payOrderNo != null">
pay_order_no = #{payOrderNo,jdbcType=VARCHAR},
</if>
<if test="masterId != null">
master_id = #{masterId,jdbcType=VARCHAR},
</if>
<if test="remark != null and remark!=''">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="staffId != null and staffId!=''">
staff_id = #{staffId,jdbcType=INTEGER},
</if>
<if test="useType != null and useType!=''">
use_type = #{useType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
update tb_order_info
set order_no = #{orderNo,jdbcType=VARCHAR},
settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
pack_fee = #{packFee,jdbcType=DECIMAL},
origin_amount = #{originAmount,jdbcType=DECIMAL},
product_amount = #{productAmount,jdbcType=DECIMAL},
amount = #{amount,jdbcType=DECIMAL},
refund_amount = #{refundAmount,jdbcType=DECIMAL},
pay_type = #{payType,jdbcType=VARCHAR},
pay_amount = #{payAmount,jdbcType=DECIMAL},
order_amount = #{orderAmount,jdbcType=DECIMAL},
freight_amount = #{freightAmount,jdbcType=DECIMAL},
discount_ratio = #{discountRatio,jdbcType=DECIMAL},
discount_amount = #{discountAmount,jdbcType=DECIMAL},
table_id = #{tableId,jdbcType=VARCHAR},
small_change = #{smallChange,jdbcType=DECIMAL},
send_type = #{sendType,jdbcType=VARCHAR},
order_type = #{orderType,jdbcType=VARCHAR},
product_type = #{productType,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
billing_id = #{billingId,jdbcType=VARCHAR},
merchant_id = #{merchantId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
is_vip = #{isVip,jdbcType=TINYINT},
member_id = #{memberId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
product_score = #{productScore,jdbcType=INTEGER},
deduct_score = #{deductScore,jdbcType=INTEGER},
user_coupon_id = #{userCouponId,jdbcType=VARCHAR},
user_coupon_amount = #{userCouponAmount,jdbcType=DECIMAL},
refund_able = #{refundAble,jdbcType=TINYINT},
paid_time = #{paidTime,jdbcType=BIGINT},
is_effect = #{isEffect,jdbcType=TINYINT},
is_group = #{isGroup,jdbcType=TINYINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
system_time = #{systemTime,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=BIGINT},
is_accepted = #{isAccepted,jdbcType=TINYINT},
pay_order_no = #{payOrderNo,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusById">
update tb_order_info set status = #{status} where id = #{orderId}
</update>
<select id="selectAllByStatus" resultMap="BaseResultMap">
select * from tb_order_info where `status`=#{status} and order_type !='miniapp'
</select>
<select id="selectByTradeAndMasterId"
resultType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
select * from tb_order_info where trade_day = #{day} and table_id = #{masterId} and shop_id = #{shopId}
</select>
<select id="selectByOutNumber" resultMap="BaseResultMap">
select * from tb_order_info where trade_day = #{tradeDay} and out_number=#{outNumber} and shop_id=#{shopId}
</select>
<select id="selectByOutNumberLimit" resultMap="BaseResultMap">
select * from tb_order_info where out_number=#{outNumber} and shop_id=#{shopId} order by id desc limit 1
</select>
<select id="selectByOrderId" resultType="java.util.Map">
SELECT
GROUP_CONCAT( d.product_name ) AS product_names,
GROUP_CONCAT( d.product_sku_name ) AS product_sku_name
FROM
tb_order_detail d
WHERE
d.order_id = #{orderId}
GROUP BY
d.order_id
</select>
<select id="selectSkuByOrderId" resultType="com.chaozhanggui.system.cashierservice.entity.po.SkuInfoPo">
SELECT
d.product_name AS productName,
d.num,
d.product_sku_name AS productSkuName,
c.category_id AS categoryId,
d.price_amount as priceAmount,
d.pack_amount as packAmount
FROM
tb_order_detail d
LEFT JOIN tb_cashier_cart c ON d.order_id = c.order_id
AND d.product_sku_id = c.sku_id
where c.order_id=#{orderId}
</select>
<select id="selectById" resultMap="BaseResultMap">
select * from tb_order_info where id=#{id} and status='closed'
</select>
<select id="selectSkuByOrderIdAndType" resultType="com.chaozhanggui.system.cashierservice.entity.po.SkuInfoPo">
SELECT
d.product_name AS productName,
d.num,
d.product_sku_name AS productSkuName,
'' AS categoryId,
d.price_amount as priceAmount,
d.pack_amount as packAmount,
d.price as price
FROM
tb_order_detail d
where d.order_id=#{orderId}
</select>
<select id="selectActivateOrder" resultType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
SELECT * FROM `tb_order_info` where shop_id=#{shopId} and
table_id=#{tableId} and order_type != 'return' and `status` not in ('closed', 'refund', 'merge')
</select>
</mapper>