Jelajahi Sumber

首页优化

叶君翔 3 tahun lalu
induk
melakukan
e2232cb4db

+ 1 - 1
lb-module/src/main/java/com/ydd/module/mapper/AgentMapper.java

@@ -28,7 +28,7 @@ public interface AgentMapper extends BaseMapper<Agent> {
 
     List<Agent> selectByPid(@Param("id") Integer id);
 
-    Integer getSAgentNum(@Param("pid") Integer pid, @Param("startDate") String todayStartDate);
+    Integer getSAgentNum(@Param("agentIds") List<Long> agentIds, @Param("startDate") String todayStartDate);
 
     List<Integer> getAgentIdsByPid(@Param("id") Integer id);
 

+ 1 - 1
lb-module/src/main/java/com/ydd/module/mapper/ProfitsAgentMapper.java

@@ -28,7 +28,7 @@ public interface ProfitsAgentMapper extends BaseMapper<ProfitsAgent> {
 
     ProfitsAgent profitProportion(@Param("agentIds") List<Long> agentIds);
 
-    BigDecimal selectCommissionByAgentId(@Param("agentId") Long agentId, @Param("startDate") String startDate, @Param("endDate") String endDate);
+    BigDecimal selectCommissionByAgentId(@Param("agentIds") List<Long> agentIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
     List<ProfitsAgent> pageList(Page page,@Param("params")ProfitsAgent profitsAgent);
 

+ 1 - 1
lb-module/src/main/java/com/ydd/module/mapper/ProfitsDetailMapper.java

@@ -57,6 +57,6 @@ public interface ProfitsDetailMapper extends BaseMapper<ProfitsDetail> {
 
     List<ProfitsDetail> getByOrderId(Long orderId);
 
-    List<Double> getProfitCommissionList(@Param("agentId") Long agentId, @Param("dspId") Long dspId);
+    List<Double> getProfitCommissionList(@Param("agentIds") List<Long> agentIds, @Param("dspId") Long dspId);
 
 }

+ 1 - 1
lb-module/src/main/java/com/ydd/module/service/IAgentService.java

@@ -46,7 +46,7 @@ public interface IAgentService extends IService<Agent> {
 
     List<Agent> selectByPid(Integer id);
 
-    Integer getSAgentNum(Integer pid, String todayStartDate);
+    Integer getSAgentNum(List<Long> agentIds, String todayStartDate);
 
     void updateAgentListAmount(List<Agent> list);
 

+ 1 - 1
lb-module/src/main/java/com/ydd/module/service/IMerchantService.java

@@ -39,7 +39,7 @@ public interface IMerchantService extends IService<Merchant> {
 
     List<Long> findMerchantIdByAgentId(List<Long> agentIds);
 
-    Integer getMerchantNum(Integer agenId, String startDate);
+    Integer getMerchantNum(List<Long> agentIds, String startDate);
 
     Boolean edtiMerchantById(Merchant merchant, SysUser user);
 

+ 1 - 1
lb-module/src/main/java/com/ydd/module/service/IProfitsAgentService.java

@@ -59,7 +59,7 @@ public interface IProfitsAgentService extends IService<ProfitsAgent> {
 
     ProfitsAgent profitProportion(List<Long> agentIds);
 
-    BigDecimal selectCommissionByAgentId(Long agentId, String startDate, String endDate);
+    BigDecimal selectCommissionByAgentId(List<Long> agentIds, String startDate, String endDate);
 
     ProfitsAgent profitStatistics(ProfitsAgent profitsAgent, SysUser sysUser);
 

+ 2 - 2
lb-module/src/main/java/com/ydd/module/service/IProfitsDetailService.java

@@ -77,10 +77,10 @@ public interface IProfitsDetailService extends IService<ProfitsDetail> {
 
     /**
      * 获取分润列表
-     * @param agentId 代理商id
+     * @param agentIds 代理商id
      * @param dspId 渠道商id
      * @return 分润金额列表
      */
-    List<Double> getProfitCommissionList(Long agentId, Long dspId);
+    List<Double> getProfitCommissionList(List<Long> agentIds, Long dspId);
 
 }

+ 2 - 2
lb-module/src/main/java/com/ydd/module/service/impl/AgentServiceImpl.java

@@ -471,8 +471,8 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
     }
 
     @Override
-    public Integer getSAgentNum(Integer pid, String todayStartDate) {
-        return baseMapper.getSAgentNum(pid, todayStartDate);
+    public Integer getSAgentNum(List<Long> agentIds, String todayStartDate) {
+        return baseMapper.getSAgentNum(agentIds, todayStartDate);
     }
 
     @Override

+ 2 - 7
lb-module/src/main/java/com/ydd/module/service/impl/MerchantServiceImpl.java

@@ -389,13 +389,8 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
     }
 
     @Override
-    public Integer getMerchantNum(Integer agenId, String startDate){
-        List<Long> agents = Lists.newArrayList();
-        if (agenId != null) {
-            agents = iAgentService.listAgent(agenId.longValue());
-        }
-
-        return baseMapper.getMerchantNum(agents, startDate);
+    public Integer getMerchantNum(List<Long> agentIds, String startDate){
+        return baseMapper.getMerchantNum(agentIds, startDate);
     }
 
     @Override

+ 2 - 2
lb-module/src/main/java/com/ydd/module/service/impl/ProfitsAgentServiceImpl.java

@@ -783,8 +783,8 @@ public class ProfitsAgentServiceImpl extends ServiceImpl<ProfitsAgentMapper, Pro
     }
 
     @Override
-    public BigDecimal selectCommissionByAgentId(Long agentId, String startDate, String endDate){
-        return baseMapper.selectCommissionByAgentId(agentId, startDate, endDate);
+    public BigDecimal selectCommissionByAgentId(List<Long> agentIds, String startDate, String endDate){
+        return baseMapper.selectCommissionByAgentId(agentIds, startDate, endDate);
     }
 
     @Override

+ 2 - 2
lb-module/src/main/java/com/ydd/module/service/impl/ProfitsDetailServiceImpl.java

@@ -353,8 +353,8 @@ public class ProfitsDetailServiceImpl extends ServiceImpl<ProfitsDetailMapper, P
     }
 
     @Override
-    public List<Double> getProfitCommissionList(Long agentId, Long dspId) {
-        return baseMapper.getProfitCommissionList(agentId, dspId);
+    public List<Double> getProfitCommissionList(List<Long> agentIds, Long dspId) {
+        return baseMapper.getProfitCommissionList(agentIds, dspId);
     }
 
 }

+ 8 - 1
lb-module/src/main/resources/mapper/module/ProfitsAgentMapper.xml

@@ -86,7 +86,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectCommissionByAgentId" resultType="java.math.BigDecimal">
         SELECT COALESCE(SUM(commission),0)
         FROM lb_profits_detail
-        WHERE deleted=0 and agent_id = #{agentId}
+        WHERE deleted = 0
+        <if test="agentIds != null and agentIds.size > 0">
+            and agent_id in
+            <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
+                #{agentId}
+            </foreach>
+        </if>
+
         <if test="startDate != null and startDate != ''">
             AND create_time >= #{startDate}
         </if>

+ 6 - 2
lb-module/src/main/resources/mapper/module/ProfitsDetailMapper.xml

@@ -170,8 +170,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getProfitCommissionList" resultType="java.lang.Double">
         select IFNULL(commission, 0)
         from lb_profits_detail where deleted = 0 and is_source = 0
-        <if test="agentId != null">
-            and agent_id = #{agentId}
+
+        <if test="agentIds != null and agentIds.size > 0">
+            AND agent_id IN
+            <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
+                #{agentId}
+            </foreach>
         </if>
         <if test="dspId != null">
             and dsp_id = #{dspId}

+ 5 - 2
lb-module/src/main/resources/mapper/module/agentMapper.xml

@@ -57,8 +57,11 @@
 
     <select id="getSAgentNum" resultType="java.lang.Integer">
         SELECT count(id) FROM lb_agent WHERE deleted = 0
-        <if test="pid != null">
-            AND pid = #{pid}
+        <if test="agentIds != null and agentIds.size > 0">
+            AND pid IN
+            <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
+                #{agentId}
+            </foreach>
         </if>
         <if test="startDate != null and startDate != ''">
             AND create_time >= #{startDate}

+ 7 - 5
lb-module/src/main/resources/mapper/module/merchantMapper.xml

@@ -67,7 +67,7 @@
 
     <select id="getMerchantNum" resultType="java.lang.Integer">
         SELECT count(id) FROM lb_merchant WHERE deleted = 0
-        <if test=" agentIds.size() > 0 and agentIds != null ">
+        <if test="agentIds != null and agentIds.size() > 0">
             AND agent_id in
             <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
                 #{agentId}
@@ -322,10 +322,12 @@
 
     <select id="findMerchantIdByAgentId" resultType="java.lang.Long">
         SELECT id FROM lb_merchant WHERE 1 = 1
-        AND agent_id IN
-        <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
-            #{agentId}
-        </foreach>
+        <if test="agentIds != null and agentIds.size > 0">
+            AND agent_id IN
+            <foreach collection="agentIds" index="index" item="agentId" open="(" separator="," close=")">
+                #{agentId}
+            </foreach>
+        </if>
     </select>
 
 </mapper>

+ 31 - 21
lb-web/src/main/java/com/ydd/web/controller/HomeController.java

@@ -88,6 +88,7 @@ public class HomeController extends BaseController {
         return Result.success(map);
     }
 
+    @BindAgent
     @GetMapping("/dataInfo")
     public Result dataInfo() {
         SysUser user = getSysUser();
@@ -108,34 +109,43 @@ public class HomeController extends BaseController {
                 }
             }
 //            List<Long> agentIds = iAgentService.listAgent(user.getAgentId());
-            List<Long> merchantIds = iMerchantService.findMerchantIdByAgentId(agentIds);
             List<Long> shopIds = Lists.newArrayList();
-            if (CollectionUtils.isNotEmpty(merchantIds)) {
-                shopIds = iShopService.findShopIdByMerchantId(merchantIds);
+            if (CollectionUtils.isNotEmpty(agentIds)) {
+                List<Long> merchantIds = iMerchantService.findMerchantIdByAgentId(agentIds);
+                if (CollectionUtils.isNotEmpty(merchantIds)) {
+                    shopIds = iShopService.findShopIdByMerchantId(merchantIds);
+                }
             }
+
             for (int i = 1; i < 3; i++) {
                 Map<String, Object> map = new HashMap<>();
                 String todayStartDate = DateUtils.parseToBeginTime(dft.format(new Date()));
-                if (i == 2) {
-                    Date beginDate = new Date();
-                    Calendar date = Calendar.getInstance();
-                    date.setTime(beginDate);
-                    date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
-                    String yesStartDate = DateUtils.parseToBeginTime(dft.format(date.getTime()));
-                    String yesEndDate = DateUtils.parseToTomorrowBeginTime(dft.format(date.getTime()));
-                    map.put("commission", iProfitsAgentService.selectCommissionByAgentId(user.getAgentId(), yesStartDate, yesEndDate));
-
-                    map.put("agentNum", iAgentService.getSAgentNum(user.getAgentId().intValue(), todayStartDate));
-                    map.put("merchantNum", iMerchantService.getMerchantNum(user.getAgentId().intValue(), todayStartDate));
+                if (CollectionUtils.isNotEmpty(agentIds)) {
+                    if (i == 2) {
+                        Date beginDate = new Date();
+                        Calendar date = Calendar.getInstance();
+                        date.setTime(beginDate);
+                        date.set(Calendar.DATE, date.get(Calendar.DATE) - 1);
+                        String yesStartDate = DateUtils.parseToBeginTime(dft.format(date.getTime()));
+                        String yesEndDate = DateUtils.parseToTomorrowBeginTime(dft.format(date.getTime()));
+                        map.put("commission", iProfitsAgentService.selectCommissionByAgentId(agentIds, yesStartDate, yesEndDate));
+
+                        map.put("agentNum", iAgentService.getSAgentNum(agentIds, todayStartDate));
+                        map.put("merchantNum", iMerchantService.getMerchantNum(agentIds, todayStartDate));
+                    } else {
+                        List<Double> commissions = iProfitsDetailService.getProfitCommissionList(agentIds, null);
+                        double commissionDouble = commissions.stream().collect(Collectors.summarizingDouble(value -> value)).getSum();
+                        BigDecimal commission = BigDecimal.valueOf(commissionDouble).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        map.put("commission", commission);
+                        map.put("agentNum", iAgentService.getSAgentNum(agentIds, null));
+                        map.put("merchantNum", iMerchantService.getMerchantNum(agentIds, null));
+                    }
                 } else {
-//                    BigDecimal commission = iProfitsDetailService.countBigDecimal(user.getAgentId(), null);
-                    List<Double> commissions = iProfitsDetailService.getProfitCommissionList(user.getAgentId(), null);
-                    double commissionDouble = commissions.stream().collect(Collectors.summarizingDouble(value -> value)).getSum();
-                    BigDecimal commission = BigDecimal.valueOf(commissionDouble).setScale(2, BigDecimal.ROUND_HALF_UP);
-                    map.put("commission", commission);
-                    map.put("agentNum", iAgentService.getSAgentNum(user.getAgentId().intValue(), null));
-                    map.put("merchantNum", iMerchantService.getMerchantNum(user.getAgentId().intValue(), null));
+                    map.put("commission", BigDecimal.ZERO);
+                    map.put("agentNum", BigDecimal.ZERO);
+                    map.put("merchantNum", BigDecimal.ZERO);
                 }
+
                 if (agentIds.size() == ListSizeEnum.ZERO.getSize() || shopIds.size() == 0) {
                     map.put("orderNum", 0);
                     map.put("orderAmount", BigDecimal.ZERO);