数据统计
This commit is contained in:
parent
1e29682782
commit
fee909b675
|
|
@ -7,12 +7,13 @@ import com.czg.order.param.DataSummaryTradeParam;
|
|||
import com.czg.order.service.DataSummaryService;
|
||||
import com.czg.order.vo.DataSummaryDateAmountVo;
|
||||
import com.czg.order.vo.DataSummaryPayTypeVo;
|
||||
import com.czg.order.vo.DataSummaryProductSaleVo;
|
||||
import com.czg.order.vo.DataSummaryProductSaleRankingVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.validator.ValidatorUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -52,10 +53,11 @@ public class DataSummaryController {
|
|||
@GetMapping("productSaleDate")
|
||||
@OperationLog("商品销售-右下")
|
||||
//@SaAdminCheckPermission("dataSummary:productSaleData")
|
||||
public CzgResult<DataSummaryProductSaleVo> getProductSaleData(DataSummaryProductSaleParam param) {
|
||||
public CzgResult<Page<DataSummaryProductSaleRankingVo>> getProductSaleData(DataSummaryProductSaleParam param) {
|
||||
ValidatorUtil.validateEntity(param, DefaultGroup.class);
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
param.setShopId(shopId);
|
||||
DataSummaryProductSaleVo data = dataSummaryService.getProductSaleData(param);
|
||||
Page<DataSummaryProductSaleRankingVo> data = dataSummaryService.getProductSaleRankingPage(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
package com.czg.order.param;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据统计-营业-产品销量
|
||||
|
|
@ -21,7 +24,13 @@ public class DataSummaryProductSaleParam implements Serializable {
|
|||
/**
|
||||
* 天数
|
||||
*/
|
||||
@NotNull(message = "天数不能为空", groups = DefaultGroup.class)
|
||||
private Integer day;
|
||||
/**
|
||||
* 天数列表
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private List<String> days;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.czg.order.param;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
|
|
@ -17,20 +18,24 @@ public class SaleSummaryCountParam implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* shopId
|
||||
* 店铺id
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
private Long shopId;
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Long cateId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String proName;
|
||||
private String productName;
|
||||
/**
|
||||
* 类型
|
||||
* 商品分类id
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private Long prodCategoryId;
|
||||
/**
|
||||
* 开始日期 格式:yyyy-MM-dd
|
||||
*/
|
||||
private String beginDate;
|
||||
/**
|
||||
* 结束日期 格式:yyyy-MM-dd
|
||||
*/
|
||||
private String endDate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import com.czg.order.param.DataSummaryProductSaleParam;
|
|||
import com.czg.order.param.DataSummaryTradeParam;
|
||||
import com.czg.order.vo.DataSummaryDateAmountVo;
|
||||
import com.czg.order.vo.DataSummaryPayTypeVo;
|
||||
import com.czg.order.vo.DataSummaryProductSaleVo;
|
||||
import com.czg.order.vo.DataSummaryProductSaleRankingVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
||||
/**
|
||||
* 数据统计Service接口
|
||||
|
|
@ -17,7 +18,7 @@ public interface DataSummaryService {
|
|||
|
||||
ShopOrderStatistic getTradeData(DataSummaryTradeParam param);
|
||||
|
||||
DataSummaryProductSaleVo getProductSaleData(DataSummaryProductSaleParam param);
|
||||
Page<DataSummaryProductSaleRankingVo> getProductSaleRankingPage(DataSummaryProductSaleParam param);
|
||||
|
||||
DataSummaryDateAmountVo getSummaryAmountData(Long shopId,Integer day);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.czg.order.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -12,7 +11,6 @@ import java.math.BigDecimal;
|
|||
* @author tankaikai
|
||||
* @since 2025-03-07 16:22
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class SaleSummaryCountVo implements Serializable {
|
||||
|
||||
|
|
@ -20,23 +18,19 @@ public class SaleSummaryCountVo implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* icon
|
||||
* 总金额
|
||||
*/
|
||||
private String icon;
|
||||
private BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* isAmount
|
||||
* 退款金额
|
||||
*/
|
||||
private String isAmount;
|
||||
private BigDecimal refundAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* payAmount
|
||||
* 总数量
|
||||
*/
|
||||
private Double payAmount;
|
||||
private BigDecimal saleCount = BigDecimal.ZERO;
|
||||
/**
|
||||
* payType
|
||||
* 退单量
|
||||
*/
|
||||
private String payType;
|
||||
/**
|
||||
* saveAmount
|
||||
*/
|
||||
private BigDecimal saveAmount;
|
||||
private Integer refundCount = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
package com.czg.service.order.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.order.entity.ShopProdStatistic;
|
||||
import com.czg.order.param.DataSummaryProductSaleParam;
|
||||
import com.czg.order.param.SaleSummaryCountParam;
|
||||
import com.czg.order.vo.DataSummaryProductSaleRankingVo;
|
||||
import com.czg.order.vo.SaleSummaryCountVo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
|
|
@ -11,4 +17,8 @@ import com.czg.order.entity.ShopProdStatistic;
|
|||
*/
|
||||
public interface ShopProdStatisticMapper extends BaseMapper<ShopProdStatistic> {
|
||||
|
||||
List<DataSummaryProductSaleRankingVo> findProdRandingSummaryPage(DataSummaryProductSaleParam param);
|
||||
|
||||
SaleSummaryCountVo getSaleSummaryCount(SaleSummaryCountParam param);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,14 @@ import com.czg.order.param.DataSummaryTradeParam;
|
|||
import com.czg.order.service.DataSummaryService;
|
||||
import com.czg.order.vo.DataSummaryDateAmountVo;
|
||||
import com.czg.order.vo.DataSummaryPayTypeVo;
|
||||
import com.czg.order.vo.DataSummaryProductSaleVo;
|
||||
import com.czg.order.vo.DataSummaryProductSaleRankingVo;
|
||||
import com.czg.service.order.mapper.OrderInfoMapper;
|
||||
import com.czg.service.order.mapper.ShopOrderStatisticMapper;
|
||||
import com.czg.service.order.mapper.ShopProdStatisticMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -34,6 +39,8 @@ public class DataSummaryServiceImpl implements DataSummaryService {
|
|||
private ShopOrderStatisticMapper shopOrderStatisticMapper;
|
||||
@Resource
|
||||
private OrderInfoMapper orderInfoMapper;
|
||||
@Resource
|
||||
private ShopProdStatisticMapper shopProdStatisticMapper;
|
||||
|
||||
@Override
|
||||
public ShopOrderStatistic getTradeData(DataSummaryTradeParam param) {
|
||||
|
|
@ -45,10 +52,19 @@ public class DataSummaryServiceImpl implements DataSummaryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DataSummaryProductSaleVo getProductSaleData(DataSummaryProductSaleParam param) {
|
||||
DataSummaryProductSaleVo data = new DataSummaryProductSaleVo();
|
||||
System.out.println(1);
|
||||
return data;
|
||||
public Page<DataSummaryProductSaleRankingVo> getProductSaleRankingPage(DataSummaryProductSaleParam param) {
|
||||
LocalDate now = LocalDate.now();
|
||||
Integer day = param.getDay();
|
||||
LocalDate beginDate = now.plusDays(-day);
|
||||
List<String> days = new ArrayList<>();
|
||||
for (int i = 1; i <= day; i++) {
|
||||
String thisDay = beginDate.plusDays(i).format(DatePattern.NORM_DATE_FORMATTER);
|
||||
days.add(thisDay);
|
||||
}
|
||||
param.setDays(days);
|
||||
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
PageInfo<DataSummaryProductSaleRankingVo> pageInfo = new PageInfo<>(shopProdStatisticMapper.findProdRandingSummaryPage(param));
|
||||
return PageUtil.convert(pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import com.czg.order.param.SaleSummaryCountParam;
|
|||
import com.czg.order.service.SaleSummaryService;
|
||||
import com.czg.order.vo.SaleSummaryCountVo;
|
||||
import com.czg.order.vo.SaleSummaryInfoVo;
|
||||
import com.czg.service.order.mapper.ShopProdStatisticMapper;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -18,10 +20,16 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class SaleSummaryServiceImpl implements SaleSummaryService {
|
||||
@Resource
|
||||
private ShopProdStatisticMapper shopProdStatisticMapper;
|
||||
|
||||
@Override
|
||||
public SaleSummaryCountVo summaryCount(SaleSummaryCountParam param) {
|
||||
return new SaleSummaryCountVo();
|
||||
SaleSummaryCountVo saleSummaryCount = shopProdStatisticMapper.getSaleSummaryCount(param);
|
||||
if (saleSummaryCount == null) {
|
||||
saleSummaryCount = new SaleSummaryCountVo();
|
||||
}
|
||||
return saleSummaryCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@
|
|||
<select id="getTradeData" resultType="com.czg.order.entity.ShopOrderStatistic">
|
||||
select
|
||||
sum(sale_amount) as sale_amount,
|
||||
count(sale_count) as sale_count,
|
||||
sum(sale_count) as sale_count,
|
||||
sum(discount_amount) as discount_amount,
|
||||
count(discount_count) as discount_count,
|
||||
sum(discount_count) as discount_count,
|
||||
sum(refund_amount) as refund_amount,
|
||||
count(refund_count) as refund_count,
|
||||
count(wechat_pay_count) as wechat_pay_count,
|
||||
sum(refund_count) as refund_count,
|
||||
sum(wechat_pay_count) as wechat_pay_count,
|
||||
sum(wechat_pay_amount) as wechat_pay_amount,
|
||||
count(ali_pay_count) as ali_pay_count,
|
||||
sum(ali_pay_count) as ali_pay_count,
|
||||
sum(ali_pay_amount) as ali_pay_amount,
|
||||
count(credit_pay_count) as credit_pay_count,
|
||||
sum(credit_pay_count) as credit_pay_count,
|
||||
sum(credit_pay_amount) as credit_pay_amount,
|
||||
count(member_pay_count) as member_pay_count,
|
||||
sum(member_pay_count) as member_pay_count,
|
||||
sum(member_pay_amount) as member_pay_amount,
|
||||
count(scan_pay_count) as scan_pay_count,
|
||||
sum(scan_pay_count) as scan_pay_count,
|
||||
sum(scan_pay_amount) as scan_pay_amount,
|
||||
count(cash_pay_count) as cash_pay_count,
|
||||
sum(cash_pay_count) as cash_pay_count,
|
||||
sum(cash_pay_amount) as cash_pay_amount,
|
||||
sum(recharge_amount) as recharge_amount,
|
||||
avg(customer_unit_price) as customer_unit_price,
|
||||
|
|
|
|||
|
|
@ -4,4 +4,43 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.order.mapper.ShopProdStatisticMapper">
|
||||
|
||||
<select id="findProdRandingSummaryPage" resultType="com.czg.order.vo.DataSummaryProductSaleRankingVo">
|
||||
select
|
||||
t1.prod_id,
|
||||
t2.name as product_name,
|
||||
sum(t1.sale_count) as number,
|
||||
sum(t1.sale_amount) as amount
|
||||
from tb_shop_prod_statistic t1
|
||||
left join tb_product t2 on t1.prod_id = t2.id
|
||||
where t1.shop_id = #{shopId}
|
||||
and t1.create_day in
|
||||
<foreach item="day" collection="days" open="(" separator="," close=")">
|
||||
#{day}
|
||||
</foreach>
|
||||
group by t1.prod_id
|
||||
</select>
|
||||
<select id="getSaleSummaryCount" resultType="com.czg.order.vo.SaleSummaryCountVo">
|
||||
select
|
||||
sum(t1.sale_count) as sale_count,
|
||||
sum(t1.sale_amount) as total_amount,
|
||||
sum(t1.refund_count) as refund_count,
|
||||
sum(t1.refund_amount) as refund_amount
|
||||
from tb_shop_prod_statistic t1
|
||||
left join tb_product t2 on t1.prod_id = t2.id
|
||||
where t1.shop_id = #{shopId}
|
||||
<if test="productName != null and productName != ''">
|
||||
and t2.name like concat('%', #{productName}, '%')
|
||||
</if>
|
||||
<if test="prodCategoryId != null">
|
||||
and t2.category_id = #{prodCategoryId}
|
||||
</if>
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
and t1.create_day >= str_to_date(#{beginDate}, '%Y-%m-%d')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
<![CDATA[
|
||||
and t1.create_day <= str_to_date(#{endDate}, '%Y-%m-%d')
|
||||
]]>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue