|
@@ -4,13 +4,19 @@ 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.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
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.TenantProxyUserRelation;
|
|
|
+import com.ym.mec.biz.dal.vo.ProxyDividendInfoVo;
|
|
|
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.TenantProxyUserRelationService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.PageUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -20,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
|
@@ -36,6 +43,10 @@ public class TenantProxyDividendServiceImpl extends ServiceImpl<TenantProxyDivid
|
|
|
|
|
|
@Autowired
|
|
|
private TenantPreJoinService tenantPreJoinService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ @Autowired
|
|
|
+ private TenantProxyUserRelationService tenantProxyUserRelationService;
|
|
|
|
|
|
@Override
|
|
|
public TenantProxyDividendDao getDao() {
|
|
@@ -43,6 +54,30 @@ public class TenantProxyDividendServiceImpl extends ServiceImpl<TenantProxyDivid
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 代理商分润汇总查询
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ProxyDividendVo queryProxyDividend() {
|
|
|
+ ProxyDividendVo result = new ProxyDividendVo();
|
|
|
+ result.setPreTenant(0);
|
|
|
+ result.setTenantAgency(0);
|
|
|
+ //查询入驻信息
|
|
|
+ List<TenantPreJoin> preJoinsList = tenantPreJoinService.list();
|
|
|
+ if (CollectionUtils.isNotEmpty(preJoinsList)) {
|
|
|
+ result.setTenantAgency(preJoinsList.size());
|
|
|
+ long count = preJoinsList.stream()
|
|
|
+ .filter(a -> Objects.nonNull(a.getState()) && a.getState() == 1)
|
|
|
+ .count();
|
|
|
+ result.setPreTenant((int) count);
|
|
|
+ }
|
|
|
+
|
|
|
+ //团练宝销售数
|
|
|
+ int count = baseMapper.queryProxyDividendCount();
|
|
|
+ result.setMemberCount(count);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 代理商分润查询
|
|
|
*
|
|
|
* @param param 传入参数
|
|
@@ -55,7 +90,7 @@ public class TenantProxyDividendServiceImpl extends ServiceImpl<TenantProxyDivid
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ProxyDividendVo queryProxyDividend(Map<String, Object> param) {
|
|
|
+ public PageInfo<ProxyDividendInfoVo> queryProxyDividendInfo(Map<String, Object> param) {
|
|
|
Optional.ofNullable(param.get("startData")).orElseThrow(() -> new BizException("查询的开始日期不能为空!"));
|
|
|
Optional.ofNullable(param.get("endData")).orElseThrow(() -> new BizException("查询的结束日期不能为空!"));
|
|
|
//拼接时分秒
|
|
@@ -64,30 +99,27 @@ public class TenantProxyDividendServiceImpl extends ServiceImpl<TenantProxyDivid
|
|
|
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);
|
|
|
+ SysUser user = getUser();
|
|
|
+ //当前登录人是代理商账号类型,需要做数据隔离
|
|
|
+ if (user.getUserType().equalsIgnoreCase("PROXY")) {
|
|
|
+ //查询代理商
|
|
|
+ TenantProxyUserRelation proxyUserRelation = tenantProxyUserRelationService.getOne(Wrappers.<TenantProxyUserRelation>lambdaQuery()
|
|
|
+ .eq(TenantProxyUserRelation::getUserId, user.getId()));
|
|
|
+ if (Objects.nonNull(proxyUserRelation)) {
|
|
|
+ param.put("proxyId", proxyUserRelation.getProxyId());
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- //团练宝销售数
|
|
|
- int count = baseMapper.queryProxyDividendCount(param);
|
|
|
- result.setMemberCount(count);
|
|
|
-
|
|
|
//分页查询分润记录
|
|
|
- Page<ProxyDividendVo.ProxyDividendInfoVo> pageInfo = PageUtil.getPageInfo(param);
|
|
|
+ Page<ProxyDividendInfoVo> pageInfo = PageUtil.getPageInfo(param);
|
|
|
pageInfo.setAsc("a.active_time_");
|
|
|
- IPage<ProxyDividendVo.ProxyDividendInfoVo> tiPage = baseMapper.queryProxyDividendInfo(pageInfo, param);
|
|
|
- result.setPageData(PageUtil.pageInfo(tiPage));
|
|
|
- return result;
|
|
|
+ IPage<ProxyDividendInfoVo> tiPage = baseMapper.queryProxyDividendInfo(pageInfo, param);
|
|
|
+ return PageUtil.pageInfo(tiPage);
|
|
|
}
|
|
|
|
|
|
+ private SysUser getUser() {
|
|
|
+ //修改机构基础信息
|
|
|
+ return Optional.ofNullable(sysUserFeignService.queryUserInfo())
|
|
|
+ .orElseThrow(() -> new BizException("用户信息获取失败,请刷新页面或者重新登录!"));
|
|
|
+ }
|
|
|
}
|
|
|
|