|
|
@@ -22,10 +22,7 @@ import com.kxs.stat.api.dto.statUser.StatUserGetMyTradeDTO;
|
|
|
import com.kxs.stat.api.dto.statUser.StatUserGetTradeDetailDTO;
|
|
|
import com.kxs.stat.api.dto.statUser.StatUserGetUserStatByDayOrMonthDTO;
|
|
|
import com.kxs.stat.api.dto.statUser.StatUserGetUserTradeListDTO;
|
|
|
-import com.kxs.stat.api.model.KxsLkbTrade;
|
|
|
-import com.kxs.stat.api.model.KxsUserActTrade;
|
|
|
-import com.kxs.stat.api.model.KxsUserLogoutTrade;
|
|
|
-import com.kxs.stat.api.model.KxsUserTrade;
|
|
|
+import com.kxs.stat.api.model.*;
|
|
|
import com.kxs.stat.api.vo.ShdTradeAmtVO;
|
|
|
import com.kxs.stat.api.vo.TotalTradeAmtVO;
|
|
|
import com.kxs.stat.api.vo.myUser.*;
|
|
|
@@ -257,7 +254,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
statUserGetUserStatByDayOrMonthVO.setActMchPercent(mchActPercentList);
|
|
|
|
|
|
//新增激活商户趋势图
|
|
|
- List<TrendVO> addMchTrendList = kxsUserActTradeService.getAddActMchTrend(userId, times, type == 1 ? 1 : 0, TotalTypeEnum.TEAM, getBrandMap());
|
|
|
+ List<TrendVO> addMchTrendList = kxsUserActTradeService.getAddActMchTrend(userId, times, type == 1 ? 1 : 0, TotalTypeEnum.TEAM, getBrandMap());
|
|
|
statUserGetUserStatByDayOrMonthVO.setMchAddTrend(addMchTrendList);
|
|
|
|
|
|
//新增创客趋势图
|
|
|
@@ -268,60 +265,33 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R getHomeAmout(Long userId) {
|
|
|
+ public R getHomeAmount(Long userId) {
|
|
|
LocalDate now = LocalDate.now();
|
|
|
- String month = LocalDateTimeUtil.format(now, DatePattern.SIMPLE_MONTH_PATTERN);
|
|
|
- String today = LocalDateTimeUtil.format(now, DatePattern.PURE_DATE_PATTERN);
|
|
|
+ Integer month = TotalDateUtil.getMonthNumber(now);
|
|
|
+ Integer today = TotalDateUtil.getDateNumber(now);
|
|
|
//拼接表名
|
|
|
String tableName = PREFIX_TABLE_NAME + month;
|
|
|
-//// 一次性查询全部数据 已弃用
|
|
|
-// StatUserGetHomeAmoutVO statUserGetHomeAmoutVO1 = baseMapper.getHomeAmout(userId,tableName,date,month);
|
|
|
//今日交易额
|
|
|
StatUserGetHomeAmoutVO statUserGetHomeAmoutVO = new StatUserGetHomeAmoutVO();
|
|
|
|
|
|
//获取团队日总交易额
|
|
|
- BigDecimal amountToDay = statUserGetHomeAmoutVO.getAmountToDay();
|
|
|
- amountToDay = getAmountToDayOrMonth(userId, today, tableName, amountToDay, 1);
|
|
|
+ BigDecimal amountToDay = getAmountToDayOrMonth(userId, today, tableName, TotalTypeEnum.TEAM.getType());
|
|
|
statUserGetHomeAmoutVO.setAmountToDay(amountToDay);
|
|
|
|
|
|
//获取团队月总交易额
|
|
|
- BigDecimal amountMonth = statUserGetHomeAmoutVO.getAmountMonth();
|
|
|
- amountMonth = getAmountToDayOrMonth(userId, month, tableName, amountMonth, 2);
|
|
|
+ BigDecimal amountMonth = getAmountToDayOrMonth(userId, month, tableName, TotalTypeEnum.TEAM.getType());
|
|
|
statUserGetHomeAmoutVO.setAmountMonth(amountMonth);
|
|
|
|
|
|
//获取今日新增用户
|
|
|
- Integer userAddToDay = statUserGetHomeAmoutVO.getUserAddToDay();
|
|
|
- List<String> todayList = Collections.singletonList(today);
|
|
|
- List<TrendTimesVO> userAddTrendToday = kxsUserNewTradeMapper.getUserAddTrend(userId, todayList, 1, 1);
|
|
|
- for (TrendTimesVO trendTimesVO : userAddTrendToday) {
|
|
|
- userAddToDay += trendTimesVO.getTotal();
|
|
|
- }
|
|
|
- statUserGetHomeAmoutVO.setUserAddToDay(userAddToDay);
|
|
|
-
|
|
|
+ statUserGetHomeAmoutVO.setUserAddToDay(kxsUserNewTradeMapper.selectToDayOrMonthCount(userId, today, TotalTypeEnum.TEAM.getType()));
|
|
|
//获取本月新增用户
|
|
|
- Integer userAddMonth = statUserGetHomeAmoutVO.getUserAddMonth();
|
|
|
- List<String> monthList = Collections.singletonList(month);
|
|
|
- List<TrendTimesVO> userAddTrendMonth = kxsUserNewTradeMapper.getUserAddTrend(userId, monthList, 2, 1);
|
|
|
- for (TrendTimesVO trendTimesVO : userAddTrendMonth) {
|
|
|
- userAddMonth += trendTimesVO.getTotal();
|
|
|
- }
|
|
|
- statUserGetHomeAmoutVO.setUserAddMonth(userAddMonth);
|
|
|
+ statUserGetHomeAmoutVO.setUserAddMonth(kxsUserNewTradeMapper.selectToDayOrMonthCount(userId, month, TotalTypeEnum.TEAM.getType()));
|
|
|
|
|
|
//获取今日新增商户
|
|
|
- Integer merchantAddToDay = statUserGetHomeAmoutVO.getMerchantAddToDay();
|
|
|
- List<TrendTimesVO> userActListByDay = kxsUserActTradeMapper.getUserActListByDayOrMonth(monthList, userId, null, 1, 1);
|
|
|
- for (TrendTimesVO trendTimesVO : userActListByDay) {
|
|
|
- merchantAddToDay += trendTimesVO.getTotal();
|
|
|
- }
|
|
|
- statUserGetHomeAmoutVO.setMerchantAddToDay(merchantAddToDay);
|
|
|
+ statUserGetHomeAmoutVO.setMerchantAddToDay(kxsUserActTradeMapper.getUserActByDayOrMonthCount(userId, today, TotalTypeEnum.SELF.getType()));
|
|
|
|
|
|
//获取本月新增商户
|
|
|
- Integer merchantAddMonth = statUserGetHomeAmoutVO.getMerchantAddMonth();
|
|
|
- List<TrendTimesVO> userActListByMonth = kxsUserActTradeMapper.getUserActListByDayOrMonth(monthList, userId, null, 2, 1);
|
|
|
- for (TrendTimesVO trendTimesVO : userActListByMonth) {
|
|
|
- merchantAddMonth += trendTimesVO.getTotal();
|
|
|
- }
|
|
|
- statUserGetHomeAmoutVO.setMerchantAddMonth(merchantAddMonth);
|
|
|
+ statUserGetHomeAmoutVO.setMerchantAddMonth(kxsUserActTradeMapper.getUserActByDayOrMonthCount(userId, month, TotalTypeEnum.TEAM.getType()));
|
|
|
return R.ok(statUserGetHomeAmoutVO);
|
|
|
}
|
|
|
|
|
|
@@ -329,21 +299,15 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
public R getMyTrade(StatUserGetMyTradeDTO param) {
|
|
|
Long userId = SecurityUtils.getUser().getId();
|
|
|
param.setUserId(userId);
|
|
|
- String month = param.getMonth();
|
|
|
- Integer type = param.getType();
|
|
|
+ Integer month = param.getMonth();
|
|
|
+ Integer totalType = param.getType();
|
|
|
//拼接表名
|
|
|
String tableName = CommonConstants.USER_TABLE_PREFIX + param.getMonth();
|
|
|
StatUserGetMyTradeVO statUserGetMyTradeVO = new StatUserGetMyTradeVO();
|
|
|
- KxsUserTrade kxsUserPosTrade = new KxsUserTrade();
|
|
|
+ //总交易
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
//获取pos交易额
|
|
|
- try {
|
|
|
- //此处存在查询的月份不在统计范围,找不到表的错误,直接包裹跳过视为当月无交易
|
|
|
- kxsUserPosTrade = baseMapper.getMyPosOrCloudTrade(param, tableName, 0, userId, "");
|
|
|
- } catch (Exception e) {
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- BigDecimal posDebitAmount = BigDecimal.ZERO;
|
|
|
- BigDecimal posCreditAmount = BigDecimal.ZERO;
|
|
|
+ KxsUserTrade kxsUserPosTrade = baseMapper.getMyPosOrCloudTrade(param, tableName, 0, userId, null);
|
|
|
if (kxsUserPosTrade != null) {
|
|
|
BigDecimal proBDirectTradeAmt = kxsUserPosTrade.getProBDirectTradeAmt();//稳定期B贷记卡
|
|
|
BigDecimal proADirectTradeAmt = kxsUserPosTrade.getProADirectTradeAmt();//稳定期A贷记卡
|
|
|
@@ -357,23 +321,19 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
BigDecimal helpDebitTradeAmt = kxsUserPosTrade.getHelpDebitTradeAmt();//扶持期借记卡
|
|
|
|
|
|
//pos借记卡
|
|
|
- posDebitAmount = posDebitAmount.add(proBDebitTradeAmt).add(proADebitTradeAmt).add(proDebitTradeAmt).add(helpDebitTradeAmt);
|
|
|
+ BigDecimal posDebitAmount = BigDecimal.ZERO.add(proBDebitTradeAmt).add(proADebitTradeAmt).add(proDebitTradeAmt).add(helpDebitTradeAmt);
|
|
|
//贷记卡
|
|
|
- posCreditAmount = posCreditAmount.add(proBDirectTradeAmt).add(proADirectTradeAmt).add(proDirectTradeAmt).add(helpDirectTradeAmt);
|
|
|
+ BigDecimal posCreditAmount = BigDecimal.ZERO.add(proBDirectTradeAmt).add(proADirectTradeAmt).add(proDirectTradeAmt).add(helpDirectTradeAmt);
|
|
|
+
|
|
|
+ statUserGetMyTradeVO.setPosDebitAmount(posDebitAmount);//Pos借记卡
|
|
|
+ statUserGetMyTradeVO.setPosCreditAmount(posCreditAmount);//Pos贷记卡
|
|
|
+
|
|
|
+ totalAmount = totalAmount.add(posDebitAmount).add(posCreditAmount);
|
|
|
}
|
|
|
- statUserGetMyTradeVO.setPosDebitAmount(posDebitAmount);//Pos借记卡
|
|
|
- statUserGetMyTradeVO.setPosCreditAmount(posCreditAmount);//Pos贷记卡
|
|
|
- KxsUserTrade kxsUserCloudTrade = new KxsUserTrade();
|
|
|
//获取云闪付交易额
|
|
|
- try {
|
|
|
- //此处存在查询的月份不在统计范围,找不到表的错误,直接包裹跳过视为当月无交易
|
|
|
- kxsUserCloudTrade = baseMapper.getMyPosOrCloudTrade(param, tableName, 1, userId, "");
|
|
|
- } catch (Exception e) {
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- BigDecimal cloudAmount = BigDecimal.ZERO;
|
|
|
+ KxsUserTrade kxsUserCloudTrade = baseMapper.getMyPosOrCloudTrade(param, tableName, 1, userId, "");
|
|
|
if (kxsUserCloudTrade != null) {
|
|
|
- cloudAmount = cloudAmount.add(kxsUserCloudTrade.getProBDirectTradeAmt())
|
|
|
+ BigDecimal cloudAmount = BigDecimal.ZERO.add(kxsUserCloudTrade.getProBDirectTradeAmt())
|
|
|
.add(kxsUserCloudTrade.getProADirectTradeAmt())
|
|
|
.add(kxsUserCloudTrade.getProDirectTradeAmt())
|
|
|
.add(kxsUserCloudTrade.getHelpDirectTradeAmt())
|
|
|
@@ -381,77 +341,93 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
.add(kxsUserCloudTrade.getProADebitTradeAmt())
|
|
|
.add(kxsUserCloudTrade.getProDebitTradeAmt())
|
|
|
.add(kxsUserCloudTrade.getHelpDebitTradeAmt());
|
|
|
+ statUserGetMyTradeVO.setCloudAmount(cloudAmount);
|
|
|
+ totalAmount = totalAmount.add(cloudAmount);
|
|
|
}
|
|
|
- statUserGetMyTradeVO.setCloudAmunt(cloudAmount);//云闪付
|
|
|
|
|
|
|
|
|
//助力宝交易额
|
|
|
- TotalTradeAmtVO totalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, month, 2, type);
|
|
|
- BigDecimal zlbAmt = BigDecimal.ZERO;
|
|
|
+ TotalTradeAmtVO totalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, month, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
+ BigDecimal zlbAmt = BigDecimal.ZERO;
|
|
|
zlbAmt = totalTradeAmtVO.getZlbAmt();
|
|
|
+ statUserGetMyTradeVO.setZlbAmount(zlbAmt);//助力宝
|
|
|
+ totalAmount = totalAmount.add(zlbAmt);
|
|
|
}
|
|
|
- statUserGetMyTradeVO.setZlbAmount(zlbAmt);//助力宝
|
|
|
-
|
|
|
|
|
|
- totalTradeAmtVO = kxsLkbTradeMapper.getLkbTrade(userId, month, 2, type);
|
|
|
- BigDecimal lkbActAmt = BigDecimal.ZERO;
|
|
|
- BigDecimal lkbAmt = BigDecimal.ZERO;
|
|
|
+ //来客吧交易额
|
|
|
+ totalTradeAmtVO = kxsLkbTradeMapper.getLkbTrade(userId, month, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
- lkbActAmt = totalTradeAmtVO.getLkbActAmt();
|
|
|
- lkbAmt = totalTradeAmtVO.getLkbAmt();
|
|
|
+ BigDecimal lkbActAmt = totalTradeAmtVO.getLkbActAmt();
|
|
|
+ BigDecimal lkbAmt = totalTradeAmtVO.getLkbAmt();
|
|
|
+ statUserGetMyTradeVO.setLkbActivityAmount(lkbActAmt);//来客吧活动
|
|
|
+ statUserGetMyTradeVO.setLkbAmount(lkbAmt);//来客吧非活动
|
|
|
+ totalAmount = totalAmount.add(lkbActAmt).add(lkbAmt);
|
|
|
}
|
|
|
- statUserGetMyTradeVO.setLkbActivityAmount(lkbActAmt);//来客吧活动
|
|
|
- statUserGetMyTradeVO.setLkbAmount(lkbAmt);//来客吧非活动
|
|
|
-
|
|
|
|
|
|
- totalTradeAmtVO = kxsUserGdTradeMapper.getGdTrade(userId, month, 2, type);
|
|
|
- BigDecimal gdAmount = BigDecimal.ZERO;
|
|
|
+ //广电话费
|
|
|
+ totalTradeAmtVO = kxsUserGdTradeMapper.getGdTrade(userId, month, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
- gdAmount = totalTradeAmtVO.getGdAmount();
|
|
|
+ BigDecimal gdAmount = totalTradeAmtVO.getGdAmount();
|
|
|
+
|
|
|
+ statUserGetMyTradeVO.setGdTelephoneCharge(gdAmount);
|
|
|
+ totalAmount = totalAmount.add(gdAmount);
|
|
|
}
|
|
|
- statUserGetMyTradeVO.setGdTelephoneCharge(gdAmount);//广电话费
|
|
|
|
|
|
//广电交易额
|
|
|
- totalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, month, 2, type);
|
|
|
- BigDecimal gdActivityAmount = BigDecimal.ZERO;
|
|
|
+ totalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, month, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
Integer gdCount = totalTradeAmtVO.getGdCount();
|
|
|
//广电激活量 * 10000
|
|
|
- gdActivityAmount = gdActivityAmount.add(new BigDecimal(gdCount * 10000));
|
|
|
+ BigDecimal gdActivityAmount = BigDecimal.ZERO.add(new BigDecimal(gdCount * CommonConstants.GD_TO_PRICE));
|
|
|
+ //广电活动
|
|
|
+ statUserGetMyTradeVO.setGdActivityAmount(gdActivityAmount);
|
|
|
+
|
|
|
+ totalAmount = totalAmount.add(gdActivityAmount);
|
|
|
}
|
|
|
- statUserGetMyTradeVO.setGdActivityAmount(gdActivityAmount);//广电活动
|
|
|
|
|
|
- BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
- totalAmount = totalAmount.add(posDebitAmount).add(posCreditAmount).add(cloudAmount).add(zlbAmt).add(lkbActAmt).add(lkbAmt).add(gdAmount).add(gdActivityAmount);
|
|
|
- statUserGetMyTradeVO.setTotalAmount(totalAmount);//总交易
|
|
|
|
|
|
- //获取指定月新增用户
|
|
|
- Integer userAddMonth = 0;
|
|
|
- List<String> monthList = Arrays.asList(month);
|
|
|
- List<TrendTimesVO> userAddTrendMonth = kxsUserNewTradeMapper.getUserAddTrend(userId, monthList, 2, type);
|
|
|
- for (TrendTimesVO trendTimesVO : userAddTrendMonth) {
|
|
|
- userAddMonth += trendTimesVO.getTotal();
|
|
|
- }
|
|
|
- statUserGetMyTradeVO.setUserAddCount(userAddMonth);//新增用户
|
|
|
|
|
|
|
|
|
- Integer totalUserCount = kxsUserNewTradeMapper.getUserAllTrend(userId, type);
|
|
|
- statUserGetMyTradeVO.setTotalUserCount(totalUserCount != null ? totalUserCount : 0);//总用户
|
|
|
+ //获取指定月新增用户
|
|
|
+ Integer userAddMonth = kxsUserNewTradeMapper.selectToDayOrMonthCount(userId, month, TotalTypeEnum.TEAM.getType());
|
|
|
+ statUserGetMyTradeVO.setUserAddCount(userAddMonth);
|
|
|
|
|
|
- //获取累计全部激活商户
|
|
|
- Integer merchantAddMonth = kxsUserActTradeMapper.getUserActListByAll(userId, type, 1, 3, null);
|
|
|
- statUserGetMyTradeVO.setActivateMerchantCount(merchantAddMonth);//商户总激活
|
|
|
+ //总用户
|
|
|
+ Long totalUserCount = kxsUserNewTradeMapper.selectCount(Wrappers.<KxsUserNewTrade>lambdaQuery()
|
|
|
+ .eq(KxsUserNewTrade::getUserId, userId)
|
|
|
+ .eq(KxsUserNewTrade::getTotalType, totalType));
|
|
|
+ statUserGetMyTradeVO.setTotalUserCount(totalUserCount);
|
|
|
|
|
|
- //获取累计全部激活码牌
|
|
|
- Integer signCount = kxsLkbActTradeMapper.getSignCount(userId, type);
|
|
|
+ //获取累计全部激活商户
|
|
|
+ Long merchantAddMonth = kxsUserActTradeMapper.selectCount(Wrappers.<KxsUserActTrade>lambdaQuery()
|
|
|
+ .eq(KxsUserActTrade::getUserId, userId)
|
|
|
+ .eq(KxsUserActTrade::getTotalType, totalType));
|
|
|
+ statUserGetMyTradeVO.setActivateMerchantCount(merchantAddMonth != null ? merchantAddMonth : 0);//商户总激活
|
|
|
+
|
|
|
+ //获取当月全部激活码牌
|
|
|
+ Long signCount = kxsLkbActTradeMapper.selectCount(Wrappers.<KxsLkbActTrade>lambdaQuery()
|
|
|
+ .eq(KxsLkbActTrade::getUserId, userId)
|
|
|
+ .eq(KxsLkbActTrade::getTotalType, totalType)
|
|
|
+ .eq(KxsLkbActTrade::getTradeMonth, month));
|
|
|
statUserGetMyTradeVO.setActivateSignCount(signCount != null ? signCount : 0);//码牌
|
|
|
|
|
|
- //获取
|
|
|
- Integer simCount = kxsUserActTradeMapper.getUserActListByAll(userId, type, 2, 2, Integer.valueOf(month));
|
|
|
+ //存量激活广电卡
|
|
|
+ Long simCount = kxsUserActTradeMapper.selectCount(Wrappers.<KxsUserActTrade>lambdaQuery()
|
|
|
+ .eq(KxsUserActTrade::getUserId, userId)
|
|
|
+ .eq(KxsUserActTrade::getBrandId, 14)
|
|
|
+ .eq(KxsUserActTrade::getTotalType, totalType));
|
|
|
statUserGetMyTradeVO.setActivateSIMCount(simCount != null ? simCount : 0);//存量激活sim卡
|
|
|
- Integer simToMonthCount = kxsUserActTradeMapper.getUserActListByAll(userId, type, 2, 1, Integer.valueOf(month));
|
|
|
- statUserGetMyTradeVO.setActivateSIMToMonthCount(simToMonthCount != null ? simToMonthCount : 0);//当月
|
|
|
+ //当月激活广电卡
|
|
|
+ Long simToMonthCount = kxsUserActTradeMapper.selectCount(Wrappers.<KxsUserActTrade>lambdaQuery()
|
|
|
+ .eq(KxsUserActTrade::getUserId, userId)
|
|
|
+ .eq(KxsUserActTrade::getBrandId, 14)
|
|
|
+ .eq(KxsUserActTrade::getTradeMonth, month)
|
|
|
+ .eq(KxsUserActTrade::getTotalType, totalType));
|
|
|
+ statUserGetMyTradeVO.setActivateSIMToMonthCount(simToMonthCount != null ? simToMonthCount : 0);
|
|
|
+
|
|
|
+ statUserGetMyTradeVO.setTotalAmount(totalAmount);
|
|
|
+
|
|
|
statUserGetMyTradeVO.setType(param.getType());
|
|
|
return R.ok(statUserGetMyTradeVO);
|
|
|
}
|
|
|
@@ -494,7 +470,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
}
|
|
|
}
|
|
|
- return R.ok();
|
|
|
+ return R.ok();
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -505,21 +481,20 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
Integer getType = param.getGetType();// 1获取日详情 2获取月详情
|
|
|
Integer tradeType = param.getTradeType();//1获取增量 2获取存量 3获取全部
|
|
|
Long userId = param.getUserId();//用户id
|
|
|
- if(userId == null || userId == 0){
|
|
|
+ if (userId == null || userId == 0) {
|
|
|
userId = SecurityUtils.getUser().getId();
|
|
|
}
|
|
|
Integer brandId = param.getBrandId();//品牌id
|
|
|
|
|
|
String tableName;
|
|
|
- switch (tradeType){
|
|
|
+ switch (tradeType) {
|
|
|
case 1 -> tableName = CommonConstants.USER_TABLE_AFTER_PREFIX + month;
|
|
|
case 2 -> tableName = CommonConstants.USER_TABLE_BEFORE_PREFIX + month;
|
|
|
case 3 -> tableName = CommonConstants.USER_TABLE_PREFIX + month;
|
|
|
- default -> throw new GlobalCustomerException("参数错误");
|
|
|
+ default -> throw new GlobalCustomerException("参数错误");
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
StatUserGetTradeDetailVO statUserGetTradeDetailVO = new StatUserGetTradeDetailVO();
|
|
|
statUserGetTradeDetailVO.setDate(month);//交易时间
|
|
|
statUserGetTradeDetailVO.setBrandId(brandId);//品牌
|
|
|
@@ -619,7 +594,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = new ArrayList<>();
|
|
|
//构造查询Dto
|
|
|
StatUserGetMyTradeDTO statUserGetMyTradeDTO = new StatUserGetMyTradeDTO();
|
|
|
- statUserGetMyTradeDTO.setMonth(month);
|
|
|
+ statUserGetMyTradeDTO.setMonth(Integer.valueOf(month));
|
|
|
statUserGetMyTradeDTO.setType(totalType);
|
|
|
for (int i = times.size() - 1; i >= 0; i--) {
|
|
|
String time = times.get(i);
|
|
|
@@ -654,7 +629,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
//获取交易额
|
|
|
//构造查询Dto
|
|
|
StatUserGetMyTradeDTO statUserGetMyTradeDTO = new StatUserGetMyTradeDTO();
|
|
|
- statUserGetMyTradeDTO.setMonth(month);
|
|
|
+ statUserGetMyTradeDTO.setMonth(Integer.valueOf(month));
|
|
|
statUserGetMyTradeDTO.setType(totalType);
|
|
|
ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = new ArrayList<>();
|
|
|
//查询进半年需要循环查询不同的表
|
|
|
@@ -705,7 +680,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
KxsUserTrade myCloudTrade = null;
|
|
|
try {
|
|
|
//存在表不存在的月份,跳过报错视为无数据 查询云闪付
|
|
|
- myCloudTrade = baseMapper.getMyPosOrCloudTrade(statUserGetMyTradeDTO, tableName, 1, userId, getType == 1 ? date:null);
|
|
|
+ myCloudTrade = baseMapper.getMyPosOrCloudTrade(statUserGetMyTradeDTO, tableName, 1, userId, getType == 1 ? date : null);
|
|
|
} catch (Exception e) {
|
|
|
log.info(e.getMessage());
|
|
|
}
|
|
|
@@ -737,7 +712,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
|
|
|
if (!tradeType.equals(2)) {//存量不存在以下数据
|
|
|
//助力宝交易额
|
|
|
- TotalTradeAmtVO TotalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, String.valueOf(date), getType, totalType);
|
|
|
+ TotalTradeAmtVO TotalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, Integer.valueOf(date), totalType);
|
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
|
|
|
|
|
|
|
@@ -746,7 +721,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
totalAmount = totalAmount.add(zlbAmt);
|
|
|
|
|
|
//来客吧交易额
|
|
|
- TotalTradeAmtVO = kxsLkbTradeMapper.getLkbTrade(userId, String.valueOf(date), getType, totalType);
|
|
|
+ TotalTradeAmtVO = kxsLkbTradeMapper.getLkbTrade(userId, Integer.valueOf(date), totalType);
|
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
|
|
|
|
BigDecimal lkbActAmt = TotalTradeAmtVO.getLkbActAmt() == null ? BigDecimal.ZERO : TotalTradeAmtVO.getLkbActAmt();
|
|
|
@@ -758,7 +733,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
statUserGetUserTradeStatListVO.setLkbAmount(lkbAmt);
|
|
|
totalAmount = totalAmount.add(lkbAmt);
|
|
|
//广电话费
|
|
|
- TotalTradeAmtVO = kxsUserGdTradeMapper.getGdTrade(userId, String.valueOf(date), getType, totalType);
|
|
|
+ TotalTradeAmtVO = kxsUserGdTradeMapper.getGdTrade(userId, Integer.valueOf(date), totalType);
|
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
|
|
|
|
BigDecimal gdAmount = TotalTradeAmtVO.getGdAmount() == null ? BigDecimal.ZERO : TotalTradeAmtVO.getGdAmount();
|
|
|
@@ -768,9 +743,9 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
if (tradeType.equals(3)) {//广电获取全部
|
|
|
//广电激活量
|
|
|
if (getType == 1) {
|
|
|
- TotalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, String.valueOf(date), 3, totalType);
|
|
|
+ TotalTradeAmtVO = kxsUserGdTradeMapper.getGdActAllCount(userId, Integer.valueOf(date), totalType);
|
|
|
} else {
|
|
|
- TotalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, String.valueOf(date), 4, totalType);
|
|
|
+ TotalTradeAmtVO = kxsUserGdTradeMapper.getGdActAllCount(userId, Integer.valueOf(date), totalType);
|
|
|
}
|
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
|
|
|
|
@@ -779,7 +754,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
}
|
|
|
if (tradeType.equals(1)) {//广电获取增量 只获取当前时间
|
|
|
//广电激活量
|
|
|
- TotalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, String.valueOf(date), getType, totalType);
|
|
|
+ TotalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, Integer.valueOf(date), totalType);
|
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
|
|
|
|
BigDecimal gdActAmt = BigDecimal.valueOf(TotalTradeAmtVO.getGdCount() != null ? TotalTradeAmtVO.getGdCount() * 10000 : 0);
|
|
|
@@ -790,37 +765,48 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
statUserGetUserTradeStatListVO.setTotalAmount(totalAmount);
|
|
|
|
|
|
//查询各品牌交易总额
|
|
|
- List<StatUserBrandTradeVO> statUserBrandTradeVOS = baseMapper.getStatUserBrandTradeVOS(userId,getType, tableName,totalType,date);
|
|
|
+ List<StatUserBrandTradeVO> statUserBrandTradeVOS = baseMapper.getStatUserBrandTradeVOS(userId, getType, tableName, totalType, date);
|
|
|
statUserGetUserTradeStatListVO.setProductList(statUserBrandTradeVOS);
|
|
|
return statUserGetUserTradeStatListVO;
|
|
|
}
|
|
|
|
|
|
- private BigDecimal getAmountToDayOrMonth(Long userId, String date, String tableName, BigDecimal amount, int type) {
|
|
|
+ /**
|
|
|
+ * 获取天或月的交易金额
|
|
|
+ *
|
|
|
+ * @param userId 用户 ID
|
|
|
+ * @param date 日期
|
|
|
+ * @param tableName 表名
|
|
|
+ * @param totalType 0个人 1团队
|
|
|
+ * @return {@link BigDecimal}
|
|
|
+ */
|
|
|
+ private BigDecimal getAmountToDayOrMonth(Long userId, Integer date, String tableName, Integer totalType) {
|
|
|
+
|
|
|
+ BigDecimal amount = BigDecimal.ZERO;
|
|
|
//pos交易
|
|
|
- TotalTradeAmtVO totalTradeAmtVO = baseMapper.getPosTrade(userId, tableName, date, type);
|
|
|
+ TotalTradeAmtVO totalTradeAmtVO = baseMapper.getPosTrade(userId, tableName, date, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
amount = amount.add(totalTradeAmtVO.getPosAmt());
|
|
|
}
|
|
|
//来客吧交易额
|
|
|
- totalTradeAmtVO = kxsLkbTradeMapper.getLkbTrade(userId, date, type, 1);
|
|
|
+ totalTradeAmtVO = kxsLkbTradeMapper.getLkbTrade(userId, date, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
amount = amount.add(totalTradeAmtVO.getLkbAmt());
|
|
|
amount = amount.add(totalTradeAmtVO.getLkbActAmt());
|
|
|
}
|
|
|
//助力宝交易额
|
|
|
- totalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, date, type, 1);
|
|
|
+ totalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, date, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
amount = amount.add(totalTradeAmtVO.getZlbAmt());
|
|
|
}
|
|
|
//广电交易额
|
|
|
- totalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, date, type, 1);
|
|
|
+ totalTradeAmtVO = kxsUserGdTradeMapper.getGdActCount(userId, date, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
Integer gdCount = totalTradeAmtVO.getGdCount();
|
|
|
//广电激活量 * 10000
|
|
|
- amount = amount.add(new BigDecimal(gdCount * 10000));
|
|
|
+ amount = amount.add(new BigDecimal(gdCount * CommonConstants.GD_TO_PRICE));
|
|
|
}
|
|
|
//广电话费
|
|
|
- totalTradeAmtVO = kxsUserGdTradeMapper.getGdTrade(userId, date, type, 1);
|
|
|
+ totalTradeAmtVO = kxsUserGdTradeMapper.getGdTrade(userId, date, totalType);
|
|
|
if (totalTradeAmtVO != null) {
|
|
|
amount = amount.add(totalTradeAmtVO.getGdAmount());
|
|
|
}
|
|
|
@@ -839,7 +825,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
private List<PercentVO> setTradeTotalAndPercent(Long userId, List<Integer> times, Integer type) {
|
|
|
|
|
|
List<PercentVO> percentVOList = new ArrayList<>();
|
|
|
- if(type == 1){
|
|
|
+ if (type == 1) {
|
|
|
//近7天
|
|
|
for (Integer day : times) {
|
|
|
Integer month = TotalDateUtil.getMonthNumber(LocalDateTimeUtil.parseDate(String.valueOf(day), DatePattern.PURE_DATE_PATTERN));
|
|
|
@@ -853,7 +839,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
return o1;
|
|
|
})).values().stream().toList();
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//近半年
|
|
|
for (Integer month : times) {
|
|
|
List<PercentVO> userTradeTotal = baseMapper.getUserTradeMonthTotal(CommonConstants.USER_TABLE_PREFIX + month, userId, TotalTypeEnum.TEAM.getType());
|
|
|
@@ -881,7 +867,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
|
|
|
MonthTableNameHandler.setData(MonthTableNameHandler.getThisMoth());
|
|
|
List<TrendVO> trendVOList = new ArrayList<>();
|
|
|
- if(type == 1){
|
|
|
+ if (type == 1) {
|
|
|
//近7天交易趋势图
|
|
|
LinkedHashMap<Integer, List<TrendTimesVO>> tradeTrend = new LinkedHashMap<>();
|
|
|
for (Integer day : times) {
|
|
|
@@ -892,7 +878,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
}
|
|
|
initUserTrend(trendVOList, tradeTrend);
|
|
|
}
|
|
|
- if(type == 2){
|
|
|
+ if (type == 2) {
|
|
|
//近半年
|
|
|
LinkedHashMap<Integer, List<TrendTimesVO>> tradeTrend = new LinkedHashMap<>();
|
|
|
|
|
|
@@ -906,7 +892,8 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
|
|
|
return trendVOList;
|
|
|
}
|
|
|
- private void initUserTrend(List<TrendVO> trendVOList, LinkedHashMap<Integer, List<TrendTimesVO>> tradeTrend){
|
|
|
+
|
|
|
+ private void initUserTrend(List<TrendVO> trendVOList, LinkedHashMap<Integer, List<TrendTimesVO>> tradeTrend) {
|
|
|
//全部交易额
|
|
|
TrendVO trendVO = new TrendVO();
|
|
|
trendVO.setName("全部");
|
|
|
@@ -935,8 +922,8 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Map<Integer, KxsBrand>getBrandMap(){
|
|
|
- if(brandsMap == null){
|
|
|
+ private Map<Integer, KxsBrand> getBrandMap() {
|
|
|
+ if (brandsMap == null) {
|
|
|
R<List<KxsBrand>> brandRes = remoteKxsProductService.loadByAllBrand();
|
|
|
List<KxsBrand> brands = RetOps.of(brandRes)
|
|
|
.getData()
|