|
|
@@ -1,7 +1,5 @@
|
|
|
package com.cyksj.web.controller.cps;
|
|
|
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -14,36 +12,25 @@ import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.GoodsDonMapper;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
|
import com.cyksj.model.dto.AuthRedirect;
|
|
|
import com.cyksj.model.dto.AuthToken;
|
|
|
import com.cyksj.model.dto.CpsAuthDto;
|
|
|
import com.cyksj.model.dto.GzhOAuth2UserInfo;
|
|
|
-import com.cyksj.model.entity.*;
|
|
|
+import com.cyksj.model.entity.User;
|
|
|
+import com.cyksj.model.entity.UserDistribute;
|
|
|
import com.cyksj.model.request.LoginReq;
|
|
|
-import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.authorization.AuthorizationService;
|
|
|
import com.cyksj.service.cps.CpsManageService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
import com.cyksj.web.util.StpCpsManageUser;
|
|
|
-import com.ejlchina.searcher.BeanSearcher;
|
|
|
-import com.ejlchina.searcher.SearchResult;
|
|
|
-import com.ejlchina.searcher.util.MapBuilder;
|
|
|
-import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/*
|
|
|
*项目名: netflix
|
|
|
@@ -57,12 +44,6 @@ import java.util.stream.Collectors;
|
|
|
public class CpsBackLoginController {
|
|
|
private final CpsManageService cpsManageService;
|
|
|
|
|
|
- private final BeanSearcher beanSearcher;
|
|
|
-
|
|
|
- private final HttpServletRequest request;
|
|
|
-
|
|
|
- private final GoodsDonMapper goodsDonMapper;
|
|
|
-
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
private final static Sequence SEQUENCE = new Sequence(0);
|
|
|
@@ -169,118 +150,4 @@ public class CpsBackLoginController {
|
|
|
redisService.del(key);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(o.toString());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 个人分销平台数据详情
|
|
|
- */
|
|
|
- @GetMapping("/get/distribute/detail")
|
|
|
- public Result<CpsUserDistributeDetailView> getDistributeDetail() {
|
|
|
- long cpsUserId = StpCpsManageUser.getLoginIdAsLong();
|
|
|
- User user = beanSearcher.searchFirst(User.class, MapUtils.builder().field(User::getId, cpsUserId).onlySelect(User::getPoints).build());
|
|
|
- BigDecimal thresholdPoints = BigDecimal.valueOf(1000);
|
|
|
- BigDecimal wApplyMoney = user.getPoints().divide(thresholdPoints, 2, RoundingMode.DOWN);
|
|
|
- //已提现
|
|
|
- Number gotApplyMoney = beanSearcher.searchSum(DistributeMoneyApply.class, MapUtils.builder()
|
|
|
- .field(DistributeMoneyApply::getUserId, cpsUserId)
|
|
|
- .field(DistributeMoneyApply::getVerifyStatus, DistributeMoneyApply.Status.success.name())
|
|
|
- .build(), "money");
|
|
|
- Number reMoneyPoints = beanSearcher.searchSum(DistributeWaitingSendPoints.class, MapUtils.builder().field(DistributeWaitingSendPoints::getSharedId, cpsUserId).field(DistributeWaitingSendPoints::getSendStatus, DistributeWaitingSendPoints.Status.success.name()).build(), "points");
|
|
|
- Number wMoneyPoints = beanSearcher.searchSum(DistributeWaitingSendPoints.class, MapUtils.builder().field(DistributeWaitingSendPoints::getSharedId, cpsUserId).field(DistributeWaitingSendPoints::getSendStatus, DistributeWaitingSendPoints.Status.waiting.name()).build(), "points");
|
|
|
- List<UserDistributeRateView> rateViews = beanSearcher.searchAll(UserDistributeRateView.class, MapUtils.builder()
|
|
|
- .put("distribute_id", String.format("and distribute_id = (select id from user_distribute where user_id = %s and deleted is true limit 1)", cpsUserId))
|
|
|
- .orderBy(UserDistributeRateView::getRate).desc()
|
|
|
- .build());
|
|
|
- CpsUserDistributeDetailView detailView = new CpsUserDistributeDetailView();
|
|
|
- Map<String, List<UserDistributeRateView>> collect = rateViews.stream().filter(ct -> StrUtil.isNotBlank(ct.getCategoryName())).collect(Collectors.groupingBy(UserDistributeRateView::getCategoryName));
|
|
|
- detailView.setRateViews(collect);
|
|
|
- detailView.setWMoney(BigDecimal.valueOf(wMoneyPoints.doubleValue()).divide(thresholdPoints, 2, RoundingMode.DOWN));
|
|
|
- detailView.setReMoney(BigDecimal.valueOf(reMoneyPoints.doubleValue()).divide(thresholdPoints, 2, RoundingMode.DOWN));
|
|
|
-
|
|
|
- detailView.setWApplyMoney(wApplyMoney);
|
|
|
- detailView.setGotApplyMoney(BigDecimal.valueOf(gotApplyMoney.doubleValue()).divide(BigDecimal.valueOf(100)));
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(detailView);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 待入账数据统计
|
|
|
- */
|
|
|
- @GetMapping("/get/wMoney/statisticsData")
|
|
|
- public Result<BrokenLineCpsUserWMoneyView> getWMoneyStatisticsDataView(Long firstDate, Long lastDate) {
|
|
|
- long cpsUserId = StpCpsManageUser.getLoginIdAsLong();
|
|
|
- DateTime first = null;
|
|
|
- DateTime end = null;
|
|
|
- if (firstDate != null) {
|
|
|
- first = DateUtil.date(firstDate);
|
|
|
- }
|
|
|
- if (lastDate != null) {
|
|
|
- end = DateUtil.date(lastDate);
|
|
|
- }
|
|
|
- BrokenLineCpsUserWMoneyView brokenLineCpsUserWMoneyView = Optional.ofNullable(cpsManageService.getWMoneyStatisticsDate(cpsUserId, first, end)).orElse(new BrokenLineCpsUserWMoneyView());
|
|
|
- List<CpsUserWMoneyStatisticsDataView> dataView = cpsManageService.getWMoneyStatisticsDataView(cpsUserId, first, end);
|
|
|
- brokenLineCpsUserWMoneyView.setDataView(dataView);
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(brokenLineCpsUserWMoneyView);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分销订单收入统计
|
|
|
- */
|
|
|
- @GetMapping("/get/distribute/orders/statistics")
|
|
|
- public Result<SearchResult<UserDistributeOrdersStatisticsView>> getUserDistributeOrdersStatisticsView(Long firstDate, Long lastDate) {
|
|
|
- long cpsUserId = StpCpsManageUser.getLoginIdAsLong();
|
|
|
- String first = null;
|
|
|
- String end = null;
|
|
|
- String timeSql = StrUtil.EMPTY;
|
|
|
- if (firstDate != null) {
|
|
|
- first = DateUtil.format(DateTime.of(firstDate), "yyyy-MM-dd HH:mm:ss");
|
|
|
- timeSql += String.format(" and o.created_time >= '%s'", first);
|
|
|
- }
|
|
|
- if (lastDate != null) {
|
|
|
- end = DateUtil.format(DateTime.of(lastDate), "yyyy-MM-dd HH:mm:ss");
|
|
|
- timeSql += String.format(" and o.created_time < '%s'", end);
|
|
|
- }
|
|
|
- MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
- builder.put("sharedId", String.format("shared_id = %s", cpsUserId));
|
|
|
- if (StrUtil.isNotEmpty(timeSql)) {
|
|
|
- builder.put("time", timeSql);
|
|
|
- }
|
|
|
- SearchResult<UserDistributeOrdersStatisticsView> search = beanSearcher.search(UserDistributeOrdersStatisticsView.class, builder.build());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分销订单收入详细
|
|
|
- */
|
|
|
- @GetMapping("/get/distribute/orders/detail")
|
|
|
- public Result<SearchResult<UserDistributeOrdersDetailView>> getUserDistributeOrdersDetailView(Long firstDate, Long lastDate) {
|
|
|
- long cpsUserId = StpCpsManageUser.getLoginIdAsLong();
|
|
|
- String first = null;
|
|
|
- String end = null;
|
|
|
- String timeSql = StrUtil.EMPTY;
|
|
|
- if (firstDate != null) {
|
|
|
- first = DateUtil.format(DateTime.of(firstDate), "yyyy-MM-dd HH:mm:ss");
|
|
|
- timeSql += String.format(" and o.created_time >= '%s'", first);
|
|
|
- }
|
|
|
- if (lastDate != null) {
|
|
|
- end = DateUtil.format(DateTime.of(lastDate), "yyyy-MM-dd HH:mm:ss");
|
|
|
- timeSql += String.format(" and o.created_time < '%s'", end);
|
|
|
- }
|
|
|
- MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
- builder.put("sharedId", String.format("shared_id = %s", cpsUserId));
|
|
|
- if (StrUtil.isNotEmpty(timeSql)) {
|
|
|
- builder.put("time", timeSql);
|
|
|
- }
|
|
|
- SearchResult<UserDistributeOrdersDetailView> search = beanSearcher.search(UserDistributeOrdersDetailView.class, builder.build());
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分销商品列表
|
|
|
- */
|
|
|
- @GetMapping("/get/goods")
|
|
|
- public Result<List<GoodsDon>> getGoodsList() {
|
|
|
- long cpsUserId = StpCpsManageUser.getLoginIdAsLong();
|
|
|
- List<GoodsDon> goodsDons = goodsDonMapper.getDistributeGoodsDetail(cpsUserId);
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDons);
|
|
|
- }
|
|
|
}
|