You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
5.5 KiB
135 lines
5.5 KiB
|
1 year ago
|
<?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="cc.hiver.mall.purchaseconfirm.mapper.PurchaseConfirmMapper">
|
||
|
|
<resultMap id="BaseResultMap" type="cc.hiver.mall.purchaseconfirm.entity.PurchaseConfirm">
|
||
|
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||
|
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||
|
|
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" />
|
||
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||
|
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
|
||
|
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||
|
|
<result column="purchase_id" jdbcType="VARCHAR" property="purchaseId" />
|
||
|
|
<result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
|
||
|
|
<result column="supplier_name" jdbcType="VARCHAR" property="supplierName" />
|
||
|
|
<result column="purchase_time" jdbcType="INTEGER" property="purchaseTime" />
|
||
|
|
</resultMap>
|
||
|
|
<sql id="Base_Column_List">
|
||
|
|
id, create_by,create_by_name, create_time, del_flag, update_by, update_time,purchase_id,supplier_id,supplier_name,purchase_time
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<!-- -->
|
||
|
|
<update id="updatePurchaseConfirmDelFlag" parameterType="java.lang.String">
|
||
|
|
update t_purchase_confirm
|
||
|
|
set del_flag = #{delFlag,jdbcType=VARCHAR}
|
||
|
|
where id = #{id,jdbcType=VARCHAR}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="notConfirmPurductCount" resultType="java.lang.Integer">
|
||
|
|
SELECT
|
||
|
|
COALESCE(SUM(pcd.product_count), 0) AS total_product_count
|
||
|
|
FROM
|
||
|
|
t_purchase_confirm_details pcd
|
||
|
|
JOIN
|
||
|
|
t_purchase_confirm pc ON pcd.purchase_confirm_id = pc.id
|
||
|
|
WHERE
|
||
|
|
pc.supplier_id = #{supplierId,jdbcType=VARCHAR}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="purchaseNotConfirmPurductCount" resultType="cc.hiver.mall.purchaseconfirm.vo.PurchaseConfirmVo">
|
||
|
|
SELECT
|
||
|
|
pc.purchase_id,
|
||
|
|
pc.create_by_name,
|
||
|
|
pc.purchase_time,
|
||
|
|
COALESCE(SUM(pcd.product_count), 0) AS total_unshipped_count
|
||
|
|
FROM
|
||
|
|
t_purchase_confirm pc
|
||
|
|
JOIN
|
||
|
|
t_purchase_confirm_details pcd ON pc.id = pcd.purchase_confirm_id
|
||
|
|
WHERE
|
||
|
|
pcd.product_count > 0 -- 未发货的记录
|
||
|
|
AND pc.supplier_id = #{supplierId,jdbcType=VARCHAR}
|
||
|
|
GROUP BY
|
||
|
|
pc.purchase_id,pc.create_by_name,pc.purchase_time;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="productNotConfirmPurductCount" resultType="cc.hiver.mall.purchaseconfirm.vo.PurchaseConfirmVo">
|
||
|
|
SELECT
|
||
|
|
pcd.product_id,
|
||
|
|
pcd.product_name,
|
||
|
|
pcd.product_sn,
|
||
|
|
COALESCE(SUM(pcd.product_count), 0) AS total_unshipped_count
|
||
|
|
FROM
|
||
|
|
t_purchase_confirm pc
|
||
|
|
JOIN
|
||
|
|
t_purchase_confirm_details pcd ON pc.id = pcd.purchase_confirm_id
|
||
|
|
WHERE
|
||
|
|
pcd.product_count > 0
|
||
|
|
AND pc.supplier_id = #{supplierId,jdbcType=VARCHAR}
|
||
|
|
GROUP BY
|
||
|
|
pcd.product_id,
|
||
|
|
pcd.product_name,
|
||
|
|
pcd.product_sn;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="shopNotConfirmPurductCount" resultType="java.lang.Integer">
|
||
|
|
SELECT
|
||
|
|
COALESCE(SUM(pcd.product_count), 0) AS total_product_count
|
||
|
|
FROM
|
||
|
|
t_purchase_confirm_details pcd
|
||
|
|
JOIN
|
||
|
|
t_purchase_confirm pc ON pcd.purchase_confirm_id = pc.id
|
||
|
|
JOIN
|
||
|
|
t_purchase p ON pc.purchase_id = p.id
|
||
|
|
WHERE
|
||
|
|
p.shop_id = #{shopId,jdbcType=VARCHAR}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="supplierNotConfirmPurductCount" resultType="cc.hiver.mall.purchaseconfirm.vo.PurchaseConfirmVo">
|
||
|
|
SELECT
|
||
|
|
pc.supplier_id,
|
||
|
|
COALESCE(SUM(pcd.product_count), 0) AS total_unshipped_count
|
||
|
|
FROM
|
||
|
|
t_purchase_confirm pc
|
||
|
|
JOIN
|
||
|
|
t_purchase_confirm_details pcd ON pc.id = pcd.purchase_confirm_id
|
||
|
|
WHERE
|
||
|
|
pcd.product_count > 0 -- 未发货的记录
|
||
|
|
AND pc.supplier_id in
|
||
|
|
<foreach close=")" collection="supplierIdList" item="listItem" open="(" separator=",">
|
||
|
|
#{listItem}
|
||
|
|
</foreach>
|
||
|
|
GROUP BY
|
||
|
|
pc.supplier_id; -- 根据 t_purchase_confirm_details 的 product_id 分组
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectByPurchaseId" resultMap="BaseResultMap">
|
||
|
|
select
|
||
|
|
<include refid="Base_Column_List" />
|
||
|
|
from t_purchase_confirm a
|
||
|
|
where a.purchase_id = #{purchaseId,jdbcType=VARCHAR}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getPurchaseConfirmDetailsByProductId" resultType="cc.hiver.mall.purchaseconfirm.vo.PurchaseConfirmVo">
|
||
|
|
SELECT
|
||
|
|
pcd.id as purchase_confirmdetails_id,
|
||
|
|
pcd.product_id,
|
||
|
|
pcd.product_name,
|
||
|
|
pcd.product_sn,
|
||
|
|
COALESCE(pcd.product_count, 0) AS total_unshipped_count,
|
||
|
|
pc.purchase_time,
|
||
|
|
pc.create_by_name
|
||
|
|
FROM
|
||
|
|
t_purchase_confirm_details pcd
|
||
|
|
left JOIN
|
||
|
|
t_purchase_confirm pc ON pc.id = pcd.purchase_confirm_id
|
||
|
|
WHERE
|
||
|
|
pcd.product_count > 0
|
||
|
|
AND pcd.product_id = #{productId,jdbcType=VARCHAR}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<delete id="deleteByPurchaseId" parameterType="java.lang.String">
|
||
|
|
delete from t_purchase_confirm
|
||
|
|
where purchase_id = #{purchaseId,jdbcType=VARCHAR}
|
||
|
|
</delete>
|
||
|
|
</mapper>
|