qihang-ecom-erp-open/module/order/src/main/resources/mapper/OOrderItemMapper.xml

104 lines
4.9 KiB
XML
Raw Normal View History

2025-03-02 19:10:17 +08:00
<?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.qihangerp.module.order.mapper.OOrderItemMapper">
<resultMap id="BaseResultMap" type="cn.qihangerp.module.order.domain.OOrderItem">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="orderId" column="order_id" jdbcType="BIGINT"/>
<result property="subOrderNum" column="sub_order_num" jdbcType="VARCHAR"/>
<result property="skuId" column="sku_id" jdbcType="VARCHAR"/>
<result property="goodsId" column="goods_id" jdbcType="BIGINT"/>
<result property="goodsSkuId" column="goods_sku_id" jdbcType="BIGINT"/>
<result property="goodsTitle" column="goods_title" jdbcType="VARCHAR"/>
<result property="goodsImg" column="goods_img" jdbcType="VARCHAR"/>
<result property="goodsNum" column="goods_num" jdbcType="VARCHAR"/>
<result property="goodsSpec" column="goods_spec" jdbcType="VARCHAR"/>
<result property="skuNum" column="sku_num" jdbcType="VARCHAR"/>
<result property="goodsPrice" column="goods_price" jdbcType="DOUBLE"/>
<result property="itemAmount" column="item_amount" jdbcType="DOUBLE"/>
<result property="discountAmount" column="discount_amount" jdbcType="DOUBLE"/>
<result property="payment" column="payment" jdbcType="DOUBLE"/>
<result property="quantity" column="quantity" jdbcType="INTEGER"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="refundCount" column="refund_count" jdbcType="INTEGER"/>
<result property="refundStatus" column="refund_status" jdbcType="INTEGER"/>
<result property="orderStatus" column="order_status" jdbcType="INTEGER"/>
<result property="hasPushErp" column="has_push_erp" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,order_id,sub_order_num,
sku_id,goods_id,goods_sku_id,
goods_title,goods_img,goods_num,
goods_spec,sku_num,goods_price,discount_amount,
item_amount,payment,quantity,remark,
refund_count,refund_status,order_status,has_push_erp,create_time,
create_by,update_time,update_by
</sql>
<select id="selectPageVo" parameterType="cn.qihangerp.module.order.domain.bo.OrderItemListBo" resultType="cn.qihangerp.module.order.domain.vo.OrderItemListVo">
SELECT
oi.*,o.shop_id,o.order_time,gs.outer_erp_sku_id
FROM o_order_item as oi
left join o_order as o on o.id = oi.order_id
left join o_goods_sku as gs on gs.id = oi.goods_sku_id
WHERE 1=1
<if test="qw.shopId!=null">
and o.shop_id = #{qw.shopId}
</if>
<if test="qw.orderNum!=null and qw.orderNum !=''">
and oi.order_num = #{qw.orderNum}
</if>
<if test="qw.subOrderNum != null and qw.subOrderNum !=''">
and oi.sub_order_num = #{qw.subOrderNum}
</if>
<if test="qw.refundStatus!=null">
and oi.refund_status = #{qw.refundStatus}
</if>
<if test="qw.startTime!=null and qw.startTime != ''">
and o.order_time &gt;= #{qw.startTime}
</if>
<if test="qw.endTime!=null and qw.endTime != ''">
and o.order_time &lt;= #{qw.endTime}
</if>
<if test="qw.hasLink != null and qw.hasLink == 0">
AND (oi.goods_sku_id is NULL or oi.goods_sku_id = 0)
</if>
<if test="qw.hasLink != null and qw.hasLink == 1">
AND oi.goods_sku_id is NOT NULL and oi.goods_sku_id != 0
</if>
</select>
<select id="selectOrderItemListByOrderId" parameterType="Long" resultType="cn.qihangerp.module.order.domain.vo.OrderItemListVo">
SELECT
oi.*,o.shop_id,o.order_time,gs.outer_erp_sku_id
FROM o_order_item as oi
left join o_order as o on o.id = oi.order_id
left join o_goods_sku as gs on gs.id = oi.goods_sku_id
WHERE oi.order_id = #{orderId}
</select>
<select id="selectTopSku" resultType="cn.qihangerp.module.order.domain.vo.SalesTopSkuVo">
SELECT
sku_num as `name`,
SUM(quantity) AS `value`
FROM
o_order_item
WHERE
create_time BETWEEN #{startDate} AND #{endDate}
AND sku_num IS NOT NULL AND sku_num != ''
GROUP BY
sku_num
ORDER BY
`value` DESC
LIMIT 10;
</select>
</mapper>