zj
2025-01-06 0e7b38c2b3af72ea2a7f8a2fcbaad4d78e2c1977
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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<String> 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<String> 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<IPage<SwxOrder>> 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<IPage<SwxSmartOrder>> 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<IPage<SwxBuyOptionsInfo>> 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<SwxBuyOptionsInfo> 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());
        }
    }
}