|
|
@@ -10,6 +10,7 @@ import com.github.microservice.models.type.PaymentDeviceType;
|
|
|
import com.github.microservice.models.type.PaymentType;
|
|
|
import com.zhongshu.card.client.model.payment.*;
|
|
|
import com.zhongshu.card.client.model.payment.statistic.BusinessMainStatisticModel;
|
|
|
+import com.zhongshu.card.client.model.payment.statistic.StatisticItem;
|
|
|
import com.zhongshu.card.client.model.payment.statistic.StatisticSearch;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.client.ret.ResultMessage;
|
|
|
@@ -50,7 +51,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -113,9 +116,11 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
public ResultContent<ExpenseFlow> createExpenseFlowByHxz(ConsumTransactionsModel iotParam, ExpenseFlow expenseFlow) {
|
|
|
expenseFlow.setMqttDataId(iotParam.getMqttDataId());
|
|
|
|
|
|
- expenseFlow.setYear(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyy));
|
|
|
- expenseFlow.setMonth(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternMM));
|
|
|
- expenseFlow.setWeek(DateUtils.getCurrentWeekInYear() + "");
|
|
|
+ expenseFlow.setYear(DateUtils.getCurrentYear());
|
|
|
+ expenseFlow.setMonth(DateUtils.getCurrentMonthInYear());
|
|
|
+ expenseFlow.setWeek(DateUtils.getCurrentWeekInYear());
|
|
|
+ expenseFlow.setDayOfMonth(DateUtils.getCurrentDayInMonth());
|
|
|
+ expenseFlow.setDayOfYear(DateUtils.getCurrentDayInYear());
|
|
|
expenseFlow.setPaymentTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
|
// 消费订单号
|
|
|
@@ -211,8 +216,11 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
expenseFlow.setOrderFromType(OrderFromType.QrCode);
|
|
|
expenseFlow.setUserId(userId);
|
|
|
|
|
|
- expenseFlow.setYear(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyy));
|
|
|
- expenseFlow.setMonth(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternMM));
|
|
|
+ expenseFlow.setYear(DateUtils.getCurrentYear());
|
|
|
+ expenseFlow.setMonth(DateUtils.getCurrentMonthInYear());
|
|
|
+ expenseFlow.setWeek(DateUtils.getCurrentWeekInYear());
|
|
|
+ expenseFlow.setDayOfMonth(DateUtils.getCurrentDayInMonth());
|
|
|
+ expenseFlow.setDayOfYear(DateUtils.getCurrentDayInYear());
|
|
|
expenseFlow.setPaymentTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
|
// 消费订单号
|
|
|
@@ -584,14 +592,57 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
* @param statisticSearch
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent businessMainPageStatistic(StatisticSearch statisticSearch) {
|
|
|
+ public ResultContent<BusinessMainStatisticModel> businessMainPageStatistic(StatisticSearch statisticSearch) {
|
|
|
BusinessMainStatisticModel statisticModel = new BusinessMainStatisticModel();
|
|
|
|
|
|
ExpenseFlowSearch param = new ExpenseFlowSearch();
|
|
|
param.setIsPaySuccess(Boolean.TRUE);
|
|
|
BeanUtils.copyProperties(statisticSearch, param);
|
|
|
+ List<String> shopOids = getSearchAllShopOid(param);
|
|
|
+ if (ObjectUtils.isEmpty(shopOids)) {
|
|
|
+ return ResultContent.buildFail("请选择查询商户或所有的");
|
|
|
+ }
|
|
|
+ param.setShopOids(shopOids);
|
|
|
+
|
|
|
+ param.setYear(DateUtils.getCurrentYear());
|
|
|
// 统计模型,按 月、周
|
|
|
StatisticType statisticType = param.getStatisticType();
|
|
|
+ if (statisticType != null) {
|
|
|
+ param.setFieldName(statisticType.getFieldName());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StatisticItem> items = new ArrayList<>();
|
|
|
+ // 统计项
|
|
|
+ Map<String, BigDecimal> map = expenseFlowDao.statisticItems(param);
|
|
|
+ if (statisticType != null) {
|
|
|
+ // 构建item
|
|
|
+ if (statisticType == StatisticType.Month) {
|
|
|
+ // 按月
|
|
|
+ int month = DateUtils.getCurrentMonthInYear();
|
|
|
+ for (int i = 0; i <= month; i++) {
|
|
|
+ String key = String.valueOf(i);
|
|
|
+ BigDecimal value = BigDecimal.ZERO;
|
|
|
+ if (map.containsKey(key)) {
|
|
|
+ value = map.get(key);
|
|
|
+ }
|
|
|
+ StatisticItem item = StatisticItem.builder().name(key).amount(value).build();
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ } else if (statisticType == StatisticType.Week) {
|
|
|
+ // 按月
|
|
|
+ int week = DateUtils.getCurrentWeekInYear();
|
|
|
+ for (int i = 0; i <= week; i++) {
|
|
|
+ String key = String.valueOf(i);
|
|
|
+ BigDecimal value = BigDecimal.ZERO;
|
|
|
+ if (map.containsKey(key)) {
|
|
|
+ value = map.get(key);
|
|
|
+ }
|
|
|
+ StatisticItem item = StatisticItem.builder().name(key).amount(value).build();
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ statisticModel.setItems(items);
|
|
|
|
|
|
|
|
|
return ResultContent.buildSuccess(statisticModel);
|