Commit 17c989b3 by 吕明尚

保洁负责的门店增加保洁状态

parent c87b0c38
......@@ -5,10 +5,13 @@ package share.common.enums;
* @Date 2023/10/20 10:57
*/
public enum OrderStatusEnum {
//(0:待使用/已预约,1:使用中,2:已使用,3:已取消预约/申请退款,4:退款中,5:已退费)
UNUSED(0,"待使用/已预约"),
INUSE(1,"使用中"),
USED(2,"已使用"),
CANCEL(3,"已取消");
CANCEL(3, "已取消"),
REFUNDING(4, "退款中"),
REFUNDED(5, "已退款");
private Integer code;
......
......@@ -95,6 +95,12 @@ public class SRoom extends BaseEntity
@TableField(exist = false)
private String openShopUuid;
/**
* 保洁状态
*/
@TableField(exist = false)
private Integer recordsStatus;
}
......@@ -38,13 +38,12 @@ import share.system.service.*;
/**
* 订单Service业务层处理
*
*
* @author ruoyi
* @date 2023-09-27
*/
@Service
public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implements ISOrderService
{
public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> implements ISOrderService {
private static final Logger logger = LoggerFactory.getLogger(SOrderServiceImpl.class);
......@@ -86,26 +85,47 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
/**
* 查询订单
*
*
* @param id 订单主键
* @return 订单
*/
@Override
public SOrder selectSOrderById(Long id)
{
public SOrder selectSOrderById(Long id) {
return sOrderMapper.selectSOrderById(id);
}
/**
* 查询订单列表
*
*
* @param sOrder 订单
* @return 订单
*/
@Override
public List<SOrder> selectSOrderList(SOrder sOrder)
{
List<SOrder> sOrders = sOrderMapper.selectSOrderList(sOrder);
public List<SOrder> selectSOrderList(SOrder sOrder) {
List<SOrder> sOrders = new ArrayList<>();
if (ObjectUtil.isNotEmpty(sOrder.getStatus())) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
if (sOrder.getStatus().equals(OrderStatusEnum.CANCEL.getCode())) {
queryWrapper.in(SOrder::getStatus, new ArrayList<Integer>() {{
add(OrderStatusEnum.CANCEL.getCode());
add(OrderStatusEnum.REFUNDING.getCode());
add(OrderStatusEnum.REFUNDED.getCode());
}});
} else if (sOrder.getStatus().equals(OrderStatusEnum.UNUSED.getCode())) {
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.UNUSED.getCode());
} else if (sOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
} else if (sOrder.getStatus().equals(OrderStatusEnum.USED.getCode())) {
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.USED.getCode());
}
if (ObjectUtil.isNotEmpty(sOrder.getConsumerId())) {
queryWrapper.eq(SOrder::getConsumerId, sOrder.getConsumerId());
}
sOrders = sOrderMapper.selectList(queryWrapper);
} else {
sOrders = sOrderMapper.selectSOrderList(sOrder);
}
if (CollectionUtils.isNotEmpty(sOrders)) {
sOrders.stream().forEach(item -> {
if (ObjectUtil.isNotNull(item.getCouponId())) {
......@@ -132,64 +152,60 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
/**
* 新增订单
*
*
* @param sOrder 订单
* @return 结果
*/
@Override
public int insertSOrder(SOrder sOrder)
{
public int insertSOrder(SOrder sOrder) {
sOrder.setCreateTime(DateUtils.getNowDate());
return sOrderMapper.insertSOrder(sOrder);
}
/**
* 修改订单
*
*
* @param sOrder 订单
* @return 结果
*/
@Override
public int updateSOrder(SOrder sOrder)
{
public int updateSOrder(SOrder sOrder) {
sOrder.setUpdateTime(DateUtils.getNowDate());
return sOrderMapper.updateSOrder(sOrder);
}
/**
* 批量删除订单
*
*
* @param ids 需要删除的订单主键
* @return 结果
*/
@Override
public int deleteSOrderByIds(Long[] ids)
{
public int deleteSOrderByIds(Long[] ids) {
return sOrderMapper.deleteSOrderByIds(ids);
}
/**
* 删除订单信息
*
*
* @param id 订单主键
* @return 结果
*/
@Override
public int deleteSOrderById(Long id)
{
public int deleteSOrderById(Long id) {
return sOrderMapper.deleteSOrderById(id);
}
@Override
public List<SOrder> listByRoomInfo(Long storeId, Long roomId, Date day) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getStoreId,storeId);
queryWrapper.eq(SOrder::getRoomId,roomId);
queryWrapper.notIn(SOrder::getRefundStatus,RefundStatusEnum.getNotRefundStatus());
String nowDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,day);
String nextDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.addDays(day,1));
queryWrapper.apply("(DATE_FORMAT(IFNULL(start_date,pre_start_date), '%Y-%m-%d') = '"+nowDayStr+"' " +
" OR DATE_FORMAT(IFNULL(start_date,pre_start_date), '%Y-%m-%d') = '"+nextDayStr+"')");
queryWrapper.eq(SOrder::getStoreId, storeId);
queryWrapper.eq(SOrder::getRoomId, roomId);
queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getNotRefundStatus());
String nowDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, day);
String nextDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.addDays(day, 1));
queryWrapper.apply("(DATE_FORMAT(IFNULL(start_date,pre_start_date), '%Y-%m-%d') = '" + nowDayStr + "' " +
" OR DATE_FORMAT(IFNULL(start_date,pre_start_date), '%Y-%m-%d') = '" + nextDayStr + "')");
queryWrapper.last("ORDER BY IFNULL(start_date,pre_start_date) ");
return list(queryWrapper);
}
......@@ -202,9 +218,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
}
SStore sStore = storeService.getById(request.getStoreId());
//验劵
SOrder sOrder = generatSOrder(request,user);
SOrder sOrder = generatSOrder(request, user);
//校验订单金额
checkOrderPrice(sOrder,user);
checkOrderPrice(sOrder, user);
//校验订单预约时间
checkOrderDate(request);
OrderPayResultResponse response = new OrderPayResultResponse();
......@@ -214,7 +230,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
response.setOrderNo(sOrder.getOrderNo());
sOrder.setPayStatus(YesNoEnum.yes.getIndex());
sOrder.setPayTime(DateUtils.getNowDate());
}else {
} else {
response = orderPayService.payment(sOrder);
// 加入自动未支付自动取消队列
redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, sOrder.getOrderNo());
......@@ -240,44 +256,44 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
//订单开始时间在 【预定开始时间 和 预定结束时间+30分保洁】区间内
//订单结束时间在 【预定开始时间-30分钟保洁 和 预定结束时间】区间内
queryWrapper.apply("IFNULL(start_date,pre_start_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.addMinutes(request.getPreEndDate(),Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreStartDate())
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.addMinutes(request.getPreStartDate(),-Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getPreEndDate()) + "' ");
switch (OrderTypeEnum.getEnumByCode(request.getOrderType())){
+ DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(request.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
+ "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, request.getPreEndDate()) + "' ");
switch (OrderTypeEnum.getEnumByCode(request.getOrderType())) {
case RESERVER://预定
break;
case RENEW://续费
if(StringUtils.isBlank(request.getPreOrderNo())){
if (StringUtils.isBlank(request.getPreOrderNo())) {
throw new BaseException("续房订单编号不能为空!");
}
//排除上笔订单
queryWrapper.ne(SOrder::getOrderNo,request.getPreOrderNo());
queryWrapper.ne(SOrder::getOrderNo, request.getPreOrderNo());
break;
default:
throw new BaseException("订单类型异常!");
}
List<SOrder> orderList = list(queryWrapper);
if(CollectionUtils.isNotEmpty(orderList)){
if (CollectionUtils.isNotEmpty(orderList)) {
throw new BaseException("下单时间已被预定!");
}
}
private void checkOrderPrice(SOrder order, SConsumer user){
private void checkOrderPrice(SOrder order, SConsumer user) {
OrderComputedPriceRequest request = new OrderComputedPriceRequest();
BeanUtils.copyProperties(order,request);
BeanUtils.copyProperties(order, request);
ComputedOrderPriceResponse priceResponse = computedPrice(request, user);
if(priceResponse.getPayFee().compareTo(order.getPayPrice())!=0){
if (priceResponse.getPayFee().compareTo(order.getPayPrice()) != 0) {
throw new BaseException("订单金额异常!");
}
}
private SOrder generatSOrder(CreateOrderRequest request, SConsumer user){
private SOrder generatSOrder(CreateOrderRequest request, SConsumer user) {
SOrder sOrder = new SOrder();
BeanUtils.copyProperties(request,sOrder);
BeanUtils.copyProperties(request, sOrder);
sOrder.setTotalPrice(request.getTotalFee());
sOrder.setCouponPrice(request.getCouponFee());
sOrder.setPayPrice(request.getPayFee());
......@@ -291,8 +307,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
sOrder.setRefundStatus(RefundStatusEnum.UNREFUND.getCode());
//计算订单时长
sOrder.setTimeLong(DateUtils.differentHour(sOrder.getPreStartDate(),sOrder.getPreEndDate()).toString());
if(Objects.nonNull(sOrder.getPackId())&& sOrder.getPackId() != 0){
sOrder.setTimeLong(DateUtils.differentHour(sOrder.getPreStartDate(), sOrder.getPreEndDate()).toString());
if (Objects.nonNull(sOrder.getPackId()) && sOrder.getPackId() != 0) {
// 套餐订单,设置套餐金额
SPack pack = packService.getById(request.getPackId());
sOrder.setPackPrice(pack.getPrice());
......@@ -303,6 +319,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
/**
* 计算订单价格
*
* @param request 计算订单价格请求对象
* @return ComputedOrderPriceResponse
*/
......@@ -331,7 +348,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
public boolean refundAudit(OrderRefundRequest request) {
SOrder sOrder = getInfoException(request.getOrderNo());
ApprovalStatusEnum approvalStatusEnum = ApprovalStatusEnum.getEnumByCode(request.getApprovalStatus());
switch (approvalStatusEnum){
switch (approvalStatusEnum) {
case AGREE:
if (!YesNoEnum.yes.getIndex().equals(sOrder.getPayStatus())) {
throw new BaseException("未支付无法退款");
......@@ -359,9 +376,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
break;
case REJECT:
//判断订单预约开始时间是否大于当前时间
if(sOrder.getPreStartDate().compareTo(new Date())>0){
if (sOrder.getPreStartDate().compareTo(new Date()) > 0) {
sOrder.setStatus(OrderStatusEnum.USED.getCode());
}else{
} else {
sOrder.setStatus(OrderStatusEnum.UNUSED.getCode());
}
sOrder.setRefundStatus(RefundStatusEnum.REJECT.getCode());
......@@ -411,8 +428,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Override
public List<SOrder> validOrder() {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getStatus,OrderStatusEnum.UNUSED.getCode());
queryWrapper.in(SOrder::getRefundStatus,RefundStatusEnum.getNotRefundStatus());
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.UNUSED.getCode());
queryWrapper.in(SOrder::getRefundStatus, RefundStatusEnum.getNotRefundStatus());
List<SOrder> result = list(queryWrapper);
return result;
}
......@@ -420,7 +437,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Override
public boolean cancel(String orderNo) {
SOrder order = getByOrderNo(orderNo);
if(Objects.isNull(order)){
if (Objects.isNull(order)) {
throw new BaseException("订单不存在!");
}
order.setStatus(OrderStatusEnum.CANCEL.getCode());
......@@ -440,7 +457,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
public SOrderVo queryOrderInfoByNo(String orderNo) {
SOrder en = getByOrderNo(orderNo);
SOrderVo vo = new SOrderVo();
BeanUtils.copyProperties(en,vo);
BeanUtils.copyProperties(en, vo);
SStore store = storeService.getById(vo.getStoreId());
SRoom room = roomService.getById(vo.getRoomId());
vo.setStoreName(store.getName());
......@@ -457,8 +474,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
public List<SOrderVo> availableOrder() {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getConsumerId,user.getId());
queryWrapper.in(SOrder::getStatus,new ArrayList<Integer>(){{
queryWrapper.eq(SOrder::getConsumerId, user.getId());
queryWrapper.in(SOrder::getStatus, new ArrayList<Integer>() {{
add(OrderStatusEnum.UNUSED.getCode());
add(OrderStatusEnum.INUSE.getCode());
}});
......@@ -502,14 +519,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
orderList.stream().forEach(o -> {
SOrderVo vo = new SOrderVo();
BeanUtils.copyProperties(o, vo);
storeList.stream().forEach( store -> {
if(store.getId().equals(vo.getStoreId())){
storeList.stream().forEach(store -> {
if (store.getId().equals(vo.getStoreId())) {
vo.setStoreName(store.getName());
vo.setAddress(store.getAddress());
}
});
roomList.stream().forEach( room -> {
if(room.getId().equals(vo.getRoomId())){
roomList.stream().forEach(room -> {
if (room.getId().equals(vo.getRoomId())) {
vo.setRoomName(room.getName());
}
});
......@@ -557,27 +574,28 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
/**
* 查询非当前用户,预约时间或使用时间为当前时间的订单,如果存在,房间不可开门
*
* @return
*/
private boolean checkOrderOpenDoor(){
private boolean checkOrderOpenDoor() {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ne(SOrder::getConsumerId,user.getId());
queryWrapper.notIn(SOrder::getStatus,new ArrayList<Integer>(){{
queryWrapper.ne(SOrder::getConsumerId, user.getId());
queryWrapper.notIn(SOrder::getStatus, new ArrayList<Integer>() {{
add(OrderStatusEnum.USED.getCode());
add(OrderStatusEnum.CANCEL.getCode());
}});
queryWrapper.notIn(SOrder::getRefundStatus,new ArrayList<Integer>(){{
queryWrapper.notIn(SOrder::getRefundStatus, new ArrayList<Integer>() {{
add(RefundStatusEnum.INREFUND.getCode());
add(RefundStatusEnum.REFUNDED.getCode());
}});
queryWrapper.apply("IFNULL(start_date,pre_start_date) >= '"+DateUtils.getTime()+"' " +
queryWrapper.apply("IFNULL(start_date,pre_start_date) >= '" + DateUtils.getTime() + "' " +
" AND IFNULL(start_date,pre_start_date) <= '" + DateUtils.getTime() + "'");
return count(queryWrapper)==0;
return count(queryWrapper) == 0;
}
private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime){
return DateUtils.differentHour(startTime,endTime).multiply(unitPrice);
private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime) {
return DateUtils.differentHour(startTime, endTime).multiply(unitPrice);
}
private ComputedOrderPriceResponse computedPrice(OrderComputedPriceRequest request, SConsumer user) {
......@@ -586,7 +604,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
SRoom room = roomService.getById(request.getRoomId());
BigDecimal totalPrice;
BuyTypeEnum buyTypeEnum = BuyTypeEnum.getEnumByCode(request.getBuyType());
switch (buyTypeEnum){
switch (buyTypeEnum) {
case TIME://小时模式
totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate());
break;
......@@ -604,14 +622,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
} else {
// 判断优惠券是否可以使用
SConsumerCoupon consumerCoupon = consumerCouponService.getById(request.getCouponId());
computedCouponPrice(priceResponse,user,consumerCoupon);
computedCouponPrice(priceResponse, user, consumerCoupon);
}
return priceResponse;
}
private BigDecimal computeTotalPrice(Long packId) {
SPack pack = packService.getById(packId);
if(Objects.isNull(pack)){
if (Objects.isNull(pack)) {
throw new BaseException("计算订单金额套餐ID异常!");
}
return pack.getPrice();
......@@ -620,7 +638,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
/**
* 计算使用优惠券后的订单金额
*/
private void computedCouponPrice(ComputedOrderPriceResponse priceResponse, SConsumer user, SConsumerCoupon consumerCoupon){
private void computedCouponPrice(ComputedOrderPriceResponse priceResponse, SConsumer user, SConsumerCoupon consumerCoupon) {
if (ObjectUtil.isNull(consumerCoupon) || !consumerCoupon.getConsumerId().equals(user.getId())) {
throw new BaseException("优惠券领取记录不存在!");
}
......@@ -636,7 +654,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
throw new BaseException("此优惠券已经失效了");
}
CouponTypeEnum couponType = CouponTypeEnum.getTypeCode(consumerCoupon.getCouponType());
switch (couponType){
switch (couponType) {
case DISCOUNT://TODO 折扣券
break;
case PACKAGE://套餐券
......
......@@ -3,6 +3,7 @@ package share.system.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.customerauth.session.entity.CustomerKeyShopScopeResponseEntity;
import lombok.var;
......@@ -23,10 +24,7 @@ import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SRoomVo;
import share.system.domain.vo.SStoreVo;
import share.system.mapper.RoomPackMapper;
import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreConsumerMapper;
import share.system.mapper.SStoreMapper;
import share.system.mapper.*;
import share.system.request.SStoreRequest;
import share.system.service.IPackService;
import share.system.service.ISRoomService;
......@@ -53,6 +51,8 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
private IPackService packService;
@Autowired
private QPService qpService;
@Autowired
private SCleanRecordsMapper sCleanRecordsMapper;
/**
* 查询门店
......@@ -281,7 +281,17 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
});
storeList.forEach(item -> {
item.setRoolList(sRoomService.selectSroomListByStroeId(item.getId()));
item.getRoolList().forEach(room -> {
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SCleanRecords::getRoomId, room.getId());
queryWrapper.eq(SCleanRecords::getStoreId, item.getId());
queryWrapper.ne(SCleanRecords::getStatus, 2);
SCleanRecords sCleanRecords = sCleanRecordsMapper.selectOne(queryWrapper);
room.setRecordsStatus(sCleanRecords.getStatus());
});
});
return storeList;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment