|
@@ -1,7 +1,6 @@
|
|
|
package com.kxs.stat.biz.service.impl;
|
|
package com.kxs.stat.biz.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
@@ -472,37 +471,52 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
Integer getType = param.getGetType();//获取类型 1获取月 2获取半年
|
|
Integer getType = param.getGetType();//获取类型 1获取月 2获取半年
|
|
|
Integer tradeType = param.getTradeType();//1获取增量 2获取存量 3获取全部
|
|
Integer tradeType = param.getTradeType();//1获取增量 2获取存量 3获取全部
|
|
|
LocalDate now = LocalDate.now();
|
|
LocalDate now = LocalDate.now();
|
|
|
- String tableName = "";
|
|
|
|
|
|
|
+ String tableName;
|
|
|
List<String> times = new ArrayList<>();
|
|
List<String> times = new ArrayList<>();
|
|
|
- if (tradeType.equals(3)) {//获取全部
|
|
|
|
|
- tableName = PREFIX_TABLE_NAME; //全部
|
|
|
|
|
- if (getType.equals(2)) {//查询近半年
|
|
|
|
|
- ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListVOSByMonth(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
- return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
- } else if (getType.equals(1)) {//查询月详细
|
|
|
|
|
- ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
- return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
- }
|
|
|
|
|
- } else if (tradeType.equals(2)) {
|
|
|
|
|
- tableName = PREFIX_TABLE_NAME_BEFORE; //存量
|
|
|
|
|
- if (getType.equals(2)) {//查询近半年
|
|
|
|
|
- ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListVOSByMonth(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
- return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
- } else if (getType.equals(1)) {//查询月详细
|
|
|
|
|
- ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
- return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
- }
|
|
|
|
|
- } else if (tradeType.equals(1)) {
|
|
|
|
|
- tableName = PREFIX_TABLE_NAME_AFTER; //增量
|
|
|
|
|
- if (getType.equals(2)) {//查询近半年
|
|
|
|
|
- ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListVOSByMonth(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
- return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
- } else if (getType.equals(1)) {//查询月详细
|
|
|
|
|
- ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
- return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ switch (tradeType){
|
|
|
|
|
+ case 1 -> tableName = PREFIX_TABLE_NAME_AFTER; //增量
|
|
|
|
|
+ case 2 -> tableName = PREFIX_TABLE_NAME_BEFORE; //存量
|
|
|
|
|
+ case 3 -> tableName = PREFIX_TABLE_NAME; //全部
|
|
|
|
|
+ default -> throw new GlobalCustomerException("参数错误");
|
|
|
}
|
|
}
|
|
|
- return R.ok();
|
|
|
|
|
|
|
+ ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS;
|
|
|
|
|
+ if(getType == 1){
|
|
|
|
|
+ statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+ }else if(getType == 2){
|
|
|
|
|
+ statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListByMonth(totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return R.failed("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// if (tradeType.equals(3)) {//获取全部
|
|
|
|
|
+// tableName = PREFIX_TABLE_NAME; //全部
|
|
|
|
|
+// if (getType.equals(2)) {//查询近半年
|
|
|
|
|
+// ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListByMonth(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+// return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// } else if (getType.equals(1)) {//查询月详细
|
|
|
|
|
+// ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+// return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// }
|
|
|
|
|
+// } else if (tradeType.equals(2)) {
|
|
|
|
|
+// tableName = PREFIX_TABLE_NAME_BEFORE; //存量
|
|
|
|
|
+// if (getType.equals(2)) {//查询近半年
|
|
|
|
|
+// ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListByMonth(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+// return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// } else if (getType.equals(1)) {//查询月详细
|
|
|
|
|
+// ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+// return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// }
|
|
|
|
|
+// } else if (tradeType.equals(1)) {
|
|
|
|
|
+// tableName = PREFIX_TABLE_NAME_AFTER; //增量
|
|
|
|
|
+// if (getType.equals(2)) {//查询近半年
|
|
|
|
|
+// ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getStatUserGetUserTradeStatListByMonth(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+// return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// } else if (getType.equals(1)) {//查询月详细
|
|
|
|
|
+// ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = getUserGetUserTradeStatListVOSByDay(month, totalType, userId, getType, now, times, tableName, tradeType);
|
|
|
|
|
+// return R.ok(statUserGetUserTradeStatListVOS);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -659,7 +673,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private ArrayList<StatUserGetUserTradeStatListVO> getStatUserGetUserTradeStatListVOSByMonth(String month, Integer totalType, Long userId, Integer getType, LocalDate now, List<String> times, String tableName, Integer tradeType) {
|
|
|
|
|
|
|
+ private ArrayList<StatUserGetUserTradeStatListVO> getStatUserGetUserTradeStatListByMonth(Integer totalType, Long userId, Integer getType, LocalDate now, List<String> times, String tableName, Integer tradeType) {
|
|
|
//近半年
|
|
//近半年
|
|
|
for (int i = 0; i < 6; i++) {
|
|
for (int i = 0; i < 6; i++) {
|
|
|
// 计算过去半年每月月份
|
|
// 计算过去半年每月月份
|
|
@@ -671,7 +685,6 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
//获取交易额
|
|
//获取交易额
|
|
|
//构造查询Dto
|
|
//构造查询Dto
|
|
|
StatUserGetMyTradeDTO statUserGetMyTradeDTO = new StatUserGetMyTradeDTO();
|
|
StatUserGetMyTradeDTO statUserGetMyTradeDTO = new StatUserGetMyTradeDTO();
|
|
|
- statUserGetMyTradeDTO.setMonth(Integer.valueOf(month));
|
|
|
|
|
statUserGetMyTradeDTO.setType(totalType);
|
|
statUserGetMyTradeDTO.setType(totalType);
|
|
|
ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = new ArrayList<>();
|
|
ArrayList<StatUserGetUserTradeStatListVO> statUserGetUserTradeStatListVOS = new ArrayList<>();
|
|
|
//查询进半年需要循环查询不同的表
|
|
//查询进半年需要循环查询不同的表
|
|
@@ -685,7 +698,7 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
if (myPosTrade == null) {
|
|
if (myPosTrade == null) {
|
|
|
myPosTrade = new KxsUserTrade();
|
|
myPosTrade = new KxsUserTrade();
|
|
|
}
|
|
}
|
|
|
- StatUserGetUserTradeStatListVO statUserGetUserTradeStatListVO = getMonthTrade(totalType, userId, getType, statUserGetMyTradeDTO, myPosTrade, month, time, tableName, tradeType);
|
|
|
|
|
|
|
+ StatUserGetUserTradeStatListVO statUserGetUserTradeStatListVO = getMonthTrade(totalType, userId, getType, statUserGetMyTradeDTO, myPosTrade, time, time, tableName, tradeType);
|
|
|
statUserGetUserTradeStatListVO.setTime(time);
|
|
statUserGetUserTradeStatListVO.setTime(time);
|
|
|
statUserGetUserTradeStatListVOS.add(statUserGetUserTradeStatListVO);
|
|
statUserGetUserTradeStatListVOS.add(statUserGetUserTradeStatListVO);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -752,7 +765,8 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
statUserGetUserTradeStatListVO.setCloudAmunt(posAmount);
|
|
statUserGetUserTradeStatListVO.setCloudAmunt(posAmount);
|
|
|
totalAmount = totalAmount.add(posAmount);
|
|
totalAmount = totalAmount.add(posAmount);
|
|
|
|
|
|
|
|
- if (!tradeType.equals(2)) {//存量不存在以下数据
|
|
|
|
|
|
|
+ //存量不存在以下数据
|
|
|
|
|
+ if (tradeType != 2) {
|
|
|
//助力宝交易额
|
|
//助力宝交易额
|
|
|
TotalTradeAmtVO TotalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, Integer.valueOf(date), totalType);
|
|
TotalTradeAmtVO TotalTradeAmtVO = kxsZlbTradeMapper.getZlbTrade(userId, Integer.valueOf(date), totalType);
|
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
TotalTradeAmtVO = TotalTradeAmtVO == null ? new TotalTradeAmtVO() : TotalTradeAmtVO;
|
|
@@ -807,7 +821,15 @@ public class KxsUserTradeServiceImpl extends ServiceImpl<KxsUserTradeMapper, Kxs
|
|
|
statUserGetUserTradeStatListVO.setTotalAmount(totalAmount);
|
|
statUserGetUserTradeStatListVO.setTotalAmount(totalAmount);
|
|
|
|
|
|
|
|
//查询各品牌交易总额
|
|
//查询各品牌交易总额
|
|
|
- List<StatUserBrandTradeVO> statUserBrandTradeVOS = baseMapper.getStatUserBrandTradeVOS(userId, getType, tableName, totalType, date);
|
|
|
|
|
|
|
+ List<StatUserBrandTradeVO> statUserBrandTradeVOS;
|
|
|
|
|
+ if(getType == 1){
|
|
|
|
|
+ statUserBrandTradeVOS = baseMapper.getStatUserBrandTradeTotalMonthDay(tableName, userId, totalType, date);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ statUserBrandTradeVOS = baseMapper.getStatUserBrandTradeTotalMonth(tableName, userId, totalType);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (StatUserBrandTradeVO statUserBrandTradeVO : statUserBrandTradeVOS) {
|
|
|
|
|
+ statUserBrandTradeVO.setBrandName(getBrandMap().get(statUserBrandTradeVO.getBrandId()).getName());
|
|
|
|
|
+ }
|
|
|
statUserGetUserTradeStatListVO.setProductList(statUserBrandTradeVOS);
|
|
statUserGetUserTradeStatListVO.setProductList(statUserBrandTradeVOS);
|
|
|
return statUserGetUserTradeStatListVO;
|
|
return statUserGetUserTradeStatListVO;
|
|
|
}
|
|
}
|