Merge remote-tracking branch 'origin/test'

pull/17/head
Jruome 2023-06-27 14:02:43 +08:00
commit f7da38634b
8 changed files with 248 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -120,6 +120,39 @@ public class DataAnalysisController {
}
// 销售(推广员维度) 导出
@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<PromoterAnalysisReqVO> promoterAnalysisReqVOPageResult = storeOrderService.promoterAnalysis(request);
List<PromoterAnalysisExcelVo> 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<List<RefundAnalysisReqVo>> refundAnalysis(@Validated DataAnalysisRequest request) {
return CommonResult.success(storeOrderService.refundAnalysis(request));
}
@Operation(summary = "退款分析(订单量)")
@RequestMapping(value = "/refundOrderAnalysis", method = RequestMethod.GET)
@PreAuthenticated
@TenantIgnore
public CommonResult<RefundOrderAnalysisReqVO> refundOrderAnalysis(@Validated DataAnalysisRequest request) {
return CommonResult.success(storeOrderService.refundOrderAnalysis(request));
}
}

View File

@ -1,8 +1,7 @@
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.StatisticsPageVo;
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;
@ -11,6 +10,7 @@ import cn.iocoder.yudao.module.shop.response.order.StoreOrderStatisticsChartItem
import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram;
import cn.iocoder.yudao.module.shop.vo.order.StoreStaffDetail;
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;
@ -85,4 +85,10 @@ public interface StoreOrderMapper extends BaseMapperX<StoreOrder> {
List<StatementAllReqDataVo> statisticsAll(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("tenantId") Long tenantId);
IPage<StatisticsPageVo> statisticsAnalysis(IPage<StatisticsPageVo> page, @Param("data")DataAnalysisRequest request);
IPage<PromoterAnalysisReqVO> promoterAnalysis(Page<PromoterAnalysisReqVO> page, @Param("data")DataAnalysisRequest request);
List<RefundAnalysisReqVo> refundAnalysis(@Param("data")DataAnalysisRequest request);
RefundOrderAnalysisReqVO refundOrderAnalysis(@Param("data")DataAnalysisRequest request);
}

View File

@ -421,4 +421,8 @@ public interface StoreOrderService extends IService<StoreOrder> {
PageResult<StatisticsPageVo> statisticsAnalysis(DataAnalysisRequest request);
PageResult<PromoterAnalysisReqVO> promoterAnalysis(DataAnalysisRequest request);
List<RefundAnalysisReqVo> refundAnalysis(DataAnalysisRequest request);
RefundOrderAnalysisReqVO refundOrderAnalysis(DataAnalysisRequest request);
}

View File

@ -1532,11 +1532,17 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
@Override
public DimensionalityAnalysisReqVO dimensionalityAnalysis(DataAnalysisRequest request) {
if (!Objects.nonNull(request.getTenantId())) {
request.setTenantId(TenantContextHolder.getTenantId());
}
return null;
}
@Override
public List<AffiliationAnalysisReqVO> affiliation(DataAnalysisRequest request) {
if (!Objects.nonNull(request.getTenantId())) {
request.setTenantId(TenantContextHolder.getTenantId());
}
return null;
}
@ -1544,14 +1550,38 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
public PageResult<StatisticsPageVo> statisticsAnalysis(DataAnalysisRequest request) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<StatisticsPageVo> 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<PromoterAnalysisReqVO> promoterAnalysis(DataAnalysisRequest request) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<PromoterAnalysisReqVO> 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());
}
return null;
@Override
public List<RefundAnalysisReqVo> 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) {

View File

@ -131,6 +131,9 @@
<if test="null != data.endTime">
and t1.create_time &lt; #{endTime}
</if>
<if test="data.tenantId !=null and data.tenantId!=1">
and t1.tenant_id =#{data.tenantId}
</if>
GROUP BY
t1.tenant_id
<choose>
@ -142,4 +145,92 @@
</otherwise>
</choose>
</select>
<select id="promoterAnalysis"
resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.PromoterAnalysisReqVO">
SELECT
t4.`name` AS tenantName,
t2.nickname AS promoterName,
SUM(t6.price) AS totalMoney,
count(t6.id) AS totalNum,
SUM(IF(t5.refund_status=2,t6.price,0)) AS totalWithdrawMoney,
sum(t6.price = 240) AS threeTotalNum,
sum(t6.price = 400) AS twoTotalNum,
sum(t6.price = 640) AS oneTotalNum
FROM
member_promoter t1
JOIN member_user t2 ON t1.user_id = t2.id
LEFT JOIN system_dept t3 ON t1.dept_id = t3.id
LEFT JOIN system_tenant t4 ON t1.tenant_id = t4.id
LEFT JOIN cy_recharge_order t5 ON t1.user_id = t5.promoter_id
LEFT JOIN cy_recharge_order_info t6 ON t5.id = t6.recharge_order_id
WHERE t5.paid != 0
<if test="null != data.startTime">
and t1.create_time &gt;= #{startTime}
</if>
<if test="null != data.endTime">
and t1.create_time &lt; #{endTime}
</if>
<if test="data.tenantId !=null and data.tenantId!=1">
and t1.tenant_id =#{data.tenantId}
</if>
GROUP BY
t1.user_id, t4.`name`
<choose>
<when test="data.sortMoney !=null and data.sortMoney=1">
ORDER BY totalMoney DESC,totalNum DESC
</when>
<otherwise>
ORDER BY totalMoney ASC,totalNum ASC
</otherwise>
</choose>
</select>
<select id="refundAnalysis"
resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RefundAnalysisReqVo">
SELECT
refund_type,
refund_name,
count( refund_type ) AS totalNum
FROM
cy_recharge_order
WHERE
paid = 2
AND refund_status = 2
AND refund_type IS NOT NULL
<if test="null != data.startTime">
and t1.create_time &gt;= #{startTime}
</if>
<if test="null != data.endTime">
and t1.create_time &lt; #{endTime}
</if>
<if test="data.tenantId !=null and data.tenantId!=1">
and t1.tenant_id =#{data.tenantId}
</if>
GROUP BY
refund_type,refund_name
</select>
<select id="refundOrderAnalysis"
resultType="cn.iocoder.yudao.module.shop.controller.admin.recharge.vo.RefundOrderAnalysisReqVO">
SELECT
COUNT(CASE WHEN refund_status = 2 THEN 1 END) AS alreadyTotalNum,
COUNT(CASE WHEN refund_status != 2 THEN 1 END) AS notTotalNum
FROM
cy_recharge_order
WHERE
paid = 1
<if test="null != data.startTime">
and t1.create_time &gt;= #{startTime}
</if>
<if test="null != data.endTime">
and t1.create_time &lt; #{endTime}
</if>
<if test="data.tenantId !=null and data.tenantId!=1">
and t1.tenant_id =#{data.tenantId}
</if>
</select>
</mapper>