parent
ff05fadea3
commit
9b6b36685a
@ -0,0 +1,20 @@
|
||||
package au.com.royalpay.payment.manage.mappers.risk;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2017-12-21 11:45
|
||||
*/
|
||||
@AutoMapper(tablename = "risk_merchant_detail_log", pkName = "id")
|
||||
public interface RiskMerchantDetalLogMapper {
|
||||
@AutoSql(type = SqlType.INSERT)
|
||||
void save(JSONObject record);
|
||||
|
||||
@AutoSql(type = SqlType.UPDATE)
|
||||
void update(JSONObject record);
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package au.com.royalpay.payment.manage.mappers.risk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2017-12-21 11:45
|
||||
*/
|
||||
@AutoMapper(tablename = "risk_merchant_record", pkName = "id")
|
||||
public interface RiskMerchantRecordMapper {
|
||||
@AutoSql(type = SqlType.UPDATE)
|
||||
void update(JSONObject record);
|
||||
|
||||
List<JSONObject> query(JSONObject params);
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
JSONObject findById(@Param("id") String id);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package au.com.royalpay.payment.manage.mappers.risk;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2017-12-21 11:45
|
||||
*/
|
||||
@AutoMapper(tablename = "risk_transaction_log", pkName = "id")
|
||||
public interface RiskTransactionLogMapper {
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
JSONObject findByOrderId(@Param("order_id") String order_id);
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
List<JSONObject> findByRecordId(@Param("record_id") String record_id);
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package au.com.royalpay.payment.manage.mappers.risk;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2017-12-21 11:45
|
||||
*/
|
||||
@AutoMapper(tablename = "risk_white_list", pkName = "client_id")
|
||||
public interface RiskWhiteListMapper {
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
JSONObject findByClientMoniker(@Param("client_moniker") String client_moniker);
|
||||
|
||||
@AutoSql(type = SqlType.INSERT)
|
||||
void save(JSONObject record);
|
||||
|
||||
@AutoSql(type = SqlType.UPDATE)
|
||||
void update(JSONObject record);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package au.com.royalpay.payment.manage.risk.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class AddRiskDetailLog {
|
||||
|
||||
private String record_id;
|
||||
|
||||
private int client_id;
|
||||
|
||||
private String files;
|
||||
|
||||
private String operation;
|
||||
|
||||
public JSONObject params(){
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("record_id",this.record_id);
|
||||
params.put("client_id",this.client_id);
|
||||
params.put("files",this.files);
|
||||
params.put("operation",this.operation);
|
||||
return params;
|
||||
|
||||
}
|
||||
public String getRecord_id() {
|
||||
return record_id;
|
||||
}
|
||||
|
||||
public void setRecord_id(String record_id) {
|
||||
this.record_id = record_id;
|
||||
}
|
||||
|
||||
public int getClient_id() {
|
||||
return client_id;
|
||||
}
|
||||
|
||||
public void setClient_id(int client_id) {
|
||||
this.client_id = client_id;
|
||||
}
|
||||
|
||||
public String getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setFiles(String files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package au.com.royalpay.payment.manage.risk.bean;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class DealRiskRecord {
|
||||
|
||||
private String recordId;
|
||||
private BigDecimal limitAmount;
|
||||
@JsonProperty(defaultValue = "false")
|
||||
private boolean disableMerchat;
|
||||
|
||||
public String getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(String recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public BigDecimal getLimitAmount() {
|
||||
return limitAmount;
|
||||
}
|
||||
|
||||
public void setLimitAmount(BigDecimal limitAmount) {
|
||||
this.limitAmount = limitAmount;
|
||||
}
|
||||
|
||||
public Boolean getDisableMerchat() {
|
||||
return disableMerchat;
|
||||
}
|
||||
|
||||
public void setDisableMerchat(Boolean disableMerchat) {
|
||||
this.disableMerchat = disableMerchat;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package au.com.royalpay.payment.manage.risk.bean;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class QueryRIskRecord {
|
||||
|
||||
private String status;
|
||||
private String client_moniker;
|
||||
private String record_id;
|
||||
|
||||
public JSONObject toParams(){
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("status",this.status);
|
||||
params.put("client_moniker",this.client_moniker);
|
||||
params.put("record_id",this.record_id);
|
||||
return params;
|
||||
}
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRecord_id() {
|
||||
return record_id;
|
||||
}
|
||||
|
||||
public void setRecord_id(String record_id) {
|
||||
this.record_id = record_id;
|
||||
}
|
||||
|
||||
public String getClient_moniker() {
|
||||
return client_moniker;
|
||||
}
|
||||
|
||||
public void setClient_moniker(String client_moniker) {
|
||||
this.client_moniker = client_moniker;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package au.com.royalpay.payment.manage.risk.core;
|
||||
|
||||
import au.com.royalpay.payment.manage.risk.bean.AddRiskDetailLog;
|
||||
import au.com.royalpay.payment.manage.risk.bean.DealRiskRecord;
|
||||
import au.com.royalpay.payment.manage.risk.bean.QueryRIskRecord;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RiskMerchantService {
|
||||
|
||||
void addDetailLog(AddRiskDetailLog addRiskDetailLog, JSONObject account);
|
||||
|
||||
void DropOrderRiskRecord(JSONObject account,String recordId);
|
||||
|
||||
void noopRiskRecord(JSONObject account,String recordId);
|
||||
|
||||
void dealRiskRecord(JSONObject account,DealRiskRecord dealRiskRecord);
|
||||
|
||||
List<JSONObject> getRiskOrders(String recordId);
|
||||
|
||||
List<JSONObject> getRiskRecords(QueryRIskRecord queryRIskRecord);
|
||||
|
||||
void addWhiteList(String client_moinker);
|
||||
|
||||
void disableWhiteList(String client_moinker);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package au.com.royalpay.payment.manage.risk.core.impl;
|
||||
|
||||
import au.com.royalpay.payment.manage.mappers.risk.RiskMerchantDetalLogMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.risk.RiskMerchantRecordMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.risk.RiskTransactionLogMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.risk.RiskWhiteListMapper;
|
||||
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
||||
import au.com.royalpay.payment.manage.risk.bean.AddRiskDetailLog;
|
||||
import au.com.royalpay.payment.manage.risk.bean.DealRiskRecord;
|
||||
import au.com.royalpay.payment.manage.risk.bean.QueryRIskRecord;
|
||||
import au.com.royalpay.payment.manage.risk.core.RiskMerchantService;
|
||||
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
||||
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class RiskMerchantServiceImpl implements RiskMerchantService {
|
||||
|
||||
@Resource
|
||||
private RiskMerchantRecordMapper riskMerchantRecordMapper;
|
||||
@Resource
|
||||
private RiskMerchantDetalLogMapper riskMerchantDetalLogMapper;
|
||||
@Resource
|
||||
private RiskTransactionLogMapper riskTransactionLogMapper;
|
||||
@Resource
|
||||
private RiskWhiteListMapper riskWhiteListMapper;
|
||||
@Resource
|
||||
private ClientManager clientManager;
|
||||
|
||||
@Override
|
||||
public void addDetailLog(AddRiskDetailLog addRiskDetailLog, JSONObject account) {
|
||||
JSONObject record = addRiskDetailLog.params();
|
||||
record.put("auditor",account.getString("display_name"));
|
||||
record.put("create_time",new Date());
|
||||
riskMerchantDetalLogMapper.save(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void DropOrderRiskRecord(JSONObject account, String recordId) {
|
||||
JSONObject riskRecord = riskMerchantRecordMapper.findById(recordId);
|
||||
if (riskRecord == null) {
|
||||
throw new NotFoundException("Risk Record Not Found");
|
||||
}
|
||||
if (riskRecord.getIntValue("status") != 0) {
|
||||
throw new BadRequestException("The Record Has Been Handled");
|
||||
}
|
||||
JSONObject record = new JSONObject();
|
||||
record.put("id", recordId);
|
||||
record.put("status", "2");
|
||||
riskMerchantRecordMapper.update(record);
|
||||
JSONObject detail = new JSONObject();
|
||||
detail.put("record_id", recordId);
|
||||
detail.put("client_id", riskRecord.getIntValue("client_id"));
|
||||
detail.put("auditor", account.getString("display_name"));
|
||||
detail.put("operation", "进行掉单处理");
|
||||
detail.put("create_time", new Date());
|
||||
riskMerchantDetalLogMapper.save(detail);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void noopRiskRecord(JSONObject account, String recordId) {
|
||||
JSONObject riskRecord = riskMerchantRecordMapper.findById(recordId);
|
||||
if (riskRecord == null) {
|
||||
throw new NotFoundException("Risk Record Not Found");
|
||||
}
|
||||
if (riskRecord.getIntValue("status") != 0) {
|
||||
throw new BadRequestException("The Record Has Been Handled");
|
||||
}
|
||||
JSONObject record = new JSONObject();
|
||||
record.put("id", recordId);
|
||||
record.put("status", "1");
|
||||
riskMerchantRecordMapper.update(record);
|
||||
JSONObject detail = new JSONObject();
|
||||
detail.put("record_id", recordId);
|
||||
detail.put("client_id", riskRecord.getIntValue("client_id"));
|
||||
detail.put("auditor", account.getString("display_name"));
|
||||
detail.put("operation", "不做处理");
|
||||
detail.put("create_time", new Date());
|
||||
riskMerchantDetalLogMapper.save(detail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dealRiskRecord(JSONObject account,DealRiskRecord dealRiskRecord) {
|
||||
JSONObject record = riskMerchantRecordMapper.findById(dealRiskRecord.getRecordId());
|
||||
if(record==null){
|
||||
throw new NotFoundException("Risk Record Not Found Please Check");
|
||||
}
|
||||
if(dealRiskRecord.getLimitAmount()!=null){
|
||||
clientManager.setMaxOrderAmount(record.getString("client_moniker"),dealRiskRecord.getLimitAmount());
|
||||
}
|
||||
if(dealRiskRecord.getDisableMerchat()){
|
||||
clientManager.switchChannelPermission(account, record.getString("client_moniker"), "Wechat", false);
|
||||
clientManager.switchChannelPermission(account, record.getString("client_moniker"), "Alipay", false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getRiskOrders(String recordId) {
|
||||
return riskTransactionLogMapper.findByRecordId(recordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getRiskRecords(QueryRIskRecord queryRIskRecord) {
|
||||
return riskMerchantRecordMapper.query(queryRIskRecord.toParams());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWhiteList(String client_moinker) {
|
||||
JSONObject white = riskWhiteListMapper.findByClientMoniker(client_moinker);
|
||||
if (white != null) {
|
||||
white.put("is_valid", true);
|
||||
riskWhiteListMapper.update(white);
|
||||
return;
|
||||
}
|
||||
JSONObject client = clientManager.getClientInfoByMoniker(client_moinker);
|
||||
if (client == null) {
|
||||
throw new NotFoundException("Merchant Not Found Please Check");
|
||||
}
|
||||
JSONObject record = new JSONObject();
|
||||
record.put("client_id", client.getIntValue("client_id"));
|
||||
record.put("client_moniker", client.getString("client_moinker"));
|
||||
record.put("create_time", new Date());
|
||||
riskWhiteListMapper.save(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWhiteList(String client_moinker) {
|
||||
JSONObject white = riskWhiteListMapper.findByClientMoniker(client_moinker);
|
||||
if (white == null) {
|
||||
throw new NotFoundException("White List Not Found Please Check");
|
||||
}
|
||||
white.put("is_valid", false);
|
||||
riskWhiteListMapper.update(white);
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package au.com.royalpay.payment.manage.risk.web;
|
||||
|
||||
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
|
||||
import au.com.royalpay.payment.manage.risk.bean.AddRiskDetailLog;
|
||||
import au.com.royalpay.payment.manage.risk.bean.DealRiskRecord;
|
||||
import au.com.royalpay.payment.manage.risk.bean.QueryRIskRecord;
|
||||
import au.com.royalpay.payment.manage.risk.core.RiskMerchantService;
|
||||
import au.com.royalpay.payment.tools.CommonConsts;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Created by wangning on 08/12/2016.
|
||||
*/
|
||||
@RestController
|
||||
@ManagerMapping(value = "/sys/risk")
|
||||
public class RiskController {
|
||||
|
||||
@Resource
|
||||
private RiskMerchantService riskMerchantService;
|
||||
|
||||
@RequestMapping(value = "/records", method = RequestMethod.GET)
|
||||
public List<JSONObject> list(QueryRIskRecord recordQuery) {
|
||||
return riskMerchantService.getRiskRecords(recordQuery);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/records/{record_id}/dropOrder", method = RequestMethod.PUT)
|
||||
public void dropOrder(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String record_id) {
|
||||
riskMerchantService.DropOrderRiskRecord(manager, record_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/records/{record_id}/noop", method = RequestMethod.PUT)
|
||||
public void noop(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String record_id) {
|
||||
riskMerchantService.noopRiskRecord(manager, record_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/records/{record_id}/deal",method = RequestMethod.PUT)
|
||||
public void dealRecord(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String record_id, @RequestBody DealRiskRecord dealRiskRecord){
|
||||
dealRiskRecord.setRecordId(record_id);
|
||||
riskMerchantService.dealRiskRecord(manager,dealRiskRecord);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/orders/{record_id}", method = RequestMethod.GET)
|
||||
public List<JSONObject> getRiskOrders(@PathVariable String record_id) {
|
||||
return riskMerchantService.getRiskOrders(record_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/white/{client_moniker}", method = RequestMethod.POST)
|
||||
public void addWhiteList(@PathVariable String client_moniker) {
|
||||
riskMerchantService.addWhiteList(client_moniker);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/white/{client_moniker}/disable", method = RequestMethod.PUT)
|
||||
public void disableWhiteList(@PathVariable String client_moniker) {
|
||||
riskMerchantService.disableWhiteList(client_moniker);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/records/uploadFiles", method = RequestMethod.POST)
|
||||
public void addRecordLog(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@RequestBody AddRiskDetailLog addRiskDetailLog) {
|
||||
riskMerchantService.addDetailLog(addRiskDetailLog,manager);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="au.com.royalpay.payment.manage.mappers.risk.RiskMerchantRecordMapper">
|
||||
<select id="query" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT *
|
||||
FROM risk_merchant_record
|
||||
<where>
|
||||
<if test="record_id!=null">
|
||||
and id = #{record_id}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="client_moniker!=null">
|
||||
and client_moniker = #{client_moniker}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in new issue