Sfoglia il codice sorgente

代理商分润查询

hgw 3 anni fa
parent
commit
7a70bbd444

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TenantProxyDividendDao.java

@@ -1,10 +1,13 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ym.mec.biz.dal.entity.TenantProxyDividend;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 代理商分润表(TenantProxyDividend)表数据库访问层
@@ -16,5 +19,7 @@ public interface TenantProxyDividendDao extends BaseMapper<TenantProxyDividend>
 
     int insertBatch(@Param("entities") List<TenantProxyDividend> entities);
 
+    <T> IPage<T> queryProxyDividendInfo(Page<T> page, @Param("param") Map<String, Object> param);
+
 }
 

+ 134 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ProxyDividendVo.java

@@ -0,0 +1,134 @@
+package com.ym.mec.biz.dal.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@ApiModel(value = "代理商人分润")
+public class ProxyDividendVo implements Serializable {
+    @ApiModelProperty(value = "意向机构")
+    private Integer tenantAgency;
+    @ApiModelProperty(value = "入驻机构")
+    private Integer preTenant;
+    @ApiModelProperty(value = "团练宝销售数")
+    private Integer memberCount;
+    @ApiModelProperty(value = "分页-分润数据")
+    private PageInfo<ProxyDividendInfoVo> pageData;
+
+    @ApiModel(value = "代理商人分润信息")
+    public static class ProxyDividendInfoVo {
+        @ApiModelProperty(value = "代理商id")
+        private Integer proxyId;
+
+        @ApiModelProperty(value = "代理商名称")
+        private String proxyName;
+
+        @ApiModelProperty(value = "机构id")
+        private Integer tenantId;
+
+        @ApiModelProperty(value = "机构名称")
+        private String tenantName;
+
+        @JsonFormat(pattern = "yyyy-MM-dd")
+        @ApiModelProperty(value = "激活时间")
+        private Date activeDate;
+
+        @ApiModelProperty(value = "激活数量")
+        private Integer activeCount;
+
+        @ApiModelProperty(value = "推荐人")
+        private Integer recommenderName;
+
+        public Integer getProxyId() {
+            return proxyId;
+        }
+
+        public void setProxyId(Integer proxyId) {
+            this.proxyId = proxyId;
+        }
+
+        public String getProxyName() {
+            return proxyName;
+        }
+
+        public void setProxyName(String proxyName) {
+            this.proxyName = proxyName;
+        }
+
+        public Integer getTenantId() {
+            return tenantId;
+        }
+
+        public void setTenantId(Integer tenantId) {
+            this.tenantId = tenantId;
+        }
+
+        public String getTenantName() {
+            return tenantName;
+        }
+
+        public void setTenantName(String tenantName) {
+            this.tenantName = tenantName;
+        }
+
+        public Date getActiveDate() {
+            return activeDate;
+        }
+
+        public void setActiveDate(Date activeDate) {
+            this.activeDate = activeDate;
+        }
+
+        public Integer getActiveCount() {
+            return activeCount;
+        }
+
+        public void setActiveCount(Integer activeCount) {
+            this.activeCount = activeCount;
+        }
+
+        public Integer getRecommenderName() {
+            return recommenderName;
+        }
+
+        public void setRecommenderName(Integer recommenderName) {
+            this.recommenderName = recommenderName;
+        }
+    }
+
+    public Integer getTenantAgency() {
+        return tenantAgency;
+    }
+
+    public void setTenantAgency(Integer tenantAgency) {
+        this.tenantAgency = tenantAgency;
+    }
+
+    public Integer getPreTenant() {
+        return preTenant;
+    }
+
+    public void setPreTenant(Integer preTenant) {
+        this.preTenant = preTenant;
+    }
+
+    public Integer getMemberCount() {
+        return memberCount;
+    }
+
+    public void setMemberCount(Integer memberCount) {
+        this.memberCount = memberCount;
+    }
+
+    public PageInfo<ProxyDividendInfoVo> getPageData() {
+        return pageData;
+    }
+
+    public void setPageData(PageInfo<ProxyDividendInfoVo> pageData) {
+        this.pageData = pageData;
+    }
+}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ProxyUserVo.java

@@ -11,6 +11,9 @@ public class ProxyUserVo implements Serializable {
     @ApiModelProperty(value = "当前人员id")
     private Integer userId;
 
+    @ApiModelProperty(value = "当前人员父级id")
+    private Integer parentId;
+
     @ApiModelProperty(value = "代理商id")
     private Integer proxyId;
 
@@ -37,6 +40,14 @@ public class ProxyUserVo implements Serializable {
         this.userId = userId;
     }
 
+    public Integer getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Integer parentId) {
+        this.parentId = parentId;
+    }
+
     public Integer getProxyId() {
         return proxyId;
     }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TenantProxyDividendService.java

@@ -3,6 +3,9 @@ package com.ym.mec.biz.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.biz.dal.dao.TenantProxyDividendDao;
 import com.ym.mec.biz.dal.entity.TenantProxyDividend;
+import com.ym.mec.biz.dal.vo.ProxyDividendVo;
+
+import java.util.Map;
 
 /**
  * 代理商分润表(TenantProxyDividend)表服务接口
@@ -13,5 +16,20 @@ import com.ym.mec.biz.dal.entity.TenantProxyDividend;
 public interface TenantProxyDividendService extends IService<TenantProxyDividend> {
 
     TenantProxyDividendDao getDao();
+
+    /**
+     * 分页查询代理商负责人数据
+     *
+     * @param param 传入参数
+     *
+     *              <p> -  proxyId 代理商id
+     *              <p> -  recommenderId 推荐人id
+     *              <p> -  startData 开始日期 年月日
+     *              <p> -  endData 结束日期 年月日
+     *              <p> - row 条数
+     *              <p> - page 页数
+     */
+    ProxyDividendVo queryProxyDividend(Map<String, Object> param);
+
 }
 

+ 61 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantProxyDividendServiceImpl.java

@@ -1,13 +1,27 @@
 package com.ym.mec.biz.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ym.mec.biz.dal.dao.TenantProxyDividendDao;
+import com.ym.mec.biz.dal.entity.TenantPreJoin;
 import com.ym.mec.biz.dal.entity.TenantProxyDividend;
+import com.ym.mec.biz.dal.vo.ProxyDividendVo;
+import com.ym.mec.biz.service.TenantPreJoinService;
 import com.ym.mec.biz.service.TenantProxyDividendService;
-import org.springframework.stereotype.Service;
-
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.BiConsumer;
 
 /**
  * 代理商分润表(TenantProxyDividend)表服务实现类
@@ -20,15 +34,59 @@ public class TenantProxyDividendServiceImpl extends ServiceImpl<TenantProxyDivid
 
     private final static Logger log = LoggerFactory.getLogger(TenantProxyDividendServiceImpl.class);
 
+    @Autowired
+    private TenantPreJoinService tenantPreJoinService;
+
     @Override
     public TenantProxyDividendDao getDao() {
         return this.baseMapper;
     }
 
     /**
-     * 机构在对团练宝进行激活时如果机构推荐人是代理商则需要写入代理商分润表
+     * 代理商人分润查询
+     *
+     * @param param 传入参数
+     *              <p> -  proxyId 代理商id
+     *              <p> -  recommenderId 推荐人id
+     *              <p> -  startData 开始日期 年月日
+     *              <p> -  endData 结束日期 年月日
+     *              <p> - row 条数
+     *              <p> - page 页数
+     * @return
      */
+    @Override
+    public ProxyDividendVo queryProxyDividend(Map<String, Object> param) {
+        Optional.ofNullable(param.get("startData")).orElseThrow(() -> new BizException("查询的开始日期不能为空!"));
+        Optional.ofNullable(param.get("endData")).orElseThrow(() -> new BizException("查询的结束日期不能为空"));
+        //拼接时分秒
+        BiConsumer<String, String> addTimeCons = (key, time) -> Optional.ofNullable(param.get(key)).map(String::valueOf)
+                .ifPresent(date -> param.put(key, date + " " + time));
+        addTimeCons.accept("startData", "00:00:00");
+        addTimeCons.accept("endData", "23:59:59");
 
+        ProxyDividendVo result = new ProxyDividendVo();
+        result.setPreTenant(0);
+        result.setTenantAgency(0);
+        //查询入驻信息
+        List<TenantPreJoin> preJoinsList = tenantPreJoinService.list(Wrappers.<TenantPreJoin>lambdaQuery()
+                .ge(TenantPreJoin::getCreatedTime, param.get("startData"))
+                .le(TenantPreJoin::getCreatedTime, param.get("endData")));
+        if (CollectionUtils.isNotEmpty(preJoinsList)) {
+            result.setTenantAgency(preJoinsList.size());
+            long count = preJoinsList.stream().filter(a -> a.getState() == 1).count();
+            result.setPreTenant((int) count);
+        }
+        //分页查询分润记录
+        Page<ProxyDividendVo.ProxyDividendInfoVo> pageInfo = PageUtil.getPageInfo(param);
+        pageInfo.setAsc("a.active_time_");
+        IPage<ProxyDividendVo.ProxyDividendInfoVo> tiPage = baseMapper.queryProxyDividendInfo(pageInfo, param);
+        Integer reduce = tiPage.getRecords().stream()
+                .map(ProxyDividendVo.ProxyDividendInfoVo::getActiveCount)
+                .reduce(0, Integer::sum);
+        result.setMemberCount(reduce);
+        result.setPageData(PageUtil.pageInfo(tiPage));
+        return result;
+    }
 
 }
 

+ 28 - 0
mec-biz/src/main/resources/config/mybatis/TenantProxyDividendMapper.xml

@@ -24,4 +24,32 @@
         </foreach>
     </insert>
 
+    <select id="queryProxyDividendInfo" resultType="com.ym.mec.biz.dal.vo.ProxyDividendVo$ProxyDividendInfoVo">
+        select a.proxy_id_ as proxyId,
+        b.proxy_name_ as proxyName,
+        c.id_ as tenantId,
+        c.name_ as tenantName,
+        a.active_time_ as activeDate,
+        a.total_month_ as activeCount,
+        d.real_name_ as recommenderName
+        from tenant_proxy_dividend as a
+        left join tenant_proxy_info as b on a.proxy_id_ = b.id_
+        left join tenant_info as c on a.tenant_id_ = c.id_
+        left join sys_user as d on c.recommender_ = d.id_
+        <where>
+            <if test="param.startDate != null">
+
+            </if>
+            <if test="param.startDate != null">
+
+            </if>
+            <if test="param.startDate != null">
+                AND a.active_time_ <![CDATA[ >= ]]> #{param.startDate}
+            </if>
+            <if test="param.endDate != null">
+                AND a.active_time_ <![CDATA[ <= ]]> #{param.endDate}
+            </if>
+        </where>
+    </select>
+
 </mapper>

+ 1 - 0
mec-biz/src/main/resources/config/mybatis/TenantProxyInfoMapper.xml

@@ -47,6 +47,7 @@
     <select id="queryProxyUserStaff" resultType="com.ym.mec.biz.dal.vo.ProxyUserVo">
         select
             b.id_ as userId,
+            a.parent_id_ as parentId,
             c.id_ as proxyId,
             c.proxy_name_ as proxyName,
             b.real_name_ as `name`,

+ 24 - 2
mec-web/src/main/java/com/ym/mec/web/controller/TenantProxyDividendController.java

@@ -1,13 +1,21 @@
 package com.ym.mec.web.controller;
 
 
-import com.ym.mec.biz.dal.entity.TenantProxyDividend;
+import com.ym.mec.biz.dal.vo.ProxyDividendVo;
 import com.ym.mec.biz.service.TenantProxyDividendService;
-import org.springframework.web.bind.annotation.*;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.Map;
 
 /**
  * 代理商分润表(TenantProxyDividend)表控制层
@@ -25,5 +33,19 @@ public class TenantProxyDividendController extends BaseController {
     @Resource
     private TenantProxyDividendService tenantProxyDividendService;
 
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "proxyId", dataType = "Integer", value = "代理商id"),
+            @ApiImplicitParam(name = "recommenderId", dataType = "Integer", value = "推荐人id"),
+            @ApiImplicitParam(name = "startData", dataType = "String", value = "开始日期 年月日"),
+            @ApiImplicitParam(name = "endData", dataType = "String", value = "结束日期 年月日"),
+            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
+            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
+    })
+    @ApiOperation("分页查询代理商负责人数据")
+    @PostMapping(value = "/queryProxyUser")
+    public HttpResponseResult<ProxyDividendVo> queryProxyDividend(@RequestBody Map<String, Object> param) {
+        return succeed(tenantProxyDividendService.queryProxyDividend(param));
+    }
+
 }