fix
Helius
2021-11-04 08533cfc3bcd964ba89b12abe55010619d6cfdbb
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
123
124
125
126
127
128
package com.xcong.excoin.modules.home.controller;
 
import javax.annotation.Resource;
import javax.validation.Valid;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.alibaba.druid.util.StringUtils;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto;
import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
import com.xcong.excoin.modules.home.service.MemberQuickBuySaleService;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.member.service.MemberService;
 
import cn.hutool.crypto.SecureUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
 
@RestController
@Slf4j
@RequestMapping(value = "/api/quick")
@Api(value = "MemberQuickBuySaleController", tags = "USDT快捷买卖类")
public class MemberQuickBuySaleController {
 
    @Autowired
    MemberQuickBuySaleService memberQuickBuySaleService;
    @Autowired
    MemberService memberService;
 
    @ApiOperation(value = "recharge", notes = "USDT快速充值")
    @RequestMapping(value = "/recharge", method = RequestMethod.POST)
    public Result recharge(@RequestBody @Valid MemberQuickBuySaleDto memberQuickBuySaleDto) {
        log.info("入参----->{}", memberQuickBuySaleDto);
        //获取用户ID
        MemberEntity member = LoginUserUtils.getAppLoginUser();
        log.info("查询到的会员----->{}", member);
        // 验证是否实名认证
        //if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) {
        //    return Result.fail("请先实名认证");
        //}
        String tradePasswordWeb = memberQuickBuySaleDto.getTradePassword();
        
        // 验证支付密码
        String tradePassword = member.getTradePassword();
        
        log.info("入参交易密码{},用户设置的交易密码{}", tradePasswordWeb,tradePassword);
        if (StringUtils.isEmpty(tradePassword)) {
            return Result.fail("请先配置交易密码");
        }
        if (StringUtils.isEmpty(tradePasswordWeb)) {
            return Result.fail("请输入交易密码");
        }
        // 验证交易密码
        if (!tradePassword.equals(SecureUtil.md5(tradePasswordWeb))) {
            return Result.fail("请输入正确的交易密码");
        }
        return memberQuickBuySaleService.recharge(member, memberQuickBuySaleDto);
    }
    
    
    @ApiOperation(value = "commitPay", notes = "USDT充值支付确认")
    @RequestMapping(value = "/commitPay", method = RequestMethod.POST)
    public Result commitPay(@RequestBody @Valid MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto) {
        return memberQuickBuySaleService.commitPay(memberQuickBuySaleCommitDto);
    }
    
    @ApiOperation(value = "selectById", notes = "查询单个买卖记录")
    @GetMapping(value = "/selectById/{id}")
    public Result selectById(@PathVariable(value = "id") Long id) {
        return memberQuickBuySaleService.selectById(id);
    }
    
    @ApiOperation(value = "selectAll", notes = "查询用户所有的买卖记录")
    @GetMapping(value = "/selectAll")
    public Result selectAll(@RequestParam(value = "type") String type) {
        return memberQuickBuySaleService.selectAll(type);
    }
    
    @ApiOperation(value = "cancel", notes = "充值撤销")
    @GetMapping(value = "/cancel")
    public Result cancel(@RequestParam(value = "id") Long id) {
        return memberQuickBuySaleService.cancelRecharge(id);
    }
    
    @ApiOperation(value = "sell", notes = "USDT快速卖出")
    @RequestMapping(value = "/sell", method = RequestMethod.POST)
    public Result sell(@RequestBody @Valid MemberQuickBuySaleDto memberQuickBuySaleDto) {
        // 获取当前登录用户
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        MemberEntity member = memberService.getById(memberId);
        if (!MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) {
            return Result.fail("请先实名认证");
        }
        String tradePasswordWeb = memberQuickBuySaleDto.getTradePassword();
        // 验证支付密码
        String tradePassword = member.getTradePassword();
        
        log.info("入参交易密码{},用户设置的交易密码{}", tradePasswordWeb,tradePassword);
        if (StringUtils.isEmpty(tradePassword)) {
            return Result.fail("请先配置交易密码");
        }
        if (StringUtils.isEmpty(tradePasswordWeb)) {
            return Result.fail("请输入交易密码");
        }
        // 验证交易密码
        if (!tradePassword.equals(SecureUtil.md5(tradePasswordWeb))) {
            return Result.fail("请输入正确的交易密码");
        }
        return memberQuickBuySaleService.sell(member,memberQuickBuySaleDto);
    }
    
    @ApiOperation(value = "cancelSell", notes = "提现撤销")
    @GetMapping(value = "/cancelSell")
    public Result cancelSell(@RequestParam(value = "id") Long id) {
        return memberQuickBuySaleService.cancelSell(id);
    }
}