parent
1dd8dc4508
commit
770c8e01f2
|
|
@ -24,4 +24,8 @@ public interface RabbitConstants {
|
|||
String EXCHANGE_PRINT = "exchange.print";
|
||||
String ROUTING_KEY_PRINT_DISHES = "routing.dishes.print";
|
||||
|
||||
// 订单打印
|
||||
String QUEUE_PRINT_PLACE = "queue.place.order.print";
|
||||
String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,6 +236,16 @@ public class TbPlaceController {
|
|||
return ResponseEntity.ok(tbShopTableService.updateVip(updateVipDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@PostMapping("/printOrder")
|
||||
@Log("代客下单 打印订单")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> printOrder(
|
||||
@Validated @RequestBody BaseTableDTO baseTableDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.printOrder(baseTableDTO));
|
||||
}
|
||||
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
@AnonymousAccess
|
||||
@GetMapping("/test")
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@
|
|||
*/
|
||||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.AnonymousAccess;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.shoptable.AddCartDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.ClearCartDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.RemoveCartDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.TableGenerateDTO;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.service.shop.TbShopTableService;
|
||||
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
|
||||
|
|
@ -87,6 +89,15 @@ public class TbShopTableController {
|
|||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/generate")
|
||||
@ApiOperation("查询/shop/table")
|
||||
public ResponseEntity<Object> generate(@Validated @RequestBody TableGenerateDTO generateDTO){
|
||||
if (generateDTO.getStart() >= generateDTO.getEnd()){
|
||||
return ResponseEntity.badRequest().body("起始数不能大于结束数");
|
||||
}
|
||||
return new ResponseEntity<>(tbShopTableService.generate(generateDTO),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.dto.shoptable;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class BaseTableDTO {
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotEmpty
|
||||
private String tableId;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package cn.ysk.cashier.dto.shoptable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class TableGenerateDTO {
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotEmpty
|
||||
private String sign;
|
||||
private Integer areaId;
|
||||
@Min(1)
|
||||
@NotNull
|
||||
private Integer start;
|
||||
@Min(2)
|
||||
@Max(1000)
|
||||
@NotNull
|
||||
private Integer end;
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer capacity;
|
||||
private Integer autoClear = 1;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopArea;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface MpShopAreaMapper extends BaseMapper<TbShopArea> {
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface MpShopTableService extends IService<TbShopTable> {
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TagProductDepts;
|
||||
import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TagProductDeptsMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
||||
import cn.ysk.cashier.mybatis.service.TagProductDeptsService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ import cn.ysk.cashier.exception.BadRequestException;
|
|||
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
|
|
@ -37,6 +38,7 @@ import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
|||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopArea;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||
|
|
@ -111,6 +113,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final TbShopPayTypeRepository payTypeRepository;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
private final TbShopPayTypeMapper tbShopPayTypeMapper;
|
||||
private final MpShopTableService mpShopTableService;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -122,6 +125,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final TbCashierCartMapper tbCashierCartMapper;
|
||||
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
private final MpShopAreaMapper mpShopAreaMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable) {
|
||||
|
|
@ -1567,7 +1571,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, choseCountDTO.getShopId())
|
||||
.eq(TbCashierCart::getMasterId, choseCountDTO.getMasterId())
|
||||
.eq(TbCashierCart::getProductId, -999)
|
||||
.eq(TbCashierCart::getProductId, "-999")
|
||||
.eq(TbCashierCart::getSkuId, "-999")
|
||||
.eq(TbCashierCart::getTableId, choseCountDTO.getTableId());
|
||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||
|
||||
|
|
@ -1597,4 +1602,65 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
return tbCashierCart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object printOrder(BaseTableDTO baseTableDTO) {
|
||||
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, baseTableDTO.getTableId())
|
||||
.in(TbShopTable::getStatus, TableStateEnum.USING.getState(), TableStateEnum.PAYING.getState(), TableStateEnum.CLEANING.getState()));
|
||||
if (tbShopTable == null) {
|
||||
throw new BadRequestException("台桌不存在或当前台桌未开台");
|
||||
}
|
||||
String currentOrderId = getCurrentOrderId(baseTableDTO.getTableId(), baseTableDTO.getShopId().toString());
|
||||
if (StrUtil.isBlank(currentOrderId)) {
|
||||
throw new BadRequestException("当前台桌不存在订单");
|
||||
}
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectById(currentOrderId);
|
||||
rabbitMsgUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object generate(TableGenerateDTO generateDTO) {
|
||||
TbShopArea shopArea = mpShopAreaMapper.selectOne(new LambdaQueryWrapper<TbShopArea>()
|
||||
.eq(TbShopArea::getShopId, generateDTO.getShopId())
|
||||
.eq(TbShopArea::getId, generateDTO.getAreaId()));
|
||||
if (shopArea == null) {
|
||||
throw new BadRequestException("台桌区域不存在");
|
||||
}
|
||||
|
||||
List<TbShopTable> tbShopTables = mpShopTableMapper.selectList(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getShopId, generateDTO.getShopId())
|
||||
.select(TbShopTable::getName));
|
||||
|
||||
HashMap<String, Object> tableMap = new HashMap<>();
|
||||
tbShopTables.forEach(item -> {
|
||||
tableMap.put(item.getName(), item);
|
||||
});
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
ArrayList<TbShopTable> tableArrayList = new ArrayList<>();
|
||||
for (int i = generateDTO.getStart(); i <= generateDTO.getEnd(); i++) {
|
||||
String name = generateDTO.getSign() + i;
|
||||
if (tableMap.get(name) != null) {
|
||||
msg.append(name).append(";");
|
||||
continue;
|
||||
}
|
||||
TbShopTable shopTable = new TbShopTable();
|
||||
shopTable.setShopId(generateDTO.getShopId());
|
||||
shopTable.setName(name);
|
||||
shopTable.setMaxCapacity(generateDTO.getCapacity());
|
||||
shopTable.setAreaId(generateDTO.getAreaId());
|
||||
shopTable.setCreatedAt(DateUtil.current());
|
||||
shopTable.setStatus(TableStateEnum.CLOSED.getState());
|
||||
tableArrayList.add(shopTable);
|
||||
}
|
||||
|
||||
mpShopTableService.saveBatch(tableArrayList);
|
||||
if (StrUtil.isNotBlank(msg.toString())) {
|
||||
msg.append("台桌名已存在,未添加");
|
||||
throw new BadRequestException(msg.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,4 +130,8 @@ public interface TbShopTableService {
|
|||
Object choseTable(ChoseTableDTO choseTableDTO);
|
||||
|
||||
Object choseCount(ChoseCountDTO choseCountDTO);
|
||||
|
||||
Object printOrder(BaseTableDTO baseTableDTO);
|
||||
|
||||
Object generate(TableGenerateDTO generateDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,4 +54,12 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
|
|||
jsonObject.put("isReturn", true);
|
||||
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_DISHES, jsonObject, "菜品退单", false);
|
||||
}
|
||||
|
||||
public void printPlaceTicket(Integer id, boolean isReturn) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("orderId", id);
|
||||
jsonObject.put("isReturn", isReturn);
|
||||
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_PLACE, jsonObject, "订单打印", false);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue