Merge remote-tracking branch 'origin/master'

This commit is contained in:
张松
2025-03-12 11:43:35 +08:00
12 changed files with 84 additions and 62 deletions

View File

@@ -1,7 +1,9 @@
package com.czg.service.order.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.order.entity.ShopTableOrderStatistic;
import com.czg.order.param.TableSummaryParam;
import com.czg.order.vo.TableSummaryInfoVo;
import com.mybatisflex.core.BaseMapper;
import java.math.BigDecimal;
import java.util.List;
@@ -18,4 +20,5 @@ public interface ShopTableOrderStatisticMapper extends BaseMapper<ShopTableOrder
boolean incrInfo(long shopId, long tableId, long count, BigDecimal amount, String dateStr);
List<TableSummaryInfoVo> findSummaryList(TableSummaryParam param);
}

View File

@@ -48,6 +48,8 @@ public class DataSummaryServiceImpl implements DataSummaryService {
if (shopOrderStatistic == null) {
shopOrderStatistic = new ShopOrderStatistic();
}
shopOrderStatistic.setCustomerUnitPrice(shopOrderStatistic.getCustomerUnitPrice().setScale(2, java.math.RoundingMode.HALF_UP));
shopOrderStatistic.setTableTurnoverRate(shopOrderStatistic.getTableTurnoverRate().setScale(2, java.math.RoundingMode.HALF_UP));
return shopOrderStatistic;
}

View File

@@ -13,6 +13,7 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
@@ -93,8 +94,14 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
statistic = new ShopOrderStatistic();
statistic.setShopId(shopId);
statistic.setCreateDay(LocalDate.now());
statistic.setUpdateTime(LocalDateTime.now());
}
//TODO 充值金额
statistic.setRechargeAmount(BigDecimal.ZERO);
//TODO 客单价
statistic.setCustomerUnitPrice(BigDecimal.ZERO);
//TODO 翻台率
statistic.setTableTurnoverRate(BigDecimal.ZERO);
statistic.setUpdateTime(LocalDateTime.now());
BeanUtil.copyProperties(info, statistic);
saveOrUpdate(statistic);
});

View File

@@ -2,8 +2,9 @@ package com.czg.service.order.service.impl;
import com.czg.order.param.TableSummaryParam;
import com.czg.order.service.TableSummaryService;
import com.czg.order.vo.TableSummaryExportVo;
import com.czg.order.vo.TableSummaryInfoVo;
import com.czg.service.order.mapper.ShopTableOrderStatisticMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -17,14 +18,12 @@ import java.util.List;
@Service
public class TableSummaryServiceImpl implements TableSummaryService {
@Resource
private ShopTableOrderStatisticMapper shopTableOrderStatisticMapper;
@Override
public List<TableSummaryInfoVo> summaryList(TableSummaryParam param) {
return List.of();
return shopTableOrderStatisticMapper.findSummaryList(param);
}
@Override
public List<TableSummaryExportVo> summaryExport(TableSummaryParam param) {
return List.of();
}
}

View File

@@ -30,12 +30,12 @@
max(update_time) as update_time
from tb_shop_order_statistic
where shop_id = #{shopId}
<if test="beginTime != null">
and create_day >= str_to_date(#{beginTime}, '%Y-%m-%d')
<if test="beginDate != null and endDate != ''">
and create_day >= str_to_date(#{beginDate}, '%Y-%m-%d')
</if>
<if test="endTime != null">
<if test="endDate != null and endDate != ''">
<![CDATA[
and create_day <= str_to_date(#{endTime}, '%Y-%m-%d')
and create_day <= str_to_date(#{endDate}, '%Y-%m-%d')
]]>
</if>
group by shop_id

View File

@@ -26,4 +26,26 @@
a.table_id
order by a.id desc
</select>
<select id="findSummaryList" resultType="com.czg.order.vo.TableSummaryInfoVo">
select
t1.table_id,
ifnull(t3.name,'N/A') as area_name,
ifnull(t2.name,'N/A') as table_name,
sum(t1.order_count) as order_count,
sum(t1.order_amount) as order_amount,
ifnull(sum(t1.refund_count),0) as refund_count,
ifnull(sum(t1.refund_amount),0) as refund_amount
from tb_shop_table_order_statistic t1
left join tb_shop_table t2 on t1.table_id = t2.id
left join tb_shop_table_area t3 on t2.area_id = t3.id
where t1.shop_id = #{shopId}
<if test="beginDate != null and beginDate != ''">
AND t1.create_day >= str_to_date(#{beginDate}, '%Y-%m-%d')
</if>
<if test="endDate != null and endDate != ''">
and t2.create_day &lt;= str_to_date(#{endDate}, '%Y-%m-%d')
</if>
group by t1.table_id
order by sum(t1.order_count) desc,max(t1.id) desc
</select>
</mapper>