|
@@ -1,13 +1,27 @@
|
|
package com.ym.mec.biz.service.impl;
|
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.ym.mec.biz.dal.dao.TenantProxyDividendDao;
|
|
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.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 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.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
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)表服务实现类
|
|
* 代理商分润表(TenantProxyDividend)表服务实现类
|
|
@@ -20,15 +34,59 @@ public class TenantProxyDividendServiceImpl extends ServiceImpl<TenantProxyDivid
|
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(TenantProxyDividendServiceImpl.class);
|
|
private final static Logger log = LoggerFactory.getLogger(TenantProxyDividendServiceImpl.class);
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TenantPreJoinService tenantPreJoinService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public TenantProxyDividendDao getDao() {
|
|
public TenantProxyDividendDao getDao() {
|
|
return this.baseMapper;
|
|
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;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|