From 7c2c6a5e5b3d9f96aef3c67573aa62bbd9a3aa7f Mon Sep 17 00:00:00 2001
From: p-honggang.li <p-honggang.li@pcitc.com>
Date: 星期四, 11 九月 2025 10:48:18 +0800
Subject: [PATCH] 修改产品类型,单位工程条偶见查询问题

---
 src/main/resources/mapper/CartMapper.xml |   50 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/main/resources/mapper/CartMapper.xml b/src/main/resources/mapper/CartMapper.xml
index 086a599..1226da6 100644
--- a/src/main/resources/mapper/CartMapper.xml
+++ b/src/main/resources/mapper/CartMapper.xml
@@ -4,10 +4,10 @@
     
     <resultMap id="BaseResultMap" type="com.webmanage.entity.Cart">
         <id column="id" property="id" jdbcType="BIGINT"/>
-        <result column="user_id" property="userId" jdbcType="BIGINT"/>
-        <result column="unit_id" property="unitId" jdbcType="BIGINT"/>
+        <result column="user_id" property="userId" jdbcType="VARCHAR"/>
+        <result column="unit_id" property="unitId" jdbcType="VARCHAR"/>
         <result column="pricing_id" property="pricingId" jdbcType="BIGINT"/>
-        <result column="product_id" property="productId" jdbcType="BIGINT"/>
+        <result column="product_id" property="productId" jdbcType="VARCHAR"/>
         <result column="product_name" property="productName" jdbcType="VARCHAR"/>
         <result column="suite_name" property="suiteName" jdbcType="VARCHAR"/>
         <result column="sales_form" property="salesForm" jdbcType="VARCHAR"/>
@@ -37,37 +37,55 @@
     
     <select id="selectByUserIdAndUnitId" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM cart
+        FROM tb_cart
         WHERE deleted = 0 
-        AND user_id = #{userId} 
-        AND unit_id = #{unitId}
+        AND user_id = #{userId}
+        <if test="unitId !=null and unitId != ''">
+            AND unit_id = #{unitId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            AND product_id = #{productId}
+        </if>
         ORDER BY add_time DESC
     </select>
     
     <select id="selectByUserIdUnitIdAndPricingId" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM cart
-        WHERE deleted = 0 
-        AND user_id = #{userId} 
-        AND unit_id = #{unitId}
+        FROM tb_cart
+        WHERE deleted = 0
+        AND user_id = #{userId}
+        <if test="unitId != '' and unitId != null">
+            AND unit_id = #{unitId}
+        </if>
         AND pricing_id = #{pricingId}
+        AND product_id = #{productId}
         LIMIT 1
     </select>
     
     <select id="countByUserIdAndUnitId" resultType="java.lang.Integer">
         SELECT COUNT(*)
-        FROM cart
+        FROM tb_cart
         WHERE deleted = 0 
-        AND user_id = #{userId} 
-        AND unit_id = #{unitId}
+        AND user_id = #{userId}
+        <if test="unitId != '' and unitId != null">
+            AND unit_id = #{unitId}
+        </if>
+        <if test="productId != '' and productId != null">
+            AND product_id = #{productId}
+        </if>
     </select>
     
     <select id="sumTotalAmountByUserIdAndUnitId" resultType="java.math.BigDecimal">
         SELECT COALESCE(SUM(total_price), 0)
-        FROM cart
+        FROM tb_cart
         WHERE deleted = 0 
-        AND user_id = #{userId} 
-        AND unit_id = #{unitId}
+        AND user_id = #{userId}
+        <if test="unitId != '' and unitId != null">
+            AND unit_id = #{unitId}
+        </if>
     </select>
+    <delete id="deleteByCustomerCondition">
+        delete from tb_cart where id = #{id}
+    </delete>
     
 </mapper>

--
Gitblit v1.8.0