[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.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param; 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 * Create by yixian at 2017-12-21 11:45
*/ */
@AutoMapper(tablename = "risk_attention_merchants", pkName = "client_id") @AutoMapper(tablename = "risk_attention_merchants", pkName = "client_id")
public interface RiskAttentionMerchantsAMapper { public interface RiskAttentionMerchantsMapper {
@AutoSql(type = SqlType.UPDATE) @AutoSql(type = SqlType.UPDATE)
void update(JSONObject client); void update(JSONObject client);
@ -24,10 +27,18 @@ public interface RiskAttentionMerchantsAMapper {
JSONObject findById(@Param("id") String id); JSONObject findById(@Param("id") String id);
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject findByClientMoniker(@Param("client_moniker") String client_moniker); JSONObject findByClientMoniker(@Param("client_moniker") String clientMoniker);
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1") @AdvanceSelect(addonWhereClause = "is_valid=1")
PageList<JSONObject> query(JSONObject params, PageBounds pagination); 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.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
@ -294,6 +295,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
private PermissionClientModuleMapper permissionClientModuleMapper; private PermissionClientModuleMapper permissionClientModuleMapper;
@Resource @Resource
private PermissionPartnerManagerImpl permissionPartnerManagerImpl; private PermissionPartnerManagerImpl permissionPartnerManagerImpl;
@Resource
private RiskAttentionMerchantsMapper riskAttentionMerchantsMapper;
@Resource @Resource
private SmsSender smsSender; private SmsSender smsSender;
private static final String SOURCE_AGREE_FILE = "source_agree_file"; 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) { if (clientMapper.findClientByMoniker(registery.getClientMoniker()) != null) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker"); throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
} }
//检查商户是否进入系统黑名单
isRiskyMerchant(partner, null);
try { try {
clientMapper.save(partner); clientMapper.save(partner);
@ -814,6 +821,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); 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("")) { if (client.getString("sub_merchant_id") == null || client.getString("sub_merchant_id").equals("")) {
throw new BadRequestException("该商户未设置微信 Sub Merchant ID!"); throw new BadRequestException("该商户未设置微信 Sub Merchant ID!");
} }
@ -856,6 +867,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
//检查商户是否进入平台黑名单
int clientId = client.getIntValue("client_id");
isRiskyMerchant(client, clientBankAccountMapper.clientBankAccounts(clientId).get(0));
client.put("approve_result", 2); client.put("approve_result", 2);
client.put("approver", manager.getString("manager_id")); client.put("approver", manager.getString("manager_id"));
client.put("approve_time", new Date()); client.put("approve_time", new Date());
@ -3743,10 +3758,31 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
@Override @Override
public String getShortLink(String client_moniker) { public String getShortLink(String clientMoniker) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + client_moniker + "/jump"); String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + clientMoniker + "/jump");
MpWechatApi api = mpWechatApiProvider.getNewPaymentApi(); MpWechatApi api = mpWechatApiProvider.getNewPaymentApi();
return api.registerShortUrl(longUrl); 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 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 getRiskOrders(QueryRiskOrder queryRiskOrder);
JSONObject getRiskRecords(QueryRiskRecord queryRiskRecord); 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 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; package au.com.royalpay.payment.manage.risk.core.impl;
import au.com.royalpay.payment.manage.mappers.risk.*; 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.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.risk.bean.*; import au.com.royalpay.payment.manage.risk.bean.*;
import au.com.royalpay.payment.manage.risk.core.RiskMerchantService; import au.com.royalpay.payment.manage.risk.core.RiskMerchantService;
@ -34,7 +35,9 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
@Resource @Resource
private ClientManager clientManager; private ClientManager clientManager;
@Resource @Resource
private RiskAttentionMerchantsAMapper riskAttentionMerchantsAMapper; private RiskAttentionMerchantsMapper riskAttentionMerchantsAMapper;
@Resource
private ClientBankAccountMapper clientBankAccountMapper;
@Override @Override
@Transactional @Transactional
@ -55,7 +58,7 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
@Override @Override
@Transactional @Transactional
public void DropOrderRiskRecord(JSONObject account, String recordId) { public void dropOrderRiskRecord(JSONObject account, String recordId) {
JSONObject riskRecord = riskMerchantRecordMapper.findById(recordId); JSONObject riskRecord = riskMerchantRecordMapper.findById(recordId);
if (riskRecord == null) { if (riskRecord == null) {
throw new NotFoundException("Risk Record Not Found"); throw new NotFoundException("Risk Record Not Found");
@ -170,14 +173,14 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
} }
@Override @Override
public void addWhiteList(String client_moinker) { public void addWhiteList(String clientMoniker) {
JSONObject white = riskWhiteListMapper.findByClientMoniker(client_moinker); JSONObject white = riskWhiteListMapper.findByClientMoniker(clientMoniker);
if (white != null) { if (white != null) {
white.put("is_valid", true); white.put("is_valid", true);
riskWhiteListMapper.update(white); riskWhiteListMapper.update(white);
return; return;
} }
JSONObject client = clientManager.getClientInfoByMoniker(client_moinker); JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) { if (client == null) {
throw new NotFoundException("Merchant Not Found Please Check"); throw new NotFoundException("Merchant Not Found Please Check");
} }
@ -189,8 +192,8 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
} }
@Override @Override
public void disableWhiteList(String client_moinker) { public void disableWhiteList(String clientMoniker) {
JSONObject white = riskWhiteListMapper.findByClientMoniker(client_moinker); JSONObject white = riskWhiteListMapper.findByClientMoniker(clientMoniker);
if (white == null) { if (white == null) {
throw new NotFoundException("White List Not Found Please Check"); throw new NotFoundException("White List Not Found Please Check");
} }
@ -199,8 +202,8 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
} }
@Override @Override
public JSONObject getRecordById(String record_id) { public JSONObject getRecordById(String recordId) {
return riskMerchantRecordMapper.findById(record_id); return riskMerchantRecordMapper.findById(recordId);
} }
@Override @Override
@ -211,53 +214,64 @@ public class RiskMerchantServiceImpl implements RiskMerchantService {
} }
@Override @Override
public JSONObject listAttentionMerchants(JSONObject account, QueryAttentionMerchants queryAttention) { public JSONObject listAttentionMerchants(JSONObject manager, QueryAttentionMerchants queryAttention) {
if (account == null) { if (manager == null) {
throw new BadRequestException("account not exists"); throw new BadRequestException("登录状态已过期,请清新登录再试");
} }
return PageListUtils.buildPageListResult( 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 @Override
public void addAttentionMerchants(JSONObject account, String client_moniker) { public void addAttentionMerchant(JSONObject manager, String clientMoniker) {
if (account == null) { if (manager == null) {
throw new BadRequestException("account not exists"); throw new BadRequestException("登录状态已过期,请清新登录再试");
}
JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new BadRequestException("The Merchant does not exist");
} }
JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(client_moniker); 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 != null) {
if (attentionMerchant.getBoolean("is_valid")) { if (attentionMerchant.getBoolean("is_valid")) {
throw new BadRequestException("The client has already existed"); 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(client_moniker); attention.remove("creation_date");
if(client == null){ attention.remove("creation_by");
throw new BadRequestException("The client does not exist"); 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); riskAttentionMerchantsAMapper.save(attention);
} }
@Override @Override
public void updateAttentionMerchants(JSONObject account, String client_moniker) { public void disableAttentionMerchant(JSONObject manager, String clientMoniker) {
if (account == null) { if (manager == null) {
throw new BadRequestException("account not exists"); throw new BadRequestException("登录状态已过期,请清新登录再试");
} }
JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(client_moniker); JSONObject attentionMerchant = riskAttentionMerchantsAMapper.findByClientMoniker(clientMoniker);
if (attentionMerchant == null) { if (attentionMerchant == null) {
throw new BadRequestException("The client does not exist"); throw new BadRequestException("The client does not exist");
} }
attentionMerchant.put("is_valid", 0); attentionMerchant.put("is_valid", 0);
attentionMerchant.put("update_time",new Date()); attentionMerchant.put("last_update_date", new Date());
attentionMerchant.put("last_update_by", manager.getString("manager_id"));
riskAttentionMerchantsAMapper.update(attentionMerchant); riskAttentionMerchantsAMapper.update(attentionMerchant);
} }
} }

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

@ -48,15 +48,25 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th>Client Moniker</th> <th>Merchant Code</th>
<th>Create Time</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> <th>Operation</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="client in attentions"> <tr ng-repeat="client in attentions">
<td>{{client.client_moniker}}</td> <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> <td>
<a role="button" class="text-bold text-danger" <a role="button" class="text-bold text-danger"
ng-click="disableAttention(client.client_moniker)">Disable</a> ng-click="disableAttention(client.client_moniker)">Disable</a>

Loading…
Cancel
Save