|
|
|
|
@ -30,6 +30,7 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@ -268,4 +269,30 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
ordersUpdate.setCancelTime(LocalDateTime.now());
|
|
|
|
|
orderMapper.update(ordersUpdate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 再来一单
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
public void repetition(Long id) {
|
|
|
|
|
// 根据订单id查询当前订单详情
|
|
|
|
|
List<OrderDetail> orderDetailList = orderDetailMapper.getByOrderId(id);
|
|
|
|
|
|
|
|
|
|
// 查询当前用户id
|
|
|
|
|
Long userId = BaseContext.getCurrentId();
|
|
|
|
|
List<ShoppingCart> shoppingCartList = orderDetailList.stream().map(orderDetail -> {
|
|
|
|
|
ShoppingCart shoppingCart = new ShoppingCart();
|
|
|
|
|
|
|
|
|
|
// 将原订单详情里面的菜品信息重新复制到购物车对象中
|
|
|
|
|
BeanUtils.copyProperties(orderDetail, shoppingCart);
|
|
|
|
|
shoppingCart.setUserId(userId);
|
|
|
|
|
shoppingCart.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
|
|
return shoppingCart;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//将购物车对象批量添加到数据库
|
|
|
|
|
shoppingCartMapper.insertBatch(shoppingCartList);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|