|
@@ -1,6 +1,9 @@
|
|
|
package com.fuint.module.backendApi.controller;
|
|
|
|
|
|
import com.fuint.common.dto.AccountInfo;
|
|
|
+import com.fuint.common.dto.GoodsTopDto;
|
|
|
+import com.fuint.common.dto.MemberTopDto;
|
|
|
+import com.fuint.common.service.GoodsService;
|
|
|
import com.fuint.common.service.MemberService;
|
|
|
import com.fuint.common.service.OrderService;
|
|
|
import com.fuint.common.util.DateUtil;
|
|
@@ -8,16 +11,16 @@ import com.fuint.common.util.TokenUtil;
|
|
|
import com.fuint.framework.exception.BusinessCheckException;
|
|
|
import com.fuint.framework.web.BaseController;
|
|
|
import com.fuint.framework.web.ResponseObject;
|
|
|
+import com.fuint.utils.StringUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 数据统计控制器
|
|
@@ -36,6 +39,9 @@ public class BackendStatisticController extends BaseController {
|
|
|
@Resource
|
|
|
private OrderService orderService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private GoodsService goodsService;
|
|
|
+
|
|
|
/**
|
|
|
* 数据概况
|
|
|
*
|
|
@@ -49,8 +55,8 @@ public class BackendStatisticController extends BaseController {
|
|
|
String startTimeStr = param.get("startTime") == null ? "" : param.get("startTime").toString();
|
|
|
String endTimeStr = param.get("endTime") == null ? "" : param.get("endTime").toString();
|
|
|
|
|
|
- Date startTime = DateUtil.parseDate(startTimeStr);
|
|
|
- Date endTime = DateUtil.parseDate(endTimeStr);
|
|
|
+ Date startTime = StringUtil.isNotEmpty(startTimeStr) ? DateUtil.parseDate(startTimeStr) : null;
|
|
|
+ Date endTime = StringUtil.isNotEmpty(endTimeStr) ? DateUtil.parseDate(endTimeStr) : null;
|
|
|
|
|
|
AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
if (accountInfo == null) {
|
|
@@ -103,14 +109,30 @@ public class BackendStatisticController extends BaseController {
|
|
|
@ApiOperation(value = "排行榜数据")
|
|
|
@RequestMapping(value = "/top", method = RequestMethod.POST)
|
|
|
@CrossOrigin
|
|
|
- public ResponseObject top(HttpServletRequest request, @RequestBody Map<String, Object> param) {
|
|
|
+ public ResponseObject top(HttpServletRequest request, @RequestBody Map<String, Object> param) throws ParseException {
|
|
|
String token = request.getHeader("Access-Token");
|
|
|
+ String startTimeStr = param.get("startTime") == null ? "" : param.get("startTime").toString();
|
|
|
+ String endTimeStr = param.get("endTime") == null ? "" : param.get("endTime").toString();
|
|
|
+
|
|
|
+ Date startTime = StringUtil.isNotEmpty(startTimeStr) ? DateUtil.parseDate(startTimeStr) : null;
|
|
|
+ Date endTime = StringUtil.isNotEmpty(endTimeStr) ? DateUtil.parseDate(endTimeStr) : null;
|
|
|
+
|
|
|
AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
if (accountInfo == null) {
|
|
|
return getFailureResult(1001, "请先登录");
|
|
|
}
|
|
|
|
|
|
+ Integer merchantId = accountInfo.getMerchantId();
|
|
|
+ Integer storeId = accountInfo.getStoreId();
|
|
|
+
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
+
|
|
|
+ List<GoodsTopDto> goodsList = goodsService.getGoodsSaleTopList(merchantId, storeId, startTime, endTime);
|
|
|
+ List<MemberTopDto> memberList = memberService.getMemberConsumeTopList(merchantId, storeId, startTime, endTime);
|
|
|
+
|
|
|
+ result.put("goodsList", goodsList);
|
|
|
+ result.put("memberList", memberList);
|
|
|
+
|
|
|
return getSuccessResult(result);
|
|
|
}
|
|
|
}
|