[Y] 风控商户检测

master
taylor.dang 6 years ago
parent d6a2853a4d
commit 9f45114d96

@ -8,12 +8,15 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* Create by yixian at 2017-12-21 11:45
*/
@AutoMapper(tablename = "risk_attention_merchants", pkName = "client_id")
public interface RiskAttentionMerchantsAMapper {
public interface RiskAttentionMerchantsMapper {
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject client);
@ -24,10 +27,18 @@ public interface RiskAttentionMerchantsAMapper {
JSONObject findById(@Param("id") String id);
@AutoSql(type = SqlType.SELECT)
JSONObject findByClientMoniker(@Param("client_moniker") String client_moniker);
JSONObject findByClientMoniker(@Param("client_moniker") String clientMoniker);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1")
PageList<JSONObject> query(JSONObject params, PageBounds pagination);
@Select("SELECT client_moniker FROM risk_attention_merchants " +
"WHERE (abn LIKE CONCAT('%',#{abn},'%') ) OR (acn LIKE CONCAT('%',#{acn},'%') ) " +
" OR (contact_phone LIKE CONCAT('%',#{contact_phone},'%') ) " +
" OR (contact_person LIKE CONCAT('%',#{contact_person},'%') ) " +
" OR (client_moniker LIKE CONCAT('%',#{client_moniker},'%') ) " +
" OR (bank_account_no LIKE CONCAT('%',#{bank_account_no},'%') ) ")
List<JSONObject> listRiskySimilarMerchants(JSONObject params);
}

@ -32,6 +32,7 @@ import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
@ -294,6 +295,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private PermissionClientModuleMapper permissionClientModuleMapper;
@Resource
private PermissionPartnerManagerImpl permissionPartnerManagerImpl;
@Resource
private RiskAttentionMerchantsMapper riskAttentionMerchantsMapper;
@Resource
private SmsSender smsSender;
private static final String SOURCE_AGREE_FILE = "source_agree_file";
@ -589,6 +593,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (clientMapper.findClientByMoniker(registery.getClientMoniker()) != null) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}
//检查商户是否进入系统黑名单
isRiskyMerchant(partner, null);
try {
clientMapper.save(partner);
@ -814,6 +821,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) {
throw new InvalidShortIdException();
}
//检查商户是否进入平台黑名单
int clientId = client.getIntValue("client_id");
isRiskyMerchant(client, clientBankAccountMapper.clientBankAccounts(clientId).get(0));
if (client.getString("sub_merchant_id") == null || client.getString("sub_merchant_id").equals("")) {
throw new BadRequestException("该商户未设置微信 Sub Merchant ID!");
}
@ -856,6 +867,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) {
throw new InvalidShortIdException();
}
//检查商户是否进入平台黑名单
int clientId = client.getIntValue("client_id");
isRiskyMerchant(client, clientBankAccountMapper.clientBankAccounts(clientId).get(0));
client.put("approve_result", 2);
client.put("approver", manager.getString("manager_id"));
client.put("approve_time", new Date());
@ -3743,10 +3758,31 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
@Override
public String getShortLink(String client_moniker) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + client_moniker + "/jump");
public String getShortLink(String clientMoniker) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + clientMoniker + "/jump");
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
return api.registerShortUrl(longUrl);
}
private void isRiskyMerchant(JSONObject client, JSONObject bankAccount) {
JSONObject needCheckParams = new JSONObject();
needCheckParams.put("client_moniker", client.getString("client_moniker"));
needCheckParams.put("abn", client.getString("abn"));
needCheckParams.put("acn", client.getString("acn"));
needCheckParams.put("contact_phone", client.getString("contact_phone"));
needCheckParams.put("contact_person", client.getString("contact_person"));
if (bankAccount != null) {
needCheckParams.put("bank_account_no", bankAccount.getString("account_no"));
}
List<JSONObject> listRiskySimilarMerchants = riskAttentionMerchantsMapper.listRiskySimilarMerchants(needCheckParams);
StringBuilder appendStr = new StringBuilder();
listRiskySimilarMerchants.stream().forEach(json -> appendStr.append(json.getString("client_moniker")).append(","));
appendStr.deleteCharAt(appendStr.length() - 1);
if (listRiskySimilarMerchants.size() > 0) {
throw new BadRequestException("该商户信息已经进入系统黑名单,关联商户为【" + appendStr + "】");
}
}
}

@ -8,29 +8,29 @@ public interface RiskMerchantService {
void addDetailLog(AddRiskDetailLog addRiskDetailLog, JSONObject account);
void DropOrderRiskRecord(JSONObject account,String recordId);
void dropOrderRiskRecord(JSONObject account, String recordId);
void noopRiskRecord(JSONObject account,String recordId);
void noopRiskRecord(JSONObject account, String recordId);
void dealRiskRecord(JSONObject account,DealRiskRecord dealRiskRecord);
void dealRiskRecord(JSONObject account, DealRiskRecord dealRiskRecord);
void dealRiskRecordDirectly(JSONObject account,String record_id);
void dealRiskRecordDirectly(JSONObject account, String clientMoniker);
JSONObject getRiskOrders(QueryRiskOrder queryRiskOrder);
JSONObject getRiskRecords(QueryRiskRecord queryRiskRecord);
void addWhiteList(String client_moinker);
void addWhiteList(String clientMoniker);
void disableWhiteList(String client_moinker);
void disableWhiteList(String clientMoniker);
JSONObject getRecordById(String record_id);
JSONObject getRecordById(String recordId);
JSONObject getRiskDetails(QueryRiskDetail queryRiskDetail);
JSONObject listAttentionMerchants(JSONObject account,QueryAttentionMerchants queryAttention);
JSONObject listAttentionMerchants(JSONObject manager, QueryAttentionMerchants queryAttention);
void addAttentionMerchants(JSONObject account,String client_moniker);
void addAttentionMerchant(JSONObject manager, String clientMoniker);
void updateAttentionMerchants(JSONObject account,String client_moniker);
void disableAttentionMerchant(JSONObject manager, String clientMoniker);
}

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.risk.core.impl;
import au.com.royalpay.payment.manage.mappers.risk.*;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.risk.bean.*;
import au.com.royalpay.payment.manage.risk.core.RiskMerchantService;
@ -34,7 +35,9 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
@Resource
private ClientManager clientManager;
@Resource
private RiskAttentionMerchantsAMapper riskAttentionMerchantsAMapper;
private RiskAttentionMerchantsMapper riskAttentionMerchantsAMapper;
@Resource
private ClientBankAccountMapper clientBankAccountMapper;
@Override
@Transactional
@ -55,7 +58,7 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
@Override
@Transactional
public void DropOrderRiskRecord(JSONObject account, String recordId) {
public void dropOrderRiskRecord(JSONObject account, String recordId) {
JSONObject riskRecord = riskMerchantRecordMapper.findById(recordId);
if (riskRecord == null) {
throw new NotFoundException("Risk Record Not Found");
@ -170,14 +173,14 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
}
@Override
public void addWhiteList(String client_moinker) {
JSONObject white = riskWhiteListMapper.findByClientMoniker(client_moinker);
public void addWhiteList(String clientMoniker) {
JSONObject white = riskWhiteListMapper.findByClientMoniker(clientMoniker);
if (white != null) {
white.put("is_valid", true);
riskWhiteListMapper.update(white);
return;
}
JSONObject client = clientManager.getClientInfoByMoniker(client_moinker);
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new NotFoundException("Merchant Not Found Please Check");
}
@ -189,8 +192,8 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
}
@Override
public void disableWhiteList(String client_moinker) {
JSONObject white = riskWhiteListMapper.findByClientMoniker(client_moinker);
public void disableWhiteList(String clientMoniker) {
JSONObject white = riskWhiteListMapper.findByClientMoniker(clientMoniker);
if (white == null) {
throw new NotFoundException("White List Not Found Please Check");
}
@ -199,8 +202,8 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
}
@Override
public JSONObject getRecordById(String record_id) {
return riskMerchantRecordMapper.findById(record_id);
public JSONObject getRecordById(String recordId) {
return riskMerchantRecordMapper.findById(recordId);
}
@Override
@ -211,53 +214,64 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
}
@Override
public JSONObject listAttentionMerchants(JSONObject account, QueryAttentionMerchants queryAttention) {
if (account == null) {
throw new BadRequestException("account not exists");
public JSONObject listAttentionMerchants(JSONObject manager, QueryAttentionMerchants queryAttention) {
if (manager == null) {
throw new BadRequestException("登录状态已过期,请清新登录再试");
}
return PageListUtils.buildPageListResult(
riskAttentionMerchantsAMapper.query(queryAttention.toParams(), new PageBounds(queryAttention.getPage(), queryAttention.getLimit(), Order.formString("create_time.desc"))));
riskAttentionMerchantsAMapper.query(queryAttention.toParams(), new PageBounds(queryAttention.getPage(), queryAttention.getLimit(), Order.formString("last_update_date.desc"))));
}
@Override
public void addAttentionMerchants(JSONObject account, String client_moniker) {
if (account == null) {
throw new BadRequestException("account not exists");
public void addAttentionMerchant(JSONObject manager, String clientMoniker) {
if (manager == null) {
throw new BadRequestException("登录状态已过期,请清新登录再试");
}
JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(client_moniker);
if(attentionMerchant != null){
if(attentionMerchant.getBoolean("is_valid")){
throw new BadRequestException("The client has already existed");
}else {
attentionMerchant.put("is_valid",1);
attentionMerchant.put("update_time",new Date());
riskAttentionMerchantsAMapper.update(attentionMerchant);
return;
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new BadRequestException("The Merchant does not exist");
}
int clientId = client.getIntValue("client_id");
JSONObject bankAccount = clientBankAccountMapper.clientBankAccounts(clientId).get(0);
JSONObject attention = new JSONObject();
attention.put("client_id", clientId);
attention.put("client_moniker", clientMoniker);
attention.put("abn", client.getString("abn"));
attention.put("acn", client.getString("acn"));
attention.put("contact_person", client.getString("contact_person"));
attention.put("contact_phone", client.getString("contact_phone"));
attention.put("bank_account_no", bankAccount == null ? "" : bankAccount.getString("account_no"));
attention.put("is_valid", 1);
attention.put("creation_date", new Date());
attention.put("creation_by", manager.getString("manager_id"));
attention.put("last_update_date", new Date());
attention.put("last_update_by", manager.getString("manager_id"));
JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(clientMoniker);
if (attentionMerchant != null) {
if (attentionMerchant.getBoolean("is_valid")) {
throw new BadRequestException("The client has already existed");
}
JSONObject client = clientManager.getClientInfoByMoniker(client_moniker);
if(client == null){
throw new BadRequestException("The client does not exist");
attention.remove("creation_date");
attention.remove("creation_by");
riskAttentionMerchantsAMapper.update(attention);
return;
}
JSONObject attention = new JSONObject();
attention.put("client_id",client.getIntValue("client_id"));
attention.put("client_moniker",client.getString("client_moniker"));
attention.put("is_valid",1);
attention.put("create_time",new Date());
riskAttentionMerchantsAMapper.save(attention);
}
@Override
public void updateAttentionMerchants(JSONObject account, String client_moniker) {
if (account == null) {
throw new BadRequestException("account not exists");
public void disableAttentionMerchant(JSONObject manager, String clientMoniker) {
if (manager == null) {
throw new BadRequestException("登录状态已过期,请清新登录再试");
}
JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(client_moniker);
if(attentionMerchant == null){
JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(clientMoniker);
if (attentionMerchant == null) {
throw new BadRequestException("The client does not exist");
}
attentionMerchant.put("is_valid",0);
attentionMerchant.put("update_time",new Date());
attentionMerchant.put("is_valid", 0);
attentionMerchant.put("last_update_date", new Date());
attentionMerchant.put("last_update_by", manager.getString("manager_id"));
riskAttentionMerchantsAMapper.update(attentionMerchant);
}
}

@ -39,7 +39,7 @@ public class RiskController {
@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);
riskMerchantService.dropOrderRiskRecord(manager, record_id);
}
@RequestMapping(value = "/records/{record_id}/noop", method = RequestMethod.PUT)
@ -65,14 +65,14 @@ public class RiskController {
}
@RequestMapping(value = "/white/{client_moniker}", method = RequestMethod.POST)
public void addWhiteList(@PathVariable String client_moniker) {
riskMerchantService.addWhiteList(client_moniker);
@RequestMapping(value = "/white/{clientMoniker}", method = RequestMethod.POST)
public void addWhiteList(@PathVariable String clientMoniker) {
riskMerchantService.addWhiteList(clientMoniker);
}
@RequestMapping(value = "/white/{client_moniker}/disable", method = RequestMethod.PUT)
public void disableWhiteList(@PathVariable String client_moniker) {
riskMerchantService.disableWhiteList(client_moniker);
@RequestMapping(value = "/white/{clientMoniker}/disable", method = RequestMethod.PUT)
public void disableWhiteList(@PathVariable String clientMoniker) {
riskMerchantService.disableWhiteList(clientMoniker);
}
@RequestMapping(value = "/records/uploadFiles", method = RequestMethod.POST)
@ -86,22 +86,22 @@ public class RiskController {
}
@RequestMapping(value = "/details/remark", method = RequestMethod.POST)
public void addDetailRemark(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@RequestBody AddRiskDetailLog addRiskDetailLog ) {
riskMerchantService.addDetailLog(addRiskDetailLog,manager);
public void addDetailRemark(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody AddRiskDetailLog addRiskDetailLog) {
riskMerchantService.addDetailLog(addRiskDetailLog, manager);
}
@RequestMapping(value = "/attention", method = RequestMethod.GET)
public JSONObject listMerchants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,QueryAttentionMerchants queryAttention ) {
return riskMerchantService.listAttentionMerchants(manager,queryAttention);
public JSONObject listMerchant(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, QueryAttentionMerchants queryAttention) {
return riskMerchantService.listAttentionMerchants(manager, queryAttention);
}
@RequestMapping(value = "/attention/{client_moniker}", method = RequestMethod.POST)
public void addMerchants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String client_moniker) {
riskMerchantService.addAttentionMerchants(manager,client_moniker);
@RequestMapping(value = "/attention/{clientMoniker}", method = RequestMethod.POST)
public void addMerchant(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) {
riskMerchantService.addAttentionMerchant(manager, clientMoniker);
}
@RequestMapping(value = "/attention/{client_moniker}", method = RequestMethod.PUT)
public void updateMerchants(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String client_moniker) {
riskMerchantService.updateAttentionMerchants(manager,client_moniker);
@RequestMapping(value = "/attention/{clientMoniker}", method = RequestMethod.PUT)
public void disableRiskMerchant(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker) {
riskMerchantService.disableAttentionMerchant(manager, clientMoniker);
}
}

@ -48,15 +48,25 @@
<table class="table table-hover">
<thead>
<tr>
<th>Client Moniker</th>
<th>Create Time</th>
<th>Merchant Code</th>
<th>ABN</th>
<th>ACN</th>
<th>Account No</th>
<th>Contact Person</th>
<th>Contact Phone</th>
<th>Operation Time</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="client in attentions">
<td>{{client.client_moniker}}</td>
<td>{{client.create_time}}</td>
<td>{{client.abn}}</td>
<td>{{client.acn}}</td>
<td>{{client.bank_account_no}}</td>
<td>{{client.contact_person}}</td>
<td>{{client.contact_phone}}</td>
<td>{{client.last_update_date}}</td>
<td>
<a role="button" class="text-bold text-danger"
ng-click="disableAttention(client.client_moniker)">Disable</a>

Loading…
Cancel
Save