diff --git a/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/DataAnalysisRequest.java b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/DataAnalysisRequest.java new file mode 100644 index 000000000..9e673b859 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-api/src/main/java/cn/iocoder/yudao/module/shop/request/order/DataAnalysisRequest.java @@ -0,0 +1,53 @@ +package cn.iocoder.yudao.module.shop.request.order; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * @Title:DataAnalysisRequest + * @Description: 销售数据分析 + * @author: tangqian + * @date: 2023/6/21 11:08 + * @version: V1.0.0 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Schema( description="销售数据分析") +public class DataAnalysisRequest implements Serializable { + + @Schema(description = "开始执行时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime startTime; + + @Schema(description = "结束执行时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime endTime; + + @Schema(description = "租户id") + private Long tenantId; + @Schema(description = "租户名称") + private Long tenantName; + @Schema(description = "销售金额排序1(降序desc);2(升序asc)") + private Integer sortMoney; + @Schema(description = "订单数量排序1(降序desc);2(升序asc)") + private Integer sortNum; + + + @Schema(description = "页码,从 1 开始") + private Integer pageNo=1; + + @Schema(description = "每页条数,最大值为 10000") + private Integer pageSize=20; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java index 79d3bd1d2..7c84520bb 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/RechargeOrderController.java @@ -1,50 +1,43 @@ package cn.iocoder.yudao.module.shop.controller.admin.recharge; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.shop.controller.admin.recharge.method.Excel; -import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderInfoConvert; -import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO; +import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; +import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderConvert; +import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; import cn.iocoder.yudao.module.shop.request.member.RefundRequest; import cn.iocoder.yudao.module.shop.request.member.RemarkRequest; import cn.iocoder.yudao.module.shop.service.order.StoreOrderService; import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderInfoService; +import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; - -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.time.LocalDateTime; -import java.util.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; - -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; -import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; -import cn.iocoder.yudao.module.shop.convert.recharge.RechargeOrderConvert; -import cn.iocoder.yudao.module.shop.service.recharge.RechargeOrderService; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Tag(name = "管理后台 - 订单") @RestController diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/AffiliationAnalysisExcelReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/AffiliationAnalysisExcelReqVO.java new file mode 100644 index 000000000..0ece8a9d3 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/AffiliationAnalysisExcelReqVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Title:AffiliationAnalysisExcelReqVO + * @Description: TODO + * @author: tangqian + * @date: 2023/6/21 14:36 + * @version: V1.0.0 + */ +@Data +public class AffiliationAnalysisExcelReqVO implements Serializable { + @ExcelProperty( "地区") + private String name; + @ExcelProperty( "金额") + private BigDecimal money; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/AffiliationAnalysisReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/AffiliationAnalysisReqVO.java new file mode 100644 index 000000000..eb419f94e --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/AffiliationAnalysisReqVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Title:AffiliationAnalysisReqVO + * @Description: TODO + * @author: tangqian + * @date: 2023/6/21 14:13 + * @version: V1.0.0 + */ +@Data +@ToString(callSuper = true) +public class AffiliationAnalysisReqVO implements Serializable { + private static final long serialVersionUID = -1691739114336421986L; + @Schema(description = "地区") + private String name; + @Schema(description = "金额") + private BigDecimal money; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/DimensionalityAnalysisReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/DimensionalityAnalysisReqVO.java new file mode 100644 index 000000000..ecf3a9832 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/DimensionalityAnalysisReqVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Title:DimensionalityAnalysisReqVO + * @Description: TODO + * @author: tangqian + * @date: 2023/6/21 11:10 + * @version: V1.0.0 + */ +@Data +@ToString(callSuper = true) +public class DimensionalityAnalysisReqVO implements Serializable { + private static final long serialVersionUID = 9195908075161191001L; + @Schema(description = "总销售金额") + private BigDecimal totalMoney; + @Schema(description = "总订单数量") + private Integer totalNum; + @Schema(description = "订单均价(总金额/订单数量)") + private BigDecimal orderTotalMoney; + @Schema(description = "客单价(总金额/客户数量)") + private BigDecimal guestMoney; + @Schema(description = "本金待返汇总") + private BigDecimal toBeReturnedTotalMoney; + @Schema(description = "销售已返金额") + private BigDecimal haveReturnedMoney; + @Schema(description = "销售待返金额") + private BigDecimal toBeReturnedMoney; + @Schema(description = "投诉单数") + private Integer complaintTotalNum; + @Schema(description = "投诉率") + private BigDecimal complaintProportion; + @Schema(description = "退款单数") + private Integer refundTotalNum; + @Schema(description = "退款率") + private BigDecimal refundProportion; + @Schema(description = "240档单数") + private Integer threeTotalNum; + @Schema(description = "240 占比") + private BigDecimal threeProportion; + @Schema(description = "400档单数") + private Integer twoTotalNum; + @Schema(description = "400 占比") + private BigDecimal twoProportion; + @Schema(description = "640档单数") + private Integer oneTotalNum; + @Schema(description = "640 占比") + private BigDecimal oneProportion; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterAnalysisExcelVo.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterAnalysisExcelVo.java new file mode 100644 index 000000000..2f2d6ba6d --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterAnalysisExcelVo.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Title:PromoterAnalysisExcelVo + * @Description: TODO + * @author: tangqian + * @date: 2023/6/25 10:04 + * @version: V1.0.0 + */ +@Data +public class PromoterAnalysisExcelVo { + + @ExcelProperty("租户名称") + private String tenantName; + @ExcelProperty("推广员名称") + private String promoterName; + @ExcelProperty("总销售金额") + private BigDecimal totalMoney; + @ExcelProperty("总订单数量") + private Integer totalNum; + @ExcelProperty("总退款金额") + private BigDecimal totalWithdrawMoney; + @ExcelProperty("240档订单数量") + private Integer threeTotalNum; + @ExcelProperty("400档订单数量") + private Integer twoTotalNum; + @ExcelProperty("640档订单数量") + private Integer oneTotalNum; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterAnalysisReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterAnalysisReqVO.java new file mode 100644 index 000000000..205a03a87 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/PromoterAnalysisReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Title:PromoterAnalysisReqVO + * @Description: TODO + * @author: tangqian + * @date: 2023/6/21 14:51 + * @version: V1.0.0 + */ +@Data +@ToString(callSuper = true) +public class PromoterAnalysisReqVO implements Serializable { + private static final long serialVersionUID = -7630125949607067142L; + @Schema(description = "租户名称") + private String tenantName; + @Schema(description = "推广员名称") + private String promoterName; + @Schema(description = "总销售金额") + private BigDecimal totalMoney; + @Schema(description = "总订单数量") + private Integer totalNum; + @Schema(description = "总退款金额") + private BigDecimal totalWithdrawMoney; + @Schema(description = "240档订单数量") + private Integer threeTotalNum; + @Schema(description = "400档订单数量") + private Integer twoTotalNum; + @Schema(description = "640档订单数量") + private Integer oneTotalNum; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExportReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExportReqVO.java index 04b9856b6..4254f801c 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExportReqVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderExportReqVO.java @@ -135,7 +135,9 @@ public class RechargeOrderExportReqVO { */ private Integer refundType; + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime startApplyTime; + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime endApplyTime; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java index d53bbd444..8b3ee7bdc 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RechargeOrderPageReqVO.java @@ -142,6 +142,8 @@ public class RechargeOrderPageReqVO extends PageParam { /** * 申请退款时间 */ + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime startApplyTime; + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime endApplyTime; } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RefundAnalysisReqVo.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RefundAnalysisReqVo.java new file mode 100644 index 000000000..b31ee6e26 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RefundAnalysisReqVo.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Title:RefundAnalysisReqVo + * @Description: TODO + * @author: tangqian + * @date: 2023/6/25 11:08 + * @version: V1.0.0 + */ +@Data +public class RefundAnalysisReqVo implements Serializable { + private static final long serialVersionUID = -7750537307362666158L; + @Schema(description = "退款类型") + private String refundType; + @Schema(description = "退款类型中文解释") + private String refundName; + @Schema(description = "数量") + private Integer totalNum; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RefundOrderAnalysisReqVO.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RefundOrderAnalysisReqVO.java new file mode 100644 index 000000000..253ab5cd0 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/recharge/vo/RefundOrderAnalysisReqVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.shop.controller.admin.recharge.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Title:RefundOrderAnalysisReqVO + * @Description: TODO + * @author: tangqian + * @date: 2023/6/25 11:58 + * @version: V1.0.0 + */ +@Data +public class RefundOrderAnalysisReqVO implements Serializable { + @Schema(description = "已退款数量") + private Integer alreadyTotalNum; + @Schema(description = "未退款数量") + private Integer notTotalNum; +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/statement/DataAnalysisController.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/statement/DataAnalysisController.java new file mode 100644 index 000000000..9fd87a802 --- /dev/null +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/controller/admin/statement/DataAnalysisController.java @@ -0,0 +1,158 @@ +package cn.iocoder.yudao.module.shop.controller.admin.statement; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; +import cn.iocoder.yudao.module.shop.request.order.DataAnalysisRequest; +import cn.iocoder.yudao.module.shop.service.order.StoreOrderService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +/** + * @Title:DataAnalysisController + * @Description: 数据分析 + * @author: tangqian + * @date: 2023/6/21 11:01 + * @version: V1.0.0 + */ +@Tag(name = "管理后台 - 数据分析") +@RestController +@RequestMapping("/system/analysis") +@Validated +public class DataAnalysisController { + + @Autowired + private StoreOrderService storeOrderService; + + // 维度数据统计 + + @Operation(summary = "维度数据统计") + @RequestMapping(value = "/dimensionalityAnalysis", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult dimensionalityAnalysis(@Validated DataAnalysisRequest request) { + return CommonResult.success(storeOrderService.dimensionalityAnalysis(request)); + } + + // 号码归属地分析 + @Operation(summary = "号码归属地分析") + @RequestMapping(value = "/affiliationAnalysis", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult> affiliation(@Validated DataAnalysisRequest request) { + return CommonResult.success(storeOrderService.affiliation(request)); + } + + @Operation(summary = "号码归属地分析-导出") + @RequestMapping(value = "/affiliationAnalysis-excel", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + @OperateLog(type = EXPORT) + public void affiliationExcel(@Validated DataAnalysisRequest request + , HttpServletResponse response) throws IOException { + List affiliation = storeOrderService.affiliation(request); + List list = new ArrayList<>(); + if (!CollectionUtils.isEmpty(affiliation)) { + affiliation.forEach(e -> { + AffiliationAnalysisExcelReqVO vo = new AffiliationAnalysisExcelReqVO(); + BeanUtils.copyProperties(e, vo); + list.add(vo); + }); + } + ExcelUtils.write(response, "号码归属地分析.xls", "数据", AffiliationAnalysisExcelReqVO.class, list); + } + + + // 销售(商铺维度) + @Operation(summary = "销售(商铺维度)") + @RequestMapping(value = "/statisticsAnalysisPage", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult> statisticsAnalysis(@Validated DataAnalysisRequest request) { + return CommonResult.success(storeOrderService.statisticsAnalysis(request)); + } + + @Operation(summary = "销售(商铺维度)-导出") + @RequestMapping(value = "/statisticsAnalysis-excel", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + @OperateLog(type = EXPORT) + public void statisticsAnalysisExcel(@Validated DataAnalysisRequest request + , HttpServletResponse response) throws IOException { + PageResult statisticsPageVoPageResult = storeOrderService.statisticsAnalysis(request); + List list = new ArrayList<>(); + if (null != statisticsPageVoPageResult && !CollectionUtils.isEmpty(statisticsPageVoPageResult.getList())) { + statisticsPageVoPageResult.getList().forEach(e -> { + StatisticsExcelVO vo = new StatisticsExcelVO(); + BeanUtils.copyProperties(e, vo); + list.add(vo); + }); + } + ExcelUtils.write(response, "销售(商铺维度).xls", "数据", StatisticsExcelVO.class, list); + } + + + // 销售(推广员维度) + @Operation(summary = "销售(推广员维度)") + @RequestMapping(value = "/promoterAnalysis", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult> promoterAnalysis(@Validated DataAnalysisRequest request) { + return CommonResult.success(storeOrderService.promoterAnalysis(request)); + } + + // 销售(推广员维度) 导出 + @Operation(summary = "销售(推广员维度)-导出") + @RequestMapping(value = "/promoterAnalysis-excel", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + @OperateLog(type = EXPORT) + public void promoterAnalysisExcel(@Validated DataAnalysisRequest request + , HttpServletResponse response) throws IOException { + PageResult promoterAnalysisReqVOPageResult = storeOrderService.promoterAnalysis(request); + List list = new ArrayList<>(); + if (null != promoterAnalysisReqVOPageResult && !CollectionUtils.isEmpty(promoterAnalysisReqVOPageResult.getList())) { + promoterAnalysisReqVOPageResult.getList().forEach(e -> { + PromoterAnalysisExcelVo vo = new PromoterAnalysisExcelVo(); + BeanUtils.copyProperties(e, vo); + list.add(vo); + }); + } + ExcelUtils.write(response, "销售(推广员维度).xls", "数据", PromoterAnalysisExcelVo.class, list); + } + // 退款原因分析 + + @Operation(summary = "退款分析(退款类型)") + @RequestMapping(value = "/refundAnalysis", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult> refundAnalysis(@Validated DataAnalysisRequest request) { + return CommonResult.success(storeOrderService.refundAnalysis(request)); + } + + @Operation(summary = "退款分析(订单量)") + @RequestMapping(value = "/refundOrderAnalysis", method = RequestMethod.GET) + @PreAuthenticated + @TenantIgnore + public CommonResult refundOrderAnalysis(@Validated DataAnalysisRequest request) { + return CommonResult.success(storeOrderService.refundOrderAnalysis(request)); + } +} diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java index 5fee04d04..8bd3a7141 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/dal/mysql/order/StoreOrderMapper.java @@ -1,14 +1,16 @@ package cn.iocoder.yudao.module.shop.dal.mysql.order; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.StatementAllReqDataVo; +import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder; +import cn.iocoder.yudao.module.shop.request.order.DataAnalysisRequest; import cn.iocoder.yudao.module.shop.request.order.StoreOrderStaticsticsRequest; import cn.iocoder.yudao.module.shop.response.order.OrderBrokerageData; import cn.iocoder.yudao.module.shop.response.order.StoreOrderStatisticsChartItemResponse; import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram; import cn.iocoder.yudao.module.shop.vo.order.StoreStaffDetail; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -81,4 +83,12 @@ public interface StoreOrderMapper extends BaseMapperX { BigDecimal shoppingOrderCount(@Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate, @Param("promoterId") Long promoterId); List statisticsAll(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("tenantId") Long tenantId); + + IPage statisticsAnalysis(IPage page, @Param("data")DataAnalysisRequest request); + + IPage promoterAnalysis(Page page, @Param("data")DataAnalysisRequest request); + + List refundAnalysis(@Param("data")DataAnalysisRequest request); + + RefundOrderAnalysisReqVO refundOrderAnalysis(@Param("data")DataAnalysisRequest request); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java index 25ff6bcb2..6e6b55ec7 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/StoreOrderService.java @@ -1,9 +1,8 @@ package cn.iocoder.yudao.module.shop.service.order; import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.StatementAllReqVo; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.StatisticsPageVo; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.TenantListVo; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder; import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO; import cn.iocoder.yudao.module.shop.request.member.OrderContentRequest; @@ -414,4 +413,16 @@ public interface StoreOrderService extends IService { List getTenantList(); void addPhone(RechargeOrderDO orderDO, String outTradeNo); + + DimensionalityAnalysisReqVO dimensionalityAnalysis(DataAnalysisRequest request); + + List affiliation(DataAnalysisRequest request); + + PageResult statisticsAnalysis(DataAnalysisRequest request); + + PageResult promoterAnalysis(DataAnalysisRequest request); + + List refundAnalysis(DataAnalysisRequest request); + + RefundOrderAnalysisReqVO refundOrderAnalysis(DataAnalysisRequest request); } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java index f17c9574e..15ba950f1 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/service/order/impl/StoreOrderServiceImpl.java @@ -21,10 +21,7 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.member.api.user.dto.PromoterDTO; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.StatementAllReqDataVo; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.StatementAllReqVo; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.StatisticsPageVo; -import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.TenantListVo; +import cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.*; import cn.iocoder.yudao.module.shop.controller.app.recharge.vo.PhoneRecordAdd; import cn.iocoder.yudao.module.shop.dal.dataobject.express.ExpressDO; import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder; @@ -88,18 +85,14 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.math.BigDecimal; import java.time.DayOfWeek; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; import java.util.*; -import java.util.regex.Pattern; import java.util.stream.Collectors; -import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; - /** * StoreOrderServiceImpl 接口实现 * +---------------------------------------------------------------------- @@ -1537,6 +1530,59 @@ public class StoreOrderServiceImpl extends ServiceImpl affiliation(DataAnalysisRequest request) { + if (!Objects.nonNull(request.getTenantId())) { + request.setTenantId(TenantContextHolder.getTenantId()); + } + return null; + } + + @Override + public PageResult statisticsAnalysis(DataAnalysisRequest request) { + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(request.getPageNo(), request.getPageSize()); + if (!Objects.nonNull(request.getTenantId())) { + request.setTenantId(TenantContextHolder.getTenantId()); + } + mapper.statisticsAnalysis(page, request); + return new PageResult<>(page.getRecords(), page.getTotal()); + } + + @Override + public PageResult promoterAnalysis(DataAnalysisRequest request) { + com.baomidou.mybatisplus.extension.plugins.pagination.Page page = + new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(request.getPageNo(), request.getPageSize()); + if (!Objects.nonNull(request.getTenantId())) { + request.setTenantId(TenantContextHolder.getTenantId()); + } + mapper.promoterAnalysis(page, request); + return new PageResult<>(page.getRecords(), page.getTotal()); + } + + @Override + public List refundAnalysis(DataAnalysisRequest request) { + if (!Objects.nonNull(request.getTenantId())) { + request.setTenantId(TenantContextHolder.getTenantId()); + } + return mapper.refundAnalysis(request); + } + + @Override + public RefundOrderAnalysisReqVO refundOrderAnalysis(DataAnalysisRequest request) { + if (!Objects.nonNull(request.getTenantId())) { + request.setTenantId(TenantContextHolder.getTenantId()); + } + return mapper.refundOrderAnalysis(request); + } private RechargeOrderDO initializeOrder(OrderContentRequest request, String code, MemberUserRespDTO user, PromoterDTO promoterDTO) { Long tenantId = TenantContextHolder.getTenantId(); diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/task/ReplenishmentTask.java b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/task/ReplenishmentTask.java index 796998af8..7e572ebc0 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/task/ReplenishmentTask.java +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/java/cn/iocoder/yudao/module/shop/task/ReplenishmentTask.java @@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -45,8 +46,9 @@ public class ReplenishmentTask { /** * 每天上午8点和下午3点执行补单计划 */ - @Scheduled(cron = "0 0 9,15 * * ?") @TenantIgnore + @Transactional + @Scheduled(cron = "0 0 8,15 * * ?") public void replenishmentTask() { /** * 1.扫描表里面未付款的订单 @@ -99,6 +101,10 @@ public class ReplenishmentTask { rechargeOrderMapper.updateById(orderDO); // 写入 充值档位记录表 storeOrderService.addPhone(orderDO, outTradeNo); + } else { + orderDO.setIsReplenishment(1); + orderDO.setReplenishmentName(map.toString()); + rechargeOrderMapper.updateById(orderDO); } } diff --git a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml index 342179396..d166753a7 100644 --- a/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml +++ b/yudao-module-mall/yudao-module-shop-biz/src/main/resources/mapper/order/StoreOrderMapper.xml @@ -108,4 +108,129 @@ and info.tenant_id =#{tenantId} + + + + +