Sunshine
2024-11-05 8f7985d7764a0aad24bd593ac5ea47b7fc290961
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
package com.nova.sankuai.controller.v2;
 
import com.nova.sankuai.domain.dto.BlankCustomerVisitDto;
import com.nova.sankuai.domain.dto.LoanSupermarketVisitDto;
import com.nova.sankuai.domain.entity.LoanSupermarket;
import com.nova.sankuai.domain.vo.LoanSupermarketVo;
import com.nova.sankuai.infra.config.CommonException;
import com.nova.sankuai.infra.utils.ResultJson;
import com.nova.sankuai.infra.utils.UserUtil;
import com.nova.sankuai.security.UserDetail;
import com.nova.sankuai.service.IChannelInfoService;
import com.nova.sankuai.service.IChannelLogService;
import com.nova.sankuai.service.ICustomerService;
import com.nova.sankuai.service.ILoanSupermarketService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * @author weikangdi
 */
@Api(tags = "贷款超市V2")
@RestController
@RequestMapping(value = "/api/v2/loanSupermarket")
@AllArgsConstructor
@Slf4j
public class LoanSupermarketV2Controller {
 
    private final ILoanSupermarketService supermarketService;
 
    private final ICustomerService customerService;
 
    private final IChannelLogService channelLogService;
 
    private final IChannelInfoService channelInfoService;
 
    @GetMapping(value = "/getSupermarketListByKey")
    @ApiOperation(value = "根据渠道Key获取可用贷超列表")
    public ResultJson<List<LoanSupermarketVo>> getSupermarketListByKey(String appId, HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        UserDetail user = UserUtil.getUser(token);
        String phone = null;
        if (user != null) {
            phone = user.getPhone();
        }
        List<LoanSupermarketVo> result = channelInfoService.getSupermarketListByKey(appId, phone);
        return ResultJson.ok(result);
    }
 
    @GetMapping(value = "/addVisitRecord")
    @ApiOperation(value = "新增贷款超市访问记录")
    @PreAuthorize("hasAuthority('loanSupermarket.addVisitRecord')")
    public ResultJson<?> addVisitRecord(LoanSupermarketVisitDto visitDto) {
        supermarketService.addVisitRecord(visitDto);
        return ResultJson.success();
    }
 
    @GetMapping(value = "/addBlankVisitRecord")
    @ApiOperation(value = "新增空白客户贷超访问记录")
    @PreAuthorize("hasAuthority('loanSupermarket.addBlankVisitRecord')")
    public ResultJson<?> addBlankVisitRecord(BlankCustomerVisitDto visitDto) {
        log.info("新增空白贷超客户访问记录开始,原始数据:" + visitDto.toString());
        if (StringUtils.isEmpty(visitDto.getPhone())) {
            throw new CommonException("客户手机号不能为空");
        }
        customerService.addBlankVisitRecord(visitDto);
        return ResultJson.success();
    }
 
    @GetMapping(value = "/addJYDLoanMarketRecord")
    @ApiOperation(value = "新增戒易贷贷超访问记录")
    public ResultJson<?> addJYDLoanMarketRecord(Long loanMarkId, @AuthenticationPrincipal UserDetail userDetail) {
        if (loanMarkId == null) {
            throw new CommonException("贷款超市不能为空");
        }
        log.info("新增戒易贷贷超访问记录开始,原始贷超Id:" + loanMarkId + "用户信息" + userDetail.toString());
        channelLogService.addJYDLoanMarketRecord(loanMarkId, userDetail);
        return ResultJson.success();
    }
 
    @GetMapping(value = "/getH5LoanMarketListByKey")
    @ApiOperation(value = "根据渠道Key获取H5贷超列表")
    public ResultJson<List<LoanSupermarketVo>> getH5LoanMarketListByKey(String appId) {
        List<LoanSupermarketVo> result = channelInfoService.getH5LoanMarketListByKey(appId);
        return ResultJson.ok(result);
    }
 
 
    @GetMapping(value = "/getSecondSupermarket")
    @ApiOperation(value = "获取排序为第二个的贷超")
    public ResultJson<List<LoanSupermarket>> getSecondSupermarket() {
        List<LoanSupermarket> secondSupermarket = supermarketService.getSecondSupermarket();
        return ResultJson.ok(secondSupermarket);
    }
 
    @GetMapping(value = "/getVipMode")
    @ApiOperation(value = "获取开启了会员模式的贷超产品")
    public ResultJson<List<LoanSupermarket>> getVipMode() {
        List<LoanSupermarket> secondSupermarket = supermarketService.getVipMode();
        return ResultJson.ok(secondSupermarket);
    }
 
    @GetMapping(value = "/getMyMoney")
    @ApiOperation(value = "获取开启我的金额开关的贷超产品")
    public ResultJson<List<LoanSupermarketVo>> getMyMoney(@AuthenticationPrincipal UserDetail userDetail) {
        List<LoanSupermarketVo> secondSupermarket = supermarketService.getMyMoney(userDetail);
        return ResultJson.ok(secondSupermarket);
    }
 
    @GetMapping(value = "/getWaitApproval")
    @ApiOperation(value = "获取开启我的金额开关的贷超产品")
    public ResultJson<LoanSupermarketVo> getWaitApproval(@AuthenticationPrincipal UserDetail userDetail) {
        LoanSupermarketVo waitApproval = supermarketService.getWaitApproval(userDetail);
        return ResultJson.ok(waitApproval);
    }
}