大屏添加门店
This commit is contained in:
@ -0,0 +1,19 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.diningplates.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zt
|
||||||
|
* @description <description class purpose>
|
||||||
|
* @since 2024/4/16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DiningPlatesStoreVo {
|
||||||
|
|
||||||
|
@Schema(description = "门店ID")
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
@Schema(description = "门店ID")
|
||||||
|
private Integer num;
|
||||||
|
}
|
@ -30,7 +30,6 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
@Tag(name = "管理后台 - 大屏")
|
@Tag(name = "管理后台 - 大屏")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/member/screen")
|
@RequestMapping("/member/screen")
|
||||||
@PermitAll
|
|
||||||
public class ScreenController {
|
public class ScreenController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -44,26 +43,30 @@ public class ScreenController {
|
|||||||
|
|
||||||
@GetMapping("/getEvaluate")
|
@GetMapping("/getEvaluate")
|
||||||
@Operation(summary = "获得店铺评价,1-好评,2-差评")
|
@Operation(summary = "获得店铺评价,1-好评,2-差评")
|
||||||
public Map<String,String> getEvaluate(){
|
@PermitAll
|
||||||
return storeEvaluateService.getEvaluate();
|
public Map<String,String> getEvaluate(Long storeId){
|
||||||
|
return storeEvaluateService.getEvaluate(storeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getData")
|
@GetMapping("/getData")
|
||||||
@Operation(summary = "食堂今日顾客流量")
|
@Operation(summary = "食堂今日顾客流量")
|
||||||
public CommonResult<List<CustomerTrafficRespVO>> getData() {
|
@PermitAll
|
||||||
List<CustomerTrafficDO> data = customerTrafficService.getData();
|
public CommonResult<List<CustomerTrafficRespVO>> getData(Long storeId) {
|
||||||
|
List<CustomerTrafficDO> data = customerTrafficService.getData(storeId);
|
||||||
return success(BeanUtils.toBean(data, CustomerTrafficRespVO.class));
|
return success(BeanUtils.toBean(data, CustomerTrafficRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getUserCount")
|
@GetMapping("/getUserCount")
|
||||||
@Operation(summary = "获取总顾客流量")
|
@Operation(summary = "获取总顾客流量")
|
||||||
public CommonResult<Integer> getUserCount() {
|
@PermitAll
|
||||||
return success(orderService.selectTodayUser());
|
public CommonResult<Integer> getUserCount(Long storeId) {
|
||||||
|
return success(orderService.selectTodayUser(storeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/selectDishSale")
|
@GetMapping("/selectDishSale")
|
||||||
@Operation(summary = "菜品今日销售")
|
@Operation(summary = "菜品今日销售")
|
||||||
public CommonResult<List<DishVo>> selectDishSale() {
|
@PermitAll
|
||||||
return success(orderDetailService.selectDishSale());
|
public CommonResult<List<DishVo>> selectDishSale(Long storeId) {
|
||||||
|
return success(orderDetailService.selectDishSale(storeId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesStoreVo;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 餐盘 Mapper
|
* 餐盘 Mapper
|
||||||
@ -25,4 +29,7 @@ public interface DiningPlatesMapper extends BaseMapperX<DiningPlatesDO> {
|
|||||||
.orderByDesc(DiningPlatesDO::getId));
|
.orderByDesc(DiningPlatesDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Select("select store_id,count(*) as num from member_dining_plates where create_time = #{time} group by store_id")
|
||||||
|
List<DiningPlatesStoreVo> selectCountByStore(String time);
|
||||||
|
|
||||||
}
|
}
|
@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.member.controller.app.order.vo.AppOrderPageReqVO;
|
|||||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,7 +43,7 @@ public interface DishOrderMapper extends BaseMapperX<DishOrderDO> {
|
|||||||
.orderByDesc(DishOrderDO::getId));
|
.orderByDesc(DishOrderDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Select("select count(distinct user_id) from member_dish_order where create_time between #{startTime} and #{endTime}")
|
|
||||||
Integer selectTodayUser(@Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime);
|
Integer selectTodayUser(@Param("time") String time,@Param("storeId") Long storeId);
|
||||||
|
|
||||||
}
|
}
|
@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +31,7 @@ public interface OrderDetailMapper extends BaseMapperX<OrderDetailDO> {
|
|||||||
.orderByDesc(OrderDetailDO::getId));
|
.orderByDesc(OrderDetailDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Select("select dishes_name, sum(a.weight) as weight , sum(a.price) as price from member_order_detail a where a.create_time between #{startTime} and #{endTime} group by a.dishes_id,a.dishes_name")
|
@Select("")
|
||||||
List<DishVo> selectDishSale(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
List<DishVo> selectDishSale(@Param("time") String time, @Param("storeId") Long storeId);
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.member.job;
|
package cn.iocoder.yudao.module.member.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesStoreVo;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO;
|
||||||
import cn.iocoder.yudao.module.member.service.customertraffic.CustomerTrafficService;
|
import cn.iocoder.yudao.module.member.service.customertraffic.CustomerTrafficService;
|
||||||
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
|
import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService;
|
||||||
@ -12,6 +14,8 @@ import org.springframework.stereotype.Component;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zt
|
* @author zt
|
||||||
@ -36,11 +40,21 @@ public class CustomerTrafficJob implements JobHandler {
|
|||||||
public String execute(String param) {
|
public String execute(String param) {
|
||||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(MemberConstants.HOUR_FORMAT);
|
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(MemberConstants.HOUR_FORMAT);
|
||||||
LocalDateTime localDateTime = LocalDateTime.now().withSecond(0);
|
LocalDateTime localDateTime = LocalDateTime.now().withSecond(0);
|
||||||
Integer diningPlatesNum = platesService.getDiningPlatesNum(localDateTime,ROUND_TIME);
|
List<DiningPlatesStoreVo> diningPlatesNum = platesService.getDiningPlatesNum(localDateTime, ROUND_TIME);
|
||||||
CustomerTrafficDO customerTrafficDO = new CustomerTrafficDO();
|
if(CollectionUtil.isNotEmpty(diningPlatesNum)){
|
||||||
customerTrafficDO.setCustomerNum(diningPlatesNum).setTimePoint(localDateTime.format(dateFormatter));
|
List<CustomerTrafficDO> addList = new ArrayList<>();
|
||||||
|
diningPlatesNum.forEach(a -> {
|
||||||
|
if(a.getStoreId()!=null){
|
||||||
|
CustomerTrafficDO customerTrafficDO = new CustomerTrafficDO();
|
||||||
|
customerTrafficDO.setCustomerNum(a.getNum())
|
||||||
|
.setTimePoint(localDateTime.format(dateFormatter))
|
||||||
|
.setStoreId(a.getStoreId());
|
||||||
|
addList.add(customerTrafficDO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trafficService.insertBatch(addList);
|
||||||
|
}
|
||||||
|
|
||||||
trafficService.insertOne(customerTrafficDO);
|
|
||||||
log.info("[execute][顾客统计任务顾客数量 ({}) 个]", diningPlatesNum);
|
log.info("[execute][顾客统计任务顾客数量 ({}) 个]", diningPlatesNum);
|
||||||
return String.format("顾客统计定时任务顾客数量 %s 个", diningPlatesNum);
|
return String.format("顾客统计定时任务顾客数量 %s 个", diningPlatesNum);
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,11 @@ public interface CustomerTrafficService {
|
|||||||
PageResult<CustomerTrafficDO> getCustomerTrafficPage(CustomerTrafficPageReqVO pageReqVO);
|
PageResult<CustomerTrafficDO> getCustomerTrafficPage(CustomerTrafficPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
|
||||||
void insertOne(CustomerTrafficDO customerTrafficDO);
|
void insertBatch(List<CustomerTrafficDO> list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取最新7个时间节点的数据
|
* 获取最新7个时间节点的数据
|
||||||
*/
|
*/
|
||||||
List<CustomerTrafficDO> getData();
|
List<CustomerTrafficDO> getData(Long storeId);
|
||||||
|
|
||||||
}
|
}
|
@ -72,15 +72,16 @@ public class CustomerTrafficServiceImpl implements CustomerTrafficService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertOne(CustomerTrafficDO customerTrafficDO) {
|
public void insertBatch(List<CustomerTrafficDO> list) {
|
||||||
customerTrafficMapper.insert(customerTrafficDO);
|
customerTrafficMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CustomerTrafficDO> getData() {
|
public List<CustomerTrafficDO> getData(Long storeId) {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
List<CustomerTrafficDO> customerTrafficDOS = customerTrafficMapper.selectList(Wrappers.<CustomerTrafficDO>lambdaQuery()
|
List<CustomerTrafficDO> customerTrafficDOS = customerTrafficMapper.selectList(Wrappers.<CustomerTrafficDO>lambdaQuery()
|
||||||
.lt(CustomerTrafficDO::getCreateTime, now)
|
.lt(CustomerTrafficDO::getCreateTime, now)
|
||||||
|
.eq(storeId!=null,CustomerTrafficDO::getStoreId,storeId)
|
||||||
.orderByDesc(CustomerTrafficDO::getCustomerNum)
|
.orderByDesc(CustomerTrafficDO::getCustomerNum)
|
||||||
.last("limit 7"));
|
.last("limit 7"));
|
||||||
return customerTrafficDOS;
|
return customerTrafficDOS;
|
||||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.service.diningplates;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesSaveReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesStoreVo;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||||
|
|
||||||
@ -90,5 +91,5 @@ public interface DiningPlatesService {
|
|||||||
|
|
||||||
AppUserInfoCardVO appCheckBind(String diningPlatesNum);
|
AppUserInfoCardVO appCheckBind(String diningPlatesNum);
|
||||||
|
|
||||||
Integer getDiningPlatesNum(LocalDateTime localDateTime,Integer time);
|
List<DiningPlatesStoreVo> getDiningPlatesNum(LocalDateTime localDateTime, Integer time);
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|||||||
import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender;
|
import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesPageReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesSaveReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.diningplates.vo.DiningPlatesStoreVo;
|
||||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||||
@ -17,7 +18,6 @@ import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
|||||||
import cn.iocoder.yudao.module.member.service.card.CardService;
|
import cn.iocoder.yudao.module.member.service.card.CardService;
|
||||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -268,22 +268,15 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getDiningPlatesNum(LocalDateTime localDateTime, Integer time) {
|
public List<DiningPlatesStoreVo> getDiningPlatesNum(LocalDateTime localDateTime, Integer time) {
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(MemberConstants.TIME_FORMAT);
|
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(MemberConstants.DATE_FORMAT);
|
||||||
LocalDateTime currentTime = localDateTime;
|
LocalDateTime currentTime = localDateTime;
|
||||||
|
|
||||||
// 计算指定分钟之前的时间
|
// 计算指定分钟之前的时间
|
||||||
LocalDateTime timeMinutesAgo = currentTime.minusMinutes(time);
|
String nowTime = currentTime.format(dateFormatter);
|
||||||
String end = currentTime.format(dateFormatter);
|
List<DiningPlatesStoreVo> diningPlatesStoreVos = diningPlatesMapper.selectCountByStore(nowTime);
|
||||||
String start = timeMinutesAgo.format(dateFormatter);
|
return diningPlatesStoreVos;
|
||||||
|
|
||||||
QueryWrapper<DiningPlatesDO> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.le("date_format(binding_time,'%Y-%m-%d %H:%i:%s')",end)
|
|
||||||
.gt("date_format(binding_time,'%Y-%m-%d %H:%i:%s')",start);
|
|
||||||
|
|
||||||
Integer l = diningPlatesMapper.selectCount(queryWrapper).intValue();
|
|
||||||
return l;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,6 +89,6 @@ public interface OrderService {
|
|||||||
* 获取今日顾客总量
|
* 获取今日顾客总量
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer selectTodayUser();
|
Integer selectTodayUser(Long storeId);
|
||||||
|
|
||||||
}
|
}
|
@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
|||||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||||
|
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -31,6 +32,7 @@ import java.math.RoundingMode;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -215,19 +217,9 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer selectTodayUser() {
|
public Integer selectTodayUser(Long storeId) {
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
|
String time = today.format(DateTimeFormatter.ofPattern(MemberConstants.DATE_FORMAT));
|
||||||
// 一天的开始时间
|
return dishOrderMapper.selectTodayUser(time,storeId);
|
||||||
LocalDateTime startOfDay = today.atStartOfDay();
|
|
||||||
// 一天的结束时间
|
|
||||||
LocalDateTime endOfDay = today.atTime(LocalTime.MAX);
|
|
||||||
|
|
||||||
return dishOrderMapper.selectTodayUser(startOfDay,endOfDay);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -59,5 +59,5 @@ public interface OrderDetailService {
|
|||||||
|
|
||||||
List<OrderDetailDO> selectListByOrderIds(List<Long> orderIds);
|
List<OrderDetailDO> selectListByOrderIds(List<Long> orderIds);
|
||||||
|
|
||||||
List<DishVo> selectDishSale();
|
List<DishVo> selectDishSale(Long storeId);
|
||||||
}
|
}
|
@ -30,8 +30,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -180,17 +179,10 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DishVo> selectDishSale() {
|
public List<DishVo> selectDishSale(Long storeId) {
|
||||||
// 获取当前日期
|
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
|
String time = today.format(DateTimeFormatter.ofPattern(MemberConstants.DATE_FORMAT));
|
||||||
// 一天的开始时间
|
return orderDetailMapper.selectDishSale(time,storeId);
|
||||||
LocalDateTime startOfDay = today.atStartOfDay();
|
|
||||||
|
|
||||||
// 一天的结束时间
|
|
||||||
LocalDateTime endOfDay = today.atTime(LocalTime.MAX);
|
|
||||||
|
|
||||||
return orderDetailMapper.selectDishSale(startOfDay,endOfDay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public interface StoreEvaluateService {
|
|||||||
|
|
||||||
StoreEvaluateDO selectByUserId(Long storeId);
|
StoreEvaluateDO selectByUserId(Long storeId);
|
||||||
|
|
||||||
Map<String,String> getEvaluate();
|
Map<String,String> getEvaluate(Long storeId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.member.controller.app.storeevaluate.vo.AppStoreEv
|
|||||||
import cn.iocoder.yudao.module.member.dal.dataobject.storeevaluate.StoreEvaluateDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.storeevaluate.StoreEvaluateDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.mysql.storeevaluate.StoreEvaluateMapper;
|
import cn.iocoder.yudao.module.member.dal.mysql.storeevaluate.StoreEvaluateMapper;
|
||||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -107,20 +108,23 @@ public class StoreEvaluateServiceImpl implements StoreEvaluateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getEvaluate() {
|
public Map<String, String> getEvaluate(Long storeId) {
|
||||||
HashMap<String, String> result = new HashMap<>();
|
HashMap<String, String> result = new HashMap<>();
|
||||||
Long good = storeEvaluateMapper.selectCount(Wrappers.<StoreEvaluateDO>lambdaQuery()
|
LambdaQueryWrapper<StoreEvaluateDO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
.gt(StoreEvaluateDO::getEvaluate, MemberConstants.GOOD_EVALUATE));
|
queryWrapper.eq(storeId != null,StoreEvaluateDO::getStoreId,storeId);
|
||||||
Long total = storeEvaluateMapper.selectCount();
|
Long good = storeEvaluateMapper.selectCount(queryWrapper
|
||||||
|
.gt(StoreEvaluateDO::getEvaluate, MemberConstants.GOOD_EVALUATE)
|
||||||
|
);
|
||||||
|
Long total = storeEvaluateMapper.selectCount(queryWrapper);
|
||||||
if(total == 0){
|
if(total == 0){
|
||||||
result.put("1","0");
|
result.put("1","0.00%");
|
||||||
result.put("0","0");
|
result.put("0","0.00%");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
BigDecimal goodPercent = new BigDecimal(good).divide(new BigDecimal(total), 4, BigDecimal.ROUND_HALF_UP);
|
BigDecimal goodPercent = new BigDecimal(good).divide(new BigDecimal(total), 4, BigDecimal.ROUND_HALF_UP);
|
||||||
BigDecimal badPercent = BigDecimal.ONE.subtract(goodPercent);
|
BigDecimal badPercent = BigDecimal.ONE.subtract(goodPercent);
|
||||||
result.put("1",goodPercent.multiply(new BigDecimal("100")).toString()+"%");
|
result.put("1",goodPercent.multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP).toString()+"%");
|
||||||
result.put("0",badPercent.multiply(new BigDecimal("100")).toString()+"%");
|
result.put("0",badPercent.multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP).toString()+"%");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
<select id="selectTodayUser" resultType="integer">
|
||||||
|
select count(distinct user_id) from member_dish_order where
|
||||||
|
date_format(create_time,'%Y-%m-%d') = #{time}
|
||||||
|
<if test="storeId != null">
|
||||||
|
and store_id = #{storeId}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.member.dal.mysql.orderdetail.OrderDetailMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
<select id="selectDishSale" resultType="cn.iocoder.yudao.module.member.controller.admin.screen.vo.DishVo">
|
||||||
|
select dishes_name, sum(a.weight) as weight , sum(a.price) as price
|
||||||
|
from member_order_detail a
|
||||||
|
where date_format(a.create_time,'%Y-%m-%d') = #{time}
|
||||||
|
<if test="storeId != null">
|
||||||
|
and order_id in
|
||||||
|
(select id from member_dish_order
|
||||||
|
where store_id = #{storeId}
|
||||||
|
and date_format(create_time,'%Y-%m-%d') = #{time})
|
||||||
|
</if>
|
||||||
|
group by a.dishes_id,a.dishes_name
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
Reference in New Issue
Block a user