From c253b555c7905c5136d47cd615ef545fa50cc6ad Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Sun, 20 Feb 2022 21:24:16 +0800
Subject: [PATCH] Merge branch 'api_score_meger'

---
 zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderItemDao.xml |   74 ++++++++++++++++++++++++++++++------
 1 files changed, 61 insertions(+), 13 deletions(-)

diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderItemDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderItemDao.xml
index 208e3ec..2e2de04 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderItemDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysOrderItemDao.xml
@@ -10,6 +10,7 @@
         <!-- <result property="projId" column="PROJ_ID" />
         <result property="skuId" column="SKU_ID" /> -->
         <result property="count" column="COUNT"/>
+        <result property="refundCount" column="refundCount"/>
         <!-- <result property="taocanId" column="TAOCAN_ID" /> -->
         <result property="isFree" column="IS_FREE"/>
         <result property="type" column="TYPE"/>
@@ -33,6 +34,7 @@
                      resultMap="com.matrix.system.hive.dao.ShoppingGoodsDao.ShoppingGoodsSimpleMap"></association>
 
 
+
     </resultMap>
 
     <!-- 查询会员待处理的订单商品 -->
@@ -48,6 +50,7 @@
 		a.TOTAL,
 		a.SKU_ID,
 		b.COUNT,
+		b.refundCount,
 		b.ID,
 		b.IS_FREE,
 		b.ORDER_ID,
@@ -88,6 +91,7 @@
 		ID,
 		ORDER_ID,
 		COUNT,
+		refundCount,
 		TYPE,
 		IS_FREE,
 		PRICE,
@@ -105,6 +109,7 @@
 		#{id},
 		#{orderId},
 		#{count},
+		#{refundCount},
 		#{type},
 		#{isFree},
 		#{price},
@@ -128,8 +133,11 @@
             <if test="orderId != null and orderId !='' ">
                 ORDER_ID = #{orderId},
             </if>
-            <if test="count != null and count !='' ">
+            <if test="count != null and count !='' or count == 0 ">
                 COUNT = #{count},
+            </if>
+            <if test="refundCount != null and refundCount !='' or refundCount == 0 ">
+                refundCount = #{refundCount},
             </if>
             <if test="isFree != null and isFree !='' ">
                 IS_FREE = #{isFree},
@@ -231,6 +239,7 @@
 		i.ID,
 		i.ORDER_ID,
 		i.COUNT,
+		i.refundCount,
 		i.TYPE,
 		i.IS_FREE,
 		i.PRICE,
@@ -250,11 +259,11 @@
 		g.is_course,
 		g.car_use_count,
 		g.good_type,
-		g.code
-
-
+		g.code,
+		g.goods_no,
+		g.name
 		from sys_order_item i
-		left  join shopping_goods g on i.goods_id=g.id
+		left join shopping_goods g on i.goods_id=g.id
 		where ORDER_ID =#{orderId}
 	</select>
 
@@ -266,10 +275,13 @@
     </select>
     <!-- 根据商品id查询改商品下单次数总和-->
     <select id="selectByGoodsId" resultType="java.lang.Integer">
-	    select sum(COUNT) from sys_order_item a
+	    select IFNULL(sum(COUNT),0) AS total from sys_order_item a
 	    left join  sys_order b on b.ID=a.ORDER_ID
-	    where a.GOODS_ID = #{goodsId} 
-	    and b.STATU !='已取消'
+	    where a.GOODS_ID = #{goodsId}
+	    <if test="vipId != null">
+            and b.vip_id=#{vipId}
+        </if>
+	    and b.STATU ='已付款'
 	</select>
 
 
@@ -288,6 +300,7 @@
 		ID,
 		ORDER_ID,
 		COUNT,
+		refundCount,
 		TYPE,
 		IS_FREE,
 		PRICE,
@@ -340,10 +353,12 @@
         c.name as goodsName,
         g.name as cateName,
         a.COUNT,
+        a.COUNT *  a.ZK_PRICE as total,
+        a.refundCount,
         a.ZK_PRICE,
         a.IS_FREE,
         a.pay_method,
-        a.status
+        b.statu
         from sys_order_item a
         left join sys_order b on a.ORDER_ID=b.ID
         left join shopping_goods c on a.goods_id=c.id
@@ -383,8 +398,8 @@
             <if test="guwenId != null and guwenId != ''  ">
                 and  b.STAFF_ID=#{guwenId}
             </if>
-            <if test="status != null and status != ''  ">
-                and  a.status=#{status}
+            <if test="statu != null and statu != ''  ">
+                and  b.statu=#{statu}
             </if>
 
         </where>
@@ -435,8 +450,8 @@
             <if test="guwenId != null and guwenId != ''  ">
                 and  b.STAFF_ID=#{guwenId}
             </if>
-            <if test="status != null and status != ''  ">
-                and  a.status=#{status}
+            <if test="statu != null and statu != ''  ">
+                and  b.statu=#{statu}
             </if>
         </where>
     </select>
@@ -519,5 +534,38 @@
         group by c.id ,f.id) t
     </select>
 
+    <select id="selectApiOrderDetailItemsByOrderId" resultType="com.matrix.system.app.vo.OrderDetailItemVo">
+        select
+               a.id id,
+               b.name goodsName,
+               a.COUNT count,
+               a.cash_Pay cashPay,
+               a.card_Pay cardPay,
+               a.PRICE price,
+               a.ZK_PRICE zkPrice,
+               a.status status
+        from sys_order_item a
+        inner join shopping_goods b on a.goods_id=b.id
+        where a.ORDER_ID=#{orderId};
+    </select>
+
+    <select id="selectErpOrderItemByOrderId"
+            resultType="com.matrix.system.shopXcx.api.vo.ErpOrderDetailItemVo">
+            select
+               b.name goodsName,
+               a.COUNT count,
+               a.PRICE price,
+               a.ZK_PRICE zkPrice
+        from sys_order_item a
+        inner join shopping_goods b on a.goods_id=b.id
+        where a.ORDER_ID=#{orderId}
+    </select>
+
+    <!-- 临时数据处理sql -->
+    <select id="selectDgd" resultMap="SysOrderItemMap">
+        SELECT a.* from sys_order_item a
+                            left join sys_order b on a.ORDER_ID=b.id
+        where a.type='家居产品' and DATE_FORMAT(a.create_time,'%Y-%m')='2021-04' and b.company_id=17 and b.STATU='已付款';
+    </select>
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1