zj
2024-04-23 b7d0c5e9ddfedc068d2f82fab530e71043a7f4af
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
package com.nq.controller.echo;
 
import com.nq.common.ServerResponse;
import com.nq.dao.EChoMapper;
import com.nq.pojo.EChoBean;
import com.nq.service.IEchoServices;
import com.nq.utils.translate.GoogleTranslateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
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("/api/echo")
public class EChoController {
 
    @Autowired
    IEchoServices iEchoServices;
 
    @Autowired
    EChoMapper eChoMapper;
 
    @PostMapping("queryEcho.do")
    @ResponseBody
    public ServerResponse queryEcho() {
        return ServerResponse.createBySuccess(iEchoServices.queryList());
    }
 
 
    @PostMapping("buyEcho.do")
    @ResponseBody
    public ServerResponse buyEcho(@RequestParam("eId") String eid, @RequestParam("money") Integer money, HttpServletRequest request) {
        EChoBean eChoBean = eChoMapper.selectById(Integer.parseInt(eid));
        if (eChoBean == null) {
            return ServerResponse.createByErrorMsg("基金产品不存在",request);
        } else {
            if (null != eChoBean.getBuyLowestNum() && money < eChoBean.getBuyLowestNum()) {
                return ServerResponse.createByErrorMsg("购买失败,最低购买数量:"+eChoBean.getBuyLowestNum(),request);
            }
        }
        if (iEchoServices.buyECho(eid, money,request)) {
            return ServerResponse.createBySuccess("购买成功",request);
        } else {
            return ServerResponse.createByErrorMsg("购买失败",request);
        }
    }
 
 
    @PostMapping("queryOrderEcho.do")
    @ResponseBody
    public ServerResponse queryOrderEcho(HttpServletRequest request) {
        return ServerResponse.createBySuccess(iEchoServices.queryOrderEcho(request));
    }
 
 
 
 
 
}