Merge remote-tracking branch 'origin/prod' into prod

This commit is contained in:
张松
2025-11-11 16:25:25 +08:00
7 changed files with 119 additions and 9 deletions

View File

@@ -44,7 +44,7 @@ public class DataSummaryController {
@SaAdminCheckPermission(value = "dataSummary:trade", name = "营业板块-上半部分")
public CzgResult<ShopOrderStatistic> getTradeData(DataSummaryTradeParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
Long shopId = StpKit.USER.getShopId(0L);
Long shopId = StpKit.USER.getShopId();
if (param.getShopId() == null) {
param.setShopId(shopId);
}
@@ -61,7 +61,7 @@ public class DataSummaryController {
@SaAdminCheckPermission(value = "dataSummary:productSaleData", name = "商品销售-右下")
public CzgResult<Page<DataSummaryProductSaleRankingVo>> getProductSaleData(DataSummaryProductSaleParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
Long shopId = StpKit.USER.getShopId(0L);
Long shopId = StpKit.USER.getShopId();
if (param.getShopId() == null) {
param.setShopId(shopId);
}
@@ -82,7 +82,7 @@ public class DataSummaryController {
public CzgResult<DataSummaryDateAmountVo> getDateAmount(@RequestParam Integer day, @RequestParam(required = false) Long shopId) {
AssertUtil.isNull(day, "天数不能为空");
if (shopId == null) {
shopId = StpKit.USER.getShopId(0L);
shopId = StpKit.USER.getShopId();
}
DataSummaryDateAmountVo data = dataSummaryService.getSummaryAmountData(shopId, day);
return CzgResult.success(data);

View File

@@ -18,8 +18,6 @@ import java.util.Date;
* @author zs
* @since 2025-03-07
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_table_order_statistic")
@@ -74,5 +72,94 @@ public class ShopTableOrderStatistic implements Serializable {
* 退款金额
*/
private BigDecimal refundAmount;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getTableId() {
return tableId;
}
public void setTableId(Long tableId) {
this.tableId = tableId;
}
public String getTableCode() {
return tableCode;
}
public void setTableCode(String tableCode) {
this.tableCode = tableCode;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public Long getOrderCount() {
return orderCount;
}
public void setOrderCount(Long orderCount) {
this.orderCount = orderCount;
}
public BigDecimal getOrderAmount() {
return orderAmount;
}
public void setOrderAmount(BigDecimal orderAmount) {
this.orderAmount = orderAmount;
}
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public Date getCreateDay() {
return createDay;
}
public void setCreateDay(Date createDay) {
this.createDay = createDay;
}
public Long getRefundCount() {
return refundCount;
}
public void setRefundCount(Long refundCount) {
this.refundCount = refundCount;
}
public BigDecimal getRefundAmount() {
return refundAmount;
}
public void setRefundAmount(BigDecimal refundAmount) {
this.refundAmount = refundAmount;
}
}

View File

@@ -33,5 +33,9 @@ public class DataSummaryTradeParam implements Serializable {
* 店铺id
*/
private Long shopId;
/**
* 主店id
*/
private Long mainShopId;
}

View File

@@ -3,6 +3,8 @@ package com.czg.service.order.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopInfoService;
import com.czg.order.entity.ShopOrderStatistic;
import com.czg.order.param.DataSummaryTradeParam;
import com.czg.order.service.DataSummaryService;
@@ -11,6 +13,7 @@ import com.czg.service.order.mapper.ShopOrderStatisticMapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@@ -28,6 +31,10 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
@Resource
private DataSummaryService dataSummaryService;
@DubboReference
private ShopInfoService shopInfoService;
@Override
public void statistic(DateTime dateTime) {
@@ -42,8 +49,10 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
List<List<Long>> split = CollUtil.split(shopIdList, 5);
for (List<Long> splitIdList : split) {
splitIdList.parallelStream().forEach(shopId -> {
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
DataSummaryTradeParam param = new DataSummaryTradeParam();
param.setShopId(shopId);
param.setMainShopId(mainShopId);
param.setBeginDate(startOfDay.toStringDefaultTimeZone());
param.setEndDate(endOfDay.toStringDefaultTimeZone());
ShopOrderStatistic statistic = dataSummaryService.getRealTimeTradeData(param);
@@ -61,7 +70,10 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
) {
log.info("店铺:{}{},没有要存档的订单统计数据", shopId, dateTime.toDateStr());
} else {
ShopOrderStatistic entity = getMapper().selectOneByQuery(query().eq(ShopOrderStatistic::getShopId, shopId).eq(ShopOrderStatistic::getCreateDay, dateTime.toDateStr()));
ShopOrderStatistic entity =
getMapper()
.selectOneByQuery(query().eq("shop_id", shopId)
.eq("create_day", dateTime.toDateStr()));
if (entity != null) {
statistic.setId(entity.getId());
updateById(statistic);

View File

@@ -60,7 +60,10 @@ public class ShopProdStatisticServiceImpl extends ServiceImpl<ShopProdStatisticM
param.setBeginDate(startOfDay.toStringDefaultTimeZone());
param.setEndDate(endOfDay.toStringDefaultTimeZone());
// 删除之前统计数据
getMapper().deleteByQuery(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, dateTime.toDateStr()));
getMapper().deleteByQuery(
QueryWrapper.create()
.eq("shop_id", shopId)
.eq("create_day", dateTime.toDateStr()));
// 重新统计数据
List<DataSummaryProductSaleRankingVo> list = shopProdStatisticMapper.findProdRandingSummaryPage2(param);
for (DataSummaryProductSaleRankingVo dto : list) {

View File

@@ -86,7 +86,11 @@ public class ShopTableOrderStatisticServiceImpl extends ServiceImpl<ShopTableOrd
param.setBeginDate(startOfDay.toStringDefaultTimeZone());
param.setEndDate(endOfDay.toStringDefaultTimeZone());
// 删除之前统计数据
getMapper().deleteByQuery(new QueryWrapper().eq(ShopTableOrderStatistic::getShopId, shopId).eq(ShopTableOrderStatistic::getCreateDay, dateTime.toDateStr()));
getMapper()
.deleteByQuery(
new QueryWrapper()
.eq("shop_id", shopId)
.eq("create_day", dateTime.toDateStr()));
// 重新统计数据
List<TableSummaryInfoVo> list = shopTableOrderStatisticMapper.findSummaryList2(param);
for (TableSummaryInfoVo dto : list) {

View File

@@ -41,7 +41,7 @@
group by shop_id
</select>
<select id="getNewMemberCount" resultType="java.lang.Long">
select count(1) from tb_shop_user where shop_id = #{shopId} and is_vip = 1
select count(1) from tb_shop_user where main_shop_id = #{mainShopId} and is_vip = 1
<if test="beginDate != null and beginDate != ''">
and join_time >= str_to_date(#{beginDate}, '%Y-%m-%d %H:%i:%s')
</if>