|
|
@@ -0,0 +1,95 @@
|
|
|
+package org.springblade.purchase.sales.controller;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.purchase.sales.entity.Order;
|
|
|
+import org.springblade.purchase.sales.service.IOrderService;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.MathContext;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 国内贸易app数据分析
|
|
|
+ * @author :jixinyuan
|
|
|
+ * @date : 2023/6/1
|
|
|
+ */
|
|
|
+
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/app/dataAnalysis")
|
|
|
+@Api(value = "国内贸易app数据分析", tags = "国内贸易app数据分析")
|
|
|
+public class DataAnalysisController {
|
|
|
+
|
|
|
+ private final IOrderService orderService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * app营业分析
|
|
|
+ */
|
|
|
+ @GetMapping("/turnoverAnalysis")
|
|
|
+ @ApiOperation(value = "app营业分析", notes = "传入参数")
|
|
|
+ public R<Map<String, Object>> turnoverAnalysis(@RequestParam(value = "statusDate", required = false) String statusDate,
|
|
|
+ @RequestParam(value = "endDate", required = false) String endDate) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ //销售
|
|
|
+ BigDecimal income = new BigDecimal("0.00");
|
|
|
+ //支出
|
|
|
+ BigDecimal expenditure = new BigDecimal("0.00");
|
|
|
+ //利润
|
|
|
+ BigDecimal profit = new BigDecimal("0.00");
|
|
|
+ //成本
|
|
|
+ BigDecimal cost = new BigDecimal("0.00");
|
|
|
+ //平均客单价
|
|
|
+ BigDecimal averageAmount = new BigDecimal("0.00");
|
|
|
+ Map<String, BigDecimal> mapXS = orderService.turnoverAnalysisDWT("XS", null, statusDate, endDate);
|
|
|
+
|
|
|
+ Map<String, BigDecimal> mapCG = orderService.turnoverAnalysisDWT("CG", null, statusDate, endDate);
|
|
|
+
|
|
|
+ income = income.add(mapXS.get("income"));
|
|
|
+
|
|
|
+ expenditure = expenditure.add(mapCG.get("expenditure"));
|
|
|
+
|
|
|
+ cost = cost.add(mapXS.get("cost"));
|
|
|
+
|
|
|
+ profit = profit.add(mapXS.get("profit"));
|
|
|
+
|
|
|
+ Order order = new Order();
|
|
|
+ order.setBillType("XS");
|
|
|
+ order.setTradeType("GN");
|
|
|
+ List<Order> orderList = orderService.turnoverAnalysisDWTList("XS", null, statusDate, endDate);
|
|
|
+ if (orderList.size() > 0 && !income.equals(new BigDecimal("0.00"))) {
|
|
|
+ averageAmount = averageAmount.add(income.divide(new BigDecimal(orderList.size()), MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ if (!new BigDecimal("0.00").equals(income)){
|
|
|
+ income = income.divide(new BigDecimal("1000"), MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ if (!new BigDecimal("0.00").equals(expenditure)){
|
|
|
+ expenditure = expenditure.divide(new BigDecimal("1000"), MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ if (!new BigDecimal("0.00").equals(profit)){
|
|
|
+ profit = profit.divide(new BigDecimal("1000"), MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ if (!new BigDecimal("0.00").equals(cost)){
|
|
|
+ cost = cost.divide(new BigDecimal("1000"), MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ if (!new BigDecimal("0.00").equals(averageAmount)){
|
|
|
+ averageAmount = averageAmount.divide(new BigDecimal("1000"), MathContext.DECIMAL32).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ map.put("income", income);
|
|
|
+ map.put("expenditure", expenditure);
|
|
|
+ map.put("profit", profit);
|
|
|
+ map.put("cost", cost);
|
|
|
+ map.put("averageAmount", averageAmount);
|
|
|
+ return R.data(map);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|