1.代客下单 挂起订单

This commit is contained in:
SongZhang 2024-08-17 10:03:11 +08:00 committed by 牛叉闪闪
parent 5643faab22
commit 8d73b216ef
5 changed files with 46 additions and 6 deletions

View File

@ -96,9 +96,10 @@ public class TbPlaceController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size,
@RequestParam Integer shopId,
@RequestParam(required = false) Integer vipUserId
@RequestParam(required = false) Integer vipUserId,
@RequestParam String masterId
) {
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId));
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId, masterId));
}
@AnonymousAccess

View File

@ -3,6 +3,7 @@ package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.vo.CarVO;
import cn.ysk.cashier.vo.PendingCountVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -18,4 +19,8 @@ public interface TbCashierCartMapper extends BaseMapper<TbCashierCart> {
" ifnull(sum(total_amount),0) as totalAmount\n" +
" from tb_cashier_cart where table_id is not null and shop_id = #{shopId} and status = 'refund' group by shop_Id, master_id order by trade_day desc")
List<CarVO> selectCar(@Param("shopId") Integer shopId);
@Select(" SELECT order_id orderId, pending_at, sum(total_amount) toalAmount, count(id) totalCount from tb_cashier_cart where status = 'refund' and shop_id=#{shopId} " +
" GROUP BY order_id ORDER BY trade_day")
List<PendingCountVO> countPending(@Param("shopId") Integer shopId);
}

View File

@ -41,6 +41,7 @@ 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.utils.*;
import cn.ysk.cashier.vo.PendingCountVO;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -395,7 +396,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
@Override
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId) {
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page,
Integer size, Integer shopId, Integer vipUserId, String masterId) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getStatus, "create")
@ -404,6 +406,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (vipUserId != null) {
queryWrapper.eq(TbCashierCart::getUserId, vipUserId);
}else {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getUserId);
}
@ -643,7 +646,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
} else {
orderCode = String.valueOf(Integer.parseInt(code.replace("#", "")) + 1);
}
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "#" + Integer.parseInt(code.replace("#", "")) + 2);
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, String.valueOf(Integer.parseInt(orderCode) + 1));
boolean flag = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode));
if (flag) {
return generateOrderCode(day, clientType, shopId);
@ -872,7 +875,24 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public Object getCar(Integer shopId) {
return cashierCartMapper.selectCar(shopId);
ArrayList<HashMap<String, Object>> data = new ArrayList<>();
List<PendingCountVO> pendingCountVOS = cashierCartMapper.countPending(shopId);
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getStatus, "refund"));
HashMap<String, List<TbCashierCart>> cashierMap = new HashMap<>();
for (TbCashierCart tbCashierCart : tbCashierCarts) {
List<TbCashierCart> list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>());
list.add(tbCashierCart);
}
pendingCountVOS.forEach(item -> {
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
map.put("carList", cashierMap.get(item.getOrderId().toString()));
});
return data;
}
@Override

View File

@ -102,7 +102,7 @@ public interface TbShopTableService {
void clearCart(ClearCartDTO clearCartDTO);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId, String masterId);
TbCashierCart updateCart(UpdateCartDTO updateCartDTO);

View File

@ -0,0 +1,14 @@
package cn.ysk.cashier.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.sql.Timestamp;
@Data
public class PendingCountVO {
private Long pendingAt;
private BigDecimal totalAmount;
private Integer totalCount;
private Integer orderId;
}