|
|
@@ -1,30 +1,34 @@
|
|
|
package com.kym.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.kym.common.exception.BusinessException;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
import com.kym.common.utils.OrderUtils;
|
|
|
-import com.kym.entity.common.PageBean;
|
|
|
-import com.kym.entity.common.PageParams;
|
|
|
import com.kym.entity.Account;
|
|
|
import com.kym.entity.User;
|
|
|
import com.kym.entity.WashOrder;
|
|
|
+import com.kym.entity.common.PageBean;
|
|
|
+import com.kym.entity.common.PageParams;
|
|
|
import com.kym.entity.queryParams.DeviceQueryParams;
|
|
|
import com.kym.entity.queryParams.WashOrderQueryParams;
|
|
|
import com.kym.entity.vo.WashOrderVo;
|
|
|
import com.kym.mapper.WashOrderMapper;
|
|
|
-import com.kym.service.awoara.AwoaraService;
|
|
|
-import com.kym.service.cache.KymCache;
|
|
|
import com.kym.service.AccountService;
|
|
|
import com.kym.service.WashOrderService;
|
|
|
+import com.kym.service.awoara.AwoaraService;
|
|
|
+import com.kym.service.cache.KymCache;
|
|
|
import com.kym.service.mybatisplus.MyBaseServiceImpl;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -129,8 +133,8 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
|
|
|
WashOrder order = lambdaQuery()
|
|
|
.eq(WashOrder::getOrderId, params.getOrderId())
|
|
|
.one();
|
|
|
- if(null!=params.getUserId()){
|
|
|
- CommUtil.asserts(null!=order && order.getUserId().equals(StpUtil.getLoginIdAsLong()),
|
|
|
+ if (null != params.getUserId()) {
|
|
|
+ CommUtil.asserts(null != order && order.getUserId().equals(StpUtil.getLoginIdAsLong()),
|
|
|
"订单不存在或您没有权限查看该订单!");
|
|
|
}
|
|
|
return order;
|
|
|
@@ -165,7 +169,7 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
|
|
|
MPJLambdaWrapper<WashOrder> wrapper = JoinWrappers.lambda(WashOrder.class)
|
|
|
.selectAsClass(WashOrder.class, WashOrderVo.class)
|
|
|
.selectAs(User::getMobilePhone, WashOrderVo::getMobilePhone)
|
|
|
- .leftJoin(User.class, User::getId,WashOrder::getUserId)
|
|
|
+ .leftJoin(User.class, User::getId, WashOrder::getUserId)
|
|
|
.eq(CommUtil.isNotEmptyAndNull(params.getUserId()), WashOrder::getUserId, params.getUserId())
|
|
|
.eq(CommUtil.isNotEmptyAndNull(params.getMobilePhone()), User::getMobilePhone, params.getMobilePhone())
|
|
|
.eq(CommUtil.isNotEmptyAndNull(params.getOrderStatus()), WashOrder::getOrderStatus, params.getOrderStatus())
|
|
|
@@ -183,5 +187,67 @@ public class WashOrderServiceImpl extends MyBaseServiceImpl<WashOrderMapper, Was
|
|
|
public WashOrder detail(long id) {
|
|
|
return getById(id);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计指定日期消费金额
|
|
|
+ *
|
|
|
+ * @param statDay
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Integer sumAmountByDate(LocalDate statDay) {
|
|
|
+ LambdaQueryWrapper<WashOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.select(WashOrder::getAmount);
|
|
|
+ wrapper.ge(WashOrder::getStartTime, LocalDateTime.of(statDay, LocalTime.MIN));
|
|
|
+ wrapper.gt(WashOrder::getStartTime, LocalDateTime.of(statDay, LocalTime.MAX));
|
|
|
+ return list(wrapper).stream().mapToInt(WashOrder::getAmount).sum();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计指定日期当月总消费金额
|
|
|
+ *
|
|
|
+ * @param statDay
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Integer sumMonthAmount(LocalDate statDay) {
|
|
|
+ var startTime = statDay.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
|
|
|
+ var endTime = statDay.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
|
|
+ LambdaQueryWrapper<WashOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.select(WashOrder::getAmount);
|
|
|
+ wrapper.ge(WashOrder::getStartTime, startTime);
|
|
|
+ wrapper.gt(WashOrder::getStartTime, endTime);
|
|
|
+ return list(wrapper).stream().mapToInt(WashOrder::getAmount).sum();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计指定日期订单数量
|
|
|
+ *
|
|
|
+ * @param statDay
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Integer countOrdersCountByDate(LocalDate statDay) {
|
|
|
+ LambdaQueryWrapper<WashOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.ge(WashOrder::getStartTime, LocalDateTime.of(statDay, LocalTime.MIN));
|
|
|
+ wrapper.gt(WashOrder::getStartTime, LocalDateTime.of(statDay, LocalTime.MAX));
|
|
|
+ return (int) count(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计指定日期订单数量
|
|
|
+ *
|
|
|
+ * @param statDay
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Integer countMonthOrdersCount(LocalDate statDay) {
|
|
|
+ var startTime = statDay.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
|
|
|
+ var endTime = statDay.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
|
|
+ LambdaQueryWrapper<WashOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.ge(WashOrder::getStartTime, startTime);
|
|
|
+ wrapper.gt(WashOrder::getStartTime, endTime);
|
|
|
+ return (int) count(wrapper);
|
|
|
+ }
|
|
|
//endregion
|
|
|
}
|