[fix]风控对app端接口

master
lujian 6 years ago
parent bd3aec323f
commit 0322fc0570

@ -13,6 +13,9 @@ import au.com.royalpay.payment.manage.bill.core.BillOrderService;
import au.com.royalpay.payment.manage.bill.core.BillService;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientUpdateInfo;
import au.com.royalpay.payment.manage.riskbusiness.bean.RiskEventQuery;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService;
import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
@ -29,9 +32,11 @@ import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -75,6 +80,11 @@ public class RetailAppController {
@Resource
private AttachmentClient attachmentClient;
@Autowired
private RiskBusinessService riskBusinessService;
@Autowired
private RiskUploadService riskUploadService;
@RequestMapping(value = "/token", method = RequestMethod.PUT)
public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) {
@ -565,4 +575,63 @@ public class RetailAppController {
retailAppService.cancelCouponAccuessLog(accuess_id, remark);
}
/**
* app
* @param clientId
* @return
*/
@GetMapping(value = "/risk/business/notice")
public JSONObject riskNotice(@RequestParam("client_id") int clientId) {
return riskBusinessService.getNoticeInfo(clientId);
}
/**
* app
* @param riskEventQuery
* @return
*/
@GetMapping(value = "/risk/business/events")
public JSONObject getRiskEvents(RiskEventQuery riskEventQuery) {
JSONObject param = riskEventQuery.toJSON();
param.put("client_moniker", riskEventQuery.getClientMoniker());
return riskBusinessService.getRiskEventsByPage(param, null);
}
/**
* app
* @param riskId
* @return
*/
@GetMapping(value = "/risk/business/events/{risk_id}")
public JSONObject getRiskEventDetail(@PathVariable("risk_id") String riskId) {
JSONObject riskEvent = riskBusinessService.getRiskEventDetail(riskId);
List<JSONObject> tradeLogs = riskBusinessService.getRiskEventOrderList(riskEvent);
riskEvent.put("tradeLogs", tradeLogs);
return riskEvent;
}
/**
* app
* @param riskId
* @return
*/
@GetMapping(value = "/risk/business/events/{risk_id}/materials")
public JSONObject getRiskEventMaterialsRemark(@PathVariable("risk_id") String riskId) {
return riskBusinessService.getRiskEventMaterialsRemark(riskId);
}
/**
* app
* @param material
*/
@PostMapping(value = "/risk/business/events")
public void uploadMaterial(@RequestBody JSONObject material) {
riskUploadService.submitMaterial(material);
}
@RequestMapping(value = "/risk/business/upload/files", method = RequestMethod.POST)
public JSONObject uploadImage(@RequestParam MultipartFile file) throws Exception {
return attachmentClient.uploadFile(file,false);
}
}

@ -90,5 +90,23 @@ public interface RiskBusinessService {
*/
void completeEventRealOrderIds();
/**
*
* @param riskId
*/
void deleteRiskEvent(String riskId);
/**
*
* @param clientId
* @return
*/
JSONObject getNoticeInfo(int clientId);
/**
*
* @param riskId
* @return
*/
JSONObject getRiskEventMaterialsRemark(String riskId);
}

@ -30,6 +30,7 @@ import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
@ -46,6 +47,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
@ -113,7 +115,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
public JSONObject getRiskEventsByPage(JSONObject params, JSONObject manager) {
// 如果登录的角色是BD添加查询条件result_type为1,2,3,4order_type为1或者2
if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
if (manager != null && ManagerRole.BD_USER.hasRole(manager.getIntValue("role"))) {
params.put("bd_id", manager.getString("manager_id"));
List<Integer> orderTypes = Arrays.asList(RiskOrderTypeEnum.WECHAT_ORDER.getOrderType(),
RiskOrderTypeEnum.ALIPAY_ORDER.getOrderType());
@ -536,6 +538,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
@Override
@Transactional
public void completeEventRealOrderIds() {
List<JSONObject> riskEventList = getRiskEvents(null);
if (riskEventList != null && riskEventList.size() > 0) {
@ -727,4 +730,89 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
riskEventMapper.deleteRiskEvent(riskId);
}
@Override
public JSONObject getNoticeInfo(int clientId) {
JSONObject client = clientMapper.findClient(clientId);
if(client == null){
throw new InvalidShortIdException();
}
JSONObject params = new JSONObject();
params.put("is_send_client", 1);
List<Integer> resultTypes = Arrays.asList(RiskResultTypeEnum.SEND_EMAIL_TO_BD.getResultType(),
RiskResultTypeEnum.MATERIAL_NOT_PASS.getResultType());
params.put("result_types", resultTypes);
PageList<JSONObject> riskEventList = riskEventMapper.listRisksByPage(params, new PageBounds(Order.formString("create_time.desc")));
JSONObject result = new JSONObject();
result.put("notice_flag", false);
if (riskEventList != null && riskEventList.size() > 0) {
result.put("notice_flag", true);
}
return result;
}
@Override
public JSONObject getRiskEventMaterialsRemark(String riskId) {
JSONObject riskEvent = riskEventMapper.findById(riskId);
Integer orderType = riskEvent.getInteger("order_type");
List<JSONObject> materialItemList = new ArrayList<>();
List<String> materialsRemark = new ArrayList<>();
if (orderType.equals(RiskOrderTypeEnum.WECHAT_ORDER.getOrderType())) {
materialsRemark = Arrays.asList(
"1、物流公司发货单据照片 要求:每笔交易对应的物流单必须提供,且单据必须清晰可见\n" +
"Photos of logistics companies goods-delivery documents Requirement: The logistics order record corresponding to each transaction must be provided, and details of records should be clearly visible. ",
"2、用户购买虚拟物品需要提供聊天记录、订单信息、发货凭证截图、 虚拟物品最终消费场景(例如何种游戏、软件)、提供消费场景网址/下载链接 要求:每笔交易对应的截图必须清晰可见\n" +
"Users need to provide chat records, order information, screenshots of delivery documents, final consumption scenarios of virtual goods (such as games, software); provide consumer scene URL / download link. Requirement: The screenshot corresponding to each transaction must be clearly visible. ",
"3、购物小票/发票存根照片 照片应清晰,必须显示商户名称、商户地址、购物时间、物品名称 购物金额等\n" +
"Photos of shopping receipts/ invoice stubs Requirement: The photos should be clear and must show Merchant name, Business address, Transaction time, Product information, Quantity purchased, etc. ",
"4、显示商户门牌号码和店头名称的照片 要求:清晰可见,至少一张\n" +
"Photos of Merchant Street number & Merchant name Requirement: At least one visible photo ",
"5、显示商户营业场景所场内部情况如店内商品陈列、收银台等的照片 要求:照片清晰,且能清楚显示商户实际售卖物品或服务,至少三张\n" +
"Photos of internal environment of merchant business (such as in-store merchandise display, checkout counter, etc.) Requirements: The photos (at least three) showing merchant activities including actual selling-goods or services obviously ",
"6、其他图片\n" +
"Other pictures "
);
} else if (orderType.equals(RiskOrderTypeEnum.ALIPAY_ORDER.getOrderType())) {
String alipayMaterials = riskEvent.getString("alipay_materials");
if (StringUtils.isNotBlank(alipayMaterials)) {
List<JSONObject> alipayMaterialRemarkList = JSONObject.parseArray(alipayMaterials, JSONObject.class);
if (alipayMaterialRemarkList != null && alipayMaterialRemarkList.size() > 0) {
for (int i = 0; i < alipayMaterialRemarkList.size(); i++) {
materialsRemark.add(alipayMaterialRemarkList.get(i).getString("question" + (i + 1)));
}
}
}
} else if (orderType.equals(RiskOrderTypeEnum.ROYALPAY_ORDER.getOrderType())) {
materialsRemark = Arrays.asList(
"1.请解释相应的消费场景/业务模式,例如网站商城,扫码支付, 消费者到店支付等;\n" +
"Please explain the relative payment scenario/business activities, for example, online store, QR code payment, payment at the store, etc;",
"2.提供相应购物清单,订单小票(请提供与被查交易订单号相匹配的交易时间及金额的发票);\n" +
"Provide related shopping lists, invoices. (Please provide the invoices, amount of which matches that of the abnormal transaction);",
"3.提供相应的发货证明,报关单(若有消费者在国内购买,请提供物流单据或报关单);\n" +
"Relative proof of delivery, customs declaration (If the consumer purchased from China, please provide shipping receipt or customs declaration);",
"4.提供您的门店照片(门店照及店铺内的照片各一张, 一张可以看到商户名的门头照,一张可以看到相关商品或服务的店内照片);\n" +
"Photos of the store ( one of each front-store and in-store);",
"5.其他可以还原交易背景的资料,如和消费者的聊天记录等,来佐证被查单号交易的真实性;\n" +
"Other materials that can verify the payment scenario, for example, chatting history, to prove the truth of the transactions;",
"6、其他图片\n" +
"Other pictures"
);
}
JSONObject material = getRiskMaterial(riskEvent);
for (int i = 0; i < materialsRemark.size(); i++) {
JSONObject materialItem = new JSONObject();
materialItem.put("question" + (i + 1), materialsRemark.get(i));
if (material != null)
materialItem.put("file" + (i + 1), material.getJSONArray("file" + (i + 1)));
materialItemList.add(materialItem);
}
JSONObject result = new JSONObject();
result.put("material", materialItemList);
if (material != null && material.containsKey("description"))
result.put("description", material.getString("description"));
return result;
}
}

@ -30,6 +30,7 @@ import java.util.List;
*/
@RestController
@ManagerMapping(value = "/risk/business/", role = {ManagerRole.OPERATOR, ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.RISK_MANAGER})
//@RequestMapping(value = "/risk/business/")
public class RiskBusinessController {
@Autowired

@ -23,6 +23,9 @@
re.in_user_blacklist,
re.processed_remark,
re.create_time,
re.alipay_materials,
re.is_send_client,
re.real_order_ids,
sc.industry,
sc.short_name,
IFNULL(sc.sub_merchant_id, re.sub_merchant_id) sub_merchant_id
@ -66,10 +69,15 @@
<if test="risk_id != null">
AND re.risk_id = #{risk_id}
</if>
<if test="client_moniker != null">
AND re.client_moniker = #{client_moniker}
</if>
<if test="is_send_client != null">
AND re.is_send_client = #{is_send_client}
</if>
<if test="order_types != null">
<foreach collection="order_types" item="order_type_item" open="and re.order_type in (" close=")" separator=",">
#{order_type_item}
@ -93,19 +101,26 @@
<if test="order_ids != null">
AND re.order_ids LIKE CONCAT('%', #{order_ids}, '%')
</if>
<if test="sub_merchant_id != null">
AND sc.sub_merchant_id = #{sub_merchant_id}
</if>
<if test="industry != null">
AND sc.industry = #{industry}
</if>
<if test="receive_email_date != null">
AND re.receive_email_date = #{receive_email_date}
</if>
<if test="reply_email_date != null">
AND re.reply_email_date = #{reply_email_date}
</if>
<if test="real_order_ids != null">
AND re.real_order_ids = #{real_order_ids}
</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save