add product/order chart
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.service.GaoProductChartService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductCategoryStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockHealthView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockMovementDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductTypeStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductUnitSalesRankView;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 产品图表接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/product/chart")
|
||||
public class GaoProductChartController {
|
||||
|
||||
private final GaoProductChartService service;
|
||||
private final GaoStoreScopeService storeScopeService;
|
||||
|
||||
/// 查询产品每日销售统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/sales/daily")
|
||||
public List<GaoProductSalesDailyStatView> salesDaily(@RequestBody GaoProductChartReq req) {
|
||||
return service.salesDaily(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品销售排行
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/sales/rank")
|
||||
public List<GaoProductSalesRankView> salesRank(@RequestBody GaoProductChartReq req) {
|
||||
return service.salesRank(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品每日履约统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/fulfillment/daily")
|
||||
public List<GaoProductFulfillmentDailyStatView> fulfillmentDaily(@RequestBody GaoProductChartReq req) {
|
||||
return service.fulfillmentDaily(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品履约进度排行
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/fulfillment/rank")
|
||||
public List<GaoProductFulfillmentRankView> fulfillmentRank(@RequestBody GaoProductChartReq req) {
|
||||
return service.fulfillmentRank(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品每日库存变动统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/stock/movement/daily")
|
||||
public List<GaoProductStockMovementDailyStatView> stockMovementDaily(@RequestBody GaoProductChartReq req) {
|
||||
return service.stockMovementDaily(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品库存健康度
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/stock/health")
|
||||
public List<GaoProductStockHealthView> stockHealth(@RequestBody GaoProductChartReq req) {
|
||||
return service.stockHealth(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品类型统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/structure/type")
|
||||
public List<GaoProductTypeStatView> type(@RequestBody GaoProductChartReq req) {
|
||||
return service.type(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品分类统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/structure/category")
|
||||
public List<GaoProductCategoryStatView> category(@RequestBody GaoProductChartReq req) {
|
||||
return service.category(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询产品销售单位排行
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/sales/unit/rank")
|
||||
public List<GaoProductUnitSalesRankView> unitSalesRank(@RequestBody GaoProductChartReq req) {
|
||||
return service.unitSalesRank(normalize(req));
|
||||
}
|
||||
|
||||
private GaoProductChartReq normalize(GaoProductChartReq req) {
|
||||
TimiException.required(req, "not found product chart req");
|
||||
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||
return req;
|
||||
}
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
package com.imyeyu.api.modules.gao.controller;
|
||||
|
||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermission;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoPermissionCode;
|
||||
import com.imyeyu.api.modules.gao.service.GaoSalesOrderChartService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreScopeService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderProductRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatIntervalStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderCalendarStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderPaymentStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderReceivableStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderStatusStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderTypeStatView;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 销售订单图表接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/gao/sales/order/chart")
|
||||
public class GaoSalesOrderChartController {
|
||||
|
||||
private final GaoSalesOrderChartService service;
|
||||
private final GaoStoreScopeService storeScopeService;
|
||||
|
||||
/// 查询销售订单每日统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/daily")
|
||||
public List<GaoSalesOrderDailyStatView> daily(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.daily(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询销售订单类型统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/type")
|
||||
public List<GaoSalesOrderTypeStatView> type(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.type(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询销售订单付款状态统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/payment")
|
||||
public List<GaoSalesOrderPaymentStatView> payment(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.payment(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询客户订单排行
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/rank")
|
||||
public List<GaoCustomerOrderRankView> customerRank(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.customerRank(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询指定客户订单产品排行
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/product/rank")
|
||||
public List<GaoCustomerOrderProductRankView> customerProductRank(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.customerProductRank(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询销售订单状态统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/status")
|
||||
public List<GaoSalesOrderStatusStatView> status(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.status(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询销售订单应收统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/receivable")
|
||||
public GaoSalesOrderReceivableStatView receivable(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.receivable(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询客户每日有效消费统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/consumption/daily")
|
||||
public List<GaoSalesOrderConsumptionDailyStatView> consumptionDaily(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.consumptionDaily(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询客户订单日历统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/calendar")
|
||||
public List<GaoSalesOrderCalendarStatView> calendar(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.calendar(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询客户每日复购统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/repeat/daily")
|
||||
public List<GaoCustomerRepeatDailyStatView> repeatDaily(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.repeatDaily(normalize(req));
|
||||
}
|
||||
|
||||
/// 查询客户复购间隔统计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/customer/repeat/interval")
|
||||
public List<GaoCustomerRepeatIntervalStatView> repeatInterval(@RequestBody GaoSalesOrderChartReq req) {
|
||||
return service.repeatInterval(normalize(req));
|
||||
}
|
||||
|
||||
private GaoSalesOrderChartReq normalize(GaoSalesOrderChartReq req) {
|
||||
TimiException.required(req, "not found sales order chart req");
|
||||
req.setStoreId(storeScopeService.resolveStoreId(req.getStoreId()));
|
||||
return req;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.imyeyu.api.modules.gao.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductCategoryStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockHealthView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockMovementDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductTypeStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductUnitSalesRankView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 产品图表 Mapper
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
public interface GaoProductChartMapper {
|
||||
|
||||
/// 查询产品每日销售统计
|
||||
List<GaoProductSalesDailyStatView> selectSalesDaily(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品销售排行
|
||||
List<GaoProductSalesRankView> selectSalesRank(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品每日履约统计
|
||||
List<GaoProductFulfillmentDailyStatView> selectFulfillmentDaily(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品履约进度排行
|
||||
List<GaoProductFulfillmentRankView> selectFulfillmentRank(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品每日库存变动统计
|
||||
List<GaoProductStockMovementDailyStatView> selectStockMovementDaily(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品库存健康度
|
||||
List<GaoProductStockHealthView> selectStockHealth(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品类型统计
|
||||
List<GaoProductTypeStatView> selectType(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品分类统计
|
||||
List<GaoProductCategoryStatView> selectCategory(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品销售单位排行
|
||||
List<GaoProductUnitSalesRankView> selectUnitSalesRank(GaoProductChartReq req);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.imyeyu.api.modules.gao.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderProductRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatIntervalStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderCalendarStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderPaymentStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderReceivableStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderStatusStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderTypeStatView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 销售订单图表 Mapper
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
public interface GaoSalesOrderChartMapper {
|
||||
|
||||
/// 查询销售订单每日统计
|
||||
List<GaoSalesOrderDailyStatView> selectDaily(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单类型统计
|
||||
List<GaoSalesOrderTypeStatView> selectType(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单付款状态统计
|
||||
List<GaoSalesOrderPaymentStatView> selectPayment(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户订单排行
|
||||
List<GaoCustomerOrderRankView> selectCustomerRank(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户订单产品排行
|
||||
List<GaoCustomerOrderProductRankView> selectCustomerProductRank(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单状态统计
|
||||
List<GaoSalesOrderStatusStatView> selectStatus(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单应收统计
|
||||
GaoSalesOrderReceivableStatView selectReceivable(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户每日有效消费统计
|
||||
List<GaoSalesOrderConsumptionDailyStatView> selectConsumptionDaily(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户订单日历统计
|
||||
List<GaoSalesOrderCalendarStatView> selectCalendar(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户每日复购统计
|
||||
List<GaoCustomerRepeatDailyStatView> selectRepeatDaily(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户复购间隔统计
|
||||
List<GaoCustomerRepeatIntervalStatView> selectRepeatInterval(GaoSalesOrderChartReq req);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.imyeyu.api.modules.gao.service;
|
||||
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductCategoryStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockHealthView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockMovementDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductTypeStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductUnitSalesRankView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 产品图表服务
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
public interface GaoProductChartService {
|
||||
|
||||
/// 查询产品每日销售统计
|
||||
List<GaoProductSalesDailyStatView> salesDaily(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品销售排行
|
||||
List<GaoProductSalesRankView> salesRank(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品每日履约统计
|
||||
List<GaoProductFulfillmentDailyStatView> fulfillmentDaily(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品履约进度排行
|
||||
List<GaoProductFulfillmentRankView> fulfillmentRank(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品每日库存变动统计
|
||||
List<GaoProductStockMovementDailyStatView> stockMovementDaily(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品库存健康度
|
||||
List<GaoProductStockHealthView> stockHealth(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品类型统计
|
||||
List<GaoProductTypeStatView> type(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品分类统计
|
||||
List<GaoProductCategoryStatView> category(GaoProductChartReq req);
|
||||
|
||||
/// 查询产品销售单位排行
|
||||
List<GaoProductUnitSalesRankView> unitSalesRank(GaoProductChartReq req);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.imyeyu.api.modules.gao.service;
|
||||
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderProductRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatIntervalStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderCalendarStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderPaymentStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderReceivableStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderStatusStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderTypeStatView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 销售订单图表服务
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
public interface GaoSalesOrderChartService {
|
||||
|
||||
/// 查询销售订单每日统计
|
||||
List<GaoSalesOrderDailyStatView> daily(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单类型统计
|
||||
List<GaoSalesOrderTypeStatView> type(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单付款状态统计
|
||||
List<GaoSalesOrderPaymentStatView> payment(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户订单排行
|
||||
List<GaoCustomerOrderRankView> customerRank(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户订单产品排行
|
||||
List<GaoCustomerOrderProductRankView> customerProductRank(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单状态统计
|
||||
List<GaoSalesOrderStatusStatView> status(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询销售订单应收统计
|
||||
GaoSalesOrderReceivableStatView receivable(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户每日有效消费统计
|
||||
List<GaoSalesOrderConsumptionDailyStatView> consumptionDaily(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户订单日历统计
|
||||
List<GaoSalesOrderCalendarStatView> calendar(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户每日复购统计
|
||||
List<GaoCustomerRepeatDailyStatView> repeatDaily(GaoSalesOrderChartReq req);
|
||||
|
||||
/// 查询客户复购间隔统计
|
||||
List<GaoCustomerRepeatIntervalStatView> repeatInterval(GaoSalesOrderChartReq req);
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoProductChartMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoProductChartService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductCategoryStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductSalesRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockHealthView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductStockMovementDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductTypeStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoProductUnitSalesRankView;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 产品图表服务实现
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoProductChartServiceImplement implements GaoProductChartService {
|
||||
|
||||
private static final int DEFAULT_TOP_N = 20;
|
||||
private static final int MAX_TOP_N = 100;
|
||||
|
||||
private final GaoProductChartMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<GaoProductSalesDailyStatView> salesDaily(GaoProductChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectSalesDaily(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductSalesRankView> salesRank(GaoProductChartReq req) {
|
||||
checkRangeReq(req);
|
||||
normalizeTopN(req);
|
||||
return mapper.selectSalesRank(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductFulfillmentDailyStatView> fulfillmentDaily(GaoProductChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectFulfillmentDaily(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductFulfillmentRankView> fulfillmentRank(GaoProductChartReq req) {
|
||||
checkRangeReq(req);
|
||||
normalizeTopN(req);
|
||||
return mapper.selectFulfillmentRank(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductStockMovementDailyStatView> stockMovementDaily(GaoProductChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectStockMovementDaily(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductStockHealthView> stockHealth(GaoProductChartReq req) {
|
||||
checkStoreReq(req);
|
||||
normalizeTopN(req);
|
||||
return mapper.selectStockHealth(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductTypeStatView> type(GaoProductChartReq req) {
|
||||
checkStoreReq(req);
|
||||
return mapper.selectType(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductCategoryStatView> category(GaoProductChartReq req) {
|
||||
checkStoreReq(req);
|
||||
return mapper.selectCategory(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoProductUnitSalesRankView> unitSalesRank(GaoProductChartReq req) {
|
||||
checkRangeReq(req);
|
||||
normalizeTopN(req);
|
||||
return mapper.selectUnitSalesRank(req);
|
||||
}
|
||||
|
||||
private void checkRangeReq(GaoProductChartReq req) {
|
||||
checkStoreReq(req);
|
||||
TimiException.required(req.getBeginAt(), "产品图表开始时间不能为空");
|
||||
TimiException.required(req.getEndAt(), "产品图表结束时间不能为空");
|
||||
TimiException.requiredTrue(req.getBeginAt() <= req.getEndAt(), "产品图表结束时间早于开始时间");
|
||||
}
|
||||
|
||||
private void checkStoreReq(GaoProductChartReq req) {
|
||||
TimiException.required(req, "产品图表请求不能为空");
|
||||
TimiException.required(req.getStoreId(), "产品图表门店不能为空");
|
||||
}
|
||||
|
||||
private void normalizeTopN(GaoProductChartReq req) {
|
||||
int topN = req.getTopN() == null ? DEFAULT_TOP_N : req.getTopN();
|
||||
TimiException.requiredTrue(0 < topN && topN < MAX_TOP_N + 1, "产品图表排行数量无效");
|
||||
req.setTopN(topN);
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoSalesOrderChartMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoSalesOrderChartService;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderProductRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerOrderRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatIntervalStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderCalendarStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderPaymentStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderReceivableStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderStatusStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoSalesOrderTypeStatView;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 销售订单图表服务实现
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GaoSalesOrderChartServiceImplement implements GaoSalesOrderChartService {
|
||||
|
||||
private static final int DEFAULT_TOP_N = 20;
|
||||
private static final int MAX_TOP_N = 100;
|
||||
|
||||
private final GaoSalesOrderChartMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<GaoSalesOrderDailyStatView> daily(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectDaily(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoSalesOrderTypeStatView> type(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectType(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoSalesOrderPaymentStatView> payment(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectPayment(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoCustomerOrderRankView> customerRank(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
normalizeTopN(req);
|
||||
return mapper.selectCustomerRank(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoCustomerOrderProductRankView> customerProductRank(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
TimiException.required(req.getCustomerId(), "客户订单产品排行必须指定客户");
|
||||
normalizeTopN(req);
|
||||
return mapper.selectCustomerProductRank(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoSalesOrderStatusStatView> status(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectStatus(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GaoSalesOrderReceivableStatView receivable(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectReceivable(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoSalesOrderConsumptionDailyStatView> consumptionDaily(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectConsumptionDaily(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoSalesOrderCalendarStatView> calendar(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectCalendar(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoCustomerRepeatDailyStatView> repeatDaily(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectRepeatDaily(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoCustomerRepeatIntervalStatView> repeatInterval(GaoSalesOrderChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return mapper.selectRepeatInterval(req);
|
||||
}
|
||||
|
||||
private void checkRangeReq(GaoSalesOrderChartReq req) {
|
||||
TimiException.required(req, "订单图表请求不能为空");
|
||||
TimiException.required(req.getStoreId(), "订单图表门店不能为空");
|
||||
TimiException.required(req.getBeginAt(), "订单图表开始时间不能为空");
|
||||
TimiException.required(req.getEndAt(), "订单图表结束时间不能为空");
|
||||
TimiException.requiredTrue(req.getBeginAt() <= req.getEndAt(), "订单图表结束时间早于开始时间");
|
||||
}
|
||||
|
||||
private void normalizeTopN(GaoSalesOrderChartReq req) {
|
||||
int topN = req.getTopN() == null ? DEFAULT_TOP_N : req.getTopN();
|
||||
TimiException.requiredTrue(0 < topN && topN < MAX_TOP_N + 1, "订单图表排行数量无效");
|
||||
req.setTopN(topN);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 客户订单产品排行视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoCustomerOrderProductRankView {
|
||||
|
||||
/// 产品 ID
|
||||
private String productId;
|
||||
|
||||
/// 产品名称
|
||||
private String productName;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 直接产品购买数量
|
||||
private BigDecimal directQuantity;
|
||||
|
||||
/// 套餐权益数量
|
||||
private BigDecimal packageQuantity;
|
||||
|
||||
/// 已预占数量
|
||||
private BigDecimal reservedQuantity;
|
||||
|
||||
/// 已履约数量
|
||||
private BigDecimal fulfilledQuantity;
|
||||
|
||||
/// 当前可履约数量
|
||||
private BigDecimal availableQuantity;
|
||||
|
||||
/// 直接产品销售金额,单位分
|
||||
private Long directSaleAmount;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 客户订单排行视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoCustomerOrderRankView {
|
||||
|
||||
/// 客户 ID
|
||||
private String customerId;
|
||||
|
||||
/// 客户编码
|
||||
private String customerCode;
|
||||
|
||||
/// 客户名称
|
||||
private String customerName;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 有效收款,单位分
|
||||
private Long paidAmount;
|
||||
|
||||
/// 有效退款,单位分
|
||||
private Long refundedAmount;
|
||||
|
||||
/// 净收款,单位分
|
||||
private Long netPaidAmount;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 客户复购每日统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoCustomerRepeatDailyStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 当日购买客户数
|
||||
private Long customerCount;
|
||||
|
||||
/// 当日复购客户数
|
||||
private Long repeatCustomerCount;
|
||||
|
||||
/// 当日复购订单数
|
||||
private Long repeatOrderCount;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 客户复购间隔统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoCustomerRepeatIntervalStatView {
|
||||
|
||||
/// 复购间隔天数
|
||||
private Long intervalDays;
|
||||
|
||||
/// 发生复购的客户数
|
||||
private Long customerCount;
|
||||
|
||||
/// 复购订单数
|
||||
private Long orderCount;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 产品分类统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductCategoryStatView {
|
||||
|
||||
/// 分类 ID
|
||||
private String categoryId;
|
||||
|
||||
/// 分类名称
|
||||
private String categoryName;
|
||||
|
||||
/// 产品数量
|
||||
private Long productCount;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoProduct;
|
||||
import lombok.Data;
|
||||
|
||||
/// GAO 产品图表查询请求
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductChartReq {
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 产品 ID
|
||||
private String productId;
|
||||
|
||||
/// 分类 ID
|
||||
private String categoryId;
|
||||
|
||||
/// 产品类型
|
||||
private GaoProduct.ProductType productType;
|
||||
|
||||
/// 开始时间,包含
|
||||
private Long beginAt;
|
||||
|
||||
/// 结束时间,包含
|
||||
private Long endAt;
|
||||
|
||||
/// 返回排行数量
|
||||
private Integer topN;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品每日履约统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductFulfillmentDailyStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 直接产品履约数量
|
||||
private BigDecimal directQuantity;
|
||||
|
||||
/// 套餐权益履约数量
|
||||
private BigDecimal packageQuantity;
|
||||
|
||||
/// 履约基础单位数量
|
||||
private BigDecimal baseQuantity;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品履约进度排行视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductFulfillmentRankView {
|
||||
|
||||
/// 产品 ID
|
||||
private String productId;
|
||||
|
||||
/// 产品名称
|
||||
private String productName;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 直接产品购买数量
|
||||
private BigDecimal directQuantity;
|
||||
|
||||
/// 套餐权益数量
|
||||
private BigDecimal packageQuantity;
|
||||
|
||||
/// 待履约数量
|
||||
private BigDecimal reservedQuantity;
|
||||
|
||||
/// 已履约数量
|
||||
private BigDecimal fulfilledQuantity;
|
||||
|
||||
/// 当前可履约数量
|
||||
private BigDecimal availableQuantity;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品每日销售统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductSalesDailyStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 包含该产品的订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 直接产品销售数量
|
||||
private BigDecimal directQuantity;
|
||||
|
||||
/// 套餐权益数量
|
||||
private BigDecimal packageQuantity;
|
||||
|
||||
/// 直接产品销售金额,单位分
|
||||
private Long directSaleAmount;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品销售排行视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductSalesRankView {
|
||||
|
||||
/// 产品 ID
|
||||
private String productId;
|
||||
|
||||
/// 产品名称
|
||||
private String productName;
|
||||
|
||||
/// 包含该产品的订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 直接产品销售数量
|
||||
private BigDecimal directQuantity;
|
||||
|
||||
/// 套餐权益数量
|
||||
private BigDecimal packageQuantity;
|
||||
|
||||
/// 直接产品销售金额,单位分
|
||||
private Long directSaleAmount;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoProduct;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品库存健康度视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductStockHealthView {
|
||||
|
||||
/// 产品 ID
|
||||
private String productId;
|
||||
|
||||
/// 产品名称
|
||||
private String productName;
|
||||
|
||||
/// 分类 ID
|
||||
private String categoryId;
|
||||
|
||||
/// 分类名称
|
||||
private String categoryName;
|
||||
|
||||
/// 产品类型
|
||||
private GaoProduct.ProductType productType;
|
||||
|
||||
/// 实际库存,基础单位
|
||||
private BigDecimal onHandQuantity;
|
||||
|
||||
/// 预占库存,基础单位
|
||||
private BigDecimal reservedQuantity;
|
||||
|
||||
/// 可用库存,基础单位
|
||||
private BigDecimal availableQuantity;
|
||||
|
||||
/// 最低库存,基础单位
|
||||
private BigDecimal minStockQuantity;
|
||||
|
||||
/// 1 为低于最低库存,0 为正常
|
||||
private Integer lowStock;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品每日库存变动统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductStockMovementDailyStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 实际入库数量,基础单位
|
||||
private BigDecimal inQuantity;
|
||||
|
||||
/// 实际出库数量,基础单位
|
||||
private BigDecimal outQuantity;
|
||||
|
||||
/// 实际库存净变化,基础单位
|
||||
private BigDecimal netOnHandQuantity;
|
||||
|
||||
/// 新增预占数量,基础单位
|
||||
private BigDecimal reserveQuantity;
|
||||
|
||||
/// 释放预占数量,基础单位
|
||||
private BigDecimal releaseQuantity;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoProduct;
|
||||
import lombok.Data;
|
||||
|
||||
/// 产品类型统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductTypeStatView {
|
||||
|
||||
/// 产品类型
|
||||
private GaoProduct.ProductType productType;
|
||||
|
||||
/// 产品数量
|
||||
private Long productCount;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/// 产品销售单位排行视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoProductUnitSalesRankView {
|
||||
|
||||
/// 产品 ID
|
||||
private String productId;
|
||||
|
||||
/// 产品名称
|
||||
private String productName;
|
||||
|
||||
/// 产品单位 ID
|
||||
private String productUnitId;
|
||||
|
||||
/// 单位名称
|
||||
private String unitName;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 销售数量
|
||||
private BigDecimal quantity;
|
||||
|
||||
/// 销售金额,单位分
|
||||
private Long saleAmount;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 客户订单日历统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderCalendarStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 净收款,单位分
|
||||
private Long netPaidAmount;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
||||
import lombok.Data;
|
||||
|
||||
/// GAO 销售订单图表查询请求
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderChartReq {
|
||||
|
||||
/// 门店 ID
|
||||
private String storeId;
|
||||
|
||||
/// 客户 ID
|
||||
private String customerId;
|
||||
|
||||
/// 订单类型
|
||||
private GaoSalesOrder.OrderType orderType;
|
||||
|
||||
/// 订单状态
|
||||
private GaoSalesOrder.Status status;
|
||||
|
||||
/// 付款状态
|
||||
private GaoSalesOrder.PaymentStatus paymentStatus;
|
||||
|
||||
/// 开始时间,包含
|
||||
private Long beginAt;
|
||||
|
||||
/// 结束时间,包含
|
||||
private Long endAt;
|
||||
|
||||
/// 返回排行数量
|
||||
private Integer topN;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 客户每日有效消费统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderConsumptionDailyStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 有效消费记录数
|
||||
private Long recordCount;
|
||||
|
||||
/// 有效消费金额,单位分
|
||||
private Long amount;
|
||||
|
||||
/// 截止当日累计有效消费金额,单位分
|
||||
private Long cumulativeAmount;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 销售订单每日统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderDailyStatView {
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 有效收款,单位分
|
||||
private Long paidAmount;
|
||||
|
||||
/// 待核销收款,单位分
|
||||
private Long pendingPaidAmount;
|
||||
|
||||
/// 有效退款,单位分
|
||||
private Long refundedAmount;
|
||||
|
||||
/// 净收款,单位分
|
||||
private Long netPaidAmount;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
||||
import lombok.Data;
|
||||
|
||||
/// 销售订单付款状态统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderPaymentStatView {
|
||||
|
||||
/// 付款状态
|
||||
private GaoSalesOrder.PaymentStatus paymentStatus;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 有效收款,单位分
|
||||
private Long paidAmount;
|
||||
|
||||
/// 待核销收款,单位分
|
||||
private Long pendingPaidAmount;
|
||||
|
||||
/// 未收金额,单位分
|
||||
private Long unpaidAmount;
|
||||
|
||||
/// 有效退款,单位分
|
||||
private Long refundedAmount;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 销售订单应收统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderReceivableStatView {
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 有效收款,单位分
|
||||
private Long paidAmount;
|
||||
|
||||
/// 待核销收款,单位分
|
||||
private Long pendingPaidAmount;
|
||||
|
||||
/// 未收金额,单位分
|
||||
private Long unpaidAmount;
|
||||
|
||||
/// 有效退款,单位分
|
||||
private Long refundedAmount;
|
||||
|
||||
/// 净收款,单位分
|
||||
private Long netPaidAmount;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
||||
import lombok.Data;
|
||||
|
||||
/// 销售订单状态统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderStatusStatView {
|
||||
|
||||
/// 订单状态
|
||||
private GaoSalesOrder.Status status;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 有效收款,单位分
|
||||
private Long paidAmount;
|
||||
|
||||
/// 有效退款,单位分
|
||||
private Long refundedAmount;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
||||
import lombok.Data;
|
||||
|
||||
/// 销售订单类型统计视图
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-09-06
|
||||
@Data
|
||||
public class GaoSalesOrderTypeStatView {
|
||||
|
||||
/// 订单类型
|
||||
private GaoSalesOrder.OrderType orderType;
|
||||
|
||||
/// 订单数
|
||||
private Long orderCount;
|
||||
|
||||
/// 成交金额,单位分
|
||||
private Long saleAmount;
|
||||
|
||||
/// 有效收款,单位分
|
||||
private Long paidAmount;
|
||||
|
||||
/// 有效退款,单位分
|
||||
private Long refundedAmount;
|
||||
|
||||
/// 净收款,单位分
|
||||
private Long netPaidAmount;
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoProductChartMapper">
|
||||
<sql id="productFilter">
|
||||
AND p.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND p.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND p.`id` = #{productId}</if>
|
||||
<if test="categoryId != null and categoryId != ''">AND p.`category_id` = #{categoryId}</if>
|
||||
<if test="productType != null">AND p.`product_type` = #{productType}</if>
|
||||
</sql>
|
||||
|
||||
<sql id="orderProductFilter">
|
||||
AND o.`deleted_at` IS NULL
|
||||
AND i.`deleted_at` IS NULL
|
||||
AND o.`status` <> 'CANCELLED'
|
||||
<if test="storeId != null and storeId != ''">AND o.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND i.`product_id` = #{productId}</if>
|
||||
<if test="categoryId != null and categoryId != ''">AND p.`category_id` = #{categoryId}</if>
|
||||
<if test="productType != null">AND p.`product_type` = #{productType}</if>
|
||||
AND o.`purchased_at` >= #{beginAt}
|
||||
AND o.`purchased_at` <= #{endAt}
|
||||
</sql>
|
||||
|
||||
<select id="selectSalesDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoProductSalesDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(DISTINCT o.`id`) AS `orderCount`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN i.`quantity` ELSE 0 END), 0) AS `directQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT' THEN i.`quantity` ELSE 0 END), 0) AS `packageQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN COALESCE(i.`line_amount`, 0) ELSE 0 END), 0) AS `directSaleAmount`
|
||||
FROM `gao_sales_order_item` i
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = i.`sales_order_id`
|
||||
INNER JOIN `gao_product` p ON p.`id` = i.`product_id` AND p.`store_id` = o.`store_id`
|
||||
WHERE 1 = 1
|
||||
<include refid="orderProductFilter"/>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectSalesRank" resultType="com.imyeyu.api.modules.gao.vo.GaoProductSalesRankView">
|
||||
SELECT
|
||||
i.`product_id` AS `productId`,
|
||||
MAX(i.`product_name_snapshot`) AS `productName`,
|
||||
COUNT(DISTINCT o.`id`) AS `orderCount`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN i.`quantity` ELSE 0 END), 0) AS `directQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT' THEN i.`quantity` ELSE 0 END), 0) AS `packageQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN COALESCE(i.`line_amount`, 0) ELSE 0 END), 0) AS `directSaleAmount`
|
||||
FROM `gao_sales_order_item` i
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = i.`sales_order_id`
|
||||
INNER JOIN `gao_product` p ON p.`id` = i.`product_id` AND p.`store_id` = o.`store_id`
|
||||
WHERE 1 = 1
|
||||
<include refid="orderProductFilter"/>
|
||||
GROUP BY i.`product_id`
|
||||
ORDER BY (SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN i.`quantity` ELSE 0 END)
|
||||
+ SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT' THEN i.`quantity` ELSE 0 END)) DESC,
|
||||
directSaleAmount DESC,
|
||||
i.`product_id` ASC
|
||||
LIMIT #{topN}
|
||||
</select>
|
||||
|
||||
<select id="selectFulfillmentDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(f.`delivered_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT'
|
||||
THEN CASE WHEN f.`source_fulfillment_id` IS NULL THEN fi.`quantity` ELSE -fi.`quantity` END ELSE 0 END), 0) AS `directQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT'
|
||||
THEN CASE WHEN f.`source_fulfillment_id` IS NULL THEN fi.`quantity` ELSE -fi.`quantity` END ELSE 0 END), 0) AS `packageQuantity`,
|
||||
COALESCE(SUM(CASE WHEN f.`source_fulfillment_id` IS NULL THEN fi.`base_quantity` ELSE -fi.`base_quantity` END), 0) AS `baseQuantity`
|
||||
FROM `gao_order_fulfillment` f
|
||||
INNER JOIN `gao_order_fulfillment_item` fi ON fi.`fulfillment_id` = f.`id`
|
||||
INNER JOIN `gao_sales_order_item` i ON i.`id` = fi.`source_order_item_id`
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = f.`sales_order_id` AND o.`deleted_at` IS NULL
|
||||
INNER JOIN `gao_product` p ON p.`id` = fi.`product_id` AND p.`store_id` = f.`store_id`
|
||||
WHERE f.`store_id` = #{storeId}
|
||||
AND f.`status` = 'VERIFIED'
|
||||
AND f.`delivered_at` >= #{beginAt}
|
||||
AND f.`delivered_at` <= #{endAt}
|
||||
<if test="productId != null and productId != ''">AND fi.`product_id` = #{productId}</if>
|
||||
<if test="categoryId != null and categoryId != ''">AND p.`category_id` = #{categoryId}</if>
|
||||
<if test="productType != null">AND p.`product_type` = #{productType}</if>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(f.`delivered_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectFulfillmentRank" resultType="com.imyeyu.api.modules.gao.vo.GaoProductFulfillmentRankView">
|
||||
SELECT
|
||||
i.`product_id` AS `productId`,
|
||||
MAX(i.`product_name_snapshot`) AS `productName`,
|
||||
COUNT(DISTINCT o.`id`) AS `orderCount`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN i.`quantity` ELSE 0 END), 0) AS `directQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT' THEN i.`quantity` ELSE 0 END), 0) AS `packageQuantity`,
|
||||
COALESCE(SUM(i.`reserved_quantity`), 0) AS `reservedQuantity`,
|
||||
COALESCE(SUM(i.`fulfilled_quantity`), 0) AS `fulfilledQuantity`,
|
||||
COALESCE(SUM(i.`quantity` - i.`reserved_quantity` - i.`fulfilled_quantity`), 0) AS `availableQuantity`
|
||||
FROM `gao_sales_order_item` i
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = i.`sales_order_id`
|
||||
INNER JOIN `gao_product` p ON p.`id` = i.`product_id` AND p.`store_id` = o.`store_id`
|
||||
WHERE 1 = 1
|
||||
<include refid="orderProductFilter"/>
|
||||
GROUP BY i.`product_id`
|
||||
ORDER BY `availableQuantity` DESC, `fulfilledQuantity` DESC, i.`product_id` ASC
|
||||
LIMIT #{topN}
|
||||
</select>
|
||||
|
||||
<select id="selectStockMovementDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoProductStockMovementDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(r.`occurred_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COALESCE(SUM(CASE WHEN r.`on_hand_delta` > 0 THEN r.`on_hand_delta` ELSE 0 END), 0) AS `inQuantity`,
|
||||
COALESCE(SUM(CASE WHEN r.`on_hand_delta` < 0 THEN -r.`on_hand_delta` ELSE 0 END), 0) AS `outQuantity`,
|
||||
COALESCE(SUM(r.`on_hand_delta`), 0) AS `netOnHandQuantity`,
|
||||
COALESCE(SUM(CASE WHEN r.`reserved_delta` > 0 THEN r.`reserved_delta` ELSE 0 END), 0) AS `reserveQuantity`,
|
||||
COALESCE(SUM(CASE WHEN r.`reserved_delta` < 0 THEN -r.`reserved_delta` ELSE 0 END), 0) AS `releaseQuantity`
|
||||
FROM `gao_product_stock_record` r
|
||||
INNER JOIN `gao_product` p ON p.`id` = r.`product_id` AND p.`store_id` = r.`store_id`
|
||||
WHERE r.`store_id` = #{storeId}
|
||||
AND r.`occurred_at` >= #{beginAt}
|
||||
AND r.`occurred_at` <= #{endAt}
|
||||
<if test="productId != null and productId != ''">AND r.`product_id` = #{productId}</if>
|
||||
<if test="categoryId != null and categoryId != ''">AND p.`category_id` = #{categoryId}</if>
|
||||
<if test="productType != null">AND p.`product_type` = #{productType}</if>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(r.`occurred_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectStockHealth" resultType="com.imyeyu.api.modules.gao.vo.GaoProductStockHealthView">
|
||||
SELECT
|
||||
p.`id` AS `productId`,
|
||||
p.`name` AS `productName`,
|
||||
p.`category_id` AS `categoryId`,
|
||||
c.`name` AS `categoryName`,
|
||||
p.`product_type` AS `productType`,
|
||||
COALESCE(s.`on_hand_quantity`, 0) AS `onHandQuantity`,
|
||||
COALESCE(s.`reserved_quantity`, 0) AS `reservedQuantity`,
|
||||
COALESCE(s.`on_hand_quantity`, 0) - COALESCE(s.`reserved_quantity`, 0) AS `availableQuantity`,
|
||||
p.`min_stock_quantity` AS `minStockQuantity`,
|
||||
CASE WHEN p.`min_stock_quantity` IS NOT NULL
|
||||
AND COALESCE(s.`on_hand_quantity`, 0) - COALESCE(s.`reserved_quantity`, 0) < p.`min_stock_quantity`
|
||||
THEN 1 ELSE 0 END AS `lowStock`
|
||||
FROM `gao_product` p
|
||||
LEFT JOIN `gao_product_category` c ON c.`id` = p.`category_id` AND c.`store_id` = p.`store_id` AND c.`deleted_at` IS NULL
|
||||
LEFT JOIN `gao_product_stock` s ON s.`product_id` = p.`id` AND s.`store_id` = p.`store_id`
|
||||
WHERE p.`store_id` = #{storeId}
|
||||
AND p.`stock_enabled` = 1
|
||||
<include refid="productFilter"/>
|
||||
ORDER BY `lowStock` DESC, `availableQuantity` ASC, p.`sort` ASC, p.`name` ASC
|
||||
LIMIT #{topN}
|
||||
</select>
|
||||
|
||||
<select id="selectType" resultType="com.imyeyu.api.modules.gao.vo.GaoProductTypeStatView">
|
||||
SELECT
|
||||
p.`product_type` AS `productType`,
|
||||
COUNT(1) AS `productCount`
|
||||
FROM `gao_product` p
|
||||
WHERE p.`store_id` = #{storeId}
|
||||
<include refid="productFilter"/>
|
||||
GROUP BY p.`product_type`
|
||||
ORDER BY p.`product_type` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectCategory" resultType="com.imyeyu.api.modules.gao.vo.GaoProductCategoryStatView">
|
||||
SELECT
|
||||
p.`category_id` AS `categoryId`,
|
||||
COALESCE(c.`name`, '未分类') AS `categoryName`,
|
||||
COUNT(1) AS `productCount`
|
||||
FROM `gao_product` p
|
||||
LEFT JOIN `gao_product_category` c ON c.`id` = p.`category_id` AND c.`store_id` = p.`store_id` AND c.`deleted_at` IS NULL
|
||||
WHERE p.`store_id` = #{storeId}
|
||||
<include refid="productFilter"/>
|
||||
GROUP BY p.`category_id`, c.`name`
|
||||
ORDER BY `productCount` DESC, `categoryName` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectUnitSalesRank" resultType="com.imyeyu.api.modules.gao.vo.GaoProductUnitSalesRankView">
|
||||
SELECT
|
||||
i.`product_id` AS `productId`,
|
||||
MAX(i.`product_name_snapshot`) AS `productName`,
|
||||
i.`product_unit_id` AS `productUnitId`,
|
||||
MAX(i.`unit_snapshot`) AS `unitName`,
|
||||
COUNT(DISTINCT o.`id`) AS `orderCount`,
|
||||
COALESCE(SUM(i.`quantity`), 0) AS `quantity`,
|
||||
COALESCE(SUM(i.`line_amount`), 0) AS `saleAmount`
|
||||
FROM `gao_sales_order_item` i
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = i.`sales_order_id`
|
||||
INNER JOIN `gao_product` p ON p.`id` = i.`product_id` AND p.`store_id` = o.`store_id`
|
||||
WHERE i.`item_type` = 'DIRECT_PRODUCT'
|
||||
<include refid="orderProductFilter"/>
|
||||
GROUP BY i.`product_id`, i.`product_unit_id`
|
||||
ORDER BY `quantity` DESC, `saleAmount` DESC, i.`product_id` ASC, i.`product_unit_id` ASC
|
||||
LIMIT #{topN}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoSalesOrderChartMapper">
|
||||
<sql id="orderFilter">
|
||||
AND o.`deleted_at` IS NULL
|
||||
AND o.`store_id` = #{storeId}
|
||||
<if test="customerId != null and customerId != ''">AND o.`customer_id` = #{customerId}</if>
|
||||
<if test="orderType != null">AND o.`order_type` = #{orderType}</if>
|
||||
<if test="status != null">AND o.`status` = #{status}</if>
|
||||
<if test="paymentStatus != null">AND o.`payment_status` = #{paymentStatus}</if>
|
||||
AND o.`purchased_at` >= #{beginAt}
|
||||
AND o.`purchased_at` <= #{endAt}
|
||||
</sql>
|
||||
|
||||
<select id="selectDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderDailyStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`pending_paid_amount`), 0) AS `pendingPaidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectType" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderTypeStatView">
|
||||
SELECT
|
||||
o.`order_type` AS `orderType`,
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
GROUP BY o.`order_type`
|
||||
ORDER BY o.`order_type` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectPayment" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderPaymentStatView">
|
||||
SELECT
|
||||
o.`payment_status` AS `paymentStatus`,
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`pending_paid_amount`), 0) AS `pendingPaidAmount`,
|
||||
COALESCE(SUM(o.`sale_amount` - o.`paid_amount`), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
GROUP BY o.`payment_status`
|
||||
ORDER BY o.`payment_status` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectCustomerRank" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerOrderRankView">
|
||||
SELECT
|
||||
o.`customer_id` AS `customerId`,
|
||||
c.`code` AS `customerCode`,
|
||||
c.`name` AS `customerName`,
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
LEFT JOIN `gao_customer` c ON c.`id` = o.`customer_id` AND c.`deleted_at` IS NULL
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
<if test="status == null">AND o.`status` <> 'CANCELLED'</if>
|
||||
GROUP BY o.`customer_id`, c.`code`, c.`name`
|
||||
ORDER BY `netPaidAmount` DESC, `orderCount` DESC, o.`customer_id` ASC
|
||||
LIMIT #{topN}
|
||||
</select>
|
||||
|
||||
<select id="selectCustomerProductRank" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerOrderProductRankView">
|
||||
SELECT
|
||||
i.`product_id` AS `productId`,
|
||||
MAX(i.`product_name_snapshot`) AS `productName`,
|
||||
COUNT(DISTINCT o.`id`) AS `orderCount`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN i.`quantity` ELSE 0 END), 0) AS `directQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT' THEN i.`quantity` ELSE 0 END), 0) AS `packageQuantity`,
|
||||
COALESCE(SUM(i.`reserved_quantity`), 0) AS `reservedQuantity`,
|
||||
COALESCE(SUM(i.`fulfilled_quantity`), 0) AS `fulfilledQuantity`,
|
||||
COALESCE(SUM(i.`quantity` - i.`reserved_quantity` - i.`fulfilled_quantity`), 0) AS `availableQuantity`,
|
||||
COALESCE(SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN COALESCE(i.`line_amount`, 0) ELSE 0 END), 0) AS `directSaleAmount`
|
||||
FROM `gao_sales_order_item` i
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = i.`sales_order_id`
|
||||
INNER JOIN `gao_product` p ON p.`id` = i.`product_id` AND p.`store_id` = o.`store_id`
|
||||
WHERE o.`store_id` = #{storeId}
|
||||
AND o.`customer_id` = #{customerId}
|
||||
AND o.`deleted_at` IS NULL
|
||||
AND i.`deleted_at` IS NULL
|
||||
AND o.`status` <> 'CANCELLED'
|
||||
AND o.`purchased_at` >= #{beginAt}
|
||||
AND o.`purchased_at` <= #{endAt}
|
||||
GROUP BY i.`product_id`
|
||||
ORDER BY (SUM(CASE WHEN i.`item_type` = 'DIRECT_PRODUCT' THEN i.`quantity` ELSE 0 END)
|
||||
+ SUM(CASE WHEN i.`item_type` = 'PACKAGE_ENTITLEMENT' THEN i.`quantity` ELSE 0 END)) DESC,
|
||||
directSaleAmount DESC,
|
||||
i.`product_id` ASC
|
||||
LIMIT #{topN}
|
||||
</select>
|
||||
|
||||
<select id="selectStatus" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderStatusStatView">
|
||||
SELECT
|
||||
o.`status` AS `status`,
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
GROUP BY o.`status`
|
||||
ORDER BY o.`status` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectReceivable" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderReceivableStatView">
|
||||
SELECT
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount`), 0) AS `paidAmount`,
|
||||
COALESCE(SUM(o.`pending_paid_amount`), 0) AS `pendingPaidAmount`,
|
||||
COALESCE(SUM(o.`sale_amount` - o.`paid_amount`), 0) AS `unpaidAmount`,
|
||||
COALESCE(SUM(o.`refunded_amount`), 0) AS `refundedAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
</select>
|
||||
|
||||
<select id="selectConsumptionDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderConsumptionDailyStatView">
|
||||
WITH `daily_stat` AS (
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(r.`effective_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `recordCount`,
|
||||
COALESCE(SUM(r.`amount`), 0) AS `amount`
|
||||
FROM `gao_customer_consumption_record` r
|
||||
WHERE r.`store_id` = #{storeId}
|
||||
AND r.`status` = 'ACTIVE'
|
||||
AND r.`effective_at` >= #{beginAt}
|
||||
AND r.`effective_at` <= #{endAt}
|
||||
AND r.`deleted_at` IS NULL
|
||||
<if test="customerId != null and customerId != ''">AND r.`customer_id` = #{customerId}</if>
|
||||
<if test="orderType != null">AND r.`order_type` = #{orderType}</if>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(r.`effective_at` / 1000), '%Y%m%d')
|
||||
)
|
||||
SELECT
|
||||
`dateValue`,
|
||||
`recordCount`,
|
||||
`amount`,
|
||||
SUM(`amount`) OVER (ORDER BY `dateValue` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS `cumulativeAmount`
|
||||
FROM `daily_stat`
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectCalendar" resultType="com.imyeyu.api.modules.gao.vo.GaoSalesOrderCalendarStatView">
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(1) AS `orderCount`,
|
||||
COALESCE(SUM(o.`sale_amount`), 0) AS `saleAmount`,
|
||||
COALESCE(SUM(o.`paid_amount` - o.`refunded_amount`), 0) AS `netPaidAmount`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="orderFilter"/>
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(o.`purchased_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<sql id="repeatOrderFilter">
|
||||
AND o.`deleted_at` IS NULL
|
||||
AND o.`store_id` = #{storeId}
|
||||
<if test="customerId != null and customerId != ''">AND o.`customer_id` = #{customerId}</if>
|
||||
<if test="orderType != null">AND o.`order_type` = #{orderType}</if>
|
||||
<choose>
|
||||
<when test="status != null">AND o.`status` = #{status}</when>
|
||||
<otherwise>AND o.`status` <> 'CANCELLED'</otherwise>
|
||||
</choose>
|
||||
AND o.`purchased_at` <= #{endAt}
|
||||
</sql>
|
||||
|
||||
<select id="selectRepeatDaily" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatDailyStatView">
|
||||
WITH `ranked_order` AS (
|
||||
SELECT
|
||||
o.`customer_id`,
|
||||
o.`purchased_at`,
|
||||
LAG(o.`purchased_at`) OVER (PARTITION BY o.`customer_id` ORDER BY o.`purchased_at`, o.`id`) AS `previous_purchased_at`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="repeatOrderFilter"/>
|
||||
)
|
||||
SELECT
|
||||
CAST(DATE_FORMAT(FROM_UNIXTIME(r.`purchased_at` / 1000), '%Y%m%d') AS UNSIGNED) AS `dateValue`,
|
||||
COUNT(DISTINCT r.`customer_id`) AS `customerCount`,
|
||||
COUNT(DISTINCT CASE WHEN r.`previous_purchased_at` IS NOT NULL THEN r.`customer_id` END) AS `repeatCustomerCount`,
|
||||
SUM(CASE WHEN r.`previous_purchased_at` IS NOT NULL THEN 1 ELSE 0 END) AS `repeatOrderCount`
|
||||
FROM `ranked_order` r
|
||||
WHERE r.`purchased_at` >= #{beginAt}
|
||||
GROUP BY DATE_FORMAT(FROM_UNIXTIME(r.`purchased_at` / 1000), '%Y%m%d')
|
||||
ORDER BY `dateValue` ASC
|
||||
</select>
|
||||
|
||||
<select id="selectRepeatInterval" resultType="com.imyeyu.api.modules.gao.vo.GaoCustomerRepeatIntervalStatView">
|
||||
WITH `ranked_order` AS (
|
||||
SELECT
|
||||
o.`customer_id`,
|
||||
o.`purchased_at`,
|
||||
LAG(o.`purchased_at`) OVER (PARTITION BY o.`customer_id` ORDER BY o.`purchased_at`, o.`id`) AS `previous_purchased_at`
|
||||
FROM `gao_sales_order` o
|
||||
WHERE 1 = 1
|
||||
<include refid="repeatOrderFilter"/>
|
||||
)
|
||||
SELECT
|
||||
TIMESTAMPDIFF(DAY, FROM_UNIXTIME(r.`previous_purchased_at` / 1000), FROM_UNIXTIME(r.`purchased_at` / 1000)) AS `intervalDays`,
|
||||
COUNT(DISTINCT r.`customer_id`) AS `customerCount`,
|
||||
COUNT(1) AS `orderCount`
|
||||
FROM `ranked_order` r
|
||||
WHERE r.`previous_purchased_at` IS NOT NULL
|
||||
AND r.`purchased_at` >= #{beginAt}
|
||||
GROUP BY TIMESTAMPDIFF(DAY, FROM_UNIXTIME(r.`previous_purchased_at` / 1000), FROM_UNIXTIME(r.`purchased_at` / 1000))
|
||||
ORDER BY `intervalDays` ASC
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user