KKSU
2024-09-30 36be00e0f3cbe0d559c646fd2977e6e3a74aa6f9
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
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.xcong.excoin.modules.otc.controller;
 
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.otc.dao.OtcSettingDao;
import com.xcong.excoin.modules.otc.dto.EntrustOrderAddDto;
import com.xcong.excoin.modules.otc.dto.EntrustOrderListDto;
import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder;
import com.xcong.excoin.modules.otc.entity.OtcSetting;
import com.xcong.excoin.modules.otc.service.OtcEntrustOrderService;
import com.xcong.excoin.modules.otc.vo.EntrustListInfoVo;
import com.xcong.excoin.modules.otc.vo.EntrustListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.web3j.abi.datatypes.Int;
 
import javax.validation.Valid;
 
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/api/otcOrder")
@Validated
@Api(value = "OtcEntrustOrderController", tags = "otc委托订单接口类")
public class OtcEntrustOrderController {
 
    private final OtcEntrustOrderService otcEntrustOrderService;
    private final OtcSettingDao otcSettingDao;
 
    @ApiOperation(value = "添加otc委托单", notes = "添加otc委托单")
    @PostMapping(value = "/addEntrustOrder")
    public Result addEntrustOrder(@RequestBody EntrustOrderAddDto addDto) {
        otcEntrustOrderService.add(addDto);
        return Result.ok("添加成功");
    }
 
    @ApiOperation(value = "获取市商条件")
    @ApiResponses({
            @ApiResponse(code  = 200, message = "success", response = OtcSetting.class)
    })
    @GetMapping(value = "/findCondition")
    public Result findCondition() {
        OtcSetting setting = otcSettingDao.selectById(1L);
        return Result.ok(setting);
    }
 
    @ApiOperation(value = "编辑otc委托单", notes = "编辑otc委托单")
    @PostMapping(value = "/modifyEntrustOrder")
    public Result modifyEntrustOrder(@RequestBody EntrustOrderAddDto modifyDto) {
        otcEntrustOrderService.modify(modifyDto);
        return Result.ok("编辑成功");
    }
 
    @ApiOperation(value = "获取otc委托单列表", notes = "获取otc委托单列表")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = EntrustListVo.class)
    })
    @PostMapping(value = "/findEntrustOrderList")
    public Result findEntrustOrderList(@RequestBody EntrustOrderListDto orderListDto) {
        IPage<EntrustListVo> result = this.otcEntrustOrderService.findEntrustListInPage(orderListDto);
        return Result.ok(result.getRecords());
    }
 
    @ApiOperation(value = "获取我的委托单列表", notes = "获取我的委托单列表")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = EntrustListInfoVo.class)
    })
    @PostMapping(value = "/findOwnEntrustOrderList")
    public Result findOwnEntrustOrderList(@RequestBody EntrustOrderListDto orderListDto) {
        return Result.ok(otcEntrustOrderService.findOwnEntrustOrder(orderListDto));
    }
 
    @ApiOperation(value = "获取我的委托单详情")
    @GetMapping(value = "/findOwnOrderDetail/{id}")
    public Result findOwnOrderDetail(@PathVariable("id") Long id) {
        return otcEntrustOrderService.findEntrustOrderDetail(id);
    }
 
    @ApiOperation(value = "上/下线接口")
    @PostMapping(value = "/upOrDownList/{id}")
    public Result upOrDownList(@PathVariable("id") Long id) {
        MemberEntity member = LoginUserUtils.getAppLoginUser();
        OtcEntrustOrder otcEntrustOrder = this.otcEntrustOrderService.getById(id);
        if (otcEntrustOrder == null) {
            return Result.fail("数据不存在");
        }
 
        if (!member.getId().equals(otcEntrustOrder.getMemberId())) {
            return Result.fail("数据错误");
        }
 
        Integer status = otcEntrustOrder.getStatus();
        otcEntrustOrder = new OtcEntrustOrder();
        otcEntrustOrder.setId(id);
        if (status.equals(OtcEntrustOrder.LINE_DOWN)) {
            otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_UP);
        } else {
            otcEntrustOrder.setStatus(OtcEntrustOrder.LINE_DOWN);
        }
 
        this.otcEntrustOrderService.updateById(otcEntrustOrder);
        return Result.ok("修改成功");
    }
 
    @ApiOperation(value = "撤销委托单")
    @PostMapping(value = "/cancelOrder/{id}")
    public Result cancelOrder(@PathVariable("id") Long id) {
        this.otcEntrustOrderService.cancelEntrustOrder(id);
        return Result.ok("撤销成功");
    }
 
}