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

This commit is contained in:
Tankaikai 2024-10-26 17:27:52 +08:00
commit 0e05d067a0
19 changed files with 244 additions and 91 deletions

View File

@ -1,10 +1,12 @@
package cn.ysk.cashier.controller.product;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.dto.shoptable.*;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.TbMerchantAccountMapper;
import cn.ysk.cashier.pojo.TbToken;
import cn.ysk.cashier.pojo.order.TbCashierCart;
@ -199,6 +201,13 @@ public class TbPlaceController {
@ApiOperation("代客下单 选择用餐人数")
public ResponseEntity<Object> choseCount(@Validated @RequestBody ChoseCountDTO choseCountDTO) {
if (StrUtil.isBlank(choseCountDTO.getTableId())) {
return ResponseEntity.ok(null);
}
if (StrUtil.isNotBlank(choseCountDTO.getTableId()) && choseCountDTO.getNum() == null) {
throw new BadRequestException("人数不为空");
}
return ResponseEntity.ok(tbShopTableService.choseCount(choseCountDTO));
}

View File

@ -53,8 +53,8 @@ public class TbShopTableController {
@GetMapping
@ApiOperation("查询/shop/table")
public ResponseEntity<Object> queryTbShopTable(TbShopTableQueryCriteria criteria){
return new ResponseEntity<>(tbShopTableService.queryAllNoPage(criteria),HttpStatus.OK);
public ResponseEntity<Object> queryTbShopTable(@Validated TbShopTableQueryCriteria criteria){
return new ResponseEntity<>(tbShopTableService.queryAllPage(criteria),HttpStatus.OK);
}
@PostMapping

View File

@ -16,6 +16,7 @@
package cn.ysk.cashier.dto.order;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -159,7 +160,7 @@ public class TbOrderInfoDto implements Serializable {
private String remark;
private List<TbOrderDetail> detailList;
private List<? extends TbOrderDetail> detailList;
private String payRemark;

View File

@ -15,9 +15,12 @@
*/
package cn.ysk.cashier.dto.shop;
import cn.ysk.cashier.enums.TableStateEnum;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
import javax.validation.constraints.NotNull;
/**
* @website https://eladmin.vip
* @author lyf
@ -32,6 +35,7 @@ public class TbShopTableQueryCriteria{
/** 精确 */
@Query
@NotNull
private Integer shopId;
@Query
@ -39,4 +43,8 @@ public class TbShopTableQueryCriteria{
@Query
private Long qrcode;
private String state;
private Integer page = 1;
private Integer size = 99999;
}

View File

@ -12,9 +12,7 @@ public class ChoseCountDTO {
private String masterId;
@NotNull
private Integer shopId;
@NotEmpty
private String tableId;
@NotNull
@Min(1)
private Integer num;
@NotEmpty

View File

@ -12,5 +12,7 @@ public class ChoseTableDTO {
private String masterId;
@NotBlank
private String tableId;
@NotNull
private Boolean isClear;
}

View File

@ -1,9 +1,13 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
public interface TbOrderDetailMapper extends BaseMapper<TbOrderDetail> {
/**
@ -16,4 +20,11 @@ public interface TbOrderDetailMapper extends BaseMapper<TbOrderDetail> {
@Update("update tb_order_detail set status=#{status}, price_amount=(num+#{changeNum})*price,num=num+#{changeNum} " +
"where id=#{id}")
int updateNumAmountStatus(Integer id, String status, int changeNum);
/**
* 查询包含打包费和是否赠送的订单详情信息
* @param orderId 订单id
*/
@Select("select a.*, b.is_gift, b.is_pack from tb_order_detail as a left join tb_cashier_cart as b on a.cart_id=b.id where a.order_id=#{orderId}")
List<TbFullOrderDetail> selectFullInfoByOrderId(Integer orderId);
}

View File

@ -2,7 +2,6 @@ package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -23,6 +22,14 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
*/
List<TbCashierCart> selectTakeoutCart(String masterId, Integer shopId);
/**
* 查询无台桌购物车商品
* @param masterId 取餐码
* @param shopId 店铺did
*/
List<TbCashierCart> selectUnTableCart(String masterId, Integer shopId);
/**
* 统计当前台桌购物车数量
* @param shopId 店铺id
@ -31,5 +38,15 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
* @return 购物车数量
*/
long countByTableId(Integer shopId, String tableId, OrderStatusEnums... statusEnums);
/**
* 根据tableIdId和用餐类型清空购物车
*
* @param tableId 台桌id
* @param useType 用餐类型
* @param shopId 店铺id
*/
boolean clearCartByTableIdAndUseType(String tableId, String useType, Integer shopId);
}

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import com.baomidou.mybatisplus.extension.service.IService;
@ -33,5 +34,13 @@ public interface MpOrderDetailService extends IService<TbOrderDetail> {
* @return 是否成功
*/
boolean updateUseTypeByCartIds(ArrayList<Integer> cartIds, String useType);
/**
* 根据订单id查询订单详情
* @param orderId 订单id
* @return 详情信息
*/
List<TbOrderDetail> selectByOrderId(Integer orderId);
}

View File

@ -1,14 +1,17 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.enums.OrderUseTypeEnum;
import cn.ysk.cashier.enums.ShopInfoEatModelEnum;
import cn.ysk.cashier.enums.ShopInfoRegisterlEnum;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper;
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
import cn.ysk.cashier.mybatis.service.MpCashierCartService;
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@ -25,6 +28,12 @@ import java.util.List;
*/
@Service
public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, TbCashierCart> implements MpCashierCartService {
private final MpShopInfoMapper mpShopInfoMapper;
public MpCashierCartServiceImpl(MpShopInfoMapper mpShopInfoMapper) {
this.mpShopInfoMapper = mpShopInfoMapper;
}
@Override
public List<TbCashierCart> selectTakeoutCart(String masterId, Integer shopId) {
return list(new LambdaQueryWrapper<TbCashierCart>()
@ -34,6 +43,25 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()));
}
@Override
public List<TbCashierCart> selectUnTableCart(String masterId, Integer shopId) {
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
.eq(TbShopInfo::getId, shopId)
.eq(TbShopInfo::getStatus, 1));
if (shopInfo == null) {
throw new BadRequestException("店铺信息不存在");
}
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
return list(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getMasterId, masterId)
.eq(TbCashierCart::getUseType, isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()));
}
@Override
public long countByTableId(Integer shopId, String tableId, OrderStatusEnums... statusEnums) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
@ -49,5 +77,15 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
}
return count(queryWrapper);
}
@Override
public boolean clearCartByTableIdAndUseType(String tableId, String useType, Integer shopId) {
return remove(new LambdaQueryWrapper<TbCashierCart>()
.in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue(), OrderStatusEnums.RETURN.getValue())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getUseType, useType));
}
}

View File

@ -5,11 +5,13 @@ import cn.ysk.cashier.enums.OrderStatusEnums;
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
import cn.ysk.cashier.pojo.order.TbOrderDetail;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -38,5 +40,11 @@ public class MpOrderDetailServiceImpl extends ServiceImpl<TbOrderDetailMapper, T
.in(TbOrderDetail::getCartId, cartIds)
.set(TbOrderDetail::getUseType, useType));
}
@Override
public List<TbOrderDetail> selectByOrderId(Integer orderId) {
return list(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderId));
}
}

View File

@ -16,10 +16,13 @@ import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
import cn.ysk.cashier.mybatis.entity.*;
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
import cn.ysk.cashier.mybatis.service.impl.MpOrderDetailServiceImpl;
import cn.ysk.cashier.pojo.TbShopPayType;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.order.TbFullOrderDetail;
@ -105,6 +108,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
private final TbCashierCartMapper tbCashierCartMapper;
private final PayService payService;
private final MpOrderDetailService mpOrderDetailService;
private final TbOrderDetailMapper tbOrderDetailMapper;
@Value("${thirdPay.url}")
private String url;
@ -167,7 +172,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
for (TbOrderInfo tbOrderInfo : page.getContent()) {
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
BigDecimal refundAmount = BigDecimal.ZERO;
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
List<TbFullOrderDetail> details = tbOrderDetailMapper.selectFullInfoByOrderId(tbOrderInfo.getId());
if (!tbOrderInfo.getOrderType().equals("return")) {
List<TbOrderInfo> tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId());
Map<Integer, Integer> map;
@ -190,8 +195,19 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
detail.setRefundNumber(detail.getNum());
});
}
TbOrderDetail seatInfo = null;
ArrayList<TbFullOrderDetail> detailList = new ArrayList<>();
for (TbFullOrderDetail detail : details) {
if (TableConstant.CART_SEAT_ID.equals(detail.getProductId().toString())) {
seatInfo = detail;
}else {
detailList.add(detail);
}
}
orderInfoVo.setTableName(tbOrderInfo.getTableName());
orderInfoVo.setDetailList(details);
orderInfoVo.setDetailList(detailList);
orderInfoVo.setSeatInfo(seatInfo);
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
orderInfoVo.setRefundAmount(refundAmount);
orderInfoVoList.add(orderInfoVo);
@ -291,7 +307,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
dto.setPayType("退单");
}
}
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
List<TbFullOrderDetail> details = tbOrderDetailMapper.selectFullInfoByOrderId(tbOrderInfo.getId());
dto.setIsRefund(0);
dto.setRefundAmount(BigDecimal.ZERO);
dto.setRefundRemark(tbOrderInfo.getRefundRemark());

View File

@ -762,6 +762,7 @@ public class TbProductServiceImpl implements TbProductService {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbProduct> page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size);
QueryWrapper<TbProduct> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_del", 0)
.in("type_enum", "sku", "normal")
.eq("shop_id", shopId)
.eq("is_delete", 0)
.eq("status", 1)

View File

@ -49,7 +49,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -166,11 +165,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
/**
* 通过店铺id和就餐模式获取当前店铺的就餐类型信息
*
* @param shopId 店铺id
* @param shopId 店铺id
* @param eatModel 就餐模式
* @param tableId 台桌id
* @param tableId 台桌id
* @return just餐类型信息
* */
*/
private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel, String tableId) {
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
.eq(TbShopInfo::getId, shopId)
@ -217,11 +216,32 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
@Override
public Map<String, Object> queryAllNoPage(TbShopTableQueryCriteria criteria) {
public Map<String, Object> queryAllPage(TbShopTableQueryCriteria criteria) {
if (null == criteria.getAreaId() || criteria.getAreaId() == 0) {
criteria.setAreaId(null);
}
List<TbShopTable> tbShopTableList = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
LambdaQueryWrapper<TbShopTable> query = new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, criteria.getShopId());
if (StrUtil.isNotBlank(criteria.getName())) {
query.like(TbShopTable::getName, criteria.getName());
}
if (criteria.getAreaId() != null) {
query.eq(TbShopTable::getAreaId, criteria.getAreaId());
}
if (criteria.getQrcode() != null) {
query.eq(TbShopTable::getQrcode, criteria.getQrcode());
}
if (StrUtil.isNotBlank(criteria.getState())) {
query.eq(TbShopTable::getStatus, criteria.getState()).isNotNull(TbShopTable::getQrcode).ne(TbShopTable::getQrcode, "");
}
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbShopTable> shopTablePage =
mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query);
List<TbShopTable> tbShopTableList = shopTablePage.getRecords();
ArrayList<Map<String, Object>> infoList = new ArrayList<>();
for (TbShopTable date : tbShopTableList) {
if (StrUtil.isBlank(date.getQrcode())) {
@ -264,10 +284,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
itemMap.put("masterId", orderInfo == null ? null : orderInfo.getMasterId());
infoList.add(itemMap);
}
int i = tbShopTableRepository.countAllByShopId(criteria.getShopId());
HashMap<String, Object> map = new HashMap<>();
map.put("content", infoList);
map.put("total", i);
map.put("total", shopTablePage.getTotal());
return map;
}
@ -401,7 +420,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setIsPack(updateCartDTO.getIsPack() ? "true" : "false");
}
if (updateCartDTO.getIsGift() != null ) {
if (updateCartDTO.getIsGift() != null) {
tbCashierCart.setTotalAmount(updateCartDTO.getIsGift() ? tbCashierCart.getPackFee() : tbCashierCart.getTotalAmount());
tbCashierCart.setIsGift(updateCartDTO.getIsGift() ? "true" : "false");
}
@ -443,7 +462,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("商品不存在或已下架, id: " + addCartDTO.getSkuId());
}
if (product.getIsStock() != null && product.getIsStock() == 1 &&product.getStockNumber() < 1) {
if (product.getIsStock() != null && product.getIsStock() == 1 && product.getStockNumber() < 1) {
throw new BadRequestException(product.getName() + "商品库存不足");
}
@ -576,9 +595,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public void removeCart(RemoveCartDTO removeCartDTO) {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(removeCartDTO.getShopId(), removeCartDTO.getTableId());
int currentPlaceNum = getCurrentPlaceNum(shopEatTypeInfoDTO);
// 会员点单
TbCashierCart cashierCart = cashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, removeCartDTO.getShopId())
@ -588,7 +604,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("购物车商品不存在");
}
if (removeCartDTO.getTableId() != null && cashierCart.getPlaceNum() != null && !cashierCart.getPlaceNum().equals(currentPlaceNum)) {
if (removeCartDTO.getTableId() != null && cashierCart.getPlaceNum() != null) {
throw new BadRequestException("已下单商品仅支持退单操作");
}
@ -615,7 +631,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (cashierCart.getTableId() != null && removeCartDTO.getTableId() != null) {
// 清空购物车 出票
long carCount = countCar(Long.valueOf(cashierCart.getTableId()), cashierCart.getShopId(), cashierCart.getMasterId());
long carCount = countCar(Long.valueOf(cashierCart.getTableId()), cashierCart.getShopId());
log.info("购物车数量: {}", carCount);
setRedisTableCartInfo(removeCartDTO.getTableId(), removeCartDTO.getShopId().toString(), Collections.singletonList(cashierCart), false);
}
@ -639,15 +655,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("最大退菜数量为: {}", cashierCart.getNumber());
}
TbOrderDetail tbOrderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getShopId, removeCartDTO.getShopId())
.eq(TbOrderDetail::getCartId, cashierCart.getId())
.eq(TbOrderDetail::getProductId, cashierCart.getProductId())
.eq(TbOrderDetail::getProductSkuId, cashierCart.getSkuId())
.eq(TbOrderDetail::getOrderId, cashierCart.getOrderId()));
if (tbOrderDetail == null) {
throw new BadRequestException("购物车商品不存在或已退单");
}
if (cashierCart.getOrderId() == null) {
throw new BadRequestException("此商品还未下单,无需退单");
@ -657,21 +665,25 @@ public class TbShopTableServiceImpl implements TbShopTableService {
TbOrderDetail orderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getCartId, cashierCart.getId()));
if (cashierCart.getId() == -999) {
if (cashierCart.getProductId().equals("-999")) {
cashierCartMapper.deleteById(cashierCart.getId());
if (cashierCart.getOrderId() != null) {
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getCartId, cashierCart.getId()));
orderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, cashierCart.getOrderId())
.eq(TbOrderInfo::getShopId, removeCartDTO.getShopId())
.set(TbOrderInfo::getSeatCount, null)
.set(TbOrderInfo::getSeatAmount, null));
}
cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getId, cashierCart.getId())
.set(TbCashierCart::getStatus, "return"));
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
.set(TbOrderDetail::getUpdateTime, DateUtil.date())
.set(TbOrderDetail::getStatus, "return"));
} else {
TbOrderDetail tbOrderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getShopId, removeCartDTO.getShopId())
.eq(TbOrderDetail::getCartId, cashierCart.getId())
.eq(TbOrderDetail::getProductId, cashierCart.getProductId())
.eq(TbOrderDetail::getProductSkuId, cashierCart.getSkuId())
.eq(TbOrderDetail::getOrderId, cashierCart.getOrderId()));
if (tbOrderDetail == null) {
throw new BadRequestException("购物车商品不存在或已退单");
}
if (cashierCart.getNumber().equals(removeCartDTO.getNum())) {
cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.eq(TbCashierCart::getId, cashierCart.getId())
@ -681,7 +693,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.set(TbOrderDetail::getUpdateTime, DateUtil.date())
.set(TbOrderDetail::getStatus, "return"));
rabbitMsgUtils.printDishesTicket(tbOrderDetail.getOrderId(), true, tbOrderDetail);
}else {
} else {
//生成退菜的购物车记录
TbCashierCart returnCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class);
returnCart.setNumber(removeCartDTO.getNum());
@ -751,7 +763,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
cashierCartMapper.delete(query);
}
private long countCar(Long tableId, String shopId, String masterId) {
private long countCar(Long tableId, String shopId) {
String orderId = redisTemplate.opsForValue().get(RedisConstant.getCurrentOrderKey(tableId.toString(), shopId));
return tbOrderDetailMapper.selectCount(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getShopId, shopId)
@ -762,7 +774,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public Map<String, Object> getCart(String tableId, Integer page,
Integer size, Integer shopId, String masterId, String useType) {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(shopId, OrderUseTypeEnum.TAKEOUT.getValue().equals(useType) ? null : tableId);
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(shopId, OrderUseTypeEnum.TAKEOUT.getValue().equals(useType) ? null : tableId, useType);
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.in(TbCashierCart::getStatus, "create", "return")
.eq(TbCashierCart::getShopId, shopId)
@ -771,7 +783,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
if (!shopEatTypeInfoDTO.isTakeout()) {
queryWrapper.eq(TbCashierCart::getTableId, tableId);
if (StrUtil.isBlank(tableId)) {
queryWrapper.isNull(TbCashierCart::getTableId);
} else {
queryWrapper.eq(TbCashierCart::getTableId, tableId);
}
} else {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
@ -1087,7 +1103,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (shopInfo == null) throw new BadRequestException("店铺信息不存在");
// 就餐模式信息
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(createOrderDTO.getShopId(), createOrderDTO.getTableId());
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(createOrderDTO.getShopId(), createOrderDTO.getTableId(), createOrderDTO.getUseType());
// 传递orderId直接取否则取当前缓存id
Integer orderId = shopEatTypeInfoDTO.isDineInAfter() ?
@ -1106,15 +1122,18 @@ public class TbShopTableServiceImpl implements TbShopTableService {
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
} else {
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.in(TbShopTable::getStatus, "idle", "using"));
if (tbShopTable == null) {
throw new BadRequestException("台桌未开台或不存在");
if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
.in(TbShopTable::getStatus, "idle", "using"));
if (tbShopTable == null) {
throw new BadRequestException("台桌未开台或不存在");
}
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
} else {
queryWrapper.isNull(TbCashierCart::getTableId);
}
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
}
List<TbCashierCart> allCashierCarts = cashierCartMapper
@ -1132,8 +1151,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
}
if (allCashierCarts.isEmpty() || (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart != null && allCashierCarts.size() < 2)
|| (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart == null)) {
if (StrUtil.isNotBlank(createOrderDTO.getTableId())
&& (cashierCarts.isEmpty() ||
(shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart != null && cashierCarts.size() < 2)
|| (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart == null))) {
throw new BadRequestException("购物车为空或未选择餐位费,请先添加商品或选择餐位费");
}
@ -1173,7 +1194,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
List<TbOrderDetail> addOrderDetails = new ArrayList<>();
boolean hasNewInfo = false;
for (TbCashierCart cashierCart : cashierCarts) {
if (!"return".equals(cashierCart.getStatus())) {
@ -1334,7 +1354,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
// 先付费模式结束购物车状态
if (shopEatTypeInfoDTO.isDineInBefore() || shopEatTypeInfoDTO.isTakeout()) {
if (shopEatTypeInfoDTO.isDineInBefore() || shopEatTypeInfoDTO.isTakeout() || StrUtil.isBlank(createOrderDTO.getTableId())) {
cashierCart.setStatus("final");
}
cashierCartMapper.updateById(cashierCart);
@ -1368,7 +1388,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
// 推送耗材信息
pushConsMsg(orderInfo, cashierCarts);
if (!shopEatTypeInfoDTO.isTakeout()) {
if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(createOrderDTO.getTableId())) {
// 清空台桌信息
if (shopEatTypeInfoDTO.isDineInBefore()) {
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
@ -1398,8 +1418,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
redisTemplate.delete(tableCartKey);
if (StrUtil.isNotBlank(createOrderDTO.getTableId())) {
String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString());
redisTemplate.delete(tableCartKey);
}
return orderInfo;
}, stringRedisTemplate, RedisConstant.getLockKey(RedisConstant.CREATE_ORDER, createOrderDTO.getShopId(),
createOrderDTO.getTableId(), createOrderDTO.getMasterId(), createOrderDTO.getUseType()));
@ -1570,8 +1592,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("订单非未支付状态");
}
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(payDTO.getShopId(), orderInfo.getTableId());
if (payDTO.getDiscount() == null) {
payDTO.setDiscount((double) 1);
}
@ -1636,10 +1656,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
jsonObject.put("token", payDTO.getToken());
jsonObject.put("type", "create");
jsonObject.put("orderId", orderInfo.getId());
rabbitMsgUtils.sendOrderCollectMsg(jsonObject,3);
rabbitMsgUtils.sendOrderCollectMsg(jsonObject, 3);
// 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) {
if (!OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(orderInfo.getUseType())) {
List<TbOrderDetail> detailList = orderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
.eq(TbOrderDetail::getStatus, "closed"));
@ -1654,7 +1674,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
rabbitTemplate.convertAndSend(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
// 修改台桌状态
if (!shopEatTypeInfoDTO.isTakeout()) {
if (!OrderUseTypeEnum.TAKEOUT.getValue().equals(orderInfo.getUseType()) && StrUtil.isNotBlank(orderInfo.getTableId())) {
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getShopId, payDTO.getShopId())
.eq(TbShopTable::getQrcode, orderInfo.getTableId()));
@ -1670,16 +1690,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.set(TbShopTable::getEndTime, DateUtil.date())
.set(TbShopTable::getStatus, TableStateEnum.CLEANING.getState()));
}
}
if (!shopEatTypeInfoDTO.isTakeout()) {
String day = DateUtils.getDay();
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
redisTemplate.delete(key);
}
String currentOrderKey = RedisConstant.CURRENT_TABLE_ORDER + payDTO.getShopId() + ":" + orderInfo.getTableId();
redisTemplate.delete(currentOrderKey);
@ -1762,18 +1778,27 @@ public class TbShopTableServiceImpl implements TbShopTableService {
throw new BadRequestException("台桌不存在或不处于空闲状态");
}
List<TbCashierCart> tbCashierCarts = mpCashierCartService.selectTakeoutCart(choseTableDTO.getMasterId(), choseTableDTO.getShopId());
List<TbCashierCart> tbCashierCarts = mpCashierCartService.selectUnTableCart(choseTableDTO.getMasterId(), choseTableDTO.getShopId());
if (tbCashierCarts.isEmpty()) {
throw new BadRequestException("购物车为空");
}
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(choseTableDTO.getShopId(), choseTableDTO.getTableId());
// 清空原有桌台商品
if (choseTableDTO.getIsClear()) {
mpCashierCartService.clearCartByTableIdAndUseType(choseTableDTO.getTableId(), shopEatTypeInfoDTO.getUseType(), choseTableDTO.getShopId());
}
String masterId = getMasterId(choseTableDTO.getShopId(), choseTableDTO.getTableId(), "", null).getString("masterId");
ArrayList<Integer> cartIds = new ArrayList<>();
Integer orderId = null;
for (TbCashierCart item : tbCashierCarts) {
item.setTableId(choseTableDTO.getTableId());
item.setUseType(shopEatTypeInfoDTO.getUseType());
item.setMasterId(masterId);
cartIds.add(item.getId());
if (item.getOrderId() != null) {
orderId = item.getOrderId();
@ -1785,7 +1810,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
mpOrderDetailService.updateUseTypeByCartIds(cartIds, shopEatTypeInfoDTO.getUseType());
// 修改订单表台桌信息
if(orderId != null) {
if (orderId != null) {
mpOrderInfoService.updateTableIdAndUseTypeById(orderId, shopEatTypeInfoDTO.getUseType(), choseTableDTO.getTableId());
mpShopTableService.updateStateByTableId(TableStateEnum.USING, choseTableDTO.getTableId());
// 将台桌redis数据迁移
@ -1820,7 +1845,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID)
.eq(TbCashierCart::getUseType, choseCountDTO.getUseType())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue(), OrderStatusEnums.RETURN.getValue())
.in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue(), OrderStatusEnums.RETURN.getValue())
.eq(TbCashierCart::getTableId, choseCountDTO.getTableId());
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
@ -2089,7 +2114,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
returnOrder.setSource(oldOrderInfo.getId());
returnOrder.setRefundRemark(returnOrderDTO.getNote());
orderInfoMapper.insert(returnOrder);
}else {
} else {
returnOrder.setUpdatedAt(DateUtil.current());
returnOrder.setRefundRemark(returnOrderDTO.getNote());
returnOrder.setRefundAmount(returnOrder.getRefundAmount().add(returnAmount));
@ -2142,7 +2167,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Transactional
public Object returnOrder(ReturnOrderDTO returnOrderDTO) {
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, returnOrderDTO.getOrderId())
.eq(TbOrderInfo::getId, returnOrderDTO.getOrderId())
.in(TbOrderInfo::getStatus, OrderStatusEnums.REFUND.getValue(), OrderStatusEnums.CLOSED.getValue())
// .eq(TbOrderInfo::getStatus, "closed")
);
@ -2196,7 +2221,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
public Object getShopState(Integer shopId, String tableId) {
TbShopTable tbShopTable = mpShopTableService.selectByTableId(tableId, shopId);
if (tbShopTable != null) {
long cartCount = mpCashierCartService.countByTableId(shopId, tableId);
long cartCount = mpCashierCartService.countByTableId(shopId, tableId, OrderStatusEnums.CREATE, OrderStatusEnums.RETURN);
Map<String, Object> map = BeanUtil.beanToMap(tbShopTable, false, false);
map.put("cartCount", cartCount);
return map;

View File

@ -43,7 +43,7 @@ public interface TbShopTableService {
*/
Map<String,Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable);
Map<String,Object> queryAllNoPage(TbShopTableQueryCriteria criteria);
Map<String,Object> queryAllPage(TbShopTableQueryCriteria criteria);
/**
* 查询所有数据不分页

View File

@ -114,5 +114,7 @@ public class TbOrderInfoVo {
private String remark;
private List<TbOrderDetail> detailList;
private List<? extends TbOrderDetail> detailList;
private TbOrderDetail seatInfo;
}

View File

@ -4,8 +4,9 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
# url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
# url: jdbc:mysql://127.0.0.1:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
username: cashier
password: Cashier@1@
# driver-class-name: com.mysql.cj.jdbc.Driver
@ -146,4 +147,10 @@ decorator:
multiline: false
cashier:
server:
wx: https://wxcashiertest.sxczgkj.cn/
wx: https://wxcashiertest.sxczgkj.cn/
# 三方支付回调信息
thirdPay:
notify:
fstPay: https://admintestpapi.sxczgkj.cn/notify/fstPay
fstReturn: https://admintestpapi.sxczgkj.cn/notify/fstReturn

View File

@ -138,3 +138,8 @@ file:
cashier:
server:
wx: https://pre-cashier.sxczgkj.cn/
thirdPay:
notify:
fstPay: https://pre-cashieradmin.sxczgkj.cn/notify/fstPay
fstReturn: https://pre-cashieradmin.sxczgkj.cn/notify/fstReturn

View File

@ -65,11 +65,7 @@ qrcode: https://kysh.sxczgkj.cn/codeplate?code=
thirdPay:
groupCallBack: https://wxcashiertest.sxczgkj.cn/cashierService/notify/notifyCallBackGroup
payType: fushangtong
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
url: https://paymentapi.sxczgkj.cn
notify:
fstPay: https://admintestpapi.sxczgkj.cn/notify/fstPay
fstReturn: https://admintestpapi.sxczgkj.cn/notify/fstReturn
mybatis-plus:
mapper-locations: classpath*:/mapper/plus/*.xml