Pārlūkot izejas kodu

数据统计 总退款余额

zoujiajian 4 mēneši atpakaļ
vecāks
revīzija
c0043becb2

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/OrderDonMapper.java

@@ -107,4 +107,6 @@ public interface OrderDonMapper extends BaseMapper<OrderDon> {
 	UserDistributeOrderDataDto selectUserDistributeOrders(@Param("sharedId") Long sharedId, @Param("startTime") String startTime, @Param("endTime") String endTime);
 
 	BigDecimal getSumMoneyZfbThisMonth(@Param("shopId") String shopId, @Param("start") DateTime start, @Param("end") DateTime end);
+
+    BigDecimal getTotalRefundBalanceTime(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/views/BackgroundDataView.java

@@ -47,6 +47,11 @@ public class BackgroundDataView {
 	 */
 	private BigDecimal totalRefundAmount;
 
+    /**
+     * 退款余额
+     */
+    private BigDecimal totalRefundBalance;
+
 	/**
 	 * 近5天将要到期的主账号总数
 	 */

+ 14 - 1
netflix-dao/src/main/resources/mapper/OrderDonMapper.xml

@@ -201,7 +201,8 @@
         count(id) as totalNumOfOrder,
         cast(ifnull(sum(money),0)/100 as decimal(11,2)) as totalOrderAmount,
         count(if(status = 'refund',1,NULL)) as totalNumOfRefundOrder,
-        cast(sum(ifnull(refund_money,0))/100 as decimal(11,2)) as totalRefundAmount
+        cast(sum(ifnull(refund_money,0))/100 as decimal(11,2)) as totalRefundAmount,
+        cast(sum(ifnull(refund_balance,0))/100 as decimal(11,2)) as totalRefundBalance
         from `order_don` where status not in
         <foreach collection="noOrderStatus" item="item" open="(" separator="," close=")">
             #{item}
@@ -641,4 +642,16 @@
     <select id="getSumMoneyZfbThisMonth" resultType="java.math.BigDecimal">
         select ifnull(sum(money) - sum(ifnull(refund_money,0)),0) from order_don where shop_id = #{shopId} and status not in ('close','noPayment') and created_time between #{start} and #{end}
     </select>
+
+    <select id="getTotalRefundBalanceTime" resultType="java.math.BigDecimal">
+        select cast(ifnull(sum(ifnull(refund_balance,0)),0)/100 as decimal(11,2))
+        from refund_order_don
+        where (refund_method in ('balance','bxj') or is_clear_balance = 1)
+        <if test="startDate != null">
+            and created_time >= #{startDate}
+        </if>
+        <if test="endDate != null">
+            and created_time &lt; #{endDate}
+        </if>
+    </select>
 </mapper>

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/mange/statistics/impl/StatisticsDataServiceImpl.java

@@ -1106,6 +1106,9 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
 		if (startDate != null || endDate != null) {
 			BigDecimal totalRefundMoney = orderDonMapper.getTotalRefundAmountTime(startDate, endDate);
 			backgroundDataView.setTotalRefundAmount(totalRefundMoney);
+            //退款余额
+            BigDecimal totalRefundBalance = orderDonMapper.getTotalRefundBalanceTime(startDate, endDate);
+            backgroundDataView.setTotalRefundBalance(totalRefundBalance);
 		}
 		//近5天将要到期的主账号总数
 		DateTime now = DateTime.now();