zhaoxian 3 år sedan
förälder
incheckning
47d7a11b62

+ 26 - 26
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/material/mapper/xml/ProductMaterialMapper.xml

@@ -39,22 +39,23 @@
         select
         trade_name
         FROM ctop_product_material
-        where video_url!=''
-        <if test="productId!=null">
-            and product_id = #{productId}
-        </if>
-        <if test="tradeName!=null">
-            and trade_name like CONCAT(CONCAT('%', #{tradeName}), '%')
-        </if>
-        <if test="startMonth!=null">
-            and start_month >= #{startMonth}
-        </if>
-        <if test="endMonth!=null">
-            and end_month &lt;= #{endMonth}
-        </if>
-        <if test="itemRun!=null">
-            and item_run = #{itemRun}
-        </if>
+        <where>
+            <if test="productId!=null">
+                and product_id = #{productId}
+            </if>
+            <if test="tradeName!=null">
+                and trade_name like CONCAT(CONCAT('%', #{tradeName}), '%')
+            </if>
+            <if test="startMonth!=null">
+                and start_month >= #{startMonth}
+            </if>
+            <if test="endMonth!=null">
+                and end_month &lt;= #{endMonth}
+            </if>
+            <if test="itemRun!=null">
+                and item_run = #{itemRun}
+            </if>
+        </where>
         group by product_id,trade_name
         ) t
     </select>
@@ -70,7 +71,7 @@
         IFNULL(sum(t2.charge),0.00) as 'charge',
         CONCAT(t1.start_month,' ~ ',t1.end_month) as 'time',
         IFNULL(t3.realname,'-') as 'user',
-        t4.videoCount
+        IFNULL(t4.videoCount ,'-') as 'videoCount'
         FROM ctop_product_material t1
         LEFT JOIN
         (
@@ -89,12 +90,10 @@
         GROUP BY signature
         ) t2 ON t1.signature = t2.signature
         LEFT JOIN (select id, realname from sys_user) t3 on t1.user_id =t3.id
-        LEFT JOIN (
-        SELECT product_id,trade_name,COUNT(signature) as 'videoCount' FROM ctop_product_material
-        WHERE video_url!=''
-        GROUP BY product_id,trade_name
-        ) t4 ON t1.product_id = t4.product_id AND t1.trade_name= t4.trade_name
-        where video_url!=''
+        LEFT JOIN ( SELECT product_id, trade_name, COUNT( signature ) AS 'videoCount' FROM ctop_product_material
+        WHERE video_url is not null
+        GROUP BY product_id,trade_name,signature) t4 ON t1.product_id = t4.product_id AND t1.trade_name= t4.trade_name
+        <where>
         <if test="productId!=null">
             and t1.product_id = #{productId}
         </if>
@@ -110,6 +109,7 @@
         <if test="itemRun!=null">
             and t1.item_run = #{itemRun}
         </if>
+        </where>
         group by t1.product_id,t1.trade_name
     </select>
 
@@ -118,7 +118,7 @@
         from (
                  select trade_name
                  FROM ctop_product_material
-                 WHERE video_url!=''
+                 WHERE video_url is not null
                    and product_id = #{productId}
                    and trade_name = #{tradeName}
                    and start_month >= #{startMonth}
@@ -144,7 +144,7 @@
             GROUP BY signature
         ) t2 ON t1.signature = t2.signature
                  LEFT JOIN (select id, realname from sys_user) t3 on t1.user_id = t3.id
-        WHERE video_url!=''
+        WHERE video_url is not null
         and product_id = #{productId}
           and trade_name = #{tradeName}
           and start_month >= #{startMonth}
@@ -182,7 +182,7 @@
         GROUP BY signature
         ) t2 ON t1.signature = t2.signature AND t1.product_id=t2.product_id
         LEFT JOIN (select id, realname from sys_user) t3 on t1.user_id =t3.id
-        where video_url!=''
+        where video_url is not null
         <if test="productId!=null">
             and t1.product_id = #{productId}
         </if>