Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -21,6 +21,11 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>2.8.3</version>
|
||||
</dependency>
|
||||
<!-- zxing生成二维码 -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
@@ -210,10 +215,6 @@
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.chaozhanggui.system.cashierservice.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MyBatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,14 @@ public class OrderController {
|
||||
return orderService.createOrder(orderVo, clientType, token, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转台并台
|
||||
*/
|
||||
@PutMapping("/switch")
|
||||
public Result switchTable(@Validated @RequestBody SwitchTableDTO switchTableDTO, @RequestHeader("token") String token) {
|
||||
return Result.success(CodeEnum.SUCCESS, orderService.switchTable(switchTableDTO, token));
|
||||
}
|
||||
|
||||
@PostMapping("/createBackOrder")
|
||||
public Result createBackOrder(@RequestHeader("token") String token,
|
||||
@RequestHeader("loginName") String loginName,
|
||||
|
||||
@@ -5,9 +5,13 @@ import com.chaozhanggui.system.cashierservice.entity.dto.ClearTableDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ShopInfoService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.AliUploadUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@@ -78,4 +82,9 @@ public class ShopInfoController {
|
||||
public Result queryPwdInfo(@RequestParam("shopId") String shopId) {
|
||||
return shopInfoService.queryShopPwdInfo(shopId);
|
||||
}
|
||||
|
||||
@PostMapping("upload")
|
||||
public Result upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
return Result.success(CodeEnum.SUCCESS, AliUploadUtils.uploadSuffix(file.getInputStream(), file.getOriginalFilename()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class TbShopPermission extends Model<TbShopPermission> {
|
||||
* @return 主键值
|
||||
*/
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
public Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class TbShopStaffPermission extends Model<TbShopStaffPermission> {
|
||||
* @return 主键值
|
||||
*/
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
public Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
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;
|
||||
private Integer orderId;
|
||||
private List<Integer> cartIds;
|
||||
private Boolean isFull;
|
||||
@NotEmpty(message = "当前台桌id不为空")
|
||||
private String currentTableId;
|
||||
@NotEmpty(message = "目标台桌id不为空")
|
||||
private String targetTableId;
|
||||
}
|
||||
@@ -7,6 +7,6 @@ import lombok.EqualsAndHashCode;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class CallRecordVO extends TbCallQueue {
|
||||
private String note;
|
||||
private String tableNote;
|
||||
private Long sinceAt;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,15 @@ public class CustomFilter implements Filter {
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
log.info(">>>> customFilter init <<<<");
|
||||
}
|
||||
|
||||
public boolean isMultipartRequest(HttpServletRequest request) {
|
||||
String contentType = request.getContentType();
|
||||
return contentType != null && contentType.toLowerCase().startsWith("multipart/form-data");
|
||||
}
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
log.info(">>>> customFilter doFilter start <<<<");
|
||||
RequestWrapper requestWapper = null;
|
||||
if (servletRequest instanceof HttpServletRequest) {
|
||||
if (servletRequest instanceof HttpServletRequest && !isMultipartRequest((HttpServletRequest)servletRequest)) {
|
||||
requestWapper = new RequestWrapper((HttpServletRequest) servletRequest);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.chaozhanggui.system.cashierservice.interceptor;
|
||||
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -9,73 +11,70 @@ import java.io.*;
|
||||
public class RequestWrapper extends HttpServletRequestWrapper {
|
||||
private final String body;
|
||||
|
||||
public RequestWrapper(HttpServletRequest request) {
|
||||
public RequestWrapper(HttpServletRequest request) throws IOException {
|
||||
super(request);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
BufferedReader bufferedReader = null;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
|
||||
// 仅处理普通请求体,不影响multipart请求
|
||||
if (!(request instanceof MultipartHttpServletRequest)) {
|
||||
inputStream = request.getInputStream();
|
||||
if (inputStream != null) {
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
char[] charBuffer = new char[128];
|
||||
int bytesRead = -1;
|
||||
int bytesRead;
|
||||
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
|
||||
stringBuilder.append(charBuffer, 0, bytesRead);
|
||||
}
|
||||
} else {
|
||||
stringBuilder.append("");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bufferedReader != null) {
|
||||
try {
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
body = stringBuilder.toString();
|
||||
} else {
|
||||
// 如果是Multipart请求,不做处理,直接返回
|
||||
body = null;
|
||||
}
|
||||
body = stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
||||
ServletInputStream servletInputStream = new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
return servletInputStream;
|
||||
if (body != null) {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return byteArrayInputStream.available() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return byteArrayInputStream.available() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// 如果是Multipart请求,返回空的输入流,交给Spring处理
|
||||
return super.getInputStream();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws IOException {
|
||||
return new BufferedReader(new InputStreamReader(this.getInputStream()));
|
||||
if (body != null) {
|
||||
return new BufferedReader(new InputStreamReader(this.getInputStream()));
|
||||
} else {
|
||||
// 如果是Multipart请求,返回空的reader
|
||||
return super.getReader();
|
||||
}
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -121,7 +122,7 @@ public class SignInterceptor implements HandlerInterceptor {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> getParameterMap(HttpServletRequest request) {
|
||||
private Map<String, Object> getParameterMap(HttpServletRequest request) throws IOException {
|
||||
RequestWrapper requestWrapper = new RequestWrapper(request);
|
||||
String body = requestWrapper.getBody();
|
||||
if (ObjectUtil.isNotEmpty(body)) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
*/
|
||||
public interface TbCallQueueMapper extends BaseMapper<TbCallQueue> {
|
||||
|
||||
@Select("select a.*, b.note, TIMESTAMPDIFF(SECOND, a.create_time, NOW()) as since_at from tb_call_queue a " +
|
||||
@Select("select a.*, b.note as tableNote, TIMESTAMPDIFF(SECOND, a.create_time, NOW()) as since_at from tb_call_queue a " +
|
||||
"left join tb_call_table b on a.call_table_id=b.id " +
|
||||
"where a.shop_id=#{shopId} and a.state in (3, 2, 1) order by a.create_time desc")
|
||||
Page<CallRecordVO> selectCallRecord(Integer shopId, Integer callTableId, Page<Object> objectPage);
|
||||
|
||||
@@ -61,5 +61,17 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
||||
* @param statuses 状态
|
||||
*/
|
||||
List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,5 +15,12 @@ import java.util.List;
|
||||
*/
|
||||
public interface MpShopTableService extends IService<TbShopTable> {
|
||||
|
||||
/**
|
||||
* 查询台桌信息
|
||||
* @param tableId 台桌id
|
||||
* @param shopId 店铺id
|
||||
* @return 台桌信息
|
||||
*/
|
||||
TbShopTable selectByTableId(String tableId, Integer shopId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1204,6 +1204,10 @@ public class OrderService {
|
||||
// 代课下单
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||
.set(TbShopTable::getProductNum, cashierIds.isEmpty() ? 0 : cashierIds.size())
|
||||
.set(TbShopTable::getTotalAmount, orderInfo.getOrderAmount())
|
||||
.set(TbShopTable::getRealAmount, orderInfo.getOrderAmount())
|
||||
.set(TbShopTable::getUseNum, mealNum)
|
||||
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
||||
|
||||
// 打印票据
|
||||
@@ -2392,4 +2396,126 @@ public class OrderService {
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Object switchTable(SwitchTableDTO switchTableDTO, String token) {
|
||||
// 查询当前台桌信息
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(switchTableDTO.getShopId(), switchTableDTO.getCurrentTableId());
|
||||
ShopEatTypeInfoDTO targetShopEatTypeInfoDTO = checkEatModel(switchTableDTO.getShopId(), switchTableDTO.getTargetTableId());
|
||||
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
throw new MsgException("仅后付费模式支持转台");
|
||||
}
|
||||
TbShopTable shopTable = mpShopTableService.selectByTableId(switchTableDTO.getTargetTableId(), switchTableDTO.getShopId());
|
||||
if (shopTable == null) {
|
||||
throw new MsgException("目标台桌信息不存在");
|
||||
}
|
||||
|
||||
if (TableConstant.ShopTable.State.CLEANING.getValue().equals(shopTable.getStatus())) {
|
||||
throw new MsgException("当前台桌清理中,不能转台");
|
||||
}
|
||||
|
||||
List<TbCashierCart> cashierCarts;
|
||||
long totalSize = 99999;
|
||||
if (switchTableDTO.getIsFull() != null && switchTableDTO.getIsFull()) {
|
||||
cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO, switchTableDTO.getMasterId(), switchTableDTO.getOrderId(),
|
||||
true, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
|
||||
}else {
|
||||
if (switchTableDTO.getCartIds().isEmpty()) {
|
||||
throw new MsgException("请选择转单商品");
|
||||
}
|
||||
|
||||
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 MsgException("当前台桌购物车为空");
|
||||
}
|
||||
|
||||
String masterId = ((JSONObject)createCode(switchTableDTO.getShopId().toString(), "pc", "", "0", switchTableDTO.getTargetTableId()).getData()).getString("code");
|
||||
// String masterId = getMasterId(switchTableDTO.getShopId(), switchTableDTO.getTargetTableId(), 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();
|
||||
}
|
||||
}
|
||||
|
||||
// 修改原有购物车数据
|
||||
ArrayList<Integer> cartIds = new ArrayList<>();
|
||||
Integer orderId = switchTableDTO.getOrderId();
|
||||
TbCashierCart currentSeatFee = null;
|
||||
ArrayList<TbCashierCart> updateCartInfos = new ArrayList<>();
|
||||
for (TbCashierCart item : cashierCarts) {
|
||||
if (targetSeatFee == null || !TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
|
||||
item.setTableId(switchTableDTO.getTargetTableId());
|
||||
item.setMasterId(masterId);
|
||||
updateCartInfos.add(item);
|
||||
}
|
||||
cartIds.add(item.getId());
|
||||
|
||||
if (item.getOrderId() != null) {
|
||||
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.getIsFull() != null && switchTableDTO.getIsFull()) || switchTableDTO.getCartIds().size() == totalSize)) {
|
||||
mpOrderInfoService.removeById(orderId);
|
||||
}
|
||||
|
||||
if (switchTableDTO.getIsFull() != null && !switchTableDTO.getIsFull() && switchTableDTO.getCartIds().size() != totalSize){
|
||||
// 重新创建订单数据
|
||||
OrderVo createOrderDTO = new OrderVo();
|
||||
createOrderDTO.setMasterId(switchTableDTO.getMasterId());
|
||||
createOrderDTO.setShopId(switchTableDTO.getShopId());
|
||||
createOrderDTO.setTableId(switchTableDTO.getCurrentTableId());
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
String userId = jsonObject.getString("accountId");
|
||||
createOrderDTO.setMerchantId(Integer.valueOf(userId));
|
||||
createOrder(createOrderDTO, "pc", token, switchTableDTO.getOrderId());
|
||||
}
|
||||
|
||||
if (targetOrderId != null) {
|
||||
// 重新创建订单数据
|
||||
OrderVo createOrderDTO = new OrderVo();
|
||||
createOrderDTO.setMasterId(masterId);
|
||||
createOrderDTO.setShopId(switchTableDTO.getShopId());
|
||||
createOrderDTO.setTableId(switchTableDTO.getTargetTableId());
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
String userId = jsonObject.getString("accountId");
|
||||
createOrderDTO.setMerchantId(Integer.valueOf(userId));
|
||||
createOrder(createOrderDTO, "pc", token, targetOrderId);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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 com.chaozhanggui.system.cashierservice.bean.OrderPlatformTypeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
@@ -17,8 +19,10 @@ import com.chaozhanggui.system.cashierservice.service.MpCashierCartService;
|
||||
import com.chaozhanggui.system.cashierservice.service.MpOrderDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务实现类
|
||||
@@ -96,7 +100,9 @@ public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, 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);
|
||||
}
|
||||
@@ -104,13 +110,99 @@ public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
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())
|
||||
.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 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 (long) count(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
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 com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||
@@ -22,6 +23,12 @@ import java.util.List;
|
||||
@Service
|
||||
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
||||
|
||||
@Override
|
||||
public TbShopTable selectByTableId(String tableId, Integer shopId) {
|
||||
return getOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getShopId, shopId)
|
||||
.eq(TbShopTable::getQrcode, tableId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -494,7 +494,8 @@ public class TbCallServiceImpl implements TbCallService {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
LambdaQueryChainWrapper<TbCallQueue> query = callQueueService.lambdaQuery()
|
||||
|
||||
LambdaQueryWrapper<TbCallQueue> query = new LambdaQueryWrapper<TbCallQueue>()
|
||||
.eq(TbCallQueue::getShopId, shopId)
|
||||
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||
.in(TbCallQueue::getCallTableId, tableIds);
|
||||
@@ -504,10 +505,10 @@ public class TbCallServiceImpl implements TbCallService {
|
||||
}else {
|
||||
query.in(TbCallQueue::getState, 0, 1);
|
||||
}
|
||||
Page<TbCallQueue> pageInfo = query
|
||||
.orderByAsc(TbCallQueue::getCreateTime)
|
||||
.orderByDesc(TbCallQueue::getState)
|
||||
.page(new Page<>(page, size));
|
||||
|
||||
Page<TbCallQueue> pageInfo = callQueueService.page(new Page<>(page, size),
|
||||
query.orderByAsc(TbCallQueue::getCreateTime)
|
||||
.orderByDesc(TbCallQueue::getState));
|
||||
|
||||
List<TbCallQueue> list1 = pageInfo.getRecords();
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* Copyright (c) 2018 人人开源 All rights reserved.
|
||||
*
|
||||
* https://www.renren.io
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 阿里云存储
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@Component
|
||||
public class AliUploadUtils {
|
||||
private static String secret;
|
||||
private static String key;
|
||||
private static String endPoint;
|
||||
private static String bucketName;
|
||||
private static String prefix;
|
||||
private static String url;
|
||||
|
||||
// 构造器注入
|
||||
public AliUploadUtils(@Value("${aliyun.keysecret}") String secret,
|
||||
@Value("${aliyun.keyid}") String key,
|
||||
@Value("${aliyun.oss.endpoint}") String endPoint,
|
||||
@Value("${aliyun.oss.bucketname}") String bucketName,
|
||||
@Value("${aliyun.prefix}") String prefix,
|
||||
@Value("${aliyun.url}") String url) {
|
||||
AliUploadUtils.secret = secret;
|
||||
AliUploadUtils.key = key;
|
||||
AliUploadUtils.endPoint = endPoint;
|
||||
AliUploadUtils.bucketName = bucketName;
|
||||
AliUploadUtils.prefix = prefix;
|
||||
AliUploadUtils.url = url;
|
||||
}
|
||||
/**
|
||||
* 文件路径
|
||||
* @param prefix 前缀
|
||||
* @param suffix 后缀
|
||||
* @return 返回上传路径
|
||||
*/
|
||||
public static String getPath(String prefix, String suffix) {
|
||||
//生成uuid
|
||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
//文件路径
|
||||
String path = DateUtils.getDays() + "/" + uuid;
|
||||
|
||||
if(StringUtils.isNotBlank(prefix)){
|
||||
path = prefix + "/" + path;
|
||||
}
|
||||
|
||||
return path + "." + suffix;
|
||||
}
|
||||
|
||||
|
||||
public static String upload(InputStream inputStream, String path) throws Exception {
|
||||
OSSClient client = new OSSClient(endPoint, key,
|
||||
secret);
|
||||
try {
|
||||
client.putObject(bucketName, path, inputStream);
|
||||
client.shutdown();
|
||||
} catch (Exception e){
|
||||
throw new Exception("上传异常");
|
||||
}
|
||||
|
||||
return "https://"+ url + "/" + path;
|
||||
}
|
||||
|
||||
|
||||
public static String uploadSuffix(InputStream inputStream, String fileName) throws Exception {
|
||||
return upload(inputStream, getPath(prefix, getFileExtension(fileName)));
|
||||
}
|
||||
|
||||
public static String getFileExtension(String fileName) {
|
||||
int dotIndex = fileName.lastIndexOf(".");
|
||||
if (dotIndex > 0) {
|
||||
return fileName.substring(dotIndex).replace(".", "");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,3 +83,13 @@ mybatis-plus:
|
||||
|
||||
# php服务器地址
|
||||
phpServer: https://czgdoumei.sxczgkj.com/index.php/api
|
||||
|
||||
# oss配置
|
||||
aliyun:
|
||||
prefix: upload
|
||||
keyid: LTAI5tPdEfYSZcqHbjCrtPRD
|
||||
keysecret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy
|
||||
url: cashier-oss.oss-cn-beijing.aliyuncs.com
|
||||
oss:
|
||||
bucketname: cashier-oss
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
|
||||
Reference in New Issue
Block a user