From 1cda9be49d77c83bdab4cfea7e3558fd4064bdb1 Mon Sep 17 00:00:00 2001
From: seatonwan9
Date: 星期四, 28 八月 2025 02:03:11 +0800
Subject: [PATCH] 更新代码

---
 src/main/resources/mapper/CartMapper.xml |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/src/main/resources/mapper/CartMapper.xml b/src/main/resources/mapper/CartMapper.xml
index 3d56c30..22f7e4c 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,40 +37,48 @@
     
     <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>
         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}
         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>
     </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 cart where id = #{id}
+        delete from tb_cart where id = #{id}
     </delete>
     
 </mapper>

--
Gitblit v1.8.0