|
|
@ -9,6 +9,7 @@ import com.wyz.demo.service.OrderService; |
|
|
|
import com.wyz.demo.vo.CommonOrderVO; |
|
|
|
import com.wyz.demo.vo.DetailOrderVO; |
|
|
|
import com.wyz.demo.vo.SelfOrderVO; |
|
|
|
import com.wyz.demo.vo.SelfPickedOrderVO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -35,19 +36,18 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
@Override |
|
|
|
public List<SelfOrderVO> getOrdersByUsername(String username) { |
|
|
|
int sender_id = userRepository.getIdByUsername(username); |
|
|
|
List<OrderPO> orders = orderRepository.getOrdersByUserId(sender_id); |
|
|
|
List<OrderPO> orders = orderRepository.getOrdersBySenderId(sender_id); |
|
|
|
|
|
|
|
|
|
|
|
List<SelfOrderVO> res = new ArrayList<>(); |
|
|
|
for (OrderPO orderPO : orders) { |
|
|
|
SelfOrderVO orderVO = new SelfOrderVO(); |
|
|
|
|
|
|
|
orderVO.setId(orderPO.getId()); |
|
|
|
orderVO.setTimestamp(orderPO.getTimestamp()); |
|
|
|
orderVO.setDescription(orderPO.getDescription()); |
|
|
|
orderVO.setPrice(orderPO.getPrice()); |
|
|
|
String receiver = userRepository.getUsernameById(orderPO.getReceiverId()); |
|
|
|
// log.info("receiver-id:{}",orderPO.getReceiverId());
|
|
|
|
// log.info("receiver:{}",receiver);
|
|
|
|
orderVO.setReceiver(receiver); |
|
|
|
orderVO.setStatus(orderPO.getStatus()); |
|
|
|
|
|
|
@ -58,6 +58,33 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取某个用户全部接单 |
|
|
|
* @param username |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<SelfPickedOrderVO> getPickedOrdersByUsername(String username){ |
|
|
|
int receiver_id = userRepository.getIdByUsername(username); |
|
|
|
List<OrderPO> orders = orderRepository.getOrdersByReceiverId(receiver_id); |
|
|
|
|
|
|
|
List<SelfPickedOrderVO> res = new ArrayList<>(); |
|
|
|
for (OrderPO orderPO : orders) { |
|
|
|
SelfPickedOrderVO orderVO = new SelfPickedOrderVO(); |
|
|
|
|
|
|
|
orderVO.setId(orderPO.getId()); |
|
|
|
orderVO.setTimestamp(orderPO.getTimestamp()); |
|
|
|
orderVO.setDescription(orderPO.getDescription()); |
|
|
|
orderVO.setPrice(orderPO.getPrice()); |
|
|
|
String sender = userRepository.getUsernameById(orderPO.getSenderId()); |
|
|
|
orderVO.setSender(sender); |
|
|
|
orderVO.setStatus(orderPO.getStatus()); |
|
|
|
|
|
|
|
res.add(orderVO); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void addOrder(OrderDTO orderDTO, HttpSession sess) { |
|
|
|
|
|
|
@ -125,5 +152,29 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
orderRepository.pickOrder(order_id, receiver_id); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void cancelPickedOrder(int order_id) { |
|
|
|
orderRepository.cancelPickedOrder(order_id); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void confirmPickedOrder(int order_id) { |
|
|
|
orderRepository.confirmPickedOrder(order_id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 下单者-取消订单 |
|
|
|
*/ |
|
|
|
public void cancelOrder(int order_id){ |
|
|
|
orderRepository.cancelOrder(order_id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 下单者-确认完成 |
|
|
|
*/ |
|
|
|
public void confirmOrder(int order_id){ |
|
|
|
orderRepository.confirmOrder(order_id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |