首页 > 买家订单模块—订单详情和取消订单api改进

如何指导亚马逊买家取消订单,买家订单模块—订单详情和取消订单api改进

互联网 2021-05-11 19:10:41

买家订单模块—订单详情和取消订单api改进 方法一: 在service层添加:BuyerService和BuyerServiceImpl BuyerService

package com.hdc.sell.service;import com.hdc.sell.dto.OrderDTO;public interface BuyerService {//查询订单OrderDTO findOrderOne(String openid,String orderId);//取消订单OrderDTO cancelOrder(String openid,String orderId);}

BuyerServiceImpl

package com.hdc.sell.service.impl;import com.hdc.sell.dto.OrderDTO;import com.hdc.sell.enums.ResultEnum;import com.hdc.sell.exception.SellException;import com.hdc.sell.service.BuyerService;import com.hdc.sell.service.OrderService;import lombok.extern.slf4j.Slf4j;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;@Service@Slf4jpublic class BuyerServiceImpl implements BuyerService { @Autowired private OrderService orderService;@Overridepublic OrderDTO findOrderOne(String openid, String orderId) {OrderDTO orderDTO=checkOrderOwner(openid,orderId);return orderDTO;}private OrderDTO checkOrderOwner(String openid, String orderId) {OrderDTO orderDTO = orderService.findOne(orderId);if(orderDTO == null){return null;}if(!orderDTO.getBuyerOpenid().equalsIgnoreCase(openid)){log.error("[查询订单]订单的openid不一致,openid={},orderDTO={}",openid,orderDTO);throw new SellException(ResultEnum.ORDER_OWNER_ERROR);}return orderDTO;}@Overridepublic OrderDTO cancelOrder(String openid, String orderId) {OrderDTO orderDTO=checkOrderOwner(openid,orderId);if (orderDTO==null){log.error("[取消订单]查不到该订单,orderId={}",openid);throw new SellException(ResultEnum.ORDER_NOT_EXIST);}return orderService.cancel(orderDTO);}}

BuyerOrderController

//3.查询订单详情api:/buyer/order/detail@GetMapping("/detail")public ResultVO detail(@RequestParam("openid") String openid, @RequestParam("orderId") String orderId){OrderDTO orderDTO=buyerService.findOrderOne(openid,orderId);return ResultVOUtil.success(orderDTO);}//4.取消订单api:/buyer/order/cancel@PostMapping("cancel")public ResultVO cancel(@RequestParam("openid") String openid, @RequestParam("orderId") String orderId){//根据orderid查询订单对象 // OrderDTO orderDTO=orderService.findOne(orderId);//取消订单buyerService.cancelOrder(openid,orderId);return ResultVOUtil.success();}

开头加上buyerService容器注解 在这里插入图片描述 ResultEnum 中写入 在这里插入图片描述

免责声明:非本网注明原创的信息,皆为程序自动获取自互联网,目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责;如此页面有侵犯到您的权益,请给站长发送邮件,并提供相关证明(版权证明、身份证正反面、侵权链接),站长将在收到邮件24小时内删除。

相关阅读