FengChaoYu il y a 3 semaines
Parent
commit
60bc806b37

+ 5 - 5
src/main/java/com/gree/mall/manager/bean/admin/AdminUserCom.java

@@ -20,19 +20,19 @@ public class AdminUserCom extends AdminUser {
     @ApiModelProperty("商家集合")
     private List<String> adminWebsitIds;
 
-    @ApiModelProperty("部门集合")
+    @ApiModelProperty("部门集合(没有逻辑)")
     private List<String> adminDeptIds;
 
-    @ApiModelProperty("只读帐号")
+    @ApiModelProperty("只读帐号(没有逻辑)")
     private Boolean onlyRead = false;
 
-    @ApiModelProperty("当前登录人企业微信id")
+    @ApiModelProperty("当前登录人企业微信id(没有注入值)")
     private String loginCompanyWechatId;
 
-    @ApiModelProperty("当前登录人企业名称")
+    @ApiModelProperty("当前登录人企业名称(没有注入值)")
     private String loginCompanyName;
 
-    @ApiModelProperty("当前登录人所使用的商户配置")
+    @ApiModelProperty("当前登录人所使用的商户配置(没有注入值)")
     private AdminCompanyWechat adminCompanyWechat;
 
     @ApiModelProperty("商家")

+ 14 - 12
src/main/java/com/gree/mall/manager/commonmapper/CountMapper.java

@@ -1,15 +1,13 @@
 package com.gree.mall.manager.commonmapper;
 
-import com.baomidou.mybatisplus.annotation.SqlParser;
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.gree.mall.manager.bean.count.CountBean;
 import com.gree.mall.manager.bean.count.CountOrderBean;
 import com.gree.mall.manager.bean.count.GoodsRankBean;
-import com.gree.mall.manager.bean.count.WebsitSaleCountBean;
 import com.gree.mall.manager.bean.exchange.GiftExchangeCodeBean;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 import java.util.Map;
@@ -21,13 +19,14 @@ public interface CountMapper {
      * 首页基础概况统计
      * @return
      */
-    @SqlParser(filter = true)
-    public CountBean countInfo(@Param("companyWechatIds") List<String> companyWechatIds);
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
+    public CountBean countInfo(@Param("companyWechatIds") List<String> companyWechatIds,
+                               @Param("adminWebsitIds") List<String> adminWebsitIds);
 
     /**
      * 首页销售统计
      */
-    @SqlParser(filter = true)
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     public CountOrderBean countSaleOrder(@Param("startTime") String startTime,
                                          @Param("endTime") String endTime,
                                          @Param("workOrderType") String workOrderType,
@@ -37,7 +36,7 @@ public interface CountMapper {
     /**
      * 商品销量排行
      */
-    @SqlParser(filter = true)
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     public List<GoodsRankBean> countGoodsRank(@Param("startTime") String startTime,
                                               @Param("endTime") String endTime,
                                               @Param("companyWechatIds") List<String> companyWechatIds,
@@ -46,24 +45,27 @@ public interface CountMapper {
     /**
      * 今日昨日访问量
      */
-    @SqlParser(filter = true)
-    public Integer countVisit(@Param("startTime") String startTime, @Param("endTime") String endTime,@Param("companyWechatIds") List<String> companyWechatIds);
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
+    public Integer countVisit(@Param("startTime") String startTime,
+                              @Param("endTime") String endTime,
+                              @Param("companyWechatIds") List<String> companyWechatIds,
+                              @Param("adminWebsitIds") List<String> adminWebsitIds);
 
 
     /**
      * 师傅的销售金额统计(外部接口结算用)
      */
-    @SqlParser(filter = true)
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     public List<Map<String,Object>> countWorkAmount(@Param("startTime") String startTime, @Param("endTime") String endTime,@Param("companyWechatIds") List<String> companyWechatIds);
 
-    @SqlParser(filter = true)
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     public Map<String,Object> countWebsitAmount(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("websitNumbers") List<String> websitNumbers);
 
 
     /**
      *  优惠券统计列表
      */
-    @SqlParser(filter = true)
+    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     public IPage<GiftExchangeCodeBean> queryExchangeCodeCountList(IPage page,@Param("keyword") String keyword,@Param("adminWebsitId") String adminWebsitId,@Param("companyWechatIds") List<String> companyWechatIds);
 
 

+ 15 - 4
src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

@@ -1,8 +1,6 @@
 package com.gree.mall.manager.logic.common;
 
 import com.alibaba.fastjson.JSON;
-import com.aliyuncs.utils.StringUtils;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.commonmapper.AdminMapper;
 import com.gree.mall.manager.config.wx.WxConfiguration;
@@ -18,6 +16,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.client.config.RequestConfig;
@@ -35,7 +34,10 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedOutputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.UUID;
 import java.util.stream.Collectors;
 
 @Service
@@ -69,6 +71,8 @@ public class CommonLogic {
 
     private final WechatLogic wechatLogic;
 
+    private final AdminWebsitService adminWebsitService;
+
 
     public AdminUserCom getAdminUser() {
         HttpServletRequest request = ApplicationContextUtils.getHttpServletRequest();
@@ -94,6 +98,13 @@ public class CommonLogic {
         AdminUserCom adminUserCom = new AdminUserCom();
         BeanUtils.copyProperties(adminUser, adminUserCom);
 
+        this.queryUserSysRela(adminUserCom);
+
+        if (StringUtils.isNotBlank(adminUser.getWebsitId())) {
+            final AdminWebsit adminWebsit = adminWebsitService.getById(adminUser.getAdminUserId());
+            adminUserCom.setAdminWebsit(adminWebsit);
+        }
+
         return adminUserCom;
     }
 
@@ -121,7 +132,7 @@ public class CommonLogic {
                 .collect(Collectors.toList());
         adminUserCom.setAdminWebsitIds(websitList);
 
-        // 部门
+        // 部门(无任何业务作用)
         final List<String> deptList = permissionsRelas.stream()
                 .filter(AdminUserPermissionsRela::getIsDept)
                 .map(AdminUserPermissionsRela::getAdminUserPermissionsId)

+ 43 - 43
src/main/java/com/gree/mall/manager/logic/count/CountLogic.java

@@ -46,21 +46,21 @@ public class CountLogic {
     /**
      * 概况统计
      */
-    public CountBean info(HttpServletRequest request){
+    public CountBean info(HttpServletRequest request) {
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
 
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         //累计售出商品数量,已售中商品数量,待发货订单数量,维权中订单数量,今日订单数,昨日订单数,今日收益,昨日收益
-        CountBean countBean = countMapper.countInfo(adminUser.getAdminCompanyIds());
+        CountBean countBean = countMapper.countInfo(adminUser.getAdminCompanyIds(), adminUser.getAdminWebsitIds());
         //今日访客
-        Integer todayVisit = countMapper.countVisit(sdf.format(DateUtils.getStartTime()),sdf.format(DateUtils.getEndTime()),adminUser.getAdminCompanyIds());
+        Integer todayVisit = countMapper.countVisit(sdf.format(DateUtils.getStartTime()), sdf.format(DateUtils.getEndTime()), adminUser.getAdminCompanyIds(), adminUser.getAdminWebsitIds());
         //昨日访客
-        Integer yestodayVisit = countMapper.countVisit(sdf.format(DateUtils.getBeginDayOfYesterday()),sdf.format(DateUtils.getEndDayOfYesterDay()),adminUser.getAdminCompanyIds());
+        Integer yestodayVisit = countMapper.countVisit(sdf.format(DateUtils.getBeginDayOfYesterday()), sdf.format(DateUtils.getEndDayOfYesterDay()), adminUser.getAdminCompanyIds(), adminUser.getAdminWebsitIds());
         //查询待结算金额
         List<OrderShare> list = orderShareService.lambdaQuery()
                 .eq(OrderShare::getStatus, OrderShareStatusEnum.ING.toString())
-                .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()),OrderShare::getCompanyWechatId,adminUser.getAdminCompanyIds())
-                //.//in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),OrderShare::getWebsitId,adminUser.getAdminWebsitIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()), OrderShare::getCompanyWechatId, adminUser.getAdminCompanyIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()), OrderShare::getWebsitId, adminUser.getAdminWebsitIds())
                 .list();
         BigDecimal totalShareAmount = list.stream().map(OrderShare::getAmount).reduce(BigDecimal::add).orElse(new BigDecimal(0));
         countBean.setOrderShareAmount(totalShareAmount);
@@ -73,7 +73,7 @@ public class CountLogic {
     /**
      * 商品销售排行
      */
-    public List<GoodsRankBean> countGoodsRank(Integer flag,HttpServletRequest request){
+    public List<GoodsRankBean> countGoodsRank(Integer flag, HttpServletRequest request) {
 
         AdminUserCom adminUserCom = commonLogic.getAdminUser(request);
 
@@ -82,7 +82,7 @@ public class CountLogic {
         Date startTime = this.getStartTime(flag);
         Date endTime = this.getEndTime(flag);
         List<GoodsRankBean> goodsRankBeans = countMapper.countGoodsRank(sdf.format(startTime), sdf.format(endTime),
-                adminUserCom.getAdminCompanyIds(),adminUserCom.getAdminWebsitIds());
+                adminUserCom.getAdminCompanyIds(), adminUserCom.getAdminWebsitIds());
         return goodsRankBeans;
     }
 
@@ -90,24 +90,25 @@ public class CountLogic {
     /**
      * 交易概述
      */
-    public CountOrderBean order(String type,Integer flag,HttpServletRequest request){
+    public CountOrderBean order(String type, Integer flag, HttpServletRequest request) {
         AdminUserCom adminUserCom = commonLogic.getAdminUser(request);
         //默认今天
         Date startTime = this.getStartTime(flag);
         Date endTime = this.getEndTime(flag);
         CountOrderBean countOrderBean = countMapper.countSaleOrder(DateUtils.formatDate(startTime), DateUtils.formatDate(endTime), type,
-                adminUserCom.getAdminCompanyIds(),adminUserCom.getAdminWebsitIds());
+                adminUserCom.getAdminCompanyIds(), adminUserCom.getAdminWebsitIds());
         //各时段统计
         List<OrderInfo> list = orderInfoService.lambdaQuery()
-                .in(CollectionUtils.isNotEmpty(adminUserCom.getAdminCompanyIds()),OrderInfo::getCompanyWechatId,adminUserCom.getAdminCompanyIds())
-                .notIn(OrderInfo::getOrderStatus,Arrays.asList(OrderStatusEnum.CLOSE.toString(),OrderStatusEnum.NOPAY.toString(),OrderStatusEnum.TIMEOUT.toString()))
+                .in(CollectionUtils.isNotEmpty(adminUserCom.getAdminCompanyIds()), OrderInfo::getCompanyWechatId, adminUserCom.getAdminCompanyIds())
+                .in(CollectionUtils.isNotEmpty(adminUserCom.getAdminWebsitIds()), OrderInfo::getWebsitId, adminUserCom.getAdminWebsitIds())
+                .notIn(OrderInfo::getOrderStatus, Arrays.asList(OrderStatusEnum.CLOSE.toString(), OrderStatusEnum.NOPAY.toString(), OrderStatusEnum.TIMEOUT.toString()))
                 .between(OrderInfo::getCreateTime, startTime, endTime).list();
         SimpleDateFormat hh = new SimpleDateFormat("HH");
         SimpleDateFormat dd = new SimpleDateFormat("dd");
         int[] day = new int[24];
         int[] week = new int[7];
         int[] month = new int[DateUtils.DateSubOfDay(DateUtils.getEndMonth(), DateUtils.getStartMonth()) + 1];
-        for(OrderInfo orderInfo : list) {
+        for (OrderInfo orderInfo : list) {
             Date time = orderInfo.getCreateTime();
             if (flag == 1 || flag == 2) {
                 int index = Integer.parseInt(hh.format(time));
@@ -115,27 +116,27 @@ public class CountLogic {
                 day[index]++;
             }
             if (flag == 3) {
-                int index = DateUtils.DateSubOfDay(time,startTime);
+                int index = DateUtils.DateSubOfDay(time, startTime);
                 //7天 按天维度 日不是从0号开始,所以-1
                 week[index]++;
             }
             if (flag == 4) {
                 int index = Integer.parseInt(dd.format(time));
                 //月 按天维度 日不是从0号开始,所以-1
-                month[index-1]++;
+                month[index - 1]++;
             }
         }
-        if(flag == 1 || flag== 2) {
+        if (flag == 1 || flag == 2) {
             countOrderBean.setCountAry(day);
             countOrderBean.setX(new String[24]);
         }
-        if(flag == 3) {
+        if (flag == 3) {
             countOrderBean.setCountAry(week);
-            countOrderBean.setX(getX(7,null));
+            countOrderBean.setX(getX(7, null));
         }
-        if(flag == 4) {
+        if (flag == 4) {
             countOrderBean.setCountAry(month);
-            countOrderBean.setX(getX(DateUtils.DateSubOfDay(DateUtils.getEndMonth(), DateUtils.getStartMonth()) + 1,DateUtils.getEndMonth()));
+            countOrderBean.setX(getX(DateUtils.DateSubOfDay(DateUtils.getEndMonth(), DateUtils.getStartMonth()) + 1, DateUtils.getEndMonth()));
         }
 
         return countOrderBean;
@@ -145,9 +146,9 @@ public class CountLogic {
     /**
      * 师傅的销售金额统计
      */
-    public List<Map<String,Object>> queryWorkAmount(String startTime,String endTime,HttpServletRequest request){
+    public List<Map<String, Object>> queryWorkAmount(String startTime, String endTime, HttpServletRequest request) {
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
-        List<Map<String, Object>> maps = countMapper.countWorkAmount(startTime, endTime,adminUser.getAdminCompanyIds());
+        List<Map<String, Object>> maps = countMapper.countWorkAmount(startTime, endTime, adminUser.getAdminCompanyIds());
         return maps;
     }
 
@@ -155,64 +156,63 @@ public class CountLogic {
     /**
      * 网点的销售金额统计
      */
-    public WebsitSaleCountBean queryWebsitAmount(List<String> websitNumbers){
+    public WebsitSaleCountBean queryWebsitAmount(List<String> websitNumbers) {
         //当月
-        Map<String, Object> map = countMapper.countWebsitAmount(DateUtils.formatDate(DateUtils.getStartMonth()),DateUtils.formatDate(DateUtils.getEndMonth()),websitNumbers);
+        Map<String, Object> map = countMapper.countWebsitAmount(DateUtils.formatDate(DateUtils.getStartMonth()), DateUtils.formatDate(DateUtils.getEndMonth()), websitNumbers);
         //当日
-        Map<String, Object> map2 = countMapper.countWebsitAmount(DateUtils.formatDate(DateUtils.getStartTime()),DateUtils.formatDate(DateUtils.getEndTime()),websitNumbers);
+        Map<String, Object> map2 = countMapper.countWebsitAmount(DateUtils.formatDate(DateUtils.getStartTime()), DateUtils.formatDate(DateUtils.getEndTime()), websitNumbers);
 
         WebsitSaleCountBean bean = new WebsitSaleCountBean();
-        bean.setMonthNum((Integer)map.get("num"));
+        bean.setMonthNum((Integer) map.get("num"));
         bean.setMonthAmount(new BigDecimal(map.get("amount").toString()));
-        bean.setDayNum((Integer)map2.get("num"));
+        bean.setDayNum((Integer) map2.get("num"));
         bean.setDayAmount(new BigDecimal(map2.get("amount").toString()));
         return bean;
     }
 
 
-
-    private Date getStartTime(Integer flag){
+    private Date getStartTime(Integer flag) {
         Date startTime = DateUtils.getStartTime();
         //昨天
-        if(flag == 2){
-            startTime = DateUtils.getTimeByDay(DateUtils.getStartTime(),-1);
+        if (flag == 2) {
+            startTime = DateUtils.getTimeByDay(DateUtils.getStartTime(), -1);
         }
         //最近7天
-        if(flag == 3 ){
-            startTime = DateUtils.getTimeByDay(startTime,-6);
+        if (flag == 3) {
+            startTime = DateUtils.getTimeByDay(startTime, -6);
         }
         //本月
-        if(flag == 4){
+        if (flag == 4) {
             startTime = DateUtils.getStartMonth();
         }
         return startTime;
     }
 
-    private Date getEndTime(Integer flag){
+    private Date getEndTime(Integer flag) {
         Date endTime = DateUtils.getEndTime();
         //昨天
-        if(flag == 2){
-            endTime =  DateUtils.getStartTime();
+        if (flag == 2) {
+            endTime = DateUtils.getStartTime();
         }
         //最近7天
-        if(flag == 3 ){
+        if (flag == 3) {
             endTime = DateUtils.getStartTime();
         }
         //本月
-        if(flag == 4){
+        if (flag == 4) {
             endTime = DateUtils.getEndMonth();
         }
         return endTime;
     }
 
 
-    private static String[] getX(int dayNum,Date date){
-        if(date == null){
+    private static String[] getX(int dayNum, Date date) {
+        if (date == null) {
             date = new Date();
         }
         String[] x = new String[dayNum];
-        for(int i = 0 ;i <dayNum;i++){
-            Date timeByDay = DateUtils.getTimeByDay(date,i-dayNum+1);
+        for (int i = 0; i < dayNum; i++) {
+            Date timeByDay = DateUtils.getTimeByDay(date, i - dayNum + 1);
             x[i] = DateUtils.formatDate1(timeByDay);
         }
         return x;

+ 83 - 93
src/main/java/com/gree/mall/manager/logic/order/OrderLogic.java

@@ -113,56 +113,55 @@ public class OrderLogic {
                                        String exchangeCode, String orderStatus, String startCreateTime, String endCreateTime, String startPayTime,
                                        String endPayTime, String websitId,
                                        Integer pageNum, Integer pageSize,
-                                       String isNegative,String abnormalDispatch,String workerOrderNo,String goodsId
+                                       String isNegative, String abnormalDispatch, String workerOrderNo, String goodsId
     ) {
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
 
         //派工异常订单
-        if(StringUtils.isNotEmpty(abnormalDispatch) && abnormalDispatch.trim().equals("true")){
-            return abnormalDispatchOrder( adminUser,  userId,  orderId,  productName,  userName,  phone,
-                    exchangeCode,  orderStatus,  startCreateTime,  endCreateTime,  startPayTime,
-                    endPayTime,  websitId, pageNum,  pageSize,
+        if (StringUtils.isNotEmpty(abnormalDispatch) && abnormalDispatch.trim().equals("true")) {
+            return abnormalDispatchOrder(adminUser, userId, orderId, productName, userName, phone,
+                    exchangeCode, orderStatus, startCreateTime, endCreateTime, startPayTime,
+                    endPayTime, websitId, pageNum, pageSize,
                     isNegative, abnormalDispatch);
         }
 
         List<String> orderIds = new ArrayList<>();
-        if(StringUtils.isNotEmpty(workerOrderNo)) {
+        if (StringUtils.isNotEmpty(workerOrderNo)) {
             List<OrderRequest> orderRequests = orderRequestService.lambdaQuery().eq(OrderRequest::getWorkerOrderNo, workerOrderNo).list();
             orderIds = orderRequests.stream().map(OrderRequest::getOrderId).collect(Collectors.toList());
         }
 
         IPage page = orderInfoService.lambdaQuery()
-                .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()),OrderInfo::getCompanyWechatId,adminUser.getAdminCompanyIds())
-                ////.//in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),OrderInfo::getWebsitId,adminUser.getAdminWebsitIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()), OrderInfo::getCompanyWechatId, adminUser.getAdminCompanyIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()), OrderInfo::getWebsitId, adminUser.getAdminWebsitIds())
                 .eq(StringUtils.isNotEmpty(userId), OrderInfo::getUserId, userId)
-                .eq(StringUtils.isNotEmpty(goodsId),OrderInfo::getPromotionPackageGoodsId,goodsId)
-                .like(StringUtils.isNotEmpty(exchangeCode),OrderInfo::getExchangeCode,exchangeCode)
+                .eq(StringUtils.isNotEmpty(goodsId), OrderInfo::getPromotionPackageGoodsId, goodsId)
+                .like(StringUtils.isNotEmpty(exchangeCode), OrderInfo::getExchangeCode, exchangeCode)
                 .like(StringUtils.isNotEmpty(orderId), OrderInfo::getOrderId, orderId)
                 .like(StringUtils.isNotEmpty(productName), OrderInfo::getOrderTitle, productName)
-                .in(CollectionUtils.isNotEmpty(orderIds),OrderInfo::getOrderId,orderIds)
-                .eq(StringUtils.isNotEmpty(websitId),OrderInfo::getWebsitId,websitId)
-                .and(StringUtils.isNotEmpty(userName), v -> v.like(OrderInfo::getUserName,userName).or().like(OrderInfo::getReceUserName,userName))
-                .and(StringUtils.isNotEmpty(phone), v -> v.like(OrderInfo::getPhone, phone).or().like(OrderInfo::getRecePhone,phone).or().like(OrderInfo::getWorkerPhone,phone))
-          //      .in(!(adminWebsitBean.getType() && org.apache.commons.lang3.StringUtils.isEmpty(websitId)), OrderInfo::getWebsitNumber, websitNoList)
+                .in(CollectionUtils.isNotEmpty(orderIds), OrderInfo::getOrderId, orderIds)
+                .eq(StringUtils.isNotEmpty(websitId), OrderInfo::getWebsitId, websitId)
+                .and(StringUtils.isNotEmpty(userName), v -> v.like(OrderInfo::getUserName, userName).or().like(OrderInfo::getReceUserName, userName))
+                .and(StringUtils.isNotEmpty(phone), v -> v.like(OrderInfo::getPhone, phone).or().like(OrderInfo::getRecePhone, phone).or().like(OrderInfo::getWorkerPhone, phone))
                 .eq(StringUtils.isNotEmpty(orderStatus), OrderInfo::getOrderStatus, orderStatus)
                 .between(StringUtils.isNotEmpty(startCreateTime) && StringUtils.isNotEmpty(endCreateTime), OrderInfo::getCreateTime, startCreateTime, endCreateTime + " 23:59:59")
                 .between(StringUtils.isNotEmpty(startPayTime) && StringUtils.isNotEmpty(endPayTime), OrderInfo::getPayTime, startPayTime, endPayTime + " 23:59:59")
-                .and(StringUtils.isNotEmpty(isNegative)&&isNegative.trim().equals("2"),
-                        v -> v.gt(OrderInfo::getCommentExpress,2).gt(OrderInfo::getCommentService,2).gt(OrderInfo::getCommentGoods,2))
-                .and(StringUtils.isNotEmpty(isNegative)&&isNegative.trim().equals("1"),v -> v
-                        .gt(OrderInfo::getCommentExpress,0)
-                        .gt(OrderInfo::getCommentService,0)
-                        .gt(OrderInfo::getCommentGoods,0)
+                .and(StringUtils.isNotEmpty(isNegative) && isNegative.trim().equals("2"),
+                        v -> v.gt(OrderInfo::getCommentExpress, 2).gt(OrderInfo::getCommentService, 2).gt(OrderInfo::getCommentGoods, 2))
+                .and(StringUtils.isNotEmpty(isNegative) && isNegative.trim().equals("1"), v -> v
+                        .gt(OrderInfo::getCommentExpress, 0)
+                        .gt(OrderInfo::getCommentService, 0)
+                        .gt(OrderInfo::getCommentGoods, 0)
                         .and(vv -> vv
-                                .lt(OrderInfo::getCommentExpress,3)
-                                .or().lt(OrderInfo::getCommentService,3)
-                                .or().lt(OrderInfo::getCommentGoods,3)
+                                .lt(OrderInfo::getCommentExpress, 3)
+                                .or().lt(OrderInfo::getCommentService, 3)
+                                .or().lt(OrderInfo::getCommentGoods, 3)
                         )
                 )
-                .and(StringUtils.isNotEmpty(isNegative)&&isNegative.trim().equals("0"),
-                        v -> v.eq(OrderInfo::getCommentExpress,0).eq(OrderInfo::getCommentService,0).eq(OrderInfo::getCommentGoods,0))
-                .and(StringUtils.isNotEmpty(isNegative)&&isNegative.trim().equals("3"),
-                        v -> v.gt(OrderInfo::getCommentExpress,0).gt(OrderInfo::getCommentService,0).gt(OrderInfo::getCommentGoods,0))
+                .and(StringUtils.isNotEmpty(isNegative) && isNegative.trim().equals("0"),
+                        v -> v.eq(OrderInfo::getCommentExpress, 0).eq(OrderInfo::getCommentService, 0).eq(OrderInfo::getCommentGoods, 0))
+                .and(StringUtils.isNotEmpty(isNegative) && isNegative.trim().equals("3"),
+                        v -> v.gt(OrderInfo::getCommentExpress, 0).gt(OrderInfo::getCommentService, 0).gt(OrderInfo::getCommentGoods, 0))
                 .orderByDesc(OrderInfo::getCreateTime)
                 .page(new Page<>(pageNum, pageSize));
 
@@ -175,7 +174,7 @@ public class OrderLogic {
             List<OrderDetail> orderDetails = orderDetailService.lambdaQuery().eq(OrderDetail::getOrderId, orderInfo.getOrderId()).list();
             OrderRefund orderRefund = orderRefundService.lambdaQuery()
                     .eq(OrderRefund::getOrderId, orderInfo.getOrderId())
-                    .ne(OrderRefund::getRemark,"").last("limit 1").one();
+                    .ne(OrderRefund::getRemark, "").last("limit 1").one();
 
             Integer count = orderRequestService.lambdaQuery().eq(OrderRequest::getOrderId, orderInfo.getOrderId()).count();
             orderDetailBean.setToWorkOrder(count > 0);
@@ -189,20 +188,19 @@ public class OrderLogic {
 
     //派工异常订单
     public IPage<OrderDetailBean> abnormalDispatchOrder(AdminUserCom adminUserCom, String userId, String orderId, String productName, String userName, String phone,
-                                       String exchangeCode, String orderStatus, String startCreateTime, String endCreateTime, String startPayTime,
-                                       String endPayTime, String websitId,
-                                       Integer pageNum, Integer pageSize,
-                                       String isNegative,String abnormalDispatch){
-
+                                                        String exchangeCode, String orderStatus, String startCreateTime, String endCreateTime, String startPayTime,
+                                                        String endPayTime, String websitId,
+                                                        Integer pageNum, Integer pageSize,
+                                                        String isNegative, String abnormalDispatch) {
 
 
         IPage<OrderInfo> orderInfoIPage = orderMapper.abnormalDispatchOrder(new Page<>(pageNum, pageSize), userId, orderId, productName, userName, phone,
                 exchangeCode, orderStatus, startCreateTime, endCreateTime, startPayTime,
                 endPayTime, websitId,
-                isNegative, abnormalDispatch,adminUserCom.getAdminCompanyIds(),adminUserCom.getAdminWebsitIds());
+                isNegative, abnormalDispatch, adminUserCom.getAdminCompanyIds(), adminUserCom.getAdminWebsitIds());
 
-        IPage<OrderDetailBean> orderDetailBeanIPage=new Page<>();
-        BeanUtils.copyProperties(orderInfoIPage,orderDetailBeanIPage);
+        IPage<OrderDetailBean> orderDetailBeanIPage = new Page<>();
+        BeanUtils.copyProperties(orderInfoIPage, orderDetailBeanIPage);
 
         List<OrderDetailBean> list = new ArrayList<>();
         for (OrderInfo orderInfo : orderInfoIPage.getRecords()) {
@@ -224,7 +222,7 @@ public class OrderLogic {
         return orderDetailBeanIPage;
     }
 
-    public List<OrderDetailBean> list(HttpServletRequest request,String userId, String orderId, String productName, String userName, String phone, String orderStatus,
+    public List<OrderDetailBean> list(HttpServletRequest request, String userId, String orderId, String productName, String userName, String phone, String orderStatus,
                                       String startCreateTime, String endCreateTime, String startPayTime, String endPayTime, String websitId) {
 
         List<OrderInfo> orderList = orderInfoService.lambdaQuery()
@@ -264,11 +262,11 @@ public class OrderLogic {
     /**
      * 修改物流单号
      */
-    public void updateExpress(String orderId,String logisticsNo,String companyCode) throws RemoteServiceException {
+    public void updateExpress(String orderId, String logisticsNo, String companyCode) throws RemoteServiceException {
         //查询物流公司
         String company = expressLogic.expressCompanyName(companyCode);
         OrderInfo orderInfo = orderInfoService.getById(orderId);
-        if(!orderInfo.getOrderStatus().equals(OrderStatusEnum.YFH.toString())){
+        if (!orderInfo.getOrderStatus().equals(OrderStatusEnum.YFH.toString())) {
             throw new RemoteServiceException("非已发货订单不可修改物流单号");
         }
         orderInfo.setCompanyCode(companyCode);
@@ -276,15 +274,15 @@ public class OrderLogic {
         orderInfo.setLogisticsNo(logisticsNo);
         orderInfo.updateById();
         //订阅快递
-        expressLogic.subscribeExpress(logisticsNo,null,orderInfo.getRecePhone());
+        expressLogic.subscribeExpress(logisticsNo, null, orderInfo.getRecePhone());
     }
 
     /**
      * 查看物流
      */
-    public List<ExpressInfo> queryExpressInfo(String logisticsNo){
+    public List<ExpressInfo> queryExpressInfo(String logisticsNo) {
         List<ExpressInfo> list = expressInfoService.lambdaQuery().eq(ExpressInfo::getLogisticsNo, logisticsNo).list();
-        if (CollectionUtils.isNotEmpty(list)){
+        if (CollectionUtils.isNotEmpty(list)) {
             return list;
         }
         return null;
@@ -381,16 +379,16 @@ public class OrderLogic {
                     .set(OrderInfo::getOrderStatus, OrderStatusEnum.CLOSE.toString())
                     .set(OrderInfo::getRefundFlag, RefundFlagEnum.ALL.toString())
                     .update();
-            if(StringUtils.isNotEmpty(userCouponId)){
+            if (StringUtils.isNotEmpty(userCouponId)) {
                 UserCoupon userCoupon = userCouponService.getById(orderInfo.getUserCouponId());
                 if (userCoupon.getSelfUse() != null && userCoupon.getSelfUse()) {
                     //todo sql处理,数量加一,删除指定记录
                     //coustomUserCouponMapper.increaseLeftTimes(userCoupon.getTransferor());
                     userCouponService.removeById(userCouponId);
-                }else{
+                } else {
                     userCouponService.lambdaUpdate()
-                            .eq(UserCoupon::getId,userCouponId)
-                            .set(UserCoupon::getStatus,false)
+                            .eq(UserCoupon::getId, userCouponId)
+                            .set(UserCoupon::getStatus, false)
                             .update();
                 }
             }
@@ -402,7 +400,7 @@ public class OrderLogic {
                     .update();
         }
         log.info("【退款开始:】重置flag={}的结算金额,需要减掉的金额{},国补金额{}", flag, totalShareAmount.doubleValue(), orderInfo.getCouponMerchantContribute().doubleValue());
-        orderShareLogic.reloadAmount(orderId, totalShareAmount,flag);
+        orderShareLogic.reloadAmount(orderId, totalShareAmount, flag);
         log.info("【退款开始:】退款金额{}", refundAmount);
         if (!orderInfo.getPayType().equals("云闪付")) {
             wechatLogic.refund(orderId, orderId + StringUtil.getUUID(), orderInfo.getPayAmount().doubleValue()
@@ -436,7 +434,7 @@ public class OrderLogic {
         if (refundAmount.compareTo(new BigDecimal("0.00")) < 1) {
             throw new RemoteServiceException("金额错误");
         }
-        if(StringUtils.isEmpty(remark)){
+        if (StringUtils.isEmpty(remark)) {
             throw new RemoteServiceException("请填写理赔原因");
         }
         AdminUser adminUser = adminUserService.getById(adminUserId);
@@ -493,16 +491,16 @@ public class OrderLogic {
                     .set(OrderInfo::getUserCouponId, "")
                     .set(OrderInfo::getRefundFlag, RefundFlagEnum.ALL.toString())
                     .update();
-            if(org.apache.commons.lang3.StringUtils.isNotEmpty(userCouponId)){
+            if (org.apache.commons.lang3.StringUtils.isNotEmpty(userCouponId)) {
                 UserCoupon userCoupon = userCouponService.getById(orderInfo.getUserCouponId());
                 if (userCoupon.getSelfUse() != null && userCoupon.getSelfUse()) {
                     //todo sql处理,数量加一,删除指定记录
                     coustomUserCouponMapper.increaseLeftTimes(userCoupon.getTransferor());
                     userCouponService.removeById(userCouponId);
-                }else{
+                } else {
                     userCouponService.lambdaUpdate()
-                            .eq(UserCoupon::getId,userCouponId)
-                            .set(UserCoupon::getStatus,false)
+                            .eq(UserCoupon::getId, userCouponId)
+                            .set(UserCoupon::getStatus, false)
                             .update();
                 }
             }
@@ -514,12 +512,12 @@ public class OrderLogic {
         }
 
         //1=非团购商品 2=团购商品
-        if(totalShareAmount.doubleValue() > 0) {
+        if (totalShareAmount.doubleValue() > 0) {
             int flag = StringUtils.isNotEmpty(orderDetail.getPromotionGroupId()) ? 2 : 1;
-            log.info("【退款开始:】重置结算,order_id={},flag={}金额,需要减掉的金额{}", orderInfo.getOrderId(),flag, totalShareAmount.doubleValue());
+            log.info("【退款开始:】重置结算,order_id={},flag={}金额,需要减掉的金额{}", orderInfo.getOrderId(), flag, totalShareAmount.doubleValue());
             orderShareLogic.reloadAmount(orderId, totalShareAmount, flag);
         }
-        log.info("【退款开始:】退款金额{},order_id={}", refundAmount,orderInfo.getOrderId());
+        log.info("【退款开始:】退款金额{},order_id={}", refundAmount, orderInfo.getOrderId());
         if (!orderInfo.getPayType().equals("云闪付")) {
             wechatLogic.refund(orderId, orderId + StringUtil.getUUID(), orderInfo.getPayAmount().doubleValue()
                     , refundAmount.doubleValue(), orderInfo.getCompanyWechatId());
@@ -584,7 +582,7 @@ public class OrderLogic {
         OrderInfo orderInfo = orderInfoService.getById(orderId);
         final AdminCompanyWechat companyWechat = adminCompanyWechatService.getById(orderInfo.getCompanyWechatId());
         User user = userLogic.getById(orderInfo.getUserId());
-        if(!orderInfo.getOrderStatus().equals(OrderStatusEnum.DFH.toString())){
+        if (!orderInfo.getOrderStatus().equals(OrderStatusEnum.DFH.toString())) {
             throw new RemoteServiceException("非待发货订单不可发货");
         }
         //发货商
@@ -605,7 +603,7 @@ public class OrderLogic {
         orderShareLogic.updateOrderStatus(orderId, OrderStatusEnum.YFH.toString());
 
         //订阅物流
-        expressLogic.subscribeExpress(logisticsNo, companyCode,orderInfo.getRecePhone());
+        expressLogic.subscribeExpress(logisticsNo, companyCode, orderInfo.getRecePhone());
         //发货通知
         if (user != null) {
             msgSubscriptLogic.sendFhNotice(user.getUserId(), user.getOpenId(), orderInfo.getOrderId(), orderInfo.getPayAmount()
@@ -643,7 +641,7 @@ public class OrderLogic {
                     throw new RemoteServiceException("请勿重复操作发货,请稍后再试");
                 }
                 updateDeliverItem(adminUser, deliverGoodsBean);
-            }finally {
+            } finally {
                 obtain.unlock();
             }
         }
@@ -652,7 +650,7 @@ public class OrderLogic {
 
     private String preCheck(AdminUserCom adminUser, List<DeliverGoodsBean> deliverGoodsBeanList) {
         String loginCompanyWechatId = adminUser.getLoginCompanyWechatId();
-        if(StringUtils.isEmpty(loginCompanyWechatId)){
+        if (StringUtils.isEmpty(loginCompanyWechatId)) {
             throw new RemoteServiceException("无效微信企业id");
         }
 
@@ -724,7 +722,7 @@ public class OrderLogic {
 
         orderShareLogic.updateOrderStatus(orderId, OrderStatusEnum.YFH.toString());
 
-        expressLogic.subscribeExpress(deliverGoodsBean.getLogisticsNo(), company.getCode(),orderInfo.getRecePhone());
+        expressLogic.subscribeExpress(deliverGoodsBean.getLogisticsNo(), company.getCode(), orderInfo.getRecePhone());
         if (orderInfo != null) {
             User user = userLogic.getById(orderInfo.getUserId());
             if (user != null) {
@@ -735,9 +733,6 @@ public class OrderLogic {
     }
 
 
-
-
-
     private String getStringValue(Cell cell) {
         if (cell == null) {
             return null;
@@ -780,9 +775,9 @@ public class OrderLogic {
         }
         orderDetailBean.setRefundAble(refundFlag);
         //团长信息
-        if(StringUtils.isNotEmpty(orderInfo.getPromotionGroupUserId())){
+        if (StringUtils.isNotEmpty(orderInfo.getPromotionGroupUserId())) {
             User user = userService.getById(orderInfo.getPromotionGroupUserId());
-            if(user != null){
+            if (user != null) {
                 orderDetailBean.setPromotionGroupUserName(user.getNickName());
                 orderDetailBean.setPromotionGroupMobile(user.getMobile());
             }
@@ -797,8 +792,8 @@ public class OrderLogic {
     /**
      * 是否显示评价
      */
-    public void updateShowComment(String orderId,Boolean isShow){
-        commentTagLogic.updateShow(orderId,isShow);
+    public void updateShowComment(String orderId, Boolean isShow) {
+        commentTagLogic.updateShow(orderId, isShow);
     }
 
 
@@ -816,13 +811,12 @@ public class OrderLogic {
     /**
      * 查询订单详情
      */
-    public List<OrderDetail> queryOrderDetails(String orderId){
+    public List<OrderDetail> queryOrderDetails(String orderId) {
         List<OrderDetail> list = orderDetailService.lambdaQuery().in(OrderDetail::getOrderId, orderId).list();
         return list;
     }
 
 
-
     /**
      * 导出excel
      *
@@ -831,10 +825,10 @@ public class OrderLogic {
      */
     public void export(HttpServletRequest request, HttpServletResponse response, String userId, String orderId, String productName, String userName, String phone, String orderStatus,
                        String startCreateTime, String endCreateTime, String startPayTime, String endPayTime, String websitId) throws Exception {
-        List<OrderDetailBean> list = list(request,userId, orderId, productName, userName, phone, orderStatus, startCreateTime, endCreateTime, startPayTime, endPayTime, websitId);
+        List<OrderDetailBean> list = list(request, userId, orderId, productName, userName, phone, orderStatus, startCreateTime, endCreateTime, startPayTime, endPayTime, websitId);
 //        OrderDetailBean
         String[] titles = {"订单号", "商品名称", "规格型号", "数量", "单位", "销售单价", "优惠后单价", "实际收款", "收货人姓名",
-                "手机号", "收货地址","订单状态", "售后状态", "退款金额(小项)", "退款数量(小项)", "备注", "下单时间", "买家昵称", "购买渠道", "买家备注", "卖家备注", "网点", "业务员/网点","分佣金额","团长名称","团长手机号"};
+                "手机号", "收货地址", "订单状态", "售后状态", "退款金额(小项)", "退款数量(小项)", "备注", "下单时间", "买家昵称", "购买渠道", "买家备注", "卖家备注", "网点", "业务员/网点", "分佣金额", "团长名称", "团长手机号"};
         ExcelData excelData = new ExcelData();
         List<List<Object>> rows = new ArrayList<>();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -843,7 +837,7 @@ public class OrderLogic {
             User user = null;
             //查询团长
             String promotionGroupUserId = orderDetailBean.getPromotionGroupUserId();
-            if(StringUtils.isNotEmpty(promotionGroupUserId)){
+            if (StringUtils.isNotEmpty(promotionGroupUserId)) {
                 user = userService.getById(promotionGroupUserId);
             }
 
@@ -861,7 +855,7 @@ public class OrderLogic {
                 row.add(orderDetailBean.getReceUserName());
                 row.add(orderDetailBean.getRecePhone());
                 row.add(trimStr(orderDetailBean.getProvince(), orderDetailBean.getCity(),
-                        orderDetailBean.getArea(), orderDetailBean.getStreet(), orderDetailBean.getReceAddress(),orderDetailBean.getHouseNo()));
+                        orderDetailBean.getArea(), orderDetailBean.getStreet(), orderDetailBean.getReceAddress(), orderDetailBean.getHouseNo()));
                 String orderStatusName = Enum.valueOf(OrderStatusEnum.class, orderDetailBean.getOrderStatus().trim().toUpperCase()).getName();
                 if (orderDetailBean.getOrderStatus().equals(OrderStatusEnum.REFUND.toString())) {
                     if (org.apache.commons.lang3.StringUtils.isNotEmpty(orderDetailBean.getLogisticsNo())) {
@@ -870,7 +864,7 @@ public class OrderLogic {
                         orderStatusName = OrderStatusEnum.DFH.getName();
                     }
                 }
-                if(orderDetailBean.getRefundFlag().equals(RefundFlagEnum.ALL.toString())){
+                if (orderDetailBean.getRefundFlag().equals(RefundFlagEnum.ALL.toString())) {
                     orderStatusName = OrderStatusEnum.CLOSE.getName();
                 }
                 row.add(orderStatusName);
@@ -881,7 +875,7 @@ public class OrderLogic {
                     if (orderDetail.getRefundNum() == 0) {
                         refundFlag = RefundFlagEnum.COMMONLY.getName();
                     } else {
-                        refundFlag = orderDetail.getNum() - orderDetail.getRefundNum() > 0?
+                        refundFlag = orderDetail.getNum() - orderDetail.getRefundNum() > 0 ?
                                 RefundFlagEnum.PARTLY.getName() : RefundFlagEnum.ALL.getName();
                         if (orderDetailBean.getRefundFlag().equals(RefundFlagEnum.ING.toString())) {
                             refundFlag = RefundFlagEnum.ING.getName();
@@ -904,10 +898,10 @@ public class OrderLogic {
                 row.add(trimStr(orderDetailBean.getWorkerName(), "\r\n", orderDetailBean.getWebsitName()));
                 row.add(orderDetail.getShareAmount());
                 row.add(orderDetailBean.getPromotionGroupUserId());
-                if(user != null) {
+                if (user != null) {
                     row.add(user.getNickName());
                     row.add(user.getMobile());
-                }else{
+                } else {
                     row.add("");
                     row.add("");
                 }
@@ -925,7 +919,6 @@ public class OrderLogic {
 
     /**
      * 导出excel
-     *
      */
     public void export2(HttpServletRequest request, HttpServletResponse response,
                         String userId, String orderId, String productName, String userName,
@@ -1020,15 +1013,14 @@ public class OrderLogic {
     }
 
 
-
     @Transactional
     public void overOrder(SubscribePushParamResp subscribePushParamResp) throws Exception {
         if ("3".equals(subscribePushParamResp.getLastResult().getState())) {
             OrderInfo orderInfo = orderInfoService.lambdaQuery()
-                    .eq(OrderInfo::getLogisticsNo,subscribePushParamResp.getLastResult().getNu())
-                    .eq(OrderInfo::getCompanyCode,subscribePushParamResp.getLastResult().getCom())
+                    .eq(OrderInfo::getLogisticsNo, subscribePushParamResp.getLastResult().getNu())
+                    .eq(OrderInfo::getCompanyCode, subscribePushParamResp.getLastResult().getCom())
                     .one();
-            if(orderInfo == null || !orderInfo.getOrderStatus().equals(OrderStatusEnum.YFH.toString())){
+            if (orderInfo == null || !orderInfo.getOrderStatus().equals(OrderStatusEnum.YFH.toString())) {
                 return;
             }
             final AdminCompanyWechat companyWechat = adminCompanyWechatService.getById(orderInfo.getCompanyWechatId());
@@ -1046,7 +1038,7 @@ public class OrderLogic {
     }
 
     //生成工单到工单系统
-    public void orderToPhp(OrderInfo orderInfo,String workOrderTypeEnum) throws Exception {
+    public void orderToPhp(OrderInfo orderInfo, String workOrderTypeEnum) throws Exception {
 
         if (orderInfo.getWorkOrder() == null || !orderInfo.getWorkOrder()) {
             return;
@@ -1063,21 +1055,21 @@ public class OrderLogic {
                 .list();
 
         //非退换货的拆单推送
-        if(workOrderTypeEnum.equals(WorkOrderTypeEnum.INSTALL.toString())) {
+        if (workOrderTypeEnum.equals(WorkOrderTypeEnum.INSTALL.toString())) {
             //如果是退换货的单,直接全拆
-            if(orderInfo.getExchangeOrder() != null && orderInfo.getExchangeOrder()){
-                for(OrderDetail orderDetail : list){
-                    gongdanLogic.installOrder(orderInfo,Arrays.asList(orderDetail),orderDetail.getMainNumber());
+            if (orderInfo.getExchangeOrder() != null && orderInfo.getExchangeOrder()) {
+                for (OrderDetail orderDetail : list) {
+                    gongdanLogic.installOrder(orderInfo, Arrays.asList(orderDetail), orderDetail.getMainNumber());
                 }
-            }else {
+            } else {
                 //非退换货的单,按品类拆,里面还会按营销类型拆
                 for (String mainNumber : mainNumbers) {
                     gongdanLogic.installOrder(orderInfo, list, mainNumber);
                 }
             }
-        }else{
+        } else {
             for (OrderDetail orderDetail : list) {
-                gongdanLogic.repairOrder(orderInfo,orderDetail);
+                gongdanLogic.repairOrder(orderInfo, orderDetail);
             }
         }
 
@@ -1085,8 +1077,6 @@ public class OrderLogic {
     }
 
 
-
-
     private String trimStr(String... str) {
         StringBuffer sb = new StringBuffer("");
         for (String s : str) {

+ 33 - 39
src/main/java/com/gree/mall/manager/logic/order/OrderRefundLogic.java

@@ -83,11 +83,11 @@ public class OrderRefundLogic {
 
         IPage page = orderRefundService.lambdaQuery()
                 .like(StringUtils.isNotEmpty(orderId), OrderRefund::getOrderId, orderId)
-                .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()),OrderRefund::getCompanyWechatId,adminUser.getAdminCompanyIds())
-                ////.//in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),OrderRefund::getWebsitId,adminUser.getAdminWebsitIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()), OrderRefund::getCompanyWechatId, adminUser.getAdminCompanyIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()), OrderRefund::getWebsitId, adminUser.getAdminWebsitIds())
                 .like(StringUtils.isNotEmpty(orderRefundId), OrderRefund::getOrderRefundId, orderRefundId)
                 .like(StringUtils.isNotEmpty(userName), OrderRefund::getUserName, userName)
-                .and(StringUtils.isNotEmpty(phone), v -> v.like(OrderRefund::getPhone,phone).or().like(OrderRefund::getRecePhone,phone))
+                .and(StringUtils.isNotEmpty(phone), v -> v.like(OrderRefund::getPhone, phone).or().like(OrderRefund::getRecePhone, phone))
                 .eq(StringUtils.isNotEmpty(orderStatus), OrderRefund::getOrderStatus, orderStatus)
                 .between(StringUtils.isNotEmpty(startCreateTime) && StringUtils.isNotEmpty(endCreateTime), OrderRefund::getCreateTime, startCreateTime, endCreateTime + " 23:59:59")
                 .between(StringUtils.isNotEmpty(startExamineTime) && StringUtils.isNotEmpty(endExamineTime), OrderRefund::getExamineTime, startExamineTime, endExamineTime + " 23:59:59")
@@ -140,14 +140,14 @@ public class OrderRefundLogic {
      * 审核
      */
     @Transactional
-    public void examine(String orderRefundId, String examineStatus,String refundMessage, String refundPassword) throws Exception {
+    public void examine(String orderRefundId, String examineStatus, String refundMessage, String refundPassword) throws Exception {
         OrderRefund orderRefund = orderRefundService.getById(orderRefundId);
         OrderInfo orderInfo = orderInfoService.getById(orderRefund.getOrderId());
         if (examineStatus.equals(OrderExamineEnum.FAIL.toString())) {
             orderRefundService.lambdaUpdate()
                     .eq(OrderRefund::getOrderRefundId, orderRefundId)
                     .set(OrderRefund::getExamineStatus, examineStatus)
-                    .set(OrderRefund::getRefundMessage,refundMessage)
+                    .set(OrderRefund::getRefundMessage, refundMessage)
                     .set(OrderRefund::getExamineTime, new Date())
                     .set(OrderRefund::getOrderStatus, OrderStatusEnum.CLOSE.toString())
                     .update();
@@ -163,30 +163,30 @@ public class OrderRefundLogic {
             orderInfo.setRefundFlag(RefundFlagEnum.COMMONLY.toString());
             orderInfo.updateById();
             //恢复分佣状态
-            orderShareLogic.updateOrderShare(orderInfo.getOrderId(),OrderShareStatusEnum.ING.toString());
+            orderShareLogic.updateOrderShare(orderInfo.getOrderId(), OrderShareStatusEnum.ING.toString());
             return;
         }
         String orderStatus = OrderStatusEnum.DMJCL.toString();
         if (examineStatus.equals(OrderExamineEnum.OK.toString())) {
 
             List<OrderShare> orderShareList = orderShareLogic.getOrderShareList(orderInfo.getOrderId());
-            if(orderShareList.size() > 0 && orderShareList.get(0).getStatus().equals(OrderShareStatusEnum.OVER.toString())){
+            if (orderShareList.size() > 0 && orderShareList.get(0).getStatus().equals(OrderShareStatusEnum.OVER.toString())) {
                 throw new RemoteServiceException("退款失败,订单已结算");
             }
 
             //检查工单状态是否为 报完工或者正常关闭
             List<WorkerOrderInfo> installOrderList = gongdanLogic.getInstallOrderList(orderInfo.getOrderId());
             List<WorkerOrderInfo> repairOrderList = gongdanLogic.getRepairOrderList(orderInfo.getOrderId());
-            if(installOrderList.size() > 0){
+            if (installOrderList.size() > 0) {
                 long count = installOrderList.stream().filter(v -> v.getOrderStateInt() == 7 || v.getOrderStateInt() == 10).count();
-                if(count > 0){
+                if (count > 0) {
                     throw new RemoteServiceException("退款失败,工单已报完工");
                 }
             }
-            if(repairOrderList.size() > 0){
+            if (repairOrderList.size() > 0) {
                 long count = repairOrderList.stream().filter(v -> v.getOrderStateInt() == 8 && v.getOrderStateInt() == 9 && v.getOrderStateInt() == 10
                         && v.getOrderStateInt() == 11 && v.getOrderStateInt() == 14).count();
-                if(count > 0){
+                if (count > 0) {
                     throw new RemoteServiceException("退款失败,工单已报完工");
                 }
             }
@@ -200,7 +200,7 @@ public class OrderRefundLogic {
             orderRefundService.lambdaUpdate()
                     .eq(OrderRefund::getOrderRefundId, orderRefundId)
                     .set(OrderRefund::getExamineStatus, examineStatus)
-                    .set(OrderRefund::getRefundMessage,refundMessage)
+                    .set(OrderRefund::getRefundMessage, refundMessage)
                     .set(OrderRefund::getExamineTime, new Date())
                     .set(OrderRefund::getOrderStatus, orderStatus)
                     .update();
@@ -223,7 +223,7 @@ public class OrderRefundLogic {
             } else {
                 orderInfoService.lambdaUpdate()
                         .eq(OrderInfo::getOrderId, orderId)
-                        .set(OrderInfo::getOrderStatus,orderInfo.getLastOrderStatus())
+                        .set(OrderInfo::getOrderStatus, orderInfo.getLastOrderStatus())
                         .set(OrderInfo::getRefundFlag, RefundFlagEnum.PARTLY.toString())
                         .update();
             }
@@ -251,20 +251,16 @@ public class OrderRefundLogic {
     /**
      * 查看物流
      */
-    public List<ExpressInfo> queryExpressInfo(String logisticsNo){
+    public List<ExpressInfo> queryExpressInfo(String logisticsNo) {
         List<ExpressInfo> list = expressInfoService.lambdaQuery()
                 .eq(ExpressInfo::getLogisticsNo, logisticsNo).list();
-        if (CollectionUtils.isNotEmpty(list)){
+        if (CollectionUtils.isNotEmpty(list)) {
             return list;
         }
         return null;
     }
 
 
-
-
-
-
     /**
      * 备注
      */
@@ -273,8 +269,6 @@ public class OrderRefundLogic {
     }
 
 
-
-
     /**
      * 退款
      *
@@ -291,16 +285,16 @@ public class OrderRefundLogic {
         for (OrderDetail orderDetail : list) {
             double div = ArithUtils.div(orderDetail.getRefundNum(), orderDetail.getNum(), 4);
             double mul = ArithUtils.mul(orderDetail.getShareAmount().doubleValue(), div, 2);
-            BigDecimal totalShareAmount  = BigDecimal.valueOf(mul);
+            BigDecimal totalShareAmount = BigDecimal.valueOf(mul);
 
             //1=非团购商品 2=团购商品
             int flag = StringUtils.isNotEmpty(orderDetail.getPromotionGroupId()) ? 2 : 1;
-            log.info("【退款开始:】重置结算flag={}金额,需要减掉的金额{}",flag, totalShareAmount.doubleValue());
-            orderShareLogic.reloadAmount(orderId, totalShareAmount,flag);
+            log.info("【退款开始:】重置结算flag={}金额,需要减掉的金额{}", flag, totalShareAmount.doubleValue());
+            orderShareLogic.reloadAmount(orderId, totalShareAmount, flag);
         }
 
         log.info("【退款开始:】退款金额{}", orderRefund.getRefundAmount().doubleValue());
-        if(orderRefund.getPayAmount().doubleValue() == 0){
+        if (orderRefund.getPayAmount().doubleValue() == 0) {
             return;
         }
         if (!orderRefund.getPayType().equals("云闪付")) {
@@ -322,22 +316,22 @@ public class OrderRefundLogic {
     ) throws Exception {
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
 
-        SimpleDateFormat simpleDateFormat=new SimpleDateFormat();
-        List<List<Object>> rowList=new ArrayList<>();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
+        List<List<Object>> rowList = new ArrayList<>();
 
-        String[] titles ={"订单号", "商品名称", "规格型号", "数量", "单位", "销售单价", "优惠后单价", "实际收款", "收货人姓名",
-                "手机号", "收货地址","订单状态", "售后状态", "退款金额(小项)", "退款数量(小项)", "备注", "下单时间", "买家昵称", "购买渠道",
-                "买家备注", "卖家备注", "网点", "业务员/网点","分佣金额","团长名称","团长手机号","团购活动id","退货说明"};
-        ExcelData excelData=new ExcelData();
+        String[] titles = {"订单号", "商品名称", "规格型号", "数量", "单位", "销售单价", "优惠后单价", "实际收款", "收货人姓名",
+                "手机号", "收货地址", "订单状态", "售后状态", "退款金额(小项)", "退款数量(小项)", "备注", "下单时间", "买家昵称", "购买渠道",
+                "买家备注", "卖家备注", "网点", "业务员/网点", "分佣金额", "团长名称", "团长手机号", "团购活动id", "退货说明"};
+        ExcelData excelData = new ExcelData();
         excelData.setTitles(Arrays.asList(titles));
         excelData.setName("维权订单");
         excelData.setRows(rowList);
 
         List<OrderDetailListBean> orderRefundDetailList = orderRefundInfoMapper.getOrderRefundDetailList(
-                orderId, orderRefundId, userName, phone, orderStatus, startCreateTime, endCreateTime, startExamineTime, endExamineTime,adminUser.getAdminCompanyIds(),adminUser.getAdminWebsitIds());
+                orderId, orderRefundId, userName, phone, orderStatus, startCreateTime, endCreateTime, startExamineTime, endExamineTime, adminUser.getAdminCompanyIds(), adminUser.getAdminWebsitIds());
 
-        for (OrderDetailListBean orderDetailListBean:orderRefundDetailList) {
-            List<Object> row=new ArrayList<>();
+        for (OrderDetailListBean orderDetailListBean : orderRefundDetailList) {
+            List<Object> row = new ArrayList<>();
             rowList.add(row);
 
             row.add(orderDetailListBean.getOrderId());
@@ -351,14 +345,14 @@ public class OrderRefundLogic {
             row.add(orderDetailListBean.getReceUserName());
             row.add(orderDetailListBean.getRecePhone());
             row.add(orderDetailListBean.getAddress());
-            if(StringUtils.isNotEmpty(orderDetailListBean.getOrderStatus())){
-                row.add(Enum.valueOf(OrderStatusEnum.class,orderDetailListBean.getOrderStatus()).getName());
-            }else{
+            if (StringUtils.isNotEmpty(orderDetailListBean.getOrderStatus())) {
+                row.add(Enum.valueOf(OrderStatusEnum.class, orderDetailListBean.getOrderStatus()).getName());
+            } else {
                 row.add("");
             }
             if (StringUtils.isNotEmpty(orderDetailListBean.getRefundFlag())) {
                 row.add(RefundFlagEnum.valueOf(orderDetailListBean.getRefundFlag()).getName());
-            }else{
+            } else {
                 row.add("");
             }
             row.add(orderDetailListBean.getRefundAmount());
@@ -380,7 +374,7 @@ public class OrderRefundLogic {
         }
 
 
-        ExcelUtils.exportExcel(request,response,String.format("维权订单导出%s.xlsx", simpleDateFormat.format(new Date())),excelData);
+        ExcelUtils.exportExcel(request, response, String.format("维权订单导出%s.xlsx", simpleDateFormat.format(new Date())), excelData);
 
     }
 

+ 9 - 4
src/main/java/com/gree/mall/manager/logic/order/OrderShareLogic.java

@@ -15,15 +15,20 @@ import com.gree.mall.manager.enums.*;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.common.WechatLogic;
-import com.gree.mall.manager.plus.entity.*;
-import com.gree.mall.manager.plus.service.*;
+import com.gree.mall.manager.plus.entity.OrderInfo;
+import com.gree.mall.manager.plus.entity.OrderRefund;
+import com.gree.mall.manager.plus.entity.OrderShare;
+import com.gree.mall.manager.plus.entity.User;
+import com.gree.mall.manager.plus.service.OrderInfoService;
+import com.gree.mall.manager.plus.service.OrderRefundService;
+import com.gree.mall.manager.plus.service.OrderShareService;
+import com.gree.mall.manager.plus.service.UserService;
 import com.gree.mall.manager.utils.DateUtils;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
@@ -61,7 +66,7 @@ public class OrderShareLogic {
         log.info("结算管理:companyWechatId:{},adminWebsitIds:{}",JSONObject.toJSONString(adminUser.getAdminCompanyIds()),JSONObject.toJSONString(adminUser.getAdminWebsitIds()));
         IPage<OrderShare> page = orderShareService.lambdaQuery()
                 .in(CollectionUtils.isNotEmpty(adminUser.getAdminCompanyIds()),OrderShare::getCompanyWechatId,adminUser.getAdminCompanyIds())
-                ////.//in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),OrderShare::getWebsitId,adminUser.getAdminWebsitIds())
+                .in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),OrderShare::getWebsitId,adminUser.getAdminWebsitIds())
                 .eq(StringUtils.isNotEmpty(userId), OrderShare::getUserId, userId)
                 .like(StringUtils.isNotEmpty(orderShareId), OrderShare::getOrderShareId, orderShareId)
                 .like(StringUtils.isNotEmpty(orderId), OrderShare::getOrderId, orderId)

+ 15 - 3
src/main/resources/mapper/CountMapper.xml

@@ -33,6 +33,12 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+                and websit_id in
+                <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
         </where>
     </select>
 
@@ -54,7 +60,7 @@
                 #{item}
             </foreach>
         </if>
-<!--        <if test="websitIds != null and websitIds.size > 0">
+        <if test="websitIds != null and websitIds.size > 0">
             and a.websit_id in
             <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
                 #{item}
@@ -74,12 +80,12 @@
                 #{item}
             </foreach>
         </if>
-<!--        <if test="websitIds != null and websitIds.size > 0">
+        <if test="websitIds != null and websitIds.size > 0">
             and a.websit_id in
             <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
                 #{item}
             </foreach>
-        </if>-->
+        </if>
 
         group by b.goods_id
         order by count(1) desc
@@ -94,6 +100,12 @@
                 #{item}
             </foreach>
         </if>
+        <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
+            and websit_id in
+            <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
     </select>
 
     <select id="countWorkAmount" resultType="java.util.Map">