1.代客下单 已下单商品不支持删除
This commit is contained in:
@@ -73,6 +73,6 @@ public interface TbCashierCartMapper {
|
||||
@Delete("delete from tb_cashier_cart where master_id=#{masterId} and id=#{cartId}")
|
||||
int deleteByCartId(@Param("masterId") String masterId, @Param("cartId")Integer cartId);
|
||||
|
||||
@Select("select count(*) from tb_cashier_cart where shop_id=#{shopId} and `status`='create' and table_id=#{qrcode}")
|
||||
@Select("select count(*) from tb_cashier_cart where shop_id=#{shopId} and `status`='create' and table_id=#{qrcode} and order_id is not null")
|
||||
int countTable(@Param("qrcode") String qrcode, @Param("shopId") Integer shopId);
|
||||
}
|
||||
|
||||
@@ -464,6 +464,10 @@ public class OrderService {
|
||||
return Result.fail(CodeEnum.CARTEXIST);
|
||||
}
|
||||
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
return Result.success(CodeEnum.SUCCESS, "已打票商品不支持删除", null);
|
||||
}
|
||||
|
||||
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if(ObjectUtil.isEmpty(product)){
|
||||
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
||||
@@ -488,31 +492,10 @@ public class OrderService {
|
||||
List<String> skuIds=new ArrayList<>();
|
||||
skuIds.add(cashierCart.getSkuId());
|
||||
|
||||
|
||||
|
||||
cashierCartMapper.deleteByPrimaryKey(cartId);
|
||||
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
int list = mpCashierCartMapper.selectCount( new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, cashierCart.getShopId())
|
||||
.eq(TbCashierCart::getStatus, "create").eq(TbCashierCart::getTableId, cashierCart.getTableId())
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, cashierCart.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.or()
|
||||
.eq(TbCashierCart::getMasterId, "")
|
||||
.or()
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
}));
|
||||
|
||||
if (list == 0) {
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cashierCart.getOrderId()));
|
||||
}
|
||||
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1100,8 +1083,10 @@ public class OrderService {
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
if (StrUtil.isNotBlank(cashierCart.getOrderId()) && StrUtil.isNotBlank(cashierCart.getTableId())) {
|
||||
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||
continue;
|
||||
}
|
||||
|
||||
ids.add(cashierCart.getId());
|
||||
// 数量减少, 返还库存
|
||||
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
|
||||
@@ -1110,10 +1095,7 @@ public class OrderService {
|
||||
if (message != null) {
|
||||
productService.incrStock(cashierCart.getProductId(), cashierCart.getSkuId(), Integer.parseInt(message));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||
|
||||
}
|
||||
TbProductWithBLOBs product= tbProductMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getProductId()));
|
||||
if(ObjectUtil.isNotEmpty(product)&&"1".equals(product.getIsStock().toString())){
|
||||
ProductSkuPo skuPo=new ProductSkuPo(Integer.valueOf(cashierCart.getSkuId()),cashierCart.getTotalNumber());
|
||||
@@ -1124,7 +1106,14 @@ public class OrderService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (orderId > 0) {
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
if (ids.isEmpty() && "postPay".equals(orderInfo.getUseType())) {
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
// 返还耗材
|
||||
JSONObject jsonObject1=new JSONObject();
|
||||
jsonObject1.put("orderId", orderId);
|
||||
@@ -1132,12 +1121,16 @@ public class OrderService {
|
||||
log.info("清空购物车 发送返还耗材mq消息,订单id:{},消息内容:{}", orderId, jsonObject1);
|
||||
producer.cons(jsonObject1.toString());
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
if (Objects.nonNull(orderInfo) && !orderInfo.getStatus().equals("pending")){
|
||||
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
||||
// orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
||||
orderDetailMapper.deleteByOUrderId(orderId);
|
||||
}
|
||||
|
||||
|
||||
if ("postPay".equals(orderInfo.getUseType())) {
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(orderId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1217,13 +1210,13 @@ public class OrderService {
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
|
||||
|
||||
OrderVo orderVo = new OrderVo();
|
||||
orderVo.setMasterId(orderInfo.getMasterId());
|
||||
orderVo.setShopId(Integer.valueOf(orderInfo.getShopId()));
|
||||
orderVo.setTableId(orderInfo.getTableId());
|
||||
orderVo.setMerchantId(Integer.valueOf(userId));
|
||||
createOrder(orderVo, clientType, token, id, false);
|
||||
orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
|
||||
// OrderVo orderVo = new OrderVo();
|
||||
// orderVo.setMasterId(orderInfo.getMasterId());
|
||||
// orderVo.setShopId(Integer.valueOf(orderInfo.getShopId()));
|
||||
// orderVo.setTableId(orderInfo.getTableId());
|
||||
// orderVo.setMerchantId(Integer.valueOf(userId));
|
||||
// createOrder(orderVo, clientType, token, id, false);
|
||||
// orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
|
||||
|
||||
if (Objects.nonNull(orderInfo)) {
|
||||
List<TbOrderDetail> list = orderDetailMapper.selectAllByOrderId(id);
|
||||
|
||||
@@ -229,9 +229,8 @@
|
||||
|
||||
</select>
|
||||
<select id="selectTableInfo" resultType="com.chaozhanggui.system.cashierservice.entity.vo.TbShopTableVO">
|
||||
select a.*, b.user_id, c.master_id, c.id as orderId, c.order_no as orderNo, c.amount as orderAmount from tb_shop_table a
|
||||
left join tb_order_info b on a.qrcode=b.table_id and (b.`status`='unpaid') and b.user_id is not null and b.shop_id=#{shopId} and b.trade_day=#{day} and b.use_type='postPay'
|
||||
left join tb_order_info c on a.qrcode=c.table_id and (c.`status`='unpaid') and c.master_id is not null and c.shop_id=#{shopId} and c.trade_day=#{day} and c.use_type='postPay'
|
||||
select a.*, b.user_id, b.master_id, b.id as orderId, b.order_no as orderNo, b.amount as orderAmount from tb_shop_table a
|
||||
left join tb_order_info b on a.qrcode=b.table_id and (b.`status`='unpaid') and b.master_id is not null and b.shop_id=#{shopId} and b.trade_day=#{day} and b.use_type='postPay' and b.order_type='cash'
|
||||
where a.shop_id=#{shopId}
|
||||
<if test="areaId != null and areaId !=''">
|
||||
and a.area_id = #{areaId}
|
||||
|
||||
Reference in New Issue
Block a user