Răsfoiți Sursa

订单数据日周月环比展示

zoujiajian 1 an în urmă
părinte
comite
10a31dc3f1

+ 2 - 2
netflix-dao/src/main/java/com/cyksj/model/views/PlatOrderDonBrokenLineView.java

@@ -17,7 +17,7 @@ import java.math.BigDecimal;
 @Setter
 @SearchBean(tables = "order_don od",
 		where = "od.status not in ('noPayment','close','refund')"
-		, groupBy = "od.goods_id,date_format(od.created_time,'%Y-%m-%d')")
+		, groupBy = "od.goods_id,:date:")
 public class PlatOrderDonBrokenLineView {
 	@DbField("od.goods_id")
 	private Long goodsId;
@@ -37,6 +37,6 @@ public class PlatOrderDonBrokenLineView {
 	/**
 	 * 日期
 	 */
-	@DbField("date_format(od.created_time,'%Y-%m-%d')")
+	@DbField(":date:")
 	private String date;
 }

+ 9 - 1
netflix-web/src/main/java/com/cyksj/web/controller/manage/statistics/StatisticsDataController.java

@@ -488,9 +488,10 @@ public class StatisticsDataController {
 
 	/**
 	 * 获取每日平台订单折线数据
+	 * @param chain 默认1日 2周 3月
 	 */
 	@GetMapping("/get/plat/brokenLine")
-	public Result<BrokenLineObjView> getPlatBrokenLine(Long firstDate, Long lastDate) {
+	public Result<BrokenLineObjView> getPlatBrokenLine(Long firstDate, Long lastDate, @RequestParam(defaultValue = "1") Integer chain) {
 		String first = null;
 		String end = null;
 		if (firstDate != null) {
@@ -499,11 +500,18 @@ public class StatisticsDataController {
 		if (lastDate != null) {
 			end = DateUtil.format(DateTime.of(lastDate), "yyyy-MM-dd");
 		}
+		String dateSqL = "date_format(od.created_time,'%Y-%m-%d')";
+		if (chain == 2) {
+			dateSqL = "DATE_FORMAT(created_time - INTERVAL (DAYOFWEEK(created_time) - 2) DAY, '%Y-%m-%d')";
+		} else if (chain == 3) {
+			dateSqL = "DATE_FORMAT(od.created_time, '%Y-%m')";
+		}
 		BrokenLineObjView brokenLineObjView = Optional.ofNullable(orderDonMapper.selectPlatBrokenLineMoney(first, end))
 				.orElse(new BrokenLineObjView());
 
 		if (brokenLineObjView != null) {
 			List<PlatOrderDonBrokenLineView> views = beanSearcher.searchAll(PlatOrderDonBrokenLineView.class, MapUtils.builder()
+					.put("date", dateSqL)
 					.field(PlatOrderDonBrokenLineView::getDate, first, end).op(Operator.Between)
 					.orderBy(PlatOrderDonBrokenLineView::getDate).asc()
 					.build());