Authored by tanling

no message

... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.OrderDetailInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -65,7 +66,46 @@ public class BuyerOrderController {
.orderCode(orderCode)
.tabType(tabType)
.build();
OrderDetailInfo orderDetailInfo = buyerOrderService.getOrderDetail(orderRequest);
return null;
return new ApiResponse.ApiResponseBuilder().code(200).data(orderDetailInfo).message("订单详情").build();
}
/**
* 取消订单
*/
@RequestMapping(params = "method=app.buyer.cancel")
@ResponseBody
public ApiResponse cancel(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid) {
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.orderCode(orderCode)
.build();
buyerOrderService.cancel(orderRequest);
return new ApiResponse.ApiResponseBuilder().code(200).message("取消").build();
}
/**
* 确认收货
* @param orderCode
* @param uid
* @return
*/
@RequestMapping(params = "method=app.buyer.confirm")
@ResponseBody
public ApiResponse confirm(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid) {
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.orderCode(orderCode)
.build();
buyerOrderService.confirm(orderRequest);
return new ApiResponse.ApiResponseBuilder().code(200).message("取消").build();
}
}
... ...
... ... @@ -54,4 +54,6 @@ public class ShoppingController {
}
... ...
package com.yohoufo.order.service;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.OrderDetailInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
public interface IBuyerOrderService {
... ... @@ -11,5 +13,27 @@ public interface IBuyerOrderService {
* @param request
* @return
*/
public OrderListInfoRsp getOrderList(OrderListRequest request);
OrderListInfoRsp getOrderList(OrderListRequest request);
/**
* 获取订单详情
* @param orderRequest
* @return
*/
OrderDetailInfo getOrderDetail(OrderRequest orderRequest);
/**
* 取消订单
* @param orderRequest
*/
public void cancel(OrderRequest orderRequest);
/**
* 提交订单
* @param orderRequest
*/
public void confirm(OrderRequest orderRequest);
}
... ...
... ... @@ -49,6 +49,73 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
BuyerOrderMetaMapper buyerOrderMetaMapper;
/**
* 提交订单
* @param orderRequest
*/
public void confirm(OrderRequest orderRequest){
// 参数检查 ![待收货] 不合法
checkStatusAndRequest(orderRequest, OrderStatus.WAITING_RECEIVE);
// TODO 更新状态为待收货
}
/**
* 取消订单
* @param orderRequest
*/
public void cancel(OrderRequest orderRequest){
// 状态 ![待付款] 不合法
checkStatusAndRequest(orderRequest, OrderStatus.WAITING_PAY);
// TODO
// 更新订单状态
// 更新skup的状态[可售] 卖家订单为[出售中]
// 减product skup的库存
}
/**
*
* @param orderRequest
* @param orderStatusEx
*/
private void checkStatusAndRequest(OrderRequest orderRequest, OrderStatus orderStatusEx ) {
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
logger.warn("check uid or orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
// 订单存在 & 待付款的状态
// 查询订单状态
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderRequest.getOrderCode(), orderRequest.getUid());
if (buyerOrder == null){
logger.warn("check orderCode exist, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode() );
throw new ServiceException(ServiceError.ORDER_NULL);
}
// 检查 订单状态
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
if (orderStatus == null || orderStatus.getCode() != orderStatusEx.getCode()){
logger.warn("check status invalidate, uid is {}, orderCode is {}, status is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}
/**
* 获取订单详情
* @param orderRequest
* @return
*/
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest){
// 参数检查
... ...
... ... @@ -146,6 +146,8 @@ public class ShoppingServiceImpl implements IShoppingService {
ordeCreationService.doSumbitOrder(orderBuilder);
// TODO 订单成功以后,开启15分取消消息
// 返回结果
return OrderSubmitResponse.builder().orderCode(orderCode).paymentStatus(OrderConstant.N_STR).build();
... ...