代客下单逻辑修改
This commit is contained in:
parent
11121d6ca2
commit
36d81b71d4
|
|
@ -33,7 +33,7 @@ public class TbPlaceController {
|
|||
|
||||
|
||||
@AnonymousAccess
|
||||
@GetMapping ("/activate")
|
||||
@GetMapping("/activate")
|
||||
@ApiOperation("查询/product")
|
||||
public ResponseEntity<Object> queryActivateTbProductInfo(
|
||||
@RequestParam(defaultValue = "0") Integer page,
|
||||
|
|
@ -41,8 +41,8 @@ public class TbPlaceController {
|
|||
@RequestParam(required = false) Integer categoryId,
|
||||
@RequestParam Integer shopId,
|
||||
@RequestParam(required = false) Integer productId
|
||||
){
|
||||
return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId),HttpStatus.OK);
|
||||
) {
|
||||
return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId), HttpStatus.OK);
|
||||
}
|
||||
|
||||
public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils) {
|
||||
|
|
@ -103,6 +103,7 @@ public class TbPlaceController {
|
|||
tbShopTableService.returnCart(removeCartDTO);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@DeleteMapping("/clearCart")
|
||||
|
|
@ -112,6 +113,7 @@ public class TbPlaceController {
|
|||
tbShopTableService.clearCart(clearCartDTO);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@GetMapping("/cart")
|
||||
|
|
@ -125,7 +127,7 @@ public class TbPlaceController {
|
|||
@RequestParam String masterId,
|
||||
@RequestParam String useType
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId,masterId, useType));
|
||||
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, masterId, useType));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
|
@ -157,7 +159,7 @@ public class TbPlaceController {
|
|||
@Log("代客下单 查询购物车")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> createOrder(
|
||||
@RequestBody CreateOrderDTO createOrderDTO
|
||||
@RequestBody CreateOrderDTO createOrderDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay(), true));
|
||||
}
|
||||
|
|
@ -202,7 +204,7 @@ public class TbPlaceController {
|
|||
@Validated @RequestBody PayDTO payDTO
|
||||
) {
|
||||
|
||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
|
@ -216,6 +218,7 @@ public class TbPlaceController {
|
|||
|
||||
return ResponseEntity.ok(tbShopTableService.choseTable(choseTableDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@PutMapping("/choseCount")
|
||||
|
|
@ -259,8 +262,9 @@ public class TbPlaceController {
|
|||
}
|
||||
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
@AnonymousAccess
|
||||
@GetMapping("/test")
|
||||
@GetMapping("/test")
|
||||
public void test(
|
||||
@RequestParam Integer id
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
|||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||
import cn.ysk.cashier.repository.product.TbProductRepository;
|
||||
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.impl.TbPayServiceImpl;
|
||||
|
|
@ -78,12 +77,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
private final TbShopTableRepository tbShopTableRepository;
|
||||
private final TbShopTableMapper tbShopTableMapper;
|
||||
private final TbProductRepository productRepository;
|
||||
private final TbProductSkuRepository productSkuRepository;
|
||||
private final TbCashierCartRepository cashierCartRepository;
|
||||
private final TbProductMapper productMapper;
|
||||
private final TbCashierCartMapper cashierCartMapper;
|
||||
private final RedisUtils redisUtils;
|
||||
private final TokenProvider tokenProvider;
|
||||
private final TbMerchantAccountMapper merchantAccountMapper;
|
||||
private final TbOrderInfoMapper orderInfoMapper;
|
||||
|
|
@ -92,7 +89,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final RabbitTemplate rabbitTemplate;
|
||||
private final TbShopInfoRepository shopInfoRepository;
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
private final WxAccountUtil wxAccountUtil;
|
||||
private final WxMsgUtils wxMsgUtils;
|
||||
private final TbShopPayTypeRepository payTypeRepository;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
|
|
@ -133,26 +129,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
return currentOrder == null ? null : currentOrder.getId();
|
||||
}
|
||||
|
||||
private TbOrderInfo getCurrentOrder(boolean isDineInAfter, String tableId, Object shopId) {
|
||||
// 获取当前台桌最新订单,先付款模式不获取
|
||||
String currentOrderKey = RedisConstant.getCurrentOrderKey(tableId,
|
||||
shopId.toString());
|
||||
String orderIdValue = redisTemplate.opsForValue().get(currentOrderKey);
|
||||
Integer orderId = isDineInAfter ? orderIdValue != null ? Integer.parseInt(orderIdValue) : null : null;
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getStatus, "unpaid")
|
||||
.eq(TbOrderInfo::getId, orderId));
|
||||
if (orderInfo == null) {
|
||||
redisTemplate.delete(currentOrderKey);
|
||||
}
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验就餐模式是否存在并返回就餐类型信息
|
||||
*
|
||||
* @param tableId 台桌id
|
||||
* @param shopId 店铺id
|
||||
* @param shopId 店铺id
|
||||
* @return 就餐类型信息
|
||||
*/
|
||||
public ShopEatTypeInfoDTO checkEatModel(Object shopId, String tableId) {
|
||||
|
|
@ -160,6 +142,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
return getShopEatTypeInfoDTO(shopId, eatModel, tableId);
|
||||
}
|
||||
|
||||
|
||||
private ShopEatTypeInfoDTO getShopEatTypeInfoDTO(Object shopId, String eatModel, String tableId) {
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
|
||||
.eq(TbShopInfo::getId, shopId)
|
||||
|
|
@ -185,7 +168,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable) {
|
||||
if (criteria.getAreaId() == 0) {
|
||||
|
|
@ -389,24 +371,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
return tbCashierCart;
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌状态校验
|
||||
*
|
||||
* @param tableId 桌码
|
||||
* @return z
|
||||
*/
|
||||
private TbShopTable checkTableIsOpen(String tableId) {
|
||||
TbShopTable shopTable = tbShopTableRepository.findByQrcode(tableId);
|
||||
if (shopTable == null) {
|
||||
throw new BadRequestException("桌码不存在,桌码" + tableId);
|
||||
}
|
||||
if (!shopTable.getStatus().equals("using") && !shopTable.getStatus().equals("idle")
|
||||
&& !shopTable.getStatus().equals("pending")) {
|
||||
throw new BadRequestException("当前台桌非开台状态");
|
||||
}
|
||||
return shopTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前台桌当前下单次数
|
||||
*
|
||||
|
|
@ -420,6 +384,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
@Override
|
||||
public TbCashierCart addCartForUser(AddCartDTO addCartDTO) {
|
||||
addCartDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(addCartDTO.getUseType()) ? null : addCartDTO.getTableId());
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(addCartDTO.getShopId(), addCartDTO.getTableId());
|
||||
|
||||
TbProductSku productSku = productMapper.selectSkuByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getSkuId());
|
||||
|
|
@ -453,14 +418,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||
query.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||
.in(TbCashierCart::getPlatformType, "pc", "cash");
|
||||
}else {
|
||||
} else {
|
||||
query.eq(TbCashierCart::getTableId, addCartDTO.getTableId());
|
||||
}
|
||||
|
||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||
// 增加redis购物车数据
|
||||
String tableCartKey = RedisConstant.getTableCartKey(addCartDTO.getTableId(), addCartDTO.getShopId().toString());
|
||||
String tableCart = redisTemplate.opsForValue().get(tableCartKey);
|
||||
// 首次加入
|
||||
if (tbCashierCart == null) {
|
||||
tbCashierCart = new TbCashierCart();
|
||||
|
|
@ -603,7 +565,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (cashierCart.getOrderId() != null && carCount < 1) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(cashierCart.getOrderId()));
|
||||
}
|
||||
setRedisTableCartInfo(removeCartDTO.getTableId().toString(), removeCartDTO.getShopId().toString(), Collections.singletonList(cashierCart), false);
|
||||
setRedisTableCartInfo(removeCartDTO.getTableId(), removeCartDTO.getShopId().toString(), Collections.singletonList(cashierCart), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -648,7 +610,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.set(TbOrderInfo::getSeatAmount, null));
|
||||
}
|
||||
|
||||
}else {
|
||||
} else {
|
||||
cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getId, cashierCart.getId())
|
||||
.set(TbCashierCart::getStatus, "return"));
|
||||
|
|
@ -715,7 +677,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
if (!shopEatTypeInfoDTO.isTakeout()) {
|
||||
queryWrapper.eq(TbCashierCart::getTableId, tableId);
|
||||
}else {
|
||||
} else {
|
||||
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
||||
}
|
||||
|
|
@ -951,14 +913,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|| (product.getIsDistribute() != 1) && productSku.getStockNumber() - num <= productSku.getWarnLine()
|
||||
) {
|
||||
|
||||
List<TbShopOpenId> openIdList = shopOpenIdMapper.selectList(new LambdaQueryWrapper<TbShopOpenId>()
|
||||
.eq(TbShopOpenId::getShopId, shopId)
|
||||
.eq(TbShopOpenId::getStatus, 1)
|
||||
.and((queryWrapper) -> queryWrapper.eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.ALL_MSG.getType())
|
||||
.or().eq(TbShopOpenId::getType, ShopWxMsgTypeEnum.STOCK_MSG.getType()))
|
||||
.groupBy(TbShopOpenId::getOpenId)
|
||||
);
|
||||
|
||||
wxMsgUtils.aboardStockMsg(shopInfo.getShopName(), shopId, product.getName(),
|
||||
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num));
|
||||
}
|
||||
|
|
@ -1005,7 +959,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final StringRedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public JSONObject getMasterId(Integer shopId, String tableId,String useType) {
|
||||
public JSONObject getMasterId(Integer shopId, String tableId, String useType) {
|
||||
String account = tokenProvider.getSubject();
|
||||
if (account == null) {
|
||||
throw new BadRequestException("token解析失败");
|
||||
|
|
@ -1044,6 +998,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
@Override
|
||||
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId, boolean isPrint) {
|
||||
createOrderDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(createOrderDTO.getUseType()) ? null : createOrderDTO.getTableId());
|
||||
return Utils.runFunAndCheckKey(() -> {
|
||||
TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null);
|
||||
if (shopInfo == null) throw new BadRequestException("店铺信息不存在");
|
||||
|
|
@ -1066,7 +1021,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
||||
}else {
|
||||
} else {
|
||||
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
|
||||
|
||||
tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
|
|
@ -1103,7 +1058,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
oldOrderDetailList.forEach(item -> {
|
||||
if (cartIdList.contains(item.getCartId())) {
|
||||
oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item);
|
||||
}else {
|
||||
} else {
|
||||
removeOrderDetailIds.add(item.getId());
|
||||
}
|
||||
});
|
||||
|
|
@ -1812,6 +1767,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
}
|
||||
return tbShopTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object printDishes(BaseTableDTO baseTableDTO) {
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(baseTableDTO.getShopId(), baseTableDTO.getTableId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue