From fae2db5e86b4e15ee0336739925328e88d25021a Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期六, 06 五月 2023 16:39:29 +0800
Subject: [PATCH] BUG修改

---
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
index 4d5b211..a82dbcc 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
@@ -5,6 +5,7 @@
 import com.stylefeng.guns.core.shiro.ShiroKit;
 import com.stylefeng.guns.modular.system.controller.resp.TBranchOfficeResp;
 import com.stylefeng.guns.modular.system.dao.*;
+import com.stylefeng.guns.modular.system.enums.StatusEnum;
 import com.stylefeng.guns.modular.system.model.*;
 import com.stylefeng.guns.modular.system.service.ITBranchOfficeService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
@@ -75,7 +76,8 @@
 
         // 优惠券数据,,,通过订单找到该区域的下单人,找出优惠券信息
         List<Integer> userIds = orders.stream().map(TOrder::getUserId).collect(Collectors.toList());
-        List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().in("userId", userIds));
+        List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("objectId", tBranchOfficeId)
+                .eq("roleType",2));
         // 优惠券有效数量
         int validCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getValidCount).sum();
         // 过期数量
@@ -125,6 +127,8 @@
         if(Objects.nonNull(status)){
             wrapper.eq("status",status);
         }
+        wrapper.ne("status", StatusEnum.DELETE.getCode());
+        wrapper.orderBy("createTime",false);
         // 判断代理商 分公司
         Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
         Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
@@ -152,18 +156,19 @@
 
         for (TBranchOfficeResp tBranchOfficeResp : tBranchOfficeRespList) {
 
-            List<TOrder> orderList = orders.stream().filter(t -> t.getBranchOfficeId().equals(tBranchOfficeResp.getId())).collect(Collectors.toList());
+            List<TOrder> orderList = orders.stream().filter(t -> tBranchOfficeResp.getId().equals(t.getBranchOfficeId())).collect(Collectors.toList());
 
             if(!CollectionUtils.isEmpty(orderList)){
 
                 // 订单数据
                 tBranchOfficeResp.setOrderCount(orderList.size());// 订单数量
-                List<TOrder> effectiveOrder = orderList.stream().filter(order -> order.getPayMoney().compareTo(new BigDecimal("15")) > 0).collect(Collectors.toList());
+                List<TOrder> effectiveOrder = orderList.stream().filter(order -> Objects.nonNull(order.getPayMoney()) && order.getPayMoney().compareTo(new BigDecimal("15")) > 0).collect(Collectors.toList());
                 tBranchOfficeResp.setEffectiveOrderCount(effectiveOrder.size());// 有效订单
 
                 // 优惠券数据,,,通过订单找到该区域的下单人,找出优惠券信息
                 List<Integer> userIds = orderList.stream().map(TOrder::getUserId).collect(Collectors.toList());
-                List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().in("userId", userIds));
+                List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("objectId", tBranchOfficeResp.getId())
+                        .eq("roleType",2));
                 // 优惠券有效数量
                 int validCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getValidCount).sum();
                 // 过期数量
@@ -218,6 +223,9 @@
             }
             tBranchOffice.setDistrictName(area.getName());
             tBranchOffice.setDistrictCode(area.getCode());
+        }else {
+            tBranchOffice.setDistrictName("");
+            tBranchOffice.setDistrictCode("");
         }
 
         // 通过省市查询代理商

--
Gitblit v1.7.1