package com.gear.customer.swx.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.gear.common.constant.SwxConstons; import com.gear.common.exception.CustomerException; import com.gear.common.vo.Result; import com.gear.customer.swx.biz.SwxBizOrder; import com.gear.customer.swx.vo.request.SwxBuyOptionsVo; import com.gear.customer.swx.vo.request.SwxBuySmartVo; import com.gear.customer.swx.vo.response.SwxBuyOptionsInfo; import com.gear.customer.swx.vo.response.SwxSmartOrderVo; import com.gear.swx.domain.SwxOrder; import com.gear.swx.domain.SwxSmartOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; @RestController @RequestMapping("/swx/customer/order") public class SwxCustomerOrderController { @Autowired private SwxBizOrder swxBizOrder; /** * 购买只能交易产品 * @param type * @param canSamrt * @return */ @PostMapping("/buySmart") public Result buySmart(HttpServletRequest request, @RequestBody SwxBuySmartVo vo){ try { String userId =(String) request.getAttribute("userId"); String virtually = (String)request.getAttribute("virtually"); return Result.OK(swxBizOrder.buySmart(vo,userId,virtually)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } /** * 期权购买 */ @PostMapping("/buyOptions") public Result buyOptions(HttpServletRequest request, @RequestBody SwxBuyOptionsVo vo){ try { String userId =(String) request.getAttribute("userId"); String virtually = (String)request.getAttribute("virtually"); if (virtually.equals(SwxConstons.SWX_CUSTOMER_USER_ORDER_TYPE_TRUE)){ return Result.OK(swxBizOrder.buyOptionsTrue(vo,userId,virtually)); }else{ return Result.OK(swxBizOrder.buyOptionsVirtually(vo,userId,virtually)); } }catch (CustomerException e){ return Result.error(e.getMessage()); } } // @GetMapping("/listOrder") // public Result> listOrder(HttpServletRequest request,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, // @RequestParam(name="pageSize", defaultValue="10")Integer pageSize){ // try { // String userId =(String) request.getAttribute("userId"); // String virtually = (String)request.getAttribute("virtually"); // return Result.OK(swxBizOrder.listOrder(userId,virtually,pageNo,pageSize)); // }catch (CustomerException e){ // return Result.error(e.getMessage()); // } // } //用户智能交易订单 @GetMapping("/listSmartOrder") public Result> listSmartOrder(HttpServletRequest request, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10")Integer pageSize){ try { String userId =(String) request.getAttribute("userId"); String virtually = (String)request.getAttribute("virtually"); return Result.OK(swxBizOrder.listSmartOrder(userId,virtually,pageNo,pageSize)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } @GetMapping("/listOptionsOrder") public Result> listOptionsOrder(HttpServletRequest request, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10")Integer pageSize){ try { String userId =(String) request.getAttribute("userId"); String virtually = (String)request.getAttribute("virtually"); return Result.OK(swxBizOrder.listOptionsOrder(userId,virtually,pageNo,pageSize)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } @GetMapping("/getOptionsOrderById/{id}") public Result getOptionsOrderById(HttpServletRequest request,@PathVariable String id){ try { String userId =(String) request.getAttribute("userId"); String virtually = (String)request.getAttribute("virtually"); return Result.OK(swxBizOrder.getOptionsOrderById(userId,virtually,id)); }catch (CustomerException e){ return Result.error(e.getMessage()); } } }