Merge remote-tracking branch 'origin/test' into dev

This commit is contained in:
Tankaikai
2024-12-17 10:04:44 +08:00
19 changed files with 461 additions and 87 deletions

View File

@@ -1,46 +1,45 @@
package cn.ysk.cashier.config.security.rest;
import cn.hutool.core.comparator.CompareUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.annotation.rest.AnonymousDeleteMapping;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.config.RsaProperties;
import cn.ysk.cashier.config.security.config.bean.LoginCodeEnum;
import cn.ysk.cashier.config.security.config.bean.LoginProperties;
import cn.ysk.cashier.config.security.config.bean.SecurityProperties;
import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.config.security.service.OnlineUserService;
import cn.ysk.cashier.config.security.service.dto.AuthUserDto;
import cn.ysk.cashier.config.security.service.dto.JwtUserDto;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper;
import cn.ysk.cashier.mybatis.mapper.TbMerchantAccountMapper;
import cn.ysk.cashier.mybatis.service.MpShopUserService;
import cn.ysk.cashier.pojo.TbToken;
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.repository.TbTokenRepository;
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.utils.RedisUtils;
import cn.ysk.cashier.utils.RsaUtils;
import cn.ysk.cashier.utils.SecurityUtils;
import cn.ysk.cashier.utils.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wf.captcha.base.Captcha;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousDeleteMapping;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.config.RsaProperties;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.config.security.config.bean.LoginProperties;
import cn.ysk.cashier.config.security.config.bean.SecurityProperties;
import cn.ysk.cashier.config.security.service.dto.AuthUserDto;
import cn.ysk.cashier.config.security.service.dto.JwtUserDto;
import cn.ysk.cashier.config.security.service.OnlineUserService;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication;
@@ -50,10 +49,9 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
@@ -99,8 +97,8 @@ public class AuthorizationController {
if (authUser.isChecked() && StringUtils.isBlank(authUser.getCode()) || authUser.isChecked() && !authUser.getCode().equalsIgnoreCase(code)) {
throw new BadRequestException("验证码错误");
}
String loginpre="";
String shopId="";
String loginpre = "";
String shopId = "";
// 判断是否是员工登录
if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) {
if (StrUtil.isBlank(authUser.getMerchantName())) {
@@ -117,7 +115,7 @@ public class AuthorizationController {
//生成token
UsernamePasswordAuthenticationToken authenticationToken =
new UsernamePasswordAuthenticationToken(loginpre+authUser.getUsername(), password);
new UsernamePasswordAuthenticationToken(loginpre + authUser.getUsername(), password);
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
// 生成令牌与第三方系统获取令牌方式
@@ -128,7 +126,7 @@ public class AuthorizationController {
// TbShopInfo byAccount = tbShopInfoRepository.findByAccount(jwtUserDto.getUsername());
TbPlussShopStaff tbPlussShopStaff;
if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) {
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername(),shopId);
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername(), shopId);
} else {
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername());
}
@@ -151,8 +149,8 @@ public class AuthorizationController {
put("user", jwtUserDto);
if (byAccount != null) {
put("shopId", byAccount.getId());
put("mainId", org.apache.commons.lang3.StringUtils.isNotBlank(byAccount.getMainId())?byAccount.getMainId():byAccount.getId());
put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType())?authUser.getLoginType():"merchant");
put("mainId", org.apache.commons.lang3.StringUtils.isNotBlank(byAccount.getMainId()) ? byAccount.getMainId() : byAccount.getId());
put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType()) ? authUser.getLoginType() : "merchant");
put("shopName", byAccount.getShopName());
put("logo", byAccount.getLogo());
}
@@ -165,6 +163,19 @@ public class AuthorizationController {
//踢掉之前已经登录的token
onlineUserService.checkLoginOnUser(authUser.getUsername(), token);
}
// 店铺使用有效期是否过期
authInfo.put("expireDate", null);
if (tbPlussShopStaff != null) {
TbShopInfo shopInfo = shopInfoMapper.selectById(tbPlussShopStaff.getShopId());
if (shopInfo != null && shopInfo.getExpireAt() != null) {
Long expireAt = shopInfo.getExpireAt();
Date time = DateUtil.calendar(expireAt).getTime();
authInfo.put("expireDate", DateUtil.formatDateTime(time));
if (CompareUtil.compare(time, new Date()) < 0) {
throw new BadRequestException("店铺已到期,请联系区域经理续费");
}
}
}
return ResponseEntity.ok(authInfo);
}
@@ -188,7 +199,7 @@ public class AuthorizationController {
// Integer staffId = shopStaff.getId();
// List<TbToken> onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId);
shopStaff.setPassword(null);
return ResponseEntity.ok(new HashMap<String, Object>(){{
return ResponseEntity.ok(new HashMap<String, Object>() {{
put("shopInfo", shopInfo);
put("shopStaff", shopStaff);
}});
@@ -231,6 +242,19 @@ public class AuthorizationController {
//踢掉之前已经登录的token
onlineUserService.checkLoginOnUser(authUser.getUsername(), token);
}
// 店铺使用有效期是否过期
authInfo.put("expireDate", null);
if (byAccount != null) {
TbShopInfo shopInfo = shopInfoMapper.selectById(byAccount.getId());
if (shopInfo != null && shopInfo.getExpireAt() != null) {
Long expireAt = shopInfo.getExpireAt();
Date time = DateUtil.calendar(expireAt).getTime();
authInfo.put("expireDate", DateUtil.formatDateTime(time));
if (DateUtil.compare(time, new Date()) > 0) {
throw new BadRequestException("店铺已到期,请联系区域经理续费");
}
}
}
return ResponseEntity.ok(authInfo);
}

View File

@@ -1,6 +1,7 @@
package cn.ysk.cashier.controller;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.dto.TbVersionQueryCriteria;
import cn.ysk.cashier.pojo.TbVersion;
import cn.ysk.cashier.service.TbVersionService;
@@ -27,6 +28,12 @@ public class TbVersionController {
return new ResponseEntity<>(tbVersionService.queryAllPage(criteria),HttpStatus.OK);
}
@AnonymousGetMapping("findBySource")
@ApiOperation("查询所属渠道升级版本")
public ResponseEntity<Object> findBySource(String source){
return new ResponseEntity<>(tbVersionService.findBySource(source),HttpStatus.OK);
}
@PostMapping
@Log("版本管理 新增")
@ApiOperation("新增版本")

View File

@@ -50,6 +50,7 @@ public class TbShopTableBookingController {
@ApiOperation("预订")
public ResponseEntity booking(@RequestBody TbShopTableBooking dto) {
String orderNo = tbShopTableBookingService.booking(dto);
tbShopTableBookingService.markSubscribe(dto.getShopTableId());
Map<String, Object> data = new HashMap<>(2);
data.put("id", dto.getId());
data.put("orderNo", orderNo);
@@ -60,6 +61,7 @@ public class TbShopTableBookingController {
@ApiOperation("修改预订信息")
public ResponseEntity update(@RequestBody TbShopTableBooking dto) {
boolean ret = tbShopTableBookingService.update(dto);
tbShopTableBookingService.markSubscribe(dto.getShopTableId());
return ResponseEntity.ok().body(ret);
}
@@ -67,6 +69,10 @@ public class TbShopTableBookingController {
@ApiOperation("修改预订状态")
public ResponseEntity markStatus(@RequestBody TbShopTableBooking dto) {
tbShopTableBookingService.markStatus(dto.getId(), dto.getStatus());
if(dto.getStatus() == -1){
TbShopTableBooking entity = tbShopTableBookingService.getById(dto.getId());
tbShopTableBookingService.cancelSubscribe(entity.getShopTableId());
}
return ResponseEntity.ok().build();
}

View File

@@ -160,7 +160,7 @@ public class TbPlaceController {
@ApiOperation("代客下单 查询购物车 /shop/table")
public ResponseEntity<Object> createOrder(HttpServletRequest request, @RequestBody CreateOrderDTO createOrderDTO) {
Utils.checkLimit(tokenProvider.getToken(request), 1, 400);
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, false));
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, false, true));
}
@PostMapping("/pending")
@@ -239,6 +239,11 @@ public class TbPlaceController {
return ResponseEntity.ok(tbShopTableService.choseCount(choseCountDTO));
}
@PutMapping("/switch")
public ResponseEntity<?> switchTable(@Validated @RequestBody SwitchTableDTO switchTableDTO) {
return ResponseEntity.ok(tbShopTableService.switchTable(switchTableDTO));
}
@PutMapping("/updateVip")
@ApiOperation("代客下单 查询购物车 /shop/table")
public ResponseEntity<Object> updateVip(@Validated @RequestBody UpdateVipDTO updateVipDTO) {

View File

@@ -53,6 +53,15 @@ public class TbShopTableQueryCriteria{
private Integer page = 1;
private Integer size = 99999;
/**
* 预约日期 yyyy-MM-dd
*/
private String bookingDate;
/**
* 预约类型 lunch-午餐 dinner-晚餐
*/
private String bookingType;
public Integer getIsPredate() {
return isPredate;
}
@@ -60,4 +69,5 @@ public class TbShopTableQueryCriteria{
public void setIsPredate(Integer isPredate) {
this.isPredate = isPredate;
}
}

View File

@@ -0,0 +1,25 @@
package cn.ysk.cashier.dto.shoptable;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class SwitchTableDTO {
@NotNull
private Integer shopId;
@NotEmpty(message = "取餐码不为空")
private String masterId;
@NotBlank
private String useType;
private Integer orderId;
private List<Integer> cartIds;
private boolean isFull;
@NotEmpty(message = "当前台桌id不为空")
private String currentTableId;
@NotEmpty(message = "目标台桌id不为空")
private String targetTableId;
}

View File

@@ -2,6 +2,7 @@ package cn.ysk.cashier.enums;
public enum TableStateEnum {
IDLE("idle"),
SUBSCRIBE("subscribe"),
CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using"), CLEANING("cleaning");
private String state = "closed";

View File

@@ -69,7 +69,16 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
List<TbCashierCart> selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TableConstant.OrderInfo.Status... statuses);
List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses);
/**
* 根据就餐模式查询购物车信息
* @param shopEatTypeInfoDTO 就餐模式
* @param masterId 取餐码
* @param orderId 订单id
* @param onlySearchPc 只查询pc
* @param statuses 状态
*/
List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses);
Long countByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses);
/**
* 根据订单id和状态获取购物车数据

View File

@@ -82,5 +82,17 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
boolean updateMemberByOrderId(Integer orderId, boolean isMember);
boolean updateFieldByCartId(SFunction<TbOrderDetail, ?> field, Object val, List<Integer> cartIds);
/**
* 根据购物车更改订单台桌信息
* @param shopId 店铺id
* @param targetTableId 新的台桌id
* @param masterId 取餐码
* @param cartIds 购物车id
* @return
*/
boolean updateTableInfoByCartIds(Integer shopId, String targetTableId, String masterId, List<Integer> cartIds);
boolean removeByCartIds(ArrayList<Integer> cartIds);
}

View File

@@ -38,6 +38,9 @@ public interface TbShopTableBookingService extends IService<TbShopTableBooking>
Map<String, Object> summary(Integer shopId,String[] phoneNos);
void markSubscribe(Integer shopTableId);
void cancelSubscribe(Integer shopTableId);
void batchTimeout();
void autoCancel();

View File

@@ -23,8 +23,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* (TbShopPermission)表服务实现类
@@ -55,8 +57,7 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
@Override
public List<TbCashierCart> selectUnTableCart(String masterId, Integer shopId) {
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
.eq(TbShopInfo::getId, shopId)
.eq(TbShopInfo::getStatus, 1));
.eq(TbShopInfo::getId, shopId));
if (shopInfo == null) {
throw new BadRequestException("店铺信息不存在");
}
@@ -120,7 +121,9 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
if (statuses.length == 0) {
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
} else {
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
.map(TableConstant.OrderInfo.Status::getValue)
.collect(Collectors.toList()));
}
// 非堂食校验台桌状态
@@ -139,7 +142,8 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
}
@Override
public List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, TableConstant.OrderInfo.Status... statuses) {
public List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId,
Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
@@ -149,7 +153,9 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
if (statuses.length == 0) {
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
} else {
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
.map(TableConstant.OrderInfo.Status::getValue)
.collect(Collectors.toList()));
}
if (orderId != null) {
@@ -157,6 +163,10 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
.or().isNull(TbCashierCart::getOrderId));
}
if (onlySearchPc) {
queryWrapper.ne(TbCashierCart::getPlatformType, "mimiapp");
}
// 非堂食校验台桌状态
if (shopEatTypeInfoDTO.isTakeout()) {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
@@ -172,6 +182,47 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
return list(queryWrapper);
}
@Override
public Long countByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId,
Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
if (statuses.length == 0) {
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
} else {
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
.map(TableConstant.OrderInfo.Status::getValue)
.collect(Collectors.toList()));
}
if (orderId != null) {
queryWrapper.and(q -> q.eq(TbCashierCart::getOrderId, orderId)
.or().isNull(TbCashierCart::getOrderId));
}
if (onlySearchPc) {
queryWrapper.ne(TbCashierCart::getPlatformType, "mimiapp");
}
// 非堂食校验台桌状态
if (shopEatTypeInfoDTO.isTakeout()) {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
} else {
if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) {
queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId());
} else {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
}
}
return count(queryWrapper);
}
@Override
public List<TbCashierCart> selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status) {
LambdaQueryChainWrapper<TbCashierCart> queryChainWrapper = lambdaQuery().eq(TbCashierCart::getOrderId, orderId);
@@ -215,7 +266,9 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getId, cartId);
if (statuses.length != 0) {
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
.map(TableConstant.OrderInfo.Status::getValue)
.collect(Collectors.toList()));
}
return getOne(queryWrapper);
}
@@ -224,10 +277,15 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
public List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getOrderId, orderId)
.in(TbCashierCart::getId, ids);
if (orderId != null) {
queryWrapper.eq(TbCashierCart::getOrderId, orderId);
}
if (statuses.length != 0) {
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
.map(TableConstant.OrderInfo.Status::getValue)
.collect(Collectors.toList()));
}
return list(queryWrapper);
}

View File

@@ -97,5 +97,16 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, T
}
return update(query);
}
@Override
public boolean updateTableInfoByCartIds(Integer shopId, String targetTableId, String masterId, List<Integer> cartIds) {
return false;
}
@Override
public boolean removeByCartIds(ArrayList<Integer> cartIds) {
return remove(new LambdaQueryWrapper<TbOrderDetail>()
.in(TbOrderDetail::getCartId, cartIds));
}
}

View File

@@ -250,7 +250,7 @@ public class TbPointsExchangeRecordServiceImpl extends ServiceImpl<TbPointsExcha
.set(TbPointsExchangeRecord::getCancelOrRefundTime, new Date())
.set(TbPointsExchangeRecord::getCancelOrRefundReason, "超时未支付,系统自动取消订单")
.eq(TbPointsExchangeRecord::getStatus, "unpaid")
.last("and TIMESTAMPDIFF(MINUTE, NOW(), create_time) >= 5"));
.last("and TIMESTAMPDIFF(MINUTE, create_time, NOW()) >= 5"));
}
}

View File

@@ -280,13 +280,60 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl<TbShopTableBookin
return result;
}
@Override
public void markSubscribe(Integer shopTableId) {
String today = DateUtil.today();
LambdaQueryWrapper<TbShopTableBooking> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TbShopTableBooking::getBookingDate, today);
wrapper.eq(shopTableId != null, TbShopTableBooking::getShopTableId, shopTableId);
wrapper.ne(TbShopTableBooking::getStatus, -1);
wrapper.eq(TbShopTableBooking::getDelFlag, 0);
List<TbShopTableBooking> list = super.list(wrapper);
if (CollUtil.isEmpty(list)) {
return;
}
Map<Integer, List<TbShopTableBooking>> groupMap = list.stream().collect(Collectors.groupingBy(TbShopTableBooking::getShopTableId));
groupMap.forEach((k, v) -> {
mpShopTableMapper.update(Wrappers.<TbShopTable>lambdaUpdate()
.set(TbShopTable::getStatus, "subscribe")
.eq(TbShopTable::getStatus, "idle")
.eq(TbShopTable::getId, k));
});
}
@Override
public void cancelSubscribe(Integer shopTableId) {
String today = DateUtil.today();
LambdaQueryWrapper<TbShopTableBooking> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TbShopTableBooking::getBookingDate, today);
wrapper.eq(shopTableId != null, TbShopTableBooking::getShopTableId, shopTableId);
//wrapper.ne(TbShopTableBooking::getStatus, -1);
wrapper.eq(TbShopTableBooking::getDelFlag, 0);
List<TbShopTableBooking> list = super.list(wrapper);
if (CollUtil.isEmpty(list)) {
return;
}
Map<Integer, List<TbShopTableBooking>> groupMap = list.stream().collect(Collectors.groupingBy(TbShopTableBooking::getShopTableId));
groupMap.forEach((k, v) -> {
long count = v.stream().filter(item -> item.getStatus() == -1).count();
// 全部都取消了,则标记为空闲
if (v.size() == count) {
mpShopTableMapper.update(Wrappers.<TbShopTable>lambdaUpdate()
.set(TbShopTable::getStatus, "idle")
.eq(TbShopTable::getStatus, "subscribe")
.eq(TbShopTable::getId, k)
);
}
});
}
@Override
public void batchTimeout() {
baseMapper.update(Wrappers.<TbShopTableBooking>lambdaUpdate()
.set(TbShopTableBooking::getStatus, 999)
.set(TbShopTableBooking::getUpdateTime, new Date())
.eq(TbShopTableBooking::getStatus, 20)
.last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute"));
.last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute"));
}
@Override
@@ -296,7 +343,6 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl<TbShopTableBookin
.set(TbShopTableBooking::getStatus, -1)
.set(TbShopTableBooking::getUpdateTime, new Date())
.eq(TbShopTableBooking::getStatus, 999)
.last("and TIMESTAMPDIFF(MINUTE, NOW(), booking_time) >= timeout_minute+15"));
.last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute+15"));
}
}

View File

@@ -106,6 +106,9 @@ public class TestTask {
public void cancelPointsExchangeOrder(){
log.info("积分商品订单取消定时任务执行");
tbPointsExchangeRecordService.authCancel();
log.info("当日预订台桌打标记-预订状态");
tbShopTableBookingService.markSubscribe(null);
tbShopTableBookingService.cancelSubscribe(null);
log.info("预定订单超时定时任务执行");
tbShopTableBookingService.batchTimeout();
log.info("预定订单取消定时任务执行");

View File

@@ -32,6 +32,8 @@ public interface TbVersionService {
*/
List<TbVersionDto> queryAll(TbVersionQueryCriteria criteria);
TbVersion findBySource(String source);
/**
* 根据ID查询
* @param id ID

View File

@@ -8,17 +8,21 @@ import cn.ysk.cashier.pojo.TbVersion;
import cn.ysk.cashier.repository.TbVersionRepository;
import cn.ysk.cashier.service.TbVersionService;
import cn.ysk.cashier.utils.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.Predicate;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @author ww
@@ -47,6 +51,22 @@ public class TbVersionServiceImpl implements TbVersionService {
return tbVersionMapper.toDto(tbVersionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
public TbVersion findBySource(String source) {
Specification<TbVersion> spec = (root, criteriaQuery, criteriaBuilder) -> {
Predicate param1 = criteriaBuilder.equal(root.get("source"), source);
Predicate param2 = criteriaBuilder.equal(root.get("sel"), 1);
// 使用or方法将两个条件组合起来表示满足其中一个条件即可
return criteriaBuilder.and(param1, param2);
};
Optional<TbVersion> one = tbVersionRepository.findOne(spec);
if(one.isPresent()){
return one.get();
}else {
return null;
}
}
@Override
@Transactional
public TbVersionDto findById(Integer id) {
@@ -58,17 +78,12 @@ public class TbVersionServiceImpl implements TbVersionService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbVersionDto create(TbVersion resources) {
int exist = tbVersionRepository.isExist(resources.getSource(), resources.getVersion());
int exist = tbVersionRepository.isExist(resources.getSource(), resources.getVersion());
if (exist > 0) {
throw new BadRequestException("该版本已存在。");
}
resources.setCreatedAt(Instant.now().toEpochMilli());
TbVersionDto dto = tbVersionMapper.toDto(tbVersionRepository.save(resources));
// if (dto.getIsUp() == 1) {
// //产品标识:型号:版本
// //VERSION:PC::version 存在即需要强制更新
// redisUtils.set(CacheKey.VERSION + dto.getSource() + ":" + dto.getVersion(), dto);
// }
return dto;
}
@@ -77,23 +92,15 @@ public class TbVersionServiceImpl implements TbVersionService {
public void update(TbVersion resources) {
TbVersion tbVersion = tbVersionRepository.findById(resources.getId()).orElseGet(TbVersion::new);
ValidationUtil.isNull(tbVersion.getId(), "TbVersion", "id", resources.getId());
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
tbVersion.copy(resources);
tbVersion.setUpdatedAt(Instant.now().toEpochMilli());
tbVersionRepository.save(tbVersion);
// if (resources.getIsUp() == 1) {
// //产品标识:型号:版本
// //LDBL_APP_VERSION:ios:version 存在即需要强制更新
// redisUtils.set(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion(), tbVersion.getMessage());
// } else {
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
// }
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateSel(TbVersion resources) {
tbVersionRepository.updateSelBySource(resources.getSource(),resources.getId());
tbVersionRepository.updateSelBySource(resources.getSource(), resources.getId());
}
@Override
@@ -102,9 +109,6 @@ public class TbVersionServiceImpl implements TbVersionService {
TbVersion tbVersion = tbVersionRepository.findById(id).orElseGet(TbVersion::new);
ValidationUtil.isNull(tbVersion.getId(), "TbVersion", "id", id);
tbVersionRepository.deleteById(id);
// if (tbVersion.getIsUp() == 1) {
// redisUtils.del(tbVersion.getSource() + "_VERSION:" + tbVersion.getType() + ":" + tbVersion.getVersion());
// }
}
}

View File

@@ -29,6 +29,7 @@ import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
import cn.ysk.cashier.mybatis.entity.TbShopTableBooking;
import cn.ysk.cashier.mybatis.entity.TbThirdPartyCouponRecord;
import cn.ysk.cashier.mybatis.mapper.*;
import cn.ysk.cashier.mybatis.service.*;
@@ -55,6 +56,7 @@ import cn.ysk.cashier.vo.*;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dianguang.cloud.ossservice.model.DateUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -111,6 +113,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
private final MpProductStockDetailMapper mpProductStockDetailMapper;
private final TbMemberPointsService memberPointsService;
private final TbShopCouponService shopCouponService;
private final TbShopTableBookingService tbShopTableBookingService;
/**
@@ -190,8 +193,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
*/
private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel, String tableId) {
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
.eq(TbShopInfo::getId, shopId)
.eq(TbShopInfo::getStatus, 1));
.eq(TbShopInfo::getId, shopId));
if (shopInfo == null) {
throw new BadRequestException("店铺信息不存在");
}
@@ -297,30 +299,33 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.orderByDesc(TbOrderInfo::getId)).getRecords();
orderInfoList.forEach(item -> currentOrderInfoMap.computeIfAbsent(item.getTableId(), k -> item));
for (TbShopTable date : tbShopTableList) {
if (StrUtil.isBlank(date.getQrcode())) {
date.setStatus("unbind");
} else if ((countMap.get(date.getQrcode()) == null || countMap.get(date.getQrcode()) < 1) && !TableStateEnum.CLEANING.getState().equals(date.getStatus())) {
date.setStatus("idle");
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, date.getQrcode())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
for (TbShopTable data : tbShopTableList) {
if (StrUtil.isBlank(data.getQrcode())) {
data.setStatus("unbind");
} else if ((countMap.get(data.getQrcode()) == null || countMap.get(data.getQrcode()) < 1) && !TableStateEnum.CLEANING.getState().equals(data.getStatus())) {
if (TableStateEnum.USING.getState().equals(data.getStatus())) {
data.setStatus("idle");
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, data.getQrcode())
.eq(TbShopTable::getStatus, TableStateEnum.USING.getState())
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
}
}
Map<String, Object> itemMap = BeanUtil.beanToMap(date, false, false);
if ((date.getStatus().equals("using") || date.getStatus().equals("cleaning")) && date.getUseTime() != null) {
itemMap.put("durationTime", DateUtil.current() - date.getUseTime().getTime());
Map<String, Object> itemMap = BeanUtil.beanToMap(data, false, false);
if ((data.getStatus().equals("using") || data.getStatus().equals("cleaning")) && data.getUseTime() != null) {
itemMap.put("durationTime", DateUtil.current() - data.getUseTime().getTime());
} else {
itemMap.put("durationTime", 0);
}
if (!"".equals(date.getQrcode())) {
itemMap.put("qrcode", QRCODE + date.getQrcode().trim());
itemMap.put("tableId", date.getQrcode());
if (!"".equals(data.getQrcode())) {
itemMap.put("qrcode", QRCODE + data.getQrcode().trim());
itemMap.put("tableId", data.getQrcode());
}
TbOrderInfo orderInfo = null;
if (StrUtil.isNotBlank(date.getQrcode())) {
if (StrUtil.isNotBlank(data.getQrcode())) {
try {
orderInfo = currentOrderInfoMap.get(date.getQrcode());
orderInfo = currentOrderInfoMap.get(data.getQrcode());
} catch (Exception e) {
log.info(e.getMessage());
}
@@ -329,6 +334,20 @@ public class TbShopTableServiceImpl implements TbShopTableService {
itemMap.put("orderId", orderInfo == null ? null : orderInfo.getId());
itemMap.put("useType", orderInfo == null ? null : orderInfo.getUseType());
itemMap.put("masterId", orderInfo == null ? null : orderInfo.getMasterId());
String bookingDate = StrUtil.blankToDefault(criteria.getBookingDate(), DateUtil.today());
String bookingType = StrUtil.blankToDefault(criteria.getBookingType(), "lunch");
LambdaQueryWrapper<TbShopTableBooking> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TbShopTableBooking::getBookingDate, bookingDate);
wrapper.eq(TbShopTableBooking::getBookingType, bookingType);
wrapper.eq(TbShopTableBooking::getShopTableId, data.getId());
wrapper.ne(TbShopTableBooking::getStatus, -1);
wrapper.eq(TbShopTableBooking::getDelFlag, 0);
List<TbShopTableBooking> list = tbShopTableBookingService.list(wrapper);
TbShopTableBooking bookingInfo = null;
if (CollUtil.isNotEmpty(list)) {
bookingInfo = list.get(0);
}
itemMap.put("bookingInfo", bookingInfo);
infoList.add(itemMap);
}
HashMap<String, Object> map = new HashMap<>();
@@ -1268,7 +1287,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
@Transactional
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean byOrderId) {
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean byOrderId, boolean isPrint) {
createOrderDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(createOrderDTO.getUseType()) ? null : createOrderDTO.getTableId());
return Utils.runFunAndCheckKey(() -> {
TbShopUser shopUser = null;
@@ -1309,7 +1328,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
orderInfo, cartInfoDTO.getSeatCart(), shopUser, shopTable, createOrderDTO.getIsWaitCall());
// 修改订单详情并打票
updateDetailAndPrint(orderInfo, detailPriceDTO, shopEatTypeInfoDTO);
updateDetailAndPrint(orderInfo, detailPriceDTO, shopEatTypeInfoDTO, isPrint);
// 修改购物车状态和库存
updateCartAndStock(cartInfoDTO.getNewCashierCarts(), orderInfo, shopEatTypeInfoDTO);
@@ -1781,7 +1800,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
return orderInfo;
}
private void updateDetailAndPrint(TbOrderInfo orderInfo, OrderPriceDTO priceDTO, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {
private void updateDetailAndPrint(TbOrderInfo orderInfo, OrderPriceDTO priceDTO, ShopEatTypeInfoDTO shopEatTypeInfoDTO, boolean isPrint) {
// 添加订单详细数据
Integer orderId = orderInfo.getId();
for (TbOrderDetail orderDetail : priceDTO.getOrderDetailList()) {
@@ -1796,14 +1815,14 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
// 菜品票
if (!priceDTO.getNewOrderDetailList().isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) {
if (!priceDTO.getNewOrderDetailList().isEmpty() && shopEatTypeInfoDTO.isDineInAfter() && isPrint) {
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), false, priceDTO.getNewOrderDetailList().toArray(new TbOrderDetail[0]));
}
if (!priceDTO.getRemoveOrderDetailIds().isEmpty()) {
// 退单票
orderDetailMapper.deleteBatchIds(priceDTO.getRemoveOrderDetailIds());
if (shopEatTypeInfoDTO.isDineInAfter()) {
if (shopEatTypeInfoDTO.isDineInAfter() && isPrint) {
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), true, priceDTO.getRemoveOrderDetailList().toArray(new TbOrderDetail[0]));
}
}
@@ -2002,7 +2021,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
createOrderDTO.setMasterId(pendingDTO.getMasterId());
createOrderDTO.setNote(pendingDTO.getNote());
createOrderDTO.setUseType(pendingDTO.getUseType());
orderId = createOrder(createOrderDTO, false).getId();
orderId = createOrder(createOrderDTO, false, true).getId();
}
@@ -2578,7 +2597,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
if (dto != null) {
dto.setVipUserId(updateVipDTO.getType() == 0 ? updateVipDTO.getVipUserId() : null);
return createOrder(dto, true);
return createOrder(dto, true, true);
}
return "哈哈哈";
@@ -2698,6 +2717,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setNumber(BigDecimal.valueOf(choseCountDTO.getNum()));
tbCashierCart.setTotalNumber(BigDecimal.valueOf(choseCountDTO.getNum()));
tbCashierCart.setUseType(choseCountDTO.getUseType());
tbCashierCart.setPlatformType("pc");
tbCashierCartMapper.insert(tbCashierCart);
} else {
tbCashierCart.setMemberPrice(shopInfo.getTableFee());
@@ -3326,7 +3346,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
public Object waitCall(WaitCallDTO waitCallDTO) {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(waitCallDTO.getShopId(), waitCallDTO.getTableId(), waitCallDTO.getUseType());
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO,
waitCallDTO.getMasterId(), waitCallDTO.getOrderId(), TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN, TableConstant.OrderInfo.Status.CLOSED);
waitCallDTO.getMasterId(), waitCallDTO.getOrderId(), false, TableConstant.OrderInfo.Status.CREATE,
TableConstant.OrderInfo.Status.RETURN, TableConstant.OrderInfo.Status.CLOSED);
if (cashierCarts.isEmpty()) {
throw new BadRequestException("购物车为空");
}
@@ -3344,4 +3365,125 @@ public class TbShopTableServiceImpl implements TbShopTableService {
mpCashierCartService.updateFieldValByIds(waitCallDTO.getShopId(), cartIds, TbCashierCart::getIsWaitCall, waitCallDTO.getIsWaitCall());
return mpOrderDetailService.updateFieldByCartId(TbOrderDetail::getIsWaitCall, waitCallDTO.getIsWaitCall(), cartIds);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Object switchTable(SwitchTableDTO switchTableDTO) {
// 查询当前台桌信息
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(switchTableDTO.getShopId(), switchTableDTO.getCurrentTableId(), switchTableDTO.getUseType());
ShopEatTypeInfoDTO targetShopEatTypeInfoDTO = checkEatModel(switchTableDTO.getShopId(), switchTableDTO.getTargetTableId(), switchTableDTO.getUseType());
if (!shopEatTypeInfoDTO.isDineInAfter()) {
throw new BadRequestException("仅后付费模式支持转台");
}
TbShopTable shopTable = mpShopTableService.selectByTableId(switchTableDTO.getTargetTableId(), switchTableDTO.getShopId());
if (shopTable == null) {
throw new BadRequestException("目标台桌信息不存在");
}
if (TableConstant.ShopTable.State.CLEANING.getValue().equals(shopTable.getStatus())) {
throw new BadRequestException("当前台桌清理中,不能转台");
}
List<TbCashierCart> cashierCarts;
long totalSize = 99999;
if (switchTableDTO.isFull()) {
cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO, switchTableDTO.getMasterId(), switchTableDTO.getOrderId(),
true, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
} else {
if (switchTableDTO.getCartIds().isEmpty()) {
throw new BadRequestException("请选择转单商品");
}
totalSize = mpCashierCartService.countByShopEatType(shopEatTypeInfoDTO, switchTableDTO.getMasterId(), switchTableDTO.getOrderId(),
true, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
cashierCarts = mpCashierCartService.selectByIds(switchTableDTO.getShopId(), null, switchTableDTO.getCartIds(),
TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
}
if (cashierCarts.isEmpty()) {
throw new BadRequestException("当前台桌购物车为空");
}
String masterId = getMasterId(switchTableDTO.getShopId(), switchTableDTO.getTargetTableId(), null, null).getString("masterId");
// 查询目标购物车
List<TbCashierCart> targetCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(targetShopEatTypeInfoDTO, masterId, null, false);
TbCashierCart targetSeatFee = null;
Integer targetOrderId = null;
for (TbCashierCart targetCart : targetCarts) {
if (TableConstant.CART_SEAT_ID.equals(targetCart.getProductId())) {
targetSeatFee = targetCart;
}
if (targetCart.getOrderId() != null) {
targetOrderId = targetCart.getOrderId();
}
}
if (targetOrderId == null) {
throw new BadRequestException("目标桌未开台");
}
// 修改原有购物车数据
ArrayList<Integer> cartIds = new ArrayList<>();
Integer orderId = switchTableDTO.getOrderId();
TbCashierCart currentSeatFee = null;
ArrayList<TbCashierCart> updateCartInfos = new ArrayList<>();
for (TbCashierCart item : cashierCarts) {
if (item.getOrderId() == null) {
throw new BadRequestException("商品未下单无法转台并台");
}
if (targetSeatFee == null || !TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
item.setTableId(switchTableDTO.getTargetTableId());
item.setMasterId(masterId);
updateCartInfos.add(item);
}
cartIds.add(item.getId());
orderId = item.getOrderId();
if (TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
currentSeatFee = item;
}
}
if (currentSeatFee != null && targetSeatFee != null) {
targetSeatFee.setNumber(currentSeatFee.getNumber().add(targetSeatFee.getNumber()));
targetSeatFee.setTotalNumber(currentSeatFee.getTotalNumber().add(targetSeatFee.getTotalNumber()));
targetSeatFee.setTotalAmount(targetSeatFee.getSalePrice().multiply(targetSeatFee.getTotalNumber()));
mpCashierCartService.updateById(targetSeatFee);
mpCashierCartService.removeById(currentSeatFee.getId());
}
mpCashierCartService.updateBatchById(updateCartInfos);
mpCashierCartService.update(new LambdaUpdateWrapper<TbCashierCart>()
.in(TbCashierCart::getId, cartIds)
.set(TbCashierCart::getOrderId, null)
.set(TbCashierCart::getPlaceNum, null));
mpOrderDetailService.removeByCartIds(cartIds);
// 删除原有台桌detail和order信息
if (orderId != null && (switchTableDTO.isFull() || switchTableDTO.getCartIds().size() == totalSize)) {
mpOrderInfoService.removeById(orderId);
}
if (!switchTableDTO.isFull() && switchTableDTO.getCartIds().size() == totalSize) {
// 重新创建订单数据
CreateOrderDTO createOrderDTO = new CreateOrderDTO();
createOrderDTO.setMasterId(switchTableDTO.getMasterId());
createOrderDTO.setShopId(switchTableDTO.getShopId());
createOrderDTO.setTableId(switchTableDTO.getCurrentTableId());
createOrderDTO.setUseType(shopEatTypeInfoDTO.getUseType());
createOrder(createOrderDTO, false, false);
}
// 重新创建订单数据
CreateOrderDTO createOrderDTO = new CreateOrderDTO();
createOrderDTO.setMasterId(masterId);
createOrderDTO.setShopId(switchTableDTO.getShopId());
createOrderDTO.setTableId(switchTableDTO.getTargetTableId());
createOrderDTO.setUseType(targetShopEatTypeInfoDTO.getUseType());
createOrder(createOrderDTO, false, false);
return true;
}
}

View File

@@ -117,7 +117,7 @@ public interface TbShopTableService {
void pack(PackCartDTO packCartDTO);
Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId);
Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId, boolean isPrint);
JSONObject getMasterId(Integer shopId, String tableId, String useType, Integer orderId);
@@ -169,4 +169,10 @@ public interface TbShopTableService {
Object checkCoupon(ThirdCouponCheckDTO checkDTO);
Object waitCall(WaitCallDTO waitCallDTO);
/**
* 台桌转台
* @param switchTableDTO 转台参数
*/
Object switchTable(SwitchTableDTO switchTableDTO);
}