瀏覽代碼

1添加分部查询过滤

yuanliang 1 年之前
父節點
當前提交
58fc04e059

+ 28 - 6
mec-application/src/main/java/com/ym/mec/web/controller/open/OpenDouble11StaticsController.java

@@ -28,12 +28,14 @@ import java.math.BigDecimal;
 import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -63,6 +65,10 @@ public class OpenDouble11StaticsController extends BaseController {
         Double11StaticWrapper.SaleStaticsQuery query = new Double11StaticWrapper.SaleStaticsQuery();
 
         SysConfig config = sysConfigService.findByParamName("2023_double_eleven_active_config");
+        SysConfig orgs = sysConfigService.findByParamName("2023_activity_organ");
+        if (orgs != null) {
+            query.setOrganId(orgs.getParanValue());
+        }
         Double11StaticWrapper.SaleStaticConfigParam configParam =
                 JSON.parseObject(config.getParanValue(), Double11StaticWrapper.SaleStaticConfigParam.class);
 
@@ -127,15 +133,24 @@ public class OpenDouble11StaticsController extends BaseController {
         SysConfig config = sysConfigService.findByParamName("2023_double_eleven_active_config");
         Double11StaticWrapper.SaleStaticConfigParam configParam =
                 JSON.parseObject(config.getParanValue(), Double11StaticWrapper.SaleStaticConfigParam.class);
+        Map<Integer, Organization> orgIdMap = new HashMap<>();
+        SysConfig orgs = sysConfigService.findByParamName("2023_activity_organ");
+        if (orgs != null) {
+            query.setOrganId(orgs.getParanValue());
+            Map<Integer, Organization> mapById = organizationService.getMapById(Arrays.stream(query.getOrganId()
+                    .split(",")).map(Integer::valueOf).collect(Collectors.toList()));
+            orgIdMap.putAll(mapById);
+        } else {
+            List<Organization> allOrgans = organizationService.findAllOrgans(query.getTenantId());
+            Map<Integer, Organization> mapById = allOrgans.stream()
+                    .collect(Collectors.toMap(Organization::getId, Function.identity()));
+            orgIdMap.putAll(mapById);
+        }
         setQueryParam(query, configParam);
 
 
-        List<Organization> allOrgans = organizationService.findAllOrgans(query.getTenantId());
-        Map<Integer, String> orgIdNameMap = allOrgans.stream()
-                .collect(Collectors.toMap(Organization::getId, Organization::getName));
         List<Double11StaticWrapper.SaleAmountAndUser> result = studentPaymentOrderDao.saleStaticsByOrgId(query);
-        result.forEach(next -> next.setOrganName(orgIdNameMap.getOrDefault(next.getOrganId(), "")));
-
+        result.forEach(next -> next.setOrganName(orgIdMap.getOrDefault(next.getOrganId(), new Organization()).getName()));
         String orderBy = Optional.ofNullable(query.getOrderBy()).orElse("saleAmount");
         int asc = Optional.ofNullable(query.getAsc()).orElse(0);
         if ("saleAmount".equals(orderBy)) {
@@ -180,7 +195,12 @@ public class OpenDouble11StaticsController extends BaseController {
         Double11StaticWrapper.SaleStaticConfigParam configParam =
                 JSON.parseObject(config.getParanValue(), Double11StaticWrapper.SaleStaticConfigParam.class);
         temp.setSaleStaticsType(query.getSaleStaticsType());
+        SysConfig orgs = sysConfigService.findByParamName("2023_activity_organ");
+        if (orgs != null) {
+            query.setOrganId(orgs.getParanValue());
+        }
         setQueryParam(temp, configParam);
+
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, temp);
 
@@ -225,7 +245,9 @@ public class OpenDouble11StaticsController extends BaseController {
         query.setActivityId(null);
         query.setGoodId(null);
         query.setMusicGroupId(null);
-        query.setTenantId(Optional.ofNullable(configParam.getTenantId()).orElse(1));
+        if (StringUtils.isEmpty(query.getOrganId())) {
+            query.setTenantId(Optional.ofNullable(configParam.getTenantId()).orElse(1));
+        }
 
         if (saleStaticsType == 1) {
             // 1V1

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/Double11StaticWrapper.java

@@ -23,7 +23,7 @@ public class Double11StaticWrapper {
     public static class SaleStaticsQuery {
 
         @ApiModelProperty("分部")
-        private Long organId;
+        private String organId;
 
         @ApiModelProperty("统计类型,0:汇总,1:1V1,2:1v2,3:乐理,4:云教练,5:乐器销售,6:报价卡")
         @NotNull
@@ -73,7 +73,7 @@ public class Double11StaticWrapper {
         private Integer rows;
 
         @ApiModelProperty("分部")
-        private Long organId;
+        private String organId;
 
         @ApiModelProperty("学生姓名")
         private String userName;

+ 18 - 3
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -1249,6 +1249,9 @@
             <if test="param.tenantId != null">
                 AND tenant_id_ =#{param.tenantId}
             </if>
+            <if test="param.organId != null">
+                AND find_in_set(organ_id_,#{param.organId})
+            </if>
             <if test="param.groupType != null">
                 AND group_type_ =#{param.groupType}
             </if>
@@ -1273,9 +1276,15 @@
         LEFT join sell_order so on t.order_no_ = so.order_no_
         <where>
             t.status_ = 'SUCCESS'
-            AND t.tenant_id_ = #{param.tenantId}
             AND find_in_set(so.goods_id_,#{param.goodId})
             AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
+            <if test="param.tenantId != null">
+                AND t.tenant_id_ =#{param.tenantId}
+            </if>
+            <if test="param.organId != null">
+                AND find_in_set(t.organ_id_,#{param.organId})
+            </if>
+
         </where>
     </select>
 
@@ -1294,6 +1303,9 @@
             <if test="param.tenantId != null">
                 AND t.tenant_id_ =#{param.tenantId}
             </if>
+            <if test="param.organId != null">
+                AND find_in_set(t.organ_id_,#{param.organId})
+            </if>
             <if test="param.groupType!= null">
                 AND t.group_type_ =#{param.groupType}
             </if>
@@ -1313,7 +1325,7 @@
                 AND t.pay_time_ between #{param.startPayTime} and #{param.endPayTime}
             </if>
         </where>
-        GROUP BY organ_id_
+        GROUP BY t.organ_id_
     </select>
 
     <select id="queryPaymentStudentByPage" resultType="com.ym.mec.biz.dal.wrapper.Double11StaticWrapper$SaleStaticsStudent">
@@ -1334,6 +1346,9 @@
                 AND t.tenant_id_ =#{tenantId}
             </if>
             <if test="organId != null">
+                AND find_in_set(t.organ_id_,#{organId})
+            </if>
+            <if test="organId != null">
                 AND t.organ_id_ = #{organId}
             </if>
             <if test="userName != null and userName.trim() !=''">
@@ -1379,7 +1394,7 @@
                 AND t.tenant_id_ =#{tenantId}
             </if>
             <if test="organId != null">
-                AND t.organ_id_ = #{organId}
+                AND find_in_set(t.organ_id_,#{organId})
             </if>
             <if test="userName != null and userName.trim() !=''">
                 AND su.username_ like concat('%',#{userName},'%')