zj
2024-06-03 4afe73cb84c5a609662b8b4ee20693de9b86b9a3
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.nq.controller.protol;
 
 
import com.nq.common.ServerResponse;
import com.nq.pojo.FundsAppend;
import com.nq.pojo.FundsApply;
import com.nq.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.servlet.http.HttpServletRequest;
 
@Controller
@RequestMapping({"/user/funds/"})
public class UserFundsController {
    private static final Logger log = LoggerFactory.getLogger(UserFundsController.class);
 
    @Autowired
    IFundsSettingService iFundsSettingService;
 
    @Autowired
    IFundsLeverService iFundsLeverService;
 
    @Autowired
    IFundsApplyService iFundsApplyService;
 
    @Autowired
    IUserFundsPositionService iUserFundsPositionService;
 
    @Autowired
    IFundsAppendService iFundsAppendService;
 
    //分仓配资设置信息查询
    @RequestMapping({"getFundsSetting.do"})
    @ResponseBody
    public ServerResponse getFundsSetting() {
        return ServerResponse.createBySuccess(this.iFundsSettingService.getFundsSetting());
    }
 
    //查询配资类型杠杆
    @RequestMapping({"getFundsTypeList.do"})
    @ResponseBody
    public ServerResponse getFundsTypeList(Integer cycleType) {
        return this.iFundsLeverService.getFundsTypeList(cycleType);
    }
 
    //配资申请-添加
    @RequestMapping({"addFundsApply.do"})
    @ResponseBody
    public ServerResponse addFundsApply(FundsApply fundsApply, HttpServletRequest request) throws Exception {
        return this.iFundsApplyService.insert(fundsApply, request);
    }
 
    //配资申请-用户配资列表
    @RequestMapping({"getUserApplyList.do"})
    @ResponseBody
    public ServerResponse getUserApplyList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "12") int pageSize, @RequestParam(value = "userId", defaultValue = "") int userId, HttpServletRequest request) {
        return this.iFundsApplyService.getUserApplyList(pageNum, pageSize, userId, request);
    }
 
    //配资申请-用户操盘中子账户
    @RequestMapping({"getUserSubaccount.do"})
    @ResponseBody
    public ServerResponse getUserSubaccount(HttpServletRequest request) {
        return this.iFundsApplyService.getUserEnabledSubaccount(request);
    }
 
    //分仓交易-入仓
    @RequestMapping({"buyFunds.do"})
    @ResponseBody
    public ServerResponse buyFunds(Integer stockId, Integer buyNum, Integer buyType, Integer lever, Integer subaccountNumber, HttpServletRequest request) {
        ServerResponse serverResponse = null;
        try {
            serverResponse = this.iUserFundsPositionService.buyFunds(stockId, buyNum, buyType, lever, subaccountNumber, request);
        } catch (Exception e) {
            log.error("用户下单操作 = {}", e);
        }
        return serverResponse;
    }
 
    //分仓交易-用户平仓操作
    @RequestMapping({"sellFunds.do"})
    @ResponseBody
    public ServerResponse sellFunds(HttpServletRequest request, @RequestParam("positionSn") String positionSn) {
        ServerResponse serverResponse = null;
        try {
            serverResponse = this.iUserFundsPositionService.sellFunds(positionSn, 1,request);
        } catch (Exception e) {
            log.error("用户平仓操作 = {}", e);
        }
        return serverResponse;
    }
 
    //分仓交易-查询所有平仓/持仓信息
    @RequestMapping({"fundsList.do"})
    @ResponseBody
    public ServerResponse fundsList(HttpServletRequest request, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, @RequestParam(value = "state", required = false) Integer state, @RequestParam(value = "stockCode", required = false) String stockCode, @RequestParam(value = "stockSpell", required = false) String stockSpell) {
        return this.iUserFundsPositionService.findMyPositionByCodeAndSpell(stockCode, stockSpell, state, request, pageNum, pageSize);
    }
 
    //查询子账户详情
    @RequestMapping({"getSubaccountInfo.do"})
    @ResponseBody
    public ServerResponse getSubaccountInfo(Integer id) {
        return this.iFundsApplyService.getDetail(id);
    }
 
    /**
     * 配资杠杆-查询杠杆费率
     * cycleType:周期类型:1按天、2按周、3按月
     * lever:杠杆
     */
    @RequestMapping({"getLeverRateInfo.do"})
    @ResponseBody
    public ServerResponse getLeverRateInfo(Integer cycleType, Integer lever) {
        return this.iFundsLeverService.getLeverRateInfo(cycleType, lever);
    }
 
    //配资追加申请-保存
    @RequestMapping({"appendApply.do"})
    @ResponseBody
    public ServerResponse appendApply(FundsAppend fundsApply, HttpServletRequest request) throws Exception {
        return this.iFundsAppendService.save(fundsApply, request);
    }
 
    //配资追加申请-查询用户追加列表
    @RequestMapping({"getAppendList.do"})
    @ResponseBody
    public ServerResponse getAppendList(HttpServletRequest request, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, @RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "userId", required = false) Integer userId, @RequestParam(value = "appendType", required = false) Integer appendType) {
        return this.iFundsAppendService.getList(pageNum, pageSize, keyword, status, userId, appendType, request);
    }
 
    //根据分仓配资代码查询用户最早入仓股票
    @RequestMapping({"findUserFundsPositionByCode.do"})
    @ResponseBody
    public ServerResponse findUserFundsPositionByCode(HttpServletRequest request, @RequestParam(value = "fundsCode", required = false) String fundsCode) {
        return this.iUserFundsPositionService.findUserFundsPositionByCode(request, fundsCode);
    }
 
 
 
}