package com.nova.sankuai.controller.v1;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.nova.sankuai.domain.dto.CustomerPageDto;
|
import com.nova.sankuai.domain.dto.InletFlowProportionDto;
|
import com.nova.sankuai.domain.entity.Customer;
|
import com.nova.sankuai.domain.enums.UserTypeEnum;
|
import com.nova.sankuai.domain.vo.InletFlowProportionListVo;
|
import com.nova.sankuai.domain.vo.common.MapVo;
|
import com.nova.sankuai.domain.vo.customer.CustomerDetail;
|
import com.nova.sankuai.domain.vo.customer.CustomerMechanismConfigVo;
|
import com.nova.sankuai.domain.vo.customer.CustomerVo;
|
import com.nova.sankuai.infra.config.CommonException;
|
import com.nova.sankuai.infra.constants.ResultCode;
|
import com.nova.sankuai.infra.utils.MapUtil;
|
import com.nova.sankuai.infra.utils.PageRequest;
|
import com.nova.sankuai.infra.utils.ResultJson;
|
import com.nova.sankuai.security.UserDetail;
|
import com.nova.sankuai.service.*;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
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.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
|
/**
|
* @author weikangdi
|
*/
|
@Api(tags = "客户管理")
|
@RestController
|
@RequestMapping(value = "/api/v1/customer")
|
@AllArgsConstructor
|
public class CustomerController {
|
|
private final ICustomerService customerService;
|
|
private final IChannelInfoService channelInfoService;
|
|
private final IYiXinService yiXinService;
|
|
private final IChannelLogService channelLogService;
|
|
private final IMemberRightService memberRightService;
|
|
@PostMapping(value = "/add")
|
@ApiOperation(value = "H5新增客户")
|
@PreAuthorize("hasAuthority('customer.add')")
|
public ResultJson<String> add(@RequestBody Customer customer, String appId) {
|
ResultJson checkResult = channelInfoService.checkChannel(appId, customer.toString());
|
if (checkResult != null) {
|
return checkResult;
|
}
|
String id = customerService.add(customer, appId);
|
return ResultJson.ok(id);
|
}
|
|
|
@PostMapping(value = "/calculateMechanism")
|
@ApiOperation(value = "获取匹配机构")
|
@PreAuthorize("hasAuthority('customer.calculateMechanism')")
|
public ResultJson<Customer> calculateMechanism(@RequestBody Customer customer) {
|
customer = customerService.calculate(customer);
|
return ResultJson.ok(customer);
|
}
|
|
@PostMapping("/uploadFile")
|
@ApiOperation(value = "上传图片")
|
@PreAuthorize("hasAuthority('customer.uploadFile')")
|
public ResultJson<String> uploadFile(@RequestBody MultipartFile file) {
|
String fileName = "";
|
return ResultJson.ok(fileName);
|
}
|
|
@GetMapping("/searchPlace")
|
@ApiOperation(value = "地址联想")
|
@PreAuthorize("hasAuthority('customer.searchPlace')")
|
public ResultJson<List<MapVo>> searchPlace(String query, String city) {
|
if (StringUtils.isEmpty(query)) {
|
return ResultJson.failure(ResultCode.SERVER_ERROR, "搜索关键字不能为空");
|
}
|
List<MapVo> place = MapUtil.searchPlace(query, city);
|
return ResultJson.ok(place);
|
}
|
|
@PostMapping(value = "/addLargeCustomer")
|
@ApiOperation(value = "新增大额H5客户")
|
public ResultJson<CustomerMechanismConfigVo> addLargeCustomer(@RequestBody Customer customer, String code, String appId) {
|
ResultJson checkResult = channelInfoService.checkChannel(appId, customer.toString());
|
if (checkResult != null) {
|
return checkResult;
|
}
|
CustomerMechanismConfigVo configVo = customerService.addLargeCustomer(customer, code, appId);
|
return ResultJson.ok(configVo);
|
}
|
|
|
@GetMapping(value = "/pageCustomers")
|
@ApiOperation(value = "分页查询客户信息")
|
@PreAuthorize("hasAuthority('customer.pageCustomers')")
|
public ResultJson<IPage<CustomerVo>> pageCustomers(CustomerPageDto customerPageDto, PageRequest pageRequest, @AuthenticationPrincipal UserDetail userDetail) {
|
if (UserTypeEnum.USER.getCode().equals(userDetail.getType())) {
|
customerPageDto.setMechanismId(userDetail.getId());
|
} else {
|
customerPageDto.setMechanismId(null);
|
}
|
IPage<CustomerVo> result = customerService.page(customerPageDto, pageRequest);
|
return ResultJson.ok(result);
|
}
|
|
@GetMapping(value = "/getCustomerDetail/{id}")
|
@ApiOperation(value = "获取客户详情")
|
@PreAuthorize("hasAuthority('customer.getCustomerDetail')")
|
public ResultJson<CustomerDetail> getCustomerDetail(@PathVariable("id") Long id) {
|
CustomerDetail detail = customerService.getCustomerDetail(id);
|
return ResultJson.ok(detail);
|
}
|
|
@GetMapping("/updateMatchMechanism")
|
@ApiOperation(value = "更新大额H5的匹配机构")
|
public ResultJson<Void> updateMatchMechanism(Long customerId, Long mechanismId) {
|
if (customerId == null || mechanismId == null) {
|
throw new CommonException("客户Id和机构Id不能为空");
|
}
|
customerService.updateMatchMechanism(customerId, mechanismId);
|
return ResultJson.success();
|
}
|
|
@GetMapping("/assignMechanism")
|
@ApiOperation(value = "重新分配机构")
|
@PreAuthorize("hasAuthority('customer.assignMechanism')")
|
public ResultJson<Void> assignMechanism(Long customerId, Long mechanismId) {
|
if (customerId == null || mechanismId == null) {
|
throw new CommonException("客户Id和机构Id不能为空");
|
}
|
customerService.assignMechanism(customerId, mechanismId);
|
return ResultJson.success();
|
}
|
|
@GetMapping("/checkMechanism")
|
@ApiOperation(value = "检测机构是否达到上限")
|
@PreAuthorize("hasAuthority('customer.checkMechanism')")
|
public ResultJson<Void> checkMechanism(Long mechanismId) {
|
Set<String> result = customerService.checkMechanism(mechanismId);
|
if (result != null && result.size() > 0) {
|
return ResultJson.failure(ResultCode.SERVER_ERROR, result);
|
}
|
return ResultJson.success();
|
}
|
|
@PostMapping(value = "/yxAuditCallback")
|
@ApiOperation(value = "绿地授信审批结果通知")
|
public String yxAuditCallback(@RequestBody Map<String, String> request) throws Exception {
|
String result = yiXinService.yxAuditCallback(request);
|
return result;
|
}
|
|
@PostMapping(value = "/getInletFlowProportion")
|
@ApiOperation(value = "查看入口流量占比")
|
@PreAuthorize("hasAuthority('inletFlowProportion.getInletFlowProportion')")
|
public ResultJson<List<InletFlowProportionListVo>> getInletFlowProportion(@RequestBody InletFlowProportionDto inletFlowProportionDto) {
|
List<InletFlowProportionListVo> inletFlowProportion = channelLogService.getInletFlowProportion(inletFlowProportionDto);
|
return ResultJson.ok(inletFlowProportion);
|
}
|
|
|
@ApiOperation(value = "会员权益兑换")
|
@GetMapping("/membershipInterests")
|
@PreAuthorize("hasAuthority('customer.membershipInterests')")
|
public ResultJson<String> backTongBaoMembershipInterests(@RequestParam String phone) {
|
String result = memberRightService.manualMembershipInterests(phone);
|
return ResultJson.ok(result);
|
}
|
|
@PostMapping(value = "/yxLoanApplyCallback")
|
@ApiOperation(value = "绿地用信结果通知")
|
public String yxLoanApplyCallback(@RequestBody Map<String, String> request) throws Exception {
|
String result = yiXinService.yxLoanApplyCallback(request);
|
return result;
|
}
|
|
@PostMapping(value = "/yxRepayPlanCallback")
|
@ApiOperation(value = "绿地还款计划变动通知")
|
public String yxRepayApplyCallback(@RequestBody Map<String, String> request) throws Exception {
|
String result = yiXinService.yxRepayPlanCallback(request);
|
return result;
|
}
|
|
|
@PostMapping(value = "/yxRepayResultCallback")
|
@ApiOperation(value = "绿地还款结果通知")
|
public String yxRepayResultCallback(@RequestBody Map<String, String> request) throws Exception {
|
String result = yiXinService.yxRepayResultCallback(request);
|
return result;
|
}
|
|
}
|