From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 java110-db/src/main/resources/mapper/goods/ProductSpecValueServiceDaoImplMapper.xml |   56 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/goods/ProductSpecValueServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/goods/ProductSpecValueServiceDaoImplMapper.xml
old mode 100644
new mode 100755
index b9c19b7..363b807
--- a/java110-db/src/main/resources/mapper/goods/ProductSpecValueServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/goods/ProductSpecValueServiceDaoImplMapper.xml
@@ -8,9 +8,9 @@
     <!-- 淇濆瓨浜у搧瑙勬牸鍊间俊鎭� add by wuxw 2018-07-03 -->
     <insert id="saveProductSpecValueInfo" parameterType="Map">
         insert into product_spec_value(
-        spec_id,value_id,product_id,price,ot_price,cost_price,vip_price,store_id,stock,sales
+        spec_id,value_id,product_id,price,ot_price,cost_price,vip_price,store_id,stock,sales,is_default
         ) values (
-        #{specId},#{valueId},#{productId},#{price},#{otPrice},#{costPrice},#{vipPrice},#{storeId},#{stock},#{sales}
+        #{specId},#{valueId},#{productId},#{price},#{otPrice},#{costPrice},#{vipPrice},#{storeId},#{stock},#{sales},#{isDefault}
         )
     </insert>
 
@@ -19,8 +19,10 @@
     <select id="getProductSpecValueInfo" parameterType="Map" resultType="Map">
         select t.spec_id,t.spec_id specId,t.value_id,t.value_id valueId,t.product_id,t.product_id
         productId,t.price,t.ot_price,t.ot_price otPrice,t.cost_price,t.cost_price costPrice,t.vip_price,t.vip_price
-        vipPrice,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.stock,t.sales
+        vipPrice,t.status_cd,t.status_cd statusCd,t.store_id,t.store_id storeId,t.stock,t.sales,ps.spec_name specName,
+        t.is_default isDefault
         from product_spec_value t
+        left join product_spec ps on t.spec_id = ps.spec_id and ps.store_id = t.store_id and ps.status_cd = '0'
         where 1 =1
         <if test="specId !=null and specId != ''">
             and t.spec_id= #{specId}
@@ -55,6 +57,9 @@
         <if test="sales !=null and sales != ''">
             and t.sales= #{sales}
         </if>
+        <if test="isDefault !=null and isDefault != ''">
+            and t.is_default= #{isDefault}
+        </if>
         order by t.create_time desc
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
@@ -63,18 +68,35 @@
     </select>
 
 
+    <!-- 鏌ヨ浜у搧搴撳瓨鍜岄攢閲� add by wuxw 2018-07-03 -->
+    <select id="queryProductStockAndSales" parameterType="Map" resultType="Map">
+        select t.product_id productId,sum(t.stock) stock,SUM(t.sales) sales
+        from product_spec_value t
+        where 1 =1
+        and t.status_cd= '0'
+        <if test="productId !=null and productId != ''">
+            and t.product_id= #{productId}
+        </if>
+        <if test="productIds != null">
+            and t.product_id in
+            <foreach collection="productIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
+        group by t.product_id
+    </select>
+
     <!-- 淇敼浜у搧瑙勬牸鍊间俊鎭� add by wuxw 2018-07-03 -->
     <update id="updateProductSpecValueInfo" parameterType="Map">
         update product_spec_value t set t.status_cd = #{statusCd}
-        <if test="newBId != null and newBId != ''">
-            ,t.b_id = #{newBId}
-        </if>
+
         <if test="specId !=null and specId != ''">
             , t.spec_id= #{specId}
         </if>
-        <if test="productId !=null and productId != ''">
-            , t.product_id= #{productId}
-        </if>
+
         <if test="price !=null and price != ''">
             , t.price= #{price}
         </if>
@@ -87,18 +109,25 @@
         <if test="vipPrice !=null and vipPrice != ''">
             , t.vip_price= #{vipPrice}
         </if>
-        <if test="storeId !=null and storeId != ''">
-            , t.store_id= #{storeId}
-        </if>
+
         <if test="stock !=null and stock != ''">
             , t.stock= #{stock}
         </if>
         <if test="sales !=null and sales != ''">
             , t.sales= #{sales}
         </if>
+        <if test="isDefault !=null and isDefault != ''">
+            , t.is_default= #{isDefault}
+        </if>
         where 1=1
         <if test="valueId !=null and valueId != ''">
             and t.value_id= #{valueId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            and t.product_id= #{productId}
+        </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
         </if>
 
     </update>
@@ -141,6 +170,9 @@
         <if test="sales !=null and sales != ''">
             and t.sales= #{sales}
         </if>
+        <if test="isDefault !=null and isDefault != ''">
+            and t.is_default= #{isDefault}
+        </if>
 
 
     </select>

--
Gitblit v1.8.0